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
41 changes: 16 additions & 25 deletions lib/node_modules/@stdlib/blas/base/wasm/zdrot/test/test.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
var tape = require( 'tape' );
var Float64Array = require( '@stdlib/array/float64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var EPS = require( '@stdlib/constants/float64/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var zdrot = require( './../lib' );


Expand All @@ -37,22 +36,14 @@ var zdrot = 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( isAlmostSameValue( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand Down Expand Up @@ -125,8 +116,8 @@ tape( 'the `main` method applies a plane rotation', function test( t ) {
]);

out = zdrot.main( zx.length, zx, 1, zy, 1, 0.8, 0.6 );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewX, zxe, 1 );
isApprox( t, viewY, zye, 1 );
t.strictEqual( out, zy, 'returns expected value' );
t.end();
});
Expand Down Expand Up @@ -186,8 +177,8 @@ tape( 'the `main` method supports an `x` stride', function test( t ) {
]);

out = zdrot.main( 2, zx, 2, zy, 1, 0.8, 0.6 );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewX, zxe, 1 );
isApprox( t, viewY, zye, 1 );
t.strictEqual( out, zy, 'returns expected value' );
t.end();
});
Expand Down Expand Up @@ -247,8 +238,8 @@ tape( 'the `main` method supports a `y` stride', function test( t ) {
]);

out = zdrot.main( 2, zx, 1, zy, 2, 0.8, 0.6 );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewX, zxe, 1 );
isApprox( t, viewY, zye, 1 );
t.strictEqual( out, zy, 'returns expected value' );
t.end();
});
Expand Down Expand Up @@ -350,8 +341,8 @@ tape( 'the `main` method supports negative strides', function test( t ) {
]);

out = zdrot.main( 2, zx, -1, zy, -2, 0.8, 0.6 );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewX, zxe, 1 );
isApprox( t, viewY, zye, 1 );
t.strictEqual( out, zy, 'returns expected value' );
t.end();
});
Expand Down Expand Up @@ -411,8 +402,8 @@ tape( 'the `main` method supports complex access patterns', function test( t ) {
]);

out = zdrot.main( 2, zx, 2, zy, -1, 0.8, 0.6 );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewX, zxe, 1 );
isApprox( t, viewY, zye, 1 );
t.strictEqual( out, zy, 'returns expected value' );
t.end();
});
Expand Down Expand Up @@ -479,8 +470,8 @@ tape( 'the `main` method supports view offsets', function test( t ) {
]);

out = zdrot.main( 2, zx1, -2, zy1, 1, 0.8, 0.6 );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewX, zxe, 1 );
isApprox( t, viewY, zye, 1 );
t.strictEqual( out, zy1, 'returns expected value' );
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ var tape = require( 'tape' );
var Memory = require( '@stdlib/wasm/memory' );
var Float64Array = require( '@stdlib/array/float64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var EPS = require( '@stdlib/constants/float64/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var Module = require( './../lib' ).Module;


Expand All @@ -40,22 +39,14 @@ var Module = require( './../lib' ).Module;
* @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( isAlmostSameValue( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand Down Expand Up @@ -112,12 +103,12 @@ tape( 'a module instance has a `main` method which applies a plane rotation', fu
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Expand Down Expand Up @@ -199,12 +190,12 @@ tape( 'a module instance has a `main` method which supports an `x` stride', func
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Expand Down Expand Up @@ -286,12 +277,12 @@ tape( 'a module instance has a `main` method which supports a `y` stride', funct
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Expand Down Expand Up @@ -448,12 +439,12 @@ tape( 'a module instance has a `main` method which supports negative strides', f
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Expand Down Expand Up @@ -535,12 +526,12 @@ tape( 'a module instance has a `main` method which supports complex access patte
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

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


Expand All @@ -40,22 +39,14 @@ var Module = require( './../lib' ).Module;
* @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( isAlmostSameValue( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand Down Expand Up @@ -112,12 +103,12 @@ tape( 'a module instance has an `ndarray` method which applies a plane rotation'
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Expand Down Expand Up @@ -199,12 +190,12 @@ tape( 'a module instance has an `ndarray` method which supports an `x` stride',
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Expand Down Expand Up @@ -286,12 +277,12 @@ tape( 'a module instance has an `ndarray` method which supports an `x` offset',
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Expand Down Expand Up @@ -373,12 +364,12 @@ tape( 'a module instance has an `ndarray` method which supports a `y` stride', f
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Expand Down Expand Up @@ -460,12 +451,12 @@ tape( 'a module instance has an `ndarray` method which supports a `y` offset', f
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Expand Down Expand Up @@ -622,12 +613,12 @@ tape( 'a module instance has an `ndarray` method which supports negative strides
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Expand Down Expand Up @@ -709,12 +700,12 @@ tape( 'a module instance has an `ndarray` method which supports complex access p
actualX = new Complex128Array( 4 );
mod.read( zxp, actualX );
viewX = new Float64Array( actualX.buffer );
isApprox( t, viewX, zxe, 2.0 );
isApprox( t, viewX, zxe, 1 );

actualY = new Complex128Array( 4 );
mod.read( zyp, actualY );
viewY = new Float64Array( actualY.buffer );
isApprox( t, viewY, zye, 2.0 );
isApprox( t, viewY, zye, 1 );

t.end();
});
Loading
Loading