time-to-botec

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

index.js (1884B)


      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 function to each element retrieved from a strided input array according to a callback function and assign each result to an element in a strided output array.
     23 *
     24 * @module @stdlib/strided/base/map-by
     25 *
     26 * @example
     27 * var abs = require( '@stdlib/math/base/special/abs' );
     28 * var mapBy = require( '@stdlib/strided/base/map-by' );
     29 *
     30 * function accessor( v ) {
     31 *     return v * 2.0;
     32 * }
     33 *
     34 * var x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ];
     35 * var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
     36 *
     37 * mapBy( x.length, x, 1, y, 1, abs, accessor );
     38 *
     39 * console.log( y );
     40 * // => [ 2.0, 4.0, 6.0, 8.0, 10.0 ]
     41 *
     42 * @example
     43 * var abs = require( '@stdlib/math/base/special/abs' );
     44 * var mapBy = require( '@stdlib/strided/base/map-by' );
     45 *
     46 * function accessor( v ) {
     47 *     return v * 2.0;
     48 * }
     49 *
     50 * var x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ];
     51 * var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
     52 *
     53 * mapBy.ndarray( x.length, x, 1, 0, y, 1, 0, abs, accessor );
     54 *
     55 * console.log( y );
     56 * // => [ 2.0, 4.0, 6.0, 8.0, 10.0 ]
     57 */
     58 
     59 // MODULES //
     60 
     61 var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
     62 var main = require( './main.js' );
     63 var ndarray = require( './ndarray.js' );
     64 
     65 
     66 // MAIN //
     67 
     68 setReadOnly( main, 'ndarray', ndarray );
     69 
     70 
     71 // EXPORTS //
     72 
     73 module.exports = main;