diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/README.md b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/README.md
index a1fc33e940dd..522eb711cad6 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/README.md
@@ -51,7 +51,7 @@ The [_L1_ norm][l1norm] is defined as
var dnanasumors = require( '@stdlib/blas/ext/base/dnanasumors' );
```
-#### dnanasumors( N, x, stride )
+#### dnanasumors( N, x, strideX )
Computes the sum of absolute values ([_L1_ norm][l1norm]) of double-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation.
@@ -69,9 +69,9 @@ 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 ([_L1_ norm][l1norm]) every other element in `x`,
+The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of absolute values ([_L1_ norm][l1norm]) for every other element in `x`,
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -96,7 +96,7 @@ var v = dnanasumors( 4, x1, 2 );
// returns 9.0
```
-#### dnanasumors.ndarray( N, x, stride, offset )
+#### dnanasumors.ndarray( N, x, strideX, offsetX )
Computes the sum of absolute values ([_L1_ norm][l1norm]) of double-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation and alternative indexing semantics.
@@ -112,9 +112,9 @@ var v = dnanasumors.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 ([_L1_ norm][l1norm]) 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 ([_L1_ norm][l1norm]) for every other value in `x` starting from the second value
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -170,6 +170,123 @@ console.log( v );
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/blas/ext/base/dnanasumors.h"
+```
+
+#### stdlib_strided_dnanasumors( N, \*X, strideX )
+
+Computes the sum of absolute values ([_L1_ norm][l1norm]) of double-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation.
+
+```c
+const double x[] = { 1.0, 2.0, 0.0/0.0, 4.0 };
+
+double v = stdlib_strided_dnanasumors( 4, x, 1 );
+// returns 7.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_dnanasumors( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
+```
+
+#### stdlib_strided_dnanasumors_ndarray( N, \*X, strideX, offsetX )
+
+Computes the sum of absolute values ([_L1_ norm][l1norm]) of double-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation and alternative indexing semantics.
+
+```c
+const double x[] = { 1.0, 2.0, 0.0/0.0, 4.0 };
+
+double v = stdlib_strided_dnanasumors_ndarray( 4, x, 1, 0 );
+// returns 7.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_dnanasumors_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/blas/ext/base/dnanasumors.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, 0.0/0.0, 0.0/0.0 };
+
+ // Specify the number of elements:
+ const int N = 5;
+
+ // Specify the stride length:
+ const int strideX = 2;
+
+ // Compute the sum:
+ double v = stdlib_strided_dnanasumors( N, x, strideX );
+
+ // Print the result:
+ printf( "sumabs: %lf\n", v );
+}
+```
+
+
+
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/benchmark/c/benchmark.length.c
index 6d81db4671b1..aaaebb77dd75 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/benchmark/c/benchmark.length.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/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;
@@ -124,6 +124,43 @@ 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++ ) {
+ if ( rand_double() < 0.2 ) {
+ x[ i ] = 0.0 / 0.0; // NaN
+ } else {
+ x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
+ }
+ }
+ v = 0.0;
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ v = stdlib_strided_dnanasumors_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.
*/
@@ -146,7 +183,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/dnanasumors/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/docs/repl.txt
index 4939008c7a54..676d8103545a 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/docs/repl.txt
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/docs/repl.txt
@@ -1,10 +1,10 @@
-{{alias}}( N, x, stride )
+{{alias}}( N, x, strideX )
Computes the sum of absolute values (L1 norm) of double-precision floating-
point strided array elements, ignoring `NaN` values and using ordinary
recursive 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
@@ -20,7 +20,7 @@
x: Float64Array
Input array.
- stride: integer
+ strideX: integer
Index increment.
Returns
@@ -50,14 +50,15 @@
> {{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, ignoring `NaN` values and using ordinary
recursive summation alternative indexing semantics.
While typed array views mandate a view offset based on the underlying
- buffer, the `offset` parameter supports indexing semantics based on a
- starting index.
+ buffer, the offset parameter supports indexing semantics based on a starting
+ index.
Parameters
----------
@@ -67,10 +68,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/dnanasumors/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/docs/types/index.d.ts
index 15a413b8f9c0..a8aa70f8d6bf 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/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 = dnanasumors( x.length, x, 1 );
* // returns 5.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, ignoring `NaN` values and using ordinary recursive 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 = dnanasumors.ndarray( x.length, x, 1, 0 );
* // returns 5.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/dnanasumors/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/examples/c/example.c
index 638a9c9fe609..9e9d3f1c6f5a 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/examples/c/example.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/examples/c/example.c
@@ -17,7 +17,6 @@
*/
#include "stdlib/blas/ext/base/dnanasumors.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, 0.0/0.0, 0.0/0.0 };
// Specify the number of elements:
- const int64_t N = 5;
+ const int N = 5;
// Specify the stride length:
- const int64_t stride = 2;
+ const int strideX = 2;
// Compute the sum:
- double v = stdlib_strided_dnanasumors( N, x, stride );
+ double v = stdlib_strided_dnanasumors( N, x, strideX );
// Print the result:
printf( "sumabs: %lf\n", v );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/include/stdlib/blas/ext/base/dnanasumors.h b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/include/stdlib/blas/ext/base/dnanasumors.h
index 944bc5b49ba2..17f9141b716e 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/include/stdlib/blas/ext/base/dnanasumors.h
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/include/stdlib/blas/ext/base/dnanasumors.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_BLAS_EXT_BASE_DNANASUMORS_H
#define STDLIB_BLAS_EXT_BASE_DNANASUMORS_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, ignoring `NaN` values and using ordinary recursive summation.
*/
-double stdlib_strided_dnanasumors( const int64_t N, const double *X, const int64_t stride );
+double API_SUFFIX(stdlib_strided_dnanasumors)( 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, ignoring `NaN` values and using ordinary recursive summation and alternative indexing semantics.
+*/
+double API_SUFFIX(stdlib_strided_dnanasumors_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/dnanasumors/lib/dnanasumors.js b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/dnanasumors.js
index bb0ac074048e..3dac0f10b217 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/dnanasumors.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/dnanasumors.js
@@ -20,8 +20,8 @@
// MODULES //
-var isnan = require( '@stdlib/math/base/assert/is-nan' );
-var abs = require( '@stdlib/math/base/special/abs' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
// MAIN //
@@ -31,7 +31,7 @@ var abs = require( '@stdlib/math/base/special/abs' );
*
* @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
@@ -43,35 +43,8 @@ var abs = require( '@stdlib/math/base/special/abs' );
* var v = dnanasumors( N, x, 1 );
* // returns 5.0
*/
-function dnanasumors( N, x, stride ) {
- var sum;
- var ix;
- var v;
- var i;
-
- if ( N <= 0 ) {
- return 0.0;
- }
- if ( N === 1 || stride === 0 ) {
- if ( isnan( x[ 0 ] ) ) {
- return 0.0;
- }
- return abs( x[ 0 ] );
- }
- if ( stride < 0 ) {
- ix = (1-N) * stride;
- } else {
- ix = 0;
- }
- sum = 0.0;
- for ( i = 0; i < N; i++ ) {
- v = x[ ix ];
- if ( isnan( v ) === false ) {
- sum += abs( v );
- }
- ix += stride;
- }
- return sum;
+function dnanasumors( N, x, strideX ) {
+ return ndarray( N, x, strideX, stride2offset( N, strideX ) );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/dnanasumors.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/dnanasumors.native.js
index 19fec9db5149..f796b2adbe22 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/dnanasumors.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/dnanasumors.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 = dnanasumors( N, x, 1 );
* // returns 5.0
*/
-function dnanasumors( N, x, stride ) {
- return addon( N, x, stride );
+function dnanasumors( N, x, strideX ) {
+ return addon( N, x, strideX );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/ndarray.js
index f7646c21a7c2..2143c9cb38f0 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/ndarray.js
@@ -31,8 +31,8 @@ var abs = require( '@stdlib/math/base/special/abs' );
*
* @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 - index increment
+* @param {NonNegativeInteger} offsetX - starting index
* @returns {number} sum
*
* @example
@@ -43,7 +43,7 @@ var abs = require( '@stdlib/math/base/special/abs' );
* var v = dnanasumors( 4, x, 2, 1 );
* // returns 9.0
*/
-function dnanasumors( N, x, stride, offset ) {
+function dnanasumors( N, x, strideX, offsetX ) {
var sum;
var ix;
var v;
@@ -52,20 +52,20 @@ function dnanasumors( N, x, stride, offset ) {
if ( N <= 0 ) {
return 0.0;
}
- if ( N === 1 || stride === 0 ) {
- if ( isnan( x[ offset ] ) ) {
+ if ( strideX === 0 ) {
+ if ( isnan( x[ offsetX ] ) ) {
return 0.0;
}
- return abs( x[ offset ] );
+ return abs( x[ offsetX ] ) * N;
}
- ix = offset;
+ ix = offsetX;
sum = 0.0;
for ( i = 0; i < N; i++ ) {
v = x[ ix ];
if ( isnan( v ) === false ) {
sum += abs( v );
}
- ix += stride;
+ ix += strideX;
}
return sum;
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/ndarray.native.js
index f39d4e511274..7d2c1d82c8e1 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/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( './dnanasumors.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -32,8 +30,8 @@ var addon = require( './dnanasumors.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 - index increment
+* @param {NonNegativeInteger} offsetX - starting index
* @returns {number} sum
*
* @example
@@ -44,11 +42,8 @@ var addon = require( './dnanasumors.native.js' );
* var v = dnanasumors( 4, x, 2, 1 );
* // returns 9.0
*/
-function dnanasumors( N, x, stride, offset ) {
- var view;
- offset = minViewBufferIndex( N, stride, offset );
- view = offsetView( x, offset );
- return addon( N, view, stride );
+function dnanasumors( N, x, strideX, offsetX ) {
+ return addon.ndarray( N, x, strideX, offsetX );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/manifest.json
index 67b670274de2..a944a1c63d64 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/manifest.json
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/manifest.json
@@ -28,7 +28,7 @@
{
"task": "build",
"src": [
- "./src/dnanasumors.c"
+ "./src/main.c"
],
"include": [
"./include"
@@ -41,13 +41,16 @@
"@stdlib/napi/argv-int64",
"@stdlib/napi/argv-strided-float64array",
"@stdlib/math/base/assert/is-nan",
- "@stdlib/math/base/special/abs"
+ "@stdlib/math/base/special/abs",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/napi/create-double"
]
},
{
"task": "benchmark",
"src": [
- "./src/dnanasumors.c"
+ "./src/main.c"
],
"include": [
"./include"
@@ -56,13 +59,15 @@
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nan",
- "@stdlib/math/base/special/abs"
+ "@stdlib/math/base/special/abs",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
]
},
{
"task": "examples",
"src": [
- "./src/dnanasumors.c"
+ "./src/main.c"
],
"include": [
"./include"
@@ -71,7 +76,9 @@
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nan",
- "@stdlib/math/base/special/abs"
+ "@stdlib/math/base/special/abs",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
]
}
]
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/addon.c
index dac318b22d97..1ee555d3ace2 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/addon.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/addon.c
@@ -17,12 +17,13 @@
*/
#include "stdlib/blas/ext/base/dnanasumors.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_dnanasumors)( N, X, strideX ), v );
+ return v;
+}
- napi_value v;
- napi_status status = napi_create_double( env, stdlib_strided_dnanasumors( 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_dnanasumors_ndarray)( N, X, strideX, offsetX ), v );
return v;
}
-STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
\ No newline at end of file
+STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method )
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/dnanasumors.c b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/dnanasumors.c
deleted file mode 100644
index 5e731dd35e68..000000000000
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/dnanasumors.c
+++ /dev/null
@@ -1,61 +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/dnanasumors.h"
-#include "stdlib/math/base/assert/is_nan.h"
-#include "stdlib/math/base/special/abs.h"
-#include
-
-/**
-* Computes the sum of absolute values (L1 norm) of double-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation.
-*
-* @param N number of indexed elements
-* @param X input array
-* @param stride stride length
-* @return output value
-*/
-double stdlib_strided_dnanasumors( const int64_t N, const double *X, const int64_t stride ) {
- double sum;
- int64_t ix;
- int64_t i;
- double v;
-
- if ( N <= 0 ) {
- return 0.0;
- }
- if ( N == 1 || stride == 0 ) {
- if ( stdlib_base_is_nan( X[ 0 ] ) ) {
- return 0.0;
- }
- return stdlib_base_abs( X[ 0 ] );
- }
- if ( stride < 0 ) {
- ix = (1-N) * stride;
- } else {
- ix = 0;
- }
- sum = 0.0;
- for ( i = 0; i < N; i++ ) {
- v = X[ ix ];
- if ( !stdlib_base_is_nan( v ) ) {
- sum += stdlib_base_abs( v );
- }
- ix += stride;
- }
- return sum;
-}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/main.c
new file mode 100644
index 000000000000..18fa271cfd46
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/main.c
@@ -0,0 +1,72 @@
+/**
+* @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/dnanasumors.h"
+#include "stdlib/strided/base/stride2offset.h"
+#include "stdlib/math/base/assert/is_nan.h"
+#include "stdlib/math/base/special/abs.h"
+#include "stdlib/blas/base/shared.h"
+
+/**
+* Computes the sum of absolute values (L1 norm) of double-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation.
+*
+* @param N number of indexed elements
+* @param X input array
+* @param strideX stride length
+* @return output value
+*/
+double API_SUFFIX(stdlib_strided_dnanasumors)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) {
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ return API_SUFFIX(stdlib_strided_dnanasumors_ndarray)( N, X, strideX, ox );
+}
+
+/**
+* Computes the sum of absolute values (L1 norm) of double-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation and alternative indexing semantics.
+*
+* @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_dnanasumors_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
+ double sum;
+ CBLAS_INT ix;
+ CBLAS_INT i;
+ double v;
+
+ if ( N <= 0 ) {
+ return 0.0;
+ }
+ if ( strideX == 0 ) {
+ if ( stdlib_base_is_nan( X[ offsetX ] ) ) {
+ return 0.0;
+ }
+ return stdlib_base_abs( X[ offsetX ] ) * N;
+ }
+ ix = offsetX;
+ sum = 0.0;
+ for ( i = 0; i < N; i++ ) {
+ v = X[ ix ];
+ if ( !stdlib_base_is_nan( v ) ) {
+ sum += stdlib_base_abs( v );
+ }
+ ix += strideX;
+ }
+ return sum;
+}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.dnanasumors.js b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.dnanasumors.js
index f97f48efdaa5..6304df65fd92 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.dnanasumors.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.dnanasumors.js
@@ -148,14 +148,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 = dnanasumors( 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/dnanasumors/test/test.dnanasumors.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.dnanasumors.native.js
index 68daea1d23bf..cc15c992eb63 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.dnanasumors.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.dnanasumors.native.js
@@ -241,14 +241,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 = dnanasumors( 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/dnanasumors/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.ndarray.js
index 3858f0ab9564..86f7f08f0c75 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.ndarray.js
@@ -150,14 +150,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 = dnanasumors( 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/dnanasumors/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.ndarray.native.js
index b50ff22d8081..0c622dbbdeed 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.ndarray.native.js
@@ -159,14 +159,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 = dnanasumors( x.length, x, 0, 0 );
- t.strictEqual( v, 1.0, 'returns expected value' );
+ t.strictEqual( v, 5.0, 'returns expected value' );
t.end();
});