diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/README.md b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/README.md
index 2e826e986701..4ce929b28943 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/README.md
@@ -54,11 +54,11 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **x**: input [`Float64Array`][@stdlib/array/float64].
-- **strideX**: index increment for `x`.
+- **strideX**: stride length for `x`.
- **out**: output [`Float64Array`][@stdlib/array/float64] whose first element is the sum and whose second element is the number of non-NaN elements.
-- **strideOut**: index increment for `out`.
+- **strideOut**: stride length for `out`.
-The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of every other element in the strided array,
+The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of every other element in the strided array:
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -106,7 +106,7 @@ The function has the following additional parameters:
- **offsetX**: starting index for `x`.
- **offsetOut**: starting index for `out`.
-While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the sum of every other value in the strided array starting from the second value
+While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to calculate the sum of every other element starting from the second element:
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -145,14 +145,14 @@ var filledarrayBy = require( '@stdlib/array/filled-by' );
var Float64Array = require( '@stdlib/array/float64' );
var dnannsum = require( '@stdlib/blas/ext/base/dnannsum' );
-function clbk() {
+function rand() {
if ( bernoulli( 0.7 ) > 0 ) {
return discreteUniform( 0, 100 );
}
return NaN;
}
-var x = filledarrayBy( 10, 'float64', clbk );
+var x = filledarrayBy( 10, 'float64', rand );
console.log( x );
var out = new Float64Array( 2 );
@@ -164,6 +164,136 @@ console.log( out );
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/blas/ext/base/dnannsum.h"
+```
+
+#### stdlib_strided_dnannsum( N, \*X, strideX, \*n )
+
+Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values.
+
+```c
+#include "stdlib/blas/base/shared.h"
+
+const double x[] = { 1.0, 2.0, 0.0/0.0, 4.0 };
+CBLAS_INT n = 0;
+
+double v = stdlib_strided_dnannsum( 4, x, 1, &n );
+// 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` stride length for `X`.
+- **n**: `[out] CBLAS_INT*` pointer for storing the number of non-NaN elements.
+
+```c
+double stdlib_strided_dnannsum( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, CBLAS_INT *n );
+```
+
+#### stdlib_strided_dnannsum_ndarray( N, \*X, strideX, offsetX, \*n )
+
+Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using alternative indexing semantics.
+
+```c
+#include "stdlib/blas/base/shared.h"
+
+const double x[] = { 1.0, 2.0, 0.0/0.0, 4.0 };
+CBLAS_INT n = 0;
+
+double v = stdlib_strided_dnannsum_ndarray( 4, x, 1, 0, &n );
+// 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` stride length for `X`.
+- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
+- **n**: `[out] CBLAS_INT*` pointer for storing the number of non-NaN elements.
+
+```c
+double stdlib_strided_dnannsum_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/blas/ext/base/dnannsum.h"
+#include "stdlib/blase/base/shared.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;
+
+ // Initialize a variable for storing the number of non-NaN elements:
+ CBLAS_INT n = 0;
+
+ // Compute the sum:
+ double v = stdlib_strided_dnannsum( N, x, strideX, &n );
+
+ // Print the result:
+ printf( "sum: %lf\n", v );
+ printf( "n: %"CBLAS_IFMT"\n", n );
+}
+```
+
+
+
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.js
index 22d718284755..1548ba9340f7 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.js
@@ -33,6 +33,19 @@ var dnannsum = require( './../lib/dnannsum.js' );
// FUNCTIONS //
+/**
+* Returns a random number.
+*
+* @private
+* @returns {number} random number
+*/
+function rand() {
+ if ( bernoulli( 0.7 ) > 0 ) {
+ return discreteUniform( -10, 10 );
+ }
+ return NaN;
+}
+
/**
* Creates a benchmark function.
*
@@ -44,17 +57,10 @@ function createBenchmark( len ) {
var out;
var x;
- x = filledarrayBy( len, 'float64', clbk );
+ x = filledarrayBy( len, 'float64', rand );
out = new Float64Array( 2 );
return benchmark;
- function clbk() {
- if ( bernoulli( 0.7 ) > 0 ) {
- return discreteUniform( -10, 10 );
- }
- return NaN;
- }
-
function benchmark( b ) {
var i;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.native.js
index f595fb3ffc30..9297068365e0 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.native.js
@@ -42,6 +42,19 @@ var opts = {
// FUNCTIONS //
+/**
+* Returns a random number.
+*
+* @private
+* @returns {number} random number
+*/
+function rand() {
+ if ( bernoulli( 0.7 ) > 0 ) {
+ return discreteUniform( -10, 10 );
+ }
+ return NaN;
+}
+
/**
* Creates a benchmark function.
*
@@ -53,17 +66,10 @@ function createBenchmark( len ) {
var out;
var x;
- x = filledarrayBy( len, 'float64', clbk );
+ x = filledarrayBy( len, 'float64', rand );
out = new Float64Array( 2 );
return benchmark;
- function clbk() {
- if ( bernoulli( 0.7 ) > 0 ) {
- return discreteUniform( -10, 10 );
- }
- return NaN;
- }
-
function benchmark( b ) {
var i;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.ndarray.js
index 2a6f48b10af7..f1bca5fdb706 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.ndarray.js
@@ -33,6 +33,19 @@ var dnannsum = require( './../lib/ndarray.js' );
// FUNCTIONS //
+/**
+* Returns a random number.
+*
+* @private
+* @returns {number} random number
+*/
+function rand() {
+ if ( bernoulli( 0.7 ) > 0 ) {
+ return discreteUniform( -10, 10 );
+ }
+ return NaN;
+}
+
/**
* Creates a benchmark function.
*
@@ -44,17 +57,10 @@ function createBenchmark( len ) {
var out;
var x;
- x = filledarrayBy( len, 'float64', clbk );
+ x = filledarrayBy( len, 'float64', rand );
out = new Float64Array( 2 );
return benchmark;
- function clbk() {
- if ( bernoulli( 0.7 ) > 0 ) {
- return discreteUniform( -10, 10 );
- }
- return NaN;
- }
-
function benchmark( b ) {
var i;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.ndarray.native.js
index 3c92c27fa87d..2b5b5931fd1a 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/benchmark.ndarray.native.js
@@ -42,6 +42,19 @@ var opts = {
// FUNCTIONS //
+/**
+* Returns a random number.
+*
+* @private
+* @returns {number} random number
+*/
+function rand() {
+ if ( bernoulli( 0.7 ) > 0 ) {
+ return discreteUniform( -10, 10 );
+ }
+ return NaN;
+}
+
/**
* Creates a benchmark function.
*
@@ -53,17 +66,10 @@ function createBenchmark( len ) {
var out;
var x;
- x = filledarrayBy( len, 'float64', clbk );
+ x = filledarrayBy( len, 'float64', rand );
out = new Float64Array( 2 );
return benchmark;
- function clbk() {
- if ( bernoulli( 0.7 ) > 0 ) {
- return discreteUniform( -10, 10 );
- }
- return NaN;
- }
-
function benchmark( b ) {
var i;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/c/benchmark.length.c
index 8fc3d80adef8..2a253f446672 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/c/benchmark.length.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/benchmark/c/benchmark.length.c
@@ -17,6 +17,7 @@
*/
#include "stdlib/blas/ext/base/dnannsum.h"
+#include "stdlib/blas/base/shared.h"
#include
#include
#include
@@ -94,10 +95,10 @@ 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 ];
- int64_t n;
+ CBLAS_INT n;
double v;
double t;
int i;
@@ -113,6 +114,7 @@ static double benchmark( int iterations, int len ) {
n = 0;
t = tic();
for ( i = 0; i < iterations; i++ ) {
+ // cppcheck-suppress uninitvar
v = stdlib_strided_dnannsum( len, x, 1, &n );
if ( v != v || n < 0 ) {
printf( "should not return NaN\n" );
@@ -126,6 +128,47 @@ 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 ];
+ CBLAS_INT n;
+ 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;
+ n = 0;
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ // cppcheck-suppress uninitvar
+ v = stdlib_strided_dnannsum_ndarray( len, x, 1, 0, &n );
+ if ( v != v || n < 0 ) {
+ printf( "should not return NaN\n" );
+ break;
+ }
+ }
+ elapsed = tic() - t;
+ if ( v != v || n < 0 ) {
+ printf( "should not return NaN\n" );
+ }
+ return elapsed;
+}
+
+
/**
* Main execution sequence.
*/
@@ -148,7 +191,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/dnannsum/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/docs/repl.txt
index 2b65c531b288..45cdb4a80f79 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/docs/repl.txt
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/docs/repl.txt
@@ -3,8 +3,8 @@
Computes the sum of double-precision floating-point strided array elements,
ignoring `NaN` values.
- 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.
@@ -20,13 +20,13 @@
Input array.
strideX: integer
- Index increment for `x`.
+ Stride length for `x`.
out: Float64Array
Output array.
strideOut: integer
- Index increment for `out`.
+ Stride length for `out`.
Returns
-------
@@ -42,7 +42,7 @@
> {{alias}}( x.length, x, 1, out, 1 )
[ 1.0, 3 ]
- // Using `N` .`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, NaN, NaN ] );
> out = new {{alias:@stdlib/array/float64}}( 2 );
> {{alias}}( 4, x, 2, out, 1 )
@@ -61,8 +61,8 @@
ignoring `NaN` values and using alternative indexing semantics.
While typed array views mandate a view offset based on the underlying
- buffer, the `offset` parameter supports indexing semantics based on a
- starting index.
+ buffer, the offset parameters support indexing semantics based on
+ starting indices.
Parameters
----------
@@ -73,7 +73,7 @@
Input array.
strideX: integer
- Index increment for `x`.
+ Stride length for `x`.
offsetX: integer
Starting index for `x`.
@@ -82,7 +82,7 @@
Output array.
strideOut: integer
- Index increment for `out`.
+ Stride length for `out`.
offsetOut: integer
Starting index for `out`.
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/examples/c/example.c
index 754035eeed9d..1523882771ae 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/examples/c/example.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/examples/c/example.c
@@ -17,27 +17,26 @@
*/
#include "stdlib/blas/ext/base/dnannsum.h"
-#include
+#include "stdlib/blas/base/shared.h"
#include
-#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 int64_t N = 5;
+ const int N = 5;
// Specify the stride length:
- const int64_t stride = 2;
+ const int strideX = 2;
// Initialize a variable for storing the number of non-NaN elements:
- int64_t n = 0;
+ CBLAS_INT n = 0;
// Compute the sum:
- double v = stdlib_strided_dnannsum( N, x, stride, &n );
+ double v = stdlib_strided_dnannsum( N, x, strideX, &n );
// Print the result:
printf( "sum: %lf\n", v );
- printf( "n: %"PRId64"\n", n );
+ printf( "n: %"CBLAS_IFMT"\n", n );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/examples/index.js
index dc4bc44d547f..8bd872042b78 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/examples/index.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/examples/index.js
@@ -24,14 +24,14 @@ var filledarrayBy = require( '@stdlib/array/filled-by' );
var Float64Array = require( '@stdlib/array/float64' );
var dnannsum = require( './../lib' );
-function clbk() {
+function rand() {
if ( bernoulli( 0.7 ) > 0 ) {
return discreteUniform( 0, 100 );
}
return NaN;
}
-var x = filledarrayBy( 10, 'float64', clbk );
+var x = filledarrayBy( 10, 'float64', rand );
console.log( x );
var out = new Float64Array( 2 );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/include/stdlib/blas/ext/base/dnannsum.h b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/include/stdlib/blas/ext/base/dnannsum.h
index f3b59518340d..630eeaf7c645 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/include/stdlib/blas/ext/base/dnannsum.h
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/include/stdlib/blas/ext/base/dnannsum.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_BLAS_EXT_BASE_DNANNSUM_H
#define STDLIB_BLAS_EXT_BASE_DNANNSUM_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, ignoring `NaN` values.
*/
-double stdlib_strided_dnannsum( const int64_t N, const double *X, const int64_t stride, int64_t *n );
+double API_SUFFIX(stdlib_strided_dnannsum)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, CBLAS_INT *n );
+
+/**
+* Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using alternative indexing semantics.
+*/
+double API_SUFFIX(stdlib_strided_dnannsum_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, CBLAS_INT offsetX, CBLAS_INT *n );
#ifdef __cplusplus
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/lib/dnannsum.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/lib/dnannsum.js
index 9b660026026b..c2195c12e577 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/lib/dnannsum.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/lib/dnannsum.js
@@ -20,7 +20,8 @@
// MODULES //
-var dnannsumkbn = require( '@stdlib/blas/ext/base/dnannsumkbn' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
// MAIN //
@@ -45,7 +46,12 @@ var dnannsumkbn = require( '@stdlib/blas/ext/base/dnannsumkbn' );
* // returns [ 1.0, 3 ]
*/
function dnannsum( N, x, strideX, out, strideOut ) {
- return dnannsumkbn( N, x, strideX, out, strideOut );
+ var ix;
+ var io;
+
+ ix = stride2offset( N, strideX );
+ io = stride2offset( 2, strideOut );
+ return ndarray( N, x, strideX, ix, out, strideOut, io );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/lib/ndarray.native.js
index 387c73bff18f..7455fdfc871f 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/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( './dnannsum.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -52,19 +50,7 @@ var addon = require( './dnannsum.native.js' );
* // returns [ 5.0, 4 ]
*/
function dnannsum( N, x, strideX, offsetX, out, strideOut, offsetOut ) {
- var viewOut;
- var viewX;
-
- offsetX = minViewBufferIndex( N, strideX, offsetX );
- if ( strideOut < 0 ) {
- offsetOut += strideOut;
- }
-
- viewX = offsetView( x, offsetX );
- viewOut = offsetView( out, offsetOut );
-
- addon( N, viewX, strideX, viewOut, strideOut );
-
+ addon.ndarray( N, x, strideX, offsetX, out, strideOut, offsetOut );
return out;
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/manifest.json
index d683d1a01402..196371b350d0 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/manifest.json
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/manifest.json
@@ -28,53 +28,53 @@
{
"task": "build",
"src": [
- "./src/dnannsum.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas/ext/base/dnannsumkbn",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-int64",
- "@stdlib/napi/argv-strided-float64array"
+ "@stdlib/napi/argv-strided-float64array",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
]
},
{
"task": "benchmark",
"src": [
- "./src/dnannsum.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
- "@stdlib/blas/ext/base/dnannsumkbn"
+ "@stdlib/blas/ext/base/dnannsumkbn",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
]
},
{
"task": "examples",
"src": [
- "./src/dnannsum.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
- "@stdlib/blas/ext/base/dnannsumkbn"
+ "@stdlib/blas/ext/base/dnannsumkbn",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
]
}
]
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/src/addon.c
index ec31908d533e..c9d5931b3534 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/src/addon.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/src/addon.c
@@ -17,12 +17,14 @@
*/
#include "stdlib/blas/ext/base/dnannsum.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/strided/base/stride2offset.h"
+#include
#include
-#include
/**
* Receives JavaScript callback invocation data.
@@ -39,19 +41,36 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 3 );
- int64_t io;
- if ( strideOut < 0 ) {
- io = -strideOut;
- } else {
- io = 0;
- }
+ int64_t io = stdlib_strided_stride2offset( 2, strideOut );
+ CBLAS_INT n;
+ Out[ io ] = API_SUFFIX(stdlib_strided_dnannsum)( N, X, strideX, &n );
+ Out[ io + strideOut ] = (double)n;
- double *out = Out;
- int64_t n;
- out[ io ] = stdlib_strided_dnannsum( N, X, strideX, &n );
- out[ io + strideOut ] = (double)n;
+ return NULL;
+}
+
+/**
+* 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, 7 );
+ 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_INT64( env, strideOut, argv, 5 );
+ STDLIB_NAPI_ARGV_INT64( env, offsetOut, argv, 6 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 4 );
+
+ CBLAS_INT n;
+ Out[ offsetOut ] = API_SUFFIX(stdlib_strided_dnannsum_ndarray)( N, X, strideX, offsetX, &n );
+ Out[ offsetOut+strideOut ] = (double)n;
return NULL;
}
-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/dnannsum/src/dnannsum.c b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/src/main.c
similarity index 51%
rename from lib/node_modules/@stdlib/blas/ext/base/dnannsum/src/dnannsum.c
rename to lib/node_modules/@stdlib/blas/ext/base/dnannsum/src/main.c
index 7e9c7fc85126..2d7e70aa426b 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/src/dnannsum.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/src/main.c
@@ -18,7 +18,8 @@
#include "stdlib/blas/ext/base/dnannsum.h"
#include "stdlib/blas/ext/base/dnannsumkbn.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, ignoring `NaN` values.
@@ -29,6 +30,21 @@
* @param n pointer for storing the number of non-NaN elements
* @return output value
*/
-double stdlib_strided_dnannsum( const int64_t N, const double *X, const int64_t stride, int64_t *n ) {
- return stdlib_strided_dnannsumkbn( N, X, stride, n );
+double API_SUFFIX(stdlib_strided_dnannsum)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, CBLAS_INT *n ) {
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ return API_SUFFIX(stdlib_strided_dnannsum_ndarray)( N, X, strideX, ox, n );
+}
+
+/**
+* Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using alternative indexing semantics.
+*
+* @param N number of indexed elements
+* @param X input array
+* @param strideX stride length
+* @param offsetX starting index
+* @param n pointer for storing the number of non-NaN elements
+* @return output value
+*/
+double API_SUFFIX(stdlib_strided_dnannsum_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n ) {
+ return API_SUFFIX(stdlib_strided_dnannsumkbn_ndarray)( N, X, strideX, offsetX, n );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.dnannsum.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.dnannsum.js
index 12d9edfb1943..6b16ced7aa3c 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.dnannsum.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.dnannsum.js
@@ -215,7 +215,7 @@ tape( 'the function supports negative `stride` parameters', function test( t ) {
t.end();
});
-tape( 'if provided a `stride` parameter equal to `0`, the function returns a sum equal to the first element', function test( t ) {
+tape( 'if provided a `stride` parameter equal to `0`, the function returns a sum of the first element repeated N times', function test( t ) {
var expected;
var out;
var x;
@@ -226,7 +226,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns a sum
out = new Float64Array( 2 );
v = dnannsum( x.length, x, 0, out, 1 );
- expected = new Float64Array( [ 1.0, 1.0 ] );
+ expected = new Float64Array( [ 5.0, 5.0 ] );
t.deepEqual( v, expected, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.dnannsum.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.dnannsum.native.js
index 6f31bd7df9ec..960a3670412e 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.dnannsum.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.dnannsum.native.js
@@ -224,7 +224,7 @@ tape( 'the function supports negative `stride` parameters', opts, function test(
t.end();
});
-tape( 'if provided a `stride` parameter equal to `0`, the function returns a sum equal to the first element', opts, function test( t ) {
+tape( 'if provided a `stride` parameter equal to `0`, the function returns a sum of the first element repeated N times', opts, function test( t ) {
var expected;
var out;
var x;
@@ -235,7 +235,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns a sum
out = new Float64Array( 2 );
v = dnannsum( x.length, x, 0, out, 1 );
- expected = new Float64Array( [ 1.0, 1.0 ] );
+ expected = new Float64Array( [ 5.0, 5.0 ] );
t.deepEqual( v, expected, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.ndarray.js
index 22b81f068088..6083117f52e2 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.ndarray.js
@@ -215,7 +215,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 first indexed element', function test( t ) {
+tape( 'if provided a `stride` parameter equal to `0`, the function returns a sum of the first element repeated N times', function test( t ) {
var expected;
var out;
var x;
@@ -226,7 +226,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
out = new Float64Array( 2 );
v = dnannsum( x.length, x, 0, 0, out, 1, 0 );
- expected = new Float64Array( [ 1.0, 1.0 ] );
+ expected = new Float64Array( [ 5.0, 5.0 ] );
t.deepEqual( v, expected, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.ndarray.native.js
index d18d685d61e1..98cbe2e473ba 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsum/test/test.ndarray.native.js
@@ -224,7 +224,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 first indexed element', opts, function test( t ) {
+tape( 'if provided a `stride` parameter equal to `0`, the function returns a sum of the first element repeated N times', opts, function test( t ) {
var expected;
var out;
var x;
@@ -235,7 +235,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
out = new Float64Array( 2 );
v = dnannsum( x.length, x, 0, 0, out, 1, 0 );
- expected = new Float64Array( [ 1.0, 1.0 ] );
+ expected = new Float64Array( [ 5.0, 5.0 ] );
t.deepEqual( v, expected, 'returns expected value' );
t.end();