index.js (2013B)
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 function accepting and returning single-precision floating-point numbers to each element in a single-precision floating-point strided input array and assign each result to an element in a single-precision floating-point strided output array. 23 * 24 * @module @stdlib/strided/base/smap 25 * 26 * @example 27 * var Float32Array = require( '@stdlib/array/float32' ); 28 * var smap = require( '@stdlib/strided/base/smap' ); 29 * 30 * function scale( x ) { 31 * return x * 10.0; 32 * } 33 * 34 * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); 35 * var y = new Float32Array( x.length ); 36 * 37 * smap( x.length, x, 1, y, 1, scale ); 38 * 39 * console.log( y ); 40 * // => <Float32Array>[ 10.0, 20.0, 30.0, 40.0, 50.0 ] 41 * 42 * @example 43 * var Float32Array = require( '@stdlib/array/float32' ); 44 * var smap = require( '@stdlib/strided/base/smap' ); 45 * 46 * function scale( x ) { 47 * return x * 10.0; 48 * } 49 * 50 * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); 51 * var y = new Float32Array( x.length ); 52 * 53 * smap.ndarray( x.length, x, 1, 0, y, 1, 0, scale ); 54 * 55 * console.log( y ); 56 * // => <Float32Array>[ 10.0, 20.0, 30.0, 40.0, 50.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;