diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/README.md new file mode 100644 index 000000000000..45011d9ab203 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/README.md @@ -0,0 +1,143 @@ + + +# dapx + +> Add a scalar constant to each element in a double-precision floating-point ndarray. + +
+ +## Usage + +```javascript +var dapx = require( '@stdlib/blas/ext/base/ndarray/dapx' ); +``` + +#### dapx( arrays ) + +Adds a scalar constant to each element in a double-precision floating-point ndarray. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); + +var alpha = scalar2ndarray( 5.0, { + 'dtype': 'float64' +}); + +var out = dapx( [ x, alpha ] ); +// returns + +var bool = ( out === x ); +// returns true +``` + +The function has the following parameters: + +- **arrays**: array-like object containing an input ndarray and a zero-dimensional ndarray containing the scalar constant. + +Note that indexing is relative to the first index. To introduce an offset, use [`ndarray`][@stdlib/ndarray/ctor] view creation. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +// Initial array: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + +// Create an ndarray view: +var x = new ndarray( 'float64', xbuf, [ 3 ], [ 1 ], 2, 'row-major' ); + +var alpha = scalar2ndarray( 5.0, { + 'dtype': 'float64' +}); + +var out = dapx( [ x, alpha ] ); +// returns +``` + +
+ + + +
+ +## Notes + +- The function **mutates** the input ndarray. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var dapx = require( '@stdlib/blas/ext/base/ndarray/dapx' ); + +var xbuf = discreteUniform( 10, 0, 100, { + 'dtype': 'float64' +}); +var x = new ndarray( 'float64', xbuf, [ 10 ], [ 1 ], 0, 'row-major' ); + +console.log( x.data ); + +var alpha = scalar2ndarray( 5.0, { + 'dtype': 'float64' +}); + +dapx( [ x, alpha ] ); + +console.log( x.data ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/benchmark/benchmark.js new file mode 100644 index 000000000000..c42df3ef7d05 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/benchmark/benchmark.js @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var pkg = require( './../package.json' ).name; +var dapx = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var alpha; + var xbuf; + var x; + + xbuf = discreteUniform( len, -100, 100, { + 'dtype': 'float64' + }); + x = new ndarray( 'float64', xbuf, [ len ], [ 1 ], 0, 'row-major' ); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float64' + }); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dapx( [ x, alpha ] ); + if ( isnanf( z.data[ i % len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z.data[ i % len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/docs/repl.txt new file mode 100644 index 000000000000..ca1dfa374711 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/docs/repl.txt @@ -0,0 +1,27 @@ +{{alias}}( arrays ) + + Adds a scalar constant to each element in a double-precision floating- + point ndarray. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing an input ndarray and a zero-dimensional + ndarray containing the scalar constant. + + Returns + ------- + out: ndarray + Input ndarray. + + Examples + -------- + > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var x = {{alias:@stdlib/ndarray/ctor}}( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); + > var alpha = {{alias:@stdlib/ndarray/from-scalar}}( 5.0, { 'dtype': 'float64' } ); + > {{alias}}( [ x, alpha ] ) + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/docs/types/index.d.ts new file mode 100644 index 000000000000..3a2693bbe459 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/docs/types/index.d.ts @@ -0,0 +1,51 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { float64ndarray } from '@stdlib/types/ndarray'; + +/** +* Adds a scalar constant to each element in a double-precision floating-point ndarray. +* +* @param arrays - array-like object containing an input ndarray and a zero-dimensional ndarray containing the scalar constant +* @returns input ndarray +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var alpha = scalar2ndarray( 5.0, { +* 'dtype': 'float64' +* }); +* +* var out = dapx( [ x, alpha ] ); +* // returns +*/ +declare function dapx( arrays: ArrayLike ): float64ndarray; + + +// EXPORTS // + +export = dapx; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/docs/types/test.ts new file mode 100644 index 000000000000..635361218eb9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/docs/types/test.ts @@ -0,0 +1,61 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import dapx = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float64' + }); + const alpha = zeros( [], { + 'dtype': 'float64' + }); + + dapx( [ x, alpha ] ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + dapx( '10' ); // $ExpectError + dapx( 10 ); // $ExpectError + dapx( true ); // $ExpectError + dapx( false ); // $ExpectError + dapx( null ); // $ExpectError + dapx( undefined ); // $ExpectError + dapx( [] ); // $ExpectError + dapx( {} ); // $ExpectError + dapx( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float64' + }); + const alpha = zeros( [], { + 'dtype': 'float64' + }); + + dapx(); // $ExpectError + dapx( [ x, alpha ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/examples/index.js new file mode 100644 index 000000000000..6e2ee86498c8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/examples/index.js @@ -0,0 +1,39 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var dapx = require( './../lib' ); + +var xbuf = discreteUniform( 10, 0, 100, { + 'dtype': 'float64' +}); +var x = new ndarray( 'float64', xbuf, [ 10 ], [ 1 ], 0, 'row-major' ); + +console.log( x.data ); + +var alpha = scalar2ndarray( 5.0, { + 'dtype': 'float64' +}); + +dapx( [ x, alpha ] ); + +console.log( x.data ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/lib/index.js new file mode 100644 index 000000000000..0144666ea6e9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/lib/index.js @@ -0,0 +1,50 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Add a scalar constant to each element in a double-precision floating-point ndarray. +* +* @module @stdlib/blas/ext/base/ndarray/dapx +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var dapx = require( '@stdlib/blas/ext/base/ndarray/dapx' ); +* +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var alpha = scalar2ndarray( 5.0, { +* 'dtype': 'float64' +* }); +* +* var out = dapx( [ x, alpha ] ); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/lib/main.js new file mode 100644 index 000000000000..e90e6e95fd3a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/lib/main.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); +var strided = require( '@stdlib/blas/ext/base/dapx' ).ndarray; +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); + + +// MAIN // + +/** +* Adds a scalar constant to each element in a double-precision floating-point ndarray. +* +* @param {ArrayLikeObject} arrays - array-like object containing an input ndarray and a zero-dimensional ndarray containing the scalar constant +* @returns {Object} input ndarray +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var alpha = scalar2ndarray( 5.0, { +* 'dtype': 'float64' +* }); +* +* var out = dapx( [ x, alpha ] ); +* // returns +*/ +function dapx( arrays ) { + var x = arrays[ 0 ]; + + if ( numelDimension( x, 0 ) <= 0 ) { + return x; + } + strided( numelDimension( x, 0 ), ndarraylike2scalar( arrays[ 1 ] ), getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len + return x; +} + + +// EXPORTS // + +module.exports = dapx; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/package.json new file mode 100644 index 000000000000..07bfcd990e93 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/package.json @@ -0,0 +1,76 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/dapx", + "version": "0.0.0", + "description": "Add a scalar constant to each element in a double-precision floating-point ndarray.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 1", + "dapx", + "linear", + "algebra", + "subroutines", + "ndarray", + "vector", + "array", + "multidimensional", + "add", + "constant", + "plus", + "increment", + "augment", + "float64", + "double", + "float64array" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/test/test.js new file mode 100644 index 000000000000..5f7d8a036158 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dapx/test/test.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var dapx = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dapx, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function adds a scalar constant to each element in a double-precision floating-point ndarray', function test( t ) { + var expected; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); + + expected = new Float64Array( [ 6.0, 7.0, 8.0, 9.0 ] ); + + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float64' + }); + + dapx( [ x, alpha ] ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the input ndarray', function test( t ) { + var alpha; + var xbuf; + var x; + var y; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); + + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float64' + }); + + y = dapx( [ x, alpha ] ); + + t.strictEqual( y, x, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports ndarrays with negative strides', function test( t ) { + var expected; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 4 ], [ -1 ], 3, 'row-major' ); + + expected = new Float64Array( [ 6.0, 7.0, 8.0, 9.0 ] ); + + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float64' + }); + + dapx( [ x, alpha ] ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports ndarrays with an offset', function test( t ) { + var expected; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + x = new ndarray( 'float64', xbuf, [ 3 ], [ 1 ], 2, 'row-major' ); + + expected = new Float64Array( [ 1.0, 2.0, 8.0, 9.0, 10.0 ] ); + + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float64' + }); + + dapx( [ x, alpha ] ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports zero-length ndarrays', function test( t ) { + var expected; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [] ); + x = new ndarray( 'float64', xbuf, [ 0 ], [ 1 ], 0, 'row-major' ); + + expected = new Float64Array( [] ); + + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float64' + }); + + dapx( [ x, alpha ] ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports adding zero', function test( t ) { + var expected; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); + + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + alpha = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + dapx( [ x, alpha ] ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative constants', function test( t ) { + var expected; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); + + expected = new Float64Array( [ -4.0, -3.0, -2.0, -1.0 ] ); + + alpha = scalar2ndarray( -5.0, { + 'dtype': 'float64' + }); + + dapx( [ x, alpha ] ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +});