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
45 changes: 18 additions & 27 deletions lib/node_modules/@stdlib/blas/base/wasm/drot/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 dcopy = require( '@stdlib/blas/base/dcopy' );
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 drot = require( './../lib' );


Expand All @@ -37,22 +36,14 @@ var drot = 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 @@ -103,8 +94,8 @@ tape( 'the function applies a plane rotation (sx=1, sy=1)', function test( t ) {
x = new Float64Array( xbuf );
y = new Float64Array( ybuf );
out = drot.main( N[ i ], x, 1, y, 1, 0.8, 0.6 );
isApprox( t, x, xe[ i ], 6.0 );
isApprox( t, y, ye[ i ], 6.0 );
isApprox( t, x, xe[ i ], 1 );
isApprox( t, y, ye[ i ], 5 );
t.strictEqual( out, y, 'returns expected value' );
}
t.end();
Expand Down Expand Up @@ -143,8 +134,8 @@ tape( 'the function applies a plane rotation (sx=2, sy=-2)', function test( t )
x = new Float64Array( xbuf );
y = new Float64Array( ybuf );
out = drot.main( N[ i ], x, 2, y, -2, 0.8, 0.6 );
isApprox( t, x, xe[ i ], 20.0 );
isApprox( t, y, ye[ i ], 20.0 );
isApprox( t, x, xe[ i ], 21 );
isApprox( t, y, ye[ i ], 5 );
t.strictEqual( out, y, 'returns expected value' );
}
t.end();
Expand Down Expand Up @@ -183,8 +174,8 @@ tape( 'the function applies a plane rotation (sx=-2, sy=1)', function test( t )
x = new Float64Array( xbuf );
y = new Float64Array( ybuf );
out = drot.main( N[ i ], x, -2, y, 1, 0.8, 0.6 );
isApprox( t, x, xe[ i ], 20.0 );
isApprox( t, y, ye[ i ], 20.0 );
isApprox( t, x, xe[ i ], 21 );
isApprox( t, y, ye[ i ], 5 );
t.strictEqual( out, y, 'returns expected value' );
}
t.end();
Expand Down Expand Up @@ -223,8 +214,8 @@ tape( 'the function applies a plane rotation (sx=-1, sy=-2)', function test( t )
x = new Float64Array( xbuf );
y = new Float64Array( ybuf );
out = drot.main( N[ i ], x, -1, y, -2, 0.8, 0.6 );
isApprox( t, x, xe[ i ], 4.0 );
isApprox( t, y, ye[ i ], 4.0 );
isApprox( t, x, xe[ i ], 0 );
isApprox( t, y, ye[ i ], 5 );
t.strictEqual( out, y, 'returns expected value' );
}
t.end();
Expand Down Expand Up @@ -256,8 +247,8 @@ tape( 'the function supports an `x` stride', function test( t ) {
xe = new Float64Array( [ 4.4, 2.0, 6.6, 4.0, 5.0 ] );
ye = new Float64Array( [ 4.2, 3.8, 8.0, 9.0, 10.0 ] );

isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );
isApprox( t, x, xe, 1 );
isApprox( t, y, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -364,8 +355,8 @@ tape( 'the function supports negative strides', function test( t ) {
xe = new Float64Array( [ 0.9, 0.1, -0.22, 0.8, 0.18, -0.3, -0.02 ] );
ye = new Float64Array( [ 0.64, -1.26, 0.54, 0.2, -0.6, 0.2, 0.8 ] );

isApprox( t, x, xe, 20.0 );
isApprox( t, y, ye, 20.0 );
isApprox( t, x, xe, 21 );
isApprox( t, y, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -400,8 +391,8 @@ tape( 'the function supports complex access patterns', function test( t ) {
xe = new Float64Array( [ 0.78, 0.26, -0.5, 0.8, 0.9, -0.3, -0.4 ] );
ye = new Float64Array( [ 0.04, -0.9, 0.18, 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, 5 );

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 Float64Array = require( '@stdlib/array/float64' );
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 @@ -39,22 +38,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 @@ -110,8 +101,8 @@ tape( 'a module instance has a `main` method which applies a plane rotation (sx=
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 6.0 );
isApprox( t, actualY, ye, 6.0 );
isApprox( t, actualX, xe, 1 );
isApprox( t, actualY, ye, 5 );

t.end();
});
Expand Down Expand Up @@ -147,8 +138,8 @@ tape( 'a module instance has a `main` method which applies a plane rotation (sx=
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 20.0 );
isApprox( t, actualY, ye, 20.0 );
isApprox( t, actualX, xe, 21 );
isApprox( t, actualY, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -184,8 +175,8 @@ tape( 'a module instance has a `main` method which applies a plane rotation (sx=
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 20.0 );
isApprox( t, actualY, ye, 20.0 );
isApprox( t, actualX, xe, 21 );
isApprox( t, actualY, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -221,8 +212,8 @@ tape( 'a module instance has a `main` method which applies a plane rotation (sx=
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 4.0 );
isApprox( t, actualY, ye, 4.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 5 );

t.end();
});
Expand Down Expand Up @@ -270,8 +261,8 @@ tape( 'a module instance has a `main` method which supports an `x` stride', func
actualY = new Float64Array( 5 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 6.0 );
isApprox( t, actualY, ye, 6.0 );
isApprox( t, actualX, xe, 1 );
isApprox( t, actualY, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -319,8 +310,8 @@ tape( 'a module instance has a `main` method which supports a `y` stride', funct
actualY = new Float64Array( 5 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 6.0 );
isApprox( t, actualY, ye, 6.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -441,8 +432,8 @@ tape( 'a module instance has a `main` method which supports negative strides', f
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 20.0 );
isApprox( t, actualY, ye, 20.0 );
isApprox( t, actualX, xe, 21 );
isApprox( t, actualY, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -494,8 +485,8 @@ tape( 'a module instance has a `main` method which supports complex access patte
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 6.0 );
isApprox( t, actualY, ye, 6.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 5 );

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 Float64Array = require( '@stdlib/array/float64' );
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 @@ -39,22 +38,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 @@ -110,8 +101,8 @@ tape( 'a module instance has a `main` method which applies a plane rotation (sx=
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 6.0 );
isApprox( t, actualY, ye, 6.0 );
isApprox( t, actualX, xe, 1 );
isApprox( t, actualY, ye, 5 );

t.end();
});
Expand Down Expand Up @@ -147,8 +138,8 @@ tape( 'a module instance has a `main` method which applies a plane rotation (sx=
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 20.0 );
isApprox( t, actualY, ye, 20.0 );
isApprox( t, actualX, xe, 21 );
isApprox( t, actualY, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -184,8 +175,8 @@ tape( 'a module instance has a `main` method which applies a plane rotation (sx=
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 20.0 );
isApprox( t, actualY, ye, 20.0 );
isApprox( t, actualX, xe, 21 );
isApprox( t, actualY, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -221,8 +212,8 @@ tape( 'a module instance has a `main` method which applies a plane rotation (sx=
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 4.0 );
isApprox( t, actualY, ye, 4.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 5 );

t.end();
});
Expand Down Expand Up @@ -270,8 +261,8 @@ tape( 'a module instance has a `main` method which supports an `x` stride', func
actualY = new Float64Array( 5 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 6.0 );
isApprox( t, actualY, ye, 6.0 );
isApprox( t, actualX, xe, 1 );
isApprox( t, actualY, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -319,8 +310,8 @@ tape( 'a module instance has a `main` method which supports an `x` offset', func
actualY = new Float64Array( 5 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 6.0 );
isApprox( t, actualY, ye, 6.0 );
isApprox( t, actualX, xe, 1 );
isApprox( t, actualY, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -368,8 +359,8 @@ tape( 'a module instance has a `main` method which supports a `y` stride', funct
actualY = new Float64Array( 5 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 6.0 );
isApprox( t, actualY, ye, 6.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 0 );

t.end();
});
Expand Down Expand Up @@ -417,8 +408,8 @@ tape( 'a module instance has a `main` method which supports a `y` offset', funct
actualY = new Float64Array( 5 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 6.0 );
isApprox( t, actualY, ye, 6.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 1 );

t.end();
});
Expand Down Expand Up @@ -539,8 +530,8 @@ tape( 'a module instance has a `main` method which supports negative strides', f
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 20.0 );
isApprox( t, actualY, ye, 20.0 );
isApprox( t, actualX, xe, 21 );
isApprox( t, actualY, ye, 2 );

t.end();
});
Expand Down Expand Up @@ -592,8 +583,8 @@ tape( 'a module instance has a `main` method which supports complex access patte
actualY = new Float64Array( 7 );
mod.read( xp, actualX );
mod.read( yp, actualY );
isApprox( t, actualX, xe, 6.0 );
isApprox( t, actualY, ye, 6.0 );
isApprox( t, actualX, xe, 0 );
isApprox( t, actualY, ye, 5 );

t.end();
});
Loading
Loading