You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
panic!("\nx ={:20.16?}\ne ={:20.16?}\nlimit ={:20.16?}\nvector={:20.16?}\nscalar={:20.16?}\nvector_fn={}", x, e, limit, y, yref, stringify!($vector_fn));
345
+
}
217
346
}
218
347
}};
219
348
}
220
349
221
350
#[test]
222
351
fnsin_f32(){
223
352
use core::f32::consts::PI;
224
-
letulp = (2.0_f32).powi(-23);
353
+
letone_ulp = (2.0_f32).powi(-23);
225
354
226
-
// In the range +/- pi/4 the input has 1 ulp of error.
227
355
test_range!(
228
356
min: -PI/4.0,
229
357
max:PI/4.0,
230
-
limit:ulp*1.0,
358
+
limit:one_ulp*1.0,
231
359
scalar_fn: |x :f32| x.sin(),
232
360
vector_fn: |x : f32x4| x.sin(),
233
361
scalar_type:f32,
234
362
vector_type: f32x4,
235
363
);
236
364
237
-
// In the range +/- pi/2 the input and output has 2 ulp of error.
238
365
test_range!(
239
366
min: -PI/2.0,
240
367
max:PI/2.0,
241
-
limit:ulp*2.0,
368
+
limit:one_ulp*2.0,
242
369
scalar_fn: |x :f32| x.sin(),
243
370
vector_fn: |x : f32x4| x.sin(),
244
371
scalar_type:f32,
245
372
vector_type: f32x4,
246
373
);
247
374
248
-
// In the range +/- pi the input has 2 ulp of error and the output has 5.
249
-
// Note that the scalar sin also has this error but the implementation
250
-
// is different.
251
375
test_range!(
252
376
min: -PI,
253
377
max:PI,
254
-
limit:ulp*5.0,
378
+
limit:one_ulp*8.0,
255
379
scalar_fn: |x :f32| x.sin(),
256
380
vector_fn: |x : f32x4| x.sin(),
257
381
scalar_type:f32,
258
382
vector_type: f32x4,
259
383
);
260
384
}
385
+
386
+
#[test]
387
+
fncos_f32(){
388
+
use core::f32::consts::PI;
389
+
let one_ulp = (2.0_f32).powi(-23);
390
+
391
+
// In the range +/- pi/4 the input has 1 ulp of error.
392
+
test_range!(
393
+
min: -PI/4.0,
394
+
max:PI/4.0,
395
+
limit: one_ulp *1.0,
396
+
scalar_fn: |x :f32| x.cos(),
397
+
vector_fn: |x : f32x4| x.cos(),
398
+
scalar_type:f32,
399
+
vector_type: f32x4,
400
+
);
401
+
402
+
// In the range +/- pi/2 the input and output has 2 ulp of error.
403
+
test_range!(
404
+
min: -PI/2.0,
405
+
max:PI/2.0,
406
+
limit: one_ulp *2.0,
407
+
scalar_fn: |x :f32| x.cos(),
408
+
vector_fn: |x : f32x4| x.cos(),
409
+
scalar_type:f32,
410
+
vector_type: f32x4,
411
+
);
412
+
413
+
// In the range +/- pi the input has 4 ulp of error and the output has 5.
414
+
// Note that the scalar cos also has this error but the implementation
415
+
// is different.
416
+
test_range!(
417
+
min: -PI,
418
+
max:PI,
419
+
limit: one_ulp *8.0,
420
+
scalar_fn: |x :f32| x.cos(),
421
+
vector_fn: |x : f32x4| x.cos(),
422
+
scalar_type:f32,
423
+
vector_type: f32x4,
424
+
);
425
+
}
426
+
427
+
#[test]
428
+
fntan_f32(){
429
+
use core::f32::consts::PI;
430
+
let one_ulp = (2.0_f32).powi(-23);
431
+
432
+
// For the outsides, reciprocal accuracy is important.
433
+
// Note that the vector function correctly gets -inf for -PI/2
434
+
// but the scalar function does not.
435
+
test_range!(
436
+
min: -PI/2.0 + 0.00001,
437
+
max: -PI/4.0,
438
+
limit: one_ulp *3.0,
439
+
scalar_fn: |x :f32| x.tan().recip(),
440
+
vector_fn: |x : f32x4| x.tan().recip(),
441
+
scalar_type:f32,
442
+
vector_type: f32x4,
443
+
);
444
+
445
+
// For the insides, absolute accuracy is important.
0 commit comments