time-to-botec

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

index.js (2323B)


      1 /**
      2 * @license Apache-2.0
      3 *
      4 * Copyright (c) 2020 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 a strided input array according to elements in a strided mask array and assign results to elements in a strided output array.
     23 *
     24 * @module @stdlib/strided/base/mskunary
     25 *
     26 * @example
     27 * var Float64Array = require( '@stdlib/array/float64' );
     28 * var Uint8Array = require( '@stdlib/array/uint8' );
     29 * var mskunary = require( '@stdlib/strided/base/mskunary' );
     30 *
     31 * function scale( x ) {
     32 *     return x * 10.0;
     33 * }
     34 *
     35 * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
     36 * var m = new Uint8Array( [ 0, 0, 1, 0, 0 ] );
     37 * var y = new Float64Array( x.length );
     38 *
     39 * var shape = [ x.length ];
     40 * var strides = [ 1, 1, 1 ];
     41 *
     42 * mskunary( [ x, m, y ], shape, strides, scale );
     43 *
     44 * console.log( y );
     45 * // => <Float64Array>[ 10.0, 20.0, 0.0, 40.0, 50.0 ]
     46 *
     47 * @example
     48 * var Float64Array = require( '@stdlib/array/float64' );
     49 * var Uint8Array = require( '@stdlib/array/uint8' );
     50 * var mskunary = require( '@stdlib/strided/base/mskunary' );
     51 *
     52 * function scale( x ) {
     53 *     return x * 10.0;
     54 * }
     55 *
     56 * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
     57 * var m = new Uint8Array( [ 0, 0, 1, 0, 0 ] );
     58 * var y = new Float64Array( x.length );
     59 *
     60 * var shape = [ x.length ];
     61 * var strides = [ 1, 1, 1 ];
     62 * var offsets = [ 0, 0, 0 ];
     63 *
     64 * mskunary.ndarray( [ x, m, y ], shape, strides, offsets, scale );
     65 *
     66 * console.log( y );
     67 * // => <Float64Array>[ 10.0, 20.0, 0.0, 40.0, 50.0 ]
     68 */
     69 
     70 // MODULES //
     71 
     72 var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
     73 var mskunary = require( './main.js' );
     74 var ndarray = require( './ndarray.js' );
     75 
     76 
     77 // MAIN //
     78 
     79 setReadOnly( mskunary, 'ndarray', ndarray );
     80 
     81 
     82 // EXPORTS //
     83 
     84 module.exports = mskunary;