time-to-botec

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

index.js (1963B)


      1 /**
      2 * @license Apache-2.0
      3 *
      4 * Copyright (c) 2021 The Stdlib Authors.
      5 *
      6 * Licensed under the Apache License, Version 2.0 (the "License");
      7 * you may not use this file except in compliance with the License.
      8 * You may obtain a copy of the License at
      9 *
     10 *    http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing, software
     13 * distributed under the License is distributed on an "AS IS" BASIS,
     14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15 * See the License for the specific language governing permissions and
     16 * limitations under the License.
     17 */
     18 
     19 'use strict';
     20 
     21 /**
     22 * Apply a unary callback to elements in an input ndarray and assign results to elements in an output ndarray.
     23 *
     24 * @module @stdlib/ndarray/base/unary
     25 *
     26 * @example
     27 * var Float64Array = require( '@stdlib/array/float64' );
     28 * var unary = require( '@stdlib/ndarray/base/unary' );
     29 *
     30 * function scale( x ) {
     31 *     return x * 10.0;
     32 * }
     33 *
     34 * // Create data buffers:
     35 * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
     36 * var ybuf = new Float64Array( 6 );
     37 *
     38 * // Define the shape of the input and output arrays:
     39 * var shape = [ 3, 1, 2 ];
     40 *
     41 * // Define the array strides:
     42 * var sx = [ 4, 4, 1 ];
     43 * var sy = [ 2, 2, 1 ];
     44 *
     45 * // Define the index offsets:
     46 * var ox = 1;
     47 * var oy = 0;
     48 *
     49 * // Create the input and output ndarray-like objects:
     50 * var x = {
     51 *     'dtype': 'float64',
     52 *     'data': xbuf,
     53 *     'shape': shape,
     54 *     'strides': sx,
     55 *     'offset': ox,
     56 *     'order': 'row-major'
     57 * };
     58 * var y = {
     59 *     'dtype': 'float64',
     60 *     'data': ybuf,
     61 *     'shape': shape,
     62 *     'strides': sy,
     63 *     'offset': oy,
     64 *     'order': 'row-major'
     65 * };
     66 *
     67 * // Apply the unary function:
     68 * unary( [ x, y ], scale );
     69 *
     70 * console.log( y.data );
     71 * // => <Float64Array>[ 20.0, 30.0, 60.0, 70.0, 100.0, 110.0 ]
     72 */
     73 
     74 // MODULES //
     75 
     76 var unary = require( './main.js' );
     77 
     78 
     79 // EXPORTS //
     80 
     81 module.exports = unary;