diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/README.md b/lib/node_modules/@stdlib/blas/ext/base/dcusum/README.md index ed65650cdc9d..74c504f7ee92 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/README.md @@ -208,14 +208,14 @@ stdlib_strided_dcusum( 4, 0.0, x, 1, y, 1 ); The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. -- **sum**: `[in] CBLAS_INT` initial sum. +- **sum**: `[in] double` initial sum. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` index increment for `X`. - **Y**: `[out] double*` output array. - **strideY**: `[in] CBLAS_INT` index increment for `Y`. ```c -void stdlib_strided_dcusum( const CBLAS_INT N, const CBLAS_INT sum, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ); +void stdlib_strided_dcusum( const CBLAS_INT N, const double sum, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ); ``` @@ -236,7 +236,7 @@ stdlib_strided_dcusum_ndarray( 4, 0.0, x, 1, 0, y, 1, 0 ); The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. -- **sum**: `[in] CBLAS_INT` initial sum. +- **sum**: `[in] double` initial sum. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` index increment for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. @@ -245,7 +245,7 @@ The function accepts the following arguments: - **offsetY**: `[in] CBLAS_INT` starting index for `Y`. ```c -void stdlib_strided_dcusum_ndarray( const CBLAS_INT N, const CBLAS_INT sum, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); +void stdlib_strided_dcusum_ndarray( const CBLAS_INT N, const double sum, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumkbn/README.md b/lib/node_modules/@stdlib/blas/ext/base/dcusumkbn/README.md index 99b723ca81bd..4bdd3b9084c5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumkbn/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumkbn/README.md @@ -208,14 +208,14 @@ stdlib_strided_dcusumkbn( 4, 0.0, x, 1, y, 1 ); The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. -- **sum**: `[in] CBLAS_INT` initial sum. +- **sum**: `[in] double` initial sum. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` index increment for `X`. - **Y**: `[out] double*` output array. - **strideY**: `[in] CBLAS_INT` index increment for `Y`. ```c -void stdlib_strided_dcusumkbn( const CBLAS_INT N, const CBLAS_INT sum, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ); +void stdlib_strided_dcusumkbn( const CBLAS_INT N, const double sum, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ); ``` @@ -236,7 +236,7 @@ stdlib_strided_dcusumkbn_ndarray( 4, 0.0, x, 1, 0, y, 1, 0 ); The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. -- **sum**: `[in] CBLAS_INT` initial sum. +- **sum**: `[in] double` initial sum. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` index increment for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. @@ -245,7 +245,7 @@ The function accepts the following arguments: - **offsetY**: `[in] CBLAS_INT` starting index for `Y`. ```c -void stdlib_strided_dcusumkbn_ndarray( const CBLAS_INT N, const CBLAS_INT sum, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); +void stdlib_strided_dcusumkbn_ndarray( const CBLAS_INT N, const double sum, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumkbn2/README.md b/lib/node_modules/@stdlib/blas/ext/base/dcusumkbn2/README.md index 0cc3d5de90a8..60925aa656d9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumkbn2/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumkbn2/README.md @@ -214,14 +214,14 @@ stdlib_strided_dcusumkbn2( 4, 0.0, x, 1, y, 1 ); The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. -- **sum**: `[in] CBLAS_INT` initial sum. +- **sum**: `[in] double` initial sum. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` index increment for `X`. - **Y**: `[out] double*` output array. - **strideY**: `[in] CBLAS_INT` index increment for `Y`. ```c -void stdlib_strided_dcusumkbn2( const CBLAS_INT N, const CBLAS_INT sum, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ); +void stdlib_strided_dcusumkbn2( const CBLAS_INT N, const double sum, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ); ``` @@ -242,7 +242,7 @@ stdlib_strided_dcusumkbn2_ndarray( 4, 0.0, x, 1, 0, y, 1, 0 ); The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. -- **sum**: `[in] CBLAS_INT` initial sum. +- **sum**: `[in] double` initial sum. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` index increment for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. @@ -251,7 +251,7 @@ The function accepts the following arguments: - **offsetY**: `[in] CBLAS_INT` starting index for `Y`. ```c -void stdlib_strided_dcusumkbn2_ndarray( const CBLAS_INT N, const CBLAS_INT sum, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); +void stdlib_strided_dcusumkbn2_ndarray( const CBLAS_INT N, const double sum, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/README.md b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/README.md index cc7706f58d7a..525d7a93482c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/README.md @@ -115,7 +115,7 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative sum of every other value in the strided input array starting from the second value and to store in the last `N` elements of the strided output array starting from the last element +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, to calculate the cumulative sum of every other value in the strided input array starting from the second value and to store in the last `N` elements of the strided output array starting from the last element ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -149,12 +149,13 @@ dcusumors.ndarray( 4, 0.0, x, 2, 1, y, -1, y.length-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 Float64Array = require( '@stdlib/array/float64' ); var dcusumors = require( '@stdlib/blas/ext/base/dcusumors' ); -var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) ); +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'float64' +}); var y = new Float64Array( x.length ); console.log( x ); @@ -168,6 +169,138 @@ console.log( y ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/dcusumors.h" +``` + +#### stdlib_strided_dcusumors( N, sum, \*X, strideX, \*Y, strideY ) + +Computes the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation. + +```c +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +double y[] = { 0.0, 0.0, 0.0, 0.0 }; + +stdlib_strided_dcusumors( 4, 0.0, x, 1, y, 1 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **sum**: `[in] double` initial sum. +- **X**: `[in] double*` input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **Y**: `[out] double*` output array. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. + +```c +void stdlib_strided_dcusumors( const CBLAS_INT N, double sum, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ); +``` + + + +#### stdlib_strided_dcusumors_ndarray( N, sum, \*X, strideX, offsetX, \*Y, strideY, offsetY ) + + + +Computes the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation and alternative indexing semantics. + +```c +const double x[] = { 1.0, 2.0, 3.0, 4.0 } +double y[] = { 0.0, 0.0, 0.0, 0.0 } + +stdlib_strided_dcusumors_ndarray( 4, 0.0, x, 1, 0, y, 1, 0 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **sum**: `[in] double` initial sum. +- **X**: `[in] double*` input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[out] double*` output array. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. + +```c +void stdlib_strided_dcusumors_ndarray( const CBLAS_INT N, double sum, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/ext/base/dcusumors.h" +#include + +int main( void ) { + // Create strided arrays: + const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify stride lengths: + const int strideX = 2; + const int strideY = -2; + + // Compute the cumulative sum: + stdlib_strided_dcusumors( N, 0.0, x, strideX, y, strideY ); + + // Print the result: + for ( int i = 0; i < 8; i++ ) { + printf( "y[ %d ] = %lf\n", i, y[ i ] ); + } +} +``` + +
+ + + +
+ + +
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.js index 5022df2c1756..72dd7d6a138a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/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 Float64Array = require( '@stdlib/array/float64' ); @@ -32,7 +31,9 @@ var dcusumors = require( './../lib/dcusumors.js' ); // VARIABLES // -var rand = uniform( -10.0, 10.0 ); +var options = { + 'dtype': 'float64' +}; // FUNCTIONS // @@ -45,7 +46,7 @@ var rand = uniform( -10.0, 10.0 ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'float64', rand ); + var x = uniform( len, -100, 100, options ); var y = new Float64Array( len ); return benchmark; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.native.js index 37792d8f2e81..befea65fff8c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/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 Float64Array = require( '@stdlib/array/float64' ); @@ -33,7 +32,9 @@ var pkg = require( './../package.json' ).name; // VARIABLES // -var rand = uniform( -10.0, 10.0 ); +var options = { + 'dtype': 'float64' +}; var dcusumors = tryRequire( resolve( __dirname, './../lib/dcusumors.native.js' ) ); var opts = { 'skip': ( dcusumors instanceof Error ) @@ -50,7 +51,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'float64', rand ); + var x = uniform( len, -100, 100, options ); var y = new Float64Array( len ); return benchmark; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.ndarray.js index 0b900d440a70..3356acbb5cb3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/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 Float64Array = require( '@stdlib/array/float64' ); @@ -32,7 +31,9 @@ var dcusumors = require( './../lib/ndarray.js' ); // VARIABLES // -var rand = uniform( -10.0, 10.0 ); +var options = { + 'dtype': 'float64' +}; // FUNCTIONS // @@ -45,7 +46,7 @@ var rand = uniform( -10.0, 10.0 ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'float64', rand ); + var x = uniform( len, -100, 100, options ); var y = new Float64Array( len ); return benchmark; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.ndarray.native.js index 4d25cae430ea..a38c173d66c7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/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 Float64Array = require( '@stdlib/array/float64' ); @@ -33,7 +32,9 @@ var pkg = require( './../package.json' ).name; // VARIABLES // -var rand = uniform( -10.0, 10.0 ); +var options = { + 'dtype': 'float64' +}; var dcusumors = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dcusumors instanceof Error ) @@ -50,7 +51,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'float64', rand ); + var x = uniform( len, -100, 100, options ); var y = new Float64Array( len ); return benchmark; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/c/benchmark.length.c index bde8a280d400..49c45ea47676 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/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 y[ len ]; @@ -121,6 +121,40 @@ static double benchmark( int iterations, int len ) { return elapsed; } +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + double x[ len ]; + double y[ len ]; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + y[ i ] = 0.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + x[ 0 ] += 1.0; + stdlib_strided_dcusumors_ndarray( len, 0.0, x, 1, 0, y, 1, 0 ); + if ( y[ 0 ] != y[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y[ len-1 ] != y[ len-1 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + /** * Main execution sequence. */ @@ -143,7 +177,18 @@ int main( void ) { for ( j = 0; j < REPEATS; j++ ) { count += 1; printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark( iter, len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/docs/repl.txt index cd2c847aa730..472d7a5d9f9e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/docs/repl.txt @@ -3,7 +3,7 @@ Computes the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation. - The `N` and `stride` parameters determine which elements in the strided + The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed @@ -67,7 +67,7 @@ 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 parameters support indexing semantics based on a starting index. Parameters diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/examples/c/example.c index 0e8318dbc562..6a912da6bc26 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/examples/c/example.c @@ -17,9 +17,7 @@ */ #include "stdlib/blas/ext/base/dcusumors.h" -#include #include -#include int main( void ) { // Create strided arrays: @@ -27,17 +25,17 @@ int main( void ) { double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; // Specify the number of elements: - const int64_t N = 4; + const int N = 4; // Specify stride lengths: - const int64_t strideX = 2; - const int64_t strideY = -2; + const int strideX = 2; + const int strideY = -2; // Compute the cumulative sum: stdlib_strided_dcusumors( N, 0.0, x, strideX, y, strideY ); // Print the result: - for ( int64_t i = 0; i < 8; i++ ) { - printf( "y[ %"PRId64" ] = %lf\n", i, y[ i ] ); + for ( int i = 0; i < 8; i++ ) { + printf( "y[ %d ] = %lf\n", i, y[ i ] ); } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/examples/index.js index 0e92da86a6cf..00a059d48037 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/examples/index.js @@ -18,12 +18,13 @@ '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 Float64Array = require( '@stdlib/array/float64' ); var dcusumors = require( './../lib' ); -var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) ); +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'float64' +}); var y = new Float64Array( x.length ); console.log( x ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/include/stdlib/blas/ext/base/dcusumors.h b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/include/stdlib/blas/ext/base/dcusumors.h index 95f3f1c10873..c60a8cc78f56 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/include/stdlib/blas/ext/base/dcusumors.h +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/include/stdlib/blas/ext/base/dcusumors.h @@ -19,7 +19,7 @@ #ifndef STDLIB_BLAS_EXT_BASE_DCUSUMORS_H #define STDLIB_BLAS_EXT_BASE_DCUSUMORS_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 cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation. */ -void stdlib_strided_dcusumors( const int64_t N, const double sum, const double *X, const int64_t strideX, double *Y, const int64_t strideY ); +void API_SUFFIX(stdlib_strided_dcusumors)( const CBLAS_INT N, double sum, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ); + +/** +* Computes the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation and alternative indexing semantics. +*/ +void API_SUFFIX(stdlib_strided_dcusumors_ndarray)( const CBLAS_INT N, double sum, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/lib/dcusumors.js b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/lib/dcusumors.js index c71ae77134ae..ed8198033211 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/lib/dcusumors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/lib/dcusumors.js @@ -18,6 +18,12 @@ 'use strict'; +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + // MAIN // /** @@ -41,29 +47,7 @@ * // returns [ 1.0, -1.0, 1.0 ] */ function dcusumors( N, sum, x, strideX, y, strideY ) { - var ix; - var iy; - var i; - - if ( N <= 0 ) { - return y; - } - if ( strideX < 0 ) { - ix = (1-N) * strideX; - } else { - ix = 0; - } - if ( strideY < 0 ) { - iy = (1-N) * strideY; - } else { - iy = 0; - } - for ( i = 0; i < N; i++ ) { - sum += x[ ix ]; - y[ iy ] = sum; - ix += strideX; - iy += strideY; - } + ndarray( N, sum, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ) ); // eslint-disable-line max-len return y; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/lib/ndarray.native.js index 6801b30868d3..a30811b1b578 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/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( './dcusumors.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -50,14 +48,7 @@ var addon = require( './dcusumors.native.js' ); * // returns [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ function dcusumors( N, sum, x, strideX, offsetX, y, strideY, offsetY ) { - var viewX; - var viewY; - offsetX = minViewBufferIndex( N, strideX, offsetX ); - offsetY = minViewBufferIndex( N, strideY, offsetY ); - - viewX = offsetView( x, offsetX ); - viewY = offsetView( y, offsetY ); - addon( N, sum, viewX, strideX, viewY, strideY ); + addon.ndarray( N, sum, x, strideX, offsetX, y, strideY, offsetY ); return y; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/manifest.json index 113b6112d7ab..0ec8bf37bc2b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/manifest.json @@ -28,50 +28,52 @@ { "task": "build", "src": [ - "./src/dcusumors.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-double", "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/export" + "@stdlib/napi/export", + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { "task": "benchmark", "src": [ - "./src/dcusumors.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] }, { "task": "examples", "src": [ - "./src/dcusumors.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] } ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/src/addon.c index e5f05db52ccc..ea5cc3d517f5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/src/addon.c @@ -17,11 +17,13 @@ */ #include "stdlib/blas/ext/base/dcusumors.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_double.h" #include "stdlib/napi/argv_strided_float64array.h" -#include "stdlib/napi/export.h" +#include /** * Receives JavaScript callback invocation data. @@ -38,9 +40,29 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 4 ); - stdlib_strided_dcusumors( N, sum, X, strideX, Y, strideY ); + API_SUFFIX(stdlib_strided_dcusumors)( N, sum, X, strideX, Y, strideY ); + 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, 8 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_DOUBLE( env, sum, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 6 ); + STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 7 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 5 ); + API_SUFFIX(stdlib_strided_dcusumors_ndarray)( N, sum, X, strideX, offsetX, Y, strideY, offsetY ); return NULL; } - // Register a Node-API module: -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/dcusumors/src/dcusumors.c b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/src/dcusumors.c deleted file mode 100644 index fd23e7cee4fe..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/src/dcusumors.c +++ /dev/null @@ -1,59 +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/dcusumors.h" -#include - -/** -* Computes the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation. -* -* @param N number of indexed elements -* @param sum initial sum -* @param X input array -* @param strideX X stride length -* @param Y output array -* @param strideY Y stride length -*/ -void stdlib_strided_dcusumors( const int64_t N, const double sum, const double *X, const int64_t strideX, double *Y, const int64_t strideY ) { - int64_t ix; - int64_t iy; - int64_t i; - double s; - - if ( N <= 0 ) { - return; - } - if ( strideX < 0 ) { - ix = (1-N) * strideX; - } else { - ix = 0; - } - if ( strideY < 0 ) { - iy = (1-N) * strideY; - } else { - iy = 0; - } - s = sum; - for ( i = 0; i < N; i++ ) { - s += X[ ix ]; - Y[ iy ] = s; - ix += strideX; - iy += strideY; - } - return; -} diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusumors/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/src/main.c new file mode 100644 index 000000000000..a954f216834d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusumors/src/main.c @@ -0,0 +1,68 @@ +/** +* @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/dcusumors.h" +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/blas/base/shared.h" + +/** +* Computes the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation. +* +* @param N number of indexed elements +* @param sum initial sum +* @param X input array +* @param strideX X stride length +* @param Y output array +* @param strideY Y stride length +*/ +void API_SUFFIX(stdlib_strided_dcusumors)( const CBLAS_INT N, double sum, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ) { + const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + const CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY ); + API_SUFFIX(stdlib_strided_dcusumors_ndarray)( N, sum, X, strideX, ox, Y, strideY, oy ); +} + +/** +* Computes the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation and alternative indexing semantics. +* +* @param N number of indexed elements +* @param sum initial sum +* @param X input array +* @param strideX X index increment +* @param offsetX X starting index +* @param Y output array +* @param strideY Y index increment +* @param offsetY Y starting index +*/ +void API_SUFFIX(stdlib_strided_dcusumors_ndarray)( const CBLAS_INT N, double sum, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { + CBLAS_INT ix; + CBLAS_INT iy; + CBLAS_INT i; + + if ( N <= 0 ) { + return; + } + ix = offsetX; + iy = offsetY; + for ( i = 0; i < N; i++ ) { + sum += X[ ix ]; + Y[ iy ] = sum; + ix += strideX; + iy += strideY; + } + return; +}