Skip to content
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
77 changes: 34 additions & 43 deletions lib/node_modules/@stdlib/blas/base/wasm/srotm/test/test.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

var tape = require( 'tape' );
var Float32Array = require( '@stdlib/array/float32' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValuef = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var srotm = require( './../lib' );


Expand All @@ -36,22 +35,14 @@ var srotm = require( './../lib' );
* @param {Object} t - test object
* @param {Collection} actual - actual values
* @param {Collection} expected - expected values
* @param {number} rtol - relative tolerance
* @param {NonNegativeInteger} ulp - maximum allowed ULP difference
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;
function isApprox( t, actual, expected, ulp ) {
var i;

t.strictEqual( actual.length, expected.length, 'returns expected value' );
for ( i = 0; i < expected.length; i++ ) {
if ( actual[ i ] === expected[ i ] ) {
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
} else {
delta = abs( actual[ i ] - expected[ i ] );
tol = rtol * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValuef( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand Down Expand Up @@ -104,8 +95,8 @@ tape( 'the function applies a modified Givens plane rotation (sx=1, sy=1)', func
x = new Float32Array( xbuf );
y = new Float32Array( ybuf );
out = srotm.main( N[ i ], x, 1, y, 1, param );
isApprox( t, x, xe[ i ], 5.0 );
isApprox( t, y, ye[ i ], 5.0 );
isApprox( t, x, xe[ i ], 1 );
isApprox( t, y, ye[ i ], 0 );
t.strictEqual( out, y, 'returns expected value' );
}
t.end();
Expand Down Expand Up @@ -146,8 +137,8 @@ tape( 'the function applies a modified Givens plane rotation (sx=2, sy=-2)', fun
x = new Float32Array( xbuf );
y = new Float32Array( ybuf );
out = srotm.main( N[ i ], x, 2, y, -2, param );
isApprox( t, x, xe[ i ], 10.0 );
isApprox( t, y, ye[ i ], 10.0 );
isApprox( t, x, xe[ i ], 0 );
isApprox( t, y, ye[ i ], 1 );
t.strictEqual( out, y, 'returns expected value' );
}
t.end();
Expand Down Expand Up @@ -188,8 +179,8 @@ tape( 'the function applies a modified Givens plane rotation (sx=-2, sy=1)', fun
x = new Float32Array( xbuf );
y = new Float32Array( ybuf );
out = srotm.main( N[ i ], x, -2, y, 1, param );
isApprox( t, x, xe[ i ], 10.0 );
isApprox( t, y, ye[ i ], 10.0 );
isApprox( t, x, xe[ i ], 1 );
isApprox( t, y, ye[ i ], 2 );
t.strictEqual( out, y, 'returns expected value' );
}
t.end();
Expand Down Expand Up @@ -230,8 +221,8 @@ tape( 'the function applies a plane rotation (sx=-1, sy=-2)', function test( t )
x = new Float32Array( xbuf );
y = new Float32Array( ybuf );
out = srotm.main( N[ i ], x, -1, y, -2, param );
isApprox( t, x, xe[ i ], 4.0 );
isApprox( t, y, ye[ i ], 4.0 );
isApprox( t, x, xe[ i ], 1 );
isApprox( t, y, ye[ i ], 0 );
t.strictEqual( out, y, 'returns expected value' );
}
t.end();
Expand Down Expand Up @@ -277,8 +268,8 @@ tape( 'the `main` method applies a plane rotation', function test( t ) {
10.0 // 2
]);

isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

x = new Float32Array([
1.0, // 0
Expand Down Expand Up @@ -313,8 +304,8 @@ tape( 'the `main` method applies a plane rotation', function test( t ) {
10.0
]);

isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -359,8 +350,8 @@ tape( 'the `main` method supports an `x` stride', function test( t ) {
10.0
]);

isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

x = new Float32Array([
1.0, // 0
Expand Down Expand Up @@ -395,8 +386,8 @@ tape( 'the `main` method supports an `x` stride', function test( t ) {
10.0
]);

isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -441,8 +432,8 @@ tape( 'the `main` method supports a negative `x` stride', function test( t ) {
10.0
]);

isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

x = new Float32Array([
1.0, // 2
Expand Down Expand Up @@ -477,8 +468,8 @@ tape( 'the `main` method supports a negative `x` stride', function test( t ) {
10.0
]);

isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -523,8 +514,8 @@ tape( 'the `main` method supports a `y` stride', function test( t ) {
16.0 // 2
]);

isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

x = new Float32Array([
1.0, // 0
Expand Down Expand Up @@ -559,8 +550,8 @@ tape( 'the `main` method supports a `y` stride', function test( t ) {
10.0
]);

isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -605,8 +596,8 @@ tape( 'the `main` method supports a negative `y` stride', function test( t ) {
10.0
]);

isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

x = new Float32Array([
1.0, // 0
Expand Down Expand Up @@ -641,8 +632,8 @@ tape( 'the `main` method supports a negative `y` stride', function test( t ) {
2.0 // 0
]);

isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -720,8 +711,8 @@ tape( 'the `main` method supports complex access patterns', function test( t ) {
xe = new Float32Array( [ -0.9, -0.8, -0.5, 0.8, 0.9, -0.3, -0.4 ] );
ye = new Float32Array( [ 1.7, -0.9, 0.5, 0.7, -0.6, 0.2, 0.8 ] );

isApprox( t, x, xe, 5.0 );
isApprox( t, y, ye, 5.0 );
isApprox( t, x, xe, 0 );
isApprox( t, y, ye, 0 );

t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
var tape = require( 'tape' );
var Memory = require( '@stdlib/wasm/memory' );
var Float32Array = require( '@stdlib/array/float32' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValuef = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var Module = require( './../lib' ).Module;


Expand All @@ -39,22 +38,14 @@
* @param {Object} t - test object
* @param {Collection} actual - actual values
* @param {Collection} expected - expected values
* @param {number} rtol - relative tolerance
* @param {NonNegativeInteger} ulp - maximum allowed ULP difference
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;
function isApprox( t, actual, expected, ulp ) {
var i;

t.strictEqual( actual.length, expected.length, 'returns expected value' );
for ( i = 0; i < expected.length; i++ ) {
if ( actual[ i ] === expected[ i ] ) {
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
} else {
delta = abs( actual[ i ] - expected[ i ] );
tol = rtol * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValuef( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand Down Expand Up @@ -115,8 +106,8 @@
actualY = new Float32Array( 4 );
mod.read( yp, actualY );

isApprox( t, actualX, xe, 2.0 );
isApprox( t, actualY, ye, 2.0 );
isApprox( t, actualX, xe, 1 );
isApprox( t, actualY, ye, 0 );

// Short datasets:
xp = 0;
Expand All @@ -138,8 +129,8 @@
actualY = new Float32Array( 2 );
mod.read( yp, actualY );

isApprox( t, actualX, xe, 2.0 );
isApprox( t, actualY, ye, 2.0 );
isApprox( t, actualX, xe, 1 );
isApprox( t, actualY, ye, 0 );

t.end();
});
Expand All @@ -165,8 +156,8 @@
yp = 56;
pp = 112;

mod.write( xp, new Float32Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ) );

Check warning on line 159 in lib/node_modules/@stdlib/blas/base/wasm/srotm/test/test.module.main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 82. Maximum allowed is 80
mod.write( yp, new Float32Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ) );

Check warning on line 160 in lib/node_modules/@stdlib/blas/base/wasm/srotm/test/test.module.main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 81. Maximum allowed is 80
mod.write( pp, new Float32Array( [ 1.0, 5.0, 2.0, 0.0, -4.0 ] ) );

xe = new Float32Array( [ 3.8, 0.1, -3.1, 0.8, 4.8, -0.3, -1.5 ] );
Expand All @@ -180,8 +171,8 @@
actualY = new Float32Array( 7 );
mod.read( yp, actualY );

isApprox( t, actualX, xe, 2.0 );
isApprox( t, actualY, ye, 2.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 1 );

t.end();
});
Expand Down Expand Up @@ -246,8 +237,8 @@
actualY = new Float32Array( 5 );
mod.read( yp, actualY );

isApprox( t, actualX, xe, 2.0 );
isApprox( t, actualY, ye, 2.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -312,8 +303,8 @@
actualY = new Float32Array( 5 );
mod.read( yp, actualY );

isApprox( t, actualX, xe, 2.0 );
isApprox( t, actualY, ye, 2.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -378,8 +369,8 @@
actualY = new Float32Array( 5 );
mod.read( yp, actualY );

isApprox( t, actualX, xe, 2.0 );
isApprox( t, actualY, ye, 2.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -444,8 +435,8 @@
actualY = new Float32Array( 5 );
mod.read( yp, actualY );

isApprox( t, actualX, xe, 2.0 );
isApprox( t, actualY, ye, 2.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -583,8 +574,8 @@
actualY = new Float32Array( 7 );
mod.read( yp, actualY );

isApprox( t, actualX, xe, 2.0 );
isApprox( t, actualY, ye, 2.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 0 );

t.end();
});
Loading
Loading