本文整理汇总了C++中MPFR_SAVE_EXPO_DECL函数的典型用法代码示例。如果您正苦于以下问题:C++ MPFR_SAVE_EXPO_DECL函数的具体用法?C++ MPFR_SAVE_EXPO_DECL怎么用?C++ MPFR_SAVE_EXPO_DECL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MPFR_SAVE_EXPO_DECL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mpfr_sub_ui
int
mpfr_sub_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode)
{
if (MPFR_LIKELY (u != 0)) /* if u=0, do nothing */
{
mpfr_t uu;
mp_limb_t up[1];
unsigned long cnt;
int inex;
MPFR_SAVE_EXPO_DECL (expo);
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;
/* Optimization note: Exponent save/restore operations may be
removed if mpfr_sub works even when uu is out-of-range. */
MPFR_SAVE_EXPO_MARK (expo);
MPFR_SET_EXP (uu, BITS_PER_MP_LIMB - cnt);
inex = mpfr_sub (y, x, uu, rnd_mode);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range (y, inex, rnd_mode);
}
else
return mpfr_set (y, x, rnd_mode);
}
开发者ID:mmanley,项目名称:Antares,代码行数:28,代码来源:sub_ui.c
示例2: mpfr_get_zexp
/* This function does not change the flags. */
static void
mpfr_get_zexp (mpz_ptr ez, mpfr_srcptr x)
{
mpz_init (ez);
if (MPFR_IS_UBF (x))
mpz_set (ez, MPFR_ZEXP (x));
else
{
mp_limb_t e_limb[MPFR_EXP_LIMB_SIZE];
mpfr_t e;
int inex;
MPFR_SAVE_EXPO_DECL (expo);
/* TODO: Once this has been tested, optimize based on whether
_MPFR_EXP_FORMAT <= 3. */
MPFR_TMP_INIT1 (e_limb, e, sizeof (mpfr_exp_t) * CHAR_BIT);
MPFR_SAVE_EXPO_MARK (expo);
MPFR_DBGRES (inex = mpfr_set_exp_t (e, MPFR_GET_EXP (x), MPFR_RNDN));
MPFR_ASSERTD (inex == 0);
MPFR_DBGRES (inex = mpfr_get_z (ez, e, MPFR_RNDN));
MPFR_ASSERTD (inex == 0);
MPFR_SAVE_EXPO_FREE (expo);
}
}
开发者ID:BrianGladman,项目名称:mpfr,代码行数:26,代码来源:ubf.c
示例3: mpfr_sqrt_ui
int
mpfr_sqrt_ui (mpfr_ptr r, unsigned long u, mpfr_rnd_t rnd_mode)
{
if (u)
{
mpfr_t uu;
mp_limb_t up[1];
unsigned long cnt;
int inex;
MPFR_SAVE_EXPO_DECL (expo);
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_SAVE_EXPO_MARK (expo);
MPFR_SET_EXP (uu, GMP_NUMB_BITS - cnt);
inex = mpfr_sqrt(r, uu, rnd_mode);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range(r, inex, rnd_mode);
}
else /* sqrt(0) = 0 */
{
MPFR_SET_ZERO(r);
MPFR_SET_POS(r);
MPFR_RET(0);
}
}
开发者ID:Kirija,项目名称:XPIR,代码行数:29,代码来源:sqrt_ui.c
示例4: mpfr_add_ui
int
mpfr_add_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mpfr_rnd_t rnd_mode)
{
MPFR_LOG_FUNC
(("x[%Pu]=%.*Rg u=%lu rnd=%d",
mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode),
("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y));
if (MPFR_LIKELY(u != 0) ) /* if u=0, do nothing */
{
mpfr_t uu;
mp_limb_t up[1];
unsigned long cnt;
int inex;
MPFR_SAVE_EXPO_DECL (expo);
MPFR_TMP_INIT1 (up, uu, GMP_NUMB_BITS);
MPFR_ASSERTD (u == (mp_limb_t) u);
count_leading_zeros(cnt, (mp_limb_t) u);
up[0] = (mp_limb_t) u << cnt;
/* Optimization note: Exponent save/restore operations may be
removed if mpfr_add works even when uu is out-of-range. */
MPFR_SAVE_EXPO_MARK (expo);
MPFR_SET_EXP (uu, GMP_NUMB_BITS - cnt);
inex = mpfr_add(y, x, uu, rnd_mode);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range(y, inex, rnd_mode);
}
else
/* (unsigned long) 0 is assumed to be a real 0 (unsigned) */
return mpfr_set (y, x, rnd_mode);
}
开发者ID:texlive,项目名称:texlive-source,代码行数:33,代码来源:add_ui.c
示例5: mpfr_mul_d
int
mpfr_mul_d (mpfr_ptr a, mpfr_srcptr b, double c, mpfr_rnd_t rnd_mode)
{
int inexact;
mpfr_t d;
mp_limb_t tmp_man[MPFR_LIMBS_PER_DOUBLE];
MPFR_SAVE_EXPO_DECL (expo);
MPFR_LOG_FUNC
(("b[%Pu]=%.*Rg c=%.20g rnd=%d",
mpfr_get_prec(b), mpfr_log_prec, b, c, rnd_mode),
("a[%Pu]=%.*Rg inexact=%d",
mpfr_get_prec (a), mpfr_log_prec, a, inexact));
MPFR_SAVE_EXPO_MARK (expo);
MPFR_TMP_INIT1(tmp_man, d, IEEE_DBL_MANT_DIG);
inexact = mpfr_set_d (d, c, rnd_mode);
MPFR_ASSERTD (inexact == 0);
MPFR_CLEAR_FLAGS ();
inexact = mpfr_mul (a, b, d, rnd_mode);
MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range (a, inexact, rnd_mode);
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:27,代码来源:mul_d.c
示例6: mpfr_d_div
int
mpfr_d_div (mpfr_ptr a, double b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
{
int inexact;
mpfr_t d;
MPFR_SAVE_EXPO_DECL (expo);
MPFR_LOG_FUNC (
("b=%.20g c[%Pu]=%*.Rg rnd=%d", b, mpfr_get_prec (c), mpfr_log_prec, c, rnd_mode),
("a[%Pu]=%*.Rg", mpfr_get_prec (a), mpfr_log_prec, a));
MPFR_SAVE_EXPO_MARK (expo);
mpfr_init2 (d, IEEE_DBL_MANT_DIG);
inexact = mpfr_set_d (d, b, rnd_mode);
MPFR_ASSERTN (inexact == 0);
mpfr_clear_flags ();
inexact = mpfr_div (a, d, c, rnd_mode);
MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
mpfr_clear(d);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range (a, inexact, rnd_mode);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:25,代码来源:d_div.c
示例7: mpfr_mul_d
int
mpfr_mul_d (mpfr_ptr a, mpfr_srcptr b, double c, mpfr_rnd_t rnd_mode)
{
int inexact;
mpfr_t d;
MPFR_SAVE_EXPO_DECL (expo);
MPFR_LOG_FUNC
(("b[%Pu]=%.*Rg c=%.20g rnd=%d",
mpfr_get_prec(b), mpfr_log_prec, b, c, rnd_mode),
("a[%Pu]=%.*Rg inexact=%d",
mpfr_get_prec (a), mpfr_get_prec, a, inexact));
MPFR_SAVE_EXPO_MARK (expo);
mpfr_init2 (d, IEEE_DBL_MANT_DIG);
inexact = mpfr_set_d (d, c, rnd_mode);
MPFR_ASSERTN (inexact == 0);
mpfr_clear_flags ();
inexact = mpfr_mul (a, b, d, rnd_mode);
MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
mpfr_clear(d);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range (a, inexact, rnd_mode);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:27,代码来源:mul_d.c
示例8: mpfr_ubf_zexp2exp
/* Convert an mpz_t to an mpfr_exp_t, restricted to
the interval [MPFR_EXP_MIN,MPFR_EXP_MAX]. */
mpfr_exp_t
mpfr_ubf_zexp2exp (mpz_ptr ez)
{
mp_size_t n;
mpfr_eexp_t e;
mpfr_t d;
int inex;
MPFR_SAVE_EXPO_DECL (expo);
n = ABSIZ (ez); /* limb size of ez */
if (n == 0)
return 0;
MPFR_SAVE_EXPO_MARK (expo);
mpfr_init2 (d, n * GMP_NUMB_BITS);
MPFR_DBGRES (inex = mpfr_set_z (d, ez, MPFR_RNDN));
MPFR_ASSERTD (inex == 0);
e = mpfr_get_exp_t (d, MPFR_RNDZ);
mpfr_clear (d);
MPFR_SAVE_EXPO_FREE (expo);
if (MPFR_UNLIKELY (e < MPFR_EXP_MIN))
return MPFR_EXP_MIN;
if (MPFR_UNLIKELY (e > MPFR_EXP_MAX))
return MPFR_EXP_MAX;
return e;
}
开发者ID:BrianGladman,项目名称:mpfr,代码行数:28,代码来源:ubf.c
示例9: mpfr_root
int
mpfr_root (mpfr_ptr y, mpfr_srcptr x, unsigned long k, mpfr_rnd_t rnd_mode)
{
mpz_t m;
mpfr_exp_t e, r, sh;
mpfr_prec_t n, size_m, tmp;
int inexact, negative;
MPFR_SAVE_EXPO_DECL (expo);
MPFR_LOG_FUNC
(("x[%Pu]=%.*Rg k=%lu rnd=%d",
mpfr_get_prec (x), mpfr_log_prec, x, k, rnd_mode),
("y[%Pu]=%.*Rg inexact=%d",
mpfr_get_prec (y), mpfr_log_prec, y, inexact));
if (MPFR_UNLIKELY (k <= 1))
{
if (k < 1) /* k==0 => y=x^(1/0)=x^(+Inf) */
#if 0
/* For 0 <= x < 1 => +0.
For x = 1 => 1.
For x > 1, => +Inf.
For x < 0 => NaN.
*/
{
if (MPFR_IS_NEG (x) && !MPFR_IS_ZERO (x))
{
MPFR_SET_NAN (y);
MPFR_RET_NAN;
}
inexact = mpfr_cmp (x, __gmpfr_one);
if (inexact == 0)
return mpfr_set_ui (y, 1, rnd_mode); /* 1 may be Out of Range */
else if (inexact < 0)
return mpfr_set_ui (y, 0, rnd_mode); /* 0+ */
else
{
mpfr_set_inf (y, 1);
return 0;
}
}
#endif
{
MPFR_SET_NAN (y);
MPFR_RET_NAN;
}
else /* y =x^(1/1)=x */
return mpfr_set (y, x, rnd_mode);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:49,代码来源:root.c
示例10: 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
示例11: mpfr_ui_pow
int
mpfr_ui_pow (mpfr_ptr y, unsigned long int n, mpfr_srcptr x, mpfr_rnd_t rnd_mode)
{
mpfr_t t;
int inexact;
mp_limb_t tmp_mant[(sizeof (n) - 1) / sizeof (mp_limb_t) + 1];
MPFR_SAVE_EXPO_DECL (expo);
MPFR_SAVE_EXPO_MARK (expo);
MPFR_TMP_INIT1(tmp_mant, t, sizeof(n) * CHAR_BIT);
inexact = mpfr_set_ui (t, n, MPFR_RNDN);
MPFR_ASSERTD (inexact == 0);
inexact = mpfr_pow (y, t, x, rnd_mode);
MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range (y, inexact, rnd_mode);
}
开发者ID:Canar,项目名称:mpfr,代码行数:17,代码来源:ui_pow.c
示例12: 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
示例13: 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
示例14: pi_div_2ui
static int
pi_div_2ui (mpfr_ptr dest, int i, int neg, mpfr_rnd_t rnd_mode)
{
int inexact;
MPFR_SAVE_EXPO_DECL (expo);
MPFR_SAVE_EXPO_MARK (expo);
if (neg) /* -PI/2^i */
{
inexact = - mpfr_const_pi (dest, MPFR_INVERT_RND (rnd_mode));
MPFR_CHANGE_SIGN (dest);
}
else /* PI/2^i */
{
inexact = mpfr_const_pi (dest, rnd_mode);
}
mpfr_div_2ui (dest, dest, i, rnd_mode); /* exact */
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range (dest, inexact, rnd_mode);
}
开发者ID:clerkma,项目名称:texlive-mobile,代码行数:20,代码来源:atan2.c
示例15: mpfr_cmp_d
int
mpfr_cmp_d (mpfr_srcptr b, double d)
{
mpfr_t tmp;
int res;
mp_limb_t tmp_man[MPFR_LIMBS_PER_DOUBLE];
MPFR_SAVE_EXPO_DECL (expo);
MPFR_SAVE_EXPO_MARK (expo);
MPFR_TMP_INIT1(tmp_man, tmp, IEEE_DBL_MANT_DIG);
res = mpfr_set_d (tmp, d, MPFR_RNDN);
MPFR_ASSERTD (res == 0);
MPFR_CLEAR_FLAGS ();
res = mpfr_cmp (b, tmp);
MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
MPFR_SAVE_EXPO_FREE (expo);
return res;
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:21,代码来源:cmp_d.c
示例16: 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
示例17: 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
示例18: mpfr_div_d
int
mpfr_div_d (mpfr_ptr a, mpfr_srcptr b, double c, mp_rnd_t rnd_mode)
{
int inexact;
mpfr_t d;
MPFR_SAVE_EXPO_DECL (expo);
MPFR_LOG_FUNC (("b[%#R]=%R c%.20g rnd=%d", b, b, c, rnd_mode),
("a[%#R]=%R", a, a));
MPFR_SAVE_EXPO_MARK (expo);
mpfr_init2 (d, IEEE_DBL_MANT_DIG);
inexact = mpfr_set_d (d, c, rnd_mode);
MPFR_ASSERTN (inexact == 0);
mpfr_clear_flags ();
inexact = mpfr_div (a, b, d, rnd_mode);
MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
mpfr_clear(d);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range (a, inexact, rnd_mode);
}
开发者ID:Scorpiion,项目名称:Renux_cross_gcc,代码行数:24,代码来源:div_d.c
示例19: 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
示例20: mpfr_sin_cos
/* (y, z) <- (sin(x), cos(x)), return value is 0 iff both results are exact
ie, iff x = 0 */
int
mpfr_sin_cos (mpfr_ptr y, mpfr_ptr z, mpfr_srcptr x, mpfr_rnd_t rnd_mode)
{
mpfr_prec_t prec, m;
int neg, reduce;
mpfr_t c, xr;
mpfr_srcptr xx;
mpfr_exp_t err, expx;
int inexy, inexz;
MPFR_ZIV_DECL (loop);
MPFR_SAVE_EXPO_DECL (expo);
MPFR_ASSERTN (y != z);
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x)))
{
if (MPFR_IS_NAN(x) || MPFR_IS_INF(x))
{
MPFR_SET_NAN (y);
MPFR_SET_NAN (z);
MPFR_RET_NAN;
}
else /* x is zero */
{
MPFR_ASSERTD (MPFR_IS_ZERO (x));
MPFR_SET_ZERO (y);
MPFR_SET_SAME_SIGN (y, x);
/* y = 0, thus exact, but z is inexact in case of underflow
or overflow */
inexy = 0; /* y is exact */
inexz = mpfr_set_ui (z, 1, rnd_mode);
return INEX(inexy,inexz);
}
}
MPFR_LOG_FUNC
(("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode),
("sin[%Pu]=%.*Rg cos[%Pu]=%.*Rg", mpfr_get_prec(y), mpfr_log_prec, y,
mpfr_get_prec (z), mpfr_log_prec, z));
MPFR_SAVE_EXPO_MARK (expo);
prec = MAX (MPFR_PREC (y), MPFR_PREC (z));
m = prec + MPFR_INT_CEIL_LOG2 (prec) + 13;
expx = MPFR_GET_EXP (x);
/* When x is close to 0, say 2^(-k), then there is a cancellation of about
2k bits in 1-cos(x)^2. FIXME: in that case, it would be more efficient
to compute sin(x) directly. VL: This is partly done by using
MPFR_FAST_COMPUTE_IF_SMALL_INPUT from the mpfr_sin and mpfr_cos
functions. Moreover, any overflow on m is avoided. */
if (expx < 0)
{
/* Warning: in case y = x, and the first call to
MPFR_FAST_COMPUTE_IF_SMALL_INPUT succeeds but the second fails,
we will have clobbered the original value of x.
The workaround is to first compute z = cos(x) in that case, since
y and z are different. */
if (y != x)
/* y and x differ, thus we can safely try to compute y first */
{
MPFR_FAST_COMPUTE_IF_SMALL_INPUT (
y, x, -2 * expx, 2, 0, rnd_mode,
{ inexy = _inexact;
goto small_input; });
开发者ID:epowers,项目名称:mpfr,代码行数:67,代码来源:sin_cos.c
注:本文中的MPFR_SAVE_EXPO_DECL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论