2222
2323var resolve = require ( 'path' ) . resolve ;
2424var tape = require ( 'tape' ) ;
25- var abs = require ( './../../../../base/special/abs' ) ;
2625var PINF = require ( '@stdlib/constants/float32/pinf' ) ;
2726var NINF = require ( '@stdlib/constants/float32/ninf' ) ;
2827var tryRequire = require ( '@stdlib/utils/try-require' ) ;
@@ -31,7 +30,7 @@ var isnanf = require( './../../../../base/assert/is-nanf' );
3130var randu = require ( '@stdlib/random/base/randu' ) ;
3231var isNegativeZerof = require ( './../../../../base/assert/is-negative-zerof' ) ;
3332var isPositiveZerof = require ( './../../../../base/assert/is-positive-zerof' ) ;
34- var isAlmostSameValue = require ( '@stdlib/assert/is-almost-same-value' ) ;
33+ var isAlmostSameValue = require ( '@stdlib/number/float32/base/ assert/is-almost-same-value' ) ;
3534var f32 = require ( '@stdlib/number/float64/base/to-float32' ) ;
3635
3736
@@ -61,8 +60,7 @@ tape( 'main export is a function', opts, function test( t ) {
6160
6261tape ( 'the function computes the hyperbolic arctangent (negative values)' , opts , function test ( t ) {
6362 var expected ;
64- var delta ;
65- var tol ;
63+ var ulps ;
6664 var x ;
6765 var y ;
6866 var i ;
@@ -71,24 +69,18 @@ tape( 'the function computes the hyperbolic arctangent (negative values)', opts,
7169 x = negative . x ;
7270 expected = negative . expected ;
7371
72+ ulps = 4 ;
7473 for ( i = 0 ; i < x . length ; i ++ ) {
7574 y = atanhf ( x [ i ] ) ;
7675 e = f32 ( expected [ i ] ) ;
77- if ( isAlmostSameValue ( y , e , 4 ) ) {
78- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e ) ;
79- } else {
80- delta = abs ( y - e ) ;
81- tol = 1.3 * EPS * abs ( e ) ;
82- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. Δ: ' + delta + '. tol: ' + tol + '.' ) ;
83- }
76+ t . strictEqual ( isAlmostSameValue ( y , e , ulps ) , true , 'within ' + ulps + ' ULPs. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e ) ;
8477 }
8578 t . end ( ) ;
8679} ) ;
8780
8881tape ( 'the function computes the hyperbolic arctangent (positive values)' , opts , function test ( t ) {
8982 var expected ;
90- var delta ;
91- var tol ;
83+ var ulps ;
9284 var x ;
9385 var y ;
9486 var i ;
@@ -97,24 +89,18 @@ tape( 'the function computes the hyperbolic arctangent (positive values)', opts,
9789 x = positive . x ;
9890 expected = positive . expected ;
9991
92+ ulps = 4 ;
10093 for ( i = 0 ; i < x . length ; i ++ ) {
10194 y = atanhf ( x [ i ] ) ;
10295 e = f32 ( expected [ i ] ) ;
103- if ( isAlmostSameValue ( y , e , 4 ) ) {
104- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e ) ;
105- } else {
106- delta = abs ( y - e ) ;
107- tol = 1.3 * EPS * abs ( e ) ;
108- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. Δ: ' + delta + '. tol: ' + tol + '.' ) ;
109- }
96+ t . strictEqual ( isAlmostSameValue ( y , e , ulps ) , true , 'within ' + ulps + ' ULPs. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e ) ;
11097 }
11198 t . end ( ) ;
11299} ) ;
113100
114101tape ( 'the function computes the hyperbolic arctangent (small negative)' , opts , function test ( t ) {
115102 var expected ;
116- var delta ;
117- var tol ;
103+ var ulps ;
118104 var x ;
119105 var y ;
120106 var i ;
@@ -123,24 +109,18 @@ tape( 'the function computes the hyperbolic arctangent (small negative)', opts,
123109 x = smallNegative . x ;
124110 expected = smallNegative . expected ;
125111
112+ ulps = 1 ;
126113 for ( i = 0 ; i < x . length ; i ++ ) {
127114 y = atanhf ( x [ i ] ) ;
128115 e = f32 ( expected [ i ] ) ;
129- if ( isAlmostSameValue ( y , e , 4 ) ) {
130- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e ) ;
131- } else {
132- delta = abs ( y - e ) ;
133- tol = 1.0 * EPS * abs ( e ) ;
134- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. Δ: ' + delta + '. tol: ' + tol + '.' ) ;
135- }
116+ t . strictEqual ( isAlmostSameValue ( y , e , ulps ) , true , 'within ' + ulps + ' ULPs. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e ) ;
136117 }
137118 t . end ( ) ;
138119} ) ;
139120
140121tape ( 'the function computes the hyperbolic arctangent (small positive)' , opts , function test ( t ) {
141122 var expected ;
142- var delta ;
143- var tol ;
123+ var ulps ;
144124 var x ;
145125 var y ;
146126 var i ;
@@ -149,16 +129,11 @@ tape( 'the function computes the hyperbolic arctangent (small positive)', opts,
149129 x = smallPositive . x ;
150130 expected = smallPositive . expected ;
151131
132+ ulps = 1 ;
152133 for ( i = 0 ; i < x . length ; i ++ ) {
153- y = atanhf ( x [ i ] ) ;
134+ y = atanhf ( x [ i ] ) ;
154135 e = f32 ( expected [ i ] ) ;
155- if ( isAlmostSameValue ( y , e , 4 ) ) {
156- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e ) ;
157- } else {
158- delta = abs ( y - e ) ;
159- tol = 1.0 * EPS * abs ( e ) ;
160- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. Δ: ' + delta + '. tol: ' + tol + '.' ) ;
161- }
136+ t . strictEqual ( isAlmostSameValue ( y , e , ulps ) , true , 'within ' + ulps + ' ULPs. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e ) ;
162137 }
163138 t . end ( ) ;
164139} ) ;
@@ -179,7 +154,7 @@ tape( 'the function returns `NaN` if provided a value less than `-1`', opts, fun
179154 var v ;
180155 var i ;
181156
182- for ( i = 0 ; i < 1e3 ; i ++ ) {
157+ for ( i = 0 ; i < 1e2 ; i ++ ) {
183158 v = - ( randu ( ) * 1.0e6 ) - ( 1.0 + EPS ) ;
184159 t . strictEqual ( isnanf ( atanhf ( v ) ) , true , 'returns NaN when provided ' + v ) ;
185160 }
@@ -190,7 +165,7 @@ tape( 'the function returns `NaN` if provided a value greater than `1`', opts, f
190165 var v ;
191166 var i ;
192167
193- for ( i = 0 ; i < 1e3 ; i ++ ) {
168+ for ( i = 0 ; i < 1e2 ; i ++ ) {
194169 v = ( randu ( ) * 1.0e6 ) + 1.0 + EPS ;
195170 t . strictEqual ( isnanf ( atanhf ( v ) ) , true , 'returns NaN when provided ' + v ) ;
196171 }
0 commit comments