Example #1
0
File: texp.c Project: jozip/xcl
/* worst cases communicated by Jean-Michel Muller and Vincent Lefevre */
static int
check_worst_cases (void)
{
    mpfr_t x;
    mpfr_t y;

    mpfr_init(x);
    mpfr_set_prec (x, 53);

    check_worst_case("4.44089209850062517562e-16", "1.00000000000000022204");
    check_worst_case("6.39488462184069720009e-14", "1.00000000000006372680");
    check_worst_case("1.84741111297455401935e-12", "1.00000000000184718907");
    check_worst_case("1.76177628026265550074e-10", "1.00000000017617751702");
    check3("1.76177628026265550074e-10", MPFR_RNDN, "1.00000000017617773906");
    check_worst_case("7.54175277499595900852e-10", "1.00000000075417516676");
    check3("7.54175277499595900852e-10", MPFR_RNDN, "1.00000000075417538881");
    /* bug found by Vincent Lefe`vre on December 8, 1999 */
    check3("-5.42410311287441459172e+02", MPFR_RNDN, "2.7176584868845723e-236");
    /* further cases communicated by Vincent Lefe`vre on January 27, 2000 */
    check3("-1.32920285897904911589e-10", MPFR_RNDN, "0.999999999867079769622");
    check3("-1.44037948245738330735e-10", MPFR_RNDN, "0.9999999998559621072757");
    check3("-1.66795910430705305937e-10", MPFR_RNDZ, "0.9999999998332040895832");
    check3("-1.64310953745426656203e-10", MPFR_RNDN, "0.9999999998356891017792");
    check3("-1.38323574826034659172e-10", MPFR_RNDZ, "0.9999999998616764251835");
    check3("-1.23621668465115401498e-10", MPFR_RNDZ, "0.9999999998763783315425");

    mpfr_set_prec (x, 601);
    mpfr_set_str (x, "0.88b6ba510e10450edc258748bc9dfdd466f21b47ed264cdf24aa8f64af1f3fad9ec2301d43c0743f534b5aa20091ff6d352df458ef1ba519811ef6f5b11853534fd8fa32764a0a6d2d0dd20@0", 16, MPFR_RNDZ);
    mpfr_init2 (y, 601);
    mpfr_exp_2 (y, x, MPFR_RNDD);
    mpfr_exp_3 (x, x, MPFR_RNDD);
    if (mpfr_cmp (x, y))
    {
        printf ("mpfr_exp_2 and mpfr_exp_3 differ for prec=601\n");
        printf ("mpfr_exp_2 gives ");
        mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
        printf ("\nmpfr_exp_3 gives ");
        mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN);
        printf ("\n");
        exit (1);
    }

    mpfr_set_prec (x, 13001);
    mpfr_set_prec (y, 13001);
    mpfr_urandomb (x, RANDS);
    mpfr_exp_3 (y, x, MPFR_RNDN);
    mpfr_exp_2 (x, x, MPFR_RNDN);
    if (mpfr_cmp (x, y))
    {
        printf ("mpfr_exp_2 and mpfr_exp_3 differ for prec=13001\n");
        exit (1);
    }

    mpfr_clear (x);
    mpfr_clear (y);
    return 0;
}
Example #2
0
int main(int argc, char** argv) {
  std::cout.precision(10);
  options opt(argc, argv, 14);
  if (!opt.valid) std::abort();
  boost::timer tm;
  double t1 = tm.elapsed();

  // lattice structure
  int n = opt.N;
  int ibond = n;
  std::vector<int> ipair;
  for (int i = 0; i < ibond; ++i) {
    ipair.push_back(i);
    ipair.push_back((i + 1) % n);
  }

  // Hamiltonian parameters
  std::vector<double> bondwt(ibond, -1);
  std::vector<double> zrtio(ibond, 1);

  // table of configurations and Hamiltonian operator
  subspace ss(n, 0);
  hamiltonian hop(ss, ipair, bondwt, zrtio);

  // Hamiltonian matrix
  matrix_type elemnt;
  elm3(hop, elemnt);
  double t2 = tm.elapsed();
  
  std::vector<double> E;
  matrix_type v;
  int nvec = 1;
  diag(elemnt, E, v, nvec);
  double t3 = tm.elapsed();

  int ne = 4;
  std::cout << "[Eigenvalues]\n";
  for (int i = 0; i < ne; ++i) std::cout << '\t' << E[i];
  std::cout << std::endl;

  // // Do not forget to call elm3 again before calling check3
  elm3(hop, elemnt);
  check3(elemnt, v, 0);
  double t4 = tm.elapsed();
  
  std::vector<int> npair;
  npair.push_back(1);
  npair.push_back(2);
  std::vector<double> sxx(1);
  xcorr(ss, npair, v, 0, sxx);
  std::cout << "sxx: " << sxx[0] << std::endl;
  std::vector<double> szz(1);
  zcorr(ss, npair, v, 0, szz);
  std::cout << "szz: " << szz[0] << std::endl;
  double t5 = tm.elapsed();
  std::cerr << "initialize      " << (t2-t1) << " sec\n"
            << "diagonalization " << (t3-t2) << " sec\n"
            << "check           " << (t4-t3) << " sec\n"
            << "correlation     " << (t5-t4) << " sec\n";
}
Example #3
0
int main()
{
      int tmp;
      long int len;
      long int i;
      long int ctr;
      char str[256];
      while (scanf("%s", str) != EOF) {
            int arr[10] = {0};
            len = strlen(str);
            ctr = 0;
            if (len < 2) {
                  printf("1\n");
                  continue;
            }
            arr[1] = 1;
            arr[2] = ((str[len-1]-'0')%2 == 0);
            arr[3] = (check3(str));
            arr[4] = (((str[len-1] - '0') + (str[len-2] - '0')*10)%4 == 0);
            arr[5] = ((str[len-1]-'0')%5 == 0);
            arr[6] = (!(!(((str[len-1]-'0')%2 == 0 ) && arr[3])));
            arr[7] = check7(str);
            arr[8] = (check8(str));
            arr[9] = (check9(str));

            for (i =0 ;i<len; i++) {
                  tmp = (str[i] - '0');
                  ctr = ctr + arr[tmp];
            }
            printf("%ld\n", ctr);
      }
      return 0;
}
Example #4
0
void State::updateLine(const Test & test)
{
    size_t i = 0;
    Block old = SPACE;
    while (i < test->line.size()) {
        if (old != test->line[i] && test->line[i] != SPACE) {
            bool win = check5(test, i);
            if (win) {
                _winner = get(test->position[i]);
            }
            else {
                auto attackable = check4(test, i);
                if (attackable->rank != NONE) {
                    _attackables.push_back(attackable);
                } else {
                    auto attackable = check3(test, i);
                    if (attackable->rank != NONE) {
                        _attackables.push_back(attackable);
                    } else {
                        auto attackable = check(test, i);
                        if (attackable->rank != NONE) {
                            _attackables.push_back(attackable);
                        }
                    }
                }
            }
        }
        old = test->line[i];
        ++i;
    }
}
Example #5
0
int main()
{
	int p[8], i, j;

	while (gets(buf)) {
		memset(p, 0, sizeof(p));
		p[1] = check1();
		if (p[1]) {
			p[2] = ispal(s2);
			p[3] = check3();
			p[4] = check4();
			p[5] = check5();
			p[6] = check6();
			p[7] = check7();
		}

		for (i = 1, j = 1; i <= 7; i++) {
			putchar(p[i] ? 'T' : 'F');
			j &= p[i];
		}
		printf(" The solution is %s\n", j ? "accepted" : "not accepted");
	}

	return 0;
}
Example #6
0
char		*check_format2(char *str, char **tmp, int size, char **piece)
{
	int		j;
	int		a;

	j = I;
	a = 0;
	while (I + a <= size && !check(str[I + a]) && str[I + a] != '\0')
		a++;
	a++;
	if (I < size && str[I - 1] == '%' && check(str[I + (a - 1)]))
		if (!(check3(&str[I - 1], a)))
			a--;
	if (!check(str[I]) && str[I - 1] == '%' && str[I - 2] == '%')
		*tmp = ft_strsub(str, I - 1, a--);
	else if (I < size && str[I - 1] == '%' && str[I] != '%')
		*tmp = ft_strsub(str, I - 1, a + 1);
	else if (I < size)
		*tmp = ft_strsub(str, I, a);
	I += a;
	if (I >= size)
		I = size;
	*piece = ft_strdup(*tmp);
	ft_strdel(tmp);
	return (*piece);
}
double AngularGradient_dfy1(Vector v0, Vector v1, Vector v2, double w, int mass) {
    double x0, y0, x1, y1, x2, y2;
    x0 = v0.x; 
    y0 = v0.y; 
    x1 = v1.x; 
    y1 = v1.y; 
    x2 = v2.x; 
    y2 = v2.y; 
    double a00 = -x1 + x2;
    double a01 = x0 - x1;
    double a02 = y0 - y1;
    double a03 = -y1 + y2;
    double a04 = 2 * M_PI / mass;
    double a05 = -y0 + 2 * y1 - y2;

    double b00 = pow(a01, 2);
    double b01 = pow(a02, 2);
    double b02 = pow(a00, 2);
    double b04 = pow(a03, 2);
    double b05 = a01 * a00 + a02 * a03;

    double c00 = sqrt(b00 + b01);
    double c01 = sqrt(b02 + b04);
    double c02 = pow(b00 + b01, 1.5);
    double c03 = pow(b05, 2);
    double c04 = pow(b02 + b04, 1.5);
    double c05 = b00 + b01;
    double c06 = b02 + b04;
    double c08 = a02 * b05;
    double c10 = a03 * b05;

    double d00 = c00 * c01;
    double d01 = c02 * c01;
    double d03 = c05 * c06;
    double d04 = c00 * c04;
    check3(&d00, &d01, &d03, &d04);
    /*assert(!Util_is_zero(d00));*/
    /*assert(!Util_is_zero(d01));*/
    /*assert(!Util_is_zero(d03));*/
    /*assert(!Util_is_zero(d04));*/

    double e02 = b05 / d00;
    double e03 = c03 / d03;
    double e05 = c08 / d01;
    double e09 = c10 / d04;
    double e11 = a05 / d00;
    check1(&e02, &e03);

    double f01 = acosf(e02);
    double f02 = sqrt(1 - e03);
    double f05 = e09 +e11 +e05;
    check2(&f02);

    double g00 = a04 - f01;

    double h03 = (2*w*f05*g00);
    
    return h03/f02;
}
Example #8
0
int main(void) {
	check1();
	printf("--------------------------------------");
	check2();
	printf("--------------------------------------");
	check3();
	printf("--------------------------------------");

	return 0;
}
Example #9
0
bool Control::check(std::vector<int> &n)
{
    getOutCard(n);

    bool result=false;
    switch (n.size())
    {
    case 1:
        result=check1();
        break;
    case 2:
        result=check2();
        break;
    case 3:
        result=check3();
        break;
    case 4:
        result=check4();
        break;
    case 5:
        result=check5();
        break;
    case 6:
        result=check6();
        break;
    case 7:
    case 11:
    case 13:
        result=check7();
        break;
    case 8:
        result=check8();
        break;
    case 9:
        result=check9();
        break;
    case 10:
        result=check10();
        break;
    case 12:
        result=check12();
        break;
    case 14:
        result=check14();
        break;
    case 15:
        result=check15();
        break;
    case 16:
        result=check16();
        break;
    }
    return result;
}
Example #10
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  check1 ();
  check2 ();
  check3 ();

  tests_end_mpfr ();
  return 0;
}
Example #11
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  check_nans ();

  special ();
  check3 ("-1.716113812768534e-140", 1271212614, MPFR_RNDZ,
          "1.27121261399999976e9");
  check3 ("1.22191250737771397120e+20", 948002822, MPFR_RNDN,
          "122191250738719408128.0");
  check3 ("-6.72658901114033715233e-165", 2000878121, MPFR_RNDZ,
          "2.0008781209999997615e9");
  check3 ("-2.0769715792901673e-5", 880524, MPFR_RNDN,
          "8.8052399997923023e5");
  test_generic_ui (2, 1000, 100);

  tests_end_mpfr ();
  return 0;
}
Example #12
0
int main()
{
  zeropad();
  printfield();
  calculate();
  if (check1() || check2() || check3())
    printf("No solution\n");
  else
    if (solve())
      drawpath();
    else
      printf("Path not found\n");
  return 0;
}
Example #13
0
bool judge()
{
	if(2 * m <= x && x <= 6 * m && x % m == 0)
		return true;
	if(check2(x - m, 1))
		return true;
	if(check2(x - 2 * m, 0))
		return true;
	if(check1(x - 3 * m, 0))
		return true;
	if(check1(x - 4 * m, 0))
		return true;
	return check3(x);
}
Example #14
0
void play()
{
	char ar[3][3];
	int r,c,b=0;

	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			ar[i][j]='~';
		}
	}

	for(i=1;i<=9;i++)
	{
		if(i%2==1)
		{
			a1:
			cout<<"\n\tEnter a CROSS (X):\n\n";
			cout<<"\tEnter row and column:";
			cin>>r>>c;

			if(ar[r-1][c-1]=='~'&&r<=3&&c<=3)
			{
				ar[r-1][c-1]='X';
			}

			else
			{
				cout<<"\tWrong parameters inputed ! ! !\tEnter again ! !\n";
				goto a1;
			}
			output(ar);

			if(check1(ar,'X')==3||check2(ar,'X')==3||check3(ar,'X')==3||check4(ar,'X')==3)
			{
				cout<<"\t****PLAYER MARKING WITH X SIGN WINS!**** \n\n\tCONGRATULATIONS\n\n";
				b=1;
				cout<<"\tPRESS ANY KEY FOR MAIN MENU:";
				getch();
				break;
			}

		}

		else
		{
Example #15
0
int
main (int argc, char *argv[])
{
  int h;

  if (argc == 5)
    {
      check_random (atoi (argv[1]), atoi (argv[2]), atoi (argv[3]),
                    (mpfr_rnd_t) atoi (argv[4]));
      return 0;
    }

  tests_start_mpfr ();

  if (argc != 1)
    {
      fprintf (stderr, "Usage: tsum\n       tsum n k prec rnd\n");
      exit (1);
    }

  check_simple ();
  check_special ();
  check_more_special ();
  for (h = 0; h <= 64; h++)
    check1 (h);
  check2 ();
  check3 ();
  check4 ();
  bug20131027 ();
  bug20150327 ();
  bug20160315 ();
  generic_tests ();
  check_extreme ();
  cancel ();
  check_overflow ();
  check_underflow ();

  check_coverage ();
  tests_end_mpfr ();
  return 0;
}
Example #16
0
int
main (int argc, char *argv[])
{
  mpfr_prec_t p;
  int k;

  tests_start_mpfr ();

  check_nans ();

  for (p=2; p<200; p++)
    for (k=0; k<200; k++)
      check_two_sum (p);

  check3 ("0.9999999999", 1, MPFR_RNDN,
          "-10000000827403709990903735160827636718750e-50");

  test_generic_ui (2, 1000, 100);

  tests_end_mpfr ();
  return 0;
}
int check(int length1, float *number3, int *oper3){
	if (length1 == 1)
		return check1(number3,oper3);
	if (length1 == 2)
		return check2(number3,oper3);
	if (length1 == 3)
		return check3(number3,oper3);
	if (length1 == 4)
		return check4(number3,oper3);
	if (length1 == 5)
		return check5(number3,oper3);
	if (length1 == 6)
		return check6(number3,oper3);
	if (length1 == 7)
		return check7(number3,oper3);
	if (length1 == 8)
		return check8(number3,oper3);
	if (length1 == 9)
		return check9(number3,oper3);
	if (length1 == 10)
		return check10(number3,oper3);
	return 0;
}
Example #18
0
int
main (int argc, char** argv)
{
  double x = 2.0;
  double y = -5.0;
  double epsilon = 0.00001;

  double expected = -2.0;

  if (fabs (check (x, y) - expected) >= epsilon)
    __builtin_abort ();

  expected = 2.0;

  if (fabs (check1 (x) - expected) >= epsilon)
    __builtin_abort ();

  expected = 1.0;

  if (fabs (check2 (x) - expected) >= epsilon)
    __builtin_abort ();

  expected = -2.0;

  if (fabs (check3 (x) - expected) >= epsilon)
    __builtin_abort ();

  expected = -4.0;

  if (fabs (check4 (x, y) - expected) >= epsilon)
    __builtin_abort ();

  expected = 2.0;

  if (fabs (check5 (x, y) - expected) >= epsilon)
    __builtin_abort ();
}
Example #19
0
File: 1_2_2.cpp Project: SamJia/Oj
int main(){
	freopen("transform.in", "r", stdin);
	freopen("transform.out", "w", stdout);
	scanf("%d", &total_length);
	for(int i = 0; i < total_length; ++i)
		scanf("%s", before[i]);
	for(int i = 0; i < total_length; ++i)
		scanf("%s", after[i]);
	if(check1())
		printf("1\n");
	else if(check2())
		printf("2\n");
	else if(check3())
		printf("3\n");
	else if(check4())
		printf("4\n");
	else if(check5())
		printf("5\n");
	else if(check6())
		printf("6\n");
	else
		printf("7\n");
	return 0;
}
Example #20
0
void main()
{
	char c2;
	int done, high,i, in, low;
	int x,y=1,z;
	int c;
	printstr("if then else(6 line block repeated)\n");
	printstr("x = 5\nx = 5\nx = 1\nx = 7	z = 0\nx = 3	z = 0\nx = 3	z = 1\n");
	if (y!=0) x=5;
	PRINT1(d,x);

	if (y==0) x=3;
	else x=5;
	PRINT1(d,x);

	x=1;
	if (y<00) if (y>0) x=3;
	else x=5;
	PRINT1(d,x);

	if (z=y<0) x=3;
	else if (y==0) x=5;
	else x=7;
	PRINT2(d,x,z);

	if (z=(y==0)) x=5; x=3;
	PRINT2(d,x,z);

	if (x=z=y) x=3;
	PRINT2(d,x,z);

	printstr("for & while(just look for checkfail msgs)\n");

	x=y=0;
	while (y<10) ++y; x+=y;;
	PRINT2(d,x,y); check2(x==10,y==10);

	x=y=0;
	while (y<10) x+= ++y;
	PRINT2(d,x,y); check2(x==55,y==10);

	y=1;;
	while (y<10) {
		x=y++; z=++y;
	}
	PRINT3(d,x,y,z); check3(x==9,y==11,z==11);

	for (y=1; y<10; y++) x=y;
	PRINT2(d,x,y);
	check2(x==9,y==10);

	for (y=1; (x=y)<10; y++) ;
	PRINT2(d,x,y); check2(x==10,y==10);

	for (x=0, y=1000; y>1; x++, y/=10)
	PRINT2(d,x,y);
	check2(x==3,y==1);
printstr(" nested statements(look for checkfails)\n");
#define ENUF 3
#define EOS '\0'
#define NEXT(i) input[i++]
#define FALSE 0
#define TRUE 1

	i=low=in=high=0;
	while( c=NEXT(i) !=EOS )
		if( c<'0' ) low++;
		else if( c>'9' ) high++;
		else in++;
	PRINT3 (d,low, in, high) ; check3(low==25,in==0, high==0);
	i=low=in=high=0; done=FALSE;
	while( (c=NEXT(i))!=EOS && !done )
		if( c<'0' ) low++;
		else if( c>'9' ) high++;
		else in++;
		if( low>=ENUF|| high>=ENUF|| in>=ENUF )
			done = TRUE;
	PRINT3(d,low,in,high); check3(low==3,in==6, high==16);

	i=low=in=high=0; done=FALSE;
	while( (c=NEXT(i))!=EOS && !done )
		if( c<'0' ) done=(++low==ENUF);
		else if( c>'9' ) done = (++high==ENUF);
		else done =(++in==ENUF);
	PRINT3(d,low,in,high); check3(low==0,in==0, high==3);

	printstr("switch/break/continue(prints SWITCH SWAMP\n");
	for( i=2; (c2=inpu2[i])!='\0'; i++) {
		switch(c2) {
			case 'a': putchar('i'); continue;
			case '1': break;
			case 1: while( (c2=inpu2[++i])!='\1'  && c2!='\0');
			case 9: putchar('S');
			case 'E': case 'L': continue;
			default: putchar(c2); continue;
		}
		putchar(' ');
	}
	putchar('\n');
printstr("And we're done\n");
}
Example #21
0
bool State::isForbidden(Position p, Block b, const Test &test) const
{
    bool isForbidden = true;

    size_t count33 = 0;
    auto check33 = [&](Test t) {
        auto iter = std::find(t->position.cbegin(), t->position.cend(), p);
        assert(iter != t->position.cend());
        size_t i = iter - t->position.cbegin();
        assert(i < t->line.size());
        t->line[i] = b;

        size_t count = 0;
        for (size_t j = i+1; j < t->line.size(); ++j) {
            if (t->line[j] != b)
                break;
            ++count;
        }

        bool isS3 = false;

        if (isS3 == false  && count < 3 && i > 0 && t->line[i - 1] == SPACE) {
            auto attackable = check3(t, i);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }

        if (isS3 == false && count < 2 && i > 1 && t->line[i - 1] == b && t->line[i - 2] == SPACE) {
            auto attackable = check3(t, i - 1);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }

        if (isS3 == false && count == 0 && i > 2 && t->line[i - 1] == b && t->line[i - 2] == b && t->line[i - 3] == SPACE) {
            auto attackable = check3(t, i - 2);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }

        if (isS3 == false && count < 2 && i > 2 && t->line[i - 1] == SPACE && t->line[i - 2] == b && t->line[i - 3] == SPACE) {
            auto attackable = check3(t, i - 2);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }
        if (isS3 == false && count == 0 &&  i > 3 && t->line[i - 1] == SPACE && t->line[i - 2] == b && t->line[i - 3] == b && t->line[i  - 4] == SPACE) {
            auto attackable = check3(t, i - 3);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }
        if (isS3 == false && count == 0 && i > 3 && t->line[i - 1] == b && t->line[i - 2] == SPACE && t->line[i - 3] == b && t->line[i - 4] == SPACE) {
            auto attackable = check3(t, i - 3);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }
        if (isS3) {
            ++count33;
        }
    };

    if (get(p) == SPACE) {
        isForbidden = false;
        auto vertical = getVertical(p);
        auto horizontal = getHorizontal(p);
        auto diagonalA = getDiagonalA(p);
        auto diagonalB = getDiagonalB(p);
        if (test) {
            if (vertical->position.front() == test->position.front()
                && vertical->position.back() == test->position.back()) {
                vertical = test;
            }
            else if (horizontal->position.front() == test->position.front()
                && horizontal->position.back() == test->position.back()) {
                horizontal = test;
            }
            else if (diagonalA->position.front() == test->position.front()
                && diagonalA->position.back() == test->position.back()) {
                diagonalA = test;
            }
            else if (diagonalB->position.front() == test->position.front()
                && diagonalB->position.back() == test->position.back()) {
                diagonalB = test;
            }
        }

        Rule *rule = b == BLACK ? Rule::getBlack() : Rule::getWhite();
        if (rule->getThreeAndThree() == false) {
            check33(vertical);
            check33(horizontal);
            if (diagonalA->line.size() > 0) {
                check33(diagonalA);
            }
            if (diagonalB->line.size() > 0) {
                check33(diagonalB);
            }
            if (count33 > 1) {
                isForbidden = true;
            }
        }
    }
    return isForbidden;
}
Example #22
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  if (argc==4)
    {   /* tlog x prec rnd */
      check3 (atof(argv[1]), atoi(argv[2]), (mp_rnd_t) atoi(argv[3]));
      goto done;
    }

  special ();
  check_worst_cases();

  check2("1.01979300812244555452", GMP_RNDN, "1.95996734891603664741e-02");
  check2("10.0",GMP_RNDU,"2.30258509299404590110e+00");
  check2("6.0",GMP_RNDU,"1.79175946922805517936");
  check2("1.0",GMP_RNDZ,"0.0");
  check2("62.0",GMP_RNDU,"4.12713438504509166905");
  check2("0.5",GMP_RNDZ,"-6.93147180559945286226e-01");
  check2("3.0",GMP_RNDZ,"1.09861228866810956006e+00");
  check2("234375765.0",GMP_RNDU,"1.92724362186836231104e+01");
  check2("8.0",GMP_RNDZ,"2.07944154167983574765e+00");
  check2("44.0",GMP_RNDU,"3.78418963391826146392e+00");
  check2("1.01979300812244555452", GMP_RNDN, "1.95996734891603664741e-02");

  /* bugs found by Vincent Lefe`vre */
  check2("0.99999599881598921769", GMP_RNDN, "-0.0000040011920155404072924737977900999652547398000024259090423583984375");
  check2("9.99995576063808955247e-01",GMP_RNDZ,"-4.42394597667932383816e-06");
  check2("9.99993687357856209097e-01",GMP_RNDN,"-6.31266206860017342601e-06");
  check2("9.99995223520736886691e-01",GMP_RNDN,"-4.77649067052670982220e-06");
  check2("9.99993025794720935551e-01",GMP_RNDN,"-6.97422959894716163837e-06");
  check2("9.99987549017837484833e-01",GMP_RNDN,"-1.24510596766369924330e-05");
  check2("9.99985901426543311032e-01",GMP_RNDN,"-1.40986728425098585229e-05");
  check2("9.99986053947420794330e-01",GMP_RNDN, "-0.000013946149826301084938555592540598837558718514628708362579345703125");
  check2("9.99971938247442126979e-01",GMP_RNDN,"-2.80621462962173414790e-05");

  /* other bugs found by Vincent Lefe`vre */
  check2("1.18615436389927785905e+77",GMP_RNDN,"1.77469768607706015473e+02");
  check2("9.48868723578399476187e+77",GMP_RNDZ,"1.79549152432275803903e+02");
  check2("2.31822210096938820854e+89",GMP_RNDN,"2.05770873832573869322e+02");

  /* further bugs found by Vincent Lefe`vre */
  check2("9.99999989485669482647e-01",GMP_RNDZ,"-1.05143305726283042331e-08");
  check2("9.99999989237970177136e-01",GMP_RNDZ,"-1.07620298807745377934e-08");
  check2("9.99999989239339082125e-01",GMP_RNDN,"-1.07606609757704445430e-08");

  check2("7.3890560989306504",GMP_RNDU,"2.0000000000000004"); /* exp(2.0) */
  check2("7.3890560989306495",GMP_RNDU,"2.0"); /* exp(2.0) */
  check2("7.53428236571286402512e+34",GMP_RNDZ,"8.03073567492226345621e+01");
  check2("6.18784121531737948160e+19",GMP_RNDZ,"4.55717030391710693493e+01");
  check2("1.02560267603047283735e+00",GMP_RNDD,"2.52804164149448735987e-02");
  check2("7.53428236571286402512e+34",GMP_RNDZ,"8.03073567492226345621e+01");
  check2("1.42470900831881198052e+49",GMP_RNDZ,"113.180637144887668910087086260318756103515625");

  check2("1.08013816255293777466e+11",GMP_RNDN,"2.54055249841782604392e+01");
  check2("6.72783635300509015581e-37",GMP_RNDU,"-8.32893948416799503320e+01");
  check2("2.25904918906057891180e-52",GMP_RNDU,"-1.18919480823735682406e+02");
  check2("1.48901209246462951085e+00",GMP_RNDD,"3.98112874867437460668e-01");
  check2("1.70322470467612341327e-01",GMP_RNDN,"-1.77006175364294615626");
  check2("1.94572026316065240791e+01",GMP_RNDD,"2.96821731676437838842");
  check2("4.01419512207026418764e+04",GMP_RNDD,"1.06001772315501128218e+01");
  check2("9.47077365236487591672e-04",GMP_RNDZ,"-6.96212977303956748187e+00");
  check2("3.95906157687589643802e-109",GMP_RNDD,"-2.49605768114704119399e+02");
  check2("2.73874914516503004113e-02",GMP_RNDD,"-3.59766888618655977794e+00");
  check2("9.18989072589566467669e-17",GMP_RNDZ,"-3.69258425351464083519e+01");
  check2("7706036453608191045959753324430048151991964994788917248.0",GMP_RNDZ,"126.3815989984199177342816255986690521240234375");
  check2("1.74827399630587801934e-23",GMP_RNDZ,"-5.24008281254547156891e+01");
  check2("4.35302958401482307665e+22",GMP_RNDD,"5.21277441046519527390e+01");
  check2("9.70791868689332915209e+00",GMP_RNDD,"2.27294191194272210410e+00");
  check2("2.22183639799464011100e-01",GMP_RNDN,"-1.50425103275253957413e+00");
  check2("2.27313466156682375540e+00",GMP_RNDD,"8.21159787095675608448e-01");
  check2("6.58057413965851156767e-01",GMP_RNDZ,"-4.18463096196088235600e-01");
  check2 ("7.34302197248998461006e+43",GMP_RNDZ,"101.0049094695131799426235374994575977325439453125");
  check2("6.09969788341579732815e+00",GMP_RNDD,"1.80823924264386204363e+00");

  x_near_one ();

  test_generic (2, 100, 40);

  data_check ("data/log", mpfr_log, "mpfr_log");

 done:
  tests_end_mpfr ();
  return 0;
}
int
main (void)
{
  mpfr_prec_t p;
  int k;

  tests_start_mpfr ();

  for (p = MPFR_PREC_MIN; p <= 128; p++)
    {
      test_property1 (p, MPFR_RNDN, 0);
      test_property1 (p, MPFR_RNDU, 0);
      test_property1 (p, MPFR_RNDA, 0);
      test_property1 (p, MPFR_RNDN, 1);
      test_property1 (p, MPFR_RNDU, 1);
      test_property1 (p, MPFR_RNDA, 1);
      test_property2 (p, MPFR_RNDN);
    }

  check_diverse ("635030154261163106768013773815762607450069292760790610550915652722277604820131530404842415587328", 160, "796887792767063979679855997149887366668464780637");
  special ();
  check_nan ();

  for (p=2; p<200; p++)
    for (k=0; k<200; k++)
      check_inexact (p);
  check_float();

  check3 ("-0.0", MPFR_RNDN, "0.0");
  check4 ("6.37983013646045901440e+32", MPFR_RNDN, "5.9bc5036d09e0c@13");
  check4 ("1.0", MPFR_RNDN, "1");
  check4 ("1.0", MPFR_RNDZ, "1");
  check4 ("3.725290298461914062500000e-9", MPFR_RNDN, "4@-4");
  check4 ("3.725290298461914062500000e-9", MPFR_RNDZ, "4@-4");
  check4 ("1190456976439861.0", MPFR_RNDZ, "2.0e7957873529a@6");
  check4 ("1219027943874417664.0", MPFR_RNDZ, "4.1cf2af0e6a534@7");
  /* the following examples are bugs in Cygnus compiler/system, found by
     Fabrice Rouillier while porting mpfr to Windows */
  check4 ("9.89438396044940256501e-134", MPFR_RNDU, "8.7af7bf0ebbee@-56");
  check4 ("7.86528588050363751914e+31", MPFR_RNDZ, "1.f81fc40f32062@13");
  check4 ("0.99999999999999988897", MPFR_RNDN, "f.ffffffffffff8@-1");
  check4 ("1.00000000000000022204", MPFR_RNDN, "1");
  /* the following examples come from the paper "Number-theoretic Test
   Generation for Directed Rounding" from Michael Parks, Table 4 */

  check4 ("78652858805036375191418371571712.0", MPFR_RNDN,
          "1.f81fc40f32063@13");
  check4 ("38510074998589467860312736661504.0", MPFR_RNDN,
          "1.60c012a92fc65@13");
  check4 ("35318779685413012908190921129984.0", MPFR_RNDN,
          "1.51d17526c7161@13");
  check4 ("26729022595358440976973142425600.0", MPFR_RNDN,
          "1.25e19302f7e51@13");
  check4 ("22696567866564242819241453027328.0", MPFR_RNDN,
          "1.0ecea7dd2ec3d@13");
  check4 ("22696888073761729132924856434688.0", MPFR_RNDN,
          "1.0ecf250e8e921@13");
  check4 ("36055652513981905145251657416704.0", MPFR_RNDN,
          "1.5552f3eedcf33@13");
  check4 ("30189856268896404997497182748672.0", MPFR_RNDN,
          "1.3853ee10c9c99@13");
  check4 ("36075288240584711210898775080960.0", MPFR_RNDN,
          "1.556abe212b56f@13");
  check4 ("72154663483843080704304789585920.0", MPFR_RNDN,
          "1.e2d9a51977e6e@13");

  check4 ("78652858805036375191418371571712.0", MPFR_RNDZ,
          "1.f81fc40f32062@13");
  check4 ("38510074998589467860312736661504.0", MPFR_RNDZ,
          "1.60c012a92fc64@13");
  check4 ("35318779685413012908190921129984.0", MPFR_RNDZ, "1.51d17526c716@13");
  check4 ("26729022595358440976973142425600.0", MPFR_RNDZ, "1.25e19302f7e5@13");
  check4 ("22696567866564242819241453027328.0", MPFR_RNDZ,
          "1.0ecea7dd2ec3c@13");
  check4 ("22696888073761729132924856434688.0", MPFR_RNDZ, "1.0ecf250e8e92@13");
  check4 ("36055652513981905145251657416704.0", MPFR_RNDZ,
          "1.5552f3eedcf32@13");
  check4 ("30189856268896404997497182748672.0", MPFR_RNDZ,
          "1.3853ee10c9c98@13");
  check4 ("36075288240584711210898775080960.0", MPFR_RNDZ,
          "1.556abe212b56e@13");
  check4 ("72154663483843080704304789585920.0", MPFR_RNDZ,
          "1.e2d9a51977e6d@13");

  check4 ("78652858805036375191418371571712.0", MPFR_RNDU,
          "1.f81fc40f32063@13");
  check4 ("38510074998589467860312736661504.0", MPFR_RNDU,
          "1.60c012a92fc65@13");
  check4 ("35318779685413012908190921129984.0", MPFR_RNDU,
          "1.51d17526c7161@13");
  check4 ("26729022595358440976973142425600.0", MPFR_RNDU,
          "1.25e19302f7e51@13");
  check4 ("22696567866564242819241453027328.0", MPFR_RNDU,
          "1.0ecea7dd2ec3d@13");
  check4 ("22696888073761729132924856434688.0", MPFR_RNDU,
          "1.0ecf250e8e921@13");
  check4 ("36055652513981905145251657416704.0", MPFR_RNDU,
          "1.5552f3eedcf33@13");
  check4 ("30189856268896404997497182748672.0", MPFR_RNDU,
          "1.3853ee10c9c99@13");
  check4 ("36075288240584711210898775080960.0", MPFR_RNDU,
          "1.556abe212b56f@13");
  check4 ("72154663483843080704304789585920.0", MPFR_RNDU,
          "1.e2d9a51977e6e@13");

  check4 ("78652858805036375191418371571712.0", MPFR_RNDD,
          "1.f81fc40f32062@13");
  check4 ("38510074998589467860312736661504.0", MPFR_RNDD,
          "1.60c012a92fc64@13");
  check4 ("35318779685413012908190921129984.0", MPFR_RNDD, "1.51d17526c716@13");
  check4 ("26729022595358440976973142425600.0", MPFR_RNDD, "1.25e19302f7e5@13");
  check4 ("22696567866564242819241453027328.0", MPFR_RNDD,
          "1.0ecea7dd2ec3c@13");
  check4 ("22696888073761729132924856434688.0", MPFR_RNDD, "1.0ecf250e8e92@13");
  check4 ("36055652513981905145251657416704.0", MPFR_RNDD,
          "1.5552f3eedcf32@13");
  check4 ("30189856268896404997497182748672.0", MPFR_RNDD,
          "1.3853ee10c9c98@13");
  check4 ("36075288240584711210898775080960.0", MPFR_RNDD,
          "1.556abe212b56e@13");
  check4 ("72154663483843080704304789585920.0", MPFR_RNDD,
          "1.e2d9a51977e6d@13");

  /* check that rounding away is just rounding toward plus infinity */
  check4 ("72154663483843080704304789585920.0", MPFR_RNDA,
          "1.e2d9a51977e6e@13");

  test_generic (2, 300, 15);
  data_check ("data/sqrt", mpfr_sqrt, "mpfr_sqrt");
  bad_cases (mpfr_sqrt, mpfr_sqr, "mpfr_sqrt", 8, -256, 255, 4, 128, 800, 50);

  tests_end_mpfr ();
  return 0;
}
Example #24
0
int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Thread_Attrs_Test"));

  int status = 0;
#if defined (ACE_HAS_THREADS)
  Stack_Size_Check size_checker (40*1024);
  status = size_checker.open(0);
  if (status == 0)
    {
      if (size_checker.wait () == -1)
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("size_checker %p\n"),
                             ACE_TEXT ("wait")),
                            1);
      if (!size_checker)
        status = 1;
    }

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Cancel flags sanity check:\n")
              ACE_TEXT ("  THR_CANCEL_ENABLE: 0x%x\n")
              ACE_TEXT ("  THR_CANCEL_DISABLE: 0x%x\n")
              ACE_TEXT ("  THR_CANCEL_DEFERRED: 0x%x\n")
              ACE_TEXT ("  THR_CANCEL_ASYNCHRONOUS: 0x%x\n"),
              THR_CANCEL_ENABLE,
              THR_CANCEL_DISABLE,
              THR_CANCEL_DEFERRED,
              THR_CANCEL_ASYNCHRONOUS));
  // Cancel check args:  enable (yes/no), async/deferred
  Cancel_Check check1 (true, true);
  Cancel_Check check2 (true, false);
  Cancel_Check check3 (false, true);
  Cancel_Check check4 (false, false);
  if (check1.open(0) == 0)
    {
      check1.wait ();
      if (!check1)
        status = 1;

      check2.open (0);
      check2.wait ();
      if (!check2)
        status = 1;

      check3.open (0);
      check3.wait ();
      if (!check3)
        status = 1;

      check4.open (0);
      check4.wait ();
      if (!check4)
        status = 1;
    }
  else
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("Cancel_Check open")));
      status = 1;
    }
#else
  ACE_ERROR ((LM_INFO,
              ACE_TEXT ("threads not supported on this platform\n")));
#endif /* ACE_HAS_THREADS */
  ACE_END_TEST;
  return status;
}
Example #25
0
	int main(const std::vector<CL_String> &args)
	{
		try
		{
			CL_GUIManager gui;

			CL_ResourceManager resources("../../../Resources/GUIThemeLuna/resources.xml");

			CL_GUIWindowManagerSystem wm;
			gui.set_window_manager(wm);

			CL_GUIThemeDefault theme;
			theme.set_resources(resources);
			gui.set_theme(theme); 
			//gui.set_css_document("theme.css");
			gui.set_css_document("../../../Resources/GUIThemeLuna/theme.css");

			CL_DisplayWindowDescription win_desc;
			win_desc.set_allow_resize(true);
			win_desc.set_title("Button WM System Test Application");
			win_desc.set_position(CL_RectPS(200, 200, 320, 240), false);
			CL_Window window(&gui, win_desc);
			window.func_close().set(this, &App::on_close, &window);
	
			CL_PushButton button(&window);
			button.set_geometry(CL_RectPS(10, 10, 160, 40));
			button.set_text("Button 1");

			CL_PushButton button2(&window);
			button2.set_geometry(CL_RectPS(10, 50, 160, 40));
			button2.set_text("Button 2");
			button2.set_enabled(false);

			CL_PushButton button3(&window);
			button3.set_geometry(CL_RectPS(10, 90, 160, 40));
			button3.set_text("Button 3");
 
			CL_CheckBox check1(&window);
			check1.set_geometry(CL_RectPS(10, 130, 160, 21));
			check1.set_text("Check Box 1");

			CL_CheckBox check2(&window);
			check2.set_geometry(CL_RectPS(10, 160, 160, 21));
			check2.set_text("Check Box 2");
			check2.set_enabled(false);

			CL_CheckBox check3(&window);
			check3.set_geometry(CL_RectPS(10, 190, 160, 21));
			check3.set_text("Check Box 3");

			gui.exec();
		}
		catch (CL_Exception e)
		{
			CL_ConsoleWindow console("Console");
			CL_Console::write_line(e.message);
			console.display_close_message();
		}

		return 0;
	}
Example #26
0
File: tadd.c Project: mahdiz/mpclib
int
main (int argc, char *argv[])
{
#ifdef MPFR_HAVE_FESETROUND
  int prec, rnd_mode;
  int rnd;
  double y;
#endif
  double x;
  int i;

  mpfr_test_init ();
  check_inexact ();
  check_case_1b ();
  check_case_2 ();
  check64();
  check(293607738.0, 1.9967571564050541e-5, GMP_RNDU, 64, 53, 53,
	2.9360773800002003e8);
  check(880524.0, -2.0769715792901673e-5, GMP_RNDN, 64, 53, 53,
	8.8052399997923023e5);
  check(1196426492.0, -1.4218093058435347e-3, GMP_RNDN, 64, 53, 53,
	1.1964264919985781e9);
  check(982013018.0, -8.941829477291838e-7, GMP_RNDN, 64, 53, 53,
	9.8201301799999905e8);
  check(1092583421.0, 1.0880649218158844e9, GMP_RNDN, 64, 53, 53,
	2.1806483428158846e9);
  check(1.8476886419022969e-6, 961494401.0, GMP_RNDN, 53, 64, 53,
	9.6149440100000179e8);
  check(-2.3222118418069868e5, 1229318102.0, GMP_RNDN, 53, 64, 53,
	1.2290858808158193e9);
  check(-3.0399171300395734e-6, 874924868.0, GMP_RNDN, 53, 64, 53,
	8.749248679999969e8);
  check(9.064246624706179e1, 663787413.0, GMP_RNDN, 53, 64, 53,
	6.6378750364246619e8);
  check(-1.0954322421551264e2, 281806592.0, GMP_RNDD, 53, 64, 53,
	2.8180648245677572e8);
  check(5.9836930386056659e-8, 1016217213.0, GMP_RNDN, 53, 64, 53,
	1.0162172130000001e9);
  check(-1.2772161928500301e-7, 1237734238.0, GMP_RNDN, 53, 64, 53,
	1.2377342379999998e9);
  check(-4.567291988483277e8, 1262857194.0, GMP_RNDN, 53, 64, 53,
	8.0612799515167236e8);
  check(4.7719471752925262e7, 196089880.0, GMP_RNDN, 53, 53, 53, 
	2.4380935175292528e8);
  check(4.7719471752925262e7, 196089880.0, GMP_RNDN, 53, 64, 53, 
	2.4380935175292528e8);
  check(-1.716113812768534e-140, 1271212614.0, GMP_RNDZ, 53, 64, 53,
	1.2712126139999998e9);
  check(-1.2927455200185474e-50, 1675676122.0, GMP_RNDD, 53, 64, 53,
	1.6756761219999998e9);
  check53(1.22191250737771397120e+20, 948002822.0, GMP_RNDN, 
	  122191250738719408128.0);
  check53(9966027674114492.0, 1780341389094537.0, GMP_RNDN,
	  11746369063209028.0);
  check53(2.99280481918991653800e+272, 5.34637717585790933424e+271, GMP_RNDN,
	  3.5274425367757071711e272);
  check_same();
  check53(6.14384195492641560499e-02, -6.14384195401037683237e-02, GMP_RNDU,
	  9.1603877261370314499e-12);
  check53(1.16809465359248765399e+196, 7.92883212101990665259e+196, GMP_RNDU,
	  9.0969267746123943065e196);
  check53(3.14553393112021279444e-67, 3.14553401015952024126e-67, GMP_RNDU,
	  6.2910679412797336946e-67);

  SEED_RAND (time(NULL));
  check53(5.43885304644369509058e+185,-1.87427265794105342763e-57,GMP_RNDN,
	  5.4388530464436950905e185);
  check53(5.43885304644369509058e+185,-1.87427265794105342763e-57, GMP_RNDZ,
	  5.4388530464436944867e185);
  check53(5.43885304644369509058e+185,-1.87427265794105342763e-57, GMP_RNDU,
	  5.4388530464436950905e185);
  check53(5.43885304644369509058e+185,-1.87427265794105342763e-57, GMP_RNDD,
	  5.4388530464436944867e185);
  check2a(6.85523243386777784171e+107,187,-2.78148588123699111146e+48,87,178,
	  GMP_RNDD, "4.ab980a5cb9407ffffffffffffffffffffffffffffffe@89");
  check2a(-1.21510626304662318398e+145,70,1.21367733647758957118e+145,65,61,
	 GMP_RNDD, "-1.2bfad031d94@118");
  check2a(2.73028857032080744543e+155,83,-1.16446121423113355603e+163,59,125,
	  GMP_RNDZ, "-3.3c42dee09703d0639a6@135");
  check2a(-4.38589520019641698848e+78,155,-1.09923643769309483415e+72,15,159,
	  GMP_RNDD, "-2.5e09955c663d@65");
  check2a(-1.49963910666191123860e+265,76,-2.30915090591874527520e-191,8,75,
	  GMP_RNDZ, "-1.dc3ec027da54e@220");
  check2a(3.25471707846623300604e-160,81,-7.93846654265839958715e-274,58,54,
	  GMP_RNDN, "4.936a52bc17254@-133");
  check2a(5.17945380930936917508e+112,119,1.11369077158813567738e+108,15,150,
	  GMP_RNDZ, "5.62661692498ec@93");
  check2a(-2.66910493504493276454e-52,117,1.61188644159592323415e-52,61,68,
	  GMP_RNDZ, "-a.204acdd25d788@-44");
  check2a(-1.87427265794105342764e-57,175,1.76570844587489516446e+190,2,115,
	  GMP_RNDZ, "b.fffffffffffffffffffffffffffe@157");
  check2a(-1.15706375390780417299e-135,94,-1.07455137477117851576e-129,66,111,
	  GMP_RNDU, "-b.eae2643497ff6286b@-108");
  check2a(-1.15706375390780417299e-135,94,-1.07455137477117851576e-129,66,111,
	  GMP_RNDD, "-b.eae2643497ff6286b@-108");
  check2a(-3.31624349995221499866e-22,107,-8.20150212714204839621e+156,79,99,
	 GMP_RNDD, "-2.63b22b55697e8000000000008@130");
  x = -5943982715394951.0; for (i=0; i<446; i++) x *= 2.0;
  check2a(x, 63, 1.77607317509426332389e+73, 64, 64, GMP_RNDN,
	  "-5.4781549356e1c@124");
  check2a(4.49465557237618783128e+53,108,-2.45103927353799477871e+48,60,105,
	  GMP_RNDN, "4.b14f230f909dc803e@44");
  check2a(2.26531902208967707071e+168,99,-2.67795218510613988524e+168,67,94,
	GMP_RNDU, "-1.bfd7ff2647098@139");
  check2a(-8.88471912490080158206e+253,79,-7.84488427404526918825e+124,95,53,
	  GMP_RNDD, "-c.1e533b8d835@210");
  check2a(-2.18548638152863831959e-125,61,-1.22788940592412363564e+226,71,54,
	  GMP_RNDN, "-8.4b0f99ffa3b58@187");
  check2a(-7.94156823309993162569e+77,74,-5.26820160805275124882e+80,99,101,
	  GMP_RNDD, "-1.1cc90f11d6af26f4@67");
  check2a(-3.85170653452493859064e+189,62,2.18827389706660314090e+158,94,106,
	  GMP_RNDD, "-3.753ac0935b701ffffffffffffd@157");
  check2a(1.07966151149311101950e+46,88,1.13198076934147457400e+46,67,53,
	  GMP_RNDN, "3.dfbc152dd4368@38");
  check2a(3.36768223223409657622e+209,55,-9.61624007357265441884e+219,113,53,
	  GMP_RNDN, "-6.cf7217a451388@182");
  check2a(-6.47376909368979326475e+159,111,5.11127211034490340501e+159,99,62,
	  GMP_RNDD, "-1.8cf3aadf537c@132");
  check2a(-4.95229483271607845549e+220,110,-6.06992115033276044773e+213,109,55,
	  GMP_RNDN, "-2.3129f1f63b31b@183");
  check2a(-6.47376909368979326475e+159,74,5.11127211034490340501e+159,111,75,
	  GMP_RNDU, "-1.8cf3aadf537c@132");
  check2a(2.26531902208967707070e+168,99,-2.67795218510613988525e+168,67,94,
	 GMP_RNDU, "-1.bfd7ff2647098@139");
  check2a(-2.28886326552077479586e-188,67,3.41419438647157839320e-177,60,110,
	  GMP_RNDU, "3.75740b4fe8f17f90258907@-147");
  check2a(-2.66910493504493276454e-52,117,1.61188644159592323415e-52,61,68,
	  GMP_RNDZ, "-a.204acdd25d788@-44");
  check2a(2.90983392714730768886e+50,101,2.31299792168440591870e+50,74,105,
	 GMP_RNDZ, "1.655c53ff5719c8@42");
  check2a(2.72046257722708717791e+243,97,-1.62158447436486437113e+243,83,96,
	  GMP_RNDN, "a.4cc63e002d2e8@201");
  /* Checking double precision (53 bits) */
  check53(-8.22183238641455905806e-19, 7.42227178769761587878e-19, GMP_RNDD, 
	  -7.9956059871694317927e-20);
  check53(5.82106394662028628236e+234, -5.21514064202368477230e+89, GMP_RNDD,
	  5.8210639466202855763e234);
  check53(5.72931679569871602371e+122, -5.72886070363264321230e+122, GMP_RNDN,
	  4.5609206607281141508e118);
  check53(-5.09937369394650450820e+238, 2.70203299854862982387e+250, GMP_RNDD,
	  2.7020329985435301323e250);
  check53(-2.96695924472363684394e+27, 1.22842938251111500000e+16, GMP_RNDD,
	  -2.96695924471135255027e27);
  check53(1.74693641655743793422e-227, -7.71776956366861843469e-229, GMP_RNDN,
	  1.669758720920751867e-227);
  x = -7883040437021647.0; for (i=0; i<468; i++) x = x / 2.0;
  check53(-1.03432206392780011159e-125, 1.30127034799251347548e-133, GMP_RNDN,
	  x);
  check53(1.05824655795525779205e+71, -1.06022698059744327881e+71, GMP_RNDZ,
	  -1.9804226421854867632e68);
  check53(-5.84204911040921732219e+240, 7.26658169050749590763e+240, GMP_RNDD,
	  1.4245325800982785854e240);
  check53(1.00944884131046636376e+221, 2.33809162651471520268e+215, GMP_RNDN,
	  1.0094511794020929787e221);
  x = 7045852550057985.0; for (i=0; i<986; i++) x = x / 2.0;
  check53(4.29232078932667367325e-278, x, GMP_RNDU,
	  4.2933981418314132787e-278);
  check53(5.27584773801377058681e-80, 8.91207657803547196421e-91, GMP_RNDN,
	  5.2758477381028917269e-80);
  check53(2.99280481918991653800e+272, 5.34637717585790933424e+271, GMP_RNDN,
	  3.5274425367757071711e272);
  check53(4.67302514390488041733e-184, 2.18321376145645689945e-190, GMP_RNDN,
	  4.6730273271186420541e-184);
  check53(5.57294120336300389254e+71, 2.60596167942024924040e+65, GMP_RNDZ,
	  5.5729438093246831053e71);
  check53(6.6052588496951015469e24, 4938448004894539.0, GMP_RNDU,
	6.6052588546335505068e24);
  check53(1.23056185051606761523e-190, 1.64589756643433857138e-181, GMP_RNDU, 
	  1.6458975676649006598e-181);
  check53(2.93231171510175981584e-280, 3.26266919161341483877e-273, GMP_RNDU,
	  3.2626694848445867288e-273);
  check53(5.76707395945001907217e-58, 4.74752971449827687074e-51, GMP_RNDD,
	  4.747530291205672325e-51);
  check53(277363943109.0, 11.0, GMP_RNDN, 277363943120.0);
#if 0         /* disabled since it seems silly to use denorms *
  /* test denormalized numbers too */
  check53(8.06294740693074521573e-310, 6.95250701071929654575e-310, GMP_RNDU,
	  1.5015454417650041761e-309);
#endif
#ifdef HAVE_INFS
  /* the following check double overflow */
  check53(6.27557402141211962228e+307, 1.32141396570101687757e+308,
     GMP_RNDZ, DBL_POS_INF);
  check53(DBL_POS_INF, 6.95250701071929654575e-310, GMP_RNDU, DBL_POS_INF);
  check53(DBL_NEG_INF, 6.95250701071929654575e-310, GMP_RNDU, DBL_NEG_INF);
  check53(6.95250701071929654575e-310, DBL_POS_INF, GMP_RNDU, DBL_POS_INF);
  check53(6.95250701071929654575e-310, DBL_NEG_INF, GMP_RNDU, DBL_NEG_INF);
  check53nan (DBL_POS_INF, DBL_NEG_INF, GMP_RNDN);
#endif
  check53(1.44791789689198883921e-140, -1.90982880222349071284e-121,
	  GMP_RNDN, -1.90982880222349071e-121);


  /* tests for particular cases (Vincent Lefevre, 22 Aug 2001) */
  check53(9007199254740992.0, 1.0, GMP_RNDN, 9007199254740992.0);
  check53(9007199254740994.0, 1.0, GMP_RNDN, 9007199254740996.0);
  check53(9007199254740992.0, -1.0, GMP_RNDN, 9007199254740991.0);
  check53(9007199254740994.0, -1.0, GMP_RNDN, 9007199254740992.0);
  check53(9007199254740996.0, -1.0, GMP_RNDN, 9007199254740996.0);
  
#ifdef MPFR_HAVE_FESETROUND
  prec = (argc<2) ? 53 : atoi(argv[1]);
  rnd_mode = (argc<3) ? -1 : atoi(argv[2]);
  /* Comparing to double precision using machine arithmetic */
  for (i=0;i<N;i++) {
    x = drand(); 
    y = drand();
    if (ABS(x)>2.2e-307 && ABS(y)>2.2e-307 && x+y<1.7e+308 && x+y>-1.7e308) {
      /* avoid denormalized numbers and overflows */
      rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
      check(x, y, rnd, prec, prec, prec, 0.0);
    }
  } 
  /* tests with random precisions */
  for (i=0;i<N;i++) {
    int px, py, pz;
    px = 53 + (LONG_RAND() % 64); 
    py = 53 + (LONG_RAND() % 64); 
    pz = 53 + (LONG_RAND() % 64); 
    rnd_mode = LONG_RAND() % 4;
    do { x = drand(); } while (isnan(x));
    do { y = drand(); } while (isnan(y));
    check2 (x, px, y, py, pz, rnd_mode);
  }
  /* Checking mpfr_add(x, x, y) with prec=53 */
  for (i=0;i<N;i++) {
    x = drand(); 
    y = drand();
    if (ABS(x)>2.2e-307 && ABS(y)>2.2e-307 && x+y<1.7e+308 && x+y>-1.7e308) {
      /* avoid denormalized numbers and overflows */
      rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
      check3(x, y, rnd);
    }
  }
  /* Checking mpfr_add(x, y, x) with prec=53 */
  for (i=0;i<N;i++) {
    x = drand(); 
    y = drand();
    if (ABS(x)>2.2e-307 && ABS(y)>2.2e-307 && x+y<1.7e+308 && x+y>-1.7e308) {
      /* avoid denormalized numbers and overflows */
      rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
      check4(x, y, rnd);
    }
  }
  /* Checking mpfr_add(x, x, x) with prec=53 */
  for (i=0;i<N;i++) {
    do { x = drand(); } while ((ABS(x)<2.2e-307) || (ABS(x)>0.8e308));
    /* avoid denormalized numbers and overflows */
    rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
    check5(x, rnd);
  }
#endif

  return 0;
}
Example #27
0
stamp stamp_fresh_large(void)
{
  return (check3(++count3));
}
Example #28
0
vector<Point3d> PlaneDetector::getPlanes(Mat& rgbImage,
        PointCloud<PointXYZ>& pcl, vector<Vec4i>& lines) {
    vector<Point3d> foundPlanes;

    for (int i = 0; i < lines.size(); i++) {
        Vec4i line = lines[i];
        Point2i a = Point2i(line[0], line[1]);
        Point2i b = Point2i(line[2], line[3]);
        if (norm(b - a) < 100)
            continue;
        for (int j = 0; j < 2; j++) {
            Point2i diff = b - a;
            float len = cv::norm(diff);
            Point2i mid1(a.x + 4 * diff.x / 10, a.y + 3 * diff.y / 10);
            Point2i mid2(a.x + 5 * diff.x / 10, a.y + 5 * diff.y / 10);
            Point2i mid3(a.x + 6 * diff.x / 10, a.y + 7 * diff.y / 10);
            Point2i rotated;
            if (j == 0)
                rotated = Point2i(-diff.y, diff.x);
            else
                rotated = Point2i(diff.y, -diff.x);
            Point2i check1(mid1.x + rotated.x / 5, mid1.y + rotated.y / 5);
            Point2i check2(mid2.x + rotated.x / 2, mid2.y + rotated.y / 2);
            Point2i check3(mid3.x + rotated.x / 5, mid3.y + rotated.y / 5);
            Point3d d1 = depthCloseToPoint(check1, pcl, 10);
            Point3d d2 = depthCloseToPoint(check2, pcl, 10);
            Point3d d3 = depthCloseToPoint(check3, pcl, 10);
            bool planeAlreadyFound = false;
            for (int j = 0; j < foundPlanes.size(); j++) {
                if (fabs(pointOnPlane(d1, foundPlanes[j])) < DIST_EPSILON
                        || fabs(pointOnPlane(d2, foundPlanes[j])) < DIST_EPSILON
                        || fabs(pointOnPlane(d3, foundPlanes[j]))
                        < DIST_EPSILON) {
                    planeAlreadyFound = true;
                    break;
                }
            }
            if (planeAlreadyFound) {
                cv::line(rgbImage, check1, check2, Scalar(0, 0, 255), 3, 8);
                cv::line(rgbImage, check2, check3, Scalar(0, 0, 255), 3, 8);
                cv::line(rgbImage, check3, check1, Scalar(0, 0, 255), 3, 8);
                continue;
            }
            cv::line(rgbImage, check1, check2, Scalar(255, 0, 0), 3, 8);
            cv::line(rgbImage, check2, check3, Scalar(255, 0, 0), 3, 8);
            cv::line(rgbImage, check3, check1, Scalar(255, 0, 0), 3, 8);
            if (d1.z != -1 && d2.z != -1 && d3.z != -1) {
                cv::line(rgbImage, check1, check2, Scalar(255, 255, 255), 3, 8);
                cv::line(rgbImage, check2, check3, Scalar(255, 255, 255), 3, 8);
                cv::line(rgbImage, check3, check1, Scalar(255, 255, 255), 3, 8);
                vector<Point3d> v;
                v.push_back(d1);
                v.push_back(d2);
                v.push_back(d3);
                Point3d plane = getPlane(v);
                foundPlanes.push_back(plane);
            }
        }
    }

    return foundPlanes;
}
Example #29
0
int
main (int argc, char *argv[])
{
  int b;
  mpfr_t x;
  mpfr_rnd_t r;
  char s[MAX_DIGITS + 2];
  mpfr_exp_t e, f;
  size_t m;
  mpfr_prec_t p;
  int i;

  tests_start_mpfr ();

  check_small ();

  check_special (2, 2);
  for (i = 0; i < ITER; i++)
    {
      p = 2 + (randlimb () % (MAX_DIGITS - 1));
      b = 2 + (randlimb () % 35);
      check_special (b, p);
    }

  mpfr_init2 (x, MAX_DIGITS);
  for (i = 0; i < ITER; i++)
    {
      m = 2 + (randlimb () % (MAX_DIGITS - 1));
      mpfr_urandomb (x, RANDS);
      e = (mpfr_exp_t) (randlimb () % 21) - 10;
      if (!MPFR_IS_ZERO(x))
        mpfr_set_exp (x, (e == -10) ? mpfr_get_emin () :
                      ((e == 10) ? mpfr_get_emax () : e));
      b = 2 + (randlimb () % 35);
      r = RND_RAND ();
      mpfr_get_str (s, &f, b, m, x, r);
    }
  mpfr_clear (x);

  check_large ();
  check3 ("4.059650008e-83", MPFR_RNDN, "40597");
  check3 ("-6.606499965302424244461355e233", MPFR_RNDN, "-66065");
  check3 ("-7.4", MPFR_RNDN, "-74000");
  check3 ("0.997", MPFR_RNDN, "99700");
  check3 ("-4.53063926135729747564e-308", MPFR_RNDN, "-45306");
  check3 ("2.14478198760196000000e+16", MPFR_RNDN, "21448");
  check3 ("7.02293374921793516813e-84", MPFR_RNDN, "70229");

  check3 ("-6.7274500420134077e-87", MPFR_RNDN, "-67275");
  check3 ("-6.7274500420134077e-87", MPFR_RNDZ, "-67274");
  check3 ("-6.7274500420134077e-87", MPFR_RNDU, "-67274");
  check3 ("-6.7274500420134077e-87", MPFR_RNDD, "-67275");
  check3 ("-6.7274500420134077e-87", MPFR_RNDA, "-67275");

  check3 ("6.7274500420134077e-87", MPFR_RNDN, "67275");
  check3 ("6.7274500420134077e-87", MPFR_RNDZ, "67274");
  check3 ("6.7274500420134077e-87", MPFR_RNDU, "67275");
  check3 ("6.7274500420134077e-87", MPFR_RNDD, "67274");
  check3 ("6.7274500420134077e-87", MPFR_RNDA, "67275");

  check_bug_base2k ();
  check_reduced_exprange ();

  tests_end_mpfr ();
  return 0;
}
Example #30
0
File: texp.c Project: jozip/xcl
int
main (int argc, char *argv[])
{
    tests_start_mpfr ();

    if (argc > 1)
        check_large ();

    check_inexact ();
    check_special ();

    test_generic (2, 100, 100);

    compare_exp2_exp3 (20, 1000);
    check_worst_cases();
    check3("0.0", MPFR_RNDU, "1.0");
    check3("-1e-170", MPFR_RNDU, "1.0");
    check3("-1e-170", MPFR_RNDN, "1.0");
    check3("-8.88024741073346941839e-17", MPFR_RNDU, "1.0");
    check3("8.70772839244701057915e-01", MPFR_RNDN, "2.38875626491680437269");
    check3("1.0", MPFR_RNDN, "2.71828182845904509080");
    check3("-3.42135637628104173534e-07", MPFR_RNDZ, "0.999999657864420798958");
    /* worst case for argument reduction, very near from 5*log(2),
       thanks to Jean-Michel Muller  */
    check3("3.4657359027997265421", MPFR_RNDN, "32.0");
    check3("3.4657359027997265421", MPFR_RNDU, "32.0");
    check3("3.4657359027997265421", MPFR_RNDD, "31.999999999999996447");
    check3("2.26523754332090625496e+01", MPFR_RNDD, "6.8833785261699581146e9");
    check3("1.31478962104089092122e+01", MPFR_RNDZ, "5.12930793917860137299e+05");
    check3("4.25637507920002378103e-01", MPFR_RNDU, "1.53056585656161181497e+00");
    check3("6.26551618962329307459e-16", MPFR_RNDU, "1.00000000000000066613e+00");
    check3("-3.35589513871216568383e-03",MPFR_RNDD, "9.96649729583626853291e-01");
    check3("1.95151388850007272424e+01", MPFR_RNDU, "2.98756340674767792225e+08");
    check3("2.45045953503350730784e+01", MPFR_RNDN, "4.38743344916128387451e+10");
    check3("2.58165606081678085104e+01", MPFR_RNDD, "1.62925781879432281494e+11");
    check3("-2.36539020084338638128e+01",MPFR_RNDZ, "5.33630792749924762447e-11");
    check3("2.39211946135858077866e+01", MPFR_RNDU, "2.44817704330214385986e+10");
    check3("-2.78190533055889162029e+01",MPFR_RNDZ, "8.2858803483596879512e-13");
    check3("2.64028186174889789584e+01", MPFR_RNDD, "2.9281844652878973388e11");
    check3("2.92086338843268329413e+01", MPFR_RNDZ, "4.8433797301907177734e12");
    check3("-2.46355324071459982349e+01",MPFR_RNDZ, "1.9995129297760994791e-11");
    check3("-2.23509444608605427618e+01",MPFR_RNDZ, "1.9638492867489702307e-10");
    check3("-2.41175390197331687148e+01",MPFR_RNDD, "3.3564940885530624592e-11");
    check3("2.46363885231578088053e+01", MPFR_RNDU, "5.0055014282693267822e10");
    check3("111.1263531080090984914932050742208957672119140625", MPFR_RNDN, "1.8262572323517295459e48");
    check3("-3.56196340354684821250e+02",MPFR_RNDN, "2.0225297096141478156e-155");
    check3("6.59678273772710895173e+02", MPFR_RNDU, "3.1234469273830195529e286");
    check3("5.13772529701934331570e+02", MPFR_RNDD, "1.3445427121297197752e223");
    check3("3.57430211008718345056e+02", MPFR_RNDD, "1.6981197246857298443e155");
    check3("3.82001814471465536371e+02", MPFR_RNDU, "7.9667300591087367805e165");
    check3("5.92396038219384422518e+02", MPFR_RNDD, "1.880747529554661989e257");
    check3("-5.02678550462488090034e+02",MPFR_RNDU, "4.8919201895446217839e-219");
    check3("5.30015757134837031117e+02", MPFR_RNDD, "1.5237672861171573939e230");
    check3("5.16239362447650933063e+02", MPFR_RNDZ, "1.5845518406744492105e224");
    check3("6.00812634798592370977e-01", MPFR_RNDN, "1.823600119339019443");
    check_exp10 ();

    bug20080731 ();

    overflowed_exp0 ();
    underflow ();

    data_check ("data/exp", mpfr_exp, "mpfr_exp");
    bad_cases (mpfr_exp, mpfr_log, "mpfr_exp", 0, -256, 255, 4, 128, 800, 50);

    tests_end_mpfr ();
    return 0;
}