本文整理汇总了C++中MPFR_IS_SINGULAR函数的典型用法代码示例。如果您正苦于以下问题:C++ MPFR_IS_SINGULAR函数的具体用法?C++ MPFR_IS_SINGULAR怎么用?C++ MPFR_IS_SINGULAR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MPFR_IS_SINGULAR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test_cmp_z
static void
test_cmp_z (mpfr_prec_t pmin, mpfr_prec_t pmax, int nmax)
{
mpfr_t x, z;
mpz_t y;
mpfr_prec_t p;
int res1, res2;
int n;
mpfr_init (x);
mpfr_init2 (z, MPFR_PREC_MIN);
mpz_init (y);
/* check the erange flag when x is NaN */
mpfr_set_nan (x);
mpz_set_ui (y, 17);
mpfr_clear_erangeflag ();
res1 = mpfr_cmp_z (x, y);
if (res1 != 0 || mpfr_erangeflag_p () == 0)
{
printf ("Error for mpfr_cmp_z (NaN, 17)\n");
printf ("Return value: expected 0, got %d\n", res1);
printf ("Erange flag: expected set, got %d\n", mpfr_erangeflag_p ());
exit (1);
}
for(p=pmin ; p < pmax ; p++)
{
mpfr_set_prec (x, p);
for ( n = 0; n < nmax ; n++)
{
mpfr_urandomb (x, RANDS);
mpz_urandomb (y, RANDS, 1024);
if (!MPFR_IS_SINGULAR (x))
{
mpfr_sub_z (z, x, y, MPFR_RNDN);
res1 = mpfr_sgn (z);
res2 = mpfr_cmp_z (x, y);
if (res1 != res2)
{
printf("Error for mpfr_cmp_z: res=%d sub_z gives %d\n",
res2, res1);
exit (1);
}
}
}
}
mpz_clear (y);
mpfr_clear (x);
mpfr_clear (z);
}
开发者ID:Canar,项目名称:mpfr,代码行数:51,代码来源:tgmpop.c
示例2: mpfr_get_d_2exp
double
mpfr_get_d_2exp (long *expptr, mpfr_srcptr src, mpfr_rnd_t rnd_mode)
{
double ret;
mpfr_exp_t exp;
mpfr_t tmp;
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (src)))
{
int negative;
*expptr = 0;
if (MPFR_IS_NAN (src))
return MPFR_DBL_NAN;
negative = MPFR_IS_NEG (src);
if (MPFR_IS_INF (src))
return negative ? MPFR_DBL_INFM : MPFR_DBL_INFP;
MPFR_ASSERTD (MPFR_IS_ZERO(src));
return negative ? DBL_NEG_ZERO : 0.0;
}
tmp[0] = *src; /* Hack copy mpfr_t */
MPFR_SET_EXP (tmp, 0);
ret = mpfr_get_d (tmp, rnd_mode);
if (MPFR_IS_PURE_FP(src))
{
exp = MPFR_GET_EXP (src);
/* rounding can give 1.0, adjust back to 0.5 <= abs(ret) < 1.0 */
if (ret == 1.0)
{
ret = 0.5;
exp++;
}
else if (ret == -1.0)
{
ret = -0.5;
exp++;
}
MPFR_ASSERTN ((ret >= 0.5 && ret < 1.0)
|| (ret <= -0.5 && ret > -1.0));
MPFR_ASSERTN (exp >= LONG_MIN && exp <= LONG_MAX);
}
else
exp = 0;
*expptr = exp;
return ret;
}
开发者ID:Kirija,项目名称:XPIR,代码行数:50,代码来源:get_d.c
示例3: mpfr_get_ld
/* special code for IEEE 754 little-endian extended format */
long double
mpfr_get_ld (mpfr_srcptr x, mpfr_rnd_t rnd_mode)
{
mpfr_long_double_t ld;
mpfr_t tmp;
int inex;
MPFR_SAVE_EXPO_DECL (expo);
MPFR_SAVE_EXPO_MARK (expo);
mpfr_init2 (tmp, MPFR_LDBL_MANT_DIG);
inex = mpfr_set (tmp, x, rnd_mode);
mpfr_set_emin (-16382-63);
mpfr_set_emax (16384);
mpfr_subnormalize (tmp, mpfr_check_range (tmp, inex, rnd_mode), rnd_mode);
mpfr_prec_round (tmp, 64, MPFR_RNDZ); /* exact */
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (tmp)))
ld.ld = (long double) mpfr_get_d (tmp, rnd_mode);
else
{
mp_limb_t *tmpmant;
mpfr_exp_t e, denorm;
tmpmant = MPFR_MANT (tmp);
e = MPFR_GET_EXP (tmp);
/* The smallest positive normal number is 2^(-16382), which is
0.5*2^(-16381) in MPFR, thus any exponent <= -16382 corresponds to a
subnormal number. The smallest positive subnormal number is 2^(-16445)
which is 0.5*2^(-16444) in MPFR thus 0 <= denorm <= 63. */
denorm = MPFR_UNLIKELY (e <= -16382) ? - e - 16382 + 1 : 0;
MPFR_ASSERTD (0 <= denorm && denorm < 64);
#if GMP_NUMB_BITS >= 64
ld.s.manl = (tmpmant[0] >> denorm);
ld.s.manh = (tmpmant[0] >> denorm) >> 32;
#elif GMP_NUMB_BITS == 32
if (MPFR_LIKELY (denorm == 0))
{
ld.s.manl = tmpmant[0];
ld.s.manh = tmpmant[1];
}
else if (denorm < 32)
{
ld.s.manl = (tmpmant[0] >> denorm) | (tmpmant[1] << (32 - denorm));
ld.s.manh = tmpmant[1] >> denorm;
}
else /* 32 <= denorm < 64 */
{
开发者ID:Canar,项目名称:mpfr,代码行数:49,代码来源:get_ld.c
示例4: MPFR_INT_SIGN
int
(mpfr_sgn) (mpfr_srcptr a)
{
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (a)))
{
if (MPFR_LIKELY (MPFR_IS_ZERO (a)))
return 0;
if (MPFR_UNLIKELY (MPFR_IS_NAN (a)))
{
MPFR_SET_ERANGEFLAG ();
return 0;
}
/* Remains infinity, handled by the return below. */
}
return MPFR_INT_SIGN (a);
}
开发者ID:epowers,项目名称:mpfr,代码行数:16,代码来源:sgn.c
示例5: mpfr_get_z
int
mpfr_get_z (mpz_ptr z, mpfr_srcptr f, mpfr_rnd_t rnd)
{
int inex;
mpfr_t r;
mpfr_exp_t exp;
MPFR_SAVE_EXPO_DECL (expo);
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
{
if (MPFR_UNLIKELY (MPFR_NOTZERO (f)))
MPFR_SET_ERANGEFLAG ();
mpz_set_ui (z, 0);
/* The ternary value is 0 even for infinity. Giving the rounding
direction in this case would not make much sense anyway, and
the direction would not necessarily match rnd. */
return 0;
}
MPFR_SAVE_EXPO_MARK (expo);
exp = MPFR_GET_EXP (f);
/* if exp <= 0, then |f|<1, thus |o(f)|<=1 */
MPFR_ASSERTN (exp < 0 || exp <= MPFR_PREC_MAX);
mpfr_init2 (r, (exp < (mpfr_exp_t) MPFR_PREC_MIN ?
MPFR_PREC_MIN : (mpfr_prec_t) exp));
inex = mpfr_rint (r, f, rnd);
MPFR_ASSERTN (inex != 1 && inex != -1); /* integral part of f is
representable in r */
MPFR_ASSERTN (MPFR_IS_FP (r));
/* The flags from mpfr_rint are the wanted ones. In particular,
it sets the inexact flag when necessary. */
MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
exp = mpfr_get_z_2exp (z, r);
if (exp >= 0)
mpz_mul_2exp (z, z, exp);
else
mpz_fdiv_q_2exp (z, z, -exp);
mpfr_clear (r);
MPFR_SAVE_EXPO_FREE (expo);
return inex;
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:46,代码来源:get_z.c
示例6: mpfr_odd_p
/* Return 1 if y is an odd integer, 0 otherwise.
Assumes y is not singular. */
int
mpfr_odd_p (mpfr_srcptr y)
{
mpfr_exp_t expo;
mpfr_prec_t prec;
mp_size_t yn;
mp_limb_t *yp;
/* NAN, INF or ZERO are not allowed */
MPFR_ASSERTD (!MPFR_IS_SINGULAR (y));
expo = MPFR_GET_EXP (y);
if (expo <= 0)
return 0; /* |y| < 1 and not 0 */
prec = MPFR_PREC(y);
if ((mpfr_prec_t) expo > prec)
return 0; /* y is a multiple of 2^(expo-prec), thus not odd */
/* 0 < expo <= prec:
y = 1xxxxxxxxxt.zzzzzzzzzzzzzzzzzz[000]
expo bits (prec-expo) bits
We have to check that:
(a) the bit 't' is set
(b) all the 'z' bits are zero
*/
prec = MPFR_PREC2LIMBS (prec) * GMP_NUMB_BITS - expo;
/* number of z+0 bits */
yn = prec / GMP_NUMB_BITS;
MPFR_ASSERTN(yn >= 0);
/* yn is the index of limb containing the 't' bit */
yp = MPFR_MANT(y);
/* if expo is a multiple of GMP_NUMB_BITS, t is bit 0 */
if (expo % GMP_NUMB_BITS == 0 ? (yp[yn] & 1) == 0
: yp[yn] << ((expo % GMP_NUMB_BITS) - 1) != MPFR_LIMB_HIGHBIT)
return 0;
while (--yn >= 0)
if (yp[yn] != 0)
return 0;
return 1;
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:47,代码来源:odd_p.c
示例7: mpfr_erfc
int
mpfr_erfc (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd)
{
int inex;
mpfr_t tmp;
mpfr_exp_t te, err;
mpfr_prec_t prec;
mpfr_exp_t emin = mpfr_get_emin ();
MPFR_SAVE_EXPO_DECL (expo);
MPFR_ZIV_DECL (loop);
MPFR_LOG_FUNC
(("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd),
("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inex));
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x)))
{
if (MPFR_IS_NAN (x))
{
MPFR_SET_NAN (y);
MPFR_RET_NAN;
}
/* erfc(+inf) = 0+, erfc(-inf) = 2 erfc (0) = 1 */
else if (MPFR_IS_INF (x))
return mpfr_set_ui (y, MPFR_IS_POS (x) ? 0 : 2, rnd);
else
return mpfr_set_ui (y, 1, rnd);
}
if (MPFR_SIGN (x) > 0)
{
/* by default, emin = 1-2^30, thus the smallest representable
number is 1/2*2^emin = 2^(-2^30):
for x >= 27282, erfc(x) < 2^(-2^30-1), and
for x >= 1787897414, erfc(x) < 2^(-2^62-1).
*/
if ((emin >= -1073741823 && mpfr_cmp_ui (x, 27282) >= 0) ||
mpfr_cmp_ui (x, 1787897414) >= 0)
{
/* May be incorrect if MPFR_EMAX_MAX >= 2^62. */
MPFR_ASSERTN ((MPFR_EMAX_MAX >> 31) >> 31 == 0);
return mpfr_underflow (y, (rnd == MPFR_RNDN) ? MPFR_RNDZ : rnd, 1);
}
}
开发者ID:pgundlach,项目名称:LuaTeX,代码行数:44,代码来源:erfc.c
示例8: mpfr_ui_sub
int
mpfr_ui_sub (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mpfr_rnd_t rnd_mode)
{
mpfr_t uu;
mp_limb_t up[1];
unsigned long cnt;
MPFR_LOG_FUNC
(("u=%lu x[%Pu]=%.*Rg rnd=%d",
u, mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode),
("y[%Pu]=%.*Rg", mpfr_get_prec(y), mpfr_log_prec, y));
if (MPFR_UNLIKELY (u == 0))
return mpfr_neg (y, x, rnd_mode);
if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x)))
{
if (MPFR_IS_NAN(x))
{
MPFR_SET_NAN(y);
MPFR_RET_NAN;
}
else if (MPFR_IS_INF(x))
{
/* u - Inf = -Inf and u - -Inf = +Inf */
MPFR_SET_INF(y);
MPFR_SET_OPPOSITE_SIGN(y,x);
MPFR_RET(0); /* +/-infinity is exact */
}
else /* x is zero */
/* u - 0 = u */
return mpfr_set_ui(y, u, rnd_mode);
}
else
{
MPFR_TMP_INIT1 (up, uu, GMP_NUMB_BITS);
MPFR_ASSERTN(u == (mp_limb_t) u);
count_leading_zeros (cnt, (mp_limb_t) u);
*up = (mp_limb_t) u << cnt;
MPFR_SET_EXP (uu, GMP_NUMB_BITS - cnt);
return mpfr_sub (y, uu, x, rnd_mode);
}
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:43,代码来源:ui_sub.c
示例9: mpfr_fits_uintmax_p
/* We can't use fits_u.h <= mpfr_cmp_ui */
int
mpfr_fits_uintmax_p (mpfr_srcptr f, mpfr_rnd_t rnd)
{
mpfr_exp_t e;
int prec;
uintmax_t s;
mpfr_t x;
int res;
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
/* Zero always fit */
return MPFR_IS_ZERO (f) ? 1 : 0;
else if (MPFR_IS_NEG (f))
/* Negative numbers don't fit */
return 0;
/* now it fits if
(a) f <= MAXIMUM
(b) round(f, prec(slong), rnd) <= MAXIMUM */
e = MPFR_GET_EXP (f);
/* first compute prec(MAXIMUM); fits in an int */
for (s = MPFR_UINTMAX_MAX, prec = 0; s != 0; s /= 2, prec ++);
/* MAXIMUM needs prec bits, i.e. MAXIMUM = 2^prec - 1 */
/* if e <= prec - 1, then f < 2^(prec-1) < MAXIMUM */
if (e <= prec - 1)
return 1;
/* if e >= prec + 1, then f >= 2^prec > MAXIMUM */
if (e >= prec + 1)
return 0;
MPFR_ASSERTD (e == prec);
/* hard case: first round to prec bits, then check */
mpfr_init2 (x, prec);
mpfr_set (x, f, rnd);
res = MPFR_GET_EXP (x) == e;
mpfr_clear (x);
return res;
}
开发者ID:119,项目名称:aircam-openwrt,代码行数:44,代码来源:fits_uintmax.c
示例10: mpfr_rint_trunc
int
mpfr_rint_trunc (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode)
{
if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(u) ) || mpfr_integer_p (u))
return mpfr_set (r, u, rnd_mode);
else
{
mpfr_t tmp;
int inex;
unsigned int saved_flags = __gmpfr_flags;
mpfr_init2 (tmp, MPFR_PREC (u));
/* trunc(u) is always representable in tmp */
mpfr_trunc (tmp, u);
__gmpfr_flags = saved_flags;
inex = mpfr_set (r, tmp, rnd_mode);
mpfr_clear (tmp);
return inex;
}
}
开发者ID:clerkma,项目名称:texlive-mobile,代码行数:20,代码来源:rint.c
示例11: mpfr_rint_trunc
int
mpfr_rint_trunc (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode)
{
if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(u) ) || mpfr_integer_p (u))
return mpfr_set (r, u, rnd_mode);
else
{
mpfr_t tmp;
int inex;
MPFR_SAVE_EXPO_DECL (expo);
MPFR_SAVE_EXPO_MARK (expo);
mpfr_init2 (tmp, MPFR_PREC (u));
/* trunc(u) is always representable in tmp */
mpfr_trunc (tmp, u);
inex = mpfr_set (r, tmp, rnd_mode);
mpfr_clear (tmp);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range (r, inex, rnd_mode);
}
}
开发者ID:Scorpiion,项目名称:Renux_cross_gcc,代码行数:21,代码来源:rint.c
示例12: mpfr_get_ld
long double
mpfr_get_ld (mpfr_srcptr x, mp_rnd_t rnd_mode)
{
mpfr_long_double_t ld;
mpfr_t tmp;
MPFR_SAVE_EXPO_DECL (expo);
MPFR_SAVE_EXPO_MARK (expo);
mpfr_set_emin (-16382-63);
mpfr_set_emax (16383);
mpfr_init2 (tmp, MPFR_LDBL_MANT_DIG);
mpfr_subnormalize(tmp, mpfr_set (tmp, x, rnd_mode), rnd_mode);
mpfr_prec_round (tmp, 64, GMP_RNDZ); /* exact */
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (tmp)))
ld.ld = (long double) mpfr_get_d (tmp, rnd_mode);
else
{
mp_limb_t *tmpmant;
mp_exp_t e, denorm;
tmpmant = MPFR_MANT (tmp);
e = MPFR_GET_EXP (tmp);
denorm = MPFR_UNLIKELY (e < -16382) ? - e - 16382 + 1 : 0;
#if BITS_PER_MP_LIMB >= 64
ld.s.manl = (tmpmant[0] >> denorm);
ld.s.manh = (tmpmant[0] >> denorm) >> 32;
#elif BITS_PER_MP_LIMB == 32
if (MPFR_LIKELY (denorm == 0))
{
ld.s.manl = tmpmant[0];
ld.s.manh = tmpmant[1];
}
else if (denorm < 32)
{
ld.s.manl = (tmpmant[0] >> denorm) | (tmpmant[1] << (32 - denorm));
ld.s.manh = tmpmant[1] >> denorm;
}
else /* 32 <= denorm <= 64 */
{
开发者ID:sriramnrn,项目名称:gcc,代码行数:40,代码来源:get_ld.c
示例13: test_cmp_f
static void
test_cmp_f (mpfr_prec_t pmin, mpfr_prec_t pmax, int nmax)
{
mpfr_t x, z;
mpf_t y;
mpfr_prec_t p;
int res1, res2;
int n;
mpfr_init (x);
mpfr_init2 (z, pmax+GMP_NUMB_BITS);
mpf_init2 (y, MPFR_PREC_MIN);
for(p=pmin ; p < pmax ; p+=3)
{
mpfr_set_prec (x, p);
mpf_set_prec (y, p);
for ( n = 0; n < nmax ; n++)
{
mpfr_urandomb (x, RANDS);
mpf_urandomb (y, RANDS, p);
if (!MPFR_IS_SINGULAR (x))
{
mpfr_set_f (z, y, MPFR_RNDN);
mpfr_sub (z, x, z, MPFR_RNDN);
res1 = mpfr_sgn (z);
res2 = mpfr_cmp_f (x, y);
if (res1 != res2)
{
printf("Error for mpfr_cmp_f: res=%d sub gives %d\n",
res2, res1);
exit (1);
}
}
}
}
mpf_clear (y);
mpfr_clear (x);
mpfr_clear (z);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:39,代码来源:tgmpop.c
示例14: mpfr_ui_sub
int
mpfr_ui_sub (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mp_rnd_t rnd_mode)
{
mpfr_t uu;
mp_limb_t up[1];
unsigned long cnt;
if (MPFR_UNLIKELY (u == 0))
return mpfr_neg (y, x, rnd_mode);
if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x)))
{
if (MPFR_IS_NAN(x))
{
MPFR_SET_NAN(y);
MPFR_RET_NAN;
}
else if (MPFR_IS_INF(x))
{
/* u - Inf = -Inf and u - -Inf = +Inf */
MPFR_SET_INF(y);
MPFR_SET_OPPOSITE_SIGN(y,x);
MPFR_RET(0); /* +/-infinity is exact */
}
else /* x is zero */
/* u - 0 = u */
return mpfr_set_ui(y, u, rnd_mode);
}
else
{
MPFR_TMP_INIT1 (up, uu, BITS_PER_MP_LIMB);
MPFR_ASSERTN(u == (mp_limb_t) u);
count_leading_zeros (cnt, (mp_limb_t) u);
*up = (mp_limb_t) u << cnt;
MPFR_SET_EXP (uu, BITS_PER_MP_LIMB - cnt);
return mpfr_sub (y, uu, x, rnd_mode);
}
}
开发者ID:Scorpiion,项目名称:Renux_cross_gcc,代码行数:38,代码来源:ui_sub.c
示例15: mpfr_extract
void
mpfr_extract (mpz_ptr y, mpfr_srcptr p, unsigned int i)
{
unsigned long two_i = 1UL << i;
unsigned long two_i_2 = i ? two_i / 2 : 1;
mp_size_t size_p = MPFR_LIMB_SIZE (p);
/* as 0 <= |p| < 1, we don't have to care with infinities, NaN, ... */
MPFR_ASSERTD (!MPFR_IS_SINGULAR (p));
_mpz_realloc (y, two_i_2);
if ((mpfr_uexp_t) size_p < two_i)
{
MPN_ZERO (PTR(y), two_i_2);
if ((mpfr_uexp_t) size_p >= two_i_2)
MPN_COPY (PTR(y) + two_i - size_p, MPFR_MANT(p), size_p - two_i_2);
}
else
MPN_COPY (PTR(y), MPFR_MANT(p) + size_p - two_i, two_i_2);
MPN_NORMALIZE (PTR(y), two_i_2);
SIZ(y) = (MPFR_IS_NEG (p)) ? -two_i_2 : two_i_2;
}
开发者ID:119,项目名称:aircam-openwrt,代码行数:23,代码来源:extract.c
示例16: mpfr_rint_floor
int
mpfr_rint_floor (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode)
{
if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(u) ) || mpfr_integer_p (u))
return mpfr_set (r, u, rnd_mode);
else
{
mpfr_t tmp;
int inex;
unsigned int saved_flags = __gmpfr_flags;
MPFR_BLOCK_DECL (flags);
mpfr_init2 (tmp, MPFR_PREC (u));
/* floor(u) is representable in tmp unless an overflow occurs */
MPFR_BLOCK (flags, mpfr_floor (tmp, u));
__gmpfr_flags = saved_flags;
inex = (MPFR_OVERFLOW (flags)
? mpfr_overflow (r, rnd_mode, MPFR_SIGN_NEG)
: mpfr_set (r, tmp, rnd_mode));
mpfr_clear (tmp);
return inex;
}
}
开发者ID:clerkma,项目名称:texlive-mobile,代码行数:23,代码来源:rint.c
示例17: mpfr_lgamma_nosign
static int
mpfr_lgamma_nosign (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd)
{
int inex, sign;
inex = mpfr_lgamma (y, &sign, x, rnd);
if (!MPFR_IS_SINGULAR (y))
{
MPFR_ASSERTN (sign == 1 || sign == -1);
if (sign == -1 && (rnd == GMP_RNDN || rnd == GMP_RNDZ))
{
mpfr_neg (y, y, GMP_RNDN);
inex = -inex;
/* This is a way to check with the generic tests, that the value
returned in the sign variable is consistent, but warning! The
tested function depends on the rounding mode: it is
* lgamma(x) = log(|Gamma(x)|) in GMP_RNDD and GMP_RNDU;
* lgamma(x) * sign(Gamma(x)) in GMP_RNDN and GMP_RNDZ. */
}
}
return inex;
}
开发者ID:mmanley,项目名称:Antares,代码行数:23,代码来源:tlgamma.c
示例18: mpfr_div_2si
MPFR_HOT_FUNCTION_ATTR int
mpfr_div_2si (mpfr_ptr y, mpfr_srcptr x, long int n, mpfr_rnd_t rnd_mode)
{
int inexact;
MPFR_LOG_FUNC
(("x[%Pu]=%.*Rg n=%ld rnd=%d",
mpfr_get_prec(x), mpfr_log_prec, x, n, rnd_mode),
("y[%Pu]=%.*Rg inexact=%d",
mpfr_get_prec(y), mpfr_log_prec, y, inexact));
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x)))
return mpfr_set (y, x, rnd_mode);
else
{
mpfr_exp_t exp = MPFR_GET_EXP (x);
MPFR_SETRAW (inexact, y, x, exp, rnd_mode);
if (MPFR_UNLIKELY( n > 0 && (__gmpfr_emin > MPFR_EMAX_MAX - n ||
exp < __gmpfr_emin + n)) )
{
if (rnd_mode == MPFR_RNDN &&
(__gmpfr_emin > MPFR_EMAX_MAX - (n - 1) ||
exp < __gmpfr_emin + (n - 1) ||
((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) &&
mpfr_powerof2_raw (y))))
rnd_mode = MPFR_RNDZ;
return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y));
}
else if (MPFR_UNLIKELY(n <= 0 && (__gmpfr_emax < MPFR_EMIN_MIN - n ||
exp > __gmpfr_emax + n)) )
return mpfr_overflow (y, rnd_mode, MPFR_SIGN(y));
MPFR_SET_EXP (y, exp - n);
}
MPFR_RET (inexact);
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:37,代码来源:div_2si.c
示例19: test_cmp_q
static void
test_cmp_q (mpfr_prec_t pmin, mpfr_prec_t pmax, int nmax)
{
mpfr_t x, z;
mpq_t y;
mpfr_prec_t p;
int res1, res2;
int n;
mpfr_init (x);
mpfr_init2 (z, MPFR_PREC_MIN);
mpq_init (y);
for(p=pmin ; p < pmax ; p++)
{
mpfr_set_prec (x, p);
for (n = 0 ; n < nmax ; n++)
{
mpfr_urandomb (x, RANDS);
mpq_set_ui (y, randlimb (), randlimb() );
if (!MPFR_IS_SINGULAR (x))
{
mpfr_sub_q (z, x, y, MPFR_RNDN);
res1 = mpfr_sgn (z);
res2 = mpfr_cmp_q (x, y);
if (res1 != res2)
{
printf("Error for mpfr_cmp_q: res=%d sub_z gives %d\n",
res2, res1);
exit (1);
}
}
}
}
mpq_clear (y);
mpfr_clear (x);
mpfr_clear (z);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:37,代码来源:tgmpop.c
示例20: mpfr_rint_floor
int
mpfr_rint_floor (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode)
{
if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(u) ) || mpfr_integer_p (u))
return mpfr_set (r, u, rnd_mode);
else
{
mpfr_t tmp;
int inex;
MPFR_SAVE_EXPO_DECL (expo);
MPFR_BLOCK_DECL (flags);
MPFR_SAVE_EXPO_MARK (expo);
mpfr_init2 (tmp, MPFR_PREC (u));
/* floor(u) is representable in tmp unless an overflow occurs */
MPFR_BLOCK (flags, mpfr_floor (tmp, u));
inex = (MPFR_OVERFLOW (flags)
? mpfr_overflow (r, rnd_mode, MPFR_SIGN_NEG)
: mpfr_set (r, tmp, rnd_mode));
mpfr_clear (tmp);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range (r, inex, rnd_mode);
}
}
开发者ID:Scorpiion,项目名称:Renux_cross_gcc,代码行数:24,代码来源:rint.c
注:本文中的MPFR_IS_SINGULAR函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论