diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/README.md b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/README.md index 559b9b5ba945..4889c376e16d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/README.md @@ -36,7 +36,7 @@ limitations under the License. var ssumkbn2 = require( '@stdlib/blas/ext/base/ssumkbn2' ); ``` -#### ssumkbn2( N, x, stride ) +#### ssumkbn2( N, x, strideX ) Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm. @@ -45,7 +45,7 @@ var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -var v = ssumkbn2( 3, x, 1 ); +var v = ssumkbn2( x.length, x, 1 ); // returns 1.0 ``` @@ -53,9 +53,9 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Float32Array`][@stdlib/array/float32]. -- **stride**: index increment for `x`. +- **strideX**: stride length. -The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of every other element in the strided array, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of every other element: ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -80,7 +80,7 @@ var v = ssumkbn2( 4, x1, 2 ); // returns 5.0 ``` -#### ssumkbn2.ndarray( N, x, stride, offset ) +#### ssumkbn2.ndarray( N, x, strideX, offsetX ) Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics. @@ -89,15 +89,15 @@ var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -var v = ssumkbn2.ndarray( 3, x, 1, 0 ); +var v = ssumkbn2.ndarray( x.length, x, 1, 0 ); // returns 1.0 ``` The function has the following additional parameters: -- **offset**: starting index for `x`. +- **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 calculate the sum of every other value in the strided array starting from the second value +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 calculate the sum of every other element starting from the second element: ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -129,11 +129,12 @@ var v = ssumkbn2.ndarray( 4, x, 2, 1 ); ```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledarrayBy = require( '@stdlib/array/filled-by' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var ssumkbn2 = require( '@stdlib/blas/ext/base/ssumkbn2' ); -var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'float32' +}); console.log( x ); var v = ssumkbn2( x.length, x, 1 ); @@ -144,8 +145,123 @@ console.log( v ); + + * * * +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/ssumkbn2.h" +``` + +#### stdlib_strided_ssumkbn2( N, \*X, strideX ) + +Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm. + +```c +const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f }; + +float v = stdlib_strided_ssumkbn2( 4, x, 1 ); +// returns 10.0f +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] float*` input array. +- **strideX**: `[in] CBLAS_INT` stride length. + +```c +float stdlib_strided_ssumkbn2( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); +``` + +#### stdlib_strided_ssumkbn2_ndarray( N, \*X, strideX, offsetX ) + +Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics. + +```c +const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f }; + +float v = stdlib_strided_ssumkbn2_ndarray( 4, x, 1, 0 ); +// returns 10.0f +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] float*` input array. +- **strideX**: `[in] CBLAS_INT` stride length. +- **offsetX**: `[in] CBLAS_INT` starting index. + +```c +float stdlib_strided_ssumkbn2_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/ext/base/ssumkbn2.h" +#include + +int main( void ) { + // Create a strided array: + const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + + // Specify the number of elements: + const int N = 4; + + // Specify the stride length: + const int strideX = 2; + + // Compute the sum: + float v = stdlib_strided_ssumkbn2( N, x, strideX ); + + // Print the result: + printf( "Sum: %f\n", v ); +} +``` + +
+ + + +
+ + +
## References diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.js index 60bdbb4563cd..16876ed407fa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var filledarrayBy = require( '@stdlib/array/filled-by' ); +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 pkg = require( './../package.json' ).name; @@ -31,7 +30,9 @@ var ssumkbn2 = require( './../lib/ssumkbn2.js' ); // VARIABLES // -var rand = uniform( -10.0, 10.0 ); +var options = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -44,7 +45,7 @@ var rand = uniform( -10.0, 10.0 ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'float32', rand ); + var x = uniform( len, -100, 100, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.native.js index a1eaec4f45c1..4db4904848a4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var filledarrayBy = require( '@stdlib/array/filled-by' ); +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 tryRequire = require( '@stdlib/utils/try-require' ); @@ -36,7 +35,9 @@ var ssumkbn2 = tryRequire( resolve( __dirname, './../lib/ssumkbn2.native.js' ) ) var opts = { 'skip': ( ssumkbn2 instanceof Error ) }; -var rand = uniform( -10.0, 10.0 ); +var options = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -49,7 +50,7 @@ var rand = uniform( -10.0, 10.0 ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'float32', rand ); + var x = uniform( len, -100, 100, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.ndarray.js index 98e5b5a90024..023b7e3c2e7b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.ndarray.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var filledarrayBy = require( '@stdlib/array/filled-by' ); +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 pkg = require( './../package.json' ).name; @@ -31,7 +30,9 @@ var ssumkbn2 = require( './../lib/ndarray.js' ); // VARIABLES // -var rand = uniform( -10.0, 10.0 ); +var options = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -44,7 +45,7 @@ var rand = uniform( -10.0, 10.0 ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'float32', rand ); + var x = uniform( len, -100, 100, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.ndarray.native.js index dbec12a0f3ce..6cd565ff24d8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/benchmark.ndarray.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var filledarrayBy = require( '@stdlib/array/filled-by' ); +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 tryRequire = require( '@stdlib/utils/try-require' ); @@ -36,7 +35,9 @@ var ssumkbn2 = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( ssumkbn2 instanceof Error ) }; -var rand = uniform( -10.0, 10.0 ); +var options = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -49,7 +50,7 @@ var rand = uniform( -10.0, 10.0 ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'float32', rand ); + var x = uniform( len, -100, 100, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/c/benchmark.length.c index 1e52aee5e655..53c130d94e78 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/benchmark/c/benchmark.length.c @@ -94,7 +94,7 @@ static float rand_float( void ) { * @param len array length * @return elapsed time in seconds */ -static double benchmark( int iterations, int len ) { +static double benchmark1( int iterations, int len ) { double elapsed; float x[ len ]; float v; @@ -107,6 +107,7 @@ static double benchmark( int iterations, int len ) { v = 0.0f; t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar v = stdlib_strided_ssumkbn2( len, x, 1 ); if ( v != v ) { printf( "should not return NaN\n" ); @@ -120,6 +121,40 @@ static double benchmark( int iterations, int len ) { return elapsed; } +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + float x[ len ]; + float v; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_float()*20000.0f ) - 10000.0f; + } + v = 0.0f; + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + v = stdlib_strided_ssumkbn2_ndarray( len, x, 1, 0 ); + if ( v != v ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( v != v ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + /** * Main execution sequence. */ @@ -142,7 +177,18 @@ int main( void ) { for ( j = 0; j < REPEATS; j++ ) { count += 1; printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark( iter, len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/docs/repl.txt index 8f336b417db4..3309c32a60e5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/docs/repl.txt @@ -1,10 +1,10 @@ -{{alias}}( N, x, stride ) +{{alias}}( N, x, strideX ) Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm. - The `N` and `stride` parameters determine which elements in the strided - array are accessed at runtime. + 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 a typed array view. @@ -19,8 +19,8 @@ x: Float32Array Input array. - stride: integer - Index increment. + strideX: integer + Stride length. Returns ------- @@ -34,7 +34,7 @@ > {{alias}}( x.length, x, 1 ) 1.0 - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); > {{alias}}( 3, x, 2 ) 1.0 @@ -46,14 +46,14 @@ -1.0 -{{alias}}.ndarray( N, x, stride, offset ) +{{alias}}.ndarray( N, x, strideX, offsetX ) Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm and 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. + buffer, the offset parameter supports indexing semantics based on a starting + index. Parameters ---------- @@ -63,10 +63,10 @@ x: Float32Array Input array. - stride: integer - Index increment. + strideX: integer + Stride length. - offset: integer + offsetX: integer Starting index. Returns diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/docs/types/index.d.ts index b4c6e56e7fa1..d267a9b649a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length + * @param strideX - stride length * @returns sum * * @example @@ -38,15 +38,15 @@ interface Routine { * var v = ssumkbn2( x.length, x, 1 ); * // returns 1.0 */ - ( N: number, x: Float32Array, stride: number ): number; + ( N: number, x: Float32Array, strideX: number ): number; /** * Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics. * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length - * @param offset - starting index + * @param strideX - stride length + * @param offsetX - starting index * @returns sum * * @example @@ -57,7 +57,7 @@ interface Routine { * var v = ssumkbn2.ndarray( x.length, x, 1, 0 ); * // returns 1.0 */ - ndarray( N: number, x: Float32Array, stride: number, offset: number ): number; + ndarray( N: number, x: Float32Array, strideX: number, offsetX: number ): number; } /** @@ -65,7 +65,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array -* @param stride - stride length +* @param strideX - stride length * @returns sum * * @example diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/examples/c/example.c index 2175eec36feb..d0af8f8f0c76 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/examples/c/example.c @@ -17,22 +17,21 @@ */ #include "stdlib/blas/ext/base/ssumkbn2.h" -#include #include int main( void ) { // Create a strided array: - const float x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; // Specify the number of elements: - const int64_t N = 4; + const int N = 4; // Specify the stride length: - const int64_t stride = 2; + const int strideX = 2; // Compute the sum: - float v = stdlib_strided_ssumkbn2( N, x, stride ); + float v = stdlib_strided_ssumkbn2( N, x, strideX ); // Print the result: - printf( "sum: %f\n", v ); + printf( "Sum: %f\n", v ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/examples/index.js index bbee99dcd2c7..dd145657e125 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/examples/index.js @@ -18,11 +18,12 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledarrayBy = require( '@stdlib/array/filled-by' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var ssumkbn2 = require( './../lib' ); -var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'float32' +}); console.log( x ); var v = ssumkbn2( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/include/stdlib/blas/ext/base/ssumkbn2.h b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/include/stdlib/blas/ext/base/ssumkbn2.h index d53445e699eb..24dc05bb0f8a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/include/stdlib/blas/ext/base/ssumkbn2.h +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/include/stdlib/blas/ext/base/ssumkbn2.h @@ -19,7 +19,7 @@ #ifndef STDLIB_BLAS_EXT_BASE_SSUMKBN2_H #define STDLIB_BLAS_EXT_BASE_SSUMKBN2_H -#include +#include "stdlib/blas/base/shared.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -31,7 +31,12 @@ extern "C" { /** * Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm. */ -float stdlib_strided_ssumkbn2( const int64_t N, const float *X, const int64_t stride ); +float API_SUFFIX(stdlib_strided_ssumkbn2)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); + +/** +* Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics. +*/ +float API_SUFFIX(stdlib_strided_ssumkbn2_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/index.js index a5df854a9599..a47fc5980ec5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/index.js @@ -28,20 +28,17 @@ * var ssumkbn2 = require( '@stdlib/blas/ext/base/ssumkbn2' ); * * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = ssumkbn2( N, x, 1 ); +* var v = ssumkbn2( x.length, x, 1 ); * // returns 1.0 * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var ssumkbn2 = require( '@stdlib/blas/ext/base/ssumkbn2' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -* var N = floor( x.length / 2 ); * -* var v = ssumkbn2.ndarray( N, x, 2, 1 ); +* var v = ssumkbn2.ndarray( 4, x, 2, 1 ); * // returns 5.0 */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ndarray.js index 33f27091bf2c..51484b2907dd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ndarray.js @@ -21,7 +21,7 @@ // MODULES // var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var absf = require( '@stdlib/math/base/special/absf' ); // MAIN // @@ -39,21 +39,19 @@ var abs = require( '@stdlib/math/base/special/abs' ); * * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} sum * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -* var N = floor( x.length / 2 ); * -* var v = ssumkbn2( N, x, 2, 1 ); +* var v = ssumkbn2( 4, x, 2, 1 ); * // returns 5.0 */ -function ssumkbn2( N, x, stride, offset ) { +function ssumkbn2( N, x, strideX, offsetX ) { var sum; var ccs; var ix; @@ -67,31 +65,31 @@ function ssumkbn2( N, x, stride, offset ) { if ( N <= 0 ) { return 0.0; } - if ( N === 1 || stride === 0 ) { - return x[ offset ]; + ix = offsetX; + if ( strideX === 0 ) { + return float64ToFloat32( N * x[ ix ] ); } - ix = offset; sum = 0.0; ccs = 0.0; // second order correction term for lost low order bits cs = 0.0; // first order correction term for lost low order bits for ( i = 0; i < N; i++ ) { v = x[ ix ]; t = float64ToFloat32( sum+v ); - if ( abs( sum ) >= abs( v ) ) { + if ( absf( sum ) >= absf( v ) ) { c = float64ToFloat32( float64ToFloat32( sum-t ) + v ); } else { c = float64ToFloat32( float64ToFloat32( v-t ) + sum ); } sum = t; t = float64ToFloat32( cs+c ); - if ( abs( cs ) >= abs( c ) ) { + if ( absf( cs ) >= absf( c ) ) { cc = float64ToFloat32( float64ToFloat32( cs-t ) + c ); } else { cc = float64ToFloat32( float64ToFloat32( c-t ) + cs ); } cs = t; ccs = float64ToFloat32( ccs+cc ); - ix += stride; + ix += strideX; } return float64ToFloat32( sum + float64ToFloat32( cs+ccs ) ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ndarray.native.js index dabdfad578d6..dd7e548e7904 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ndarray.native.js @@ -20,9 +20,7 @@ // MODULES // -var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); -var offsetView = require( '@stdlib/strided/base/offset-view' ); -var addon = require( './ssumkbn2.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -32,8 +30,8 @@ var addon = require( './ssumkbn2.native.js' ); * * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} sum * * @example @@ -41,14 +39,11 @@ var addon = require( './ssumkbn2.native.js' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -* var v = ssumkbn( 4, x, 2, 1 ); +* var v = ssumkbn2( 4, x, 2, 1 ); * // returns 5.0 */ -function ssumkbn2( N, x, stride, offset ) { - var view; - offset = minViewBufferIndex( N, stride, offset ); - view = offsetView( x, offset ); - return addon( N, view, stride ); +function ssumkbn2( N, x, strideX, offsetX ) { + return addon.ndarray( N, x, strideX, offsetX ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ssumkbn2.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ssumkbn2.js index 8bd2ae60b9b7..85ac6bc9cb28 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ssumkbn2.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ssumkbn2.js @@ -20,8 +20,8 @@ // MODULES // -var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); // MAIN // @@ -39,63 +39,19 @@ var abs = require( '@stdlib/math/base/special/abs' ); * * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - input array -* @param {integer} stride - stride length +* @param {integer} strideX - stride length * @returns {number} sum * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = ssumkbn2( N, x, 1 ); +* var v = ssumkbn2( x.length, x, 1 ); * // returns 1.0 */ -function ssumkbn2( N, x, stride ) { - var sum; - var ccs; - var ix; - var cs; - var cc; - var v; - var t; - var c; - var i; - - if ( N <= 0 ) { - return 0.0; - } - if ( N === 1 || stride === 0 ) { - return x[ 0 ]; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - sum = 0.0; - ccs = 0.0; // second order correction term for lost low order bits - cs = 0.0; // first order correction term for lost low order bits - for ( i = 0; i < N; i++ ) { - v = x[ ix ]; - t = float64ToFloat32( sum+v ); - if ( abs( sum ) >= abs( v ) ) { - c = float64ToFloat32( float64ToFloat32( sum-t ) + v ); - } else { - c = float64ToFloat32( float64ToFloat32( v-t ) + sum ); - } - sum = t; - t = float64ToFloat32( cs+c ); - if ( abs( cs ) >= abs( c ) ) { - cc = float64ToFloat32( float64ToFloat32( cs-t ) + c ); - } else { - cc = float64ToFloat32( float64ToFloat32( c-t ) + cs ); - } - cs = t; - ccs = float64ToFloat32( ccs+cc ); - ix += stride; - } - return float64ToFloat32( sum + float64ToFloat32( cs+ccs ) ); +function ssumkbn2( N, x, strideX ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ) ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ssumkbn2.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ssumkbn2.native.js index ad2ff5b7db25..7200eb1ea631 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ssumkbn2.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/lib/ssumkbn2.native.js @@ -30,20 +30,19 @@ var addon = require( './../src/addon.node' ); * * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - input array -* @param {integer} stride - stride length +* @param {integer} strideX - stride length * @returns {number} sum * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = ssumkbn2( N, x, 1 ); +* var v = ssumkbn2( x.length, x, 1 ); * // returns 1.0 */ -function ssumkbn2( N, x, stride ) { - return addon( N, x, stride ); +function ssumkbn2( N, x, strideX ) { + return addon( N, x, strideX ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/manifest.json index 1e76def7807f..8ce308b065e6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/manifest.json @@ -7,7 +7,7 @@ "field": "src", "resolve": true, "relative": true - }, + }, { "field": "include", "resolve": true, @@ -28,49 +28,55 @@ { "task": "build", "src": [ - "./src/ssumkbn2.c" + "./src/main.c" ], "include": [ - "./include" - ], - "libraries": [ - "-lm" + "./include" ], + "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/napi/export", - "@stdlib/napi/argv", - "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float32array" + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/create-double", + "@stdlib/math/base/special/absf", + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/base/shared" ] }, { "task": "benchmark", "src": [ - "./src/ssumkbn2.c" + "./src/main.c" ], "include": [ - "./include" - ], - "libraries": [ - "-lm" + "./include" ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/math/base/special/absf", + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/base/shared" + ] }, { "task": "examples", "src": [ - "./src/ssumkbn2.c" + "./src/main.c" ], "include": [ - "./include" - ], - "libraries": [ - "-lm" + "./include" ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/math/base/special/absf", + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/base/shared" + ] } ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/src/addon.c index 2a238ba64904..2d2acca0a8aa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/src/addon.c @@ -17,12 +17,13 @@ */ #include "stdlib/blas/ext/base/ssumkbn2.h" +#include "stdlib/blas/base/shared.h" #include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" #include "stdlib/napi/argv_int64.h" #include "stdlib/napi/argv_strided_float32array.h" +#include "stdlib/napi/create_double.h" #include -#include /** * Receives JavaScript callback invocation data. @@ -34,14 +35,27 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 3 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); - STDLIB_NAPI_ARGV_INT64( env, stride, argv, 2 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 1 ); - - napi_value v; - napi_status status = napi_create_double( env, (double)stdlib_strided_ssumkbn2( N, X, stride ), &v ); - assert( status == napi_ok ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(stdlib_strided_ssumkbn2)( N, X, strideX ), v ); + return v; +} +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 4 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(stdlib_strided_ssumkbn2_ndarray)( N, X, strideX, offsetX ), v ); return v; } -STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/src/main.c new file mode 100644 index 000000000000..ce865effd990 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/src/main.c @@ -0,0 +1,103 @@ +/** +* @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. +*/ + +#include "stdlib/blas/ext/base/ssumkbn2.h" +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/math/base/special/absf.h" +#include "stdlib/blas/base/shared.h" + +/** +* Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm. +* +* ## Method +* +* - This implementation uses a second-order iterative Kahan–Babuška algorithm, as described by Klein (2005). +* +* ## References +* +* - Klein, Andreas. 2005. "A Generalized Kahan-Babuška-Summation-Algorithm." _Computing_ 76 (3): 279–93. doi:[10.1007/s00607-005-0139-x](https://doi.org/10.1007/s00607-005-0139-x). +* +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @return output value +*/ +float API_SUFFIX(stdlib_strided_ssumkbn2)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) { + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + return API_SUFFIX(stdlib_strided_ssumkbn2_ndarray)( N, X, strideX, ox ); +} + +/** +* Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics. +* +* ## Method +* +* - This implementation uses a second-order iterative Kahan–Babuška algorithm, as described by Klein (2005). +* +* ## References +* +* - Klein, Andreas. 2005. "A Generalized Kahan-Babuška-Summation-Algorithm." _Computing_ 76 (3): 279–93. doi:[10.1007/s00607-005-0139-x](https://doi.org/10.1007/s00607-005-0139-x). +* +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @param offsetX starting index +* @return output value +*/ +float API_SUFFIX(stdlib_strided_ssumkbn2_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + CBLAS_INT ix; + CBLAS_INT i; + float sum; + float ccs; + float cs; + float cc; + float v; + float t; + float c; + + if ( N <= 0 ) { + return 0.0f; + } + ix = offsetX; + if ( strideX == 0 ) { + return N * X[ ix ]; + } + sum = 0.0f; + ccs = 0.0f; // second order correction term for lost lower order bits + cs = 0.0f; // first order correction term for lost low order bits + for ( i = 0; i < N; i++ ) { + v = X[ ix ]; + t = sum + v; + if ( stdlib_base_absf( sum ) >= stdlib_base_absf( v ) ) { + c = ( sum - t ) + v; + } else { + c = ( v - t ) + sum; + } + sum = t; + t = cs + c; + if ( stdlib_base_absf( cs ) >= stdlib_base_absf( c ) ) { + cc = ( cs - t ) + c; + } else { + cc = ( c - t ) + cs; + } + cs = t; + ccs += cc; + ix += strideX; + } + return sum + cs + ccs; +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/src/ssumkbn2.c b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/src/ssumkbn2.c deleted file mode 100644 index 5125222e5deb..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/src/ssumkbn2.c +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -#include "stdlib/blas/ext/base/ssumkbn2.h" -#include -#include - -/** -* Computes the sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm. -* -* ## Method -* -* - This implementation uses a second-order iterative Kahan–Babuška algorithm, as described by Klein (2005). -* -* ## References -* -* - Klein, Andreas. 2005. "A Generalized Kahan-Babuška-Summation-Algorithm." _Computing_ 76 (3): 279–93. doi:[10.1007/s00607-005-0139-x](https://doi.org/10.1007/s00607-005-0139-x). -* -* @param N number of indexed elements -* @param X input array -* @param stride stride length -* @return output value -*/ -float stdlib_strided_ssumkbn2( const int64_t N, const float *X, const int64_t stride ) { - int64_t ix; - int64_t i; - float sum; - float ccs; - float cs; - float cc; - float v; - float t; - float c; - - if ( N <= 0 ) { - return 0.0f; - } - if ( N == 1 || stride == 0 ) { - return X[ 0 ]; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - sum = 0.0f; - ccs = 0.0f; // second order correction term for lost lower order bits - cs = 0.0f; // first order correction term for lost low order bits - for ( i = 0; i < N; i++ ) { - v = X[ ix ]; - t = sum + v; - if ( fabsf( sum ) >= fabsf( v ) ) { - c = (sum-t) + v; - } else { - c = (v-t) + sum; - } - sum = t; - t = cs + c; - if ( fabsf( cs ) >= fabsf( c ) ) { - cc = (cs-t) + c; - } else { - cc = (c-t) + cs; - } - cs = t; - ccs += cc; - ix += stride; - } - return sum + cs + ccs; -} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ndarray.js index dfcae8688377..d38f9ae581a9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ndarray.js @@ -135,14 +135,14 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) t.end(); }); -tape( 'if provided a `stride` parameter equal to `0`, the function returns the first indexed element', function test( t ) { +tape( 'if provided a `stride` parameter equal to `0`, the function returns the sum of the first element repeated N times', function test( t ) { var x; var v; x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); v = ssumkbn2( x.length, x, 0, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); + t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ndarray.native.js index 3e618933ed7c..889cf0d860ed 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ndarray.native.js @@ -144,14 +144,14 @@ tape( 'the function supports a negative `stride` parameter', opts, function test t.end(); }); -tape( 'if provided a `stride` parameter equal to `0`, the function returns the first indexed element', opts, function test( t ) { +tape( 'if provided a `stride` parameter equal to `0`, the function returns the sum of the first element repeated N times', opts, function test( t ) { var x; var v; x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); v = ssumkbn2( x.length, x, 0, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); + t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ssumkbn2.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ssumkbn2.js index 090bb4c85990..9fa00cbd96ab 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ssumkbn2.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ssumkbn2.js @@ -135,14 +135,14 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) t.end(); }); -tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', function test( t ) { +tape( 'if provided a `stride` parameter equal to `0`, the function returns the sum of the first element repeated N times', function test( t ) { var x; var v; x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); v = ssumkbn2( x.length, x, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); + t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ssumkbn2.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ssumkbn2.native.js index d86d11fbda9d..692583053e68 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ssumkbn2.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn2/test/test.ssumkbn2.native.js @@ -226,14 +226,14 @@ tape( 'the function supports a negative `stride` parameter', opts, function test t.end(); }); -tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', opts, function test( t ) { +tape( 'if provided a `stride` parameter equal to `0`, the function returns the sum of the first element repeated N times', opts, function test( t ) { var x; var v; x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); v = ssumkbn2( x.length, x, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); + t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); });