@@ -26,8 +26,7 @@ var tape = require( 'tape' );
2626var Memory = require ( '@stdlib/wasm/memory' ) ;
2727var Float32Array = require ( '@stdlib/array/float32' ) ;
2828var Complex64Array = require ( '@stdlib/array/complex64' ) ;
29- var EPS = require ( '@stdlib/constants/float32/eps' ) ;
30- var abs = require ( '@stdlib/math/base/special/abs' ) ;
29+ var isAlmostSameValuef = require ( '@stdlib/number/float32/base/assert/is-almost-same-value' ) ;
3130var Module = require ( './../lib' ) . Module ;
3231
3332
@@ -40,22 +39,14 @@ var Module = require( './../lib' ).Module;
4039* @param {Object } t - test object
4140* @param {Collection } actual - actual values
4241* @param {Collection } expected - expected values
43- * @param {number } rtol - relative tolerance
42+ * @param {NonNegativeInteger } ulp - maximum allowed ULP difference
4443*/
45- function isApprox ( t , actual , expected , rtol ) {
46- var delta ;
47- var tol ;
44+ function isApprox ( t , actual , expected , ulp ) {
4845 var i ;
4946
5047 t . strictEqual ( actual . length , expected . length , 'returns expected value' ) ;
5148 for ( i = 0 ; i < expected . length ; i ++ ) {
52- if ( actual [ i ] === expected [ i ] ) {
53- t . strictEqual ( actual [ i ] , expected [ i ] , 'returns expected value' ) ;
54- } else {
55- delta = abs ( actual [ i ] - expected [ i ] ) ;
56- tol = rtol * EPS * abs ( expected [ i ] ) ;
57- t . ok ( delta <= tol , 'within tolerance. actual: ' + actual [ i ] + '. expected: ' + expected [ i ] + '. delta: ' + delta + '. tol: ' + tol + '.' ) ;
58- }
49+ t . strictEqual ( isAlmostSameValuef ( actual [ i ] , expected [ i ] , ulp ) , true , 'returns expected value' ) ;
5950 }
6051}
6152
@@ -112,12 +103,12 @@ tape( 'a module instance has an `ndarray` method which applies a plane rotation'
112103 actualX = new Complex64Array ( 4 ) ;
113104 mod . read ( cxp , actualX ) ;
114105 viewX = new Float32Array ( actualX . buffer ) ;
115- isApprox ( t , viewX , cxe , 2. 0 ) ;
106+ isApprox ( t , viewX , cxe , 0 ) ;
116107
117108 actualY = new Complex64Array ( 4 ) ;
118109 mod . read ( cyp , actualY ) ;
119110 viewY = new Float32Array ( actualY . buffer ) ;
120- isApprox ( t , viewY , cye , 2.0 ) ;
111+ isApprox ( t , viewY , cye , 1 ) ;
121112
122113 t . end ( ) ;
123114} ) ;
@@ -199,12 +190,12 @@ tape( 'a module instance has an `ndarray` method which supports an `x` stride',
199190 actualX = new Complex64Array ( 4 ) ;
200191 mod . read ( cxp , actualX ) ;
201192 viewX = new Float32Array ( actualX . buffer ) ;
202- isApprox ( t , viewX , cxe , 2. 0 ) ;
193+ isApprox ( t , viewX , cxe , 0 ) ;
203194
204195 actualY = new Complex64Array ( 4 ) ;
205196 mod . read ( cyp , actualY ) ;
206197 viewY = new Float32Array ( actualY . buffer ) ;
207- isApprox ( t , viewY , cye , 2.0 ) ;
198+ isApprox ( t , viewY , cye , 1 ) ;
208199
209200 t . end ( ) ;
210201} ) ;
@@ -286,12 +277,12 @@ tape( 'a module instance has an `ndarray` method which supports an `x` offset',
286277 actualX = new Complex64Array ( 4 ) ;
287278 mod . read ( cxp , actualX ) ;
288279 viewX = new Float32Array ( actualX . buffer ) ;
289- isApprox ( t , viewX , cxe , 2. 0 ) ;
280+ isApprox ( t , viewX , cxe , 0 ) ;
290281
291282 actualY = new Complex64Array ( 4 ) ;
292283 mod . read ( cyp , actualY ) ;
293284 viewY = new Float32Array ( actualY . buffer ) ;
294- isApprox ( t , viewY , cye , 2.0 ) ;
285+ isApprox ( t , viewY , cye , 1 ) ;
295286
296287 t . end ( ) ;
297288} ) ;
@@ -373,12 +364,12 @@ tape( 'a module instance has an `ndarray` method which supports a `y` stride', f
373364 actualX = new Complex64Array ( 4 ) ;
374365 mod . read ( cxp , actualX ) ;
375366 viewX = new Float32Array ( actualX . buffer ) ;
376- isApprox ( t , viewX , cxe , 2. 0 ) ;
367+ isApprox ( t , viewX , cxe , 0 ) ;
377368
378369 actualY = new Complex64Array ( 4 ) ;
379370 mod . read ( cyp , actualY ) ;
380371 viewY = new Float32Array ( actualY . buffer ) ;
381- isApprox ( t , viewY , cye , 2.0 ) ;
372+ isApprox ( t , viewY , cye , 1 ) ;
382373
383374 t . end ( ) ;
384375} ) ;
@@ -460,12 +451,12 @@ tape( 'a module instance has an `ndarray` method which supports a `y` offset', f
460451 actualX = new Complex64Array ( 4 ) ;
461452 mod . read ( cxp , actualX ) ;
462453 viewX = new Float32Array ( actualX . buffer ) ;
463- isApprox ( t , viewX , cxe , 2. 0 ) ;
454+ isApprox ( t , viewX , cxe , 0 ) ;
464455
465456 actualY = new Complex64Array ( 4 ) ;
466457 mod . read ( cyp , actualY ) ;
467458 viewY = new Float32Array ( actualY . buffer ) ;
468- isApprox ( t , viewY , cye , 2.0 ) ;
459+ isApprox ( t , viewY , cye , 1 ) ;
469460
470461 t . end ( ) ;
471462} ) ;
@@ -622,12 +613,12 @@ tape( 'a module instance has an `ndarray` method which supports negative strides
622613 actualX = new Complex64Array ( 4 ) ;
623614 mod . read ( cxp , actualX ) ;
624615 viewX = new Float32Array ( actualX . buffer ) ;
625- isApprox ( t , viewX , cxe , 2. 0 ) ;
616+ isApprox ( t , viewX , cxe , 0 ) ;
626617
627618 actualY = new Complex64Array ( 4 ) ;
628619 mod . read ( cyp , actualY ) ;
629620 viewY = new Float32Array ( actualY . buffer ) ;
630- isApprox ( t , viewY , cye , 2.0 ) ;
621+ isApprox ( t , viewY , cye , 1 ) ;
631622
632623 t . end ( ) ;
633624} ) ;
@@ -709,12 +700,12 @@ tape( 'a module instance has an `ndarray` method which supports complex access p
709700 actualX = new Complex64Array ( 4 ) ;
710701 mod . read ( cxp , actualX ) ;
711702 viewX = new Float32Array ( actualX . buffer ) ;
712- isApprox ( t , viewX , cxe , 2. 0 ) ;
703+ isApprox ( t , viewX , cxe , 0 ) ;
713704
714705 actualY = new Complex64Array ( 4 ) ;
715706 mod . read ( cyp , actualY ) ;
716707 viewY = new Float32Array ( actualY . buffer ) ;
717- isApprox ( t , viewY , cye , 2.0 ) ;
708+ isApprox ( t , viewY , cye , 1 ) ;
718709
719710 t . end ( ) ;
720711} ) ;
0 commit comments