From bd58519b3bbb96cf0edecaf5601f57f772f02b72 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 4 Oct 2026 21:29:45 +0500 Subject: [PATCH 1/2] feat: add blas/ext/base/ndarray/cfill-nan --- .../blas/ext/base/ndarray/cfill-nan/README.md | 150 +++++ .../ndarray/cfill-nan/benchmark/benchmark.js | 131 +++++ .../ext/base/ndarray/cfill-nan/docs/repl.txt | 43 ++ .../ndarray/cfill-nan/docs/types/index.d.ts | 70 +++ .../base/ndarray/cfill-nan/docs/types/test.ts | 77 +++ .../base/ndarray/cfill-nan/examples/index.js | 52 ++ .../ext/base/ndarray/cfill-nan/lib/index.js | 57 ++ .../ext/base/ndarray/cfill-nan/lib/main.js | 101 ++++ .../ext/base/ndarray/cfill-nan/package.json | 73 +++ .../ext/base/ndarray/cfill-nan/test/test.js | 535 ++++++++++++++++++ 10 files changed, 1289 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/test/test.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/README.md new file mode 100644 index 000000000000..a57c55847044 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/README.md @@ -0,0 +1,150 @@ + + +# cfillNaN + +> Replace elements in a one-dimensional single-precision complex floating-point ndarray equal to `NaN` with a specified scalar constant. + +
+ +
+ + + +
+ +## Usage + +```javascript +var cfillNaN = require( '@stdlib/blas/ext/base/ndarray/cfill-nan' ); +``` + +#### cfillNaN( arrays ) + +Replaces elements in a one-dimensional single-precision complex floating-point ndarray equal to `NaN` with a specified scalar constant. + +```javascript +var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); + +var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + +var alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' +}); + +var start = scalar2ndarray( 0, { + 'dtype': 'generic' +}); + +var end = scalar2ndarray( 2, { + 'dtype': 'generic' +}); + +cfillNaN( [ x, alpha, start, end ] ); +// x => [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ NaN, NaN ], [ 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. + - a zero-dimensional ndarray containing the starting index (inclusive). + - a zero-dimensional ndarray containing the ending index (exclusive). + +
+ + + +
+ +## Notes + +- The input ndarray is modified **in-place** (i.e., the input ndarray is **mutated**). +- If a specified `start` or `end` index is negative, the function resolves the respective index by counting backward from the last element (where `-1` refers to the last element). +- A complex number is considered `NaN` if either the real or imaginary component is `NaN`. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var cfillNaN = require( '@stdlib/blas/ext/base/ndarray/cfill-nan' ); + +var opts = { + 'dtype': 'float32' +}; + +var x = new Complex64Vector( discreteUniform( 20, 0, 2, opts ) ); +console.log( ndarray2array( x ) ); + +var alpha = scalar2ndarray( new Complex64( 5.0, 5.0 ), { + 'dtype': 'complex64' +}); +console.log( 'Alpha:', ndarraylike2scalar( alpha ) ); + +var start = scalar2ndarray( 5, { + 'dtype': 'generic' +}); +console.log( 'Start Index:', ndarraylike2scalar( start ) ); + +var end = scalar2ndarray( 15, { + 'dtype': 'generic' +}); +console.log( 'End Index:', ndarraylike2scalar( end ) ); + +cfillNaN( [ x, alpha, start, end ] ); +console.log( ndarray2array( x ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/benchmark/benchmark.js new file mode 100644 index 000000000000..40af26e8f362 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/benchmark/benchmark.js @@ -0,0 +1,131 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var cfillNaN = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var alpha; + var start; + var xbuf; + var end; + var x; + var i; + + xbuf = uniform( len*2, -100.0, 100.0, options ); + for ( i = 0; i < len*2; i += 6 ) { + xbuf[ i ] = NaN; + xbuf[ i+1 ] = NaN; + } + x = new Complex64Vector( xbuf.buffer ); + alpha = [ + scalar2ndarray( new Complex64( 1.0, 1.0 ), { + 'dtype': 'complex64' + }), + scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }) + ]; + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( len, { + 'dtype': 'generic' + }); + 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 = cfillNaN( [ x, alpha[ i%2 ], start, end ] ); + 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/cfill-nan/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/repl.txt new file mode 100644 index 000000000000..c63206805277 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/repl.txt @@ -0,0 +1,43 @@ + +{{alias}}( arrays ) + Replaces elements in a one-dimensional single-precision complex 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*). + + If a specified `start` or `end` index is negative, the function resolves + the respective index by counting backward from the last element (where `-1` + refers to the last element). + + A complex number is considered `NaN` if either the real or imaginary + component is `NaN`. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray containing the scalar constant. + - a zero-dimensional ndarray containing the starting index (inclusive). + - a zero-dimensional ndarray containing the ending index (exclusive). + + Returns + ------- + out: ndarray + Input ndarray. + + Examples + -------- + > var x = new {{alias:@stdlib/ndarray/vector/complex64}}( [ NaN, NaN, -2.0, 3.0 ] ); + > var a = new {{alias:@stdlib/complex/float32/ctor}}( 0.0, 0.0 ); + > var alpha = {{alias:@stdlib/ndarray/from-scalar}}( a, { 'dtype': 'complex64' } ); + > var st = {{alias:@stdlib/ndarray/from-scalar}}( 0, { 'dtype': 'generic' } ); + > var en = {{alias:@stdlib/ndarray/from-scalar}}( 2, { 'dtype': 'generic' } ); + > {{alias}}( [ x, alpha, st, en ] ) + [ [ 0.0, 0.0 ], [ -2.0, 3.0 ] ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/index.d.ts new file mode 100644 index 000000000000..110074ae2043 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/index.d.ts @@ -0,0 +1,70 @@ +/* +* @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 { complex64ndarray, typedndarray } from '@stdlib/types/ndarray'; +import { Complex64 } from '@stdlib/types/complex'; + +/** +* Replaces elements in a one-dimensional single-precision complex 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. +* - a zero-dimensional ndarray containing the starting index (inclusive). +* - a zero-dimensional ndarray containing the ending index (exclusive). +* +* - A complex number is considered `NaN` if either the real or imaginary component is `NaN`. +* +* @param arrays - array-like object containing ndarrays +* @returns input ndarray +* +* @example +* var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); +* +* var alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { +* 'dtype': 'complex64' +* }); +* +* var start = scalar2ndarray( 0, { +* 'dtype': 'generic' +* }); +* +* var end = scalar2ndarray( 2, { +* 'dtype': 'generic' +* }); +* +* var out = cfillNaN( [ x, alpha, start, end ] ); +* // returns [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ NaN, NaN ], [ 4.0, -6.0 ] ] +*/ +declare function cfillNaN( arrays: [ complex64ndarray, typedndarray, typedndarray, typedndarray ] ): complex64ndarray; + + +// EXPORTS // + +export = cfillNaN; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/test.ts new file mode 100644 index 000000000000..92172d5c5f9e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/test.ts @@ -0,0 +1,77 @@ +/* +* @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 Complex64 = require( '@stdlib/complex/float32/ctor' ); +import cfillNaN = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 10 ], { + 'dtype': 'complex64' + }); + const alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + const start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + const end = scalar2ndarray( 10, { + 'dtype': 'generic' + }); + + cfillNaN( [ x, alpha, start, end ] ); // $ExpectType complex64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + cfillNaN( '10' ); // $ExpectError + cfillNaN( 5 ); // $ExpectError + cfillNaN( true ); // $ExpectError + cfillNaN( false ); // $ExpectError + cfillNaN( null ); // $ExpectError + cfillNaN( undefined ); // $ExpectError + cfillNaN( [] ); // $ExpectError + cfillNaN( {} ); // $ExpectError + cfillNaN( ( 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': 'complex64' + }); + const alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + const start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + const end = scalar2ndarray( 10, { + 'dtype': 'generic' + }); + + cfillNaN(); // $ExpectError + cfillNaN( [ x, alpha, start, end ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/examples/index.js new file mode 100644 index 000000000000..a75f8116bc48 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/examples/index.js @@ -0,0 +1,52 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var cfillNaN = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var x = new Complex64Vector( discreteUniform( 20, 0, 2, opts ) ); +console.log( ndarray2array( x ) ); + +var alpha = scalar2ndarray( new Complex64( 5.0, 5.0 ), { + 'dtype': 'complex64' +}); +console.log( 'Alpha:', ndarraylike2scalar( alpha ) ); + +var start = scalar2ndarray( 5, { + 'dtype': 'generic' +}); +console.log( 'Start Index:', ndarraylike2scalar( start ) ); + +var end = scalar2ndarray( 15, { + 'dtype': 'generic' +}); +console.log( 'End Index:', ndarraylike2scalar( end ) ); + +cfillNaN( [ x, alpha, start, end ] ); +console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/index.js new file mode 100644 index 000000000000..16a97f624590 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/index.js @@ -0,0 +1,57 @@ +/** +* @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 single-precision complex floating-point ndarray equal to `NaN` with a specified scalar constant. +* +* @module @stdlib/blas/ext/base/ndarray/cfill-nan +* +* @example +* var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var cfillNaN = require( '@stdlib/blas/ext/base/ndarray/cfill-nan' ); +* +* var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); +* +* var alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { +* 'dtype': 'complex64' +* }); +* +* var start = scalar2ndarray( 0, { +* 'dtype': 'generic' +* }); +* +* var end = scalar2ndarray( 2, { +* 'dtype': 'generic' +* }); +* +* var out = cfillNaN( [ x, alpha, start, end ] ); +* // returns [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ NaN, NaN ], [ 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/cfill-nan/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/main.js new file mode 100644 index 000000000000..b415d3c3a8da --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/main.js @@ -0,0 +1,101 @@ +/** +* @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 clipIndex = require( '@stdlib/ndarray/base/clip-index' ); +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' ); +var strided = require( '@stdlib/blas/ext/base/cfill-nan' ).ndarray; + + +// MAIN // + +/** +* Replaces elements in a one-dimensional single-precision complex 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. +* - a zero-dimensional ndarray containing the starting index (inclusive). +* - a zero-dimensional ndarray containing the ending index (exclusive). +* +* - A complex number is considered `NaN` if either the real or imaginary component is `NaN`. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {ndarray} input ndarray +* +* @example +* var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); +* +* var alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { +* 'dtype': 'complex64' +* }); +* +* var start = scalar2ndarray( 0, { +* 'dtype': 'generic' +* }); +* +* var end = scalar2ndarray( 2, { +* 'dtype': 'generic' +* }); +* +* var out = cfillNaN( [ x, alpha, start, end ] ); +* // returns [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ NaN, NaN ], [ 4.0, -6.0 ] ] +*/ +function cfillNaN( arrays ) { + var stride; + var offset; + var alpha; + var start; + var end; + var N; + var x; + + x = arrays[ 0 ]; + alpha = ndarraylike2scalar( arrays[ 1 ] ); + + N = numelDimension( x, 0 ); + start = clipIndex( ndarraylike2scalar( arrays[ 2 ] ), N ); + end = clipIndex( ndarraylike2scalar( arrays[ 3 ] ), N ); + if ( start >= end ) { + return x; + } + stride = getStride( x, 0 ); + offset = getOffset( x ) + ( stride*start ); + + strided( end-start, alpha, getData( x ), stride, offset ); + return x; +} + + +// EXPORTS // + +module.exports = cfillNaN; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/package.json new file mode 100644 index 000000000000..cfe5de2ac6e0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/cfill-nan", + "version": "0.0.0", + "description": "Replace elements in a one-dimensional single-precision complex 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", + "complex64", + "complex", + "single" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/test/test.js new file mode 100644 index 000000000000..a24d01eee4ee --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/test/test.js @@ -0,0 +1,535 @@ +/** +* @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 isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var cfillNaN = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Complex64Array} 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( 'complex64', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof cfillNaN, '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 start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 4, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 4, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ 0.0, 0.0, -2.0, 3.0, 0.0, 0.0, 4.0, -6.0 ] ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function replaces elements where only the real component is `NaN`', function test( t ) { + var expected; + var actual; + var alpha; + var start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, 1.0, -2.0, 3.0, NaN, 4.0, 5.0, -6.0 ] ); + x = vector( xbuf, 4, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 4, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ 0.0, 0.0, -2.0, 3.0, 0.0, 0.0, 5.0, -6.0 ] ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function replaces elements where only the imaginary component is `NaN`', function test( t ) { + var expected; + var actual; + var alpha; + var start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ 1.0, NaN, -2.0, 3.0, 4.0, NaN, 5.0, -6.0 ] ); + x = vector( xbuf, 4, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 4, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ 0.0, 0.0, -2.0, 3.0, 0.0, 0.0, 5.0, -6.0 ] ); + t.strictEqual( isSameComplex64Array( 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 start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, 1.0, 2.0, 3.0, 4.0, NaN, NaN ] ); + x = vector( xbuf, 2, 2, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, NaN, NaN ] ); + t.strictEqual( isSameComplex64Array( 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 start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, 1.0, 2.0, 3.0, 4.0, NaN, NaN ] ); + x = vector( xbuf, 2, -2, 2 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, NaN, NaN ] ); + t.strictEqual( isSameComplex64Array( 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 start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 2, 1, 2 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ NaN, NaN, -2.0, 3.0, 0.0, 0.0, 4.0, -6.0 ] ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a nonnegative starting index', function test( t ) { + var expected; + var actual; + var alpha; + var start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 4, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 4, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ NaN, NaN, -2.0, 3.0, 0.0, 0.0, 4.0, -6.0 ] ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative starting index', function test( t ) { + var expected; + var actual; + var alpha; + var start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 4, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( -2, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 4, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ NaN, NaN, -2.0, 3.0, 0.0, 0.0, 4.0, -6.0 ] ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a nonnegative ending index', function test( t ) { + var expected; + var actual; + var alpha; + var start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 4, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ 0.0, 0.0, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative ending index', function test( t ) { + var expected; + var actual; + var alpha; + var start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 4, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( -2, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ 0.0, 0.0, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function clamps out-of-bounds starting and ending indices', function test( t ) { + var expected; + var actual; + var alpha; + var start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 4, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( -10, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 10, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ 0.0, 0.0, -2.0, 3.0, 0.0, 0.0, 4.0, -6.0 ] ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if a resolved starting index is greater than or equal to a resolved ending index, the function returns the input ndarray unchanged', function test( t ) { + var expected; + var actual; + var alpha; + var start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 4, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + expected = new Complex64Array( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + + start = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + start = scalar2ndarray( 3, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + start = scalar2ndarray( 5, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 4, { + 'dtype': 'generic' + }); + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( -10, { + 'dtype': 'generic' + }); + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a fill range for an input ndarray having a non-unit stride', function test( t ) { + var expected; + var actual; + var alpha; + var start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); + x = vector( xbuf, 2, 2, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ NaN, NaN, -2.0, 3.0, 0.0, 0.0, 4.0, -6.0 ] ); + t.strictEqual( isSameComplex64Array( 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 start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = vector( xbuf, 2, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( 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 start; + var xbuf; + var end; + var x; + + xbuf = new Complex64Array( [] ); + x = vector( xbuf, 0, 1, 0 ); + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); + start = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + end = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + + actual = cfillNaN( [ x, alpha, start, end ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = new Complex64Array( [] ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); From c3cfe1bf4f202169124ff8b13eb5d4a3855644d2 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 5 Oct 2026 13:13:48 +0500 Subject: [PATCH 2/2] fix: apply suggestions from code review --- .../blas/ext/base/ndarray/cfill-nan/README.md | 15 ++++++--------- .../base/ndarray/cfill-nan/benchmark/benchmark.js | 13 ++++--------- .../blas/ext/base/ndarray/cfill-nan/docs/repl.txt | 5 ++--- .../base/ndarray/cfill-nan/docs/types/index.d.ts | 4 ++-- .../ext/base/ndarray/cfill-nan/examples/index.js | 11 ++++------- .../blas/ext/base/ndarray/cfill-nan/lib/index.js | 4 ++-- .../blas/ext/base/ndarray/cfill-nan/lib/main.js | 4 ++-- 7 files changed, 22 insertions(+), 34 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/README.md index a57c55847044..ff73244889f2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/README.md @@ -45,7 +45,7 @@ var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); +var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, 4.0, 5.0, 4.0, -6.0 ] ); var alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { 'dtype': 'complex64' @@ -60,7 +60,7 @@ var end = scalar2ndarray( 2, { }); cfillNaN( [ x, alpha, start, end ] ); -// x => [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ NaN, NaN ], [ 4.0, -6.0 ] ] +// x => [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ 4.0, 5.0 ], [ 4.0, -6.0 ] ] ``` The function has the following parameters: @@ -95,8 +95,7 @@ The function has the following parameters: ```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +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' ); @@ -104,15 +103,13 @@ var Complex64 = require( '@stdlib/complex/float32/ctor' ); var cfillNaN = require( '@stdlib/blas/ext/base/ndarray/cfill-nan' ); var opts = { - 'dtype': 'float32' + 'dtype': 'complex64' }; -var x = new Complex64Vector( discreteUniform( 20, 0, 2, opts ) ); +var x = nans( [ 20 ], opts ); console.log( ndarray2array( x ) ); -var alpha = scalar2ndarray( new Complex64( 5.0, 5.0 ), { - 'dtype': 'complex64' -}); +var alpha = scalar2ndarray( new Complex64( 5.0, 5.0 ), opts ); console.log( 'Alpha:', ndarraylike2scalar( alpha ) ); var start = scalar2ndarray( 5, { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/benchmark/benchmark.js index 40af26e8f362..f966dff15134 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/benchmark/benchmark.js @@ -61,14 +61,9 @@ function createBenchmark( len ) { xbuf[ i+1 ] = NaN; } x = new Complex64Vector( xbuf.buffer ); - alpha = [ - scalar2ndarray( new Complex64( 1.0, 1.0 ), { - 'dtype': 'complex64' - }), - scalar2ndarray( new Complex64( 0.0, 0.0 ), { - 'dtype': 'complex64' - }) - ]; + alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { + 'dtype': 'complex64' + }); start = scalar2ndarray( 0, { 'dtype': 'generic' }); @@ -89,7 +84,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = cfillNaN( [ x, alpha[ i%2 ], start, end ] ); + out = cfillNaN( [ x, alpha, start, end ] ); if ( typeof out !== 'object' ) { b.fail( 'should return an ndarray' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/repl.txt index c63206805277..f4fa3ec3cf83 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/repl.txt @@ -6,8 +6,8 @@ The input ndarray is modified *in-place* (i.e., the input ndarray is *mutated*). - If a specified `start` or `end` index is negative, the function resolves - the respective index by counting backward from the last element (where `-1` + If a specified `start` or `end` index is negative, the function resolves the + respective index by counting backward from the last element (where `-1` refers to the last element). A complex number is considered `NaN` if either the real or imaginary @@ -40,4 +40,3 @@ See Also -------- - diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/index.d.ts index 110074ae2043..d6bc77ec4936 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/docs/types/index.d.ts @@ -45,7 +45,7 @@ import { Complex64 } from '@stdlib/types/complex'; * var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * -* var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); +* var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, 4.0, 5.0, 4.0, -6.0 ] ); * * var alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { * 'dtype': 'complex64' @@ -60,7 +60,7 @@ import { Complex64 } from '@stdlib/types/complex'; * }); * * var out = cfillNaN( [ x, alpha, start, end ] ); -* // returns [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ NaN, NaN ], [ 4.0, -6.0 ] ] +* // returns [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ 4.0, 5.0 ], [ 4.0, -6.0 ] ] */ declare function cfillNaN( arrays: [ complex64ndarray, typedndarray, typedndarray, typedndarray ] ): complex64ndarray; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/examples/index.js index a75f8116bc48..1c35dd652a9b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/examples/index.js @@ -18,8 +18,7 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +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' ); @@ -27,15 +26,13 @@ var Complex64 = require( '@stdlib/complex/float32/ctor' ); var cfillNaN = require( './../lib' ); var opts = { - 'dtype': 'float32' + 'dtype': 'complex64' }; -var x = new Complex64Vector( discreteUniform( 20, 0, 2, opts ) ); +var x = nans( [ 20 ], opts ); console.log( ndarray2array( x ) ); -var alpha = scalar2ndarray( new Complex64( 5.0, 5.0 ), { - 'dtype': 'complex64' -}); +var alpha = scalar2ndarray( new Complex64( 5.0, 5.0 ), opts ); console.log( 'Alpha:', ndarraylike2scalar( alpha ) ); var start = scalar2ndarray( 5, { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/index.js index 16a97f624590..e326004545a4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/index.js @@ -29,7 +29,7 @@ * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var cfillNaN = require( '@stdlib/blas/ext/base/ndarray/cfill-nan' ); * -* var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); +* var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, 4.0, 5.0, 4.0, -6.0 ] ); * * var alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { * 'dtype': 'complex64' @@ -44,7 +44,7 @@ * }); * * var out = cfillNaN( [ x, alpha, start, end ] ); -* // returns [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ NaN, NaN ], [ 4.0, -6.0 ] ] +* // returns [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ 4.0, 5.0 ], [ 4.0, -6.0 ] ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/main.js index b415d3c3a8da..e0ecb4bfb136 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill-nan/lib/main.js @@ -53,7 +53,7 @@ var strided = require( '@stdlib/blas/ext/base/cfill-nan' ).ndarray; * var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * -* var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, NaN, NaN, 4.0, -6.0 ] ); +* var x = new Complex64Vector( [ NaN, NaN, -2.0, 3.0, 4.0, 5.0, 4.0, -6.0 ] ); * * var alpha = scalar2ndarray( new Complex64( 0.0, 0.0 ), { * 'dtype': 'complex64' @@ -68,7 +68,7 @@ var strided = require( '@stdlib/blas/ext/base/cfill-nan' ).ndarray; * }); * * var out = cfillNaN( [ x, alpha, start, end ] ); -* // returns [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ NaN, NaN ], [ 4.0, -6.0 ] ] +* // returns [ [ 0.0, 0.0 ], [ -2.0, 3.0 ], [ 4.0, 5.0 ], [ 4.0, -6.0 ] ] */ function cfillNaN( arrays ) { var stride;