diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/README.md new file mode 100644 index 000000000000..98e2e23036da --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/README.md @@ -0,0 +1,123 @@ + + +# dfillNaN + +> Replace elements in a one-dimensional double-precision floating-point ndarray equal to `NaN` with a specified scalar constant. + +
+ +
+ + + +
+ +## Usage + +```javascript +var dfillNaN = require( '@stdlib/blas/ext/base/ndarray/dfill-nan' ); +``` + +#### dfillNaN( arrays ) + +Replaces elements in a one-dimensional double-precision floating-point ndarray equal to `NaN` with a specified scalar constant. + +```javascript +var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +var x = new Float64Vector( [ NaN, -2.0, 3.0, NaN, 4.0, -6.0 ] ); + +var alpha = scalar2ndarray( 0.0, { + 'dtype': 'float64' +}); + +dfillNaN( [ x, alpha ] ); +// x => [ 0.0, -2.0, 3.0, 0.0, 4.0, -6.0 ] +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray containing the scalar constant. + +
+ + + +
+ +## Notes + +- The input ndarray is modified **in-place** (i.e., the input ndarray is **mutated**). + +
+ + + +
+ +## Examples + + + +```javascript +var nans = require( '@stdlib/ndarray/nans' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); +var dfillNaN = require( '@stdlib/blas/ext/base/ndarray/dfill-nan' ); + +var opts = { + 'dtype': 'float64' +}; + +var x = nans( [ 10 ], opts ); +console.log( ndarray2array( x ) ); + +var alpha = scalar2ndarray( 5.0, opts ); +console.log( 'Alpha: %d', ndarraylike2scalar( alpha ) ); + +dfillNaN( [ x, alpha ] ); +console.log( ndarray2array( x ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/benchmark/benchmark.js new file mode 100644 index 000000000000..1e1fef86791a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/benchmark/benchmark.js @@ -0,0 +1,123 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 fillBy = require( '@stdlib/ndarray/fill-by' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dfillNaN = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Returns an array element. +* +* @private +* @param {number} value - current array element +* @param {NonNegativeIntegerArray} indices - current array element indices +* @returns {number} array element +*/ +function clbk( value, indices ) { + if ( indices[ 0 ]%3 === 0 ) { + return NaN; + } + return value; +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var alpha; + var x; + + x = fillBy( zeros( [ len ], options ), clbk ); + alpha = scalar2ndarray( 0.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = dfillNaN( [ x, alpha ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + 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( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/docs/repl.txt new file mode 100644 index 000000000000..835b953e9e02 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/docs/repl.txt @@ -0,0 +1,31 @@ + +{{alias}}( arrays ) + Replaces elements in a one-dimensional double-precision floating-point + ndarray equal to `NaN` with a specified scalar constant. + + The input ndarray is modified *in-place* (i.e., the input ndarray is + *mutated*). + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray containing the scalar constant. + + Returns + ------- + out: ndarray + Input ndarray. + + Examples + -------- + > var x = new {{alias:@stdlib/ndarray/vector/float64}}( [ NaN, -2.0, 3.0, NaN, 4.0, -6.0 ] ); + > var alpha = {{alias:@stdlib/ndarray/from-scalar}}( 0.0, { 'dtype': 'float64' } ); + > {{alias}}( [ x, alpha ] ) + [ 0.0, -2.0, 3.0, 0.0, 4.0, -6.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/docs/types/index.d.ts new file mode 100644 index 000000000000..220ed8819d33 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/docs/types/index.d.ts @@ -0,0 +1,56 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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, typedndarray } from '@stdlib/types/ndarray'; + +/** +* Replaces elements in a one-dimensional double-precision floating-point ndarray equal to `NaN` with a specified scalar constant. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a zero-dimensional ndarray containing the scalar constant. +* +* @param arrays - array-like object containing ndarrays +* @returns input ndarray +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Float64Vector( [ NaN, -2.0, 3.0, NaN, 4.0, -6.0 ] ); +* +* var alpha = scalar2ndarray( 0.0, { +* 'dtype': 'float64' +* }); +* +* var out = dfillNaN( [ x, alpha ] ); +* // returns [ 0.0, -2.0, 3.0, 0.0, 4.0, -6.0 ] +*/ +declare function dfillNaN( arrays: [ float64ndarray, typedndarray ] ): float64ndarray; + + +// EXPORTS // + +export = dfillNaN; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/docs/types/test.ts new file mode 100644 index 000000000000..3be4f921a291 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/docs/types/test.ts @@ -0,0 +1,64 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +import dfillNaN = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float64' + }); + const alpha = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + dfillNaN( [ x, alpha ] ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + dfillNaN( '10' ); // $ExpectError + dfillNaN( 5 ); // $ExpectError + dfillNaN( true ); // $ExpectError + dfillNaN( false ); // $ExpectError + dfillNaN( null ); // $ExpectError + dfillNaN( undefined ); // $ExpectError + dfillNaN( [] ); // $ExpectError + dfillNaN( {} ); // $ExpectError + dfillNaN( ( 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 = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + dfillNaN(); // $ExpectError + dfillNaN( [ x, alpha ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/examples/index.js new file mode 100644 index 000000000000..8c063465c54a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/examples/index.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 nans = require( '@stdlib/ndarray/nans' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); +var dfillNaN = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; + +var x = nans( [ 10 ], opts ); +console.log( ndarray2array( x ) ); + +var alpha = scalar2ndarray( 5.0, opts ); +console.log( 'Alpha: %d', ndarraylike2scalar( alpha ) ); + +dfillNaN( [ x, alpha ] ); +console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/lib/index.js new file mode 100644 index 000000000000..89023c0db3be --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/lib/index.js @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* Replace elements in a one-dimensional double-precision floating-point ndarray equal to `NaN` with a specified scalar constant. +* +* @module @stdlib/blas/ext/base/ndarray/dfill-nan +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var dfillNaN = require( '@stdlib/blas/ext/base/ndarray/dfill-nan' ); +* +* var x = new Float64Vector( [ NaN, -2.0, 3.0, NaN, 4.0, -6.0 ] ); +* +* var alpha = scalar2ndarray( 0.0, { +* 'dtype': 'float64' +* }); +* +* var out = dfillNaN( [ x, alpha ] ); +* // returns [ 0.0, -2.0, 3.0, 0.0, 4.0, -6.0 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/lib/main.js new file mode 100644 index 000000000000..39b5b153a7f3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/lib/main.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var strided = require( '@stdlib/blas/ext/base/dfill-nan' ).ndarray; +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); + + +// MAIN // + +/** +* Replaces elements in a one-dimensional double-precision floating-point ndarray equal to `NaN` with a specified scalar constant. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a zero-dimensional ndarray containing the scalar constant. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {ndarray} input ndarray +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Float64Vector( [ NaN, -2.0, 3.0, NaN, 4.0, -6.0 ] ); +* +* var alpha = scalar2ndarray( 0.0, { +* 'dtype': 'float64' +* }); +* +* var out = dfillNaN( [ x, alpha ] ); +* // returns [ 0.0, -2.0, 3.0, 0.0, 4.0, -6.0 ] +*/ +function dfillNaN( arrays ) { + var alpha; + var x; + + x = arrays[ 0 ]; + alpha = ndarraylike2scalar( arrays[ 1 ] ); + strided( numelDimension( x, 0 ), alpha, getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len + return x; +} + + +// EXPORTS // + +module.exports = dfillNaN; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/package.json new file mode 100644 index 000000000000..ab4c26f3754a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/dfill-nan", + "version": "0.0.0", + "description": "Replace elements in a one-dimensional double-precision floating-point ndarray equal to NaN with a specified scalar constant.", + "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", + "extended", + "ext", + "fill", + "nan", + "not-a-number", + "replace", + "assign", + "set", + "strided", + "array", + "ndarray", + "float64", + "double" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/test/test.js new file mode 100644 index 000000000000..052f7e399208 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dfill-nan/test/test.js @@ -0,0 +1,187 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var dfillNaN = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Float64Array} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, length, stride, offset ) { + return new ndarray( 'float64', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dfillNaN, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function replaces elements equal to `NaN`', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [ NaN, -2.0, 3.0, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 6, 1, 0 ); + alpha = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + actual = dfillNaN( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Float64Array( [ 0.0, -2.0, 3.0, 0.0, 4.0, -6.0 ] ); + t.strictEqual( isSameFloat64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an input ndarray having a non-unit stride', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [ NaN, -2.0, 3.0, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 3, 2, 0 ); + alpha = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + actual = dfillNaN( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Float64Array( [ 0.0, -2.0, 3.0, NaN, 4.0, -6.0 ] ); + t.strictEqual( isSameFloat64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an input ndarray having a negative stride', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [ NaN, -2.0, 3.0, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 3, -2, 4 ); + alpha = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + actual = dfillNaN( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Float64Array( [ 0.0, -2.0, 3.0, NaN, 4.0, -6.0 ] ); + t.strictEqual( isSameFloat64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an input ndarray having a non-zero offset', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [ NaN, -2.0, 3.0, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 3, 1, 3 ); + alpha = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + actual = dfillNaN( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Float64Array( [ NaN, -2.0, 3.0, 0.0, 4.0, -6.0 ] ); + t.strictEqual( isSameFloat64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if none of the elements are equal to `NaN`, the function returns the input ndarray unchanged', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = vector( xbuf, 4, 1, 0 ); + alpha = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + actual = dfillNaN( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + t.strictEqual( isSameFloat64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the input ndarray unchanged when the input ndarray is empty', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = new Float64Array( [] ); + x = vector( xbuf, 0, 1, 0 ); + alpha = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + actual = dfillNaN( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Float64Array( [] ); + t.strictEqual( isSameFloat64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +});