2222
2323var tape = require ( 'tape' ) ;
2424var isnanf = require ( '@stdlib/math/base/assert/is-nanf' ) ;
25- var PINF = require ( '@stdlib/constants/float32/pinf' ) ;
26- var NINF = require ( '@stdlib/constants/float32/ninf' ) ;
27- var float64ToFloat32 = require ( '@stdlib/number/float64/base/to-float32' ) ;
2825var isNegativeZerof = require ( '@stdlib/math/base/assert/is-negative-zerof' ) ;
2926var isPositiveZerof = require ( '@stdlib/math/base/assert/is-positive-zerof' ) ;
27+ var float64ToFloat32 = require ( '@stdlib/number/float64/base/to-float32' ) ;
3028var isAlmostSameValue = require ( '@stdlib/number/float32/base/assert/is-almost-same-value' ) ;
3129var acschf = require ( './../lib' ) ;
3230
@@ -56,213 +54,236 @@ tape( 'main export is a function', function test( t ) {
5654 t . end ( ) ;
5755} ) ;
5856
59- tape ( 'the function handles signed zero' , function test ( t ) {
60- t . strictEqual ( acschf ( 0.0 ) , PINF , 'positive zero returns +infinity' ) ;
61- t . strictEqual ( acschf ( - 0.0 ) , NINF , 'negative zero returns -infinity' ) ;
57+ tape ( 'the function computes the hyperbolic arccosecant on the interval `[-1e-30,-1e-38]`' , function test ( t ) {
58+ var expected ;
59+ var x ;
60+ var y ;
61+ var i ;
62+ var e ;
63+
64+ x = tinyNegative . x ;
65+ expected = tinyNegative . expected ;
66+
67+ for ( i = 0 ; i < x . length ; i ++ ) {
68+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
69+ e = float64ToFloat32 ( expected [ i ] ) ;
70+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
71+ }
6272 t . end ( ) ;
6373} ) ;
6474
65- tape ( 'the function computes the hyperbolic arccosecant on the interval [-0.8,0.8] ' , function test ( t ) {
75+ tape ( 'the function computes the hyperbolic arccosecant on the interval `[1e-30,1e-38]` ' , function test ( t ) {
6676 var expected ;
6777 var x ;
6878 var y ;
79+ var i ;
6980 var e ;
81+
82+ x = tinyPositive . x ;
83+ expected = tinyPositive . expected ;
84+
85+ for ( i = 0 ; i < x . length ; i ++ ) {
86+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
87+ e = float64ToFloat32 ( expected [ i ] ) ;
88+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
89+ }
90+ t . end ( ) ;
91+ } ) ;
92+
93+ tape ( 'the function computes the hyperbolic arccosecant on the interval `[-0.8,0.8]`' , function test ( t ) {
94+ var expected ;
95+ var x ;
96+ var y ;
7097 var i ;
98+ var e ;
7199
72100 x = smaller . x ;
73101 expected = smaller . expected ;
74102
75103 for ( i = 0 ; i < x . length ; i ++ ) {
76- y = acschf ( x [ i ] ) ;
77-
78- if ( expected [ i ] === null ) {
79- t . strictEqual ( y , PINF , 'x: ' + x [ i ] + '. E: +infinity' ) ;
80- } else {
81- e = float64ToFloat32 ( expected [ i ] ) ;
82- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
83- }
104+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
105+ e = float64ToFloat32 ( expected [ i ] ) ;
106+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
84107 }
85108 t . end ( ) ;
86109} ) ;
87110
88- tape ( 'the function computes the hyperbolic arccosecant on the interval [-1.0,-0.8]' , function test ( t ) {
111+ tape ( 'the function computes the hyperbolic arccosecant on the interval ` [-1.0,-0.8]` ' , function test ( t ) {
89112 var expected ;
90113 var x ;
91114 var y ;
92- var e ;
93115 var i ;
116+ var e ;
94117
95118 x = smallNegative . x ;
96119 expected = smallNegative . expected ;
97120
98121 for ( i = 0 ; i < x . length ; i ++ ) {
99- y = acschf ( x [ i ] ) ;
122+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
100123 e = float64ToFloat32 ( expected [ i ] ) ;
101- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
124+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
102125 }
103126 t . end ( ) ;
104127} ) ;
105128
106- tape ( 'the function computes the hyperbolic arccosecant on the interval [0.8,1.0]' , function test ( t ) {
129+ tape ( 'the function computes the hyperbolic arccosecant on the interval ` [0.8,1.0]` ' , function test ( t ) {
107130 var expected ;
108131 var x ;
109132 var y ;
110- var e ;
111133 var i ;
134+ var e ;
112135
113136 x = smallPositive . x ;
114137 expected = smallPositive . expected ;
115138
116139 for ( i = 0 ; i < x . length ; i ++ ) {
117- y = acschf ( x [ i ] ) ;
140+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
118141 e = float64ToFloat32 ( expected [ i ] ) ;
119- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
142+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
120143 }
121144 t . end ( ) ;
122145} ) ;
123146
124- tape ( 'the function computes the hyperbolic arccosecant on the interval [-3.0,-1.0]' , function test ( t ) {
147+ tape ( 'the function computes the hyperbolic arccosecant on the interval ` [-3.0,-1.0]` ' , function test ( t ) {
125148 var expected ;
126149 var x ;
127150 var y ;
128- var e ;
129151 var i ;
152+ var e ;
130153
131154 x = mediumNegative . x ;
132155 expected = mediumNegative . expected ;
133156
134157 for ( i = 0 ; i < x . length ; i ++ ) {
135- y = acschf ( x [ i ] ) ;
158+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
136159 e = float64ToFloat32 ( expected [ i ] ) ;
137- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
160+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
138161 }
139162 t . end ( ) ;
140163} ) ;
141164
142- tape ( 'the function computes the hyperbolic arccosecant on the interval [1.0,3.0]' , function test ( t ) {
165+ tape ( 'the function computes the hyperbolic arccosecant on the interval ` [1.0,3.0]` ' , function test ( t ) {
143166 var expected ;
144167 var x ;
145168 var y ;
146- var e ;
147169 var i ;
170+ var e ;
148171
149172 x = mediumPositive . x ;
150173 expected = mediumPositive . expected ;
151174
152175 for ( i = 0 ; i < x . length ; i ++ ) {
153- y = acschf ( x [ i ] ) ;
176+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
154177 e = float64ToFloat32 ( expected [ i ] ) ;
155- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
178+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
156179 }
157180 t . end ( ) ;
158181} ) ;
159182
160- tape ( 'the function computes the hyperbolic arccosecant on the interval [3.0,28.0]' , function test ( t ) {
183+ tape ( 'the function computes the hyperbolic arccosecant on the interval ` [3.0,28.0]` ' , function test ( t ) {
161184 var expected ;
162185 var x ;
163186 var y ;
164- var e ;
165187 var i ;
188+ var e ;
166189
167190 x = largePositive . x ;
168191 expected = largePositive . expected ;
169192
170193 for ( i = 0 ; i < x . length ; i ++ ) {
171- y = acschf ( x [ i ] ) ;
194+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
172195 e = float64ToFloat32 ( expected [ i ] ) ;
173- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
196+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
174197 }
175198 t . end ( ) ;
176199} ) ;
177200
178- tape ( 'the function computes the hyperbolic arccosecant on the interval [-28.0,-3.0]' , function test ( t ) {
201+ tape ( 'the function computes the hyperbolic arccosecant on the interval ` [-28.0,-3.0]` ' , function test ( t ) {
179202 var expected ;
180203 var x ;
181204 var y ;
182- var e ;
183205 var i ;
206+ var e ;
184207
185208 x = largeNegative . x ;
186209 expected = largeNegative . expected ;
187210
188211 for ( i = 0 ; i < x . length ; i ++ ) {
189- y = acschf ( x [ i ] ) ;
212+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
190213 e = float64ToFloat32 ( expected [ i ] ) ;
191-
192- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
214+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
193215 }
194216 t . end ( ) ;
195217} ) ;
196218
197- tape ( 'the function computes the hyperbolic arccosecant on the interval [28.0,100.0]' , function test ( t ) {
219+ tape ( 'the function computes the hyperbolic arccosecant on the interval ` [28.0,100.0]` ' , function test ( t ) {
198220 var expected ;
199221 var x ;
200222 var y ;
201- var e ;
202223 var i ;
224+ var e ;
203225
204226 x = largerPositive . x ;
205227 expected = largerPositive . expected ;
206228
207229 for ( i = 0 ; i < x . length ; i ++ ) {
208- y = acschf ( x [ i ] ) ;
230+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
209231 e = float64ToFloat32 ( expected [ i ] ) ;
210- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
232+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
211233 }
212234 t . end ( ) ;
213235} ) ;
214236
215- tape ( 'the function computes the hyperbolic arccosecant on the interval [-100.0,-28.0]' , function test ( t ) {
237+ tape ( 'the function computes the hyperbolic arccosecant on the interval ` [-100.0,-28.0]` ' , function test ( t ) {
216238 var expected ;
217239 var x ;
218240 var y ;
219- var e ;
220241 var i ;
242+ var e ;
221243
222244 x = largerNegative . x ;
223245 expected = largerNegative . expected ;
224246
225247 for ( i = 0 ; i < x . length ; i ++ ) {
226- y = acschf ( x [ i ] ) ;
248+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
227249 e = float64ToFloat32 ( expected [ i ] ) ;
228- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
250+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
229251 }
230252 t . end ( ) ;
231253} ) ;
232254
233- tape ( 'the function computes the hyperbolic arccosecant on the interval [-1e30,-1e38]' , function test ( t ) {
255+ tape ( 'the function computes the hyperbolic arccosecant on the interval ` [-1e30,-1e38]` ' , function test ( t ) {
234256 var expected ;
235257 var x ;
236258 var y ;
237- var e ;
238259 var i ;
260+ var e ;
239261
240262 x = hugeNegative . x ;
241263 expected = hugeNegative . expected ;
242264
243265 for ( i = 0 ; i < x . length ; i ++ ) {
244- y = acschf ( x [ i ] ) ;
266+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
245267 e = float64ToFloat32 ( expected [ i ] ) ;
246- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
268+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
247269 }
248270 t . end ( ) ;
249271} ) ;
250272
251- tape ( 'the function computes the hyperbolic arccosecant on the interval [1e30,1e38]' , function test ( t ) {
273+ tape ( 'the function computes the hyperbolic arccosecant on the interval ` [1e30,1e38]` ' , function test ( t ) {
252274 var expected ;
253275 var x ;
254276 var y ;
255- var e ;
256277 var i ;
278+ var e ;
257279
258280 x = hugePositive . x ;
259281 expected = hugePositive . expected ;
260282
261283 for ( i = 0 ; i < x . length ; i ++ ) {
262- y = acschf ( x [ i ] ) ;
284+ y = acschf ( float64ToFloat32 ( x [ i ] ) ) ;
263285 e = float64ToFloat32 ( expected [ i ] ) ;
264-
265- t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
286+ t . strictEqual ( isAlmostSameValue ( y , e , 3 ) , true , 'x: ' + x [ i ] + '. y: ' + y + '. E: ' + e + '.' ) ;
266287 }
267288 t . end ( ) ;
268289} ) ;
@@ -273,40 +294,26 @@ tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
273294 t . end ( ) ;
274295} ) ;
275296
276- tape ( 'the function returns -0 if provided -infinity ' , function test ( t ) {
277- var v = acschf ( NINF ) ;
278- t . strictEqual ( isNegativeZerof ( v ) , true , 'returns expected value' ) ;
297+ tape ( 'the function returns `+infinity` if provided `+0` ' , function test ( t ) {
298+ var v = acschf ( + 0.0 ) ;
299+ t . strictEqual ( v , float64ToFloat32 ( Infinity ) , 'returns expected value' ) ;
279300 t . end ( ) ;
280301} ) ;
281302
282- tape ( 'the function returns +0 if provided +infinity ' , function test ( t ) {
283- var v = acschf ( PINF ) ;
284- t . strictEqual ( isPositiveZerof ( v ) , true , 'returns expected value' ) ;
303+ tape ( 'the function returns `-infinity` if provided `-0` ' , function test ( t ) {
304+ var v = acschf ( - 0.0 ) ;
305+ t . strictEqual ( v , float64ToFloat32 ( - Infinity ) , 'returns expected value' ) ;
285306 t . end ( ) ;
286307} ) ;
287308
288- tape ( 'the function evaluates the inverse hyperbolic arccosecant for tiny negative values' , function test ( t ) {
289- var x ;
290- var i ;
291- var v ;
292-
293- x = tinyNegative . x ;
294- for ( i = 0 ; i < x . length ; i ++ ) {
295- v = acschf ( x [ i ] ) ;
296- t . strictEqual ( isnanf ( v ) , false , 'does not return NaN' ) ;
297- }
309+ tape ( 'the function returns `-0` if provided `-infinity`' , function test ( t ) {
310+ var v = acschf ( float64ToFloat32 ( - Infinity ) ) ;
311+ t . strictEqual ( isNegativeZerof ( v ) , true , 'returns expected value' ) ;
298312 t . end ( ) ;
299313} ) ;
300314
301- tape ( 'the function evaluates the inverse hyperbolic arccosecant for tiny positive values' , function test ( t ) {
302- var x ;
303- var i ;
304- var v ;
305-
306- x = tinyPositive . x ;
307- for ( i = 0 ; i < x . length ; i ++ ) {
308- v = acschf ( x [ i ] ) ;
309- t . strictEqual ( isnanf ( v ) , false , 'does not return NaN' ) ;
310- }
315+ tape ( 'the function returns `+0` if provided `+infinity`' , function test ( t ) {
316+ var v = acschf ( float64ToFloat32 ( Infinity ) ) ;
317+ t . strictEqual ( isPositiveZerof ( v ) , true , 'returns expected value' ) ;
311318 t . end ( ) ;
312319} ) ;
0 commit comments