Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update blas/ext/base/dcusum to follow current project conventions #1867

Merged
merged 10 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions lib/node_modules/@stdlib/blas/ext/base/dcusum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,15 @@ The function has the following parameters:
- **y**: output [`Float64Array`][@stdlib/array/float64].
- **strideY**: index increment for `y`.

The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative sum of every other element in `x`,
The `N` and `stride` parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative sum of every other element in the strided input array,

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var floor = require( '@stdlib/math/base/special/floor' );

var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] );
var y = new Float64Array( x.length );

var N = floor( x.length / 2 );

var v = dcusum( N, 0.0, x, 2, y, 1 );
var v = dcusum( 4, 0.0, x, 2, y, 1 );
// y => <Float64Array>[ 1.0, 3.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ]
```

Expand All @@ -86,7 +83,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var floor = require( '@stdlib/math/base/special/floor' );

// Initial arrays...
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
Expand All @@ -96,9 +92,7 @@ var y0 = new Float64Array( x0.length );
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element

var N = floor( x0.length / 2 );

dcusum( N, 0.0, x1, -2, y1, 1 );
dcusum( 4, 0.0, x1, -2, y1, 1 );
// y0 => <Float64Array>[ 0.0, 0.0, 0.0, 4.0, 6.0, 4.0, 5.0, 0.0 ]
```

Expand All @@ -121,18 +115,15 @@ 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 `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element
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

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var floor = require( '@stdlib/math/base/special/floor' );

var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
var y = new Float64Array( x.length );

var N = floor( x.length / 2 );

dcusum.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 );
dcusum.ndarray( 4, 0.0, x, 2, 1, y, -1, y.length-1 );
// y => <Float64Array>[ 0.0, 0.0, 0.0, 0.0, 5.0, 1.0, -1.0, 1.0 ]
```

Expand All @@ -157,20 +148,14 @@ dcusum.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
var Float64Array = require( '@stdlib/array/float64' );
var dcusum = require( '@stdlib/blas/ext/base/dcusum' );

var y;
var x;
var i;
var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) );
var y = new Float64Array( x.length );

x = new Float64Array( 10 );
y = new Float64Array( x.length );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = round( randu()*100.0 );
}
console.log( x );
console.log( y );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var dcusum = require( './../lib/dcusum.js' );


// VARIABLES //

var rand = uniform( -10.0, 10.0 );


// FUNCTIONS //

/**
Expand All @@ -39,15 +45,8 @@ var dcusum = require( './../lib/dcusum.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var y;
var x;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = filledarrayBy( len, 'float64', rand );
var y = new Float64Array( len );
return benchmark;

function benchmark( b ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var Float64Array = require( '@stdlib/array/float64' );
Expand All @@ -36,6 +37,7 @@ var dcusum = tryRequire( resolve( __dirname, './../lib/dcusum.native.js' ) );
var opts = {
'skip': ( dcusum instanceof Error )
};
var rand = uniform( -10.0, 10.0 );


// FUNCTIONS //
Expand All @@ -48,15 +50,8 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = filledarrayBy( len, 'float64', rand );
var y = new Float64Array( len );
return benchmark;

function benchmark( b ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var dcusum = require( './../lib/ndarray.js' );


// VARIABLES //

var rand = uniform( -10.0, 10.0 );


// FUNCTIONS //

/**
Expand All @@ -39,15 +45,8 @@ var dcusum = require( './../lib/ndarray.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = filledarrayBy( len, 'float64', rand );
var y = new Float64Array( len );
return benchmark;

function benchmark( b ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var Float64Array = require( '@stdlib/array/float64' );
Expand All @@ -36,6 +37,7 @@ var dcusum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
var opts = {
'skip': ( dcusum instanceof Error )
};
var rand = uniform( -10.0, 10.0 );


// FUNCTIONS //
Expand All @@ -48,15 +50,8 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = filledarrayBy( len, 'float64', rand );
var y = new Float64Array( len );
return benchmark;

function benchmark( b ) {
Expand Down
14 changes: 6 additions & 8 deletions lib/node_modules/@stdlib/blas/ext/base/dcusum/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Computes the cumulative sum of double-precision floating-point strided array
elements.

The `N` and `stride` parameters determine which elements in `x` and `y` are
accessed at runtime.
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
array view.
Expand Down Expand Up @@ -47,21 +47,20 @@
// Using `N` and `stride` parameters:
> x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] );
> y = new {{alias:@stdlib/array/float64}}( x.length );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}( N, 0.0, x, 2, y, 2 )
> {{alias}}( 3, 0.0, x, 2, y, 2 )
<Float64Array>[ -2.0, 0.0, -1.0, 0.0, 1.0, 0.0 ]

// Using view offsets:
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
> var y0 = new {{alias:@stdlib/array/float64}}( x0.length );
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 );
> N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
> {{alias}}( N, 0.0, x1, 2, y1, 1 )
> {{alias}}( 3, 0.0, x1, 2, y1, 1 )
<Float64Array>[ -2.0, 0.0, -1.0 ]
> y0
<Float64Array>[ 0.0, 0.0, 0.0, -2.0, 0.0, -1.0 ]


{{alias}}.ndarray( N, sum, x, strideX, offsetX, y, strideY, offsetY )
Computes the cumulative sum of double-precision floating-point strided array
elements using alternative indexing semantics.
Expand Down Expand Up @@ -112,8 +111,7 @@
// Advanced indexing:
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
> y = new {{alias:@stdlib/array/float64}}( x.length );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 )
> {{alias}}.ndarray( 3, 0.0, x, 2, 1, y, -1, y.length-1 )
<Float64Array>[ 0.0, 0.0, 0.0, -1.0, 0.0, -2.0 ]

See Also
Expand Down
14 changes: 4 additions & 10 deletions lib/node_modules/@stdlib/blas/ext/base/dcusum/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,14 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
var Float64Array = require( '@stdlib/array/float64' );
var dcusum = require( './../lib' );

var y;
var x;
var i;
var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) );
var y = new Float64Array( x.length );

x = new Float64Array( 10 );
y = new Float64Array( x.length );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = round( randu()*100.0 );
}
console.log( x );
console.log( y );

Expand Down
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/blas/ext/base/dcusum/include.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Source files:
'src_files': [
'<(src_dir)/addon.cpp',
'<(src_dir)/addon.c',
'<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
],

Expand Down
3 changes: 1 addition & 2 deletions lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/dcusum.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ var dcusumkbn = require( '@stdlib/blas/ext/base/dcusumkbn' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
* var y = new Float64Array( x.length );
* var N = x.length;
*
* var v = dcusum( N, 0.0, x, 1, y, 1 );
* var v = dcusum( 3, 0.0, x, 1, y, 1 );
* // returns <Float64Array>[ 1.0, -1.0, 1.0 ]
*/
function dcusum( N, sum, x, strideX, y, strideY ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ var addon = require( './../src/addon.node' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
* var y = new Float64Array( x.length );
* var N = x.length;
*
* var v = dcusum( N, 0.0, x, 1, y, 1 );
* var v = dcusum( 3, 0.0, x, 1, y, 1 );
* // returns <Float64Array>[ 1.0, -1.0, 1.0 ]
*/
function dcusum( N, sum, x, strideX, y, strideY ) {
Expand Down
7 changes: 2 additions & 5 deletions lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,18 @@
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
* var y = new Float64Array( x.length );
* var N = x.length;
*
* dcusum( N, 0.0, x, 1, y, 1 );
* dcusum( 3, 0.0, x, 1, y, 1 );
* // y => <Float64Array>[ 1.0, -1.0, 1.0 ]
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
* var floor = require( '@stdlib/math/base/special/floor' );
* var dcusum = require( '@stdlib/blas/ext/base/dcusum' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
* var y = new Float64Array( x.length );
* var N = floor( x.length / 2 );
*
* dcusum.ndarray( N, 0.0, x, 2, 1, y, 1, 0 );
* dcusum.ndarray( 4, 0.0, x, 2, 1, y, 1, 0 );
* // y => <Float64Array>[ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ]
*/

Expand Down
4 changes: 1 addition & 3 deletions lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ var dcusumkbn = require( '@stdlib/blas/ext/base/dcusumkbn' ).ndarray;
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
* var floor = require( '@stdlib/math/base/special/floor' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
* var y = new Float64Array( x.length );
* var N = floor( x.length / 2 );
*
* var v = dcusum( N, 0.0, x, 2, 1, y, 1, 0 );
* var v = dcusum( 4, 0.0, x, 2, 1, y, 1, 0 );
* // returns <Float64Array>[ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ]
*/
function dcusum( N, sum, x, strideX, offsetX, y, strideY, offsetY ) {
Expand Down
Loading
Loading