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
25 changes: 8 additions & 17 deletions lib/node_modules/@stdlib/blas/base/wasm/cscal/test/test.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ var tape = require( 'tape' );
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
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 cscal = require( './../lib' );


Expand All @@ -38,22 +37,14 @@ var cscal = 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 @@ -102,7 +93,7 @@ tape( 'the `main` method scales elements from `cx` by `ca`', function test( t )
0.14, // 4
0.08 // 4
]);
isApprox( t, viewX, expected, 1.0 );
isApprox( t, viewX, expected, 1 );

t.end();
});
Expand Down Expand Up @@ -146,7 +137,7 @@ tape( 'the `main` method supports specifying a `cx` stride', function test( t )
7.0,
2.0
]);
isApprox( t, viewX, expected, 1.0 );
isApprox( t, viewX, expected, 1 );

t.end();
});
Expand Down Expand Up @@ -190,7 +181,7 @@ tape( 'the `main` method supports specifying a negative `cx` stride', function t
7.0,
2.0
]);
isApprox( t, viewX, expected, 1.0 );
isApprox( t, viewX, expected, 1 );

t.end();
});
Expand Down Expand Up @@ -270,7 +261,7 @@ tape( 'the `main` method supports view offsets', function test( t ) {
2.0,
3.0
]);
isApprox( t, viewX, expected, 1.0 );
isApprox( t, viewX, expected, 2 );

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 Complex64Array = require( '@stdlib/array/complex64' );
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 @@ -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( isAlmostSameValuef( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand Down Expand Up @@ -108,7 +99,7 @@ tape( 'a module instance has a `main` method which scales elements from `cx` by
actualX = new Complex64Array( 3 );
mod.read( cxp, actualX );
viewX = new Float32Array( actualX.buffer );
isApprox( t, viewX, cxe, 1.0 );
isApprox( t, viewX, cxe, 0 );

t.end();
});
Expand Down Expand Up @@ -172,7 +163,7 @@ tape( 'a module instance has a `main` method which supports specifying a `cx` st
actualX = new Complex64Array( 6 );
mod.read( cxp, actualX );
viewX = new Float32Array( actualX.buffer );
isApprox( t, viewX, cxe, 1.0 );
isApprox( t, viewX, cxe, 1 );

t.end();
});
Expand Down Expand Up @@ -236,7 +227,7 @@ tape( 'a module instance has a `main` method which supports specifying a negativ
actualX = new Complex64Array( 6 );
mod.read( cxp, actualX );
viewX = new Float32Array( actualX.buffer );
isApprox( t, viewX, cxe, 1.0 );
isApprox( t, viewX, cxe, 1 );

t.end();
});
Expand Down
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 Complex64Array = require( '@stdlib/array/complex64' );
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 @@ -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( isAlmostSameValuef( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand Down Expand Up @@ -108,7 +99,7 @@ tape( 'a module instance has an `ndarray` method which scales elements from `cx`
actualX = new Complex64Array( 3 );
mod.read( cxp, actualX );
viewX = new Float32Array( actualX.buffer );
isApprox( t, viewX, cxe, 1.0 );
isApprox( t, viewX, cxe, 0 );

t.end();
});
Expand Down Expand Up @@ -172,7 +163,7 @@ tape( 'a module instance has an `ndarray` method which supports a `cx` stride',
actualX = new Complex64Array( 6 );
mod.read( cxp, actualX );
viewX = new Float32Array( actualX.buffer );
isApprox( t, viewX, cxe, 1.0 );
isApprox( t, viewX, cxe, 1 );

t.end();
});
Expand Down Expand Up @@ -236,7 +227,7 @@ tape( 'a module instance has an `ndarray` method which supports a negative `cx`
actualX = new Complex64Array( 6 );
mod.read( cxp, actualX );
viewX = new Float32Array( actualX.buffer );
isApprox( t, viewX, cxe, 1.0 );
isApprox( t, viewX, cxe, 1 );

t.end();
});
Expand Down Expand Up @@ -300,7 +291,7 @@ tape( 'a module instance has an `ndarray` method which supports a `cx` offset',
actualX = new Complex64Array( 6 );
mod.read( cxp, actualX );
viewX = new Float32Array( actualX.buffer );
isApprox( t, viewX, cxe, 1.0 );
isApprox( t, viewX, cxe, 1 );

t.end();
});
Expand Down Expand Up @@ -417,7 +408,7 @@ tape( 'a module instance has an `ndarray` method which supports complex access p
actualX = new Complex64Array( 6 );
mod.read( cxp, actualX );
viewX = new Float32Array( actualX.buffer );
isApprox( t, viewX, cxe, 1.0 );
isApprox( t, viewX, cxe, 1 );

t.end();
});
27 changes: 9 additions & 18 deletions lib/node_modules/@stdlib/blas/base/wasm/cscal/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ var tape = require( 'tape' );
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
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 cscal = require( './../lib' );


Expand All @@ -38,22 +37,14 @@ var cscal = 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 @@ -110,7 +101,7 @@ tape( 'the `ndarray` method scales elements from `cx` by `ca`', function test( t
2.0,
3.0
]);
isApprox( t, viewX, expected, 1.0 );
isApprox( t, viewX, expected, 1 );

t.end();
});
Expand Down Expand Up @@ -154,7 +145,7 @@ tape( 'the `ndarray` method supports specifying a `cx` stride', function test( t
7.0,
2.0
]);
isApprox( t, viewX, expected, 1.0 );
isApprox( t, viewX, expected, 1 );

t.end();
});
Expand Down Expand Up @@ -198,7 +189,7 @@ tape( 'the `ndarray` method supports specifying a negative `cx` stride', functio
7.0,
2.0
]);
isApprox( t, viewX, expected, 1.0 );
isApprox( t, viewX, expected, 1 );

t.end();
});
Expand Down Expand Up @@ -242,7 +233,7 @@ tape( 'the `ndarray` method supports a `cx` offset', function test( t ) {
4.2, // 3
-4.1 // 3
]);
isApprox( t, viewX, expected, 5.0 );
isApprox( t, viewX, expected, 5 );

t.end();
});
Expand Down Expand Up @@ -325,7 +316,7 @@ tape( 'the `ndarray` method supports complex access patterns', function test( t
2.9, // 2
-0.2 // 2
]);
isApprox( t, viewX, expected, 5.0 );
isApprox( t, viewX, expected, 5 );

t.end();
});
Loading
Loading