Skip to content

feat: add blas/base/drot #1823

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

Merged
merged 27 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ccd0c39
chore: in-process
aman-095 Mar 10, 2024
64788f5
feat: add BLAS Level 1 drot routine
aman-095 Mar 11, 2024
e064ac3
chore: apply error changes
aman-095 Mar 11, 2024
9960599
chore: solve lint error
aman-095 Mar 11, 2024
37dd267
chore: apply changes for lint error and tests
aman-095 Mar 11, 2024
de92f4a
chore: apply readme changes
aman-095 Mar 12, 2024
9e371a5
chore: apply review changes
aman-095 Mar 12, 2024
25d7542
Apply suggestions from code review
kgryte Mar 14, 2024
18681d4
Apply suggestions from code review
kgryte Mar 14, 2024
df45a1a
Apply suggestions from code review
kgryte Mar 14, 2024
7fb5d2c
Apply suggestions from code review
kgryte Mar 14, 2024
fec516f
Apply suggestions from code review
kgryte Mar 14, 2024
fd7978d
chore: apply review changes
aman-095 Mar 14, 2024
639ea83
chore: apply review changes
aman-095 Mar 14, 2024
e18d183
chore: apply review changes
aman-095 Mar 14, 2024
4cf3434
Apply suggestions from code review
kgryte Mar 15, 2024
1f34b38
Apply suggestions from code review
kgryte Mar 15, 2024
bd544ea
chore: apply review changes
aman-095 Mar 15, 2024
47361ef
chore: apply suggestions from code review
Pranavchiku Mar 16, 2024
21002f9
chore: apply review changes
aman-095 Mar 17, 2024
3c73b2c
chore: apply review changes
aman-095 Mar 25, 2024
e005888
chore: apply review changes
aman-095 Mar 26, 2024
23b03d1
feat: add C / Fortran implementation for drot
aman-095 Apr 12, 2024
7e37513
chore: apply review changes
aman-095 Apr 12, 2024
818ede6
chore: resolve lint errors
aman-095 Apr 12, 2024
c8e7dea
refactor: replace use of 'double precision' and update tests
kgryte Apr 19, 2024
43f62d8
docs: update example
kgryte Apr 19, 2024
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
Prev Previous commit
Next Next commit
chore: apply review changes
  • Loading branch information
aman-095 committed Mar 17, 2024
commit 21002f977d77aaed0bc8024bdda76517fec2aecf
18 changes: 9 additions & 9 deletions lib/node_modules/@stdlib/blas/base/drot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var y = new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );

drot( x.length, x, 2, y, 2, 0.707, 0.707 );
// x => <Float64Array>[ ~5.7, 2.0, ~8.5, 4.0, ~11.3, 6.0 ]
// y => <Float64Array>[ ~4.2, 8.0, ~4.2, 10.0, ~4.2, 12.0 ]
drot( 3, x, 2, y, 2, 0.8, 0.6 );
// x => <Float64Array>[ 5.0, 2.0, 7.8, 4.0, 10.6, 6.0 ]
// y => <Float64Array>[ ~5.0, 8.0, 5.4, 10.0, ~5.8, 12.0 ]
```

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
Expand Down Expand Up @@ -112,7 +112,7 @@ var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );

drot.ndarray( x.length, x, 1, 1, y, 1, 1, 0.8, 0.6 );
drot.ndarray( 4, x, 1, 1, y, 1, 1, 0.8, 0.6 );
// x => <Float64Array>[ 1.0, ~5.8, 7.2, 8.6, 10.0 ]
// y => <Float64Array>[ 6.0, 4.4, ~4.6, ~4.8, 5.0 ]
```
Expand All @@ -122,17 +122,17 @@ 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, the offset parameters support indexing semantics based on starting indices. For example, to apply a plane rotation to every other element starting from second element,
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 apply a plane rotation to every other element starting from the second element,

```javascript
var Float64Array = require( '@stdlib/array/float64' );

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

drot.ndarray( x.length, x, 2, 2, y, 2, 2, 0.8, 0.6 );
// x => <Float64Array>[ 1.0, 2.0, 7.8, 4.0, 10.6, 6.0 ]
// y => <Float64Array>[ 7.0, 8.0, 5.4, 10.0, ~5.8, 12.0 ]
drot.ndarray( 3, x, 2, 1, y, 2, 1, 0.8, 0.6 );
// x => <Float64Array>[ 1.0, 6.4, 3.0, 9.2, 5.0, 12.0 ]
// y => <Float64Array>[ 7.0, 5.2, 9.0, 5.6, 11.0, ~6.0 ]
```

</section>
Expand Down Expand Up @@ -169,7 +169,7 @@ console.log( x );
var y = discreteUniform( x.length, 0, 255, opts );
console.log( y );

// Apply a plane rotation :
// Apply a plane rotation:
drot( x.length, x, 1, y, 1, 0.8, 0.6 );
console.log( x );
console.log( y );
Expand Down
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/blas/base/drot/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@
// Standard Usage:
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
> var y = new {{alias:@stdlib/array/float64}}( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
> {{alias}}.ndarray( x.length, x, 1, 1, y, 1, 1, 0.8, 0.6 );
> {{alias}}.ndarray( 4, x, 1, 1, y, 1, 1, 0.8, 0.6 );
> x
<Float64Array>[ 1.0, ~5.8, 7.2, 8.6, 10.0 ]
<Float64Array>[ 6.0, 4.4, ~4.6, ~4.8, 5.0 ]

// Advanced Indexing:
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> y = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
> {{alias}}.ndarray( x.length, x, 2, 2, y, 2, 2, 0.8, 0.6 );
> {{alias}}.ndarray( 3, x, 2, 1, y, 2, 1, 0.8, 0.6 );
> x
<Float64Array>[ 1.0, 2.0, 7.8, 4.0, 10.6, 6.0 ]
<Float64Array>[ 1.0, 6.4, 3.0, 9.2, 5.0, 12.0 ]
> y
<Float64Array>[ 7.0, 8.0, 5.4, 10.0, ~5.8, 12.0 ]
<Float64Array>[ 7.0, 5.2, 9.0, 5.6, 11.0, ~6.0 ]

See Also
--------
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/blas/base/drot/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ interface Routine {
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var y = new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
*
* drot.ndarray( 4, x, 0, 2, y, 0, 2, 0.707, 0.707 );
* // x => <Float64Array>[ 1.0, 2.0, ~-3.0, 4.0, 5.0, 6.0 ]
* // y => <Float64Array>[ 7.0, 8.0, ~-9.0, 10.0, 11.0, 12.0 ]
* drot.ndarray( 3, x, 2, 1, y, 2, 1, 0.8, 0.6 );
* // x => <Float64Array>[ 1.0, 6.4, 3.0, 9.2, 5.0, 12.0 ]
* // y => <Float64Array>[ 7.0, 5.2, 9.0, 5.6, 11.0, ~6.0 ]
*/
ndarray( N: number, x: Float64Array, strideX: number, offsetX: number, y: Float64Array, strideY: number, offsetY: number, c: number, s: number ): Float64Array;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ interface Routine {
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var y = new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
*
* drot.ndarray( x.length, x, 2, 2, y, 2, 2, 0.8, 0.6 );
* drot.ndarray( 2, x, 2, 2, y, 2, 2, 0.8, 0.6 );
* // x => <Float64Array>[ 1.0, 2.0, 7.8, 4.0, 10.6, 6.0 ]
* // y => <Float64Array>[ 7.0, 8.0, 5.4, 10.0, ~5.8, 12.0 ]
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/blas/base/drot/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ console.log( x );
var y = discreteUniform( x.length, 0, 255, opts );
console.log( y );

drot( x.length, x, 1, y, 1, 0.707, 0.707 );
drot( x.length, x, 1, y, 1, 0.8, 0.6 );
console.log( x );
console.log( y );
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/blas/base/drot/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
* var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
*
* drot.ndarray( x.length, x, 1, 1, y, 1, 1, 0.8, 0.6 );
* drot.ndarray( 4, x, 1, 1, y, 1, 1, 0.8, 0.6 );
* // x => <Float64Array>[ 1.0, ~5.8, 7.2, 8.6, 10.0 ]
* // y => <Float64Array>[ 6.0, 4.4, ~4.6, ~4.8, 5.0 ]
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/blas/base/drot/lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
* var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
*
* drot( x.length, x, 1, 1, y, 1, 1, 0.8, 0.6 );
* drot( 4, x, 1, 1, y, 1, 1, 0.8, 0.6 );
* // x => <Float64Array>[ 1.0, ~5.8, 7.2, 8.6, 10.0 ]
* // y => <Float64Array>[ 6.0, 4.4, ~4.6, ~4.8, 5.0 ]
*/
Expand Down
56 changes: 8 additions & 48 deletions lib/node_modules/@stdlib/blas/base/drot/test/test.drot.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ tape( 'the function applies a plane rotation with x stride as 1 and y stride as
var out;
var ex;
var ey;
var ix;
var iy;
var c;
var j;
var k;
Expand All @@ -73,8 +71,6 @@ tape( 'the function applies a plane rotation with x stride as 1 and y stride as
[ 0.04, -0.78, 0.54, 0.08, -0.6, 0.2, 0.8 ]
];
nvalues = [ 0, 1, 2, 4 ];
ix = 1;
iy = 1;

xvalues = [
[ 0.6, 0.10, -0.5, 0.8, 0.9, -0.3, -0.4 ]
Expand All @@ -87,7 +83,7 @@ tape( 'the function applies a plane rotation with x stride as 1 and y stride as
for ( j = 0; j < nvalues.length; j++ ) {
x = new Float64Array( xvalues[ 0 ] );
y = new Float64Array( yvalues[ 0 ] );
out = drot( nvalues[ j ], x, ix, y, iy, 0.8, 0.6 );
out = drot( nvalues[ j ], x, 1, y, 1, 0.8, 0.6 );
ex = new Float64Array( xexpected[ c ] );
ey = new Float64Array( yexpected[ c ] );
c += 1;
Expand All @@ -106,13 +102,7 @@ tape( 'the function applies a plane rotation with x stride as 1 and y stride as
tol = 4.0 * EPS * abs( ey[ k ] );
t.ok( delta <= tol, 'within tolerance. y: '+y[ k ]+'. expected: '+ey[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
if ( out[ k ] === y[ k ] ) {
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
} else {
delta = abs( out[ k ] - y[ k ] );
tol = 4.0 * EPS * abs( y[ k ] );
t.ok( delta <= tol, 'within tolerance. out: '+out[ k ]+'. expected: '+y[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
}
}
t.end();
Expand All @@ -129,8 +119,6 @@ tape( 'the function applies a plane rotation with x stride as 2 and y stride as
var out;
var ex;
var ey;
var ix;
var iy;
var c;
var j;
var k;
Expand All @@ -150,8 +138,6 @@ tape( 'the function applies a plane rotation with x stride as 2 and y stride as
[ 0.64, -0.9, -0.3, 0.7, -0.18, 0.2, 0.28 ]
];
nvalues = [ 0, 1, 2, 4 ];
ix = 2;
iy = -2;

xvalues = [
[ 0.6, 0.10, -0.5, 0.8, 0.9, -0.3, -0.4 ]
Expand All @@ -164,7 +150,7 @@ tape( 'the function applies a plane rotation with x stride as 2 and y stride as
for ( j = 0; j < nvalues.length; j++ ) {
x = new Float64Array( xvalues[ 0 ] );
y = new Float64Array( yvalues[ 0 ] );
out = drot( nvalues[ j ], x, ix, y, iy, 0.8, 0.6 );
out = drot( nvalues[ j ], x, 2, y, -2, 0.8, 0.6 );
ex = new Float64Array( xexpected[ c ] );
ey = new Float64Array( yexpected[ c ] );
c += 1;
Expand All @@ -183,13 +169,7 @@ tape( 'the function applies a plane rotation with x stride as 2 and y stride as
tol = 20.0 * EPS * abs( ey[ k ] );
t.ok( delta <= tol, 'within tolerance. y: '+y[ k ]+'. expected: '+ey[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
if ( out[ k ] === y[ k ] ) {
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
} else {
delta = abs( out[ k ] - y[ k ] );
tol = 20.0 * EPS * abs( y[ k ] );
t.ok( delta <= tol, 'within tolerance. out: '+out[ k ]+'. expected: '+y[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
}
}
t.end();
Expand All @@ -206,8 +186,6 @@ tape( 'the function applies a plane rotation with x stride as -2 and y stride as
var out;
var ex;
var ey;
var ix;
var iy;
var c;
var j;
var k;
Expand All @@ -227,8 +205,6 @@ tape( 'the function applies a plane rotation with x stride as -2 and y stride as
[ 0.64, -1.26, 0.54, 0.2, -0.6, 0.2, 0.8 ]
];
nvalues = [ 0, 1, 2, 4 ];
ix = -2;
iy = 1;

xvalues = [
[ 0.6, 0.10, -0.5, 0.8, 0.9, -0.3, -0.4 ]
Expand All @@ -241,7 +217,7 @@ tape( 'the function applies a plane rotation with x stride as -2 and y stride as
for ( j = 0; j < nvalues.length; j++ ) {
x = new Float64Array( xvalues[ 0 ] );
y = new Float64Array( yvalues[ 0 ] );
out = drot( nvalues[ j ], x, ix, y, iy, 0.8, 0.6 );
out = drot( nvalues[ j ], x, -2, y, 1, 0.8, 0.6 );
ex = new Float64Array( xexpected[ c ] );
ey = new Float64Array( yexpected[ c ] );
c += 1;
Expand All @@ -260,13 +236,7 @@ tape( 'the function applies a plane rotation with x stride as -2 and y stride as
tol = 20.0 * EPS * abs( ey[ k ] );
t.ok( delta <= tol, 'within tolerance. y: '+y[ k ]+'. expected: '+ey[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
if ( out[ k ] === y[ k ] ) {
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
} else {
delta = abs( out[ k ] - y[ k ] );
tol = 20.0 * EPS * abs( y[ k ] );
t.ok( delta <= tol, 'within tolerance. out: '+out[ k ]+'. expected: '+y[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
}
}
t.end();
Expand All @@ -283,8 +253,6 @@ tape( 'the function applies a plane rotation with x stride as -1 and y stride as
var out;
var ex;
var ey;
var ix;
var iy;
var c;
var j;
var k;
Expand All @@ -304,8 +272,6 @@ tape( 'the function applies a plane rotation with x stride as -1 and y stride as
[ 0.04, -0.9, 0.18, 0.7, -0.18, 0.2, 0.16 ]
];
nvalues = [ 0, 1, 2, 4 ];
ix = -1;
iy = -2;

xvalues = [
[ 0.6, 0.10, -0.5, 0.8, 0.9, -0.3, -0.4 ]
Expand All @@ -318,7 +284,7 @@ tape( 'the function applies a plane rotation with x stride as -1 and y stride as
for ( j = 0; j < nvalues.length; j++ ) {
x = new Float64Array( xvalues[ 0 ] );
y = new Float64Array( yvalues[ 0 ] );
out = drot( nvalues[ j ], x, ix, y, iy, 0.8, 0.6 );
out = drot( nvalues[ j ], x, -1, y, -2, 0.8, 0.6 );
ex = new Float64Array( xexpected[ c ] );
ey = new Float64Array( yexpected[ c ] );
c += 1;
Expand All @@ -337,13 +303,7 @@ tape( 'the function applies a plane rotation with x stride as -1 and y stride as
tol = 4.0 * EPS * abs( ey[ k ] );
t.ok( delta <= tol, 'within tolerance. y: '+y[ k ]+'. expected: '+ey[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
if ( out[ k ] === y[ k ] ) {
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
} else {
delta = abs( out[ k ] - y[ k ] );
tol = 4.0 * EPS * abs( y[ k ] );
t.ok( delta <= tol, 'within tolerance. out: '+out[ k ]+'. expected: '+y[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
}
}
t.end();
Expand Down
32 changes: 4 additions & 28 deletions lib/node_modules/@stdlib/blas/base/drot/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,7 @@ tape( 'the function applies a plane rotation with x stride as 1 and y stride as
tol = 4.0 * EPS * abs( ey[ k ] );
t.ok( delta <= tol, 'within tolerance. y: '+y[ k ]+'. expected: '+ey[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
if ( out[ k ] === y[ k ] ) {
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
} else {
delta = abs( out[ k ] - y[ k ] );
tol = 4.0 * EPS * abs( y[ k ] );
t.ok( delta <= tol, 'within tolerance. out: '+out[ k ]+'. expected: '+y[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
}
}
t.end();
Expand Down Expand Up @@ -207,13 +201,7 @@ tape( 'the function applies a plane rotation with x stride as 2 and y stride as
tol = 20.0 * EPS * abs( ey[ k ] );
t.ok( delta <= tol, 'within tolerance. y: '+y[ k ]+'. expected: '+ey[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
if ( out[ k ] === y[ k ] ) {
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
} else {
delta = abs( out[ k ] - y[ k ] );
tol = 20.0 * EPS * abs( y[ k ] );
t.ok( delta <= tol, 'within tolerance. out: '+out[ k ]+'. expected: '+y[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
}
}
t.end();
Expand Down Expand Up @@ -296,13 +284,7 @@ tape( 'the function applies a plane rotation with x stride as -2 and y stride as
tol = 20.0 * EPS * abs( ey[ k ] );
t.ok( delta <= tol, 'within tolerance. y: '+y[ k ]+'. expected: '+ey[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
if ( out[ k ] === y[ k ] ) {
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
} else {
delta = abs( out[ k ] - y[ k ] );
tol = 20.0 * EPS * abs( y[ k ] );
t.ok( delta <= tol, 'within tolerance. out: '+out[ k ]+'. expected: '+y[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
}
}
t.end();
Expand Down Expand Up @@ -385,13 +367,7 @@ tape( 'the function applies a plane rotation with x stride as -1 and y stride as
tol = 4.0 * EPS * abs( ey[ k ] );
t.ok( delta <= tol, 'within tolerance. y: '+y[ k ]+'. expected: '+ey[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
if ( out[ k ] === y[ k ] ) {
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
} else {
delta = abs( out[ k ] - y[ k ] );
tol = 4.0 * EPS * abs( y[ k ] );
t.ok( delta <= tol, 'within tolerance. out: '+out[ k ]+'. expected: '+y[ k ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( out[ k ], y[ k ], 'returns expected value' );
}
}
t.end();
Expand Down