2 #include <UnitTest++.h>
15 for(
int i=0; i < 2048; ++i )
18 char *p =
static_cast<char*
>(pool.
avx_alloc(sz));
19 size_t ip =
reinterpret_cast<size_t>(p);
22 for(
size_t j=0; j < sz; ++j )
27 const int ntest = 200;
29 for(
int i=0; i < ntest; ++i )
31 pp[i] =
static_cast<char*
>(pool.
avx_alloc(4000));
32 size_t ip =
reinterpret_cast<size_t>(pp[i]);
34 for(
size_t j=0; j < 4000; ++j )
37 for(
int i=0; i < ntest; ++i )
44 CHECK( p1.data() != NULL && p1.data() == p1.ptr0() );
45 for(
int i=0; i < 100; ++i )
47 CHECK_THROW(( p1[-1] = 1. ),out_of_range);
48 CHECK_THROW(( p1[100] = 1. ),out_of_range);
50 CHECK( p2.data() == NULL );
52 CHECK( p3.data() == NULL );
54 CHECK( p4.data() != NULL && p4.data() == p4.ptr0()-10 );
55 for(
int i=-10; i < 100; ++i )
57 CHECK_THROW(( p4[-11] = 1. ),out_of_range);
58 CHECK_THROW(( p1[100] = 1. ),out_of_range);
60 CHECK( p5.data() == NULL );
62 CHECK( p6.data() == NULL );
65 TEST(TestAllocatorAvx)
70 for(
int i=0; i < 2048; ++i )
73 vector< int, allocator_avx<int> > a(sz);
74 size_t ip =
reinterpret_cast<size_t>(
get_ptr(a));
76 for(
size_t j=0; j < sz; ++j )
84 for(
int i=0; i < 32; ++i )
86 for(
int ilo=0; ilo < 32; ilo++ )
88 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
90 double val =
reduce_a( a, ilo, ihi );
91 double expect = double(ihi*(ihi-1)/2 - ilo*(ilo-1)/2);
100 for(
int i=0; i < 32; ++i )
102 for(
int ilo=0; ilo < 32; ilo++ )
104 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
116 for(
int i=0; i < 32; ++i )
121 for(
int ilo=0; ilo < 32; ilo++ )
123 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
125 double val =
reduce_ab( a, b, ilo, ihi );
126 double expect = double(ihi*(ihi-1)*(2*ihi-1)/6 - ilo*(ilo-1)*(2*ilo-1)/6);
136 for(
int i=0; i < 32; ++i )
141 for(
int ilo=0; ilo < 32; ilo++ )
143 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
145 double val =
reduce_ab( a, b, ilo, ihi );
146 double expect = double(ihi*(ihi-1)*(2*ihi-1)/6 - ilo*(ilo-1)*(2*ilo-1)/6);
155 for(
int i=0; i < 32; ++i )
160 for(
int ilo=0; ilo < 32; ilo++ )
162 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
173 double a[32], b[32], c[32];
174 for(
int i=0; i < 32; ++i )
180 for(
int ilo=0; ilo < 32; ilo++ )
182 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
185 double expect = double(
pow2(ihi*(ihi-1)/2) -
pow2(ilo*(ilo-1)/2));
191 TEST(TestReduceABCddf)
195 for(
int i=0; i < 32; ++i )
201 for(
int ilo=0; ilo < 32; ilo++ )
203 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
206 double expect = double(
pow2(ihi*(ihi-1)/2) -
pow2(ilo*(ilo-1)/2));
212 TEST(TestReduceABCdff)
216 for(
int i=0; i < 32; ++i )
222 for(
int ilo=0; ilo < 32; ilo++ )
224 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
227 double expect = double(
pow2(ihi*(ihi-1)/2) -
pow2(ilo*(ilo-1)/2));
236 for(
int i=0; i < 32; ++i )
242 for(
int ilo=0; ilo < 32; ilo++ )
244 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
253 TEST(TestReduceAB_Ad)
256 for(
int i=0; i < 32; ++i )
261 for(
int ilo=0; ilo < 32; ilo++ )
263 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
265 double val2, val =
reduce_ab_a( a, b, ilo, ihi, &val2 );
266 double expect = double(ihi*(ihi-1)*(2*ihi-1)/6 - ilo*(ilo-1)*(2*ilo-1)/6);
267 double expect2 = double(ihi*(ihi-1)/2 - ilo*(ilo-1)/2);
274 TEST(TestReduceAB_Adf)
278 for(
int i=0; i < 32; ++i )
283 for(
int ilo=0; ilo < 32; ilo++ )
285 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
287 double val2, val =
reduce_ab_a( a, b, ilo, ihi, &val2 );
288 double expect = double(ihi*(ihi-1)*(2*ihi-1)/6 - ilo*(ilo-1)*(2*ilo-1)/6);
289 double expect2 = double(ihi*(ihi-1)/2 - ilo*(ilo-1)/2);
299 TEST(TestReduceAB_Af)
302 for(
int i=0; i < 32; ++i )
307 for(
int ilo=0; ilo < 32; ilo++ )
309 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
311 double val2, val =
reduce_ab_a( a, b, ilo, ihi, &val2 );
312 double expect = double(ihi*(ihi-1)*(2*ihi-1)/6 - ilo*(ilo-1)*(2*ilo-1)/6);
313 double expect2 = double(ihi*(ihi-1)/2 - ilo*(ilo-1)/2);
320 TEST(TestReduceABC_ABd)
322 double a[32], b[32], c[32];
323 for(
int i=0; i < 32; ++i )
329 for(
int ilo=0; ilo < 32; ilo++ )
331 for(
int ihi=ilo+1; ihi <= 32; ihi++ )
333 double val2, val =
reduce_abc_ab( a, b, c, ilo, ihi, &val2 );
334 double expect = double(
pow2(ihi*(ihi-1)/2) -
pow2(ilo*(ilo-1)/2));
335 double expect2 = double(ihi*(ihi-1)*(2*ihi-1)/6 - ilo*(ilo-1)*(2*ilo-1)/6);
345 double maxarg = log10(DBL_MAX);
347 for(
int i=0; i < 2048; ++i )
352 double val1 =
exp10(arg);
353 double val2 = pow(10.,arg);
356 CHECK(
fp_equal( val1, val2, 10 ) );
366 for(
int i=0; i < 2048; ++i )
384 double minarg = log(DBL_MIN);
387 double a1 = nextafter(minarg,-DBL_MAX);
388 vexp(val,a1,a1,a1,a1);
389 CHECK( val[0] == 0. );
390 double a2 = nextafter(minarg,DBL_MAX);
391 vexp(val,a2,a2,a2,a2);
392 CHECK( val[0] > 0. );
394 double maxarg = log(DBL_MAX);
395 a1 = nextafter(maxarg,-DBL_MAX);
396 vexp(val,a1,a1,a1,a1);
397 CHECK( val[0] < DBL_MAX );
398 a2 = nextafter(maxarg,DBL_MAX);
399 CHECK_THROW(
vexp(val,a2,a2,a2,a2), domain_error );
400 a2 = -numeric_limits<double>().infinity();
401 vexp(val,a2,a2,a2,a2);
402 CHECK( val[0] == 0. );
403 a2 = numeric_limits<double>().infinity();
404 CHECK_THROW(
vexp(val,a2,a2,a2,a2), domain_error );
405 a2 = numeric_limits<double>().quiet_NaN();
406 CHECK_THROW(
vexp(val,a2,a2,a2,a2), domain_error );
409 for(
int i=0; i < sz; )
415 vexp( arg, val, 0, sz );
416 for(
int i=0; i < sz; ++i )
418 if( arg[i] < minarg )
419 CHECK( val[i] == 0. );
421 CHECK(
fp_equal( val[i], exp(arg[i]) ) );
424 for(
int i=0; i < 32; ++i )
427 for(
int i=0; i < 32; ++i )
429 for(
int j=i+1; j <= 32; ++j )
432 vexp( arg, val, i, j );
433 for(
int k=0; k < 32; ++k )
435 if( k < i || k >= j )
436 CHECK(
isnan(val[k]) );
438 CHECK(
fp_equal( val[k], exp(arg[k]) ) );
441 vexp( &arg[i], val, 0, j-i );
442 for(
int k=0; k < 32; ++k )
445 CHECK(
isnan(val[k]) );
447 CHECK(
fp_equal( val[k], exp(arg[k+i]) ) );
460 double minarg = log10(DBL_MIN);
461 double a1 = nextafter(minarg,-DBL_MAX);
463 CHECK( val[0] == 0. );
464 double a2 = nextafter(minarg,DBL_MAX);
466 CHECK( val[0] > 0. );
467 double maxarg = log10(DBL_MAX);
468 a1 = nextafter(maxarg,-DBL_MAX);
470 CHECK( val[0] < DBL_MAX );
471 a2 = nextafter(maxarg,DBL_MAX);
472 CHECK_THROW(
vexp10(val,a2,a2,a2,a2), domain_error );
473 a2 = -numeric_limits<
double>().infinity();
475 CHECK( val[0] == 0. );
476 a2 = numeric_limits<
double>().infinity();
477 CHECK_THROW(
vexp10(val,a2,a2,a2,a2), domain_error );
478 a2 = numeric_limits<
double>().quiet_NaN();
479 CHECK_THROW(
vexp10(val,a2,a2,a2,a2), domain_error );
481 for(
int i=0; i < sz; )
487 vexp10( arg, val, 0, sz );
488 for(
int i=0; i < sz; ++i )
490 if( arg[i] < minarg )
491 CHECK( val[i] == 0. );
493 CHECK(
fp_equal( val[i], pow(10.,arg[i]), 10 ) );
507 double maxarg = log(DBL_MAX);
508 double a1 = nextafter(maxarg,-DBL_MAX);
510 CHECK( val[0] < DBL_MAX );
511 double a2 = nextafter(maxarg,DBL_MAX);
512 CHECK_THROW(
vexpm1(val,a2,a2,a2,a2), domain_error );
513 a2 = -numeric_limits<
double>().infinity();
515 CHECK( val[0] == -1. );
516 a2 = numeric_limits<
double>().infinity();
517 CHECK_THROW(
vexpm1(val,a2,a2,a2,a2), domain_error );
518 a2 = numeric_limits<
double>().quiet_NaN();
519 CHECK_THROW(
vexpm1(val,a2,a2,a2,a2), domain_error );
521 vexpm1( y, 1.e-10, 8.e-8, 4.e-5, 6.e-3, 2.e-1, 1., 1., 1. );
523 CHECK(
fp_equal( y[0], 1.000000000050000e-10 ) );
524 CHECK(
fp_equal( y[1], 8.00000032000000853e-8 ) );
525 CHECK(
fp_equal( y[2], 4.00008000106667733342e-5 ) );
526 CHECK(
fp_equal( y[3], 6.0180360540648648555845e-3 ) );
527 CHECK(
fp_equal( y[4], 2.214027581601698339210720e-1 ) );
528 CHECK(
fp_equal( y[5], 1.7182818284590452353602875 ) );
530 for(
int i=0; i < sz; )
536 vexpm1( arg, val, 0, sz );
537 for(
int i=0; i < sz; ++i )
538 CHECK(
fp_equal( val[i], expm1(arg[i]) ) );
551 sys_float a1 = nextafterf(minarg,-FLT_MAX);
552 vexp(val,a1,a1,a1,a1);
553 CHECK( val[0] == 0.f );
554 sys_float a2 = nextafterf(minarg,FLT_MAX);
555 vexp(val,a2,a2,a2,a2);
556 CHECK( val[0] > 0.f );
558 a1 = nextafterf(maxarg,-FLT_MAX);
559 vexp(val,a1,a1,a1,a1);
560 CHECK( val[0] < FLT_MAX );
561 a2 = nextafterf(maxarg,FLT_MAX);
562 CHECK_THROW(
vexp(val,a2,a2,a2,a2), domain_error );
563 a2 = -numeric_limits<sys_float>().infinity();
564 vexp(val,a2,a2,a2,a2);
565 CHECK( val[0] == 0.f );
566 a2 = numeric_limits<sys_float>().infinity();
567 CHECK_THROW(
vexp(val,a2,a2,a2,a2), domain_error );
568 a2 = numeric_limits<sys_float>().quiet_NaN();
569 CHECK_THROW(
vexp(val,a2,a2,a2,a2), domain_error );
571 for(
int i=0; i < sz; )
577 vexp( arg, val, 0, sz );
578 for(
int i=0; i < sz; ++i )
580 if( arg[i] < minarg )
581 CHECK( val[i] == 0.f );
583 CHECK(
fp_equal( val[i], expf(arg[i]) ) );
586 for(
int i=0; i < 32; ++i )
588 for(
int i=0; i < 32; ++i )
590 for(
int j=i+1; j <= 32; ++j )
593 vexp( arg, val, i, j );
594 for(
int k=0; k < 32; ++k )
596 if( k < i || k >= j )
597 CHECK(
isnan(val[k]) );
599 CHECK(
fp_equal( val[k], expf(arg[k]) ) );
602 vexp( &arg[i], val, 0, j-i );
603 for(
int k=0; k < 32; ++k )
606 CHECK(
isnan(val[k]) );
608 CHECK(
fp_equal( val[k], expf(arg[k+i]) ) );
622 sys_float a1 = nextafterf(minarg,-FLT_MAX);
624 CHECK( val[0] == 0.f );
625 sys_float a2 = nextafterf(minarg,FLT_MAX);
627 CHECK( val[0] > 0.f );
629 a1 = nextafterf(maxarg,-FLT_MAX);
631 CHECK( val[0] < FLT_MAX );
632 a2 = nextafterf(maxarg,FLT_MAX);
633 CHECK_THROW(
vexp10(val,a2,a2,a2,a2), domain_error );
634 a2 = -numeric_limits<
sys_float>().infinity();
636 CHECK( val[0] == 0.f );
637 a2 = numeric_limits<
sys_float>().infinity();
638 CHECK_THROW(
vexp10(val,a2,a2,a2,a2), domain_error );
639 a2 = numeric_limits<
sys_float>().quiet_NaN();
640 CHECK_THROW(
vexp10(val,a2,a2,a2,a2), domain_error );
642 for(
int i=0; i < sz; )
648 vexp10( arg, val, 0, sz );
649 for(
int i=0; i < sz; ++i )
651 if( arg[i] < minarg )
652 CHECK( val[i] == 0.f );
654 CHECK(
fp_equal( val[i], powf(10.f,arg[i]), 8 ) );
669 sys_float a1 = nextafterf(maxarg,-FLT_MAX);
671 CHECK( val[0] < FLT_MAX );
672 sys_float a2 = nextafterf(maxarg,FLT_MAX);
673 CHECK_THROW(
vexpm1(val,a2,a2,a2,a2), domain_error );
674 a2 = -numeric_limits<
sys_float>().infinity();
676 CHECK( val[0] == -1.f );
677 a2 = numeric_limits<
sys_float>().infinity();
678 CHECK_THROW(
vexpm1(val,a2,a2,a2,a2), domain_error );
679 a2 = numeric_limits<
sys_float>().quiet_NaN();
680 CHECK_THROW(
vexpm1(val,a2,a2,a2,a2), domain_error );
682 vexpm1( y, 1.e-10f, 8.e-8f, 4.e-5f, 6.e-3f, 2.e-1f, 1.f, 1.f, 1.f );
684 CHECK(
fp_equal( y[0], 1.000000000050000e-10f ) );
685 CHECK(
fp_equal( y[1], 8.00000032000000853e-8f ) );
686 CHECK(
fp_equal( y[2], 4.00008000106667733342e-5f ) );
687 CHECK(
fp_equal( y[3], 6.0180360540648648555845e-3f ) );
688 CHECK(
fp_equal( y[4], 2.214027581601698339210720e-1f ) );
689 CHECK(
fp_equal( y[5], 1.7182818284590452353602875f ) );
691 for(
int i=0; i < sz; )
697 vexpm1( arg, val, 0, sz );
698 for(
int i=0; i < sz; ++i )
699 CHECK(
fp_equal( val[i], expm1f(arg[i]) ) );
708 vexp(y,1.1,1.2,1.3,1.4);
709 CHECK(
fp_equal( y[0], exp(1.1) ) );
710 CHECK(
fp_equal( y[1], exp(1.2) ) );
711 CHECK(
fp_equal( y[2], exp(1.3) ) );
712 CHECK(
fp_equal( y[3], exp(1.4) ) );
718 vexp10(y,1.1,1.2,1.3,1.4);
719 CHECK(
fp_equal( y[0], pow(10.,1.1) ) );
720 CHECK(
fp_equal( y[1], pow(10.,1.2) ) );
721 CHECK(
fp_equal( y[2], pow(10.,1.3) ) );
722 CHECK(
fp_equal( y[3], pow(10.,1.4) ) );
728 vexpm1(y,1.e-10,1.2,1.3,1.4);
729 CHECK(
fp_equal( y[0], expm1(1.e-10) ) );
730 CHECK(
fp_equal( y[1], expm1(1.2) ) );
731 CHECK(
fp_equal( y[2], expm1(1.3) ) );
732 CHECK(
fp_equal( y[3], expm1(1.4) ) );
738 vexp(y,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8);
739 CHECK(
fp_equal( y[0], exp(1.1) ) );
740 CHECK(
fp_equal( y[1], exp(1.2) ) );
741 CHECK(
fp_equal( y[2], exp(1.3) ) );
742 CHECK(
fp_equal( y[3], exp(1.4) ) );
743 CHECK(
fp_equal( y[4], exp(1.5) ) );
744 CHECK(
fp_equal( y[5], exp(1.6) ) );
745 CHECK(
fp_equal( y[6], exp(1.7) ) );
746 CHECK(
fp_equal( y[7], exp(1.8) ) );
752 vexp10(y,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8);
753 CHECK(
fp_equal( y[0], pow(10.,1.1) ) );
754 CHECK(
fp_equal( y[1], pow(10.,1.2) ) );
755 CHECK(
fp_equal( y[2], pow(10.,1.3) ) );
756 CHECK(
fp_equal( y[3], pow(10.,1.4) ) );
757 CHECK(
fp_equal( y[4], pow(10.,1.5) ) );
758 CHECK(
fp_equal( y[5], pow(10.,1.6) ) );
759 CHECK(
fp_equal( y[6], pow(10.,1.7) ) );
760 CHECK(
fp_equal( y[7], pow(10.,1.8) ) );
766 vexpm1(y,1.e-10,1.2,1.3,1.4,1.5,1.6,1.7,1.8);
767 CHECK(
fp_equal( y[0], expm1(1.e-10) ) );
768 CHECK(
fp_equal( y[1], expm1(1.2) ) );
769 CHECK(
fp_equal( y[2], expm1(1.3) ) );
770 CHECK(
fp_equal( y[3], expm1(1.4) ) );
771 CHECK(
fp_equal( y[4], expm1(1.5) ) );
772 CHECK(
fp_equal( y[5], expm1(1.6) ) );
773 CHECK(
fp_equal( y[6], expm1(1.7) ) );
774 CHECK(
fp_equal( y[7], expm1(1.8) ) );
780 vexp(y,1.1f,1.2f,1.3f,1.4f);
781 CHECK(
fp_equal( y[0], expf(1.1f) ) );
782 CHECK(
fp_equal( y[1], expf(1.2f) ) );
783 CHECK(
fp_equal( y[2], expf(1.3f) ) );
784 CHECK(
fp_equal( y[3], expf(1.4f) ) );
790 vexp10(y,1.1f,1.2f,1.3f,1.4f);
791 CHECK(
fp_equal( y[0], powf(10.f,1.1f) ) );
792 CHECK(
fp_equal( y[1], powf(10.f,1.2f) ) );
793 CHECK(
fp_equal( y[2], powf(10.f,1.3f) ) );
794 CHECK(
fp_equal( y[3], powf(10.f,1.4f) ) );
800 vexpm1(y,1.e-10f,1.2f,1.3f,1.4f);
801 CHECK(
fp_equal( y[0], expm1f(1.e-10f) ) );
802 CHECK(
fp_equal( y[1], expm1f(1.2f) ) );
803 CHECK(
fp_equal( y[2], expm1f(1.3f) ) );
804 CHECK(
fp_equal( y[3], expm1f(1.4f) ) );
810 vexp(y,1.1f,1.2f,1.3f,1.4f,1.5f,1.6f,1.7f,1.8f);
811 CHECK(
fp_equal( y[0], expf(1.1f) ) );
812 CHECK(
fp_equal( y[1], expf(1.2f) ) );
813 CHECK(
fp_equal( y[2], expf(1.3f) ) );
814 CHECK(
fp_equal( y[3], expf(1.4f) ) );
815 CHECK(
fp_equal( y[4], expf(1.5f) ) );
816 CHECK(
fp_equal( y[5], expf(1.6f) ) );
817 CHECK(
fp_equal( y[6], expf(1.7f) ) );
818 CHECK(
fp_equal( y[7], expf(1.8f) ) );
824 vexp10(y,1.1f,1.2f,1.3f,1.4f,1.5f,1.6f,1.7f,1.8f);
825 CHECK(
fp_equal( y[0], powf(10.f,1.1f) ) );
826 CHECK(
fp_equal( y[1], powf(10.f,1.2f) ) );
827 CHECK(
fp_equal( y[2], powf(10.f,1.3f) ) );
828 CHECK(
fp_equal( y[3], powf(10.f,1.4f) ) );
829 CHECK(
fp_equal( y[4], powf(10.f,1.5f) ) );
830 CHECK(
fp_equal( y[5], powf(10.f,1.6f) ) );
831 CHECK(
fp_equal( y[6], powf(10.f,1.7f) ) );
832 CHECK(
fp_equal( y[7], powf(10.f,1.8f) ) );
838 vexpm1(y,1.e-10f,1.2f,1.3f,1.4f,1.5f,1.6f,1.7f,1.8f);
839 CHECK(
fp_equal( y[0], expm1f(1.e-10f) ) );
840 CHECK(
fp_equal( y[1], expm1f(1.2f) ) );
841 CHECK(
fp_equal( y[2], expm1f(1.3f) ) );
842 CHECK(
fp_equal( y[3], expm1f(1.4f) ) );
843 CHECK(
fp_equal( y[4], expm1f(1.5f) ) );
844 CHECK(
fp_equal( y[5], expm1f(1.6f) ) );
845 CHECK(
fp_equal( y[6], expm1f(1.7f) ) );
846 CHECK(
fp_equal( y[7], expm1f(1.8f) ) );
852 vexp(y,1.1f,1.2f,1.3f,1.4f,1.5f,1.6f,1.7f,1.8f,2.11f,2.22f,2.33f,2.44f,2.55f,2.66f,2.77f,2.88f);
853 CHECK(
fp_equal( y[0], expf(1.1f) ) );
854 CHECK(
fp_equal( y[1], expf(1.2f) ) );
855 CHECK(
fp_equal( y[2], expf(1.3f) ) );
856 CHECK(
fp_equal( y[3], expf(1.4f) ) );
857 CHECK(
fp_equal( y[4], expf(1.5f) ) );
858 CHECK(
fp_equal( y[5], expf(1.6f) ) );
859 CHECK(
fp_equal( y[6], expf(1.7f) ) );
860 CHECK(
fp_equal( y[7], expf(1.8f) ) );
861 CHECK(
fp_equal( y[8], expf(2.11f) ) );
862 CHECK(
fp_equal( y[9], expf(2.22f) ) );
863 CHECK(
fp_equal( y[10], expf(2.33f) ) );
864 CHECK(
fp_equal( y[11], expf(2.44f) ) );
865 CHECK(
fp_equal( y[12], expf(2.55f) ) );
866 CHECK(
fp_equal( y[13], expf(2.66f) ) );
867 CHECK(
fp_equal( y[14], expf(2.77f) ) );
868 CHECK(
fp_equal( y[15], expf(2.88f) ) );
874 vexp10(y,1.1f,1.2f,1.3f,1.4f,1.5f,1.6f,1.7f,1.8f,2.11f,2.22f,2.33f,2.44f,2.55f,2.66f,2.77f,2.88f);
875 CHECK(
fp_equal( y[0], powf(10.f,1.1f) ) );
876 CHECK(
fp_equal( y[1], powf(10.f,1.2f) ) );
877 CHECK(
fp_equal( y[2], powf(10.f,1.3f) ) );
878 CHECK(
fp_equal( y[3], powf(10.f,1.4f) ) );
879 CHECK(
fp_equal( y[4], powf(10.f,1.5f) ) );
880 CHECK(
fp_equal( y[5], powf(10.f,1.6f) ) );
881 CHECK(
fp_equal( y[6], powf(10.f,1.7f) ) );
882 CHECK(
fp_equal( y[7], powf(10.f,1.8f) ) );
883 CHECK(
fp_equal( y[8], powf(10.f,2.11f) ) );
884 CHECK(
fp_equal( y[9], powf(10.f,2.22f) ) );
885 CHECK(
fp_equal( y[10], powf(10.f,2.33f) ) );
886 CHECK(
fp_equal( y[11], powf(10.f,2.44f) ) );
887 CHECK(
fp_equal( y[12], powf(10.f,2.55f) ) );
888 CHECK(
fp_equal( y[13], powf(10.f,2.66f) ) );
889 CHECK(
fp_equal( y[14], powf(10.f,2.77f) ) );
890 CHECK(
fp_equal( y[15], powf(10.f,2.88f) ) );
896 vexpm1(y,1.e-10f,1.2f,1.3f,1.4f,1.5f,1.6f,1.7f,1.8f,2.11f,2.22f,2.33f,2.44f,2.55f,2.66f,2.77f,2.88f);
897 CHECK(
fp_equal( y[0], expm1f(1.e-10f) ) );
898 CHECK(
fp_equal( y[1], expm1f(1.2f) ) );
899 CHECK(
fp_equal( y[2], expm1f(1.3f) ) );
900 CHECK(
fp_equal( y[3], expm1f(1.4f) ) );
901 CHECK(
fp_equal( y[4], expm1f(1.5f) ) );
902 CHECK(
fp_equal( y[5], expm1f(1.6f) ) );
903 CHECK(
fp_equal( y[6], expm1f(1.7f) ) );
904 CHECK(
fp_equal( y[7], expm1f(1.8f) ) );
905 CHECK(
fp_equal( y[8], expm1f(2.11f) ) );
906 CHECK(
fp_equal( y[9], expm1f(2.22f) ) );
907 CHECK(
fp_equal( y[10], expm1f(2.33f) ) );
908 CHECK(
fp_equal( y[11], expm1f(2.44f) ) );
909 CHECK(
fp_equal( y[12], expm1f(2.55f) ) );
910 CHECK(
fp_equal( y[13], expm1f(2.66f) ) );
911 CHECK(
fp_equal( y[14], expm1f(2.77f) ) );
912 CHECK(
fp_equal( y[15], expm1f(2.88f) ) );
920 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
922 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
924 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
925 x = numeric_limits<double>().infinity();
926 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
927 x = -numeric_limits<double>().infinity();
928 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
929 x = numeric_limits<double>().quiet_NaN();
930 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
936 for(
int i=0; i < sz; ++i )
938 vlog( arg, val, 0, sz );
939 for(
int i=0; i < sz; ++i )
940 CHECK(
fp_equal( val[i], log(arg[i]) ) );
951 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
953 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
955 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
956 x = numeric_limits<double>().infinity();
957 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
958 x = -numeric_limits<double>().infinity();
959 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
960 x = numeric_limits<double>().quiet_NaN();
961 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
967 for(
int i=0; i < sz; ++i )
968 arg[i] = exp(genrand_real1()*1418.17-708.39);
969 vlog10( arg, val, 0, sz );
970 for(
int i=0; i < sz; ++i )
971 CHECK(
fp_equal( val[i], log10(arg[i]) ) );
982 CHECK_THROW(
vlog1p(y,x,x,x,x), domain_error );
984 CHECK_THROW(
vlog1p(y,x,x,x,x), domain_error );
985 x = numeric_limits<double>().infinity();
986 CHECK_THROW(
vlog1p(y,x,x,x,x), domain_error );
987 x = -numeric_limits<double>().infinity();
988 CHECK_THROW(
vlog1p(y,x,x,x,x), domain_error );
989 x = numeric_limits<double>().quiet_NaN();
990 CHECK_THROW(
vlog1p(y,x,x,x,x), domain_error );
997 for(
int i=0; i < sz; ++i )
1003 vlog1p( arg, val, 0, sz );
1004 for(
int i=0; i < sz; ++i )
1005 CHECK(
fp_equal( val[i], log1p(arg[i]) ) );
1007 for(
int i=0; i < sz; ++i )
1008 arg[i] = exp(
genrand_real1()*1418.17-708.39) - 0.9999999999;
1009 vlog1p( arg, val, 0, sz );
1010 for(
int i=0; i < sz; ++i )
1011 CHECK(
fp_equal( val[i], log1p(arg[i]) ) );
1022 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
1024 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
1026 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
1027 x = numeric_limits<sys_float>().infinity();
1028 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
1029 x = -numeric_limits<sys_float>().infinity();
1030 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
1031 x = numeric_limits<sys_float>().quiet_NaN();
1032 CHECK_THROW(
vlog(y,x,x,x,x), domain_error );
1034 const int sz = 2048;
1038 for(
int i=0; i < sz; ++i )
1039 arg[i] = exp(genrand_real1()*176.05-87.33);
1040 vlog( arg, val, 0, sz );
1041 for(
int i=0; i < sz; ++i )
1042 CHECK(
fp_equal( val[i], logf(arg[i]) ) );
1053 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
1055 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
1057 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
1058 x = numeric_limits<sys_float>().infinity();
1059 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
1060 x = -numeric_limits<sys_float>().infinity();
1061 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
1062 x = numeric_limits<sys_float>().quiet_NaN();
1063 CHECK_THROW(
vlog10(y,x,x,x,x), domain_error );
1065 const int sz = 2048;
1069 for(
int i=0; i < sz; ++i )
1070 arg[i] = exp(genrand_real1()*176.05-87.33);
1071 vlog10( arg, val, 0, sz );
1072 for(
int i=0; i < sz; ++i )
1073 CHECK(
fp_equal( val[i], log10f(arg[i]) ) );
1084 CHECK_THROW(
vlog1p(y,x,x,x,x), domain_error );
1086 CHECK_THROW(
vlog1p(y,x,x,x,x), domain_error );
1087 x = numeric_limits<sys_float>().infinity();
1088 CHECK_THROW(
vlog1p(y,x,x,x,x), domain_error );
1089 x = -numeric_limits<sys_float>().infinity();
1090 CHECK_THROW(
vlog1p(y,x,x,x,x), domain_error );
1091 x = numeric_limits<sys_float>().quiet_NaN();
1092 CHECK_THROW(
vlog1p(y,x,x,x,x), domain_error );
1094 const int sz = 2048;
1099 for(
int i=0; i < sz; ++i )
1105 vlog1p( arg, val, 0, sz );
1106 for(
int i=0; i < sz; ++i )
1107 CHECK(
fp_equal( val[i], log1pf(arg[i]) ) );
1109 for(
int i=0; i < sz; ++i )
1111 vlog1p( arg, val, 0, sz );
1112 for(
int i=0; i < sz; ++i )
1113 CHECK(
fp_equal( val[i], log1pf(arg[i]) ) );
1122 vlog(y,11.,22.,33.,44.);
1123 CHECK(
fp_equal( y[0], log(11.) ) );
1124 CHECK(
fp_equal( y[1], log(22.) ) );
1125 CHECK(
fp_equal( y[2], log(33.) ) );
1126 CHECK(
fp_equal( y[3], log(44.) ) );
1132 vlog10(y,11.,22.,33.,44.);
1133 CHECK(
fp_equal( y[0], log10(11.) ) );
1134 CHECK(
fp_equal( y[1], log10(22.) ) );
1135 CHECK(
fp_equal( y[2], log10(33.) ) );
1136 CHECK(
fp_equal( y[3], log10(44.) ) );
1142 vlog1p(y,11.,22.,33.,44.);
1143 CHECK(
fp_equal( y[0], log1p(11.) ) );
1144 CHECK(
fp_equal( y[1], log1p(22.) ) );
1145 CHECK(
fp_equal( y[2], log1p(33.) ) );
1146 CHECK(
fp_equal( y[3], log1p(44.) ) );
1152 vlog(y,11.,22.,33.,44.,55.,66.,77.,88.);
1153 CHECK(
fp_equal( y[0], log(11.) ) );
1154 CHECK(
fp_equal( y[1], log(22.) ) );
1155 CHECK(
fp_equal( y[2], log(33.) ) );
1156 CHECK(
fp_equal( y[3], log(44.) ) );
1157 CHECK(
fp_equal( y[4], log(55.) ) );
1158 CHECK(
fp_equal( y[5], log(66.) ) );
1159 CHECK(
fp_equal( y[6], log(77.) ) );
1160 CHECK(
fp_equal( y[7], log(88.) ) );
1166 vlog10(y,11.,22.,33.,44.,55.,66.,77.,88.);
1167 CHECK(
fp_equal( y[0], log10(11.) ) );
1168 CHECK(
fp_equal( y[1], log10(22.) ) );
1169 CHECK(
fp_equal( y[2], log10(33.) ) );
1170 CHECK(
fp_equal( y[3], log10(44.) ) );
1171 CHECK(
fp_equal( y[4], log10(55.) ) );
1172 CHECK(
fp_equal( y[5], log10(66.) ) );
1173 CHECK(
fp_equal( y[6], log10(77.) ) );
1174 CHECK(
fp_equal( y[7], log10(88.) ) );
1180 vlog1p(y,11.,22.,33.,44.,55.,66.,77.,88.);
1181 CHECK(
fp_equal( y[0], log1p(11.) ) );
1182 CHECK(
fp_equal( y[1], log1p(22.) ) );
1183 CHECK(
fp_equal( y[2], log1p(33.) ) );
1184 CHECK(
fp_equal( y[3], log1p(44.) ) );
1185 CHECK(
fp_equal( y[4], log1p(55.) ) );
1186 CHECK(
fp_equal( y[5], log1p(66.) ) );
1187 CHECK(
fp_equal( y[6], log1p(77.) ) );
1188 CHECK(
fp_equal( y[7], log1p(88.) ) );
1194 vlog(y,11.f,22.f,33.f,44.f);
1195 CHECK(
fp_equal( y[0], logf(11.f) ) );
1196 CHECK(
fp_equal( y[1], logf(22.f) ) );
1197 CHECK(
fp_equal( y[2], logf(33.f) ) );
1198 CHECK(
fp_equal( y[3], logf(44.f) ) );
1204 vlog10(y,11.f,22.f,33.f,44.f);
1205 CHECK(
fp_equal( y[0], log10f(11.f) ) );
1206 CHECK(
fp_equal( y[1], log10f(22.f) ) );
1207 CHECK(
fp_equal( y[2], log10f(33.f) ) );
1208 CHECK(
fp_equal( y[3], log10f(44.f) ) );
1214 vlog1p(y,11.f,22.f,33.f,44.f);
1215 CHECK(
fp_equal( y[0], log1pf(11.f) ) );
1216 CHECK(
fp_equal( y[1], log1pf(22.f) ) );
1217 CHECK(
fp_equal( y[2], log1pf(33.f) ) );
1218 CHECK(
fp_equal( y[3], log1pf(44.f) ) );
1224 vlog(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f);
1225 CHECK(
fp_equal( y[0], logf(11.f) ) );
1226 CHECK(
fp_equal( y[1], logf(22.f) ) );
1227 CHECK(
fp_equal( y[2], logf(33.f) ) );
1228 CHECK(
fp_equal( y[3], logf(44.f) ) );
1229 CHECK(
fp_equal( y[4], logf(55.f) ) );
1230 CHECK(
fp_equal( y[5], logf(66.f) ) );
1231 CHECK(
fp_equal( y[6], logf(77.f) ) );
1232 CHECK(
fp_equal( y[7], logf(88.f) ) );
1238 vlog10(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f);
1239 CHECK(
fp_equal( y[0], log10f(11.f) ) );
1240 CHECK(
fp_equal( y[1], log10f(22.f) ) );
1241 CHECK(
fp_equal( y[2], log10f(33.f) ) );
1242 CHECK(
fp_equal( y[3], log10f(44.f) ) );
1243 CHECK(
fp_equal( y[4], log10f(55.f) ) );
1244 CHECK(
fp_equal( y[5], log10f(66.f) ) );
1245 CHECK(
fp_equal( y[6], log10f(77.f) ) );
1246 CHECK(
fp_equal( y[7], log10f(88.f) ) );
1252 vlog1p(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f);
1253 CHECK(
fp_equal( y[0], log1pf(11.f) ) );
1254 CHECK(
fp_equal( y[1], log1pf(22.f) ) );
1255 CHECK(
fp_equal( y[2], log1pf(33.f) ) );
1256 CHECK(
fp_equal( y[3], log1pf(44.f) ) );
1257 CHECK(
fp_equal( y[4], log1pf(55.f) ) );
1258 CHECK(
fp_equal( y[5], log1pf(66.f) ) );
1259 CHECK(
fp_equal( y[6], log1pf(77.f) ) );
1260 CHECK(
fp_equal( y[7], log1pf(88.f) ) );
1266 vlog(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f,111.f,122.f,133.f,144.f,155.f,166.f,177.f,188.f);
1267 CHECK(
fp_equal( y[0], logf(11.f) ) );
1268 CHECK(
fp_equal( y[1], logf(22.f) ) );
1269 CHECK(
fp_equal( y[2], logf(33.f) ) );
1270 CHECK(
fp_equal( y[3], logf(44.f) ) );
1271 CHECK(
fp_equal( y[4], logf(55.f) ) );
1272 CHECK(
fp_equal( y[5], logf(66.f) ) );
1273 CHECK(
fp_equal( y[6], logf(77.f) ) );
1274 CHECK(
fp_equal( y[7], logf(88.f) ) );
1275 CHECK(
fp_equal( y[8], logf(111.f) ) );
1276 CHECK(
fp_equal( y[9], logf(122.f) ) );
1277 CHECK(
fp_equal( y[10], logf(133.f) ) );
1278 CHECK(
fp_equal( y[11], logf(144.f) ) );
1279 CHECK(
fp_equal( y[12], logf(155.f) ) );
1280 CHECK(
fp_equal( y[13], logf(166.f) ) );
1281 CHECK(
fp_equal( y[14], logf(177.f) ) );
1282 CHECK(
fp_equal( y[15], logf(188.f) ) );
1285 TEST(TestVlog10fx16)
1288 vlog10(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f,111.f,122.f,133.f,144.f,155.f,166.f,177.f,188.f);
1289 CHECK(
fp_equal( y[0], log10f(11.f) ) );
1290 CHECK(
fp_equal( y[1], log10f(22.f) ) );
1291 CHECK(
fp_equal( y[2], log10f(33.f) ) );
1292 CHECK(
fp_equal( y[3], log10f(44.f) ) );
1293 CHECK(
fp_equal( y[4], log10f(55.f) ) );
1294 CHECK(
fp_equal( y[5], log10f(66.f) ) );
1295 CHECK(
fp_equal( y[6], log10f(77.f) ) );
1296 CHECK(
fp_equal( y[7], log10f(88.f) ) );
1297 CHECK(
fp_equal( y[8], log10f(111.f) ) );
1298 CHECK(
fp_equal( y[9], log10f(122.f) ) );
1299 CHECK(
fp_equal( y[10], log10f(133.f) ) );
1300 CHECK(
fp_equal( y[11], log10f(144.f) ) );
1301 CHECK(
fp_equal( y[12], log10f(155.f) ) );
1302 CHECK(
fp_equal( y[13], log10f(166.f) ) );
1303 CHECK(
fp_equal( y[14], log10f(177.f) ) );
1304 CHECK(
fp_equal( y[15], log10f(188.f) ) );
1307 TEST(TestVlog1pfx16)
1310 vlog1p(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f,111.f,122.f,133.f,144.f,155.f,166.f,177.f,188.f);
1311 CHECK(
fp_equal( y[0], log1pf(11.f) ) );
1312 CHECK(
fp_equal( y[1], log1pf(22.f) ) );
1313 CHECK(
fp_equal( y[2], log1pf(33.f) ) );
1314 CHECK(
fp_equal( y[3], log1pf(44.f) ) );
1315 CHECK(
fp_equal( y[4], log1pf(55.f) ) );
1316 CHECK(
fp_equal( y[5], log1pf(66.f) ) );
1317 CHECK(
fp_equal( y[6], log1pf(77.f) ) );
1318 CHECK(
fp_equal( y[7], log1pf(88.f) ) );
1319 CHECK(
fp_equal( y[8], log1pf(111.f) ) );
1320 CHECK(
fp_equal( y[9], log1pf(122.f) ) );
1321 CHECK(
fp_equal( y[10], log1pf(133.f) ) );
1322 CHECK(
fp_equal( y[11], log1pf(144.f) ) );
1323 CHECK(
fp_equal( y[12], log1pf(155.f) ) );
1324 CHECK(
fp_equal( y[13], log1pf(166.f) ) );
1325 CHECK(
fp_equal( y[14], log1pf(177.f) ) );
1326 CHECK(
fp_equal( y[15], log1pf(188.f) ) );
1334 CHECK_THROW(
vsqrt(y,x,x,x,x), domain_error );
1335 x = -numeric_limits<double>().infinity();
1336 CHECK_THROW(
vsqrt(y,x,x,x,x), domain_error );
1337 x = numeric_limits<double>().infinity();
1338 CHECK_THROW(
vsqrt(y,x,x,x,x), domain_error );
1339 x = numeric_limits<double>().quiet_NaN();
1340 CHECK_THROW(
vsqrt(y,x,x,x,x), domain_error );
1343 CHECK( y[0] == 0. );
1345 const int sz = 2048;
1349 for(
int i=0; i < sz; ++i )
1350 arg[i] = exp(genrand_real1()*1418.17-708.39);
1351 vsqrt( arg, val, 0, sz );
1352 for(
int i=0; i < sz; ++i )
1353 CHECK(
fp_equal( val[i], sqrt(arg[i]) ) );
1361 const int sz = 2048;
1366 double y[4], x = -numeric_limits<double>().infinity();
1367 CHECK_THROW(
vhypot(y,x,1.,x,1.,x,1.,x,1.), domain_error );
1368 CHECK_THROW(
vhypot(y,1.,x,1.,x,1.,x,1.,x), domain_error );
1369 x = numeric_limits<double>().infinity();
1370 CHECK_THROW(
vhypot(y,x,1.,x,1.,x,1.,x,1.), domain_error );
1371 CHECK_THROW(
vhypot(y,1.,x,1.,x,1.,x,1.,x), domain_error );
1372 x = numeric_limits<double>().quiet_NaN();
1373 CHECK_THROW(
vhypot(y,x,1.,x,1.,x,1.,x,1.), domain_error );
1374 CHECK_THROW(
vhypot(y,1.,x,1.,x,1.,x,1.,x), domain_error );
1375 vhypot(y,0.,0.,1.,0.,0.,1.,DBL_MAX/2.,DBL_MAX/2.);
1379 CHECK(
fp_equal( y[3], DBL_MAX/sqrt(2.) ) );
1382 for(
int i=0; i < sz; ++i )
1391 vhypot( arg1, arg2, val, 0, sz );
1392 for(
int i=0; i < sz; ++i )
1394 CHECK(
fp_equal( val[i], hypot(arg1[i], arg2[i]) ) );
1397 for(
int i=0; i < 32; ++i )
1399 arg1[i] = double(i);
1400 arg2[i] = double(i);
1403 for(
int i=0; i < 32; ++i )
1405 for(
int j=i+1; j <= 32; ++j )
1408 vhypot( arg1, arg2, val, i, j );
1409 for(
int k=0; k < 32; ++k )
1411 if( k < i || k >= j )
1412 CHECK(
isnan(val[k]) );
1414 CHECK(
fp_equal( val[k],
double(k)*sqrt(2.) ) );
1417 vhypot( &arg1[i], &arg2[i], val, 0, j-i );
1418 for(
int k=0; k < 32; ++k )
1421 CHECK(
isnan(val[k]) );
1423 CHECK(
fp_equal( val[k],
double(k+i)*sqrt(2.) ) );
1426 vhypot( &arg1[i], arg2, &val[i], 0, j-i );
1427 for(
int k=0; k < 32; ++k )
1429 if( k < i || k >= j )
1430 CHECK(
isnan(val[k]) );
1432 CHECK(
fp_equal( val[k], sqrt(
double((k-i)*(k-i)+k*k)) ) );
1435 vhypot( arg1, &arg2[i], &val[i], 0, j-i );
1436 for(
int k=0; k < 32; ++k )
1438 if( k < i || k >= j )
1439 CHECK(
isnan(val[k]) );
1441 CHECK(
fp_equal( val[k], sqrt(
double((k-i)*(k-i)+k*k)) ) );
1444 vhypot( &arg1[i], &arg2[i/2], val, 0, j-i );
1445 for(
int k=0; k < 32; ++k )
1448 CHECK(
isnan(val[k]) );
1451 double ref2 = double((k+i)*(k+i) + (k+i/2)*(k+i/2));
1452 CHECK(
fp_equal( val[k], sqrt(ref2) ) );
1464 CHECK_THROW(
vsqrt(y,x,x,x,x), domain_error );
1465 x = -numeric_limits<sys_float>().infinity();
1466 CHECK_THROW(
vsqrt(y,x,x,x,x), domain_error );
1467 x = numeric_limits<sys_float>().infinity();
1468 CHECK_THROW(
vsqrt(y,x,x,x,x), domain_error );
1469 x = numeric_limits<sys_float>().quiet_NaN();
1470 CHECK_THROW(
vsqrt(y,x,x,x,x), domain_error );
1473 CHECK( y[0] == 0.f );
1475 const int sz = 2048;
1479 for(
int i=0; i < sz; ++i )
1480 arg[i] = exp(genrand_real1()*176.05-87.33);
1481 vsqrt( arg, val, 0, sz );
1482 for(
int i=0; i < sz; ++i )
1483 CHECK(
fp_equal( val[i], sqrtf(arg[i]) ) );
1491 const int sz = 2048;
1496 sys_float y[4], x = -numeric_limits<sys_float>().infinity();
1497 CHECK_THROW(
vhypot(y,x,1.f,x,1.f,x,1.f,x,1.f), domain_error );
1498 CHECK_THROW(
vhypot(y,1.f,x,1.f,x,1.f,x,1.f,x), domain_error );
1499 x = numeric_limits<sys_float>().infinity();
1500 CHECK_THROW(
vhypot(y,x,1.f,x,1.f,x,1.f,x,1.f), domain_error );
1501 CHECK_THROW(
vhypot(y,1.f,x,1.f,x,1.f,x,1.f,x), domain_error );
1502 x = numeric_limits<sys_float>().quiet_NaN();
1503 CHECK_THROW(
vhypot(y,x,1.f,x,1.f,x,1.f,x,1.f), domain_error );
1504 CHECK_THROW(
vhypot(y,1.f,x,1.f,x,1.f,x,1.f,x), domain_error );
1505 vhypot(y,0.f,0.f,1.f,0.f,0.f,1.f,FLT_MAX/2.f,FLT_MAX/2.f);
1509 CHECK(
fp_equal( y[3], FLT_MAX/sqrtf(2.f) ) );
1512 for(
int i=0; i < sz; ++i )
1521 vhypot( arg1, arg2, val, 0, sz );
1522 for(
int i=0; i < sz; ++i )
1524 CHECK(
fp_equal( val[i], hypotf(arg1[i], arg2[i]) ) );
1527 for(
int i=0; i < 32; ++i )
1533 for(
int i=0; i < 32; ++i )
1535 for(
int j=i+1; j <= 32; ++j )
1538 vhypot( arg1, arg2, val, i, j );
1539 for(
int k=0; k < 32; ++k )
1541 if( k < i || k >= j )
1542 CHECK( isnanf(val[k]) );
1547 vhypot( &arg1[i], &arg2[i], val, 0, j-i );
1548 for(
int k=0; k < 32; ++k )
1551 CHECK( isnanf(val[k]) );
1556 vhypot( &arg1[i], arg2, &val[i], 0, j-i );
1557 for(
int k=0; k < 32; ++k )
1559 if( k < i || k >= j )
1560 CHECK( isnanf(val[k]) );
1565 vhypot( arg1, &arg2[i], &val[i], 0, j-i );
1566 for(
int k=0; k < 32; ++k )
1568 if( k < i || k >= j )
1569 CHECK( isnanf(val[k]) );
1574 vhypot( &arg1[i], &arg2[i/2], val, 0, j-i );
1575 for(
int k=0; k < 32; ++k )
1578 CHECK( isnanf(val[k]) );
1582 CHECK(
fp_equal( val[k], sqrtf(ref2) ) );
1592 vsqrt(y,11.,22.,33.,44.);
1593 CHECK(
fp_equal( y[0], sqrt(11.) ) );
1594 CHECK(
fp_equal( y[1], sqrt(22.) ) );
1595 CHECK(
fp_equal( y[2], sqrt(33.) ) );
1596 CHECK(
fp_equal( y[3], sqrt(44.) ) );
1602 vhypot(y,11.,22.,33.,44.,55.,66.,77.,88.);
1603 CHECK(
fp_equal( y[0], hypot(11.,22.) ) );
1604 CHECK(
fp_equal( y[1], hypot(33.,44.) ) );
1605 CHECK(
fp_equal( y[2], hypot(55.,66.) ) );
1606 CHECK(
fp_equal( y[3], hypot(77.,88.) ) );
1612 vsqrt(y,11.,22.,33.,44.,55.,66.,77.,88.);
1613 CHECK(
fp_equal( y[0], sqrt(11.) ) );
1614 CHECK(
fp_equal( y[1], sqrt(22.) ) );
1615 CHECK(
fp_equal( y[2], sqrt(33.) ) );
1616 CHECK(
fp_equal( y[3], sqrt(44.) ) );
1617 CHECK(
fp_equal( y[4], sqrt(55.) ) );
1618 CHECK(
fp_equal( y[5], sqrt(66.) ) );
1619 CHECK(
fp_equal( y[6], sqrt(77.) ) );
1620 CHECK(
fp_equal( y[7], sqrt(88.) ) );
1626 vsqrt(y,11.f,22.f,33.f,44.f);
1627 CHECK(
fp_equal( y[0], sqrtf(11.f) ) );
1628 CHECK(
fp_equal( y[1], sqrtf(22.f) ) );
1629 CHECK(
fp_equal( y[2], sqrtf(33.f) ) );
1630 CHECK(
fp_equal( y[3], sqrtf(44.f) ) );
1636 vhypot(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f);
1637 CHECK(
fp_equal( y[0], hypotf(11.f,22.f) ) );
1638 CHECK(
fp_equal( y[1], hypotf(33.f,44.f) ) );
1639 CHECK(
fp_equal( y[2], hypotf(55.f,66.f) ) );
1640 CHECK(
fp_equal( y[3], hypotf(77.f,88.f) ) );
1646 vsqrt(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f);
1647 CHECK(
fp_equal( y[0], sqrtf(11.f) ) );
1648 CHECK(
fp_equal( y[1], sqrtf(22.f) ) );
1649 CHECK(
fp_equal( y[2], sqrtf(33.f) ) );
1650 CHECK(
fp_equal( y[3], sqrtf(44.f) ) );
1651 CHECK(
fp_equal( y[4], sqrtf(55.f) ) );
1652 CHECK(
fp_equal( y[5], sqrtf(66.f) ) );
1653 CHECK(
fp_equal( y[6], sqrtf(77.f) ) );
1654 CHECK(
fp_equal( y[7], sqrtf(88.f) ) );
1660 vhypot(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f,111.f,122.f,133.f,144.f,155.f,166.f,177.f,188.f);
1661 CHECK(
fp_equal( y[0], hypotf(11.f,22.f) ) );
1662 CHECK(
fp_equal( y[1], hypotf(33.f,44.f) ) );
1663 CHECK(
fp_equal( y[2], hypotf(55.f,66.f) ) );
1664 CHECK(
fp_equal( y[3], hypotf(77.f,88.f) ) );
1665 CHECK(
fp_equal( y[4], hypotf(111.f,122.f) ) );
1666 CHECK(
fp_equal( y[5], hypotf(133.f,144.f) ) );
1667 CHECK(
fp_equal( y[6], hypotf(155.f,166.f) ) );
1668 CHECK(
fp_equal( y[7], hypotf(177.f,188.f) ) );
1674 vsqrt(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f,111.f,122.f,133.f,144.f,155.f,166.f,177.f,188.f);
1675 CHECK(
fp_equal( y[0], sqrtf(11.f) ) );
1676 CHECK(
fp_equal( y[1], sqrtf(22.f) ) );
1677 CHECK(
fp_equal( y[2], sqrtf(33.f) ) );
1678 CHECK(
fp_equal( y[3], sqrtf(44.f) ) );
1679 CHECK(
fp_equal( y[4], sqrtf(55.f) ) );
1680 CHECK(
fp_equal( y[5], sqrtf(66.f) ) );
1681 CHECK(
fp_equal( y[6], sqrtf(77.f) ) );
1682 CHECK(
fp_equal( y[7], sqrtf(88.f) ) );
1683 CHECK(
fp_equal( y[8], sqrtf(111.f) ) );
1684 CHECK(
fp_equal( y[9], sqrtf(122.f) ) );
1685 CHECK(
fp_equal( y[10], sqrtf(133.f) ) );
1686 CHECK(
fp_equal( y[11], sqrtf(144.f) ) );
1687 CHECK(
fp_equal( y[12], sqrtf(155.f) ) );
1688 CHECK(
fp_equal( y[13], sqrtf(166.f) ) );
1689 CHECK(
fp_equal( y[14], sqrtf(177.f) ) );
1690 CHECK(
fp_equal( y[15], sqrtf(188.f) ) );
1697 x = -numeric_limits<double>().infinity();
1698 CHECK_THROW(
vasinh(y,x,x,x,x), domain_error );
1699 x = numeric_limits<double>().infinity();
1700 CHECK_THROW(
vasinh(y,x,x,x,x), domain_error );
1701 x = -numeric_limits<double>().quiet_NaN();
1702 CHECK_THROW(
vasinh(y,x,x,x,x), domain_error );
1705 CHECK( y[0] == 0. );
1707 const int sz = 2048;
1711 for(
int i=0; i < sz; ++i )
1717 vasinh( arg, val, 0, sz );
1718 for(
int i=0; i < sz; ++i )
1719 CHECK(
fp_equal( val[i], asinh(arg[i]) ) );
1725 TEST(TestVasinhdFast)
1729 x = -numeric_limits<double>().infinity();
1730 CHECK_THROW(
vfast_asinh(y,x,x,x,x), domain_error );
1731 x = numeric_limits<double>().infinity();
1732 CHECK_THROW(
vfast_asinh(y,x,x,x,x), domain_error );
1733 x = numeric_limits<double>().quiet_NaN();
1734 CHECK_THROW(
vfast_asinh(y,x,x,x,x), domain_error );
1736 CHECK_THROW(
vfast_asinh(y,x,x,x,x), domain_error );
1737 double z = sqrt(DBL_MAX);
1738 x = nextafter(z,DBL_MAX);
1739 CHECK_THROW(
vfast_asinh(y,x,x,x,x), domain_error );
1740 x = nextafter(z,-DBL_MAX);
1742 CHECK( y[0] > 0. && y[0] < DBL_MAX );
1745 CHECK( y[0] == 0. );
1747 const int sz = 2048;
1751 for(
int i=0; i < sz; ++i )
1752 arg[i] = exp(genrand_real1()*1063.28-708.39);
1754 for(
int i=0; i < sz; ++i )
1755 CHECK(
fp_equal( val[i], asinh(arg[i]) ) );
1765 x = -numeric_limits<sys_float>().infinity();
1766 CHECK_THROW(
vasinh(y,x,x,x,x), domain_error );
1767 x = numeric_limits<sys_float>().infinity();
1768 CHECK_THROW(
vasinh(y,x,x,x,x), domain_error );
1769 x = numeric_limits<sys_float>().quiet_NaN();
1770 CHECK_THROW(
vasinh(y,x,x,x,x), domain_error );
1773 CHECK( y[0] == 0.f );
1775 const int sz = 2048;
1779 for(
int i=0; i < sz; ++i )
1785 vasinh( arg, val, 0, sz );
1786 for(
int i=0; i < sz; ++i )
1787 CHECK(
fp_equal( val[i], asinhf(arg[i]) ) );
1793 TEST(TestVasinhfFast)
1797 x = -numeric_limits<sys_float>().infinity();
1798 CHECK_THROW(
vfast_asinh(y,x,x,x,x), domain_error );
1799 x = numeric_limits<sys_float>().infinity();
1800 CHECK_THROW(
vfast_asinh(y,x,x,x,x), domain_error );
1801 x = numeric_limits<sys_float>().quiet_NaN();
1802 CHECK_THROW(
vfast_asinh(y,x,x,x,x), domain_error );
1804 CHECK_THROW(
vfast_asinh(y,x,x,x,x), domain_error );
1806 x = nextafterf(z,FLT_MAX);
1807 CHECK_THROW(
vfast_asinh(y,x,x,x,x), domain_error );
1808 x = nextafterf(z,-FLT_MAX);
1810 CHECK( y[0] > 0.f && y[0] < FLT_MAX );
1813 CHECK( y[0] == 0.f );
1815 const int sz = 2048;
1819 for(
int i=0; i < sz; ++i )
1820 arg[i] = exp(genrand_real1()*131.69-87.33);
1822 for(
int i=0; i < sz; ++i )
1823 CHECK(
fp_equal( val[i], asinhf(arg[i]) ) );
1832 vasinh(y,11.,22.,33.,44.);
1833 CHECK(
fp_equal( y[0], asinh(11.) ) );
1834 CHECK(
fp_equal( y[1], asinh(22.) ) );
1835 CHECK(
fp_equal( y[2], asinh(33.) ) );
1836 CHECK(
fp_equal( y[3], asinh(44.) ) );
1839 TEST(TestVasinhdFastx4)
1843 CHECK(
fp_equal( y[0], asinh(11.) ) );
1844 CHECK(
fp_equal( y[1], asinh(22.) ) );
1845 CHECK(
fp_equal( y[2], asinh(33.) ) );
1846 CHECK(
fp_equal( y[3], asinh(44.) ) );
1852 vasinh(y,11.,22.,33.,44.,55.,66.,77.,88.);
1853 CHECK(
fp_equal( y[0], asinh(11.) ) );
1854 CHECK(
fp_equal( y[1], asinh(22.) ) );
1855 CHECK(
fp_equal( y[2], asinh(33.) ) );
1856 CHECK(
fp_equal( y[3], asinh(44.) ) );
1857 CHECK(
fp_equal( y[4], asinh(55.) ) );
1858 CHECK(
fp_equal( y[5], asinh(66.) ) );
1859 CHECK(
fp_equal( y[6], asinh(77.) ) );
1860 CHECK(
fp_equal( y[7], asinh(88.) ) );
1863 TEST(TestVasinhdFastx8)
1867 CHECK(
fp_equal( y[0], asinh(11.) ) );
1868 CHECK(
fp_equal( y[1], asinh(22.) ) );
1869 CHECK(
fp_equal( y[2], asinh(33.) ) );
1870 CHECK(
fp_equal( y[3], asinh(44.) ) );
1871 CHECK(
fp_equal( y[4], asinh(55.) ) );
1872 CHECK(
fp_equal( y[5], asinh(66.) ) );
1873 CHECK(
fp_equal( y[6], asinh(77.) ) );
1874 CHECK(
fp_equal( y[7], asinh(88.) ) );
1880 vasinh(y,11.f,22.f,33.f,44.f);
1881 CHECK(
fp_equal( y[0], asinhf(11.f) ) );
1882 CHECK(
fp_equal( y[1], asinhf(22.f) ) );
1883 CHECK(
fp_equal( y[2], asinhf(33.f) ) );
1884 CHECK(
fp_equal( y[3], asinhf(44.f) ) );
1887 TEST(TestVasinhfFastx4)
1891 CHECK(
fp_equal( y[0], asinhf(11.f) ) );
1892 CHECK(
fp_equal( y[1], asinhf(22.f) ) );
1893 CHECK(
fp_equal( y[2], asinhf(33.f) ) );
1894 CHECK(
fp_equal( y[3], asinhf(44.f) ) );
1900 vasinh(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f);
1901 CHECK(
fp_equal( y[0], asinhf(11.f) ) );
1902 CHECK(
fp_equal( y[1], asinhf(22.f) ) );
1903 CHECK(
fp_equal( y[2], asinhf(33.f) ) );
1904 CHECK(
fp_equal( y[3], asinhf(44.f) ) );
1905 CHECK(
fp_equal( y[4], asinhf(55.f) ) );
1906 CHECK(
fp_equal( y[5], asinhf(66.f) ) );
1907 CHECK(
fp_equal( y[6], asinhf(77.f) ) );
1908 CHECK(
fp_equal( y[7], asinhf(88.f) ) );
1911 TEST(TestVasinhfFastx8)
1914 vfast_asinh(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f);
1915 CHECK(
fp_equal( y[0], asinhf(11.f) ) );
1916 CHECK(
fp_equal( y[1], asinhf(22.f) ) );
1917 CHECK(
fp_equal( y[2], asinhf(33.f) ) );
1918 CHECK(
fp_equal( y[3], asinhf(44.f) ) );
1919 CHECK(
fp_equal( y[4], asinhf(55.f) ) );
1920 CHECK(
fp_equal( y[5], asinhf(66.f) ) );
1921 CHECK(
fp_equal( y[6], asinhf(77.f) ) );
1922 CHECK(
fp_equal( y[7], asinhf(88.f) ) );
1925 TEST(TestVasinhfx16)
1928 vasinh(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f,111.f,122.f,133.f,144.f,155.f,166.f,177.f,188.f);
1929 CHECK(
fp_equal( y[0], asinhf(11.f) ) );
1930 CHECK(
fp_equal( y[1], asinhf(22.f) ) );
1931 CHECK(
fp_equal( y[2], asinhf(33.f) ) );
1932 CHECK(
fp_equal( y[3], asinhf(44.f) ) );
1933 CHECK(
fp_equal( y[4], asinhf(55.f) ) );
1934 CHECK(
fp_equal( y[5], asinhf(66.f) ) );
1935 CHECK(
fp_equal( y[6], asinhf(77.f) ) );
1936 CHECK(
fp_equal( y[7], asinhf(88.f) ) );
1937 CHECK(
fp_equal( y[8], asinhf(111.f) ) );
1938 CHECK(
fp_equal( y[9], asinhf(122.f) ) );
1939 CHECK(
fp_equal( y[10], asinhf(133.f) ) );
1940 CHECK(
fp_equal( y[11], asinhf(144.f) ) );
1941 CHECK(
fp_equal( y[12], asinhf(155.f) ) );
1942 CHECK(
fp_equal( y[13], asinhf(166.f) ) );
1943 CHECK(
fp_equal( y[14], asinhf(177.f) ) );
1944 CHECK(
fp_equal( y[15], asinhf(188.f) ) );
1947 TEST(TestVasinhfFastx16)
1950 vfast_asinh(y,11.f,22.f,33.f,44.f,55.f,66.f,77.f,88.f,111.f,122.f,133.f,144.f,155.f,166.f,177.f,188.f);
1951 CHECK(
fp_equal( y[0], asinhf(11.f) ) );
1952 CHECK(
fp_equal( y[1], asinhf(22.f) ) );
1953 CHECK(
fp_equal( y[2], asinhf(33.f) ) );
1954 CHECK(
fp_equal( y[3], asinhf(44.f) ) );
1955 CHECK(
fp_equal( y[4], asinhf(55.f) ) );
1956 CHECK(
fp_equal( y[5], asinhf(66.f) ) );
1957 CHECK(
fp_equal( y[6], asinhf(77.f) ) );
1958 CHECK(
fp_equal( y[7], asinhf(88.f) ) );
1959 CHECK(
fp_equal( y[8], asinhf(111.f) ) );
1960 CHECK(
fp_equal( y[9], asinhf(122.f) ) );
1961 CHECK(
fp_equal( y[10], asinhf(133.f) ) );
1962 CHECK(
fp_equal( y[11], asinhf(144.f) ) );
1963 CHECK(
fp_equal( y[12], asinhf(155.f) ) );
1964 CHECK(
fp_equal( y[13], asinhf(166.f) ) );
1965 CHECK(
fp_equal( y[14], asinhf(177.f) ) );
1966 CHECK(
fp_equal( y[15], asinhf(188.f) ) );
void avx_free(void *p_ptr_alloc)
void vlog10(const double x[], double y[], long nlo, long nhi)
void vfast_asinh(const double x[], double y[], long nlo, long nhi)
void invalidate_array(T *p, size_t size)
ALIGNED(CD_ALIGN) static const double qg32_w[numPoints]
void vlog1p(const double x[], double y[], long nlo, long nhi)
void vhypot(const double x1[], const double x2[], double y[], long nlo, long nhi)
unsigned long genrand_int32()
void vlog(const double x[], double y[], long nlo, long nhi)
double reduce_a(const double *a, long ilo, long ihi)
void * avx_alloc(size_t sz)
void vexp(const double x[], double y[], long nlo, long nhi)
bool fp_equal(sys_float x, sys_float y, int n=3)
void vexp10(const double x[], double y[], long nlo, long nhi)
double reduce_abc_ab(const double *a, const double *b, const double *c, long ilo, long ihi, double *sum_ab)
void vasinh(const double x[], double y[], long nlo, long nhi)
double reduce_ab(const double *a, const double *b, long ilo, long ihi)
double reduce_ab_a(const double *a, const double *b, long ilo, long ihi, double *sum_a)
void vsqrt(const double x[], double y[], long nlo, long nhi)
double reduce_abc(const double *a, const double *b, const double *c, long ilo, long ihi)
void init_genrand(unsigned long s)
void vexpm1(const double x[], double y[], long nlo, long nhi)