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 3, 2023
1 parent ace9325 commit 0cb421e
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 97 deletions.
45 changes: 12 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,10 @@ The function has the following parameters:
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to calculate the dot product of every other value in `x` and 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 N = floor( x.length / 2 );

var z = gdot( N, x, 2, y, -1 );
var z = gdot( 3, x, 2, y, -1 );
// returns 9.0
```

Expand All @@ -122,7 +118,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 @@ -132,9 +127,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 );

var z = gdot( N, x1, -2, y1, 1 );
var z = gdot( 3, x1, -2, y1, 1 );
// returns 128.0
```

Expand All @@ -158,14 +151,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 calculate the dot product of every other value in `x` starting from the second value with the last 3 elements in `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 = [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ];

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

var z = gdot.ndarray( N, x, 2, 1, y, -1, y.length-1 );
var z = gdot.ndarray( 3, x, 2, 1, y, -1, y.length-1 );
// returns 128.0
```

Expand All @@ -191,28 +180,18 @@ var z = gdot.ndarray( N, 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 Float64Array = require( '@stdlib/array-float64' );
var Uint8ClampedArray = require( '@stdlib/array-uint8c' );
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var gdot = require( '@stdlib/blas-base-gdot' );

var x;
var y;
var i;

x = new Float64Array( 10 );
y = new Uint8ClampedArray( 10 );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = round( randu()*500.0 );
y[ i ] = round( randu()*255.0 );
}
var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 500 ) );
console.log( x );

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

// Compute the dot product:
var dot = gdot.ndarray( x.length, x, 1, 0, y, -1, y.length-1 );
console.log( dot );
var out = gdot.ndarray( x.length, x, 1, 0, y, -1, y.length-1 );
console.log( out );
```

</section>
Expand Down Expand Up @@ -314,12 +293,12 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].

[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

<!-- <related-links> -->

[@stdlib/blas/base/ddot]: https://github.com/stdlib-js/blas-base-ddot

[@stdlib/blas/base/sdot]: https://github.com/stdlib-js/blas-base-sdot

<!-- <related-links> -->

[@stdlib/blas/gdot]: https://github.com/stdlib-js/blas-gdot

<!-- </related-links> -->
Expand Down
20 changes: 9 additions & 11 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +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 pkg = require( './../package.json' ).name;
var gdot = require( './../lib' );


// VARIABLES //

var rand = uniform( -100.0, 100.0 );


// FUNCTIONS //

/**
Expand All @@ -38,16 +44,8 @@ var gdot = require( './../lib' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

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

/**
Expand Down
20 changes: 9 additions & 11 deletions benchmark/benchmark.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +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 pkg = require( './../package.json' ).name;
var gdot = require( './../lib' ).ndarray;


// VARIABLES //

var rand = uniform( -100.0, 100.0 );


// FUNCTIONS //

/**
Expand All @@ -38,16 +44,8 @@ var gdot = require( './../lib' ).ndarray;
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

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

/**
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0cb421e

Please sign in to comment.