diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/README.md
index 0409e7d63c78..f53c75b157c6 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/README.md
@@ -51,7 +51,7 @@ The [_L1_ norm][l1norm] is defined as
var dasumpw = require( '@stdlib/blas/ext/base/dasumpw' );
```
-#### dasumpw( N, x, stride )
+#### dasumpw( N, x, strideX )
Computes the sum of absolute values ([_L1_ norm][l1norm]) of double-precision floating-point strided array elements using pairwise summation.
@@ -69,7 +69,7 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **x**: input [`Float64Array`][@stdlib/array/float64].
-- **stride**: index increment for `x`.
+- **strideX**: index increment 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 absolute values of every other element in `x`,
@@ -96,7 +96,7 @@ var v = dasumpw( 4, x1, 2 );
// returns 9.0
```
-#### dasumpw.ndarray( N, x, stride, offset )
+#### dasumpw.ndarray( N, x, strideX, offsetX )
Computes the sum of absolute values ([_L1_ norm][l1norm]) of double-precision floating-point strided array elements using pairwise summation and alternative indexing semantics.
@@ -112,9 +112,9 @@ var v = dasumpw.ndarray( N, x, 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 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 value in `x` starting from the second value
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -147,11 +147,12 @@ var v = dasumpw.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 dasumpw = require( '@stdlib/blas/ext/base/dasumpw' );
-var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) );
+var x = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float64'
+});
console.log( x );
var v = dasumpw( x.length, x, 1 );
@@ -162,8 +163,123 @@ console.log( v );
+
+
* * *
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/blas/ext/base/dasumpw.h"
+```
+
+#### stdlib_strided_dasumpw( N, \*X, strideX )
+
+Computes the sum of absolute values ([_L1_ norm][l1norm]) 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_dasumpw( 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` index increment for `X`.
+
+```c
+double stdlib_strided_dasumpw( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
+```
+
+#### stdlib_strided_dasumpw_ndarray( N, \*X, strideX, offsetX )
+
+Computes the sum of absolute values ([_L1_ norm][l1norm]) 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_dasumpw_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` index increment for `X`.
+- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
+
+```c
+double stdlib_strided_dasumpw_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/blas/ext/base/dasumpw.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 indexed elements:
+ const int N = 8;
+
+ // Specify a stride:
+ const int strideX = 1;
+
+ // Compute the sum:
+ double v = stdlib_strided_dasumpw( N, x, strideX );
+
+ // Print the result:
+ printf( "sumabs: %lf\n", sum );
+}
+```
+
+
+
+
+
+
+
+
+
## References
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/benchmark.js
index 90ab3e8a33bb..2cf39e4c40de 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/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 dasumpw = require( './../lib/dasumpw.js' );
// VARIABLES //
-var rand = uniform( -100.0, 100.0 );
+var options = {
+ 'dtype': 'float64'
+};
// FUNCTIONS //
@@ -44,7 +45,7 @@ var rand = uniform( -100.0, 100.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/dasumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/benchmark.native.js
index 610dafc3a3e9..78b78ce79dfe 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/benchmark.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/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 dasumpw = tryRequire( resolve( __dirname, './../lib/dasumpw.native.js' ) );
var opts = {
'skip': ( dasumpw instanceof Error )
};
-var rand = uniform( -100.0, 100.0 );
+var options = {
+ 'dtype': 'float64'
+};
// FUNCTIONS //
@@ -49,7 +50,7 @@ var rand = uniform( -100.0, 100.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/dasumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/benchmark.ndarray.js
index a171c49f3faa..89169ceeaa75 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/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 dasumpw = require( './../lib/ndarray.js' );
// VARIABLES //
-var rand = uniform( -100.0, 100.0 );
+var options = {
+ 'dtype': 'float64'
+};
// FUNCTIONS //
@@ -44,7 +45,7 @@ var rand = uniform( -100.0, 100.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/dasumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/benchmark.ndarray.native.js
index c9d57e4634d9..2a0b25985216 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/benchmark.ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/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 dasumpw = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
var opts = {
'skip': ( dasumpw instanceof Error )
};
-var rand = uniform( -100.0, 100.0 );
+var options = {
+ 'dtype': 'float64'
+};
// FUNCTIONS //
@@ -49,7 +50,7 @@ var rand = uniform( -100.0, 100.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/dasumpw/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/c/benchmark.length.c
index c4b0aad45c1c..4e53354aa210 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/benchmark/c/benchmark.length.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/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;
@@ -120,6 +120,39 @@ 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++ ) {
+ v = stdlib_strided_dasumpw_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 +175,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/dasumpw/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/docs/repl.txt
index e9dac9703ee3..ec0f7c2d3622 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/docs/repl.txt
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/docs/repl.txt
@@ -1,9 +1,9 @@
-{{alias}}( N, x, stride )
+{{alias}}( N, x, strideX )
Computes the sum of absolute values (L1 norm) of double-precision floating-
point strided array elements using pairwise summation.
- The `N` and `stride` parameters determine which elements in `x` are accessed
+ The `N` and stride parameters determine which elements in `x` are accessed
at runtime.
Indexing is relative to the first index. To introduce an offset, use a typed
@@ -19,7 +19,7 @@
x: Float64Array
Input array.
- stride: integer
+ strideX: integer
Index increment.
Returns
@@ -49,13 +49,14 @@
> {{alias}}( N, x1, stride )
5.0
-{{alias}}.ndarray( N, x, stride, offset )
+
+{{alias}}.ndarray( N, x, strideX, offsetX )
Computes the sum of absolute values (L1 norm) 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
@@ -66,10 +67,10 @@
x: Float64Array
Input array.
- stride: integer
+ strideX: integer
Index increment.
- offset: integer
+ offsetX: integer
Starting index.
Returns
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/docs/types/index.d.ts
index 46aa92e688fc..e602c86e9aa3 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/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 = dasumpw( 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 absolute values (L1 norm) 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 = dasumpw.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/dasumpw/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/examples/c/example.c
index efd596d56ef5..63aa4ea6792f 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/examples/c/example.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/examples/c/example.c
@@ -25,13 +25,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_dasumpw( N, x, stride );
+ double v = stdlib_strided_dasumpw( N, x, strideX );
// Print the result:
printf( "sumabs: %lf\n", v );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/examples/index.js
index 96b5f7748224..e571e5ad7149 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/examples/index.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/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 dasumpw = require( './../lib' );
-var x = filledarrayBy( 10, 'float64', discreteUniform( -100.0, 100.0 ) );
+var x = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float64'
+});
console.log( x );
var v = dasumpw( x.length, x, 1 );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/include/stdlib/blas/ext/base/dasumpw.h b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/include/stdlib/blas/ext/base/dasumpw.h
index 19ae380a684d..2c65395ce612 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/include/stdlib/blas/ext/base/dasumpw.h
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/include/stdlib/blas/ext/base/dasumpw.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_BLAS_EXT_BASE_DASUMPW_H
#define STDLIB_BLAS_EXT_BASE_DASUMPW_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 double-precision floating-point strided array elements using pairwise summation.
*/
-double stdlib_strided_dasumpw( const int64_t N, const double *X, const int64_t stride );
+double API_SUFFIX(stdlib_strided_dasumpw)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
+
+/**
+* Computes the sum of absolute values (L1 norm) of double-precision floating-point strided array elements using pairwise summation and alternative indexing semantics.
+*/
+double API_SUFFIX(stdlib_strided_dasumpw_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/dasumpw/lib/dasumpw.js b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/dasumpw.js
index 6b65e829e62f..45c8314cfe21 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/dasumpw.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/dasumpw.js
@@ -20,8 +20,8 @@
// MODULES //
-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 //
@@ -39,7 +39,7 @@ 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
@@ -51,32 +51,8 @@ var sum = require( './ndarray.js' );
* var v = dasumpw( N, x, 1 );
* // returns 5.0
*/
-function dasumpw( 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 += abs( x[ ix ] );
- ix += stride;
- }
- return s;
- }
- return sum( N, x, stride, ix );
+function dasumpw( N, x, strideX ) {
+ return ndarray( N, x, strideX, stride2offset( N, strideX ) );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/dasumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/dasumpw.native.js
index 315bd7d0f8c5..29556c30cd9b 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/dasumpw.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/dasumpw.native.js
@@ -30,7 +30,7 @@ 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
@@ -42,8 +42,8 @@ var addon = require( './../src/addon.node' );
* var v = dasumpw( N, x, 1 );
* // returns 5.0
*/
-function dasumpw( N, x, stride ) {
- return addon( N, x, stride );
+function dasumpw( N, x, strideX ) {
+ return addon( N, x, strideX );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/ndarray.js
index 35131a5263d7..e353eb80e6ad 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/ndarray.js
@@ -45,8 +45,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
@@ -57,7 +57,7 @@ var BLOCKSIZE = 128;
* var v = dasumpw( 4, x, 2, 1 );
* // returns 9.0
*/
-function dasumpw( N, x, stride, offset ) {
+function dasumpw( N, x, strideX, offsetX ) {
var ix;
var s0;
var s1;
@@ -75,42 +75,42 @@ function dasumpw( N, x, stride, offset ) {
if ( N <= 0 ) {
return 0.0;
}
- if ( N === 1 || stride === 0 ) {
- return abs( x[ offset ] );
+ if ( N === 1 || strideX === 0 ) {
+ return abs( x[ offsetX ] );
}
- ix = offset;
+ ix = offsetX;
if ( N < 8 ) {
// Use simple summation...
s = 0.0;
for ( i = 0; i < N; i++ ) {
s += abs( 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 = 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;
+ s1 = abs( x[ ix+strideX ] );
+ s2 = abs( x[ ix+(2*strideX) ] );
+ s3 = abs( x[ ix+(3*strideX) ] );
+ s4 = abs( x[ ix+(4*strideX) ] );
+ s5 = abs( x[ ix+(5*strideX) ] );
+ s6 = abs( x[ ix+(6*strideX) ] );
+ s7 = abs( x[ ix+(7*strideX) ] );
+ ix += 8 * strideX;
M = N % 8;
for ( i = 8; i < N-M; i += 8 ) {
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;
+ s1 += abs( x[ ix+strideX ] );
+ s2 += abs( x[ ix+(2*strideX) ] );
+ s3 += abs( x[ ix+(3*strideX) ] );
+ s4 += abs( x[ ix+(4*strideX) ] );
+ s5 += abs( x[ ix+(5*strideX) ] );
+ s6 += abs( x[ ix+(6*strideX) ] );
+ s7 += abs( x[ ix+(7*strideX) ] );
+ ix += 8 * strideX;
}
// Pairwise sum the accumulators:
s = ((s0+s1) + (s2+s3)) + ((s4+s5) + (s6+s7));
@@ -118,14 +118,14 @@ function dasumpw( N, x, stride, offset ) {
// Clean-up loop...
for ( i; i < N; i++ ) {
s += abs( 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 dasumpw( n, x, stride, ix ) + dasumpw( N-n, x, stride, ix+(n*stride) ); // eslint-disable-line max-len
+ return dasumpw( n, x, strideX, ix ) + dasumpw( N-n, x, strideX, ix+(n*strideX) ); // eslint-disable-line max-len
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/ndarray.native.js
index c30bcf79ffcf..b2c3a5465987 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/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( './dasumpw.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -32,8 +30,8 @@ var addon = require( './dasumpw.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( './dasumpw.native.js' );
* var v = dasumpw( 4, x, 2, 1 );
* // returns 9.0
*/
-function dasumpw( N, x, stride, offset ) {
- var view;
- offset = minViewBufferIndex( N, stride, offset );
- view = offsetView( x, offset );
- return addon( N, view, stride );
+function dasumpw( N, x, strideX, offsetX ) {
+ return addon.ndarray( N, x, strideX, offsetX );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/manifest.json
index b2610eaf8e38..dd4b3af0d2d9 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/manifest.json
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/manifest.json
@@ -28,49 +28,55 @@
{
"task": "build",
"src": [
- "./src/dasumpw.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
+ "@stdlib/math/base/special/abs",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-int64",
- "@stdlib/napi/argv-strided-float64array"
+ "@stdlib/napi/argv-strided-float64array",
+ "@stdlib/napi/create-double"
]
},
{
"task": "benchmark",
"src": [
- "./src/dasumpw.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/math/base/special/abs",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
+ ]
},
{
"task": "examples",
"src": [
- "./src/dasumpw.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/math/base/special/abs",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
+ ]
}
]
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/src/addon.c
index 21cdff485dc7..2363a6b25a53 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/src/addon.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/src/addon.c
@@ -17,12 +17,13 @@
*/
#include "stdlib/blas/ext/base/dasumpw.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
-#include
/**
* Receives JavaScript callback invocation data.
@@ -36,12 +37,25 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
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_dasumpw)( N, X, strideX ), v );
+ return v;
+}
- napi_value v;
- napi_status status = napi_create_double( env, stdlib_strided_dasumpw( N, X, strideX ), &v );
- assert( status == napi_ok );
-
+/**
+* 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_dasumpw_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/dasumpw/src/dasumpw.c b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/src/dasumpw.c
deleted file mode 100644
index 80768518a051..000000000000
--- a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/src/dasumpw.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/dasumpw.h"
-#include
-#include
-
-/**
-* Computes the sum of absolute values (L1 norm) of double-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
-*/
-double stdlib_strided_dasumpw( const int64_t N, const double *X, const int64_t stride ) {
- double *xp1;
- double *xp2;
- double sum;
- int64_t ix;
- int64_t M;
- int64_t n;
- int64_t i;
- double s0;
- double s1;
- double s2;
- double s3;
- double s4;
- double s5;
- double s6;
- double s7;
-
- if ( N <= 0 ) {
- return 0.0;
- }
- if ( N == 1 || stride == 0 ) {
- return fabs( X[ 0 ] );
- }
- if ( stride < 0 ) {
- ix = (1-N) * stride;
- } else {
- ix = 0;
- }
- if ( N < 8 ) {
- // Use simple summation...
- sum = 0.0;
- for ( i = 0; i < N; i++ ) {
- sum += fabs( 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 = fabs( X[ ix ] );
- s1 = fabs( X[ ix+stride ] );
- s2 = fabs( X[ ix+(2*stride) ] );
- s3 = fabs( X[ ix+(3*stride) ] );
- s4 = fabs( X[ ix+(4*stride) ] );
- s5 = fabs( X[ ix+(5*stride) ] );
- s6 = fabs( X[ ix+(6*stride) ] );
- s7 = fabs( X[ ix+(7*stride) ] );
- ix += 8 * stride;
-
- M = N % 8;
- for ( i = 8; i < N-M; i += 8 ) {
- s0 += fabs( X[ ix ] );
- s1 += fabs( X[ ix+stride ] );
- s2 += fabs( X[ ix+(2*stride) ] );
- s3 += fabs( X[ ix+(3*stride) ] );
- s4 += fabs( X[ ix+(4*stride) ] );
- s5 += fabs( X[ ix+(5*stride) ] );
- s6 += fabs( X[ ix+(6*stride) ] );
- s7 += fabs( 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 += fabs( 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 = (double *)X + ( (n-N)*stride );
- xp2 = (double *)X;
- } else {
- xp1 = (double *)X;
- xp2 = (double *)X + ( n*stride );
- }
- return stdlib_strided_dasumpw( n, xp1, stride ) + stdlib_strided_dasumpw( N-n, xp2, stride );
-}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dasumpw/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/src/main.c
new file mode 100644
index 000000000000..50ff029d1722
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/dasumpw/src/main.c
@@ -0,0 +1,132 @@
+/**
+* @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/dasumpw.h"
+#include "stdlib/blas/base/shared.h"
+#include "stdlib/strided/base/stride2offset.h"
+#include "stdlib/math/base/special/abs.h"
+
+/**
+* Computes the sum of absolute values (L1 norm) of double-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
+*/
+double API_SUFFIX(stdlib_strided_dasumpw)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) {
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ return API_SUFFIX(stdlib_strided_dasumpw_ndarray)( N, X, strideX, ox );
+}
+
+/**
+* Computes the sum of absolute values (L1 norm) 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 index increment
+* @param offsetX starting index
+* @return output value
+*/
+double API_SUFFIX(stdlib_strided_dasumpw_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
+ double sum;
+ CBLAS_INT ix;
+ CBLAS_INT M;
+ CBLAS_INT n;
+ CBLAS_INT i;
+ double s0;
+ double s1;
+ double s2;
+ double s3;
+ double s4;
+ double s5;
+ double s6;
+ double s7;
+
+ if ( N <= 0 ) {
+ return 0.0;
+ }
+ if ( N == 1 || strideX == 0 ) {
+ return stdlib_base_abs( X[ 0 ] );
+ }
+ ix = offsetX;
+ if ( N < 8 ) {
+ // Use simple summation...
+ sum = 0.0;
+ for ( i = 0; i < N; i++ ) {
+ sum += stdlib_base_abs( 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_abs( X[ ix ] );
+ s1 = stdlib_base_abs( X[ ix+strideX ] );
+ s2 = stdlib_base_abs( X[ ix+(2*strideX) ] );
+ s3 = stdlib_base_abs( X[ ix+(3*strideX) ] );
+ s4 = stdlib_base_abs( X[ ix+(4*strideX) ] );
+ s5 = stdlib_base_abs( X[ ix+(5*strideX) ] );
+ s6 = stdlib_base_abs( X[ ix+(6*strideX) ] );
+ s7 = stdlib_base_abs( X[ ix+(7*strideX) ] );
+ ix += 8 * strideX;
+
+ M = N % 8;
+ for ( i = 8; i < N-M; i += 8 ) {
+ s0 += stdlib_base_abs( X[ ix ] );
+ s1 += stdlib_base_abs( X[ ix+strideX ] );
+ s2 += stdlib_base_abs( X[ ix+(2*strideX) ] );
+ s3 += stdlib_base_abs( X[ ix+(3*strideX) ] );
+ s4 += stdlib_base_abs( X[ ix+(4*strideX) ] );
+ s5 += stdlib_base_abs( X[ ix+(5*strideX) ] );
+ s6 += stdlib_base_abs( X[ ix+(6*strideX) ] );
+ s7 += stdlib_base_abs( 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_abs( 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_dasumpw_ndarray)( n, X, strideX, ix ) + API_SUFFIX(stdlib_strided_dasumpw_ndarray)( N-n, X, strideX, ix+(n*strideX) );
+}