From 50fff661d627bb5bf5aa77c85edfb9fc029a1901 Mon Sep 17 00:00:00 2001
From: AtharvaPatange <164712914+AtharvaPatange@users.noreply.github.com>
Date: Fri, 4 Dec 2026 23:42:59 +0530
Subject: [PATCH 1/2] feat: add `blas/ext/base/ndarray/dnannsum`
Ref: https://github.com/stdlib-js/stdlib/issues/14404
---
.../blas/ext/base/ndarray/dnannsum/README.md | 127 +++++++
.../ndarray/dnannsum/benchmark/benchmark.js | 124 +++++++
.../ext/base/ndarray/dnannsum/docs/repl.txt | 32 ++
.../ndarray/dnannsum/docs/types/index.d.ts | 55 +++
.../base/ndarray/dnannsum/docs/types/test.ts | 63 ++++
.../base/ndarray/dnannsum/examples/index.js | 43 +++
.../ext/base/ndarray/dnannsum/lib/index.js | 47 +++
.../ext/base/ndarray/dnannsum/lib/main.js | 67 ++++
.../ext/base/ndarray/dnannsum/package.json | 69 ++++
.../ext/base/ndarray/dnannsum/test/test.js | 318 ++++++++++++++++++
10 files changed, 945 insertions(+)
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/README.md
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/benchmark/benchmark.js
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/repl.txt
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/types/index.d.ts
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/types/test.ts
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/examples/index.js
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/lib/index.js
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/lib/main.js
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/package.json
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/test/test.js
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/README.md
new file mode 100644
index 000000000000..9d9e852d6a49
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/README.md
@@ -0,0 +1,127 @@
+
+
+# dnannsum
+
+> Compute the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values.
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var dnannsum = require( '@stdlib/blas/ext/base/ndarray/dnannsum' );
+```
+
+#### dnannsum( arrays )
+
+Computes the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values.
+
+```javascript
+var Float64Vector = require( '@stdlib/ndarray/vector/float64' );
+
+var x = new Float64Vector( [ 1.0, -2.0, NaN, 2.0 ] );
+var out = new Float64Vector( 2 );
+
+var v = dnannsum( [ x, out ] );
+// returns [ 1.0, 3.0 ]
+
+var bool = ( v === out );
+// returns true
+```
+
+The function has the following parameters:
+
+- **arrays**: array-like object containing the following ndarrays:
+
+ - a one-dimensional input ndarray.
+ - a one-dimensional output ndarray whose first element is the sum and whose second element is the number of non-NaN elements.
+
+
+
+
+
+
+
+## Notes
+
+- If provided an empty one-dimensional input ndarray, the function returns an output ndarray whose sum and number of non-NaN elements are both equal to zero.
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
+var fillBy = require( '@stdlib/ndarray/fill-by' );
+var zeros = require( '@stdlib/ndarray/zeros' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var dnannsum = require( '@stdlib/blas/ext/base/ndarray/dnannsum' );
+
+function clbk() {
+ if ( bernoulli( 0.7 ) > 0 ) {
+ return discreteUniform( 0, 100 );
+ }
+ return NaN;
+}
+
+var opts = {
+ 'dtype': 'float64'
+};
+var x = fillBy( zeros( [ 10 ], opts ), clbk );
+console.log( ndarray2array( x ) );
+
+var out = zeros( [ 2 ], opts );
+dnannsum( [ x, out ] );
+console.log( ndarray2array( out ) );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/benchmark/benchmark.js
new file mode 100644
index 000000000000..7e312acdaf4e
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/benchmark/benchmark.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 bench = require( '@stdlib/bench' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
+var fillBy = require( '@stdlib/ndarray/fill-by' );
+var zeros = require( '@stdlib/ndarray/zeros' );
+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 dnannsum = require( './../lib' );
+
+
+// VARIABLES //
+
+var options = {
+ 'dtype': 'float64'
+};
+
+
+// FUNCTIONS //
+
+/**
+* Returns a random number.
+*
+* @private
+* @returns {number} random number
+*/
+function rand() {
+ if ( bernoulli( 0.7 ) > 0 ) {
+ return discreteUniform( -10.0, 10.0 );
+ }
+ return NaN;
+}
+
+/**
+* Creates a benchmark function.
+*
+* @private
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( len ) {
+ var out;
+ var x;
+
+ x = fillBy( zeros( [ len ], options ), rand );
+ out = zeros( [ 2 ], options );
+
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var v;
+ var i;
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = dnannsum( [ x, out ] );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( isnan( v.get( i%2 ) ) ) {
+ 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/ndarray/dnannsum/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/repl.txt
new file mode 100644
index 000000000000..ab087b12b84f
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/repl.txt
@@ -0,0 +1,32 @@
+
+{{alias}}( arrays )
+ Computes the sum of a one-dimensional double-precision floating-point
+ ndarray, ignoring `NaN` values.
+
+ If provided an empty input ndarray, the function returns an output ndarray
+ whose sum and number of non-NaN elements are both equal to zero.
+
+ Parameters
+ ----------
+ arrays: ArrayLikeObject
+ Array-like object containing the following ndarrays:
+
+ - a one-dimensional input ndarray.
+ - a one-dimensional output ndarray whose first element is the sum and
+ whose second element is the number of non-NaN elements.
+
+ Returns
+ -------
+ out: ndarray
+ Output ndarray.
+
+ Examples
+ --------
+ > var x = new {{alias:@stdlib/ndarray/vector/float64}}( [ 1.0, -2.0, NaN, 2.0 ] );
+ > var out = new {{alias:@stdlib/ndarray/vector/float64}}( 2 );
+ > {{alias}}( [ x, out ] )
+ [ 1.0, 3.0 ]
+
+ See Also
+ --------
+
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/types/index.d.ts
new file mode 100644
index 000000000000..baf785a5343b
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/types/index.d.ts
@@ -0,0 +1,55 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// TypeScript Version: 4.1
+
+///
+
+import { float64ndarray } from '@stdlib/types/ndarray';
+
+/**
+* Computes the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values.
+*
+* ## Notes
+*
+* - The function expects the following ndarrays:
+*
+* - a one-dimensional input ndarray.
+* - a one-dimensional output ndarray whose first element is the sum and whose second element is the number of non-NaN elements.
+*
+* @param arrays - array-like object containing ndarrays
+* @returns output ndarray
+*
+* @example
+* var Float64Vector = require( '@stdlib/ndarray/vector/float64' );
+*
+* var x = new Float64Vector( [ 1.0, -2.0, NaN, 2.0 ] );
+* var out = new Float64Vector( 2 );
+*
+* var v = dnannsum( [ x, out ] );
+* // returns [ 1.0, 3.0 ]
+*
+* var bool = ( v === out );
+* // returns true
+*/
+declare function dnannsum( arrays: [ float64ndarray, float64ndarray ] ): float64ndarray;
+
+
+// EXPORTS //
+
+export = dnannsum;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/types/test.ts
new file mode 100644
index 000000000000..26cae9432d39
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/docs/types/test.ts
@@ -0,0 +1,63 @@
+/*
+* @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 dnannsum = require( './index' );
+
+
+// TESTS //
+
+// The function returns an ndarray...
+{
+ const x = zeros( [ 10 ], {
+ 'dtype': 'float64'
+ });
+ const out = zeros( [ 2 ], {
+ 'dtype': 'float64'
+ });
+
+ dnannsum( [ x, out ] ); // $ExpectType float64ndarray
+}
+
+// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays...
+{
+ dnannsum( '10' ); // $ExpectError
+ dnannsum( 10 ); // $ExpectError
+ dnannsum( true ); // $ExpectError
+ dnannsum( false ); // $ExpectError
+ dnannsum( null ); // $ExpectError
+ dnannsum( undefined ); // $ExpectError
+ dnannsum( [] ); // $ExpectError
+ dnannsum( {} ); // $ExpectError
+ dnannsum( ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ const x = zeros( [ 10 ], {
+ 'dtype': 'float64'
+ });
+ const out = zeros( [ 2 ], {
+ 'dtype': 'float64'
+ });
+
+ dnannsum(); // $ExpectError
+ dnannsum( [ x, out ], {} ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/examples/index.js
new file mode 100644
index 000000000000..4d20ff5859dd
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/examples/index.js
@@ -0,0 +1,43 @@
+/**
+* @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 bernoulli = require( '@stdlib/random/base/bernoulli' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
+var fillBy = require( '@stdlib/ndarray/fill-by' );
+var zeros = require( '@stdlib/ndarray/zeros' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var dnannsum = require( './../lib' );
+
+function clbk() {
+ if ( bernoulli( 0.7 ) > 0 ) {
+ return discreteUniform( 0, 100 );
+ }
+ return NaN;
+}
+
+var opts = {
+ 'dtype': 'float64'
+};
+var x = fillBy( zeros( [ 10 ], opts ), clbk );
+console.log( ndarray2array( x ) );
+
+var out = zeros( [ 2 ], opts );
+dnannsum( [ x, out ] );
+console.log( ndarray2array( out ) );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/lib/index.js
new file mode 100644
index 000000000000..ea22022dbe62
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/lib/index.js
@@ -0,0 +1,47 @@
+/**
+* @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';
+
+/**
+* Compute the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values.
+*
+* @module @stdlib/blas/ext/base/ndarray/dnannsum
+*
+* @example
+* var Float64Vector = require( '@stdlib/ndarray/vector/float64' );
+* var dnannsum = require( '@stdlib/blas/ext/base/ndarray/dnannsum' );
+*
+* var x = new Float64Vector( [ 1.0, -2.0, NaN, 2.0 ] );
+* var out = new Float64Vector( 2 );
+*
+* var v = dnannsum( [ x, out ] );
+* // returns [ 1.0, 3.0 ]
+*
+* var bool = ( v === out );
+* // returns true
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/lib/main.js
new file mode 100644
index 000000000000..58a84fda1e3e
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnannsum/lib/main.js
@@ -0,0 +1,67 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' );
+var getStride = require( '@stdlib/ndarray/base/stride' );
+var getOffset = require( '@stdlib/ndarray/base/offset' );
+var getData = require( '@stdlib/ndarray/base/data-buffer' );
+var strided = require( '@stdlib/blas/ext/base/dnannsum' ).ndarray;
+
+
+// MAIN //
+
+/**
+* Computes the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values.
+*
+* ## Notes
+*
+* - The function expects the following ndarrays:
+*
+* - a one-dimensional input ndarray.
+* - a one-dimensional output ndarray whose first element is the sum and whose second element is the number of non-NaN elements.
+*
+* @param {ArrayLikeObject