Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Dec 2, 2023
1 parent d8920fa commit 83dedaf
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 132 deletions.
38 changes: 9 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,13 @@ The function has the following parameters:
- **y**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
- **strideY**: index increment for `y`.

The `N` and stride parameters determine which elements in `x` and `y` are accessed at runtime. For example, to multiply every other value in `x` by `alpha` and add the result to the first `N` elements of `y` in reverse order,
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to multiply every other value in `x` by `alpha` and add the result to the first `N` elements of `y` in reverse order,

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

var x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
var y = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ];

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

gaxpy( N, alpha, x, 2, y, -1 );
gaxpy( 3, 5.0, x, 2, y, -1 );
// y => [ 26.0, 16.0, 6.0, 1.0, 1.0, 1.0 ]
```

Expand All @@ -104,7 +99,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( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
Expand All @@ -114,9 +108,7 @@ var y0 = new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
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 );

gaxpy( N, 5.0, x1, -2, y1, 1 );
gaxpy( 3, 5.0, x1, -2, y1, 1 );
// y0 => <Float64Array>[ 7.0, 8.0, 9.0, 40.0, 31.0, 22.0 ]
```

Expand All @@ -141,15 +133,10 @@ The function has the following additional parameters:
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 multiply every other value in `x` by a constant `alpha` starting from the second value and add to the last `N` elements in `y` where `x[i] -> y[n]`, `x[i+2] -> y[n-1]`,...,

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

var x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
var y = [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ];

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

gaxpy.ndarray( N, alpha, x, 2, 1, y, -1, y.length-1 );
gaxpy.ndarray( 3, 5.0, x, 2, 1, y, -1, y.length-1 );
// y => [ 7.0, 8.0, 9.0, 40.0, 31.0, 22.0 ]
```

Expand All @@ -175,21 +162,14 @@ gaxpy.ndarray( N, alpha, 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 gaxpy = require( '@stdlib/blas-base-gaxpy' );

var x;
var y;
var i;

x = [];
y = [];
for ( i = 0; i < 10; i++ ) {
x.push( round( randu()*100.0 ) );
y.push( round( randu()*10.0 ) );
}
var x = filledarrayBy( 10, 'generic', discreteUniform( 0, 100 ) );
console.log( x );

var y = filledarrayBy( x.length, 'generic', discreteUniform( 0, 10 ) );
console.log( y );

gaxpy.ndarray( x.length, 5.0, x, 1, 0, y, -1, y.length-1 );
Expand Down
21 changes: 9 additions & 12 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
// 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 gaxpy = require( './../lib' );


// VARIABLES //

var rand = uniform( -100.0, 100.0 );


// FUNCTIONS //

/**
Expand All @@ -39,16 +44,8 @@ var gaxpy = require( './../lib' );
* @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()*200.0 ) - 100.0;
y[ i ] = ( randu()*20000.0 ) - 10000.0;
}
var x = filledarrayBy( len, 'float64', rand );
var y = filledarrayBy( len, 'float64', rand );
return benchmark;

/**
Expand Down
21 changes: 9 additions & 12 deletions benchmark/benchmark.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
// 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 gaxpy = require( './../lib' ).ndarray;


// VARIABLES //

var rand = uniform( -100.0, 100.0 );


// FUNCTIONS //

/**
Expand All @@ -39,16 +44,8 @@ var gaxpy = require( './../lib' ).ndarray;
* @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()*200.0 ) - 100.0;
y[ i ] = ( randu()*20000.0 ) - 10000.0;
}
var x = filledarrayBy( len, 'float64', rand );
var y = filledarrayBy( len, 'float64', rand );
return benchmark;

/**
Expand Down
Loading

0 comments on commit 83dedaf

Please sign in to comment.