diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/README.md index 71d4acba54ec..fee160d72f1e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/README.md @@ -51,7 +51,7 @@ The [_L1_ norm][l1norm] is defined as var sasumpw = require( '@stdlib/blas/ext/base/sasumpw' ); ``` -#### sasumpw( N, x, stride ) +#### sasumpw( N, x, strideX ) Computes the sum of absolute values ([_L1_ norm][l1norm]) of single-precision floating-point strided array elements using pairwise summation. @@ -59,9 +59,8 @@ Computes the sum of absolute values ([_L1_ norm][l1norm]) of single-precision fl var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -var N = x.length; -var v = sasumpw( N, x, 1 ); +var v = sasumpw( x.length, x, 1 ); // returns 5.0 ``` @@ -69,9 +68,9 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Float32Array`][@stdlib/array/float32]. -- **stride**: index increment for `x`. +- **stride**: 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 absolute values of every other element in `x`, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of absolute values of every other element: ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -96,7 +95,7 @@ var v = sasumpw( 4, x1, 2 ); // returns 9.0 ``` -#### sasumpw.ndarray( N, x, stride, offset ) +#### sasumpw.ndarray( N, x, strideX, offsetX ) Computes the sum of absolute values ([_L1_ norm][l1norm]) of single-precision floating-point strided array elements using pairwise summation and alternative indexing semantics. @@ -104,17 +103,16 @@ Computes the sum of absolute values ([_L1_ norm][l1norm]) of single-precision fl var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -var N = x.length; -var v = sasumpw.ndarray( N, x, 1, 0 ); +var v = sasumpw.ndarray( x.length, x, 1, 0 ); // returns 5.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 absolute values of every other value in `x` 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 absolute values of every other element starting from the second element: ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -147,11 +145,12 @@ var v = sasumpw.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 sasumpw = require( '@stdlib/blas/ext/base/sasumpw' ); -var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'float32' +}); console.log( x ); var v = sasumpw( x.length, x, 1 ); @@ -162,8 +161,123 @@ console.log( v ); + + * * * +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/sasumpw.h" +``` + +#### stdlib_strided_sasumpw( N, \*X, strideX ) + +Computes the sum of absolute values ([_L1_ norm][l1norm]) of single-precision floating-point strided array elements using pairwise summation. + +```c +const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f } + +float v = stdlib_strided_sasumpw( 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_sasumpw( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); +``` + +#### stdlib_strided_sasumpw_ndarray( N, \*X, strideX, offsetX ) + +Computes the sum of absolute values ([_L1_ norm][l1norm]) of single-precision floating-point strided array elements using pairwise summation and alternative indexing semantics. + +```c +const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f } + +float v = stdlib_strided_sasumpw_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_sasumpw_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/ext/base/sasumpw.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 indexed elements: + const int N = 8; + + // Specify a stride: + const int strideX = 1; + + // Compute the sum: + float v = stdlib_strided_sasumpw( N, x, strideX ); + + // Print the result: + printf( "sumabs: %f\n", v ); +} +``` + +
+ + + +
+ + +
## References diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.js index 6a6fd9c6a57c..663a70aa54fd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; @@ -31,7 +30,9 @@ var sasumpw = require( './../lib/sasumpw.js' ); // VARIABLES // -var rand = uniform( -100.0, 100.0 ); +var options = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -44,7 +45,7 @@ var rand = uniform( -100.0, 100.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/sasumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.native.js index 3c378c2ac2f5..42361ad19d62 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.native.js @@ -22,11 +22,9 @@ 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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); - var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -37,7 +35,9 @@ var sasumpw = tryRequire( resolve( __dirname, './../lib/sasumpw.native.js' ) ); var opts = { 'skip': ( sasumpw instanceof Error ) }; -var rand = uniform( -100.0, 100.0 ); +var options = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -50,7 +50,7 @@ var rand = uniform( -100.0, 100.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/sasumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.js index a8a5f2a62579..2629611a6740 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; @@ -31,7 +30,9 @@ var sasumpw = require( './../lib/ndarray.js' ); // VARIABLES // -var rand = uniform( -100.0, 100.0 ); +var options = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -44,7 +45,7 @@ var rand = uniform( -100.0, 100.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/sasumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.native.js index 37276b0febad..b24835f9fae1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -36,8 +35,9 @@ var sasumpw = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( sasumpw instanceof Error ) }; - -var rand = uniform( -100.0, 100.0 ); +var options = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -50,7 +50,7 @@ var rand = uniform( -100.0, 100.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/sasumpw/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/c/benchmark.length.c index 91039fef9d09..cbda2fdbb842 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/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_sasumpw( 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_sasumpw_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/sasumpw/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/docs/repl.txt index 1774f5a709d6..6d862901ce62 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/docs/repl.txt @@ -1,10 +1,10 @@ -{{alias}}( N, x, stride ) +{{alias}}( N, x, strideX ) Computes the sum of absolute values (L1 norm) of single-precision floating- point strided array elements using pairwise summation. - 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 ) 5.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 ) 5.0 @@ -46,13 +46,13 @@ 5.0 -{{alias}}.ndarray( N, x, stride, offset ) +{{alias}}.ndarray( N, x, strideX, offsetX ) Computes the sum of absolute values (L1 norm) of single-precision floating- point strided array elements using pairwise summation 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 + 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/sasumpw/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/docs/types/index.d.ts index 3c08de014e05..2455965d0a3c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/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 = sasumpw( x.length, x, 1 ); * // returns 5.0 */ - ( N: number, x: Float32Array, stride: number ): number; + ( N: number, x: Float32Array, strideX: number ): number; /** * Computes the sum of absolute values (L1 norm) of single-precision floating-point strided array elements using pairwise summation 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 = sasumpw.ndarray( x.length, x, 1, 0 ); * // returns 5.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/sasumpw/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/examples/c/example.c index f9aeaa51ea83..0bccb6b926cc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/examples/c/example.c @@ -17,21 +17,20 @@ */ #include "stdlib/blas/ext/base/sasumpw.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; + // Specify the number of indexed elements: + const int N = 8; - // Specify the stride length: - const int64_t stride = 2; + // Specify a stride: + const int strideX = 1; // Compute the sum: - float v = stdlib_strided_sasumpw( N, x, stride ); + float v = stdlib_strided_sasumpw( N, x, strideX ); // Print the result: printf( "sumabs: %f\n", v ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/examples/index.js index 776816d6ddd0..d8b4219a2cb9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/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 sasumpw = require( './../lib' ); -var x = filledarrayBy( 10, 'float32', discreteUniform( -100.0, 100.0 ) ); +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'float32' +}); console.log( x ); var v = sasumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/include/stdlib/blas/ext/base/sasumpw.h b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/include/stdlib/blas/ext/base/sasumpw.h index 3d424d0af630..dd2ff694bf08 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/include/stdlib/blas/ext/base/sasumpw.h +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/include/stdlib/blas/ext/base/sasumpw.h @@ -19,7 +19,7 @@ #ifndef STDLIB_BLAS_EXT_BASE_SASUMPW_H #define STDLIB_BLAS_EXT_BASE_SASUMPW_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 absolute values (L1 norm) of single-precision floating-point strided array elements using pairwise summation. */ -float stdlib_strided_sasumpw( const int64_t N, const float *X, const int64_t stride ); +float API_SUFFIX(stdlib_strided_sasumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); + +/** +* Computes the sum of absolute values (L1 norm) of single-precision floating-point strided array elements using pairwise summation and alternative indexing semnatics. +*/ +float API_SUFFIX(stdlib_strided_sasumpw_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/sasumpw/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/index.js index dacab0823113..b95bed4fcba7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/index.js @@ -28,9 +28,8 @@ * var sasumpw = require( '@stdlib/blas/ext/base/sasumpw' ); * * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = sasumpw( N, x, 1 ); +* var v = sasumpw( x.length, x, 1 ); * // returns 5.0 * * @example diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/ndarray.js index 5242573edb4f..664462ceca0a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/ndarray.js @@ -22,7 +22,7 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var floor = require( '@stdlib/math/base/special/floor' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var absf = require( '@stdlib/math/base/special/absf' ); // VARIABLES // @@ -46,8 +46,8 @@ var BLOCKSIZE = 128; * * @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 @@ -58,7 +58,7 @@ var BLOCKSIZE = 128; * var v = sasumpw( 4, x, 2, 1 ); * // returns 9.0 */ -function sasumpw( N, x, stride, offset ) { +function sasumpw( N, x, strideX, offsetX ) { var ix; var s0; var s1; @@ -76,57 +76,57 @@ function sasumpw( N, x, stride, offset ) { if ( N <= 0 ) { return 0.0; } - if ( N === 1 || stride === 0 ) { - return abs( x[ offset ] ); + ix = offsetX; + if ( strideX === 0 ) { + return float64ToFloat32( N * absf( x[ ix ] ) ); } - ix = offset; if ( N < 8 ) { // Use simple summation... s = 0.0; for ( i = 0; i < N; i++ ) { - s = float64ToFloat32( s + abs( x[ ix ] ) ); - ix += stride; + s = float64ToFloat32( s + absf( x[ ix ] ) ); + ix += strideX; } return s; } if ( N <= BLOCKSIZE ) { // Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)... - s0 = abs( x[ ix ] ); - s1 = abs( x[ ix+stride ] ); - s2 = abs( x[ ix+(2*stride) ] ); - s3 = abs( x[ ix+(3*stride) ] ); - s4 = abs( x[ ix+(4*stride) ] ); - s5 = abs( x[ ix+(5*stride) ] ); - s6 = abs( x[ ix+(6*stride) ] ); - s7 = abs( x[ ix+(7*stride) ] ); - ix += 8 * stride; + s0 = absf( x[ ix ] ); + s1 = absf( x[ ix+strideX ] ); + s2 = absf( x[ ix+(2*strideX) ] ); + s3 = absf( x[ ix+(3*strideX) ] ); + s4 = absf( x[ ix+(4*strideX) ] ); + s5 = absf( x[ ix+(5*strideX) ] ); + s6 = absf( x[ ix+(6*strideX) ] ); + s7 = absf( x[ ix+(7*strideX) ] ); + ix += 8 * strideX; M = N % 8; for ( i = 8; i < N-M; i += 8 ) { - s0 = float64ToFloat32( s0 + abs( x[ ix ] ) ); - s1 = float64ToFloat32( s1 + abs( x[ ix+stride ] ) ); - s2 = float64ToFloat32( s2 + abs( x[ ix+(2*stride) ] ) ); - s3 = float64ToFloat32( s3 + abs( x[ ix+(3*stride) ] ) ); - s4 = float64ToFloat32( s4 + abs( x[ ix+(4*stride) ] ) ); - s5 = float64ToFloat32( s5 + abs( x[ ix+(5*stride) ] ) ); - s6 = float64ToFloat32( s6 + abs( x[ ix+(6*stride) ] ) ); - s7 = float64ToFloat32( s7 + abs( x[ ix+(7*stride) ] ) ); - ix += 8 * stride; + s0 = float64ToFloat32( s0 + absf( x[ ix ] ) ); + s1 = float64ToFloat32( s1 + absf( x[ ix+strideX ] ) ); + s2 = float64ToFloat32( s2 + absf( x[ ix+(2*strideX) ] ) ); + s3 = float64ToFloat32( s3 + absf( x[ ix+(3*strideX) ] ) ); + s4 = float64ToFloat32( s4 + absf( x[ ix+(4*strideX) ] ) ); + s5 = float64ToFloat32( s5 + absf( x[ ix+(5*strideX) ] ) ); + s6 = float64ToFloat32( s6 + absf( x[ ix+(6*strideX) ] ) ); + s7 = float64ToFloat32( s7 + absf( x[ ix+(7*strideX) ] ) ); + ix += 8 * strideX; } // Pairwise sum the accumulators: s = float64ToFloat32( float64ToFloat32( float64ToFloat32(s0+s1) + float64ToFloat32(s2+s3) ) + float64ToFloat32( float64ToFloat32(s4+s5) + float64ToFloat32(s6+s7) ) ); // eslint-disable-line max-len // Clean-up loop... for ( i; i < N; i++ ) { - s = float64ToFloat32( s + abs( x[ ix ] ) ); - ix += stride; + s = float64ToFloat32( s + absf( x[ ix ] ) ); + ix += strideX; } return s; } // Recurse by dividing by two, but avoiding non-multiples of unroll factor... n = floor( N/2 ); n -= n % 8; - return float64ToFloat32( sasumpw( n, x, stride, ix ) + sasumpw( N-n, x, stride, ix+(n*stride) ) ); // eslint-disable-line max-len + return float64ToFloat32( sasumpw( n, x, strideX, ix ) + sasumpw( N-n, x, strideX, ix+(n*strideX) ) ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/ndarray.native.js index 5cbf52454d03..f8ebb0c0eb79 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/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( './sasumpw.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -32,8 +30,8 @@ var addon = require( './sasumpw.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 @@ -44,11 +42,8 @@ var addon = require( './sasumpw.native.js' ); * var v = sasumpw( 4, x, 2, 1 ); * // returns 9.0 */ -function sasumpw( N, x, stride, offset ) { - var view; - offset = minViewBufferIndex( N, stride, offset ); - view = offsetView( x, offset ); - return addon( N, view, stride ); +function sasumpw( N, x, strideX, offsetX ) { + return addon.ndarray( N, x, strideX, offsetX ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/sasumpw.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/sasumpw.js index ee1afc1ac462..9df52825fc94 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/sasumpw.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/sasumpw.js @@ -20,9 +20,8 @@ // MODULES // -var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var sum = require( './ndarray.js' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); // MAIN // @@ -40,44 +39,19 @@ var sum = require( './ndarray.js' ); * * @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 = sasumpw( N, x, 1 ); +* var v = sasumpw( x.length, x, 1 ); * // returns 5.0 */ -function sasumpw( N, x, stride ) { - var ix; - var s; - var i; - - if ( N <= 0 ) { - return 0.0; - } - if ( N === 1 || stride === 0 ) { - return abs( x[ 0 ] ); - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - if ( N < 8 ) { - // Use simple summation... - s = 0.0; - for ( i = 0; i < N; i++ ) { - s = float64ToFloat32( s + abs( x[ ix ] ) ); - ix += stride; - } - return s; - } - return sum( N, x, stride, ix ); +function sasumpw( N, x, strideX ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ) ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/sasumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/sasumpw.native.js index 202356129f4e..ae857b1789a9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/sasumpw.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/sasumpw.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 = sasumpw( N, x, 1 ); +* var v = sasumpw( x.length, x, 1 ); * // returns 5.0 */ -function sasumpw( N, x, stride ) { - return addon( N, x, stride ); +function sasumpw( N, x, strideX ) { + return addon( N, x, strideX ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/manifest.json index 9414cf70c710..9644a24c3e15 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/manifest.json @@ -28,49 +28,55 @@ { "task": "build", "src": [ - "./src/sasumpw.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float32array" + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/create-double", + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/absf" ] }, { "task": "benchmark", "src": [ - "./src/sasumpw.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/absf" + ] }, { "task": "examples", "src": [ - "./src/sasumpw.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/absf" + ] } ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/addon.c index d3519c2874db..a229f4715f37 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/addon.c @@ -1,4 +1,3 @@ - /** * @license Apache-2.0 * @@ -18,12 +17,13 @@ */ #include "stdlib/blas/ext/base/sasumpw.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. @@ -35,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, stdlib_strided_sasumpw( 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_sasumpw)( 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_sasumpw_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/sasumpw/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/main.c new file mode 100644 index 000000000000..622997c2e656 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/main.c @@ -0,0 +1,132 @@ +/** +* @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/sasumpw.h" +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/math/base/special/absf.h" + +/** +* Computes the sum of absolute values (L1 norm) of single-precision floating-point strided array elements using pairwise summation. +* +* ## Method +* +* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`. +* +* ## References +* +* - Higham, Nicholas J. 1993. "The Accuracy of Floating Point Summation." _SIAM Journal on Scientific Computing_ 14 (4): 783–99. doi:[10.1137/0914050](https://doi.org/10.1137/0914050). +* +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @return output value +*/ +float API_SUFFIX(stdlib_strided_sasumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) { + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + return API_SUFFIX(stdlib_strided_sasumpw_ndarray)( N, X, strideX, ox ); +} + +/** +* Computes the sum of absolute values (L1 norm) of single-precision floating-point strided array elements using pairwise summation and alternative indexing semantics. +* +* ## Method +* +* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`. +* +* ## References +* +* - Higham, Nicholas J. 1993. "The Accuracy of Floating Point Summation." _SIAM Journal on Scientific Computing_ 14 (4): 783–99. doi:[10.1137/0914050](https://doi.org/10.1137/0914050). +* +* @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_sasumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + CBLAS_INT ix; + CBLAS_INT M; + CBLAS_INT n; + CBLAS_INT i; + float sum; + float s0; + float s1; + float s2; + float s3; + float s4; + float s5; + float s6; + float s7; + + if ( N <= 0 ) { + return 0.0f; + } + ix = offsetX; + if ( strideX == 0 ) { + return N * stdlib_base_absf( X[ ix ] ); + } + if ( N < 8 ) { + // Use simple summation... + sum = 0.0f; + for ( i = 0; i < N; i++ ) { + sum += stdlib_base_absf( X[ ix ] ); + ix += strideX; + } + return sum; + } + // Blocksize for pairwise summation: 128 (NOTE: decreasing the blocksize decreases rounding error as more pairs are summed, but also decreases performance. Because the inner loop is unrolled eight times, the blocksize is effectively `16`.) + if ( N <= 128 ) { + // Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)... + s0 = stdlib_base_absf( X[ ix ] ); + s1 = stdlib_base_absf( X[ ix+strideX ] ); + s2 = stdlib_base_absf( X[ ix+(2*strideX) ] ); + s3 = stdlib_base_absf( X[ ix+(3*strideX) ] ); + s4 = stdlib_base_absf( X[ ix+(4*strideX) ] ); + s5 = stdlib_base_absf( X[ ix+(5*strideX) ] ); + s6 = stdlib_base_absf( X[ ix+(6*strideX) ] ); + s7 = stdlib_base_absf( X[ ix+(7*strideX) ] ); + ix += 8 * strideX; + + M = N % 8; + for ( i = 8; i < N-M; i += 8 ) { + s0 += stdlib_base_absf( X[ ix ] ); + s1 += stdlib_base_absf( X[ ix+strideX ] ); + s2 += stdlib_base_absf( X[ ix+(2*strideX) ] ); + s3 += stdlib_base_absf( X[ ix+(3*strideX) ] ); + s4 += stdlib_base_absf( X[ ix+(4*strideX) ] ); + s5 += stdlib_base_absf( X[ ix+(5*strideX) ] ); + s6 += stdlib_base_absf( X[ ix+(6*strideX) ] ); + s7 += stdlib_base_absf( X[ ix+(7*strideX) ] ); + ix += 8 * strideX; + } + // Pairwise sum the accumulators: + sum = ( (s0+s1) + (s2+s3) ) + ( (s4+s5) + (s6+s7) ); + + // Clean-up loop... + for (; i < N; i++ ) { + sum += stdlib_base_absf( X[ ix ] ); + ix += strideX; + } + return sum; + } + // Recurse by dividing by two, but avoiding non-multiples of unroll factor... + n = N / 2; + n -= n % 8; + return API_SUFFIX(stdlib_strided_sasumpw_ndarray)( n, X, strideX, ix ) + API_SUFFIX(stdlib_strided_sasumpw_ndarray)( N-n, X, strideX, ix+(n*strideX) ); +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/sasumpw.c b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/sasumpw.c deleted file mode 100644 index a40c77ec7513..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/sasumpw.c +++ /dev/null @@ -1,122 +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/sasumpw.h" -#include -#include - -/** -* Computes the sum of absolute values (L1 norm) of single-precision floating-point strided array elements using pairwise summation. -* -* ## Method -* -* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`. -* -* ## References -* -* - Higham, Nicholas J. 1993. "The Accuracy of Floating Point Summation." _SIAM Journal on Scientific Computing_ 14 (4): 783–99. doi:[10.1137/0914050](https://doi.org/10.1137/0914050). -* -* @param N number of indexed elements -* @param X input array -* @param stride stride length -* @return output value -*/ -float stdlib_strided_sasumpw( const int64_t N, const float *X, const int64_t stride ) { - float *xp1; - float *xp2; - int64_t ix; - int64_t M; - int64_t n; - int64_t i; - float sum; - float s0; - float s1; - float s2; - float s3; - float s4; - float s5; - float s6; - float s7; - - if ( N <= 0 ) { - return 0.0f; - } - if ( N == 1 || stride == 0 ) { - return fabsf( X[ 0 ] ); - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - if ( N < 8 ) { - // Use simple summation... - sum = 0.0f; - for ( i = 0; i < N; i++ ) { - sum += fabsf( X[ ix ] ); - ix += stride; - } - return sum; - } - // Blocksize for pairwise summation: 128 (NOTE: decreasing the blocksize decreases rounding error as more pairs are summed, but also decreases performance. Because the inner loop is unrolled eight times, the blocksize is effectively `16`.) - if ( N <= 128 ) { - // Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)... - s0 = fabsf( X[ ix ] ); - s1 = fabsf( X[ ix+stride ] ); - s2 = fabsf( X[ ix+(2*stride) ] ); - s3 = fabsf( X[ ix+(3*stride) ] ); - s4 = fabsf( X[ ix+(4*stride) ] ); - s5 = fabsf( X[ ix+(5*stride) ] ); - s6 = fabsf( X[ ix+(6*stride) ] ); - s7 = fabsf( X[ ix+(7*stride) ] ); - ix += 8 * stride; - - M = N % 8; - for ( i = 8; i < N-M; i += 8 ) { - s0 += fabsf( X[ ix ] ); - s1 += fabsf( X[ ix+stride ] ); - s2 += fabsf( X[ ix+(2*stride) ] ); - s3 += fabsf( X[ ix+(3*stride) ] ); - s4 += fabsf( X[ ix+(4*stride) ] ); - s5 += fabsf( X[ ix+(5*stride) ] ); - s6 += fabsf( X[ ix+(6*stride) ] ); - s7 += fabsf( X[ ix+(7*stride) ] ); - ix += 8 * stride; - } - // Pairwise sum the accumulators: - sum = ((s0+s1) + (s2+s3)) + ((s4+s5) + (s6+s7)); - - // Clean-up loop... - for (; i < N; i++ ) { - sum += fabsf( X[ ix ] ); - ix += stride; - } - return sum; - } - // Recurse by dividing by two, but avoiding non-multiples of unroll factor... - n = N / 2; - n -= n % 8; - if ( stride < 0 ) { - xp1 = (float *)X + ( (n-N)*stride ); - xp2 = (float *)X; - } else { - xp1 = (float *)X; - xp2 = (float *)X + ( n*stride ); - } - return stdlib_strided_sasumpw( n, xp1, stride ) + stdlib_strided_sasumpw( N-n, xp2, stride ); -} diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.js index 4ba34cb8d024..f85303fab5f1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.js @@ -153,14 +153,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 = sasumpw( 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/sasumpw/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.native.js index 4b7824262ed8..cd5885550431 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.native.js @@ -162,14 +162,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 = sasumpw( 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/sasumpw/test/test.sasumpw.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.js index b4edbf624a86..96a4e839df0c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.js @@ -153,14 +153,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 = sasumpw( 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/sasumpw/test/test.sasumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.native.js index 241143d176ce..a653885b8c27 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.native.js @@ -244,14 +244,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 = sasumpw( x.length, x, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); + t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); });