コード例 #1
0
ファイル: floatbasic.cpp プロジェクト: AnZhg/mU
void poly_f::normalize()
{
	uint i=this->rep.size();
	while(i>0&&mpf_cmp_ui(this->rep[i-1],0)==0)i--;
	this->resize(i);
	return ;
}
コード例 #2
0
ファイル: t-set_q.c プロジェクト: BrianGladman/mpir
void
check_various (void)
{
  mpf_t got;
  mpq_t q;

  mpf_init (got);
  mpq_init (q);

  /* 1/1 == 1 */
  mpf_set_prec (got, 20L);
  mpq_set_ui (q, 1L, 1L);
  mpf_set_q (got, q);
  MPF_CHECK_FORMAT (got);
  ASSERT_ALWAYS (mpf_cmp_ui (got, 1L) == 0);

  /* 1/(2^n+1), a case where truncating the divisor would be wrong */
  mpf_set_prec (got, 500L);
  mpq_set_ui (q, 1L, 1L);
  mpz_mul_2exp (mpq_denref(q), mpq_denref(q), 800L);
  mpz_add_ui (mpq_denref(q), mpq_denref(q), 1L);
  check_one (got, q);

  mpf_clear (got);
  mpq_clear (q);
}
コード例 #3
0
ファイル: t-div.c プロジェクト: AlexeiSheplyakov/gmp.pkg
void
check_various (void)
{
  mpf_t got, u, v;

  mpf_init (got);
  mpf_init (u);
  mpf_init (v);

  /* 100/4 == 25 */
  mpf_set_prec (got, 20L);
  mpf_set_ui (u, 100L);
  mpf_set_ui (v, 4L);
  mpf_div (got, u, v);
  MPF_CHECK_FORMAT (got);
  ASSERT_ALWAYS (mpf_cmp_ui (got, 25L) == 0);

  /* 1/(2^n+1), a case where truncating the divisor would be wrong */
  mpf_set_prec (got, 500L);
  mpf_set_prec (v, 900L);
  mpf_set_ui (v, 1L);
  mpf_mul_2exp (v, v, 800L);
  mpf_add_ui (v, v, 1L);
  mpf_div (got, u, v);
  check_one ("1/2^n+1, separate", got, u, v);

  mpf_clear (got);
  mpf_clear (u);
  mpf_clear (v);
}
コード例 #4
0
ファイル: Expr.c プロジェクト: samueldotj/eva
void DoUniaryOperation(number_t result, number_t number1, char *op)
{
	switch( op[0] )
	{
		case '!':
			mpf_set_si(result, mpf_cmp_ui(number1, 0));
			break;
		case '~':
			DO_INTEGER_OPERATION1_ON_FLOAT(mpz_com, result, number1);
			break;
		case '+':
			if (op[1] == '+') {
				mpf_add_ui(result, number1, 1);
			} else {
				mpf_set(result, number1);
			}
			break;
		case '-':
			if (op[1] == '-') {
				mpf_sub_ui(result, number1, 1);
			} else {
				mpf_sub(result, result, number1);
			}
			break;
	}
}
コード例 #5
0
	void FractalTexture::computeColor(unsigned char *pixel) {
#ifdef ROE_FRACTAL_GMP_USE_C
		mpf_set(xPos, m_xPos);
		mpf_set(yPos, m_yPos);
#else
		xPos = m_xPos;
		yPos = m_yPos;
#endif
		for(long iteration = 0; iteration < m_iMaxIterations; ++iteration) {
#ifdef ROE_FRACTAL_GMP_USE_C
			mpf_mul(xPos2, xPos, xPos);
			mpf_mul(yPos2, yPos, yPos);
			mpf_add(tmp, xPos2, yPos2); //save sum temporarily
			if(mpf_cmp_ui(tmp,4) >= 0) {
#else
				xPos2 = xPos*xPos;
				yPos2 = yPos*yPos;
				if(xPos2 + yPos2 > 4.0) {
#endif
					//(coloured) outer
					const double ratio = iteration*m_dInvMaxIterations;
					//const Color c = Color::WHITE;
					const Color c = colorInterpolation.interpolate(ratio);
					pixel[0] = c.byter();
					pixel[1] = c.byteg();
					pixel[2] = c.byteb();
					return;
				}
#ifdef ROE_FRACTAL_GMP_USE_C
				mpf_mul(yPos, yPos, xPos);
				mpf_mul_ui(yPos, yPos, 2);
				mpf_add(yPos, yPos, m_yPos);
				mpf_sub(xPos, xPos2, yPos2);
				mpf_add(xPos, xPos, m_xPos);
#else
				yPos *= xPos;
				yPos *= 2;
				yPos += m_yPos;
				xPos = xPos2;
				xPos -= yPos2;
				xPos += m_xPos;
#endif
			}
			//inner
			pixel[0] = m_innerR;
			pixel[1] = m_innerG;
			pixel[2] = m_innerB;
		}
		void FractalTexture::updateMipmaps() {
			S_Texture *subtex1 = &texture, *subtex2 = nullptr;
			while (subtex1->next_mipmap) {
				subtex2 = subtex1->next_mipmap;
				Texture::scaleImage2(subtex1->data, subtex1->width, subtex1->height, subtex2->data, subtex2->width, subtex2->height, subtex1->bpp); //scaling image to new size
				subtex1 = subtex2; //one level deeper
			}
		}
コード例 #6
0
ファイル: number.c プロジェクト: live4thee/llscheme
static int
lso_is_real(struct ls_object *number)
{
  int r = 1;

  if (!lso_is_number(number))
    r = 0;

  if (lso_is_complex(number)) {
    if (lso_number_type_im(number) == 3 &&  /* inexact */
        mpf_cmp_ui(*(mpf_t *)number->u2.ptr, 0) == 0)
      r = 1;
    else
      r = 0;
  }

  return r;
}
コード例 #7
0
ファイル: reldiff.c プロジェクト: mahdiz/mpclib
void
mpf_reldiff (mpf_t rdiff, mpf_srcptr x, mpf_srcptr y)
{
  if (mpf_cmp_ui (x, 0) == 0)
    {
      mpf_set_ui (rdiff, (unsigned long int) (mpf_sgn (y) != 0));
    }
  else
    {
      mpf_t d;
      mp_limb_t tmp_limb[2];

      d->_mp_prec = 1;
      d->_mp_d = tmp_limb;

      mpf_sub (d, x, y);
      mpf_abs (d, d);
      mpf_div (rdiff, d, x);
    }
}
コード例 #8
0
ファイル: t-div.c プロジェクト: AlexeiSheplyakov/gmp.pkg
/* Exercise calls mpf(x,x,x) */
void
check_reuse_three (void)
{
  unsigned long  min_prec = __GMPF_BITS_TO_PREC (1);
  gmp_randstate_ptr  rands = RANDS;
  unsigned long  result_prec, input_prec, set_prec;
  mpf_t  got;
  int    i;

  mpf_init (got);

  for (i = 0; i < 8; i++)
    {
      result_prec = min_prec + gmp_urandomm_ui (rands, 15L);
      input_prec = min_prec + gmp_urandomm_ui (rands, 15L);

      set_prec = MAX (result_prec, input_prec);
      refmpf_set_prec_limbs (got, set_prec);

      /* input, non-zero, possibly negative */
      PREC(got) = input_prec;
      do {
        mpf_random2 (got, input_prec, (mp_exp_t) 20);
      } while (SIZ(got) == 0);
      if (gmp_urandomb_ui (rands, 1L))
        mpf_neg (got, got);

      PREC(got) = result_prec;

      mpf_div (got, got, got);

      /* expect exactly 1.0 always */
      ASSERT_ALWAYS (mpf_cmp_ui (got, 1L) == 0);

      PREC(got) = set_prec;
    }

  mpf_clear (got);
}
コード例 #9
0
ファイル: tget_f.c プロジェクト: sudheesh001/SEC-LAB
static void
special_test (void)
{
  int inex;
  mpf_t x;
  mpfr_t y;

  mpfr_init (y);
  mpf_init (x);

  mpfr_set_nan (y);
  mpfr_clear_flags ();
  mpfr_get_f (x, y, MPFR_RNDN);
  if (! mpfr_erangeflag_p ())
    {
      printf ("Error: mpfr_get_f(NaN) should raise erange flag\n");
      exit (1);
    }

  mpfr_set_inf (y, +1);
  mpfr_clear_flags ();
  inex = mpfr_get_f (x, y, MPFR_RNDN);
  if (inex >= 0)
    {
      printf ("Error: mpfr_get_f(+Inf) should return a negative ternary"
              "value\n");
      exit (1);
    }
  if (! mpfr_erangeflag_p ())
    {
      printf ("Error: mpfr_get_f(+Inf) should raise erange flag\n");
      exit (1);
    }

  mpfr_set_inf (y, -1);
  mpfr_clear_flags ();
  inex = mpfr_get_f (x, y, MPFR_RNDN);
  if (inex <= 0)
    {
      printf ("Error: mpfr_get_f(-Inf) should return a positive ternary"
              "value\n");
      exit (1);
    }
  if (! mpfr_erangeflag_p ())
    {
      printf ("Error: mpfr_get_f(-Inf) should raise erange flag\n");
      exit (1);
    }

  mpfr_set_ui (y, 0, MPFR_RNDN);
  if (mpfr_get_f (x, y, MPFR_RNDN) != 0 || mpf_cmp_ui (x, 0))
    {
      printf ("Error: mpfr_get_f(+0) fails\n");
      exit (1);
    }

  mpfr_set_ui (y, 0, MPFR_RNDN);
  mpfr_neg (y, y, MPFR_RNDN);
  if (mpfr_get_f (x, y, MPFR_RNDN) != 0 || mpf_cmp_ui (x, 0))
    {
      printf ("Error: mpfr_get_f(-0) fails\n");
      exit (1);
    }

  mpfr_clear (y);
  mpf_clear (x);
}
コード例 #10
0
void
check_n (void)
{
  {
    int  n = -1;
    check_one ("blah", "%nblah", &n);
    ASSERT_ALWAYS (n == 0);
  }

  {
    int  n = -1;
    check_one ("hello ", "hello %n", &n);
    ASSERT_ALWAYS (n == 6);
  }

  {
    int  n = -1;
    check_one ("hello  world", "hello %n world", &n);
    ASSERT_ALWAYS (n == 6);
  }

#define CHECK_N(type, string)                           \
  do {                                                  \
    type  x[2];                                         \
    char  fmt[128];                                     \
							\
    x[0] = ~ (type) 0;                                  \
    x[1] = ~ (type) 0;                                  \
    sprintf (fmt, "%%d%%%sn%%d", string);               \
    check_one ("123456", fmt, 123, &x[0], 456);         \
							\
    /* should write whole of x[0] and none of x[1] */   \
    ASSERT_ALWAYS (x[0] == 3);                          \
    ASSERT_ALWAYS (x[1] == (type) ~ (type) 0);		\
							\
  } while (0)

  CHECK_N (mp_limb_t, "M");
  CHECK_N (char,      "hh");
  CHECK_N (long,      "l");
#if HAVE_LONG_LONG
  CHECK_N (long long, "L");
#endif
#if HAVE_INTMAX_T
  CHECK_N (intmax_t,  "j");
#endif
#if HAVE_PTRDIFF_T
  CHECK_N (ptrdiff_t, "t");
#endif
  CHECK_N (short,     "h");
  CHECK_N (size_t,    "z");

  {
    mpz_t  x[2];
    mpz_init_set_si (x[0], -987L);
    mpz_init_set_si (x[1],  654L);
    check_one ("123456", "%d%Zn%d", 123, x[0], 456);
    MPZ_CHECK_FORMAT (x[0]);
    MPZ_CHECK_FORMAT (x[1]);
    ASSERT_ALWAYS (mpz_cmp_ui (x[0], 3L) == 0);
    ASSERT_ALWAYS (mpz_cmp_ui (x[1], 654L) == 0);
    mpz_clear (x[0]);
    mpz_clear (x[1]);
  }

  {
    mpq_t  x[2];
    mpq_init (x[0]);
    mpq_init (x[1]);
    mpq_set_ui (x[0], -987L, 654L);
    mpq_set_ui (x[1], 4115L, 226L);
    check_one ("123456", "%d%Qn%d", 123, x[0], 456);
    MPQ_CHECK_FORMAT (x[0]);
    MPQ_CHECK_FORMAT (x[1]);
    ASSERT_ALWAYS (mpq_cmp_ui (x[0], 3L, 1L) == 0);
    ASSERT_ALWAYS (mpq_cmp_ui (x[1], 4115L, 226L) == 0);
    mpq_clear (x[0]);
    mpq_clear (x[1]);
  }

  {
    mpf_t  x[2];
    mpf_init (x[0]);
    mpf_init (x[1]);
    mpf_set_ui (x[0], -987L);
    mpf_set_ui (x[1],  654L);
    check_one ("123456", "%d%Fn%d", 123, x[0], 456);
    MPF_CHECK_FORMAT (x[0]);
    MPF_CHECK_FORMAT (x[1]);
    ASSERT_ALWAYS (mpf_cmp_ui (x[0], 3L) == 0);
    ASSERT_ALWAYS (mpf_cmp_ui (x[1], 654L) == 0);
    mpf_clear (x[0]);
    mpf_clear (x[1]);
  }

  {
    mp_limb_t  a[5];
    mp_limb_t  a_want[numberof(a)];
    mp_size_t  i;

    a[0] = 123;
    check_one ("blah", "bl%Nnah", a, (mp_size_t) 0);
    ASSERT_ALWAYS (a[0] == 123);

    MPN_ZERO (a_want, numberof (a_want));
    for (i = 1; i < numberof (a); i++)
      {
	check_one ("blah", "bl%Nnah", a, i);
	a_want[0] = 2;
	ASSERT_ALWAYS (mpn_cmp (a, a_want, i) == 0);
      }
  }
}
コード例 #11
0
ファイル: floatbasic.cpp プロジェクト: AnZhg/mU
bool mpfc_iszero(mpfc_ptr x)
{
	return (mpf_cmp_ui(x->Im,0)==0)&&(mpf_cmp_ui(x->Re,0)==0);
}
コード例 #12
0
ファイル: big_float.c プロジェクト: canmor-lam/libsg
int sg_big_float_cmp_zero(sg_big_float_t* a)
{
    return mpf_cmp_ui(a->mpf, 0);
}
コード例 #13
0
ファイル: t-sqrt_ui.c プロジェクト: AllardJ/Tomato
void
check_rand (void)
{
  unsigned long      max_prec = 15;
  unsigned long      min_prec = __GMPF_BITS_TO_PREC (1);
  gmp_randstate_ptr  rands = RANDS;
  unsigned long      x, prec;
  mpf_t              r, s;
  int                i;

  mpf_init (r);
  mpf_init (s);
  refmpf_set_prec_limbs (s, 2*max_prec+10);

  for (i = 0; i < 50; i++)
    {
      /* input, a random non-zero ulong, exponentially distributed */
      do {
        x = gmp_urandomb_ui (rands,
                             gmp_urandomm_ui (rands, BITS_PER_ULONG) + 1);
      } while (x == 0);

      /* result precision */
      prec = gmp_urandomm_ui (rands, max_prec-min_prec) + min_prec;
      refmpf_set_prec_limbs (r, prec);

      mpf_sqrt_ui (r, x);
      MPF_CHECK_FORMAT (r);

      /* Expect to prec limbs of result.
         In the current implementation there's no stripping of low zero
         limbs in mpf_sqrt_ui, not even on perfect squares, so size should
         be exactly prec.  */
      if (SIZ(r) != prec)
        {
          printf ("mpf_sqrt_ui result not enough result limbs\n");
          printf    ("  x=%lu\n", x);
          printf    ("  want prec=%lu\n", prec);
          mpf_trace ("  r", r);
          printf    ("  r size %ld\n", (long) SIZ(r));
          printf    ("  r prec %ld\n", (long) PREC(r));
          abort ();
        }

      /* Must have r^2 <= x, since r has been truncated. */
      mpf_mul (s, r, r);
      if (! (mpf_cmp_ui (s, x) <= 0))
        {
          printf    ("mpf_sqrt_ui result too big\n");
          printf    ("  x=%lu\n", x);
          printf    ("  want prec=%lu\n", prec);
          mpf_trace ("  r", r);
          mpf_trace ("  s", s);
          abort ();
        }

      /* Must have (r+ulp)^2 > x.
         No overflow from refmpf_add_ulp since r is only prec limbs. */
      refmpf_add_ulp (r);
      mpf_mul (s, r, r);
      if (! (mpf_cmp_ui (s, x) > 0))
        {
          printf    ("mpf_sqrt_ui result too small\n");
          printf    ("  x=%lu\n", x);
          printf    ("  want prec=%lu\n", prec);
          mpf_trace ("  r+ulp", r);
          mpf_trace ("  s", s);
          abort ();
        }
    }

  mpf_clear (r);
  mpf_clear (s);
}
コード例 #14
0
ファイル: tfprintf.c プロジェクト: Scorpiion/Renux_cross_gcc
static void
check_mixed (FILE *fout)
{
  int ch = 'a';
  signed char sch = -1;
  unsigned char uch = 1;
  short sh = -1;
  unsigned short ush = 1;
  int i = -1;
  int j = 1;
  unsigned int ui = 1;
  long lo = -1;
  unsigned long ulo = 1;
  float f = -1.25;
  double d = -1.25;
  long double ld = -1.25;

  ptrdiff_t p = 1;
  size_t sz = 1;

  mpz_t mpz;
  mpq_t mpq;
  mpf_t mpf;
  mp_rnd_t rnd = GMP_RNDN;

  mp_size_t limb_size = 3;
  mp_limb_t limb[3];

  mpfr_t mpfr;
  mpfr_prec_t prec = 53;

  mpz_init (mpz);
  mpz_set_ui (mpz, ulo);
  mpq_init (mpq);
  mpq_set_si (mpq, lo, ulo);
  mpf_init (mpf);
  mpf_set_q (mpf, mpq);

  mpfr_init2 (mpfr, prec);
  mpfr_set_f (mpfr, mpf, GMP_RNDN);

  limb[0] = limb[1] = limb[2] = ~ (mp_limb_t) 0;

  check_vfprintf (fout, "a. %Ra, b. %u, c. %lx%n", mpfr, ui, ulo, &j);
  check_length (1, j, 22, d);
  check_vfprintf (fout, "a. %c, b. %Rb, c. %u, d. %li%ln", i, mpfr, i,
                  lo, &ulo);
  check_length (2, ulo, 36, lu);
  check_vfprintf (fout, "a. %hi, b. %*f, c. %Re%hn", ush, 3, f, mpfr, &ush);
  check_length (3, ush, 29, hu);
  check_vfprintf (fout, "a. %hi, b. %f, c. %#.2Rf%n", sh, d, mpfr, &i);
  check_length (4, i, 29, d);
  check_vfprintf (fout, "a. %R*A, b. %Fe, c. %i%zn", rnd, mpfr, mpf, sz,
                  &sz);
  check_length (5, (unsigned long) sz, 34, lu); /* no format specifier "%zu" in C89 */
  check_vfprintf (fout, "a. %Pu, b. %c, c. %Zi%Zn", prec, ch, mpz, &mpz);
  check_length_with_cmp (6, mpz, 17, mpz_cmp_ui (mpz, 17), Zi);
  check_vfprintf (fout, "%% a. %#.0RNg, b. %Qx%Rn, c. %p", mpfr, mpq, &mpfr,
                  (void *) &i);
  check_length_with_cmp (7, mpfr, 15, mpfr_cmp_ui (mpfr, 15), Rg);

#ifndef NPRINTF_T
  check_vfprintf (fout, "%% a. %RNg, b. %Qx, c. %td%tn", mpfr, mpq, p, &p);
  check_length (8, (long) p, 20, ld); /* no format specifier "%td" in C89 */
#endif

#ifndef NPRINTF_L
  check_vfprintf (fout, "a. %RA, b. %Lf, c. %QX%zn", mpfr, ld, mpq, &sz);
  check_length (9, (unsigned long) sz, 30, lu); /* no format specifier "%zu" in C89 */
#endif

#ifndef NPRINTF_HH
  check_vfprintf (fout, "a. %hhi, b.%RA, c. %hhu%hhn", sch, mpfr, uch, &uch);
  check_length (10, (unsigned int) uch, 21, u); /* no format specifier "%hhu" in C89 */
#endif

#if (__GNU_MP_VERSION * 10 + __GNU_MP_VERSION_MINOR) >= 42
  /* The 'M' specifier was added in gmp 4.2.0 */
  check_vfprintf (fout, "a. %Mx b. %Re%Mn", limb[0], mpfr, &limb[0]);
  if (limb[0] != 14 + BITS_PER_MP_LIMB / 4 || limb[1] != ~ (mp_limb_t) 0
      || limb[2] != ~ (mp_limb_t) 0)
    {
      printf ("Error in test #11: mpfr_vfprintf did not print %d characters"
              " as expected\n", 14 + (int) BITS_PER_MP_LIMB / 4);
      exit (1);
    }

  limb[0] = ~ (mp_limb_t) 0;
  /* we tell vfprintf that limb array is 2 cells wide
     and check it doesn't go through */
  check_vfprintf (fout, "a. %Re .b %Nx%Nn", mpfr, limb, limb_size, limb,
                  limb_size - 1);
  if (limb[0] != 14 + 3 * BITS_PER_MP_LIMB / 4 || limb[1] != (mp_limb_t) 0
      || limb[2] != ~ (mp_limb_t) 0)
    {
      printf ("Error in test #12: mpfr_vfprintf did not print %d characters"
              " as expected\n", 14 + (int) BITS_PER_MP_LIMB / 4);
      exit (1);
    }
#endif

#if defined(HAVE_LONG_LONG) && !defined(NPRINTF_LL)
  {
    long long llo = -1;
    unsigned long long ullo = 1;

    check_vfprintf (fout, "a. %Re, b. %llx%Qn", mpfr, ullo, &mpq);
    check_length_with_cmp (21, mpq, 16, mpq_cmp_ui (mpq, 16, 1), Qu);
    check_vfprintf (fout, "a. %lli, b. %Rf%Fn", llo, mpfr, &mpf);
    check_length_with_cmp (22, mpf, 19, mpf_cmp_ui (mpf, 19), Fg);
  }
#endif

#if defined(_MPFR_H_HAVE_INTMAX_T) && !defined(NPRINTF_J)
  {
    intmax_t im = -1;
    uintmax_t uim = 1;

    check_vfprintf (fout, "a. %*RA, b. %ji%Qn", 10, mpfr, im, &mpq);
    check_length_with_cmp (31, mpq, 20, mpq_cmp_ui (mpq, 20, 1), Qu);
    check_vfprintf (fout, "a. %.*Re, b. %jx%Fn", 10, mpfr, uim, &mpf);
    check_length_with_cmp (32, mpf, 25, mpf_cmp_ui (mpf, 25), Fg);
  }
#endif

  mpfr_clear (mpfr);
  mpf_clear (mpf);
  mpq_clear (mpq);
  mpz_clear (mpz);
}
コード例 #15
0
ファイル: tprintf.c プロジェクト: michalkonecny/haskell-mpfr
static void
check_mixed (void)
{
  int ch = 'a';
#ifndef NPRINTF_HH
  signed char sch = -1;
  unsigned char uch = 1;
#endif
  short sh = -1;
  unsigned short ush = 1;
  int i = -1;
  int j = 1;
  unsigned int ui = 1;
  long lo = -1;
  unsigned long ulo = 1;
  float f = -1.25;
  double d = -1.25;
#if !defined(NPRINTF_T) || !defined(NPRINTF_L)
  long double ld = -1.25;
#endif

#ifndef NPRINTF_T
  ptrdiff_t p = 1, saved_p;
#endif
  size_t sz = 1;

  mpz_t mpz;
  mpq_t mpq;
  mpf_t mpf;
  mpfr_rnd_t rnd = MPFR_RNDN;

  mpfr_t mpfr;
  mpfr_prec_t prec;

  mpz_init (mpz);
  mpz_set_ui (mpz, ulo);
  mpq_init (mpq);
  mpq_set_si (mpq, lo, ulo);
  mpf_init (mpf);
  mpf_set_q (mpf, mpq);
  mpfr_init (mpfr);
  mpfr_set_f (mpfr, mpf, MPFR_RNDN);
  prec = mpfr_get_prec (mpfr);

  check_vprintf ("a. %Ra, b. %u, c. %lx%n", mpfr, ui, ulo, &j);
  check_length (1, j, 22, d);
  check_vprintf ("a. %c, b. %Rb, c. %u, d. %li%ln", i, mpfr, i, lo, &ulo);
  check_length (2, ulo, 36, lu);
  check_vprintf ("a. %hi, b. %*f, c. %Re%hn", ush, 3, f, mpfr, &ush);
  check_length (3, ush, 29, hu);
  check_vprintf ("a. %hi, b. %f, c. %#.2Rf%n", sh, d, mpfr, &i);
  check_length (4, i, 29, d);
  check_vprintf ("a. %R*A, b. %Fe, c. %i%zn", rnd, mpfr, mpf, sz, &sz);
  check_length (5, (unsigned long) sz, 34, lu); /* no format specifier '%zu' in C89 */
  check_vprintf ("a. %Pu, b. %c, c. %RUG, d. %Zi%Zn", prec, ch, mpfr, mpz, &mpz);
  check_length_with_cmp (6, mpz, 24, mpz_cmp_ui (mpz, 24), Zi);
  check_vprintf ("%% a. %#.0RNg, b. %Qx%Rn c. %p",
                 mpfr, mpq, &mpfr, (void *) &i);
  check_length_with_cmp (7, mpfr, 15, mpfr_cmp_ui (mpfr, 15), Rg);

#ifndef NPRINTF_T
  saved_p = p;
  check_vprintf ("%% a. %RNg, b. %Qx, c. %td%tn", mpfr, mpq, p, &p);
  if (p != 20)
    mpfr_fprintf (stderr, "Error in test 8, got '%% a. %RNg, b. %Qx, c. %td'\n", mpfr, mpq, saved_p);
  check_length (8, (long) p, 20, ld); /* no format specifier '%td' in C89 */
#endif

#ifndef NPRINTF_L
  check_vprintf ("a. %RA, b. %Lf, c. %QX%zn", mpfr, ld, mpq, &sz);
  check_length (9, (unsigned long) sz, 30, lu); /* no format specifier '%zu' in C89 */
#endif

#ifndef NPRINTF_HH
  check_vprintf ("a. %hhi, b. %Ra, c. %hhu%hhn", sch, mpfr, uch, &uch);
  check_length (10, (unsigned int) uch, 22, u); /* no format specifier '%hhu' in C89 */
#endif

#if defined(HAVE_LONG_LONG) && !defined(NPRINTF_LL)
  {
    long long llo = -1;
    unsigned long long ullo = 1;

    check_vprintf ("a. %Re, b. %llx%Qn", mpfr, ullo, &mpq);
    check_length_with_cmp (11, mpq, 16, mpq_cmp_ui (mpq, 16, 1), Qu);
    check_vprintf ("a. %lli, b. %Rf%lln", llo, mpfr, &ullo);
    check_length (12, ullo, 19, llu);
  }
#endif

#if defined(_MPFR_H_HAVE_INTMAX_T) && !defined(NPRINTF_J)
  {
    intmax_t im = -1;
    uintmax_t uim = 1;

    check_vprintf ("a. %*RA, b. %ji%Fn", 10, mpfr, im, &mpf);
    check_length_with_cmp (31, mpf, 20, mpf_cmp_ui (mpf, 20), Fg);
    check_vprintf ("a. %.*Re, b. %jx%jn", 10, mpfr, uim, &im);
    check_length (32, (long) im, 25, li); /* no format specifier "%ji" in C89 */
  }
#endif

  mpfr_clear (mpfr);
  mpf_clear (mpf);
  mpq_clear (mpq);
  mpz_clear (mpz);
}
コード例 #16
0
ファイル: main.c プロジェクト: MattiHameister/Mandelbrot
void renderImage(screenTiles *tile, uint32_t threadNum) {
	printf("Rendere: %ix%ix%ix%i\n",tile->fromX,tile->toX,tile->fromY,tile->toY);
	mpf_t tmpDiff;
	mpf_t tmp;
	mpf_t re_factor;
	mpf_t im_factor;
	mpf_t c_im;
	mpf_t c_re;
	mpf_t z_re;
	mpf_t z_im;
	mpf_t z_re2;
	mpf_t z_im2;
	
	mpf_init2(tmpDiff,gmpBit);
	mpf_init2(tmp,gmpBit);
	mpf_init2(re_factor,gmpBit);
	mpf_init2(im_factor,gmpBit);
	mpf_init2(c_im,gmpBit);
	mpf_init2(c_re,gmpBit);
	mpf_init2(z_im,gmpBit);
	mpf_init2(z_re,gmpBit);
	mpf_init2(z_im2,gmpBit);
	mpf_init2(z_re2,gmpBit);
	
	mpf_sub(tmpDiff,mandelRange.maxRe,mandelRange.minRe);
	
	long double sX = sizeX;
	long double sY = sizeY;
	mpf_set_d(tmp, sY/sX);
	//	maxIm = minIm + (maxRe - minRe) * sizeY / sizeX;
	mpf_mul(tmp,tmpDiff,tmp);
	mpf_add(mandelRange.maxIm,mandelRange.minIm,tmp);
	//	re_factor = (maxRe - minRe) / (sizeX - 1);
	mpf_set_d(tmp, sX-1.0);
	mpf_div(re_factor, tmpDiff, tmp);
	//	im_factor = (maxIm - minIm) / (sizeY - 1);	
	mpf_sub(tmpDiff,mandelRange.maxIm,mandelRange.minIm);
	mpf_set_d(tmp, sY-1.0);
	mpf_div(im_factor,tmpDiff, tmp);
	
	
	for (int32_t y = tile->fromY; y < tile->toY; ++y) {
		//c_im = maxIm - y * im_factor;
		mpf_mul_ui(tmpDiff, im_factor, y);
		mpf_sub(c_im,mandelRange.maxIm,tmpDiff);
		for (int32_t x = tile->fromX; x < tile->toX; ++x) {
			//c_re = minRe + x * re_factor;
			mpf_mul_ui(tmpDiff, re_factor, x);
			mpf_add(c_re,mandelRange.minRe,tmpDiff);
			
			mpf_set(z_re,c_re);
			mpf_set(z_im,c_im);
			
			int32_t isInside = 1;
			for (uint32_t n = 0; n < maxIterations; ++n) {
				//Z_re2 = Z_re * Z_re;
				mpf_mul(z_re2,z_re,z_re);
				//Z_im2 = Z_im * Z_im;
				mpf_mul(z_im2,z_im,z_im);
				
				//Z_re2 + Z_im2 > 4
				mpf_add(tmp, z_re2, z_im2);
				if (mpf_cmp_ui(tmp,4) > 0) {
					isInside = 0;
					uint8_t red = 0;
					uint8_t green = 0;
					uint8_t blue = 0;
					//#############################################################
					if (n <= maxIterations / 2 - 1) {
						//blackToRed
						float full = (maxIterations / 2 - 1);
						float f = (((n * 100) / full) / 100)*255;
						red = f;
						green = 0;
						blue = 0;						
					} else if (n >= maxIterations / 2 && n <= maxIterations - 1) {
						//redToWhite
						float full = maxIterations - 1;
						float f = (((n * 100) / full) / 100)*255;
						red = 255;
						green = f;
						blue = f;
					}
					savePixel(threadNum, x, y, red, green, blue);
					//#############################################################
					break;
				}
				//Z_im = 2 * Z_re * Z_im + c_im;
				mpf_mul_ui(tmp, z_re, 2);
				mpf_mul(tmp,tmp,z_im);
				mpf_add(z_im,tmp,c_im);
				
				//Z_re = Z_re2 - Z_im2 + c_re;
				mpf_sub(tmp,z_re2,z_im2);
				mpf_add(z_re,tmp,c_re);
				
				// Thread hat den Stop-Befehl bekommen.
				if(threadStop == 1) {
					return;
				}
				
			}
			if (isInside) {
				savePixel(threadNum, x, y, 0, 0, 0);
			}
		}
	}
	mpf_clear(c_im);
	mpf_clear(c_re);
	mpf_clear(z_im);
	mpf_clear(z_re);
	mpf_clear(z_im2);
	mpf_clear(z_re2);
	mpf_clear(re_factor);
	mpf_clear(im_factor);
	mpf_clear(tmpDiff);
	mpf_clear(tmp);
	printf("Fertig mit: %ix%ix%ix%i\n",tile->fromX,tile->toX,tile->fromY,tile->toY);
}
コード例 #17
0
int
main (int argc, char *argv[])
{
  const char usage[] = "usage: findlc [-dv] m2exp [low_merit [high_merit]]\n";
  int f;
  int v_lose, m_lose, v_best, m_best;
  int c;
  int debug = 1;
  int cnt_high_merit;
  mpz_t m;
  unsigned long int m2exp;
#define DIMS 6			/* dimensions run in spectral test */
  mpf_t v[DIMS-1];		/* spectral test result (there's no v
                                   for 1st dimension */
  mpf_t f_merit, low_merit, high_merit;
  mpz_t acc, minus8;
  mpz_t min, max;
  mpz_t s;


  mpz_init (m);
  mpz_init (a);
  for (f = 0; f < DIMS-1; f++)
    mpf_init (v[f]);
  mpf_init (f_merit);
  mpf_init_set_d (low_merit, .1);
  mpf_init_set_d (high_merit, .1);

  while ((c = getopt (argc, argv, "a:di:hv")) != -1)
    switch (c)
      {
      case 'd':			/* debug */
	g_debug++;
	break;

      case 'v':			/* print version */
	puts (rcsid[1]);
	exit (0);

      case 'h':
      case '?':
      default:
	fputs (usage, stderr);
	exit (1);
      }

  argc -= optind;
  argv += optind;

  if (argc < 1)
    {
      fputs (usage, stderr);
      exit (1);
    }

  /* Install signal handler. */
  if (SIG_ERR == signal (SIGSEGV, sh_status))
    {
      perror ("signal (SIGSEGV)");
      exit (1);
    }
  if (SIG_ERR == signal (SIGHUP, sh_status))
    {
      perror ("signal (SIGHUP)");
      exit (1);
    }

  printf ("findlc: version: %s\n", rcsid[1]);
  m2exp = atol (argv[0]);
  mpz_init_set_ui (m, 1);
  mpz_mul_2exp (m, m, m2exp);
  printf ("m = 0x");
  mpz_out_str (stdout, 16, m);
  puts ("");

  if (argc > 1)			/* have low_merit */
    mpf_set_str (low_merit, argv[1], 0);
  if (argc > 2)			/* have high_merit */
    mpf_set_str (high_merit, argv[2], 0);

  if (debug)
    {
      fprintf (stderr, "low_merit = ");
      mpf_out_str (stderr, 10, 2, low_merit);
      fprintf (stderr, "; high_merit = ");
      mpf_out_str (stderr, 10, 2, high_merit);
      fputs ("\n", stderr);
    }

  mpz_init (minus8);
  mpz_set_si (minus8, -8L);
  mpz_init_set_ui (acc, 0);
  mpz_init (s);
  mpz_init_set_d (min, 0.01 * pow (2.0, (double) m2exp));
  mpz_init_set_d (max, 0.99 * pow (2.0, (double) m2exp));

  mpz_true_random (s, m2exp);	/* Start.  */
  mpz_setbit (s, 0);		/* Make it odd.  */

  v_best = m_best = 2*(DIMS-1);
  for (;;) 
    {
      mpz_add (acc, acc, s);
      mpz_mod_2exp (acc, acc, m2exp);
#if later
      mpz_and_si (a, acc, -8L);
#else
      mpz_and (a, acc, minus8);
#endif
      mpz_add_ui (a, a, 5);
      if (mpz_cmp (a, min) <= 0 || mpz_cmp (a, max) >= 0)
	continue;

      spectral_test (v, DIMS, a, m);
      for (f = 0, v_lose = m_lose = 0, cnt_high_merit = DIMS-1;
	   f < DIMS-1; f++)
	{
	  merit (f_merit, f + 2, v[f], m);

	  if (mpf_cmp_ui (v[f], 1 << (30 / (f + 2) + (f == 2))) < 0)
	    v_lose++;
	    
	  if (mpf_cmp (f_merit, low_merit) < 0)
	    m_lose++;

	  if (mpf_cmp (f_merit, high_merit) >= 0)
	    cnt_high_merit--;
	}

      if (0 == v_lose && 0 == m_lose)
	{
	  mpz_out_str (stdout, 10, a); puts (""); fflush (stdout);
	  if (0 == cnt_high_merit)
	    break;		/* leave loop */
	}
      if (v_lose < v_best)
	{
	  v_best = v_lose;
	  printf ("best (v_lose=%d; m_lose=%d): ", v_lose, m_lose);
	  mpz_out_str (stdout, 10, a); puts (""); fflush (stdout);
	}
      if (m_lose < m_best)
	{
	  m_best = m_lose;
	  printf ("best (v_lose=%d; m_lose=%d): ", v_lose, m_lose);
	  mpz_out_str (stdout, 10, a); puts (""); fflush (stdout);
	}
    }

  mpz_clear (m);
  mpz_clear (a);
  for (f = 0; f < DIMS-1; f++)
    mpf_clear (v[f]);
  mpf_clear (f_merit);
  mpf_clear (low_merit);
  mpf_clear (high_merit);

  printf ("done.\n");
  return 0;
}
コード例 #18
0
ファイル: reuse.c プロジェクト: mahdiz/mpclib
int
main (int argc, char **argv)
{
  int i;
  int pass, reps = 10000;
  mpf_t in1, in2, out1;
  unsigned long int in1i, in2i;
  mpf_t res1, res2, res3;
  mp_size_t bprec = 100;

  tests_start ();

  if (argc > 1)
    {
      reps = strtol (argv[1], 0, 0);
      if (argc > 2)
	bprec = strtol (argv[2], 0, 0);
    }

  mpf_set_default_prec (bprec);

  mpf_init (in1);
  mpf_init (in2);
  mpf_init (out1);
  mpf_init (res1);
  mpf_init (res2);
  mpf_init (res3);

  for (pass = 1; pass <= reps; pass++)
    {
      mpf_random2 (in1, urandom () % SIZE - SIZE/2, urandom () % EXPO);
      mpf_random2 (in2, urandom () % SIZE - SIZE/2, urandom () % EXPO);

      for (i = 0; i < sizeof (dss_funcs) / sizeof (dss_func); i++)
	{
	  /* Don't divide by 0.  */
	  if (i == 0 && mpf_cmp_ui (in2, 0) == 0)
	    continue;

	  (dss_funcs[i]) (res1, in1, in2);

	  mpf_set (out1, in1);
	  (dss_funcs[i]) (out1, out1, in2);
	  mpf_set (res2, out1);

	  mpf_set (out1, in2);
	  (dss_funcs[i]) (out1, in1, out1);
	  mpf_set (res3, out1);

	  if (mpf_cmp (res1, res2) != 0)
	    dump_abort (dss_func_names[i], res1, res2);
	  if (mpf_cmp (res1, res3) != 0)
	    dump_abort (dss_func_names[i], res1, res3);
	}

      in2i = urandom ();
      for (i = 0; i < sizeof (dsi_funcs) / sizeof (dsi_func); i++)
	{
	  /* Don't divide by 0.  */
	  if (strcmp (dsi_func_names[i], "mpf_div_ui") == 0 && in2i == 0)
	    continue;

	  (dsi_funcs[i]) (res1, in1, in2i);

	  mpf_set (out1, in1);
	  (dsi_funcs[i]) (out1, out1, in2i);
	  mpf_set (res2, out1);

	  if (mpf_cmp (res1, res2) != 0)
	    dump_abort (dsi_func_names[i], res1, res2);
	}

      in1i = urandom ();
      for (i = 0; i < sizeof (dis_funcs) / sizeof (dis_func); i++)
	{
	  /* Don't divide by 0.  */
	  if (strcmp (dis_func_names[i], "mpf_ui_div") == 0
	      && mpf_cmp_ui (in2, 0) == 0)
	    continue;

	  (dis_funcs[i]) (res1, in1i, in2);

	  mpf_set (out1, in2);
	  (dis_funcs[i]) (out1, in1i, out1);
	  mpf_set (res2, out1);

	  if (mpf_cmp (res1, res2) != 0)
	    dump_abort (dis_func_names[i], res1, res2);
	}

    }

  mpf_clear (in1);
  mpf_clear (in2);
  mpf_clear (out1);
  mpf_clear (res1);
  mpf_clear (res2);
  mpf_clear (res3);

  tests_end ();
  exit (0);
}
コード例 #19
0
void
check_n (void)
{
  int    ret;

  /* %n suppressed */
  {
    int n = 123;
    gmp_sscanf ("   ", " %*n", &n);
    ASSERT_ALWAYS (n == 123);
  }
  {
    int n = 123;
    fromstring_gmp_fscanf ("   ", " %*n", &n);
    ASSERT_ALWAYS (n == 123);
  }


#define CHECK_N(type, string)                           \
  do {                                                  \
    type  x[2];                                         \
    char  fmt[128];                                     \
    int   ret;                                          \
                                                        \
    x[0] = ~ (type) 0;                                  \
    x[1] = ~ (type) 0;                                  \
    sprintf (fmt, "abc%%%sn", string);                  \
    ret = gmp_sscanf ("abc", fmt, &x[0]);               \
                                                        \
    ASSERT_ALWAYS (ret == 0);                           \
                                                        \
    /* should write whole of x[0] and none of x[1] */   \
    ASSERT_ALWAYS (x[0] == 3);                          \
    ASSERT_ALWAYS (x[1] == (type) ~ (type) 0);		\
                                                        \
  } while (0)

  CHECK_N (char,      "hh");
  CHECK_N (long,      "l");
#if HAVE_LONG_LONG
  CHECK_N (long long, "L");
#endif
#if HAVE_INTMAX_T
  CHECK_N (intmax_t,  "j");
#endif
#if HAVE_PTRDIFF_T
  CHECK_N (ptrdiff_t, "t");
#endif
  CHECK_N (short,     "h");
  CHECK_N (size_t,    "z");

  /* %Zn */
  {
    mpz_t  x[2];
    mpz_init_set_si (x[0], -987L);
    mpz_init_set_si (x[1],  654L);
    ret = gmp_sscanf ("xyz   ", "xyz%Zn", x[0]);
    MPZ_CHECK_FORMAT (x[0]);
    MPZ_CHECK_FORMAT (x[1]);
    ASSERT_ALWAYS (ret == 0);
    ASSERT_ALWAYS (mpz_cmp_ui (x[0], 3L) == 0);
    ASSERT_ALWAYS (mpz_cmp_ui (x[1], 654L) == 0);
    mpz_clear (x[0]);
    mpz_clear (x[1]);
  }
  {
    mpz_t  x;
    mpz_init (x);
    ret = fromstring_gmp_fscanf ("xyz   ", "xyz%Zn", x);
    ASSERT_ALWAYS (ret == 0);
    ASSERT_ALWAYS (mpz_cmp_ui (x, 3L) == 0);
    mpz_clear (x);
  }

  /* %Qn */
  {
    mpq_t  x[2];
    mpq_init (x[0]);
    mpq_init (x[1]);
    mpq_set_ui (x[0], -987L, 654L);
    mpq_set_ui (x[1], 4115L, 226L);
    ret = gmp_sscanf ("xyz   ", "xyz%Qn", x[0]);
    MPQ_CHECK_FORMAT (x[0]);
    MPQ_CHECK_FORMAT (x[1]);
    ASSERT_ALWAYS (ret == 0);
    ASSERT_ALWAYS (mpq_cmp_ui (x[0], 3L, 1L) == 0);
    ASSERT_ALWAYS (mpq_cmp_ui (x[1], 4115L, 226L) == 0);
    mpq_clear (x[0]);
    mpq_clear (x[1]);
  }
  {
    mpq_t  x;
    mpq_init (x);
    ret = fromstring_gmp_fscanf ("xyz   ", "xyz%Qn", x);
    ASSERT_ALWAYS (ret == 0);
    ASSERT_ALWAYS (mpq_cmp_ui (x, 3L, 1L) == 0);
    mpq_clear (x);
  }

  /* %Fn */
  {
    mpf_t  x[2];
    mpf_init (x[0]);
    mpf_init (x[1]);
    mpf_set_ui (x[0], -987L);
    mpf_set_ui (x[1],  654L);
    ret = gmp_sscanf ("xyz   ", "xyz%Fn", x[0]);
    MPF_CHECK_FORMAT (x[0]);
    MPF_CHECK_FORMAT (x[1]);
    ASSERT_ALWAYS (ret == 0);
    ASSERT_ALWAYS (mpf_cmp_ui (x[0], 3L) == 0);
    ASSERT_ALWAYS (mpf_cmp_ui (x[1], 654L) == 0);
    mpf_clear (x[0]);
    mpf_clear (x[1]);
  }
  {
    mpf_t  x;
    mpf_init (x);
    ret = fromstring_gmp_fscanf ("xyz   ", "xyz%Fn", x);
    ASSERT_ALWAYS (ret == 0);
    ASSERT_ALWAYS (mpf_cmp_ui (x, 3L) == 0);
    mpf_clear (x);
  }
}
コード例 #20
0
ファイル: tget_f.c プロジェクト: sudheesh001/SEC-LAB
int
main (void)
{
  mpf_t x;
  mpfr_t y, z;
  unsigned long i;
  mpfr_exp_t e;
  int inex;

  tests_start_mpfr ();

  mpfr_init (y);
  mpfr_init (z);
  mpf_init (x);

  i = 1;
  while (i)
    {
      mpfr_set_ui (y, i, MPFR_RNDN);
      if (mpfr_get_f (x, y, MPFR_RNDN) != 0 || mpf_cmp_ui (x, i))
        {
          printf ("Error: mpfr_get_f(%lu) fails\n", i);
          exit (1);
        }
      if (i <= - (unsigned long) LONG_MIN)
        {
          long j = i < - (unsigned long) LONG_MIN ? - (long) i : LONG_MIN;
          mpfr_set_si (y, j, MPFR_RNDN);
          if (mpfr_get_f (x, y, MPFR_RNDN) != 0 || mpf_cmp_si (x, j))
            {
              printf ("Error: mpfr_get_f(-%lu) fails\n", i);
              exit (1);
            }
        }
      i *= 2;
    }

  /* same tests, but with a larger precision for y, which requires to
     round it */
  mpfr_set_prec (y, 100);
  i = 1;
  while (i)
    {
      mpfr_set_ui (y, i, MPFR_RNDN);
      inex = mpfr_get_f (x, y, MPFR_RNDN);
      if (! SAME_SIGN (inex, - mpfr_cmp_f (y, x)) || mpf_cmp_ui (x, i))
        {
          printf ("Error: mpfr_get_f(%lu) fails\n", i);
          exit (1);
        }
      mpfr_set_si (y, (signed long) -i, MPFR_RNDN);
      inex = mpfr_get_f (x, y, MPFR_RNDN);
      if (! SAME_SIGN (inex, - mpfr_cmp_f (y, x))
          || mpf_cmp_si (x, (signed long) -i))
        {
          printf ("Error: mpfr_get_f(-%lu) fails\n", i);
          exit (1);
        }
      i *= 2;
    }

  /* bug reported by Jim White */
  for (e = 0; e <= 2 * GMP_NUMB_BITS; e++)
    {
      /* test with 2^(-e) */
      mpfr_set_ui (y, 1, MPFR_RNDN);
      mpfr_div_2exp (y, y, e, MPFR_RNDN);
      inex = mpfr_get_f (x, y, MPFR_RNDN);
      mpf_mul_2exp (x, x, e);
      if (inex != 0 || mpf_cmp_ui (x, 1) != 0)
        {
          printf ("Error: mpfr_get_f(x,y,MPFR_RNDN) fails\n");
          printf ("y=");
          mpfr_dump (y);
          printf ("x=");
          mpf_div_2exp (x, x, e);
          mpf_out_str (stdout, 2, 0, x);
          exit (1);
        }

      /* test with 2^(e) */
      mpfr_set_ui (y, 1, MPFR_RNDN);
      mpfr_mul_2exp (y, y, e, MPFR_RNDN);
      inex = mpfr_get_f (x, y, MPFR_RNDN);
      mpf_div_2exp (x, x, e);
      if (inex != 0 || mpf_cmp_ui (x, 1) != 0)
        {
          printf ("Error: mpfr_get_f(x,y,MPFR_RNDN) fails\n");
          printf ("y=");
          mpfr_dump (y);
          printf ("x=");
          mpf_mul_2exp (x, x, e);
          mpf_out_str (stdout, 2, 0, x);
          exit (1);
        }
    }

  /* Bug reported by Yury Lukach on 2006-04-05 */
  mpfr_set_prec (y, 32);
  mpfr_set_prec (z, 32);
  mpf_set_prec (x, 32);
  mpfr_set_ui_2exp (y, 0xc1234567, -30, MPFR_RNDN);
  mpfr_get_f (x, y, MPFR_RNDN);
  inex = mpfr_set_f (z, x, MPFR_RNDN);
  if (inex != 0 || ! mpfr_equal_p (y, z))
    {
      printf ("Error in mpfr_get_f:\n  inex = %d, y = ", inex);
      mpfr_dump (z);
      printf ("Expected:\n  inex = 0, y = ");
      mpfr_dump (y);
      exit (1);
    }

  mpfr_clear (y);
  mpfr_clear (z);
  mpf_clear (x);

  special_test ();
  prec_test ();
  ternary_test ();

  tests_end_mpfr ();
  return 0;
}