2323var tape = require ( 'tape' ) ;
2424var isnanf = require ( '@stdlib/math/base/assert/is-nanf' ) ;
2525var randu = require ( '@stdlib/random/base/randu' ) ;
26- var EPS = require ( '@stdlib/constants/float32/eps' ) ;
27- var abs = require ( '@stdlib/math/base/special/abs' ) ;
2826var f32 = require ( '@stdlib/number/float64/base/to-float32' ) ;
2927var isAlmostSameValue = require ( '@stdlib/number/float32/base/assert/is-almost-same-value' ) ;
3028var acothf = require ( './../lib' ) ;
@@ -52,8 +50,6 @@ tape( 'main export is a function', function test( t ) {
5250
5351tape ( 'the function computes the inverse hyperbolic cotangent for medium positive values' , function test ( t ) {
5452 var expected ;
55- var delta ;
56- var tol ;
5753 var x ;
5854 var y ;
5955 var i ;
@@ -65,21 +61,13 @@ tape( 'the function computes the inverse hyperbolic cotangent for medium positiv
6561 for ( i = 0 ; i < x . length ; i ++ ) {
6662 y = acothf ( x [ i ] ) ;
6763 e = f32 ( expected [ i ] ) ;
68- if ( isAlmostSameValue ( y , e , 0 ) ) {
69- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e + '.' ) ;
70- } else {
71- delta = abs ( y - e ) ;
72- tol = 2.3 * EPS * abs ( e ) ;
73- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
74- }
64+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
7565 }
7666 t . end ( ) ;
7767} ) ;
7868
7969tape ( 'the function computes the inverse hyperbolic cotangent for medium negative values' , function test ( t ) {
8070 var expected ;
81- var delta ;
82- var tol ;
8371 var x ;
8472 var y ;
8573 var i ;
@@ -91,21 +79,13 @@ tape( 'the function computes the inverse hyperbolic cotangent for medium negativ
9179 for ( i = 0 ; i < x . length ; i ++ ) {
9280 y = acothf ( x [ i ] ) ;
9381 e = f32 ( expected [ i ] ) ;
94- if ( isAlmostSameValue ( y , e , 0 ) ) {
95- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e + '.' ) ;
96- } else {
97- delta = abs ( y - e ) ;
98- tol = 2.3 * EPS * abs ( e ) ;
99- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
100- }
82+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
10183 }
10284 t . end ( ) ;
10385} ) ;
10486
10587tape ( 'the function computes the inverse hyperbolic cotangent for large positive values' , function test ( t ) {
10688 var expected ;
107- var delta ;
108- var tol ;
10989 var x ;
11090 var y ;
11191 var i ;
@@ -117,21 +97,13 @@ tape( 'the function computes the inverse hyperbolic cotangent for large positive
11797 for ( i = 0 ; i < x . length ; i ++ ) {
11898 y = acothf ( x [ i ] ) ;
11999 e = f32 ( expected [ i ] ) ;
120- if ( isAlmostSameValue ( y , e , 0 ) ) {
121- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e + '.' ) ;
122- } else {
123- delta = abs ( y - e ) ;
124- tol = 2.3 * EPS * abs ( e ) ;
125- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
126- }
100+ t . strictEqual ( isAlmostSameValue ( y , e , 2 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
127101 }
128102 t . end ( ) ;
129103} ) ;
130104
131105tape ( 'the function computes the inverse hyperbolic cotangent for large negative values' , function test ( t ) {
132106 var expected ;
133- var delta ;
134- var tol ;
135107 var x ;
136108 var y ;
137109 var i ;
@@ -143,21 +115,13 @@ tape( 'the function computes the inverse hyperbolic cotangent for large negative
143115 for ( i = 0 ; i < x . length ; i ++ ) {
144116 y = acothf ( x [ i ] ) ;
145117 e = f32 ( expected [ i ] ) ;
146- if ( isAlmostSameValue ( y , e , 0 ) ) {
147- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e + '.' ) ;
148- } else {
149- delta = abs ( y - e ) ;
150- tol = 2.3 * EPS * abs ( e ) ;
151- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
152- }
118+ t . strictEqual ( isAlmostSameValue ( y , e , 2 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
153119 }
154120 t . end ( ) ;
155121} ) ;
156122
157123tape ( 'the function computes the inverse hyperbolic cotangent for larger positive values' , function test ( t ) {
158124 var expected ;
159- var delta ;
160- var tol ;
161125 var x ;
162126 var y ;
163127 var i ;
@@ -169,21 +133,13 @@ tape( 'the function computes the inverse hyperbolic cotangent for larger positiv
169133 for ( i = 0 ; i < x . length ; i ++ ) {
170134 y = acothf ( x [ i ] ) ;
171135 e = f32 ( expected [ i ] ) ;
172- if ( isAlmostSameValue ( y , e , 0 ) ) {
173- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e + '.' ) ;
174- } else {
175- delta = abs ( y - e ) ;
176- tol = 2.3 * EPS * abs ( e ) ;
177- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
178- }
136+ t . strictEqual ( isAlmostSameValue ( y , e , 2 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
179137 }
180138 t . end ( ) ;
181139} ) ;
182140
183141tape ( 'the function computes the inverse hyperbolic cotangent for larger negative values' , function test ( t ) {
184142 var expected ;
185- var delta ;
186- var tol ;
187143 var x ;
188144 var y ;
189145 var i ;
@@ -195,21 +151,13 @@ tape( 'the function computes the inverse hyperbolic cotangent for larger negativ
195151 for ( i = 0 ; i < x . length ; i ++ ) {
196152 y = acothf ( x [ i ] ) ;
197153 e = f32 ( expected [ i ] ) ;
198- if ( isAlmostSameValue ( y , e , 0 ) ) {
199- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e + '.' ) ;
200- } else {
201- delta = abs ( y - e ) ;
202- tol = 2.3 * EPS * abs ( e ) ;
203- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
204- }
154+ t . strictEqual ( isAlmostSameValue ( y , e , 2 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
205155 }
206156 t . end ( ) ;
207157} ) ;
208158
209159tape ( 'the function computes the inverse hyperbolic cotangent for huge positive values' , function test ( t ) {
210160 var expected ;
211- var delta ;
212- var tol ;
213161 var x ;
214162 var y ;
215163 var i ;
@@ -221,21 +169,13 @@ tape( 'the function computes the inverse hyperbolic cotangent for huge positive
221169 for ( i = 0 ; i < x . length ; i ++ ) {
222170 y = acothf ( x [ i ] ) ;
223171 e = f32 ( expected [ i ] ) ;
224- if ( isAlmostSameValue ( y , e , 0 ) ) {
225- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e + '.' ) ;
226- } else {
227- delta = abs ( y - e ) ;
228- tol = 1.0 * EPS * abs ( e ) ;
229- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
230- }
172+ t . strictEqual ( isAlmostSameValue ( y , e , 2 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
231173 }
232174 t . end ( ) ;
233175} ) ;
234176
235177tape ( 'the function computes the inverse hyperbolic cotangent for huge negative values' , function test ( t ) {
236178 var expected ;
237- var delta ;
238- var tol ;
239179 var x ;
240180 var y ;
241181 var i ;
@@ -247,13 +187,7 @@ tape( 'the function computes the inverse hyperbolic cotangent for huge negative
247187 for ( i = 0 ; i < x . length ; i ++ ) {
248188 y = acothf ( x [ i ] ) ;
249189 e = f32 ( expected [ i ] ) ;
250- if ( isAlmostSameValue ( y , e , 0 ) ) {
251- t . strictEqual ( y , e , 'x: ' + x [ i ] + '. E: ' + e + '.' ) ;
252- } else {
253- delta = abs ( y - e ) ;
254- tol = 1.0 * EPS * abs ( e ) ;
255- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
256- }
190+ t . strictEqual ( isAlmostSameValue ( y , e , 2 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
257191 }
258192 t . end ( ) ;
259193} ) ;
@@ -268,7 +202,7 @@ tape( 'the function returns `NaN` if provided a value on the open interval (-1,1
268202 var v ;
269203 var i ;
270204
271- for ( i = 0 ; i < 1e3 ; i ++ ) {
205+ for ( i = 0 ; i < 1e2 ; i ++ ) {
272206 v = ( randu ( ) * 2.0 ) - 1.0 ;
273207 t . strictEqual ( isnanf ( acothf ( v ) ) , true , 'returns expected value when provided ' + v ) ;
274208 }
0 commit comments