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