From f3233918502bf426ec8a2060ce66510c057c0e9d Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sat, 28 Dec 2024 18:15:53 +0000
Subject: [PATCH 1/7] feat: add C ndarray API and refactor
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: na
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- task: lint_c_examples
status: missing_dependencies
- task: lint_c_benchmarks
status: missing_dependencies
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
- task: run_javascript_examples
status: na
- task: run_c_examples
status: na
- task: run_cpp_examples
status: na
- task: run_javascript_readme_examples
status: na
- task: run_c_benchmarks
status: na
- task: run_cpp_benchmarks
status: na
- task: run_fortran_benchmarks
status: na
- task: run_javascript_benchmarks
status: na
- task: run_julia_benchmarks
status: na
- task: run_python_benchmarks
status: na
- task: run_r_benchmarks
status: na
- task: run_javascript_tests
status: na
---
---
.../@stdlib/blas/ext/base/dsumpw/README.md | 140 ++++++++++++++++--
.../ext/base/dsumpw/benchmark/benchmark.js | 9 +-
.../base/dsumpw/benchmark/benchmark.native.js | 9 +-
.../dsumpw/benchmark/benchmark.ndarray.js | 9 +-
.../benchmark/benchmark.ndarray.native.js | 9 +-
.../dsumpw/benchmark/c/benchmark.length.c | 50 ++++++-
.../blas/ext/base/dsumpw/docs/repl.txt | 22 +--
.../ext/base/dsumpw/docs/types/index.d.ts | 12 +-
.../blas/ext/base/dsumpw/examples/c/example.c | 7 +-
.../blas/ext/base/dsumpw/examples/index.js | 7 +-
.../include/stdlib/blas/ext/base/dsumpw.h | 9 +-
.../blas/ext/base/dsumpw/lib/dsumpw.js | 36 +----
.../blas/ext/base/dsumpw/lib/dsumpw.native.js | 9 +-
.../@stdlib/blas/ext/base/dsumpw/lib/index.js | 3 +-
.../blas/ext/base/dsumpw/lib/ndarray.js | 52 +++----
.../ext/base/dsumpw/lib/ndarray.native.js | 15 +-
.../blas/ext/base/dsumpw/manifest.json | 33 +++--
.../@stdlib/blas/ext/base/dsumpw/src/addon.c | 29 +++-
.../ext/base/dsumpw/src/{dsumpw.c => main.c} | 102 +++++++------
.../blas/ext/base/dsumpw/test/test.dsumpw.js | 4 +-
.../base/dsumpw/test/test.dsumpw.native.js | 4 +-
.../blas/ext/base/dsumpw/test/test.ndarray.js | 4 +-
.../base/dsumpw/test/test.ndarray.native.js | 4 +-
23 files changed, 372 insertions(+), 206 deletions(-)
rename lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/{dsumpw.c => main.c} (50%)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md
index 3c03cbc53312..e0e65bf69bf7 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md
@@ -36,7 +36,7 @@ limitations under the License.
var dsumpw = require( '@stdlib/blas/ext/base/dsumpw' );
```
-#### dsumpw( N, x, stride )
+#### dsumpw( N, x, strideX )
Computes the sum of double-precision floating-point strided array elements using pairwise summation.
@@ -44,9 +44,8 @@ Computes the sum of double-precision floating-point strided array elements using
var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-var N = x.length;
-var v = dsumpw( N, x, 1 );
+var v = dsumpw( 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 `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:
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -81,7 +80,7 @@ var v = dsumpw( 4, x1, 2 );
// returns 5.0
```
-#### dsumpw.ndarray( N, x, stride, offset )
+#### dsumpw.ndarray( N, x, strideX, offsetX )
Computes the sum of double-precision floating-point strided array elements using pairwise summation and alternative indexing semantics.
@@ -89,17 +88,16 @@ Computes the sum of double-precision floating-point strided array elements using
var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-var N = x.length;
-var v = dsumpw.ndarray( N, x, 1, 0 );
+var v = dsumpw.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 `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 every other element starting from the second element:
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -132,11 +130,12 @@ var v = dsumpw.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 dsumpw = require( '@stdlib/blas/ext/base/dsumpw' );
-var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) );
+var x = discreteUniform( 10.0, -100, 100, {
+ 'dtype': 'float64'
+});
console.log( x );
var v = dsumpw( x.length, x, 1 );
@@ -147,8 +146,123 @@ console.log( v );
+
+
* * *
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/blas/ext/base/dsumpw.h"
+```
+
+#### stdlib_strided_dsumpw( N, \*X, strideX )
+
+Computes the sum of double-precision floating-point strided array elements using pairwise summation.
+
+```c
+const double x[] = { 1.0, 2.0, 3.0, 4.0 };
+
+double v = stdlib_strided_dsumpw( 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_dsumpw( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
+```
+
+#### stdlib_strided_dsumpw_ndarray( N, \*X, strideX, offsetX )
+
+Computes the sum of double-precision floating-point strided array elements using pairwise summation and alternative indexing semantics.
+
+```c
+const double x[] = { 1.0, 2.0, 3.0, 4.0 };
+
+double v = stdlib_strided_dsumpw_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_dsumpw_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/blas/ext/base/dsumpw.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_dsumpw( N, x, strideX );
+
+ // Print the result:
+ printf( "sum: %lf\n", v );
+}
+```
+
+
+
+
+
+
+
+
+
## References
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js
index d6b22fda28af..3231547e99e7 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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 dsumpw = require( './../lib/dsumpw.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/dsumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js
index 399f150736c5..bdacaadfb4eb 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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 dsumpw = tryRequire( resolve( __dirname, './../lib/dsumpw.native.js' ) );
var opts = {
'skip': ( dsumpw 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/dsumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js
index 0e13afde1ac7..a9d05dd1bcc5 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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 dsumpw = 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/dsumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js
index fa9cd2f89840..a90174ec8898 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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 dsumpw = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
var opts = {
'skip': ( dsumpw 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/dsumpw/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/c/benchmark.length.c
index acdac0386225..e9c0b0278c0f 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/c/benchmark.length.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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_dsumpw( 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_dsumpw_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/dsumpw/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt
index 8b39ccffff64..f692d00e51b5 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt
@@ -1,10 +1,10 @@
-{{alias}}( N, x, stride )
+{{alias}}( N, x, strideX )
Computes the sum of double-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: Float64Array
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/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] );
> {{alias}}( 3, x, 2 )
1.0
@@ -46,12 +46,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 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
@@ -62,10 +62,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/dsumpw/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/types/index.d.ts
index ad96f04b9f0a..3a79ebcbb953 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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 = dsumpw( 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 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 = dsumpw.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/dsumpw/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/c/example.c
index 197ecdc1225d..50f1c83c588f 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/c/example.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/c/example.c
@@ -17,7 +17,6 @@
*/
#include "stdlib/blas/ext/base/dsumpw.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_dsumpw( N, x, stride );
+ double v = stdlib_strided_dsumpw( N, x, strideX );
// Print the result:
printf( "sum: %lf\n", v );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js
index 020cf5dbaa6c..8a3c4a182d0a 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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 dsumpw = require( './../lib' );
-var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) );
+var x = discreteUniform( 10.0, -100, 100, {
+ 'dtype': 'float64'
+});
console.log( x );
var v = dsumpw( x.length, x, 1 );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/include/stdlib/blas/ext/base/dsumpw.h b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/include/stdlib/blas/ext/base/dsumpw.h
index 2b417b596c67..84b289f8a02d 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/include/stdlib/blas/ext/base/dsumpw.h
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/include/stdlib/blas/ext/base/dsumpw.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_BLAS_EXT_BASE_DSUMPW_H
#define STDLIB_BLAS_EXT_BASE_DSUMPW_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 using pairwise summation.
*/
-double stdlib_strided_dsumpw( const int64_t N, const double *X, const int64_t stride );
+double API_SUFFIX(stdlib_strided_dsumpw)( const CBLAS_INT N, const double *X, const CBLAS_INT stride );
+
+/**
+* Computes the sum of double-precision floating-point strided array elements using pairwise summation and alternative indexing semantics.
+*/
+double API_SUFFIX(stdlib_strided_dsumpw_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/dsumpw/lib/dsumpw.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/dsumpw.js
index e10415be29ba..00b5977597df 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/dsumpw.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/dsumpw.js
@@ -20,7 +20,8 @@
// MODULES //
-var sum = require( './ndarray.js' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
// MAIN //
@@ -38,44 +39,19 @@ var sum = require( './ndarray.js' );
*
* @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 = dsumpw( N, x, 1 );
+* var v = dsumpw( x.length, x, 1 );
* // returns 1.0
*/
-function dsumpw( N, x, stride ) {
- var ix;
- var s;
- 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;
- }
- if ( N < 8 ) {
- // Use simple summation...
- s = 0.0;
- for ( i = 0; i < N; i++ ) {
- s += x[ ix ];
- ix += stride;
- }
- return s;
- }
- return sum( N, x, stride, ix );
+function dsumpw( N, x, strideX ) {
+ return ndarray( N, x, strideX, stride2offset( N, strideX ) );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/dsumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/dsumpw.native.js
index e713cc03bffd..55ddd3f57b4b 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/dsumpw.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/dsumpw.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 = dsumpw( N, x, 1 );
+* var v = dsumpw( x.length, x, 1 );
* // returns 1.0
*/
-function dsumpw( N, x, stride ) {
- return addon( N, x, stride );
+function dsumpw( N, x, strideX ) {
+ return addon( N, x, strideX );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/index.js
index 84c585bb77b5..26a444422f4d 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/index.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/index.js
@@ -28,9 +28,8 @@
* var dsumpw = require( '@stdlib/blas/ext/base/dsumpw' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-* var N = x.length;
*
-* var v = dsumpw( N, x, 1 );
+* var v = dsumpw( x.length, x, 1 );
* // returns 1.0
*
* @example
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.js
index c335bca94316..74f607ee325e 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.js
@@ -44,8 +44,8 @@ var BLOCKSIZE = 128;
*
* @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
@@ -56,7 +56,7 @@ var BLOCKSIZE = 128;
* var v = dsumpw( 4, x, 2, 1 );
* // returns 5.0
*/
-function dsumpw( N, x, stride, offset ) {
+function dsumpw( N, x, strideX, offsetX ) {
var ix;
var s0;
var s1;
@@ -74,57 +74,57 @@ function dsumpw( N, x, stride, offset ) {
if ( N <= 0 ) {
return 0.0;
}
- if ( N === 1 || stride === 0 ) {
- return x[ offset ];
+ ix = offsetX;
+ if ( strideX === 0 ) {
+ return N * x[ ix ];
}
- ix = offset;
if ( N < 8 ) {
// Use simple summation...
s = 0.0;
for ( i = 0; i < N; i++ ) {
s += x[ ix ];
- ix += stride;
+ ix += strideX;
}
return s;
}
if ( N <= BLOCKSIZE ) {
// Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)...
s0 = x[ ix ];
- s1 = x[ ix+stride ];
- s2 = x[ ix+(2*stride) ];
- s3 = x[ ix+(3*stride) ];
- s4 = x[ ix+(4*stride) ];
- s5 = x[ ix+(5*stride) ];
- s6 = x[ ix+(6*stride) ];
- s7 = x[ ix+(7*stride) ];
- ix += 8 * stride;
+ s1 = x[ ix+strideX ];
+ s2 = x[ ix+(2*strideX) ];
+ s3 = x[ ix+(3*strideX) ];
+ s4 = x[ ix+(4*strideX) ];
+ s5 = x[ ix+(5*strideX) ];
+ s6 = x[ ix+(6*strideX) ];
+ s7 = x[ ix+(7*strideX) ];
+ ix += 8 * strideX;
M = N % 8;
for ( i = 8; i < N-M; i += 8 ) {
s0 += x[ ix ];
- s1 += x[ ix+stride ];
- s2 += x[ ix+(2*stride) ];
- s3 += x[ ix+(3*stride) ];
- s4 += x[ ix+(4*stride) ];
- s5 += x[ ix+(5*stride) ];
- s6 += x[ ix+(6*stride) ];
- s7 += x[ ix+(7*stride) ];
- ix += 8 * stride;
+ s1 += x[ ix+strideX ];
+ s2 += x[ ix+(2*strideX) ];
+ s3 += x[ ix+(3*strideX) ];
+ s4 += x[ ix+(4*strideX) ];
+ s5 += x[ ix+(5*strideX) ];
+ s6 += x[ ix+(6*strideX) ];
+ s7 += x[ ix+(7*strideX) ];
+ ix += 8 * strideX;
}
// Pairwise sum the accumulators:
- s = ((s0+s1) + (s2+s3)) + ((s4+s5) + (s6+s7));
+ s = ( (s0+s1) + (s2+s3) ) + ( (s4+s5) + (s6+s7) );
// Clean-up loop...
for ( i; i < N; i++ ) {
s += x[ ix ];
- ix += stride;
+ ix += strideX;
}
return s;
}
// Recurse by dividing by two, but avoiding non-multiples of unroll factor...
n = floor( N/2 );
n -= n % 8;
- return dsumpw( n, x, stride, ix ) + dsumpw( N-n, x, stride, ix+(n*stride) );
+ return dsumpw( n, x, strideX, ix ) + dsumpw( N-n, x, strideX, ix+(n*strideX) ); // eslint-disable-line max-len
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.native.js
index 3032e3e37ff0..33a7ec0c6a72 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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( './dsumpw.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -32,8 +30,8 @@ var addon = require( './dsumpw.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
@@ -44,11 +42,8 @@ var addon = require( './dsumpw.native.js' );
* var v = dsumpw( 4, x, 2, 1 );
* // returns 5.0
*/
-function dsumpw( N, x, stride, offset ) {
- var view;
- offset = minViewBufferIndex( N, stride, offset );
- view = offsetView( x, offset );
- return addon( N, view, stride );
+function dsumpw( N, x, strideX, offsetX ) {
+ return addon.ndarray( N, x, strideX, offsetX );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json
index 118f8b71bba9..090d0bc750de 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json
@@ -28,49 +28,52 @@
{
"task": "build",
"src": [
- "./src/dsumpw.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-float64array"
+ "@stdlib/napi/argv-strided-float64array",
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/blas/base/shared",
+ "@stdlib/napi/create-double"
]
},
{
"task": "benchmark",
"src": [
- "./src/dsumpw.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/blas/base/shared"
+ ]
},
{
"task": "examples",
"src": [
- "./src/dsumpw.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/blas/base/shared"
+ ]
}
]
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c
index f8ef953974a2..8540c0526906 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c
@@ -17,10 +17,12 @@
*/
#include "stdlib/blas/ext/base/dsumpw.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_dsumpw( 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_dsumpw)( 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_dsumpw_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/dsumpw/src/dsumpw.c b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/main.c
similarity index 50%
rename from lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/dsumpw.c
rename to lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/main.c
index e4710ff2c848..8705d2bef5ba 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/dsumpw.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/main.c
@@ -17,7 +17,8 @@
*/
#include "stdlib/blas/ext/base/dsumpw.h"
-#include
+#include "stdlib/strided/base/stride2offset.h"
+#include "stdlib/blas/base/shared.h"
/**
* Computes the sum of double-precision floating-point strided array elements using pairwise summation.
@@ -30,19 +31,39 @@
*
* - 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
+* @param N number of indexed elements
+* @param X input array
+* @param strideX stride length
+* @return output value
*/
-double stdlib_strided_dsumpw( const int64_t N, const double *X, const int64_t stride ) {
- double *xp1;
- double *xp2;
+double API_SUFFIX(stdlib_strided_dsumpw)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) {
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ return API_SUFFIX(stdlib_strided_dsumpw_ndarray)( N, X, strideX, ox );
+}
+
+/**
+* Computes the sum of double-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
+*/
+double API_SUFFIX(stdlib_strided_dsumpw_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
+ CBLAS_INT ix;
+ CBLAS_INT M;
+ CBLAS_INT n;
+ CBLAS_INT i;
double sum;
- int64_t ix;
- int64_t M;
- int64_t n;
- int64_t i;
double s0;
double s1;
double s2;
@@ -55,20 +76,16 @@ double stdlib_strided_dsumpw( const int64_t N, const double *X, const int64_t st
if ( N <= 0 ) {
return 0.0;
}
- if ( N == 1 || stride == 0 ) {
- return X[ 0 ];
- }
- if ( stride < 0 ) {
- ix = (1-N) * stride;
- } else {
- ix = 0;
+ ix = offsetX;
+ if ( strideX == 0 ) {
+ return N * X[ ix ];
}
if ( N < 8 ) {
// Use simple summation...
sum = 0.0;
for ( i = 0; i < N; i++ ) {
sum += X[ ix ];
- ix += stride;
+ ix += strideX;
}
return sum;
}
@@ -76,46 +93,39 @@ double stdlib_strided_dsumpw( const int64_t N, const double *X, const int64_t st
if ( N <= 128 ) {
// Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)...
s0 = X[ ix ];
- s1 = X[ ix+stride ];
- s2 = X[ ix+(2*stride) ];
- s3 = X[ ix+(3*stride) ];
- s4 = X[ ix+(4*stride) ];
- s5 = X[ ix+(5*stride) ];
- s6 = X[ ix+(6*stride) ];
- s7 = X[ ix+(7*stride) ];
- ix += 8 * stride;
+ s1 = X[ ix+strideX ];
+ s2 = X[ ix+(2*strideX) ];
+ s3 = X[ ix+(3*strideX) ];
+ s4 = X[ ix+(4*strideX) ];
+ s5 = X[ ix+(5*strideX) ];
+ s6 = X[ ix+(6*strideX) ];
+ s7 = X[ ix+(7*strideX) ];
+ ix += 8 * strideX;
M = N % 8;
for ( i = 8; i < N-M; i += 8 ) {
s0 += X[ ix ];
- s1 += X[ ix+stride ];
- s2 += X[ ix+(2*stride) ];
- s3 += X[ ix+(3*stride) ];
- s4 += X[ ix+(4*stride) ];
- s5 += X[ ix+(5*stride) ];
- s6 += X[ ix+(6*stride) ];
- s7 += X[ ix+(7*stride) ];
- ix += 8 * stride;
+ s1 += X[ ix+strideX ];
+ s2 += X[ ix+(2*strideX) ];
+ s3 += X[ ix+(3*strideX) ];
+ s4 += X[ ix+(4*strideX) ];
+ s5 += X[ ix+(5*strideX) ];
+ s6 += X[ ix+(6*strideX) ];
+ s7 += X[ ix+(7*strideX) ];
+ ix += 8 * strideX;
}
// Pairwise sum the accumulators:
- sum = ((s0+s1) + (s2+s3)) + ((s4+s5) + (s6+s7));
+ sum = ( (s0+s1) + (s2+s3) ) + ( (s4+s5) + (s6+s7) );
// Clean-up loop...
for (; i < N; i++ ) {
sum += X[ ix ];
- ix += stride;
+ ix += strideX;
}
return sum;
}
// Recurse by dividing by two, but avoiding non-multiples of unroll factor...
n = N / 2;
n -= n % 8;
- if ( stride < 0 ) {
- xp1 = (double *)X + ( (n-N)*stride );
- xp2 = (double *)X;
- } else {
- xp1 = (double *)X;
- xp2 = (double *)X + ( n*stride );
- }
- return stdlib_strided_dsumpw( n, xp1, stride ) + stdlib_strided_dsumpw( N-n, xp2, stride );
+ return API_SUFFIX(stdlib_strided_dsumpw_ndarray)( n, X, strideX, ix ) + API_SUFFIX(stdlib_strided_dsumpw_ndarray)( N-n, X, strideX, ix+(n*strideX) );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js
index f501fae3f0a1..c121f1772394 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js
@@ -152,14 +152,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 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 = dsumpw( 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/dsumpw/test/test.dsumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js
index 146763d831a1..fcee1afa8c7f 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js
@@ -243,14 +243,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 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 = dsumpw( 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/dsumpw/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js
index 88753d3e7292..311ecd01d56a 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js
@@ -152,14 +152,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 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 = dsumpw( 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/dsumpw/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js
index bda9e678287e..240c95f30304 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js
@@ -161,14 +161,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 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 = dsumpw( x.length, x, 0, 0 );
- t.strictEqual( v, 1.0, 'returns expected value' );
+ t.strictEqual( v, 5.0, 'returns expected value' );
t.end();
});
From 07037539a43392d47256332cba8372335b76f1db Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sun, 5 Jan 2025 11:14:41 +0500
Subject: [PATCH 2/7] fix: apply review suggestions
Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
---
lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md
index e0e65bf69bf7..a126be7b570b 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md
@@ -133,7 +133,7 @@ var v = dsumpw.ndarray( 4, x, 2, 1 );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var dsumpw = require( '@stdlib/blas/ext/base/dsumpw' );
-var x = discreteUniform( 10.0, -100, 100, {
+var x = discreteUniform( 10, -100, 100, {
'dtype': 'float64'
});
console.log( x );
From 6d5439cc3cf308ecd040a13bb88d0d249ca4d1b6 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sun, 5 Jan 2025 11:14:54 +0500
Subject: [PATCH 3/7] fix: apply review suggestions
Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
---
lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js
index 8a3c4a182d0a..d28c4a29005a 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js
@@ -21,7 +21,7 @@
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var dsumpw = require( './../lib' );
-var x = discreteUniform( 10.0, -100, 100, {
+var x = discreteUniform( 10, -100, 100, {
'dtype': 'float64'
});
console.log( x );
From f1345f4a42de66fb56d7ac87218b7c2061bc2c39 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sun, 5 Jan 2025 11:15:12 +0500
Subject: [PATCH 4/7] fix: apply review suggestions
Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
---
.../@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js
index c121f1772394..98cbc7deacc6 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js
@@ -152,7 +152,7 @@ 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 sum of first element repeated N times', 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;
From 964be66a98c25cd70e6840b9bd777ca0924ab53c Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sun, 5 Jan 2025 11:15:22 +0500
Subject: [PATCH 5/7] fix: apply review suggestions
Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
---
.../@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js
index fcee1afa8c7f..e0dcde9546f3 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js
@@ -243,7 +243,7 @@ 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 sum of first element repeated N times', 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;
From 3b2cfef914e6452d9feaaae0271806186f547ba3 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sun, 5 Jan 2025 11:15:34 +0500
Subject: [PATCH 6/7] fix: apply review suggestions
Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
---
.../@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js
index 311ecd01d56a..2f70d32873a0 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js
@@ -152,7 +152,7 @@ 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 sum of first element repeated N times', 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;
From 3781cbd2a233eb629c40c25f072178ab6ee716d0 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sun, 5 Jan 2025 11:15:44 +0500
Subject: [PATCH 7/7] fix: apply review suggestions
Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
---
.../@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js
index 240c95f30304..0875f3ee52d1 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js
@@ -161,7 +161,7 @@ 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 sum of first element repeated N times', 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;