diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/README.md b/lib/node_modules/@stdlib/blas/ext/base/dsum/README.md
index febeda650931..b21e017bc972 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/README.md
@@ -36,7 +36,7 @@ limitations under the License.
var dsum = require( '@stdlib/blas/ext/base/dsum' );
```
-#### dsum( N, x, stride )
+#### dsum( N, x, strideX )
Computes the sum of double-precision floating-point strided array elements.
@@ -44,9 +44,8 @@ Computes the sum of double-precision floating-point strided array elements.
var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-var N = x.length;
-var v = dsum( N, x, 1 );
+var v = dsum( x.length, x, 1 );
// returns 1.0
```
@@ -54,9 +53,9 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **x**: input [`Float64Array`][@stdlib/array/float64].
-- **stride**: index increment for `x`.
+- **strideX**: stride length for `x`.
-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 Float64Array = require( '@stdlib/array/float64' );
@@ -81,7 +80,7 @@ var v = dsum( 4, x1, 2 );
// returns 5.0
```
-#### dsum.ndarray( N, x, stride, offset )
+#### dsum.ndarray( N, x, strideX, offsetX )
Computes the sum of double-precision floating-point strided array elements using alternative indexing semantics.
@@ -90,15 +89,15 @@ var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-var v = dsum.ndarray( 3, x, 1, 0 );
+var v = dsum.ndarray( x.length, x, 1, 0 );
// returns 1.0
```
The function has the following additional parameters:
-- **offset**: starting index for `x`.
+- **offsetX**: starting index for `x`.
-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 Float64Array = require( '@stdlib/array/float64' );
@@ -130,11 +129,12 @@ var v = dsum.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 dsum = require( '@stdlib/blas/ext/base/dsum' );
-var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) );
+var x = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float64'
+});
console.log( x );
var v = dsum( x.length, x, 1 );
@@ -145,6 +145,123 @@ console.log( v );
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/blas/ext/base/dsum.h"
+```
+
+#### stdlib_strided_dsum( N, \*X, strideX )
+
+Computes the sum of double-precision floating-point strided array elements.
+
+```c
+const double x[] = { 1.0, 2.0, 3.0, 4.0 };
+
+double v = stdlib_strided_dsum( 4, x, 1 );
+// returns 10.0
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **X**: `[in] double*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+
+```c
+double stdlib_strided_dsum( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
+```
+
+#### stdlib_strided_dsum_ndarray( N, \*X, strideX, offsetX )
+
+Computes the sum of double-precision floating-point strided array elements using alternative indexing semantics.
+
+```c
+const double x[] = { 1.0, 2.0, 3.0, 4.0 };
+
+double v = stdlib_strided_dsum_ndarray( 4, x, 1, 0 );
+// returns 10.0
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **X**: `[in] double*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
+
+```c
+double stdlib_strided_dsum_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/blas/ext/base/dsum.h"
+#include
+
+int main( void ) {
+ // Create a strided array:
+ const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
+
+ // Specify the number of elements:
+ const int N = 4;
+
+ // Specify the stride length:
+ const int strideX = 2;
+
+ // Compute the sum:
+ double v = stdlib_strided_dsum( N, x, strideX );
+
+ // Print the result:
+ printf( "sum: %lf\n", v );
+}
+```
+
+
+
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.js
index 4cea809eacf3..377c0d01c848 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/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 dsum = require( './../lib/dsum.js' );
// VARIABLES //
-var rand = uniform( -10.0, 10.0 );
+var options = {
+ 'dtype': 'float64'
+};
// FUNCTIONS //
@@ -44,7 +45,7 @@ var rand = uniform( -10.0, 10.0 );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x = filledarrayBy( len, 'float64', rand );
+ var x = uniform( len, -100, 100, options );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.native.js
index a5cdc68d94f8..1238c5ff7b2a 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/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 dsum = tryRequire( resolve( __dirname, './../lib/dsum.native.js' ) );
var opts = {
'skip': ( dsum instanceof Error )
};
-var rand = uniform( -10.0, 10.0 );
+var options = {
+ 'dtype': 'float64'
+};
// FUNCTIONS //
@@ -49,7 +50,7 @@ var rand = uniform( -10.0, 10.0 );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x = filledarrayBy( len, 'float64', rand );
+ var x = uniform( len, -100, 100, options );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.ndarray.js
index 26b8ec1af487..da81f62b6392 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/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 dsum = require( './../lib/ndarray.js' );
// VARIABLES //
-var rand = uniform( -10.0, 10.0 );
+var options = {
+ 'dtype': 'float64'
+};
// FUNCTIONS //
@@ -44,7 +45,7 @@ var rand = uniform( -10.0, 10.0 );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x = filledarrayBy( len, 'float64', rand );
+ var x = uniform( len, -100, 100, options );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.ndarray.native.js
index eff365899b03..74e4a2893c99 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/benchmark.ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/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 dsum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
var opts = {
'skip': ( dsum instanceof Error )
};
-var rand = uniform( -10.0, 10.0 );
+var options = {
+ 'dtype': 'float64'
+};
// FUNCTIONS //
@@ -49,7 +50,7 @@ var rand = uniform( -10.0, 10.0 );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x = filledarrayBy( len, 'float64', rand );
+ var x = uniform( len, -100, 100, options );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/c/benchmark.length.c
index 01689a6b2f62..d6513e8c7308 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/c/benchmark.length.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/benchmark/c/benchmark.length.c
@@ -94,7 +94,7 @@ static double rand_double( 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;
double x[ len ];
double v;
@@ -107,6 +107,7 @@ static double benchmark( int iterations, int len ) {
v = 0.0;
t = tic();
for ( i = 0; i < iterations; i++ ) {
+ // cppcheck-suppress uninitvar
v = stdlib_strided_dsum( 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;
+ double x[ len ];
+ double v;
+ double t;
+ int i;
+
+ for ( i = 0; i < len; i++ ) {
+ x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
+ }
+ v = 0.0;
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ // cppcheck-suppress uninitvar
+ v = stdlib_strided_dsum_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/dsum/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dsum/docs/repl.txt
index 377feb1ce2d3..6aa6e0cfed0f 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/docs/repl.txt
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/docs/repl.txt
@@ -1,5 +1,5 @@
-{{alias}}( N, x, stride )
+{{alias}}( N, x, strideX )
Computes the sum of double-precision floating-point strided array elements.
The `N` and stride parameters determine which elements in the strided array
@@ -18,8 +18,8 @@
x: Float64Array
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride length.
Returns
-------
@@ -45,12 +45,12 @@
-1.0
-{{alias}}.ndarray( N, x, stride, offset )
+{{alias}}.ndarray( N, x, strideX, offsetX )
Computes the sum of double-precision floating-point strided array elements
using alternative indexing semantics.
While typed array views mandate a view offset based on the underlying
- buffer, the `offset` parameter supports indexing semantics based on a
+ buffer, the offset parameter supports indexing semantics based on a
starting index.
Parameters
@@ -61,10 +61,10 @@
x: Float64Array
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/dsum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dsum/docs/types/index.d.ts
index 8b707d033fb2..1d7854069742 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/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 = dsum( x.length, x, 1 );
* // returns 1.0
*/
- ( N: number, x: Float64Array, stride: number ): number;
+ ( N: number, x: Float64Array, strideX: number ): number;
/**
* Computes the sum of double-precision floating-point strided array elements using 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 = dsum.ndarray( x.length, x, 1, 0 );
* // returns 1.0
*/
- ndarray( N: number, x: Float64Array, stride: number, offset: number ): number;
+ ndarray( N: number, x: Float64Array, 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/dsum/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dsum/examples/c/example.c
index cd40532ba101..6a616e747eec 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/examples/c/example.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/examples/c/example.c
@@ -17,7 +17,6 @@
*/
#include "stdlib/blas/ext/base/dsum.h"
-#include
#include
int main( void ) {
@@ -25,13 +24,13 @@ int main( void ) {
const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
// 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:
- double v = stdlib_strided_dsum( N, x, stride );
+ double v = stdlib_strided_dsum( N, x, strideX );
// Print the result:
printf( "sum: %lf\n", v );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/examples/index.js
index a04aad391efe..0abd6f3eadd5 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/examples/index.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/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 dsum = require( './../lib' );
-var x = filledarrayBy( 10, 'float64', discreteUniform( -100, 100 ) );
+var x = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float64'
+});
console.log( x );
var v = dsum( x.length, x, 1 );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/include/stdlib/blas/ext/base/dsum.h b/lib/node_modules/@stdlib/blas/ext/base/dsum/include/stdlib/blas/ext/base/dsum.h
index 02956b8027ce..79067b5986a4 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/include/stdlib/blas/ext/base/dsum.h
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/include/stdlib/blas/ext/base/dsum.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_BLAS_EXT_BASE_DSUM_H
#define STDLIB_BLAS_EXT_BASE_DSUM_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 double-precision floating-point strided array elements.
*/
-double stdlib_strided_dsum( const int64_t N, const double *X, const int64_t stride );
+double API_SUFFIX(stdlib_strided_dsum)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
+
+/**
+* Computes the sum of double-precision floating-point strided array elements using alternative indexing semantics.
+*/
+double API_SUFFIX(stdlib_strided_dsum_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
#ifdef __cplusplus
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/dsum.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/dsum.js
index 89ef52db791a..ab3d42a7fa50 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/dsum.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/dsum.js
@@ -20,7 +20,8 @@
// MODULES //
-var dsumkbn = require( '@stdlib/blas/ext/base/dsumkbn' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
// MAIN //
@@ -30,20 +31,19 @@ var dsumkbn = require( '@stdlib/blas/ext/base/dsumkbn' );
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
* @returns {number} sum
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-* var N = x.length;
*
-* var v = dsum( N, x, 1 );
+* var v = dsum( x.length, x, 1 );
* // returns 1.0
*/
-function dsum( N, x, stride ) {
- return dsumkbn( N, x, stride );
+function dsum( N, x, strideX ) {
+ return ndarray( N, x, strideX, stride2offset( N, strideX ) );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/dsum.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/dsum.native.js
index 01cf87a1f5c0..d4f3ba65e42c 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/dsum.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/dsum.native.js
@@ -30,20 +30,19 @@ var addon = require( './../src/addon.node' );
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
* @returns {number} sum
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-* var N = x.length;
*
-* var v = dsum( N, x, 1 );
+* var v = dsum( x.length, x, 1 );
* // returns 1.0
*/
-function dsum( N, x, stride ) {
- return addon( N, x, stride );
+function dsum( N, x, strideX ) {
+ return addon( N, x, strideX );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/index.js
index 75edc8af8417..5e80f35fa3de 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/index.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/index.js
@@ -28,20 +28,17 @@
* var dsum = require( '@stdlib/blas/ext/base/dsum' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-* var N = x.length;
*
-* var v = dsum( N, x, 1 );
+* var v = dsum( x.length, x, 1 );
* // returns 1.0
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
* var dsum = require( '@stdlib/blas/ext/base/dsum' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
-* var N = floor( x.length / 2 );
*
-* var v = dsum.ndarray( N, x, 2, 1 );
+* var v = dsum.ndarray( 4, x, 2, 1 );
* // returns 5.0
*/
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/ndarray.js
index 41db7aa81ea1..f29a242ece27 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/ndarray.js
@@ -30,22 +30,20 @@ var dsumkbn = require( '@stdlib/blas/ext/base/dsumkbn' ).ndarray;
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Float64Array} 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 Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
-* var N = floor( x.length / 2 );
*
-* var v = dsum( N, x, 2, 1 );
+* var v = dsum( 4, x, 2, 1 );
* // returns 5.0
*/
-function dsum( N, x, stride, offset ) {
- return dsumkbn( N, x, stride, offset );
+function dsum( N, x, strideX, offsetX ) {
+ return dsumkbn( N, x, strideX, offsetX );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/ndarray.native.js
index 143045bfea42..4e56591c45ba 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/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( './dsum.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -32,25 +30,20 @@ var addon = require( './dsum.native.js' );
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Float64Array} 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 Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
-* var N = floor( x.length / 2 );
*
-* var v = dsum( N, x, 2, 1 );
+* var v = dsum( 4, x, 2, 1 );
* // returns 5.0
*/
-function dsum( N, x, stride, offset ) {
- var view;
- offset = minViewBufferIndex( N, stride, offset );
- view = offsetView( x, offset );
- return addon( N, view, stride );
+function dsum( N, x, strideX, offsetX ) {
+ return addon.ndarray( N, x, strideX, offsetX );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dsum/manifest.json
index 728a21a922b9..c2096aec68a5 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/manifest.json
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/manifest.json
@@ -28,7 +28,7 @@
{
"task": "build",
"src": [
- "./src/dsum.c"
+ "./src/main.c"
],
"include": [
"./include"
@@ -40,13 +40,16 @@
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-int64",
- "@stdlib/napi/argv-strided-float64array"
+ "@stdlib/napi/argv-strided-float64array",
+ "@stdlib/napi/create-double",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
]
},
{
"task": "benchmark",
"src": [
- "./src/dsum.c"
+ "./src/main.c"
],
"include": [
"./include"
@@ -54,13 +57,15 @@
"libraries": [],
"libpath": [],
"dependencies": [
- "@stdlib/blas/ext/base/dsumkbn"
+ "@stdlib/blas/ext/base/dsumkbn",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
]
},
{
"task": "examples",
"src": [
- "./src/dsum.c"
+ "./src/main.c"
],
"include": [
"./include"
@@ -68,7 +73,9 @@
"libraries": [],
"libpath": [],
"dependencies": [
- "@stdlib/blas/ext/base/dsumkbn"
+ "@stdlib/blas/ext/base/dsumkbn",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
]
}
]
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dsum/src/addon.c
index 97ab81aa2ce6..94c657e673d8 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/src/addon.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/src/addon.c
@@ -17,10 +17,12 @@
*/
#include "stdlib/blas/ext/base/dsum.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_float64array.h"
+#include "stdlib/napi/create_double.h"
#include
/**
@@ -33,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_FLOAT64ARRAY( env, X, N, stride, argv, 1 );
-
- napi_value v;
- napi_status status = napi_create_double( env, stdlib_strided_dsum( N, X, stride ), &v );
- assert( status == napi_ok );
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 );
+ STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dsum)( 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_FLOAT64ARRAY( env, X, N, strideX, argv, 1 );
+ STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dsum_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/dsum/src/dsum.c b/lib/node_modules/@stdlib/blas/ext/base/dsum/src/dsum.c
deleted file mode 100644
index ddfa700a96e7..000000000000
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/src/dsum.c
+++ /dev/null
@@ -1,33 +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/dsum.h"
-#include "stdlib/blas/ext/base/dsumkbn.h"
-#include
-
-/**
-* Computes the sum of double-precision floating-point strided array elements.
-*
-* @param N number of indexed elements
-* @param X input array
-* @param stride stride length
-* @return output value
-*/
-double stdlib_strided_dsum( const int64_t N, const double *X, const int64_t stride ) {
- return stdlib_strided_dsumkbn( N, X, stride );
-}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dsum/src/main.c
new file mode 100644
index 000000000000..1419c595d3cc
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/src/main.c
@@ -0,0 +1,48 @@
+/**
+* @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/dsum.h"
+#include "stdlib/blas/ext/base/dsumkbn.h"
+#include "stdlib/blas/base/shared.h"
+#include "stdlib/strided/base/stride2offset.h"
+
+/**
+* Computes the sum of double-precision floating-point strided array elements.
+*
+* @param N number of indexed elements
+* @param X input array
+* @param strideX stride length
+* @return output value
+*/
+double API_SUFFIX(stdlib_strided_dsum)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) {
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ return API_SUFFIX(stdlib_strided_dsum_ndarray)( N, X, strideX, ox );
+}
+
+/**
+* Computes the sum of double-precision floating-point strided array elements.
+*
+* @param N number of indexed elements
+* @param X input array
+* @param strideX stride length
+* @param offsetX starting index
+* @return output value
+*/
+double API_SUFFIX(stdlib_strided_dsum_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
+ return API_SUFFIX(stdlib_strided_dsumkbn_ndarray)( N, X, strideX, offsetX );
+}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.dsum.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.dsum.js
index 2dfc3d5be1c2..aeffb8d7debe 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.dsum.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.dsum.js
@@ -139,14 +139,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 Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );
v = dsum( 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/dsum/test/test.dsum.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.dsum.native.js
index bdcb51522b5e..d066aa21d51d 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.dsum.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.dsum.native.js
@@ -230,14 +230,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 Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );
v = dsum( 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/dsum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.ndarray.js
index 69b88a66fa92..223b3c8bf77a 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.ndarray.js
@@ -139,14 +139,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 Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );
v = dsum( 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/dsum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.ndarray.native.js
index ced60d19a7b4..6831e067fc99 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsum/test/test.ndarray.native.js
@@ -148,14 +148,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 Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );
v = dsum( x.length, x, 0, 0 );
- t.strictEqual( v, 1.0, 'returns expected value' );
+ t.strictEqual( v, 5.0, 'returns expected value' );
t.end();
});