time-to-botec

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

index.js (2317B)


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