time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (3435B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # Convert
     22 
     23 > Convert an array to the same data type as a second input array.
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <!-- Package usage documentation. -->
     34 
     35 <section class="usage">
     36 
     37 ## Usage
     38 
     39 ```javascript
     40 var convertArraySame = require( '@stdlib/array/convert-same' );
     41 ```
     42 
     43 #### convertArraySame( x, y )
     44 
     45 Converts an `array` to the same data type as a second input `array`.
     46 
     47 ```javascript
     48 var Float32Array = require( '@stdlib/array/float32' );
     49 
     50 var y = new Float32Array( 0 );
     51 
     52 var x = [ 1.0, 2.0, 3.0 ];
     53 var out = convertArraySame( x, y );
     54 // returns <Float32Array>[ 1.0, 2.0, 3.0 ]
     55 ```
     56 
     57 The function supports input arrays having the following data types:
     58 
     59 -   `float32`: single-precision floating-point numbers.
     60 -   `float64`: double-precision floating-point numbers.
     61 -   `generic`: values of any type.
     62 -   `int16`: signed 16-bit integers.
     63 -   `int32`: signed 32-bit integers.
     64 -   `int8`: signed 8-bit integers.
     65 -   `uint16`: unsigned 16-bit integers.
     66 -   `uint32`: unsigned 32-bit integers.
     67 -   `uint8`: unsigned 8-bit integers.
     68 -   `uint8c`: unsigned clamped 8-bit integers.
     69 
     70 </section>
     71 
     72 <!-- /.usage -->
     73 
     74 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     75 
     76 <section class="notes">
     77 
     78 </section>
     79 
     80 <!-- /.notes -->
     81 
     82 <!-- Package usage examples. -->
     83 
     84 <section class="examples">
     85 
     86 ## Examples
     87 
     88 <!-- eslint-disable stdlib/new-cap-error -->
     89 
     90 <!-- eslint no-undef: "error" -->
     91 
     92 ```javascript
     93 var dtypes = require( '@stdlib/array/dtypes' );
     94 var ctors = require( '@stdlib/array/ctors' );
     95 var randu = require( '@stdlib/random/base/randu' );
     96 var floor = require( '@stdlib/math/base/special/floor' );
     97 var convertArraySame = require( '@stdlib/array/convert-same' );
     98 
     99 // Create a generic array:
    100 var x = [];
    101 var i;
    102 for ( i = 0; i < 5; i++ ) {
    103     x.push( floor( randu()*1.0e25 ) - 5.0e24 );
    104 }
    105 
    106 // Get a list of array data types:
    107 var DTYPES = dtypes();
    108 
    109 // Convert the generic array to each array data type:
    110 var ctor;
    111 var out;
    112 var y;
    113 for ( i = 0; i < DTYPES.length; i++ ) {
    114     ctor = ctors( DTYPES[ i ] );
    115     y = new ctor( 0 );
    116     out = convertArraySame( x, y );
    117     console.log( out );
    118 }
    119 ```
    120 
    121 </section>
    122 
    123 <!-- /.examples -->
    124 
    125 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    126 
    127 <section class="references">
    128 
    129 </section>
    130 
    131 <!-- /.references -->
    132 
    133 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    134 
    135 <section class="links">
    136 
    137 </section>
    138 
    139 <!-- /.links -->