diff --git a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/README.md b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/README.md
index d8d36cad837f..6cee8045f0c4 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/README.md
@@ -119,6 +119,7 @@ var v = gnannsumkbn.ndarray( 4, x, 2, 1, out, 2, 1 );
## Notes
- If `N <= 0`, both functions return a sum equal to `0.0`.
+- 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])
@@ -190,6 +191,8 @@ console.log( out );
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
+[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
+
[@neumaier:1974a]: https://doi.org/10.1002/zamm.19740540106
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/docs/types/index.d.ts
index ccec623bb8d4..1e54a5bfd54e 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/docs/types/index.d.ts
@@ -20,7 +20,17 @@
///
-import { NumericArray } from '@stdlib/types/array';
+import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';
+
+/**
+* Input array.
+*/
+type InputArray = NumericArray | Collection | AccessorArrayLike;
+
+/**
+* Output array.
+*/
+type OutputArray = NumericArray | Collection | AccessorArrayLike;
/**
* Interface describing `gnannsumkbn`.
@@ -43,7 +53,7 @@ interface Routine {
* var v = gnannsumkbn( x.length, x, 1, out, 1 );
* // returns [ 1.0, 3 ]
*/
- ( N: number, x: NumericArray, strideX: number, out: NumericArray, strideOut: number ): NumericArray;
+ ( N: number, x: InputArray, strideX: number, out: T, strideOut: number ): T;
/**
* Computes the sum of strided array elements, ignoring `NaN` values and using an improved Kahan–Babuška algorithm and alternative indexing semantics.
@@ -64,7 +74,7 @@ interface Routine {
* var v = gnannsumkbn( x.length, x, 1, 0, out, 1, 0 );
* // returns [ 1.0, 3 ]
*/
- ndarray( N: number, x: NumericArray, strideX: number, offsetX: number, out: NumericArray, strideOut: number, offsetOut: number ): NumericArray;
+ ndarray( N: number, x: InputArray, strideX: number, offsetX: number, out: T, strideOut: number, offsetOut: number ): T;
}
/**
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/docs/types/test.ts
index d762c4dc77f0..9dc24e6a430c 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/docs/types/test.ts
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import AccessorArray = require( '@stdlib/array/base/accessor' );
import gnannsumkbn = require( './index' );
@@ -26,7 +27,8 @@ import gnannsumkbn = require( './index' );
const x = new Float64Array( 10 );
const out = new Float64Array( 2 );
- gnannsumkbn( x.length, x, 1, out, 1 ); // $ExpectType NumericArray
+ gnannsumkbn( x.length, x, 1, out, 1 ); // $ExpectType Float64Array
+ gnannsumkbn( x.length, new AccessorArray( x ), 1, new AccessorArray( out ), 1 ); // $ExpectType AccessorArray
}
// The compiler throws an error if the function is provided a first argument which is not a number...
@@ -123,7 +125,8 @@ import gnannsumkbn = require( './index' );
const x = new Float64Array( 10 );
const out = new Float64Array( 2 );
- gnannsumkbn.ndarray( x.length, x, 1, 0, out, 1, 0 ); // $ExpectType NumericArray
+ gnannsumkbn.ndarray( x.length, x, 1, 0, out, 1, 0 ); // $ExpectType Float64Array
+ gnannsumkbn.ndarray( x.length, new AccessorArray( x ), 1, 0, new AccessorArray( out ), 1, 0 ); // $ExpectType AccessorArray
}
// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/lib/accessors.js
new file mode 100644
index 000000000000..a1f3c819bb47
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/lib/accessors.js
@@ -0,0 +1,122 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var abs = require( '@stdlib/math/base/special/abs' );
+
+
+// MAIN //
+
+/**
+* Computes the sum of strided array elements, ignoring `NaN` values and using an improved Kahan–Babuška algorithm.
+*
+* ## Method
+*
+* - This implementation uses an "improved Kahan–Babuška algorithm", as described by Neumaier (1974).
+*
+* ## References
+*
+* - Neumaier, Arnold. 1974. "Rounding Error Analysis of Some Methods for Summing Finite Sums." _Zeitschrift Für Angewandte Mathematik Und Mechanik_ 54 (1): 39–51. doi:[10.1002/zamm.19740540106](https://doi.org/10.1002/zamm.19740540106).
+*
+* @private
+* @param {PositiveInteger} N - number of indexed elements
+* @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 for `x`
+* @param {NonNegativeInteger} offsetX - starting index for `x`
+* @param {Object} out - output array object
+* @param {Collection} out.data - output array data
+* @param {Array} out.accessors - array element accessors
+* @param {integer} strideOut - stride length for `out`
+* @param {NonNegativeInteger} offsetOut - starting index for `out`
+* @returns {Object} output array object
+*
+* @example
+* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
+* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+*
+* var x = toAccessorArray( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
+* var out = toAccessorArray( [ 0.0, 0 ] );
+*
+* var v = gnannsumkbn( 5, arraylike2object( x ), 2, 1, arraylike2object( out ), 1, 0 );
+* // returns {...}
+*/
+function gnannsumkbn( N, x, strideX, offsetX, out, strideOut, offsetOut ) {
+ var obuf;
+ var xbuf;
+ var xget;
+ var oset;
+ var sum;
+ var ix;
+ var v;
+ var t;
+ var c;
+ var n;
+ var i;
+
+ // Cache reference to array data:
+ xbuf = x.data;
+ obuf = out.data;
+
+ // Cache reference to the element accessors:
+ xget = x.accessors[ 0 ];
+ oset = out.accessors[ 1 ];
+
+ sum = 0.0;
+ ix = offsetX;
+ if ( strideX === 0 ) {
+ v = xget( xbuf, ix );
+ if ( isnan( v ) ) {
+ oset( obuf, offsetOut, sum );
+ oset( obuf, offsetOut+strideOut, 0 );
+ return out;
+ }
+ oset( obuf, offsetOut, v * N );
+ oset( obuf, offsetOut+strideOut, N );
+ return out;
+ }
+ c = 0.0;
+ n = 0;
+ for ( i = 0; i < N; i++ ) {
+ v = xget( xbuf, ix );
+ if ( isnan( v ) === false ) {
+ t = sum + v;
+ if ( abs( sum ) >= abs( v ) ) {
+ c += (sum-t) + v;
+ } else {
+ c += (v-t) + sum;
+ }
+ sum = t;
+ n += 1;
+ }
+ ix += strideX;
+ }
+ oset( obuf, offsetOut, sum + c );
+ oset( obuf, offsetOut+strideOut, n );
+ return out;
+}
+
+
+// EXPORTS //
+
+module.exports = gnannsumkbn;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/lib/ndarray.js
index 1c2cc2d86869..e883654d1ac8 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/lib/ndarray.js
@@ -20,8 +20,10 @@
// MODULES //
+var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
+var accessors = require( './accessors.js' );
// MAIN //
@@ -56,6 +58,8 @@ var abs = require( '@stdlib/math/base/special/abs' );
function gnannsumkbn( N, x, strideX, offsetX, out, strideOut, offsetOut ) {
var sum;
var ix;
+ var ox;
+ var oo;
var v;
var t;
var c;
@@ -68,6 +72,12 @@ function gnannsumkbn( N, x, strideX, offsetX, out, strideOut, offsetOut ) {
out[ offsetOut+strideOut ] = 0;
return out;
}
+ ox = arraylike2object( x );
+ oo = arraylike2object( out );
+ if ( ox.accessorProtocol || oo.accessorProtocol ) {
+ accessors( N, ox, strideX, offsetX, oo, strideOut, offsetOut );
+ return out;
+ }
ix = offsetX;
if ( strideX === 0 ) {
if ( isnan( x[ ix ] ) ) {
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/test/test.main.js
index 42f172749130..96bebc504201 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/test/test.main.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/test/test.main.js
@@ -22,6 +22,7 @@
var tape = require( 'tape' );
var Float64Array = require( '@stdlib/array/float64' );
+var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
var gnannsumkbn = require( './../lib' );
@@ -119,6 +120,100 @@ tape( 'the function calculates the sum of strided array elements (ignoring NaN v
t.end();
});
+tape( 'the function calculates the sum of strided array elements (ignoring NaN values, accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var x;
+ var v;
+
+ x = toAccessorArray([
+ 1.0,
+ -2.0,
+ -4.0,
+ 5.0,
+ 0.0,
+ NaN,
+ 3.0,
+ 0.0,
+ -3.0,
+ 3.0,
+ NaN
+ ]);
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, out, 1 );
+
+ expected = [ 3.0, 9.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, 3.0, NaN ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, out, 1 );
+
+ expected = [ 3.0, 6.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ -4.0, NaN, -4.0 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, out, 1 );
+
+ expected = [ -8.0, 2.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ NaN, 4.0 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, out, 1 );
+
+ expected = [ 4.0, 1.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ NaN, NaN ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, out, 1 );
+
+ expected = [ 0.0, 0.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ NaN ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, out, 1 );
+
+ expected = [ 0.0, 0.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ 4.0 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, out, 1 );
+
+ expected = [ 4.0, 1.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ 1.0, 1.0e100, 1.0, -1.0e100 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, out, 1 );
+
+ expected = [ 2.0, 4.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns a sum equal to `0.0`', function test( t ) {
var expected;
var out;
@@ -187,6 +282,37 @@ tape( 'the function supports `stride` parameters', function test( t ) {
t.end();
});
+tape( 'the function supports `stride` parameters (accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var v;
+ var x;
+
+ x = toAccessorArray([
+ 1.0, // 0
+ 2.0,
+ 2.0, // 1
+ -7.0,
+ -2.0, // 2
+ 3.0,
+ 4.0, // 3
+ 2.0,
+ NaN, // 4
+ NaN
+ ]);
+ obuf = [ 0.0, 0.0, 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+
+ v = gnannsumkbn( 5, x, 2, out, 2 );
+
+ expected = [ 5.0, 0.0, 4.0, 0.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports negative `stride` parameters', function test( t ) {
var expected;
var out;
@@ -215,6 +341,37 @@ tape( 'the function supports negative `stride` parameters', function test( t ) {
t.end();
});
+tape( 'the function supports negative `stride` parameters (accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var x;
+ var v;
+
+ x = toAccessorArray([
+ NaN, // 4
+ NaN,
+ 1.0, // 3
+ 2.0,
+ 2.0, // 2
+ -7.0,
+ -2.0, // 1
+ 3.0,
+ 4.0, // 0
+ 2.0
+ ]);
+ obuf = [ 0.0, 0.0, 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+
+ v = gnannsumkbn( 5, x, -2, out, -2 );
+
+ expected = [ 4.0, 0.0, 5.0, 0.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided a `stride` parameter equal to `0`, the function returns the of the first element repeated N times', function test( t ) {
var expected;
var out;
@@ -232,6 +389,25 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the o
t.end();
});
+tape( 'if provided a `stride` parameter equal to `0`, the function returns the of the first element repeated N times (accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var x;
+ var v;
+
+ x = toAccessorArray( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 0, out, 1 );
+
+ expected = [ 5.0, 5.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns `0.0`', function test( t ) {
var expected;
var out;
@@ -249,6 +425,25 @@ tape( 'if provided a `stride` parameter equal to `0` and the first element is `N
t.end();
});
+tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns `0.0` (accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var x;
+ var v;
+
+ x = toAccessorArray( [ NaN, -2.0, -4.0, 5.0, 3.0 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 0, out, 1 );
+
+ expected = [ 0.0, 0.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports view offsets', function test( t ) {
var expected0;
var expected1;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/test/test.ndarray.js
index b3fb5364bf72..1541e682967e 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/gnannsumkbn/test/test.ndarray.js
@@ -21,6 +21,7 @@
// MODULES //
var tape = require( 'tape' );
+var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
var gnannsumkbn = require( './../lib/ndarray.js' );
@@ -118,6 +119,100 @@ tape( 'the function calculates the sum of strided array elements (ignoring NaN v
t.end();
});
+tape( 'the function calculates the sum of strided array elements (ignoring NaN values, accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var x;
+ var v;
+
+ x = toAccessorArray([
+ 1.0,
+ -2.0,
+ -4.0,
+ 5.0,
+ 0.0,
+ NaN,
+ 3.0,
+ 0.0,
+ -3.0,
+ 3.0,
+ NaN
+ ]);
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, 0, out, 1, 0 );
+
+ expected = [ 3.0, 9.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, 3.0, NaN ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, 0, out, 1, 0 );
+
+ expected = [ 3.0, 6.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ -4.0, NaN, -4.0 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, 0, out, 1, 0 );
+
+ expected = [ -8.0, 2.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ NaN, 4.0 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, 0, out, 1, 0 );
+
+ expected = [ 4.0, 1.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ NaN, NaN ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, 0, out, 1, 0 );
+
+ expected = [ 0.0, 0.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ NaN ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, 0, out, 1, 0 );
+
+ expected = [ 0.0, 0.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ 4.0 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, 0, out, 1, 0 );
+
+ expected = [ 4.0, 1.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ x = toAccessorArray( [ 1.0, 1.0e100, 1.0, -1.0e100 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 1, 0, out, 1, 0 );
+
+ expected = [ 2.0, 4.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0.0`', function test( t ) {
var expected;
var out;
@@ -186,6 +281,37 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
t.end();
});
+tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var v;
+ var x;
+
+ x = toAccessorArray([
+ 1.0, // 0
+ 2.0,
+ 2.0, // 1
+ -7.0,
+ -2.0, // 2
+ 3.0,
+ 4.0, // 3
+ 2.0,
+ NaN, // 4
+ NaN
+ ]);
+ obuf = [ 0.0, 0.0, 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+
+ v = gnannsumkbn( 5, x, 2, 0, out, 2, 0 );
+
+ expected = [ 5.0, 0.0, 4.0, 0.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports a negative `stride` parameter', function test( t ) {
var expected;
var out;
@@ -214,6 +340,37 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
t.end();
});
+tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var x;
+ var v;
+
+ x = toAccessorArray([
+ NaN, // 4
+ NaN,
+ 1.0, // 3
+ 2.0,
+ 2.0, // 2
+ -7.0,
+ -2.0, // 1
+ 3.0,
+ 4.0, // 0
+ 2.0
+ ]);
+ obuf = [ 0.0, 0.0, 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+
+ v = gnannsumkbn( 5, x, -2, 8, out, -2, 2 );
+
+ expected = [ 4.0, 0.0, 5.0, 0.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided a `stride` parameter equal to `0`, the function returns the of the first element repeated N times', function test( t ) {
var expected;
var out;
@@ -231,6 +388,25 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the o
t.end();
});
+tape( 'if provided a `stride` parameter equal to `0`, the function returns the of the first element repeated N times (accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var x;
+ var v;
+
+ x = toAccessorArray( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 0, 0, out, 1, 0 );
+
+ expected = [ 5.0, 5.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns `0.0`', function test( t ) {
var expected;
var out;
@@ -248,6 +424,25 @@ tape( 'if provided a `stride` parameter equal to `0` and the first element is `N
t.end();
});
+tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns `0.0` (accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var x;
+ var v;
+
+ x = toAccessorArray( [ NaN, -2.0, -4.0, 5.0, 3.0 ] );
+ obuf = [ 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+ v = gnannsumkbn( x.length, x, 0, 0, out, 1, 0 );
+
+ expected = [ 0.0, 0.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports `offset` parameters', function test( t ) {
var expected;
var out;
@@ -275,3 +470,34 @@ tape( 'the function supports `offset` parameters', function test( t ) {
t.end();
});
+
+tape( 'the function supports `offset` parameters (accessors)', function test( t ) {
+ var expected;
+ var obuf;
+ var out;
+ var x;
+ var v;
+
+ x = toAccessorArray([
+ 2.0,
+ 1.0, // 0
+ 2.0,
+ -2.0, // 1
+ -2.0,
+ 2.0, // 2
+ 3.0,
+ 4.0, // 3
+ NaN,
+ NaN // 4
+ ]);
+ obuf = [ 0.0, 0.0, 0.0, 0.0 ];
+ out = toAccessorArray( obuf );
+
+ v = gnannsumkbn( 5, x, 2, 1, out, 2, 1 );
+
+ expected = [ 0.0, 5.0, 0.0, 4.0 ];
+ t.strictEqual( v, out, 'returns expected value' );
+ t.deepEqual( obuf, expected, 'returns expected value' );
+
+ t.end();
+});