From 62674d03bee6e06c9d4c387d2ed4f13695222dce Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 5 Jul 2026 02:20:59 +0500 Subject: [PATCH 01/16] feat: add blas/ext/base/gfill-nan --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/gfill-nan/README.md | 159 +++++++++ .../ext/base/gfill-nan/benchmark/benchmark.js | 109 ++++++ .../gfill-nan/benchmark/benchmark.ndarray.js | 109 ++++++ .../blas/ext/base/gfill-nan/docs/repl.txt | 97 ++++++ .../ext/base/gfill-nan/docs/types/index.d.ts | 130 +++++++ .../ext/base/gfill-nan/docs/types/test.ts | 156 +++++++++ .../blas/ext/base/gfill-nan/examples/index.js | 28 ++ .../blas/ext/base/gfill-nan/lib/accessors.js | 74 ++++ .../blas/ext/base/gfill-nan/lib/index.js | 57 ++++ .../blas/ext/base/gfill-nan/lib/main.js | 51 +++ .../blas/ext/base/gfill-nan/lib/ndarray.js | 124 +++++++ .../blas/ext/base/gfill-nan/package.json | 69 ++++ .../blas/ext/base/gfill-nan/test/test.js | 38 +++ .../blas/ext/base/gfill-nan/test/test.main.js | 316 ++++++++++++++++++ .../ext/base/gfill-nan/test/test.ndarray.js | 313 +++++++++++++++++ 15 files changed, 1830 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md new file mode 100644 index 000000000000..92ce9865a927 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md @@ -0,0 +1,159 @@ + + +# gfill-nan + +> Replace strided array elements equal to NaN with a specified scalar constant. + +
+ +## Usage + +```javascript +var gfillNaN = require( '@stdlib/blas/ext/base/gfill-nan' ); +``` + +#### gfillNaN( N, alpha, x, strideX ) + +Replaces strided array elements equal to NaN with a specified scalar constant. + +```javascript +var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; + +gfillNaN( x.length, 0.0, x, 1 ); +// x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **alpha**: scalar constant. +- **x**: input array. +- **strideX**: stride length. + +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to replace every other NaN element: + +```javascript +var x = [ NaN, 1.0, NaN, -5.0, NaN, 0.0, -1.0, -3.0 ]; + +gfillNaN( 4, 0.0, x, 2 ); +// x => [ 0.0, 1.0, 0.0, -5.0, 0.0, 0.0, -1.0, -3.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial array... +var x0 = new Float64Array( [ 1.0, NaN, 3.0, NaN, 5.0, -6.0 ] ); + +// Create an offset view... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Replace every other NaN element... +gfillNaN( 3, 0.0, x1, 2 ); +// x0 => [ 1.0, 0.0, 3.0, 0.0, 5.0, -6.0 ] +``` + +#### gfillNaN.ndarray( N, alpha, x, strideX, offsetX ) + +Replaces strided array elements equal to NaN with a specified scalar constant using alternative indexing semantics. + +```javascript +var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; + +gfillNaN.ndarray( x.length, 0.0, x, 1, 0 ); +// x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements: + +```javascript +var x = [ 1.0, NaN, 3.0, NaN, 5.0, -6.0 ]; + +gfillNaN.ndarray( 3, 0.0, x, 1, x.length-3 ); +// x => [ 1.0, NaN, 3.0, 0.0, 5.0, -6.0 ] +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `x` unchanged. +- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). + +
+ + + +
+ +## Examples + + + +```javascript +var nans = require( '@stdlib/array/nans' ); +var gfillNaN = require( '@stdlib/blas/ext/base/gfill-nan' ); + +var x = nans( 10 ); +console.log( x ); + +gfillNaN( x.length, 0.0, x, 1 ); +console.log( x ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.js new file mode 100644 index 000000000000..872d7f5f8da8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.js @@ -0,0 +1,109 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gfillNaN = require( './../lib/main.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x; + var i; + + x = uniform( len, -100, 100, options ); + for ( i = 0; i < x.length; i += 3 ) { + x[ i ] = NaN; + } + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var j; + + b.tic(); + for ( j = 0; j < b.iterations; j++ ) { + y = gfillNaN( x.length, 0.0, x, 1 ); + if ( isnan( y[ j%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y[ j%x.length ] ) ) { + 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( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..856315d14c28 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.ndarray.js @@ -0,0 +1,109 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gfillNaN = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var i; + var x; + + x = uniform( len, -100, 100, options ); + for ( i = 0; i < x.length; i += 3 ) { + x[ i ] = NaN; + } + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var j; + + b.tic(); + for ( j = 0; j < b.iterations; j++ ) { + y = gfillNaN( x.length, 0.0, x, 1, 0 ); + if ( isnan( y[ j%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y[ j%x.length ] ) ) { + 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( format( '%s:ndarray:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/repl.txt new file mode 100644 index 000000000000..833c777077d1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/repl.txt @@ -0,0 +1,97 @@ + +{{alias}}( N, alpha, x, strideX ) + Replaces strided array elements equal to NaN with a specified scalar + constant. + + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N <= 0`, the function returns `x` unchanged. + + Parameters + ---------- + N: integer + Number of indexed elements. + + alpha: any + Scalar constant. + + x: ArrayLikeObject + Input array. + + strideX: integer + Stride length. + + Returns + ------- + x: ArrayLikeObject + Input array. + + Examples + -------- + // Standard Usage: + > var x = [ NaN, 1.0, 3.0, NaN, 4.0, -1.0, -3.0 ]; + > {{alias}}( x.length, 0.0, x, 1 ) + [ 0.0, 1.0, 3.0, 0.0, 4.0, -1.0, -3.0 ] + + // Using `N` and stride parameters: + > x = [ NaN, 1.0, NaN, -5.0, NaN, -1.0, -3.0 ]; + > {{alias}}( 4, 0.0, x, 2 ) + [ 0.0, 1.0, 0.0, -5.0, 0.0, -1.0, -3.0 ] + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, NaN, 3.0, NaN, 5.0, -6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 2, 0.0, x1, 2 ) + [ 0.0, 3.0, 0.0, 5.0, -6.0 ] + > x0 + [ 1.0, 0.0, 3.0, 0.0, 5.0, -6.0 ] + + +{{alias}}.ndarray( N, alpha, x, strideX, offsetX ) + Replaces strided array elements equal to NaN with a specified scalar + constant using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameter supports indexing semantics based on a starting + index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + alpha: any + Scalar constant. + + x: ArrayLikeObject + Input array. + + strideX: integer + Stride length. + + offsetX: integer + Starting index. + + Returns + ------- + x: ArrayLikeObject + Input array. + + Examples + -------- + // Standard Usage: + > var x = [ NaN, 1.0, 3.0, NaN, 4.0, -1.0, -3.0 ]; + > {{alias}}.ndarray( x.length, 0.0, x, 1, 0 ) + [ 0.0, 1.0, 3.0, 0.0, 4.0, -1.0, -3.0 ] + + // Using an index offset: + > x = [ 1.0, NaN, 3.0, NaN, 5.0, -6.0 ]; + > {{alias}}.ndarray( 3, 0.0, x, 2, 1 ) + [ 1.0, 0.0, 3.0, 0.0, 5.0, -6.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts new file mode 100644 index 000000000000..4356d19dc986 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts @@ -0,0 +1,130 @@ +/* +* @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 { Collection, AccessorArrayLike } from '@stdlib/types/array'; + +/** +* Interface describing `gfillNaN`. +*/ +interface Routine { + /** + * Replaces strided array elements equal to NaN with a specified scalar constant. + * + * @param N - number of indexed elements + * @param alpha - scalar constant + * @param x - input array + * @param strideX - stride length + * @returns `x` + * + * @example + * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); + * + * var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; + * + * gfillNaN( x.length, 0.0, toAccessorArray( x ), 1 ); + * // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] + */ + ( N: number, alpha: T, x: AccessorArrayLike, strideX: number ): AccessorArrayLike; + + /** + * Replaces strided array elements equal to NaN with a specified scalar constant. + * + * @param N - number of indexed elements + * @param alpha - scalar constant + * @param x - input array + * @param strideX - stride length + * @returns `x` + * + * @example + * var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; + * + * gfillNaN( x.length, 0.0, x, 1 ); + * // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] + */ + ( N: number, alpha: T, x: Collection, strideX: number ): Collection; + + /** + * Replaces strided array elements equal to NaN with a specified scalar constant using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param alpha - scalar constant + * @param x - input array + * @param strideX - stride length + * @param offsetX - starting index + * @returns `x` + * + * @example + * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); + * + * var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; + * + * gfillNaN.ndarray( x.length, 0.0, toAccessorArray( x ), 1, 0 ); + * // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] + */ + ndarray( N: number, alpha: T, x: AccessorArrayLike, strideX: number, offsetX: number ): AccessorArrayLike; + + /** + * Replaces strided array elements equal to NaN with a specified scalar constant using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param alpha - scalar constant + * @param x - input array + * @param strideX - stride length + * @param offsetX - starting index + * @returns `x` + * + * @example + * var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; + * + * gfillNaN.ndarray( x.length, 0.0, x, 1, 0 ); + * // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] + */ + ndarray( N: number, alpha: T, x: Collection, strideX: number, offsetX: number ): Collection; +} + +/** +* Replaces strided array elements equal to NaN with a specified scalar constant. +* +* @param N - number of indexed elements +* @param alpha - scalar constant +* @param x - input array +* @param strideX - stride length +* @returns `x` +* +* @example +* var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; +* +* gfillNaN( x.length, 0.0, x, 1 ); +* // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] +* +* @example +* var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; +* +* gfillNaN.ndarray( x.length, 0.0, x, 1, 0 ); +* // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] +*/ +declare var gfillNaN: Routine; + + +// EXPORTS // + +export = gfillNaN; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts new file mode 100644 index 000000000000..5ade13d0dd4d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts @@ -0,0 +1,156 @@ +/* +* @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. +*/ + +import AccessorArray = require( '@stdlib/array/base/accessor' ); +import gfillNaN = require( './index' ); + + +// TESTS // + +// The function returns a collection... +{ + const x = new Float64Array( 10 ); + + gfillNaN( x.length, 0.0, x, 1 ); // $ExpectType Collection + gfillNaN( x.length, 0.0, new AccessorArray( x ), 1 ); // $ExpectType AccessorArrayLike +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gfillNaN( '10', 0.0, x, 1 ); // $ExpectError + gfillNaN( true, 0.0, x, 1 ); // $ExpectError + gfillNaN( false, 0.0, x, 1 ); // $ExpectError + gfillNaN( null, 0.0, x, 1 ); // $ExpectError + gfillNaN( undefined, 0.0, x, 1 ); // $ExpectError + gfillNaN( [], 0.0, x, 1 ); // $ExpectError + gfillNaN( {}, 0.0, x, 1 ); // $ExpectError + gfillNaN( ( x: number ): number => x, 0.0, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a collection... +{ + const x = new Float64Array( 10 ); + + gfillNaN( x.length, 0.0, 10, 1 ); // $ExpectError + gfillNaN( x.length, 0.0, true, 1 ); // $ExpectError + gfillNaN( x.length, 0.0, false, 1 ); // $ExpectError + gfillNaN( x.length, 0.0, null, 1 ); // $ExpectError + gfillNaN( x.length, 0.0, undefined, 1 ); // $ExpectError + gfillNaN( x.length, 0.0, {}, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gfillNaN( x.length, 0.0, x, '10' ); // $ExpectError + gfillNaN( x.length, 0.0, x, true ); // $ExpectError + gfillNaN( x.length, 0.0, x, false ); // $ExpectError + gfillNaN( x.length, 0.0, x, null ); // $ExpectError + gfillNaN( x.length, 0.0, x, undefined ); // $ExpectError + gfillNaN( x.length, 0.0, x, [] ); // $ExpectError + gfillNaN( x.length, 0.0, x, {} ); // $ExpectError + gfillNaN( x.length, 0.0, x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + + gfillNaN(); // $ExpectError + gfillNaN( x.length ); // $ExpectError + gfillNaN( x.length, 0.0 ); // $ExpectError + gfillNaN( x.length, 0.0, x ); // $ExpectError + gfillNaN( x.length, 0.0, x, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a collection... +{ + const x = new Float64Array( 10 ); + + gfillNaN.ndarray( x.length, 0.0, x, 1, 0 ); // $ExpectType Collection + gfillNaN.ndarray( x.length, 0.0, new AccessorArray( x ), 1, 0 ); // $ExpectType AccessorArrayLike +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gfillNaN.ndarray( '10', 0.0, x, 1, 0 ); // $ExpectError + gfillNaN.ndarray( true, 0.0, x, 1, 0 ); // $ExpectError + gfillNaN.ndarray( false, 0.0, x, 1, 0 ); // $ExpectError + gfillNaN.ndarray( null, 0.0, x, 1, 0 ); // $ExpectError + gfillNaN.ndarray( undefined, 0.0, x, 1, 0 ); // $ExpectError + gfillNaN.ndarray( [], 0.0, x, 1, 0 ); // $ExpectError + gfillNaN.ndarray( {}, 0.0, x, 1, 0 ); // $ExpectError + gfillNaN.ndarray( ( x: number ): number => x, 0.0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... +{ + const x = new Float64Array( 10 ); + + gfillNaN.ndarray( x.length, 0.0, 10, 1, 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, true, 1, 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, false, 1, 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, null, 1, 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, undefined, 1, 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, {}, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gfillNaN.ndarray( x.length, 0.0, x, '10', 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, true, 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, false, 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, null, 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, undefined, 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, [], 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, {}, 0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gfillNaN.ndarray( x.length, 0.0, x, 1, '10' ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, 1, true ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, 1, false ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, 1, null ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, 1, undefined ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, 1, [] ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, 1, {} ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + + gfillNaN.ndarray(); // $ExpectError + gfillNaN.ndarray( x.length ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, 1 ); // $ExpectError + gfillNaN.ndarray( x.length, 0.0, x, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/examples/index.js new file mode 100644 index 000000000000..6b1653475ba6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/examples/index.js @@ -0,0 +1,28 @@ +/** +* @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/array/nans' ); +var gfillNaN = require( './../lib' ); + +var x = nans( 10 ); +console.log( x ); + +gfillNaN( x.length, 0.0, x, 1 ); +console.log( x ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js new file mode 100644 index 000000000000..464a224478f0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js @@ -0,0 +1,74 @@ +/** +* @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'; + +// MAIN // + +/** +* Replaces strided array elements equal to NaN with a specified scalar constant. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {*} alpha - scalar constant +* @param {Object} x - input array object +* @param {Collection} x.data - input array data +* @param {Array} x.accessors - array element accessors +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @returns {Object} input array object +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; +* +* gfillNaN( x.length, 0.0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] +*/ +function gfillNaN( N, alpha, x, strideX, offsetX ) { + var xbuf; + var get; + var set; + var ix; + var i; + var v; + + // Cache reference to array data: + xbuf = x.data; + + // Cache references to the element accessors: + get = x.accessors[ 0 ]; + set = x.accessors[ 1 ]; + + ix = offsetX; + for ( i = 0; i < N; i++ ) { + v = get( xbuf, ix ); + if ( v !== v ) { + set( xbuf, ix, alpha ); + } + ix += strideX; + } + return x; +} + + +// EXPORTS // + +module.exports = gfillNaN; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/index.js new file mode 100644 index 000000000000..adfc08bfd948 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-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 strided array elements equal to NaN with a specified scalar constant. +* +* @module @stdlib/blas/ext/base/gfill-nan +* +* @example +* var gfillNaN = require( '@stdlib/blas/ext/base/gfill-nan' ); +* +* var x = [ NaN, NaN, 1.0, NaN ]; +* +* gfillNaN( x.length, 0.0, x, 1 ); +* // x => [ 0.0, 0.0, 1.0, 0.0 ] +* +* @example +* var gfillNaN = require( '@stdlib/blas/ext/base/gfill-nan' ); +* +* var x = [ NaN, NaN, 1.0, NaN ]; +* +* gfillNaN.ndarray( x.length, 0.0, x, 1, 0 ); +* // x => [ 0.0, 0.0, 1.0, 0.0 ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/main.js new file mode 100644 index 000000000000..78e50cd64a5f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/main.js @@ -0,0 +1,51 @@ +/** +* @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 stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Replaces strided array elements equal to NaN with a specified scalar constant. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {*} alpha - scalar constant +* @param {Collection} x - input array +* @param {integer} strideX - stride length +* @returns {Collection} input array +* +* @example +* var x = [ NaN, NaN, 1.0, NaN ]; +* +* gfillNaN( x.length, 0.0, x, 1 ); +* // x => [ 0.0, 0.0, 1.0, 0.0 ] +*/ +function gfillNaN( N, alpha, x, strideX ) { + return ndarray( N, alpha, x, strideX, stride2offset( N, strideX ) ); +} + + +// EXPORTS // + +module.exports = gfillNaN; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js new file mode 100644 index 000000000000..3f6f3b49df86 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js @@ -0,0 +1,124 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); + + +// VARIABLES // + +var M = 8; + + +// MAIN // + +/** +* Replaces strided array elements equal to NaN with a specified scalar constant. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {*} alpha - scalar constant +* @param {Collection} x - input array +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @returns {Collection} input array +* +* @example +* var x = [ NaN, -2.0, 3.0, NaN, 5.0, -6.0 ]; +* +* gfillNaN( 6, 0.0, x, 1, 0 ); +* // x => [ 0.0, -2.0, 3.0, 0.0, 5.0, -6.0 ] +*/ +function gfillNaN( N, alpha, x, strideX, offsetX ) { + var ix; + var m; + var o; + var i; + + if ( N <= 0 ) { + return x; + } + o = arraylike2object( x ); + if ( o.accessorProtocol ) { + accessors( N, alpha, o, strideX, offsetX ); + return o.data; + } + ix = offsetX; + + // Use loop unrolling if the stride is equal to `1`... + if ( strideX === 1 ) { + m = N % M; + + // If we have a remainder, run a clean-up loop... + if ( m > 0 ) { + for ( i = 0; i < m; i++ ) { + if ( isnan( x[ ix ] ) ) { + x[ ix ] = alpha; + } + ix += strideX; + } + } + if ( N < M ) { + return x; + } + for ( i = m; i < N; i += M ) { + if ( isnan( x[ ix ] ) ) { + x[ ix ] = alpha; + } + if ( isnan( x[ ix+1 ] ) ) { + x[ ix+1 ] = alpha; + } + if ( isnan( x[ ix+2 ] ) ) { + x[ ix+2 ] = alpha; + } + if ( isnan( x[ ix+3 ] ) ) { + x[ ix+3 ] = alpha; + } + if ( isnan( x[ ix+4 ] ) ) { + x[ ix+4 ] = alpha; + } + if ( isnan( x[ ix+5 ] ) ) { + x[ ix+5 ] = alpha; + } + if ( isnan( x[ ix+6 ] ) ) { + x[ ix+6 ] = alpha; + } + if ( isnan( x[ ix+7 ] ) ) { + x[ ix+7 ] = alpha; + } + ix += M; + } + return x; + } + for ( i = 0; i < N; i++ ) { + if ( isnan( x[ ix ] ) ) { + x[ ix ] = alpha; + } + ix += strideX; + } + return x; +} + + +// EXPORTS // + +module.exports = gfillNaN; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/package.json b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/package.json new file mode 100644 index 000000000000..4b82c89a1ac0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/blas/ext/base/gfill-nan", + "version": "0.0.0", + "description": "Replace strided array elements 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", + "fill", + "nan", + "not-a-number", + "replace", + "assign", + "set", + "strided", + "array", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.js new file mode 100644 index 000000000000..496b0b764a7f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.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'; + +// MODULES // + +var tape = require( 'tape' ); +var gfillNaN = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gfillNaN, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof gfillNaN.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js new file mode 100644 index 000000000000..fbccdca3e722 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js @@ -0,0 +1,316 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Float64Array = require( '@stdlib/array/float64' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gfillNaN = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gfillNaN, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( gfillNaN.length, 4, 'has expected arity' ); + t.end(); +}); + +tape( 'the function replaces NaN values in a strided array', function test( t ) { + var expected; + var x; + + x = [ + NaN, + 2.0, + NaN, + 5.0, + -1.0, + NaN, + -5.0, + 6.0 + ]; + expected = [ + 0.0, + 2.0, + 0.0, + 5.0, + -1.0, + 0.0, + -5.0, + 6.0 + ]; + + gfillNaN( x.length, 0.0, x, 1 ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = [ NaN, 2.0 ]; + expected = [ 5.0, 2.0 ]; + + gfillNaN( x.length, 5.0, x, 1 ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function replaces NaN values in a strided array (accessors)', function test( t ) { + var expected; + var x; + + x = [ + NaN, + 2.0, + NaN, + 5.0, + -1.0, + NaN, + -5.0, + 6.0 + ]; + expected = [ + 0.0, + 2.0, + 0.0, + 5.0, + -1.0, + 0.0, + -5.0, + 6.0 + ]; + + gfillNaN( x.length, 0.0, toAccessorArray( x ), 1 ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the input array', function test( t ) { + var out; + var x; + + x = [ 1.0, NaN, 3.0, NaN, 5.0 ]; + out = gfillNaN( x.length, 0.0, x, 1 ); + + t.strictEqual( out, x, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) { + var x; + + x = [ NaN, -4.0, 1.0 ]; + + gfillNaN( 0, 0.0, x, 1 ); + t.true( isnan( x[ 0 ] ), 'returns expected value' ); + t.strictEqual( x[ 1 ], -4.0, 'returns expected value' ); + t.strictEqual( x[ 2 ], 1.0, 'returns expected value' ); + + x = [ NaN, -4.0, 1.0 ]; + gfillNaN( -4, 0.0, x, 1 ); + t.true( isnan( x[ 0 ] ), 'returns expected value' ); + t.strictEqual( x[ 1 ], -4.0, 'returns expected value' ); + t.strictEqual( x[ 2 ], 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride', function test( t ) { + var expected; + var x; + + x = [ + NaN, // 0 + -3.0, + -5.0, // 1 + 7.0, + NaN // 2 + ]; + expected = [ + 0.0, // 0 + -3.0, + -5.0, // 1 + 7.0, + 0.0 // 2 + ]; + + gfillNaN( 3, 0.0, x, 2 ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride (accessors)', function test( t ) { + var expected; + var x; + + x = [ + NaN, // 0 + 2.0, + -3.0, + 5.0, + NaN, // 1 + 2.0, + -5.0, + 6.0 + ]; + expected = [ + 0.0, // 0 + 2.0, + -3.0, + 5.0, + 0.0, // 1 + 2.0, + -5.0, + 6.0 + ]; + + gfillNaN( 2, 0.0, toAccessorArray( x ), 4 ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride', function test( t ) { + var expected; + var x; + + x = [ + NaN, // 2 + -3.0, + -5.0, // 1 + 7.0, + NaN // 0 + ]; + expected = [ + 0.0, // 2 + -3.0, + -5.0, // 1 + 7.0, + 0.0 // 0 + ]; + + gfillNaN( 3, 0.0, x, -2 ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride (accessors)', function test( t ) { + var expected; + var x; + + x = [ + NaN, // 1 + 2.0, + -3.0, + 5.0, + NaN, // 0 + 2.0, + -5.0, + 6.0 + ]; + expected = [ + 0.0, // 1 + 2.0, + -3.0, + 5.0, + 0.0, // 0 + 2.0, + -5.0, + 6.0 + ]; + + gfillNaN( 2, 0.0, toAccessorArray( x ), -4 ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + NaN, // 0 + 3.0, + NaN, // 1 + 5.0, + 6.0 // 2 + ]); + expected = new Float64Array([ + 1.0, + 0.0, // 0 + 3.0, + 0.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + gfillNaN( 3, 0.0, x1, 2 ); + t.deepEqual( x0, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `stride` is equal to `1`, the function efficiently replaces NaN values in a strided array', function test( t ) { + var expected; + var alpha; + var x; + var i; + + alpha = 0.0; + x = new Float64Array( 100 ); + expected = new Float64Array( x.length ); + for ( i = 0; i < x.length; i++ ) { + if ( i % 3 === 0 ) { + x[ i ] = NaN; + expected[ i ] = alpha; + } else { + x[ i ] = i; + expected[ i ] = i; + } + } + gfillNaN( x.length, alpha, x, 1 ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float64Array( 240 ); + expected = new Float64Array( x.length ); + for ( i = 0; i < x.length; i++ ) { + if ( i % 3 === 0 ) { + x[ i ] = NaN; + expected[ i ] = alpha; + } else { + x[ i ] = i; + expected[ i ] = i; + } + } + gfillNaN( x.length, alpha, x, 1 ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js new file mode 100644 index 000000000000..924290e92b23 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js @@ -0,0 +1,313 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Float64Array = require( '@stdlib/array/float64' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gfillNaN = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gfillNaN, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( gfillNaN.length, 5, 'has expected arity' ); + t.end(); +}); + +tape( 'the function replaces NaN values in a strided array', function test( t ) { + var expected; + var x; + + x = [ + NaN, + 2.0, + NaN, + 5.0, + -1.0, + NaN, + -5.0, + 6.0 + ]; + expected = [ + 0.0, + 2.0, + 0.0, + 5.0, + -1.0, + 0.0, + -5.0, + 6.0 + ]; + + gfillNaN( x.length, 0.0, x, 1, 0 ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = [ NaN, 2.0 ]; + expected = [ 5.0, 2.0 ]; + + gfillNaN( x.length, 5.0, x, 1, 0 ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function replaces NaN values in a strided array (accessors)', function test( t ) { + var expected; + var x; + + x = [ + NaN, + 2.0, + NaN, + 5.0, + -1.0, + NaN, + -5.0, + 6.0 + ]; + expected = [ + 0.0, + 2.0, + 0.0, + 5.0, + -1.0, + 0.0, + -5.0, + 6.0 + ]; + + gfillNaN( x.length, 0.0, toAccessorArray( x ), 1, 0 ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the input array', function test( t ) { + var out; + var x; + + x = [ 1.0, NaN, 3.0, NaN, 5.0 ]; + out = gfillNaN( x.length, 0.0, x, 1, 0 ); + + t.strictEqual( out, x, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) { + var x; + + x = [ NaN, -4.0, 1.0 ]; + + gfillNaN( 0, 0.0, x, 1, 0 ); + t.true( isnan( x[ 0 ] ), 'returns expected value' ); + t.strictEqual( x[ 1 ], -4.0, 'returns expected value' ); + t.strictEqual( x[ 2 ], 1.0, 'returns expected value' ); + + x = [ NaN, -4.0, 1.0 ]; + gfillNaN( -4, 0.0, x, 1, 0 ); + t.true( isnan( x[ 0 ] ), 'returns expected value' ); + t.strictEqual( x[ 1 ], -4.0, 'returns expected value' ); + t.strictEqual( x[ 2 ], 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride', function test( t ) { + var expected; + var x; + + x = [ + NaN, // 0 + -3.0, + -5.0, // 1 + 7.0, + NaN // 2 + ]; + expected = [ + 0.0, // 0 + -3.0, + -5.0, // 1 + 7.0, + 0.0 // 2 + ]; + + gfillNaN( 3, 0.0, x, 2, 0 ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride (accessors)', function test( t ) { + var expected; + var x; + + x = [ + NaN, // 0 + 2.0, + -3.0, + 5.0, + NaN, // 1 + 2.0, + -5.0, + 6.0 + ]; + expected = [ + 0.0, // 0 + 2.0, + -3.0, + 5.0, + 0.0, // 1 + 2.0, + -5.0, + 6.0 + ]; + + gfillNaN( 2, 0.0, toAccessorArray( x ), 4, 0 ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride', function test( t ) { + var expected; + var x; + + x = [ + NaN, // 2 + -3.0, + -5.0, // 1 + 7.0, + NaN // 0 + ]; + expected = [ + 0.0, // 2 + -3.0, + -5.0, // 1 + 7.0, + 0.0 // 0 + ]; + + gfillNaN( 3, 0.0, x, -2, 4 ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride (accessors)', function test( t ) { + var expected; + var x; + + x = [ + NaN, // 1 + 2.0, + -3.0, + 5.0, + NaN, // 0 + 2.0, + -5.0, + 6.0 + ]; + expected = [ + 0.0, // 1 + 2.0, + -3.0, + 5.0, + 0.0, // 0 + 2.0, + -5.0, + 6.0 + ]; + + gfillNaN( 2, 0.0, toAccessorArray( x ), -4, 4 ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an offset parameter', function test( t ) { + var expected; + var x; + + x = [ + 1.0, + NaN, // 0 + 3.0, + NaN, // 1 + 5.0, + 6.0 // 2 + ]; + expected = [ + 1.0, + 0.0, // 0 + 3.0, + 0.0, // 1 + 5.0, + 6.0 // 2 + ]; + + gfillNaN( 3, 0.0, x, 2, 1 ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `stride` is equal to `1`, the function efficiently replaces NaN values in a strided array', function test( t ) { + var expected; + var alpha; + var x; + var i; + + alpha = 0.0; + x = new Float64Array( 100 ); + expected = new Float64Array( x.length ); + for ( i = 0; i < x.length; i++ ) { + if ( i % 3 === 0 ) { + x[ i ] = NaN; + expected[ i ] = alpha; + } else { + x[ i ] = i; + expected[ i ] = i; + } + } + gfillNaN( x.length, alpha, x, 1, 0 ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float64Array( 240 ); + expected = new Float64Array( x.length ); + for ( i = 0; i < x.length; i++ ) { + if ( i % 3 === 0 ) { + x[ i ] = NaN; + expected[ i ] = alpha; + } else { + x[ i ] = i; + expected[ i ] = i; + } + } + gfillNaN( x.length, alpha, x, 1, 0 ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); From 61e24392a50bf2c93d7661ec96d3a5547fed5df8 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 02:56:49 -0700 Subject: [PATCH 02/16] style: rename variable Signed-off-by: Athan --- .../blas/ext/base/gfill-nan/benchmark/benchmark.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.js index 872d7f5f8da8..0bdef7edd7d5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.js @@ -63,17 +63,17 @@ function createBenchmark( len ) { */ function benchmark( b ) { var y; - var j; + var i; b.tic(); - for ( j = 0; j < b.iterations; j++ ) { + for ( i = 0; i < b.iterations; i++ ) { y = gfillNaN( x.length, 0.0, x, 1 ); - if ( isnan( y[ j%x.length ] ) ) { + if ( isnan( y[ i%x.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( y[ j%x.length ] ) ) { + if ( isnan( y[ i%x.length ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); From 8f6f31f7821a59b372730e95b409de6a42607c89 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 02:57:56 -0700 Subject: [PATCH 03/16] style: rename variable Signed-off-by: Athan --- .../ext/base/gfill-nan/benchmark/benchmark.ndarray.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.ndarray.js index 856315d14c28..7b08b9301892 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/benchmark/benchmark.ndarray.js @@ -46,8 +46,8 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var i; var x; + var i; x = uniform( len, -100, 100, options ); for ( i = 0; i < x.length; i += 3 ) { @@ -63,17 +63,17 @@ function createBenchmark( len ) { */ function benchmark( b ) { var y; - var j; + var i; b.tic(); - for ( j = 0; j < b.iterations; j++ ) { + for ( i = 0; i < b.iterations; i++ ) { y = gfillNaN( x.length, 0.0, x, 1, 0 ); - if ( isnan( y[ j%x.length ] ) ) { + if ( isnan( y[ i%x.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( y[ j%x.length ] ) ) { + if ( isnan( y[ i%x.length ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); From fb2e3a16c0f95e198e7f65259d61cd9687b2ca8a Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:03:22 -0700 Subject: [PATCH 04/16] fix: update declarations Signed-off-by: Athan --- .../ext/base/gfill-nan/docs/types/index.d.ts | 48 +++---------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts index 4356d19dc986..b9d251a9cbcd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts @@ -22,29 +22,15 @@ import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +/** +* Input array. +*/ +type InputArray = Collection | AccessorArrayLike; + /** * Interface describing `gfillNaN`. */ interface Routine { - /** - * Replaces strided array elements equal to NaN with a specified scalar constant. - * - * @param N - number of indexed elements - * @param alpha - scalar constant - * @param x - input array - * @param strideX - stride length - * @returns `x` - * - * @example - * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); - * - * var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; - * - * gfillNaN( x.length, 0.0, toAccessorArray( x ), 1 ); - * // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] - */ - ( N: number, alpha: T, x: AccessorArrayLike, strideX: number ): AccessorArrayLike; - /** * Replaces strided array elements equal to NaN with a specified scalar constant. * @@ -60,27 +46,7 @@ interface Routine { * gfillNaN( x.length, 0.0, x, 1 ); * // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] */ - ( N: number, alpha: T, x: Collection, strideX: number ): Collection; - - /** - * Replaces strided array elements equal to NaN with a specified scalar constant using alternative indexing semantics. - * - * @param N - number of indexed elements - * @param alpha - scalar constant - * @param x - input array - * @param strideX - stride length - * @param offsetX - starting index - * @returns `x` - * - * @example - * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); - * - * var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; - * - * gfillNaN.ndarray( x.length, 0.0, toAccessorArray( x ), 1, 0 ); - * // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] - */ - ndarray( N: number, alpha: T, x: AccessorArrayLike, strideX: number, offsetX: number ): AccessorArrayLike; + = InputArray>( N: number, alpha: T, x: V, strideX: number ): V; /** * Replaces strided array elements equal to NaN with a specified scalar constant using alternative indexing semantics. @@ -98,7 +64,7 @@ interface Routine { * gfillNaN.ndarray( x.length, 0.0, x, 1, 0 ); * // x => [ 0.0, 1.0, 3.0, 0.0, 4.0, 0.0, -1.0, -3.0 ] */ - ndarray( N: number, alpha: T, x: Collection, strideX: number, offsetX: number ): Collection; + ndarray = InputArray>( N: number, alpha: T, x: V, strideX: number, offsetX: number ): V; } /** From 2d355ff6749c343d46f5044bf209af3cda03465d Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:04:36 -0700 Subject: [PATCH 05/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts index b9d251a9cbcd..d9e19ac8276c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts @@ -49,7 +49,7 @@ interface Routine { = InputArray>( N: number, alpha: T, x: V, strideX: number ): V; /** - * Replaces strided array elements equal to NaN with a specified scalar constant using alternative indexing semantics. + * Replaces strided array elements equal to `NaN` with a specified scalar constant using alternative indexing semantics. * * @param N - number of indexed elements * @param alpha - scalar constant From 9a978f9bc16b7dfbf9ed4fce156497c0c463791a Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:04:59 -0700 Subject: [PATCH 06/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts index d9e19ac8276c..74bb0cb060c6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/index.d.ts @@ -32,7 +32,7 @@ type InputArray = Collection | AccessorArrayLike; */ interface Routine { /** - * Replaces strided array elements equal to NaN with a specified scalar constant. + * Replaces strided array elements equal to `NaN` with a specified scalar constant. * * @param N - number of indexed elements * @param alpha - scalar constant @@ -68,7 +68,7 @@ interface Routine { } /** -* Replaces strided array elements equal to NaN with a specified scalar constant. +* Replaces strided array elements equal to `NaN` with a specified scalar constant. * * @param N - number of indexed elements * @param alpha - scalar constant From a495ff452d1c10bf119cdfaa8519f2b3a1b3c0dd Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:05:36 -0700 Subject: [PATCH 07/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts index 5ade13d0dd4d..a5c9f8de02e7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts @@ -26,7 +26,7 @@ import gfillNaN = require( './index' ); { const x = new Float64Array( 10 ); - gfillNaN( x.length, 0.0, x, 1 ); // $ExpectType Collection + gfillNaN( x.length, 0.0, x, 1 ); // $ExpectType Float64Array gfillNaN( x.length, 0.0, new AccessorArray( x ), 1 ); // $ExpectType AccessorArrayLike } @@ -85,7 +85,7 @@ import gfillNaN = require( './index' ); { const x = new Float64Array( 10 ); - gfillNaN.ndarray( x.length, 0.0, x, 1, 0 ); // $ExpectType Collection + gfillNaN.ndarray( x.length, 0.0, x, 1, 0 ); // $ExpectType Float64Array gfillNaN.ndarray( x.length, 0.0, new AccessorArray( x ), 1, 0 ); // $ExpectType AccessorArrayLike } From 18be2351f71579c2aad45a52012379ee8fd654ab Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:12:25 -0700 Subject: [PATCH 08/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gfill-nan/README.md | 7 ++- .../blas/ext/base/gfill-nan/docs/repl.txt | 4 +- .../blas/ext/base/gfill-nan/lib/accessors.js | 2 +- .../blas/ext/base/gfill-nan/lib/index.js | 2 +- .../blas/ext/base/gfill-nan/lib/main.js | 2 +- .../blas/ext/base/gfill-nan/lib/ndarray.js | 2 +- .../blas/ext/base/gfill-nan/package.json | 2 +- .../blas/ext/base/gfill-nan/test/test.main.js | 42 +----------------- .../ext/base/gfill-nan/test/test.ndarray.js | 43 +------------------ 9 files changed, 14 insertions(+), 92 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md index 92ce9865a927..8c7c841b9e02 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md @@ -20,7 +20,7 @@ limitations under the License. # gfill-nan -> Replace strided array elements equal to NaN with a specified scalar constant. +> Replace strided array elements equal to `NaN` with a specified scalar constant.
@@ -32,7 +32,7 @@ var gfillNaN = require( '@stdlib/blas/ext/base/gfill-nan' ); #### gfillNaN( N, alpha, x, strideX ) -Replaces strided array elements equal to NaN with a specified scalar constant. +Replaces strided array elements equal to `NaN` with a specified scalar constant. ```javascript var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; @@ -75,7 +75,7 @@ gfillNaN( 3, 0.0, x1, 2 ); #### gfillNaN.ndarray( N, alpha, x, strideX, offsetX ) -Replaces strided array elements equal to NaN with a specified scalar constant using alternative indexing semantics. +Replaces strided array elements equal to `NaN` with a specified scalar constant using alternative indexing semantics. ```javascript var x = [ NaN, 1.0, 3.0, NaN, 4.0, 0.0, -1.0, -3.0 ]; @@ -149,7 +149,6 @@ console.log( x ); [@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor - diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/repl.txt index 833c777077d1..72f5446a9ea0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( N, alpha, x, strideX ) - Replaces strided array elements equal to NaN with a specified scalar + Replaces strided array elements equal to `NaN` with a specified scalar constant. The `N` and stride parameters determine which elements in the strided array @@ -52,7 +52,7 @@ {{alias}}.ndarray( N, alpha, x, strideX, offsetX ) - Replaces strided array elements equal to NaN with a specified scalar + Replaces strided array elements equal to `NaN` with a specified scalar constant using alternative indexing semantics. While typed array views mandate a view offset based on the underlying diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js index 464a224478f0..c24397378e2e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js @@ -21,7 +21,7 @@ // MAIN // /** -* Replaces strided array elements equal to NaN with a specified scalar constant. +* Replaces strided array elements equal to `NaN` with a specified scalar constant. * * @private * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/index.js index adfc08bfd948..9d232d20da65 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Replace strided array elements equal to NaN with a specified scalar constant. +* Replace strided array elements equal to `NaN` with a specified scalar constant. * * @module @stdlib/blas/ext/base/gfill-nan * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/main.js index 78e50cd64a5f..2fc31ba152cb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/main.js @@ -27,7 +27,7 @@ var ndarray = require( './ndarray.js' ); // MAIN // /** -* Replaces strided array elements equal to NaN with a specified scalar constant. +* Replaces strided array elements equal to `NaN` with a specified scalar constant. * * @param {PositiveInteger} N - number of indexed elements * @param {*} alpha - scalar constant diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js index 3f6f3b49df86..2019472593a5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js @@ -33,7 +33,7 @@ var M = 8; // MAIN // /** -* Replaces strided array elements equal to NaN with a specified scalar constant. +* Replaces strided array elements equal to `NaN` with a specified scalar constant. * * @param {PositiveInteger} N - number of indexed elements * @param {*} alpha - scalar constant diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/package.json b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/package.json index 4b82c89a1ac0..39b69d1815e1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/ext/base/gfill-nan", "version": "0.0.0", - "description": "Replace strided array elements equal to NaN with a specified scalar constant.", + "description": "Replace strided array elements equal to `NaN` with a specified scalar constant.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js index fbccdca3e722..c7497d2c82b8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js @@ -40,7 +40,7 @@ tape( 'the function has an arity of 4', function test( t ) { t.end(); }); -tape( 'the function replaces NaN values in a strided array', function test( t ) { +tape( 'the function replaces `NaN` values in a strided array', function test( t ) { var expected; var x; @@ -77,7 +77,7 @@ tape( 'the function replaces NaN values in a strided array', function test( t ) t.end(); }); -tape( 'the function replaces NaN values in a strided array (accessors)', function test( t ) { +tape( 'the function replaces `NaN` values in a strided array (accessors)', function test( t ) { var expected; var x; @@ -276,41 +276,3 @@ tape( 'the function supports view offsets', function test( t ) { t.deepEqual( x0, expected, 'returns expected value' ); t.end(); }); - -tape( 'if `stride` is equal to `1`, the function efficiently replaces NaN values in a strided array', function test( t ) { - var expected; - var alpha; - var x; - var i; - - alpha = 0.0; - x = new Float64Array( 100 ); - expected = new Float64Array( x.length ); - for ( i = 0; i < x.length; i++ ) { - if ( i % 3 === 0 ) { - x[ i ] = NaN; - expected[ i ] = alpha; - } else { - x[ i ] = i; - expected[ i ] = i; - } - } - gfillNaN( x.length, alpha, x, 1 ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = new Float64Array( 240 ); - expected = new Float64Array( x.length ); - for ( i = 0; i < x.length; i++ ) { - if ( i % 3 === 0 ) { - x[ i ] = NaN; - expected[ i ] = alpha; - } else { - x[ i ] = i; - expected[ i ] = i; - } - } - gfillNaN( x.length, alpha, x, 1 ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js index 924290e92b23..9ecb443bdb63 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js @@ -22,7 +22,6 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var gfillNaN = require( './../lib/ndarray.js' ); @@ -40,7 +39,7 @@ tape( 'the function has an arity of 5', function test( t ) { t.end(); }); -tape( 'the function replaces NaN values in a strided array', function test( t ) { +tape( 'the function replaces `NaN` values in a strided array', function test( t ) { var expected; var x; @@ -77,7 +76,7 @@ tape( 'the function replaces NaN values in a strided array', function test( t ) t.end(); }); -tape( 'the function replaces NaN values in a strided array (accessors)', function test( t ) { +tape( 'the function replaces `NaN` values in a strided array (accessors)', function test( t ) { var expected; var x; @@ -273,41 +272,3 @@ tape( 'the function supports an offset parameter', function test( t ) { t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); - -tape( 'if `stride` is equal to `1`, the function efficiently replaces NaN values in a strided array', function test( t ) { - var expected; - var alpha; - var x; - var i; - - alpha = 0.0; - x = new Float64Array( 100 ); - expected = new Float64Array( x.length ); - for ( i = 0; i < x.length; i++ ) { - if ( i % 3 === 0 ) { - x[ i ] = NaN; - expected[ i ] = alpha; - } else { - x[ i ] = i; - expected[ i ] = i; - } - } - gfillNaN( x.length, alpha, x, 1, 0 ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = new Float64Array( 240 ); - expected = new Float64Array( x.length ); - for ( i = 0; i < x.length; i++ ) { - if ( i % 3 === 0 ) { - x[ i ] = NaN; - expected[ i ] = alpha; - } else { - x[ i ] = i; - expected[ i ] = i; - } - } - gfillNaN( x.length, alpha, x, 1, 0 ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); From 1053beb0e017e1096dfe0ee57d5877c1d305c2a4 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:14:17 -0700 Subject: [PATCH 09/16] refactor: use utility Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gfill-nan/lib/accessors.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js index c24397378e2e..6151dcbb4846 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/accessors.js @@ -18,6 +18,11 @@ 'use strict'; +// MODULES // + +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + // MAIN // /** @@ -60,7 +65,7 @@ function gfillNaN( N, alpha, x, strideX, offsetX ) { ix = offsetX; for ( i = 0; i < N; i++ ) { v = get( xbuf, ix ); - if ( v !== v ) { + if ( isnan( v ) ) { set( xbuf, ix, alpha ); } ix += strideX; From c372970a5a639e79216054f218be6ab6595d3f49 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:16:04 -0700 Subject: [PATCH 10/16] refactor: remove loop unrolling Signed-off-by: Athan --- .../blas/ext/base/gfill-nan/lib/ndarray.js | 52 ------------------- 1 file changed, 52 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js index 2019472593a5..4d6f7e586cca 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js @@ -25,11 +25,6 @@ var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var accessors = require( './accessors.js' ); -// VARIABLES // - -var M = 8; - - // MAIN // /** @@ -50,7 +45,6 @@ var M = 8; */ function gfillNaN( N, alpha, x, strideX, offsetX ) { var ix; - var m; var o; var i; @@ -63,52 +57,6 @@ function gfillNaN( N, alpha, x, strideX, offsetX ) { return o.data; } ix = offsetX; - - // Use loop unrolling if the stride is equal to `1`... - if ( strideX === 1 ) { - m = N % M; - - // If we have a remainder, run a clean-up loop... - if ( m > 0 ) { - for ( i = 0; i < m; i++ ) { - if ( isnan( x[ ix ] ) ) { - x[ ix ] = alpha; - } - ix += strideX; - } - } - if ( N < M ) { - return x; - } - for ( i = m; i < N; i += M ) { - if ( isnan( x[ ix ] ) ) { - x[ ix ] = alpha; - } - if ( isnan( x[ ix+1 ] ) ) { - x[ ix+1 ] = alpha; - } - if ( isnan( x[ ix+2 ] ) ) { - x[ ix+2 ] = alpha; - } - if ( isnan( x[ ix+3 ] ) ) { - x[ ix+3 ] = alpha; - } - if ( isnan( x[ ix+4 ] ) ) { - x[ ix+4 ] = alpha; - } - if ( isnan( x[ ix+5 ] ) ) { - x[ ix+5 ] = alpha; - } - if ( isnan( x[ ix+6 ] ) ) { - x[ ix+6 ] = alpha; - } - if ( isnan( x[ ix+7 ] ) ) { - x[ ix+7 ] = alpha; - } - ix += M; - } - return x; - } for ( i = 0; i < N; i++ ) { if ( isnan( x[ ix ] ) ) { x[ ix ] = alpha; From c8479839d8cd826345c7a774119d1ba66b71726e Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:18:07 -0700 Subject: [PATCH 11/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js index 4d6f7e586cca..8ac52887d65f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/lib/ndarray.js @@ -54,7 +54,7 @@ function gfillNaN( N, alpha, x, strideX, offsetX ) { o = arraylike2object( x ); if ( o.accessorProtocol ) { accessors( N, alpha, o, strideX, offsetX ); - return o.data; + return x; } ix = offsetX; for ( i = 0; i < N; i++ ) { From c0c975fb6d1dbf7dcb8050a65ac8ca1f2f2730a5 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:19:42 -0700 Subject: [PATCH 12/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gfill-nan/test/test.main.js | 4 ++-- .../@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js index c7497d2c82b8..addf10f3af8c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.main.js @@ -125,13 +125,13 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu x = [ NaN, -4.0, 1.0 ]; gfillNaN( 0, 0.0, x, 1 ); - t.true( isnan( x[ 0 ] ), 'returns expected value' ); + t.ok( isnan( x[ 0 ] ), 'returns expected value' ); t.strictEqual( x[ 1 ], -4.0, 'returns expected value' ); t.strictEqual( x[ 2 ], 1.0, 'returns expected value' ); x = [ NaN, -4.0, 1.0 ]; gfillNaN( -4, 0.0, x, 1 ); - t.true( isnan( x[ 0 ] ), 'returns expected value' ); + t.ok( isnan( x[ 0 ] ), 'returns expected value' ); t.strictEqual( x[ 1 ], -4.0, 'returns expected value' ); t.strictEqual( x[ 2 ], 1.0, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js index 9ecb443bdb63..73666022d59e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js @@ -124,13 +124,13 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu x = [ NaN, -4.0, 1.0 ]; gfillNaN( 0, 0.0, x, 1, 0 ); - t.true( isnan( x[ 0 ] ), 'returns expected value' ); + t.ok( isnan( x[ 0 ] ), 'returns expected value' ); t.strictEqual( x[ 1 ], -4.0, 'returns expected value' ); t.strictEqual( x[ 2 ], 1.0, 'returns expected value' ); x = [ NaN, -4.0, 1.0 ]; gfillNaN( -4, 0.0, x, 1, 0 ); - t.true( isnan( x[ 0 ] ), 'returns expected value' ); + t.ok( isnan( x[ 0 ] ), 'returns expected value' ); t.strictEqual( x[ 1 ], -4.0, 'returns expected value' ); t.strictEqual( x[ 2 ], 1.0, 'returns expected value' ); From 1ba862f95de69f7dca28f9a9531a862aade401c9 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:22:04 -0700 Subject: [PATCH 13/16] test: add missing accessor array test Signed-off-by: Athan --- .../ext/base/gfill-nan/test/test.ndarray.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js index 73666022d59e..197b6e28d00e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/test/test.ndarray.js @@ -272,3 +272,29 @@ tape( 'the function supports an offset parameter', function test( t ) { t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an offset parameter (accessors)', function test( t ) { + var expected; + var x; + + x = [ + 1.0, + NaN, // 0 + 3.0, + NaN, // 1 + 5.0, + 6.0 // 2 + ]; + expected = [ + 1.0, + 0.0, // 0 + 3.0, + 0.0, // 1 + 5.0, + 6.0 // 2 + ]; + + gfillNaN( 3, 0.0, toAccessorArray( x ), 2, 1 ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); From 1fd869c54a8a1f484b10c86434d2f75690ca07ff Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:24:51 -0700 Subject: [PATCH 14/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gfill-nan/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md index 8c7c841b9e02..bb1a0fed25f5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md @@ -48,7 +48,7 @@ The function has the following parameters: - **x**: input array. - **strideX**: stride length. -The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to replace every other NaN element: +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to iterate over every other element: ```javascript var x = [ NaN, 1.0, NaN, -5.0, NaN, 0.0, -1.0, -3.0 ]; @@ -62,13 +62,13 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -// Initial array... +// Initial array: var x0 = new Float64Array( [ 1.0, NaN, 3.0, NaN, 5.0, -6.0 ] ); -// Create an offset view... +// Create an offset view: var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -// Replace every other NaN element... +// Iterate every other element: gfillNaN( 3, 0.0, x1, 2 ); // x0 => [ 1.0, 0.0, 3.0, 0.0, 5.0, -6.0 ] ``` From 1be27b9a7088dd129189f7a3f72a4b3806e48356 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:25:27 -0700 Subject: [PATCH 15/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md index bb1a0fed25f5..7e88b31119f1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/README.md @@ -68,7 +68,7 @@ var x0 = new Float64Array( [ 1.0, NaN, 3.0, NaN, 5.0, -6.0 ] ); // Create an offset view: var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -// Iterate every other element: +// Iterate over every other element: gfillNaN( 3, 0.0, x1, 2 ); // x0 => [ 1.0, 0.0, 3.0, 0.0, 5.0, -6.0 ] ``` From 52c6b27e8a0d09b14b31df475f14a16afba52774 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 5 Jul 2026 03:27:25 -0700 Subject: [PATCH 16/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts index a5c9f8de02e7..5ac16e8f4683 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-nan/docs/types/test.ts @@ -27,7 +27,7 @@ import gfillNaN = require( './index' ); const x = new Float64Array( 10 ); gfillNaN( x.length, 0.0, x, 1 ); // $ExpectType Float64Array - gfillNaN( x.length, 0.0, new AccessorArray( x ), 1 ); // $ExpectType AccessorArrayLike + gfillNaN( x.length, 0.0, new AccessorArray( x ), 1 ); // $ExpectType AccessorArray } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -86,7 +86,7 @@ import gfillNaN = require( './index' ); const x = new Float64Array( 10 ); gfillNaN.ndarray( x.length, 0.0, x, 1, 0 ); // $ExpectType Float64Array - gfillNaN.ndarray( x.length, 0.0, new AccessorArray( x ), 1, 0 ); // $ExpectType AccessorArrayLike + gfillNaN.ndarray( x.length, 0.0, new AccessorArray( x ), 1, 0 ); // $ExpectType AccessorArray } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...