|
nsz |
f9d179 |
#include <stdio.h>
|
|
nsz |
f9d179 |
#include <stdint.h>
|
|
nsz |
f9d179 |
#include <mpfr.h>
|
|
nsz |
f9d179 |
#include "gen.h"
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
static int rmap(int r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
switch (r) {
|
|
nsz |
f9d179 |
case RN: return MPFR_RNDN;
|
|
nsz |
f9d179 |
case RZ: return MPFR_RNDZ;
|
|
nsz |
f9d179 |
case RD: return MPFR_RNDD;
|
|
nsz |
f9d179 |
case RU: return MPFR_RNDU;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
return -1;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
Szabolcs Nagy |
c58b8e |
enum {FLT, DBL, LDBL};
|
|
Szabolcs Nagy |
c58b8e |
static const int emin[] = {
|
|
Szabolcs Nagy |
c58b8e |
[FLT] = -148,
|
|
Szabolcs Nagy |
c58b8e |
[DBL] = -1073,
|
|
Szabolcs Nagy |
c58b8e |
[LDBL] = -16444
|
|
Szabolcs Nagy |
c58b8e |
};
|
|
Szabolcs Nagy |
c58b8e |
static const int emax[] = {
|
|
Szabolcs Nagy |
c58b8e |
[FLT] = 128,
|
|
Szabolcs Nagy |
c58b8e |
[DBL] = 1024,
|
|
Szabolcs Nagy |
c58b8e |
[LDBL] = 16384
|
|
Szabolcs Nagy |
c58b8e |
};
|
|
Szabolcs Nagy |
c58b8e |
|
|
nsz |
f9d179 |
void debug(mpfr_t x)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
mpfr_out_str(stdout, 10, 0, x, MPFR_RNDN);
|
|
nsz |
f9d179 |
printf("\n");
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
/*
|
|
nsz |
f9d179 |
round x into y considering x is already rounded (t = up or down)
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
only cases where adjustment is done:
|
|
nsz |
f9d179 |
x=...|1...0, t=up -> x=nextbelow(x)
|
|
nsz |
f9d179 |
x=...|1...0, t=down -> x=nextabove(x)
|
|
nsz |
f9d179 |
where | is the rounding point, ... is 0 or 1 bit patterns
|
|
nsz |
f9d179 |
*/
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
// TODO: adjust(y, 0, 2, RN); when prec is 24 (0 vs 0x1p-149f), special case x=0
|
|
nsz |
f9d179 |
static int adjust_round(mpfr_t y, mpfr_t x, int t, int r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
mp_limb_t *p, *q;
|
|
nsz |
f9d179 |
unsigned xp, yp;
|
|
nsz |
f9d179 |
int t2;
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
xp = mpfr_get_prec(x);
|
|
nsz |
f9d179 |
yp = mpfr_get_prec(y);
|
|
nsz |
f9d179 |
if (yp >= xp || r != MPFR_RNDN || t == 0 || !mpfr_number_p(x) || mpfr_zero_p(x)) {
|
|
nsz |
f9d179 |
t2 = mpfr_set(y, x, r);
|
|
nsz |
f9d179 |
return t2 ? t2 : t;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
p = x->_mpfr_d;
|
|
nsz |
f9d179 |
yp++;
|
|
nsz |
f9d179 |
q = p + (xp + mp_bits_per_limb - 1)/mp_bits_per_limb - (yp + mp_bits_per_limb - 1)/mp_bits_per_limb;
|
|
nsz |
f9d179 |
if ((*p & 1 << -xp%mp_bits_per_limb) || !(*q & 1 << -yp%mp_bits_per_limb)) {
|
|
nsz |
f9d179 |
t2 = mpfr_set(y, x, r);
|
|
nsz |
f9d179 |
return t2 ? t2 : t;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
if (t > 0)
|
|
nsz |
f9d179 |
mpfr_nextbelow(x);
|
|
nsz |
f9d179 |
else
|
|
nsz |
f9d179 |
mpfr_nextabove(x);
|
|
nsz |
f9d179 |
return mpfr_set(y, x, r);
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
Szabolcs Nagy |
c58b8e |
static int adjust(mpfr_t mr, mpfr_t my, int t, int r, int type)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
// double d, dn, dp;
|
|
nsz |
f9d179 |
//printf("adj %d\n", t);
|
|
nsz |
f9d179 |
//debug(my);
|
|
nsz |
f9d179 |
t = adjust_round(mr, my, t, r);
|
|
nsz |
f9d179 |
//printf("rnd %d\n", t);
|
|
nsz |
f9d179 |
//debug(mr);
|
|
Szabolcs Nagy |
c58b8e |
mpfr_set_emin(emin[type]);
|
|
Szabolcs Nagy |
c58b8e |
mpfr_set_emax(emax[type]);
|
|
Szabolcs Nagy |
c58b8e |
// mpfr could handle this in subnormlize easily but no it doesnt...
|
|
Szabolcs Nagy |
c58b8e |
t = mpfr_check_range(mr, t, r);
|
|
nsz |
f9d179 |
t = mpfr_subnormalize(mr, t, r);
|
|
Szabolcs Nagy |
c58b8e |
mpfr_set_emax(MPFR_EMAX_DEFAULT);
|
|
Szabolcs Nagy |
c58b8e |
mpfr_set_emin(MPFR_EMIN_DEFAULT);
|
|
nsz |
f9d179 |
//printf("sub %d\n", t);
|
|
nsz |
f9d179 |
//debug(mr);
|
|
nsz |
f9d179 |
// d = mpfr_get_d(mr, r);
|
|
nsz |
f9d179 |
// dn = nextafter(d, INFINITY);
|
|
nsz |
f9d179 |
// dp = nextafter(d, -INFINITY);
|
|
nsz |
f9d179 |
//printf("c\n %.21e %a\n %.21e %a\n %.21e %a\n",d,d,dn,dn,dp,dp);
|
|
nsz |
f9d179 |
// dn = nextafterf(d, INFINITY);
|
|
nsz |
f9d179 |
// dp = nextafterf(d, -INFINITY);
|
|
nsz |
f9d179 |
//printf("cf\n %.21e %a\n %.21e %a\n %.21e %a\n",d,d,dn,dn,dp,dp);
|
|
nsz |
f9d179 |
return t;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
// TODO
|
|
nsz |
f9d179 |
//static int eflags(mpfr_t mr, mpfr_t my, int t)
|
|
nsz |
f9d179 |
static int eflags(int naninput)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
int i = 0;
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
if (mpfr_inexflag_p())
|
|
nsz |
f9d179 |
i |= FE_INEXACT;
|
|
nsz |
f9d179 |
// if (mpfr_underflow_p() && (t || mpfr_cmp(mr, my) != 0))
|
|
nsz |
f9d179 |
if (mpfr_underflow_p() && i)
|
|
nsz |
f9d179 |
i |= FE_UNDERFLOW;
|
|
nsz |
f9d179 |
if (mpfr_overflow_p())
|
|
nsz |
f9d179 |
i |= FE_OVERFLOW;
|
|
nsz |
f9d179 |
if (mpfr_divby0_p())
|
|
nsz |
f9d179 |
i |= FE_DIVBYZERO;
|
|
nsz |
f9d179 |
if (!naninput && (mpfr_nanflag_p() || mpfr_erangeflag_p()))
|
|
nsz |
f9d179 |
i |= FE_INVALID;
|
|
nsz |
f9d179 |
return i;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
static void genf(struct t *p, mpfr_t my, int t, int r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mr, 24);
|
|
nsz |
f9d179 |
int i;
|
|
nsz |
f9d179 |
|
|
Szabolcs Nagy |
c58b8e |
t = adjust(mr, my, t, r, FLT);
|
|
nsz |
f9d179 |
p->y = mpfr_get_flt(mr, r);
|
|
Szabolcs Nagy |
db87a4 |
p->e = eflags(isnan(p->x) || isnan(p->x2) || isnan(p->x3));
|
|
nsz |
f9d179 |
i = eulpf(p->y);
|
|
nsz |
f9d179 |
if (!isfinite(p->y)) {
|
|
nsz |
f9d179 |
p->dy = 0;
|
|
nsz |
f9d179 |
} else {
|
|
nsz |
f9d179 |
mpfr_sub(my, mr, my, MPFR_RNDN);
|
|
nsz |
f9d179 |
mpfr_div_2si(my, my, i, MPFR_RNDN);
|
|
Szabolcs Nagy |
c58b8e |
p->dy = mpfr_get_flt(my, MPFR_RNDN);
|
|
Szabolcs Nagy |
c58b8e |
// happens in RU,RD,RZ modes when y is finite but outside the domain
|
|
Szabolcs Nagy |
c58b8e |
if (p->dy > 1)
|
|
Szabolcs Nagy |
c58b8e |
p->dy = 1;
|
|
Szabolcs Nagy |
c58b8e |
if (p->dy < -1)
|
|
Szabolcs Nagy |
c58b8e |
p->dy = -1;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
static int mpf1(struct t *p, int (*fmp)(mpfr_t, const mpfr_t, mpfr_rnd_t))
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
int tn;
|
|
nsz |
f9d179 |
int r = rmap(p->r);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 24);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(my, 128);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_flt(mx, p->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
tn = fmp(my, mx, r);
|
|
nsz |
f9d179 |
p->x2 = 0;
|
|
nsz |
f9d179 |
genf(p, my, tn, r);
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
static int mpf2(struct t *p, int (*fmp)(mpfr_t, const mpfr_t, const mpfr_t, mpfr_rnd_t))
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
int tn;
|
|
nsz |
f9d179 |
int r = rmap(p->r);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 24);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx2, 24);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(my, 128);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_flt(mx, p->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
mpfr_set_flt(mx2, p->x2, MPFR_RNDN);
|
|
nsz |
f9d179 |
tn = fmp(my, mx, mx2, r);
|
|
nsz |
f9d179 |
genf(p, my, tn, r);
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
static void gend(struct t *p, mpfr_t my, int t, int r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mr, 53);
|
|
nsz |
f9d179 |
int i;
|
|
nsz |
f9d179 |
|
|
Szabolcs Nagy |
c58b8e |
t = adjust(mr, my, t, r, DBL);
|
|
nsz |
f9d179 |
p->y = mpfr_get_d(mr, r);
|
|
Szabolcs Nagy |
db87a4 |
p->e = eflags(isnan(p->x) || isnan(p->x2) || isnan(p->x3));
|
|
nsz |
f9d179 |
i = eulp(p->y);
|
|
nsz |
f9d179 |
if (!isfinite(p->y)) {
|
|
nsz |
f9d179 |
p->dy = 0;
|
|
nsz |
f9d179 |
} else {
|
|
nsz |
f9d179 |
mpfr_sub(my, mr, my, MPFR_RNDN);
|
|
nsz |
f9d179 |
mpfr_div_2si(my, my, i, MPFR_RNDN);
|
|
Szabolcs Nagy |
c58b8e |
p->dy = mpfr_get_flt(my, MPFR_RNDN);
|
|
Szabolcs Nagy |
c58b8e |
// happens in RU,RD,RZ modes when y is finite but outside the domain
|
|
Szabolcs Nagy |
c58b8e |
if (p->dy > 1)
|
|
Szabolcs Nagy |
c58b8e |
p->dy = 1;
|
|
Szabolcs Nagy |
c58b8e |
if (p->dy < -1)
|
|
Szabolcs Nagy |
c58b8e |
p->dy = -1;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
static int mpd1(struct t *p, int (*fmp)(mpfr_t, const mpfr_t, mpfr_rnd_t))
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
int tn;
|
|
nsz |
f9d179 |
int r = rmap(p->r);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 53);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(my, 128);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_d(mx, p->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
tn = fmp(my, mx, r);
|
|
nsz |
f9d179 |
p->x2 = 0;
|
|
nsz |
f9d179 |
gend(p, my, tn, r);
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
static int mpd2(struct t *p, int (*fmp)(mpfr_t, const mpfr_t, const mpfr_t, mpfr_rnd_t))
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
int tn;
|
|
nsz |
f9d179 |
int r = rmap(p->r);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 53);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx2, 53);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(my, 128);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_d(mx, p->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
mpfr_set_d(mx2, p->x2, MPFR_RNDN);
|
|
nsz |
f9d179 |
tn = fmp(my, mx, mx2, r);
|
|
nsz |
f9d179 |
gend(p, my, tn, r);
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
#if LDBL_MANT_DIG == 64
|
|
nsz |
f9d179 |
static void genl(struct t *p, mpfr_t my, int t, int r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mr, 64);
|
|
nsz |
f9d179 |
int i;
|
|
nsz |
f9d179 |
|
|
Szabolcs Nagy |
c58b8e |
t = adjust(mr, my, t, r, LDBL);
|
|
nsz |
f9d179 |
p->y = mpfr_get_ld(mr, r);
|
|
Szabolcs Nagy |
db87a4 |
p->e = eflags(isnan(p->x) || isnan(p->x2) || isnan(p->x3));
|
|
nsz |
f9d179 |
i = eulpl(p->y);
|
|
nsz |
f9d179 |
if (!isfinite(p->y)) {
|
|
nsz |
f9d179 |
p->dy = 0;
|
|
nsz |
f9d179 |
} else {
|
|
nsz |
f9d179 |
mpfr_sub(my, mr, my, MPFR_RNDN);
|
|
nsz |
f9d179 |
mpfr_div_2si(my, my, i, MPFR_RNDN);
|
|
Szabolcs Nagy |
c58b8e |
p->dy = mpfr_get_flt(my, MPFR_RNDN);
|
|
Szabolcs Nagy |
c58b8e |
// happens in RU,RD,RZ modes when y is finite but outside the domain
|
|
Szabolcs Nagy |
c58b8e |
if (p->dy > 1)
|
|
Szabolcs Nagy |
c58b8e |
p->dy = 1;
|
|
Szabolcs Nagy |
c58b8e |
if (p->dy < -1)
|
|
Szabolcs Nagy |
c58b8e |
p->dy = -1;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
#endif
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
static int mpl1(struct t *p, int (*fmp)(mpfr_t, const mpfr_t, mpfr_rnd_t))
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
#if LDBL_MANT_DIG == 53
|
|
nsz |
f9d179 |
return mpd1(p, fmp);
|
|
nsz |
f9d179 |
#elif LDBL_MANT_DIG == 64
|
|
nsz |
f9d179 |
int tn;
|
|
nsz |
f9d179 |
int r = rmap(p->r);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 64);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(my, 128);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_ld(mx, p->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
tn = fmp(my, mx, r);
|
|
nsz |
f9d179 |
p->x2 = 0;
|
|
nsz |
f9d179 |
genl(p, my, tn, r);
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
#else
|
|
nsz |
f9d179 |
return -1;
|
|
nsz |
f9d179 |
#endif
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
static int mpl2(struct t *p, int (*fmp)(mpfr_t, const mpfr_t, const mpfr_t, mpfr_rnd_t))
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
#if LDBL_MANT_DIG == 53
|
|
nsz |
f9d179 |
return mpd2(p, fmp);
|
|
nsz |
f9d179 |
#elif LDBL_MANT_DIG == 64
|
|
nsz |
f9d179 |
int tn;
|
|
nsz |
f9d179 |
int r = rmap(p->r);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 64);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx2, 64);
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(my, 128);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
79ae5f |
mpfr_set_ld(mx, p->x, MPFR_RNDN);
|
|
nsz |
79ae5f |
mpfr_set_ld(mx2, p->x2, MPFR_RNDN);
|
|
nsz |
f9d179 |
tn = fmp(my, mx, mx2, r);
|
|
nsz |
f9d179 |
genl(p, my, tn, r);
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
#else
|
|
nsz |
f9d179 |
return -1;
|
|
nsz |
f9d179 |
#endif
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
// TODO
|
|
nsz |
f9d179 |
static int mplgamma_sign;
|
|
nsz |
f9d179 |
static int wrap_lgamma(mpfr_t my, const mpfr_t mx, mpfr_rnd_t r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
return mpfr_lgamma(my, &mplgamma_sign, mx, r);
|
|
nsz |
f9d179 |
}
|
|
nsz |
588927 |
static long mpremquo_q;
|
|
nsz |
588927 |
static int wrap_remquo(mpfr_t my, const mpfr_t mx, const mpfr_t mx2, mpfr_rnd_t r)
|
|
nsz |
588927 |
{
|
|
nsz |
588927 |
return mpfr_remquo(my, &mpremquo_q, mx, mx2, r);
|
|
nsz |
588927 |
}
|
|
nsz |
21dd45 |
static int mpbessel_n;
|
|
nsz |
21dd45 |
static int wrap_jn(mpfr_t my, const mpfr_t mx, mpfr_rnd_t r)
|
|
nsz |
21dd45 |
{
|
|
nsz |
21dd45 |
return mpfr_jn(my, mpbessel_n, mx, r);
|
|
nsz |
21dd45 |
}
|
|
nsz |
21dd45 |
static int wrap_yn(mpfr_t my, const mpfr_t mx, mpfr_rnd_t r)
|
|
nsz |
21dd45 |
{
|
|
nsz |
21dd45 |
return mpfr_yn(my, mpbessel_n, mx, r);
|
|
nsz |
21dd45 |
}
|
|
nsz |
f9d179 |
static int wrap_ceil(mpfr_t my, const mpfr_t mx, mpfr_rnd_t r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
return mpfr_ceil(my, mx);
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
static int wrap_floor(mpfr_t my, const mpfr_t mx, mpfr_rnd_t r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
return mpfr_floor(my, mx);
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
static int wrap_round(mpfr_t my, const mpfr_t mx, mpfr_rnd_t r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
return mpfr_round(my, mx);
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
static int wrap_trunc(mpfr_t my, const mpfr_t mx, mpfr_rnd_t r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
return mpfr_trunc(my, mx);
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
static int wrap_nearbyint(mpfr_t my, const mpfr_t mx, mpfr_rnd_t r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
int i = mpfr_rint(my, mx, r);
|
|
nsz |
f9d179 |
mpfr_clear_inexflag();
|
|
nsz |
f9d179 |
return i;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
static int wrap_pow10(mpfr_t my, const mpfr_t mx, mpfr_rnd_t r)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
return mpfr_ui_pow(my, 10, mx, r);
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
Szabolcs Nagy |
c58b8e |
|
|
Szabolcs Nagy |
c58b8e |
static int wrap_sinpi(mpfr_t my, const mpfr_t mx, mpfr_rnd_t r)
|
|
Szabolcs Nagy |
c58b8e |
{
|
|
Szabolcs Nagy |
c58b8e |
// hack because mpfr has no sinpi
|
|
Szabolcs Nagy |
c58b8e |
MPFR_DECL_INIT(mz, 4096);
|
|
Szabolcs Nagy |
c58b8e |
mpfr_const_pi(mz, r);
|
|
Szabolcs Nagy |
c58b8e |
mpfr_mul(mz,mz,mx,r);
|
|
Szabolcs Nagy |
c58b8e |
return mpfr_sin(my, mz, r);
|
|
Szabolcs Nagy |
c58b8e |
}
|
|
Szabolcs Nagy |
c58b8e |
int mpsinpi(struct t *t) { return mpd1(t, wrap_sinpi); }
|
|
Szabolcs Nagy |
c58b8e |
|
|
Szabolcs Nagy |
ae0f0f |
int mpadd(struct t *t) { return mpd2(t, mpfr_add); }
|
|
Szabolcs Nagy |
7fd3b8 |
int mpaddf(struct t *t) { return mpf2(t, mpfr_add); }
|
|
Szabolcs Nagy |
7fd3b8 |
int mpaddl(struct t *t) { return mpl2(t, mpfr_add); }
|
|
Szabolcs Nagy |
c58b8e |
int mpmul(struct t *t) { return mpd2(t, mpfr_mul); }
|
|
Szabolcs Nagy |
7fd3b8 |
int mpmulf(struct t *t) { return mpf2(t, mpfr_mul); }
|
|
Szabolcs Nagy |
7fd3b8 |
int mpmull(struct t *t) { return mpl2(t, mpfr_mul); }
|
|
Szabolcs Nagy |
c58b8e |
int mpdiv(struct t *t) { return mpd2(t, mpfr_div); }
|
|
Szabolcs Nagy |
7fd3b8 |
int mpdivf(struct t *t) { return mpf2(t, mpfr_div); }
|
|
Szabolcs Nagy |
7fd3b8 |
int mpdivl(struct t *t) { return mpl2(t, mpfr_div); }
|
|
Szabolcs Nagy |
ae0f0f |
|
|
nsz |
f9d179 |
int mpacos(struct t *t) { return mpd1(t, mpfr_acos); }
|
|
nsz |
f9d179 |
int mpacosf(struct t *t) { return mpf1(t, mpfr_acos); }
|
|
nsz |
f9d179 |
int mpacosl(struct t *t) { return mpl1(t, mpfr_acos); }
|
|
nsz |
f9d179 |
int mpacosh(struct t *t) { return mpd1(t, mpfr_acosh); }
|
|
nsz |
f9d179 |
int mpacoshf(struct t *t) { return mpf1(t, mpfr_acosh); }
|
|
nsz |
f9d179 |
int mpacoshl(struct t *t) { return mpl1(t, mpfr_acosh); }
|
|
nsz |
f9d179 |
int mpasin(struct t *t) { return mpd1(t, mpfr_asin); }
|
|
nsz |
f9d179 |
int mpasinf(struct t *t) { return mpf1(t, mpfr_asin); }
|
|
nsz |
f9d179 |
int mpasinl(struct t *t) { return mpl1(t, mpfr_asin); }
|
|
nsz |
f9d179 |
int mpasinh(struct t *t) { return mpd1(t, mpfr_asinh); }
|
|
nsz |
f9d179 |
int mpasinhf(struct t *t) { return mpf1(t, mpfr_asinh); }
|
|
nsz |
f9d179 |
int mpasinhl(struct t *t) { return mpl1(t, mpfr_asinh); }
|
|
nsz |
f9d179 |
int mpatan(struct t *t) { return mpd1(t, mpfr_atan); }
|
|
nsz |
f9d179 |
int mpatanf(struct t *t) { return mpf1(t, mpfr_atan); }
|
|
nsz |
f9d179 |
int mpatanl(struct t *t) { return mpl1(t, mpfr_atan); }
|
|
nsz |
f9d179 |
int mpatan2(struct t *t) { return mpd2(t, mpfr_atan2); }
|
|
nsz |
f9d179 |
int mpatan2f(struct t *t) { return mpf2(t, mpfr_atan2); }
|
|
nsz |
f9d179 |
int mpatan2l(struct t *t) { return mpl2(t, mpfr_atan2); }
|
|
nsz |
f9d179 |
int mpatanh(struct t *t) { return mpd1(t, mpfr_atanh); }
|
|
nsz |
f9d179 |
int mpatanhf(struct t *t) { return mpf1(t, mpfr_atanh); }
|
|
nsz |
f9d179 |
int mpatanhl(struct t *t) { return mpl1(t, mpfr_atanh); }
|
|
nsz |
f9d179 |
int mpcbrt(struct t *t) { return mpd1(t, mpfr_cbrt); }
|
|
nsz |
f9d179 |
int mpcbrtf(struct t *t) { return mpf1(t, mpfr_cbrt); }
|
|
nsz |
f9d179 |
int mpcbrtl(struct t *t) { return mpl1(t, mpfr_cbrt); }
|
|
nsz |
f9d179 |
int mpceil(struct t *t) { return mpd1(t, wrap_ceil); }
|
|
nsz |
f9d179 |
int mpceilf(struct t *t) { return mpf1(t, wrap_ceil); }
|
|
nsz |
f9d179 |
int mpceill(struct t *t) { return mpl1(t, wrap_ceil); }
|
|
nsz |
f9d179 |
int mpcopysign(struct t *t) { return mpd2(t, mpfr_copysign); }
|
|
nsz |
f9d179 |
int mpcopysignf(struct t *t) { return mpf2(t, mpfr_copysign); }
|
|
nsz |
f9d179 |
int mpcopysignl(struct t *t) { return mpl2(t, mpfr_copysign); }
|
|
nsz |
f9d179 |
int mpcos(struct t *t) { return mpd1(t, mpfr_cos); }
|
|
nsz |
f9d179 |
int mpcosf(struct t *t) { return mpf1(t, mpfr_cos); }
|
|
nsz |
f9d179 |
int mpcosl(struct t *t) { return mpl1(t, mpfr_cos); }
|
|
nsz |
f9d179 |
int mpcosh(struct t *t) { return mpd1(t, mpfr_cosh); }
|
|
nsz |
f9d179 |
int mpcoshf(struct t *t) { return mpf1(t, mpfr_cosh); }
|
|
nsz |
f9d179 |
int mpcoshl(struct t *t) { return mpl1(t, mpfr_cosh); }
|
|
nsz |
f9d179 |
int mperf(struct t *t) { return mpd1(t, mpfr_erf); }
|
|
nsz |
f9d179 |
int mperff(struct t *t) { return mpf1(t, mpfr_erf); }
|
|
nsz |
f9d179 |
int mperfl(struct t *t) { return mpl1(t, mpfr_erf); }
|
|
nsz |
f9d179 |
int mperfc(struct t *t) { return mpd1(t, mpfr_erfc); }
|
|
nsz |
f9d179 |
int mperfcf(struct t *t) { return mpf1(t, mpfr_erfc); }
|
|
nsz |
f9d179 |
int mperfcl(struct t *t) { return mpl1(t, mpfr_erfc); }
|
|
nsz |
f9d179 |
int mpexp(struct t *t) { return mpd1(t, mpfr_exp); }
|
|
nsz |
f9d179 |
int mpexpf(struct t *t) { return mpf1(t, mpfr_exp); }
|
|
nsz |
f9d179 |
int mpexpl(struct t *t) { return mpl1(t, mpfr_exp); }
|
|
nsz |
f9d179 |
int mpexp2(struct t *t) { return mpd1(t, mpfr_exp2); }
|
|
nsz |
f9d179 |
int mpexp2f(struct t *t) { return mpf1(t, mpfr_exp2); }
|
|
nsz |
f9d179 |
int mpexp2l(struct t *t) { return mpl1(t, mpfr_exp2); }
|
|
nsz |
f9d179 |
int mpexpm1(struct t *t) { return mpd1(t, mpfr_expm1); }
|
|
nsz |
f9d179 |
int mpexpm1f(struct t *t) { return mpf1(t, mpfr_expm1); }
|
|
nsz |
f9d179 |
int mpexpm1l(struct t *t) { return mpl1(t, mpfr_expm1); }
|
|
nsz |
f9d179 |
int mpfabs(struct t *t) { return mpd1(t, mpfr_abs); }
|
|
nsz |
f9d179 |
int mpfabsf(struct t *t) { return mpf1(t, mpfr_abs); }
|
|
nsz |
f9d179 |
int mpfabsl(struct t *t) { return mpl1(t, mpfr_abs); }
|
|
nsz |
f9d179 |
int mpfdim(struct t *t) { return mpd2(t, mpfr_dim); }
|
|
nsz |
f9d179 |
int mpfdimf(struct t *t) { return mpf2(t, mpfr_dim); }
|
|
nsz |
f9d179 |
int mpfdiml(struct t *t) { return mpl2(t, mpfr_dim); }
|
|
nsz |
f9d179 |
int mpfloor(struct t *t) { return mpd1(t, wrap_floor); }
|
|
nsz |
f9d179 |
int mpfloorf(struct t *t) { return mpf1(t, wrap_floor); }
|
|
nsz |
f9d179 |
int mpfloorl(struct t *t) { return mpl1(t, wrap_floor); }
|
|
nsz |
f9d179 |
int mpfmax(struct t *t) { return mpd2(t, mpfr_max); }
|
|
nsz |
f9d179 |
int mpfmaxf(struct t *t) { return mpf2(t, mpfr_max); }
|
|
nsz |
f9d179 |
int mpfmaxl(struct t *t) { return mpl2(t, mpfr_max); }
|
|
nsz |
f9d179 |
int mpfmin(struct t *t) { return mpd2(t, mpfr_min); }
|
|
nsz |
f9d179 |
int mpfminf(struct t *t) { return mpf2(t, mpfr_min); }
|
|
nsz |
f9d179 |
int mpfminl(struct t *t) { return mpl2(t, mpfr_min); }
|
|
nsz |
f9d179 |
int mpfmod(struct t *t) { return mpd2(t, mpfr_fmod); }
|
|
nsz |
f9d179 |
int mpfmodf(struct t *t) { return mpf2(t, mpfr_fmod); }
|
|
nsz |
f9d179 |
int mpfmodl(struct t *t) { return mpl2(t, mpfr_fmod); }
|
|
nsz |
f9d179 |
int mphypot(struct t *t) { return mpd2(t, mpfr_hypot); }
|
|
nsz |
f9d179 |
int mphypotf(struct t *t) { return mpf2(t, mpfr_hypot); }
|
|
nsz |
f9d179 |
int mphypotl(struct t *t) { return mpl2(t, mpfr_hypot); }
|
|
nsz |
f9d179 |
int mplgamma(struct t *t) { return mpd1(t, wrap_lgamma) || (t->i = mplgamma_sign, 0); }
|
|
nsz |
f9d179 |
int mplgammaf(struct t *t) { return mpf1(t, wrap_lgamma) || (t->i = mplgamma_sign, 0); }
|
|
nsz |
f9d179 |
int mplgammal(struct t *t) { return mpl1(t, wrap_lgamma) || (t->i = mplgamma_sign, 0); }
|
|
nsz |
f9d179 |
int mplog(struct t *t) { return mpd1(t, mpfr_log); }
|
|
nsz |
f9d179 |
int mplogf(struct t *t) { return mpf1(t, mpfr_log); }
|
|
nsz |
f9d179 |
int mplogl(struct t *t) { return mpl1(t, mpfr_log); }
|
|
nsz |
f9d179 |
int mplog10(struct t *t) { return mpd1(t, mpfr_log10); }
|
|
nsz |
f9d179 |
int mplog10f(struct t *t) { return mpf1(t, mpfr_log10); }
|
|
nsz |
f9d179 |
int mplog10l(struct t *t) { return mpl1(t, mpfr_log10); }
|
|
nsz |
f9d179 |
int mplog1p(struct t *t) { return mpd1(t, mpfr_log1p); }
|
|
nsz |
f9d179 |
int mplog1pf(struct t *t) { return mpf1(t, mpfr_log1p); }
|
|
nsz |
f9d179 |
int mplog1pl(struct t *t) { return mpl1(t, mpfr_log1p); }
|
|
nsz |
f9d179 |
int mplog2(struct t *t) { return mpd1(t, mpfr_log2); }
|
|
nsz |
f9d179 |
int mplog2f(struct t *t) { return mpf1(t, mpfr_log2); }
|
|
nsz |
f9d179 |
int mplog2l(struct t *t) { return mpl1(t, mpfr_log2); }
|
|
nsz |
f9d179 |
int mplogb(struct t *t)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 53);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
t->dy = 0;
|
|
nsz |
f9d179 |
t->e = 0;
|
|
Szabolcs Nagy |
9aeadc |
if (t->x == 0) {
|
|
Szabolcs Nagy |
9aeadc |
t->y = -INFINITY;
|
|
Szabolcs Nagy |
9aeadc |
t->e |= DIVBYZERO;
|
|
Szabolcs Nagy |
9aeadc |
return 0;
|
|
Szabolcs Nagy |
9aeadc |
}
|
|
Szabolcs Nagy |
9aeadc |
if (isinf(t->x)) {
|
|
Szabolcs Nagy |
9aeadc |
t->y = INFINITY;
|
|
Szabolcs Nagy |
9aeadc |
return 0;
|
|
Szabolcs Nagy |
9aeadc |
}
|
|
Szabolcs Nagy |
9aeadc |
if (isnan(t->x)) {
|
|
Szabolcs Nagy |
9aeadc |
t->y = t->x;
|
|
Szabolcs Nagy |
9aeadc |
return 0;
|
|
Szabolcs Nagy |
9aeadc |
}
|
|
Szabolcs Nagy |
9aeadc |
mpfr_set_d(mx, t->x, MPFR_RNDN);
|
|
Szabolcs Nagy |
9aeadc |
t->y = mpfr_get_exp(mx) - 1;
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
int mplogbf(struct t *t)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 24);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
t->dy = 0;
|
|
nsz |
f9d179 |
t->e = 0;
|
|
Szabolcs Nagy |
9aeadc |
if (t->x == 0) {
|
|
Szabolcs Nagy |
9aeadc |
t->y = -INFINITY;
|
|
Szabolcs Nagy |
9aeadc |
t->e |= DIVBYZERO;
|
|
Szabolcs Nagy |
9aeadc |
return 0;
|
|
Szabolcs Nagy |
9aeadc |
}
|
|
Szabolcs Nagy |
9aeadc |
if (isinf(t->x)) {
|
|
Szabolcs Nagy |
9aeadc |
t->y = INFINITY;
|
|
Szabolcs Nagy |
9aeadc |
return 0;
|
|
Szabolcs Nagy |
9aeadc |
}
|
|
Szabolcs Nagy |
9aeadc |
if (isnan(t->x)) {
|
|
Szabolcs Nagy |
9aeadc |
t->y = t->x;
|
|
Szabolcs Nagy |
9aeadc |
return 0;
|
|
Szabolcs Nagy |
9aeadc |
}
|
|
Szabolcs Nagy |
9aeadc |
mpfr_set_flt(mx, t->x, MPFR_RNDN);
|
|
Szabolcs Nagy |
9aeadc |
t->y = mpfr_get_exp(mx) - 1;
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
int mplogbl(struct t *t)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 64);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
t->dy = 0;
|
|
nsz |
f9d179 |
t->e = 0;
|
|
Szabolcs Nagy |
9aeadc |
if (t->x == 0) {
|
|
Szabolcs Nagy |
9aeadc |
t->y = -INFINITY;
|
|
Szabolcs Nagy |
9aeadc |
t->e |= DIVBYZERO;
|
|
Szabolcs Nagy |
9aeadc |
return 0;
|
|
Szabolcs Nagy |
9aeadc |
}
|
|
Szabolcs Nagy |
9aeadc |
if (isinf(t->x)) {
|
|
Szabolcs Nagy |
9aeadc |
t->y = INFINITY;
|
|
Szabolcs Nagy |
9aeadc |
return 0;
|
|
Szabolcs Nagy |
9aeadc |
}
|
|
Szabolcs Nagy |
9aeadc |
if (isnan(t->x)) {
|
|
Szabolcs Nagy |
9aeadc |
t->y = t->x;
|
|
Szabolcs Nagy |
9aeadc |
return 0;
|
|
Szabolcs Nagy |
9aeadc |
}
|
|
Szabolcs Nagy |
9aeadc |
mpfr_set_ld(mx, t->x, MPFR_RNDN);
|
|
Szabolcs Nagy |
9aeadc |
t->y = mpfr_get_exp(mx) - 1;
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
457b0d |
int mpnearbyint(struct t *t) { return mpd1(t, wrap_nearbyint) || (t->e&=~INEXACT, 0); }
|
|
nsz |
457b0d |
int mpnearbyintf(struct t *t) { return mpf1(t, wrap_nearbyint) || (t->e&=~INEXACT, 0); }
|
|
nsz |
457b0d |
int mpnearbyintl(struct t *t) { return mpl1(t, wrap_nearbyint) || (t->e&=~INEXACT, 0); }
|
|
nsz |
ddfb9f |
// TODO: hard to implement with mpfr
|
|
nsz |
ddfb9f |
int mpnextafter(struct t *t)
|
|
nsz |
ddfb9f |
{
|
|
nsz |
ddfb9f |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
ddfb9f |
t->y = nextafter(t->x, t->x2);
|
|
nsz |
ddfb9f |
t->e = getexcept();
|
|
nsz |
ddfb9f |
t->dy = 0;
|
|
nsz |
ddfb9f |
return 0;
|
|
nsz |
ddfb9f |
}
|
|
nsz |
ddfb9f |
int mpnextafterf(struct t *t)
|
|
nsz |
ddfb9f |
{
|
|
nsz |
ddfb9f |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
ddfb9f |
t->y = nextafterf(t->x, t->x2);
|
|
nsz |
ddfb9f |
t->e = getexcept();
|
|
nsz |
ddfb9f |
t->dy = 0;
|
|
nsz |
ddfb9f |
return 0;
|
|
nsz |
ddfb9f |
}
|
|
nsz |
ddfb9f |
int mpnextafterl(struct t *t)
|
|
nsz |
ddfb9f |
{
|
|
nsz |
ddfb9f |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
ddfb9f |
t->y = nextafterl(t->x, t->x2);
|
|
nsz |
ddfb9f |
t->e = getexcept();
|
|
nsz |
ddfb9f |
t->dy = 0;
|
|
nsz |
ddfb9f |
return 0;
|
|
nsz |
ddfb9f |
}
|
|
nsz |
ddfb9f |
int mpnexttoward(struct t *t)
|
|
nsz |
ddfb9f |
{
|
|
nsz |
ddfb9f |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
ddfb9f |
t->y = nexttoward(t->x, t->x2);
|
|
nsz |
ddfb9f |
t->e = getexcept();
|
|
nsz |
ddfb9f |
t->dy = 0;
|
|
nsz |
ddfb9f |
return 0;
|
|
nsz |
ddfb9f |
}
|
|
nsz |
ddfb9f |
int mpnexttowardf(struct t *t)
|
|
nsz |
ddfb9f |
{
|
|
nsz |
ddfb9f |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
ddfb9f |
t->y = nexttowardf(t->x, t->x2);
|
|
nsz |
ddfb9f |
t->e = getexcept();
|
|
nsz |
ddfb9f |
t->dy = 0;
|
|
nsz |
ddfb9f |
return 0;
|
|
nsz |
ddfb9f |
}
|
|
nsz |
ddfb9f |
int mpnexttowardl(struct t *t) { return mpnextafterl(t); }
|
|
nsz |
f9d179 |
int mppow(struct t *t) { return mpd2(t, mpfr_pow); }
|
|
nsz |
f9d179 |
int mppowf(struct t *t) { return mpf2(t, mpfr_pow); }
|
|
nsz |
f9d179 |
int mppowl(struct t *t) { return mpl2(t, mpfr_pow); }
|
|
nsz |
f9d179 |
int mpremainder(struct t *t) { return mpd2(t, mpfr_remainder); }
|
|
nsz |
f9d179 |
int mpremainderf(struct t *t) { return mpf2(t, mpfr_remainder); }
|
|
nsz |
f9d179 |
int mpremainderl(struct t *t) { return mpl2(t, mpfr_remainder); }
|
|
nsz |
f9d179 |
int mprint(struct t *t) { return mpd1(t, mpfr_rint); }
|
|
nsz |
f9d179 |
int mprintf(struct t *t) { return mpf1(t, mpfr_rint); }
|
|
nsz |
f9d179 |
int mprintl(struct t *t) { return mpl1(t, mpfr_rint); }
|
|
nsz |
f9d179 |
int mpround(struct t *t) { return mpd1(t, wrap_round); }
|
|
nsz |
f9d179 |
int mproundf(struct t *t) { return mpf1(t, wrap_round); }
|
|
nsz |
f9d179 |
int mproundl(struct t *t) { return mpl1(t, wrap_round); }
|
|
nsz |
f9d179 |
int mpsin(struct t *t) { return mpd1(t, mpfr_sin); }
|
|
nsz |
f9d179 |
int mpsinf(struct t *t) { return mpf1(t, mpfr_sin); }
|
|
nsz |
f9d179 |
int mpsinl(struct t *t) { return mpl1(t, mpfr_sin); }
|
|
nsz |
f9d179 |
int mpsinh(struct t *t) { return mpd1(t, mpfr_sinh); }
|
|
nsz |
f9d179 |
int mpsinhf(struct t *t) { return mpf1(t, mpfr_sinh); }
|
|
nsz |
f9d179 |
int mpsinhl(struct t *t) { return mpl1(t, mpfr_sinh); }
|
|
nsz |
f9d179 |
int mpsqrt(struct t *t) { return mpd1(t, mpfr_sqrt); }
|
|
nsz |
f9d179 |
int mpsqrtf(struct t *t) { return mpf1(t, mpfr_sqrt); }
|
|
nsz |
f9d179 |
int mpsqrtl(struct t *t) { return mpl1(t, mpfr_sqrt); }
|
|
nsz |
f9d179 |
int mptan(struct t *t) { return mpd1(t, mpfr_tan); }
|
|
nsz |
f9d179 |
int mptanf(struct t *t) { return mpf1(t, mpfr_tan); }
|
|
nsz |
f9d179 |
int mptanl(struct t *t) { return mpl1(t, mpfr_tan); }
|
|
nsz |
f9d179 |
int mptanh(struct t *t) { return mpd1(t, mpfr_tanh); }
|
|
nsz |
f9d179 |
int mptanhf(struct t *t) { return mpf1(t, mpfr_tanh); }
|
|
nsz |
f9d179 |
int mptanhl(struct t *t) { return mpl1(t, mpfr_tanh); }
|
|
Szabolcs Nagy |
9aeadc |
// TODO: tgamma(2) raises wrong flags
|
|
nsz |
f9d179 |
int mptgamma(struct t *t) { return mpd1(t, mpfr_gamma); }
|
|
nsz |
f9d179 |
int mptgammaf(struct t *t) { return mpf1(t, mpfr_gamma); }
|
|
nsz |
f9d179 |
int mptgammal(struct t *t) { return mpl1(t, mpfr_gamma); }
|
|
nsz |
f9d179 |
int mptrunc(struct t *t) { return mpd1(t, wrap_trunc); }
|
|
nsz |
f9d179 |
int mptruncf(struct t *t) { return mpf1(t, wrap_trunc); }
|
|
nsz |
f9d179 |
int mptruncl(struct t *t) { return mpl1(t, wrap_trunc); }
|
|
nsz |
f9d179 |
int mpj0(struct t *t) { return mpd1(t, mpfr_j0); }
|
|
nsz |
f9d179 |
int mpj1(struct t *t) { return mpd1(t, mpfr_j1); }
|
|
nsz |
f9d179 |
int mpy0(struct t *t) { return mpd1(t, mpfr_y0); }
|
|
nsz |
f9d179 |
int mpy1(struct t *t) { return mpd1(t, mpfr_y1); }
|
|
nsz |
ddfb9f |
// TODO: non standard functions
|
|
nsz |
ddfb9f |
int mpscalb(struct t *t)
|
|
nsz |
ddfb9f |
{
|
|
nsz |
ddfb9f |
setupfenv(t->r);
|
|
nsz |
ddfb9f |
t->y = scalb(t->x, t->x2);
|
|
nsz |
ddfb9f |
t->e = getexcept();
|
|
nsz |
ddfb9f |
t->dy = 0; // wrong
|
|
nsz |
ddfb9f |
return 0;
|
|
nsz |
ddfb9f |
}
|
|
nsz |
ddfb9f |
int mpscalbf(struct t *t)
|
|
nsz |
ddfb9f |
{
|
|
nsz |
ddfb9f |
setupfenv(t->r);
|
|
nsz |
ddfb9f |
t->y = scalbf(t->x, t->x2);
|
|
nsz |
ddfb9f |
t->e = getexcept();
|
|
nsz |
ddfb9f |
t->dy = 0; // wrong
|
|
nsz |
ddfb9f |
return 0;
|
|
nsz |
ddfb9f |
}
|
|
nsz |
f9d179 |
int mpj0f(struct t *t) { return mpf1(t, mpfr_j0); }
|
|
nsz |
f9d179 |
int mpj0l(struct t *t) { return mpl1(t, mpfr_j0); }
|
|
nsz |
f9d179 |
int mpj1f(struct t *t) { return mpf1(t, mpfr_j1); }
|
|
nsz |
f9d179 |
int mpj1l(struct t *t) { return mpl1(t, mpfr_j1); }
|
|
nsz |
f9d179 |
int mpy0f(struct t *t) { return mpf1(t, mpfr_y0); }
|
|
nsz |
f9d179 |
int mpy0l(struct t *t) { return mpl1(t, mpfr_y0); }
|
|
nsz |
f9d179 |
int mpy1f(struct t *t) { return mpf1(t, mpfr_y1); }
|
|
nsz |
f9d179 |
int mpy1l(struct t *t) { return mpl1(t, mpfr_y1); }
|
|
nsz |
f9d179 |
int mpexp10(struct t *t) { return mpd1(t, wrap_pow10); }
|
|
nsz |
f9d179 |
int mpexp10f(struct t *t) { return mpf1(t, wrap_pow10); }
|
|
nsz |
f9d179 |
int mpexp10l(struct t *t) { return mpl1(t, wrap_pow10); }
|
|
nsz |
f9d179 |
int mppow10(struct t *t) { return mpd1(t, wrap_pow10); }
|
|
nsz |
f9d179 |
int mppow10f(struct t *t) { return mpf1(t, wrap_pow10); }
|
|
nsz |
f9d179 |
int mppow10l(struct t *t) { return mpl1(t, wrap_pow10); }
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
int mpfrexp(struct t *t)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
mpfr_exp_t e;
|
|
nsz |
f9d179 |
int k;
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 53);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
t->dy = 0;
|
|
nsz |
f9d179 |
t->y = 0;
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_d(mx, t->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
k = mpfr_frexp(&e, mx, mx, t->r);
|
|
nsz |
f9d179 |
t->y = mpfr_get_d(mx, MPFR_RNDN);
|
|
nsz |
f9d179 |
t->i = e;
|
|
nsz |
f9d179 |
t->e = eflags(isnan(t->x));
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
int mpfrexpf(struct t *t)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
mpfr_exp_t e;
|
|
nsz |
f9d179 |
int k;
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 24);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
t->dy = 0;
|
|
nsz |
f9d179 |
t->y = 0;
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_flt(mx, t->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
k = mpfr_frexp(&e, mx, mx, t->r);
|
|
nsz |
f9d179 |
t->y = mpfr_get_flt(mx, MPFR_RNDN);
|
|
nsz |
f9d179 |
t->i = e;
|
|
nsz |
f9d179 |
t->e = eflags(isnan(t->x));
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
int mpfrexpl(struct t *t)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
mpfr_exp_t e;
|
|
nsz |
f9d179 |
int k;
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 64);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
t->dy = 0;
|
|
nsz |
f9d179 |
t->y = 0;
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_ld(mx, t->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
k = mpfr_frexp(&e, mx, mx, t->r);
|
|
nsz |
f9d179 |
t->y = mpfr_get_ld(mx, MPFR_RNDN);
|
|
nsz |
f9d179 |
t->i = e;
|
|
nsz |
f9d179 |
t->e = eflags(isnan(t->x));
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
int mpldexp(struct t *t)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
int k;
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 53);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
t->dy = 0;
|
|
nsz |
f9d179 |
t->y = 0;
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_d(mx, t->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
k = mpfr_mul_2si(mx, mx, t->i, t->r);
|
|
Szabolcs Nagy |
c58b8e |
adjust(mx, mx, k, t->r, DBL);
|
|
nsz |
f9d179 |
t->y = mpfr_get_d(mx, MPFR_RNDN);
|
|
nsz |
f9d179 |
t->e = eflags(isnan(t->x));
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
int mpldexpf(struct t *t)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
int k;
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 24);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
t->dy = 0;
|
|
nsz |
f9d179 |
t->y = 0;
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_flt(mx, t->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
k = mpfr_mul_2si(mx, mx, t->i, t->r);
|
|
Szabolcs Nagy |
c58b8e |
adjust(mx, mx, k, t->r, FLT);
|
|
nsz |
f9d179 |
t->y = mpfr_get_flt(mx, MPFR_RNDN);
|
|
nsz |
f9d179 |
t->e = eflags(isnan(t->x));
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
int mpldexpl(struct t *t)
|
|
nsz |
f9d179 |
{
|
|
nsz |
f9d179 |
int k;
|
|
nsz |
f9d179 |
MPFR_DECL_INIT(mx, 64);
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
t->dy = 0;
|
|
nsz |
f9d179 |
t->y = 0;
|
|
nsz |
f9d179 |
mpfr_clear_flags();
|
|
nsz |
f9d179 |
mpfr_set_ld(mx, t->x, MPFR_RNDN);
|
|
nsz |
f9d179 |
k = mpfr_mul_2si(mx, mx, t->i, t->r);
|
|
Szabolcs Nagy |
c58b8e |
adjust(mx, mx, k, t->r, LDBL);
|
|
nsz |
f9d179 |
t->y = mpfr_get_ld(mx, MPFR_RNDN);
|
|
nsz |
f9d179 |
t->e = eflags(isnan(t->x));
|
|
nsz |
f9d179 |
return 0;
|
|
nsz |
f9d179 |
}
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
int mpscalbn(struct t *t) { return mpldexp(t); }
|
|
nsz |
f9d179 |
int mpscalbnf(struct t *t) { return mpldexpf(t); }
|
|
nsz |
f9d179 |
int mpscalbnl(struct t *t) { return mpldexpl(t); }
|
|
nsz |
f9d179 |
int mpscalbln(struct t *t) { return mpldexp(t); }
|
|
nsz |
f9d179 |
int mpscalblnf(struct t *t) { return mpldexpf(t); }
|
|
nsz |
f9d179 |
int mpscalblnl(struct t *t) { return mpldexpl(t); }
|
|
nsz |
f9d179 |
|
|
nsz |
f9d179 |
int mplgamma_r(struct t *t) { return mplgamma(t); }
|
|
nsz |
f9d179 |
int mplgammaf_r(struct t *t) { return mplgammaf(t); }
|
|
nsz |
f9d179 |
int mplgammal_r(struct t *t) { return mplgammal(t); }
|
|
nsz |
2146d5 |
|
|
nsz |
2146d5 |
int mpilogb(struct t *t)
|
|
nsz |
2146d5 |
{
|
|
nsz |
2146d5 |
MPFR_DECL_INIT(mx, 53);
|
|
nsz |
2146d5 |
|
|
nsz |
2146d5 |
mpfr_set_d(mx, t->x, MPFR_RNDN);
|
|
nsz |
2146d5 |
t->i = mpfr_get_exp(mx) - 1;
|
|
nsz |
2146d5 |
t->e = 0;
|
|
Szabolcs Nagy |
9aeadc |
if (isinf(t->x) || isnan(t->x) || t->x == 0)
|
|
Szabolcs Nagy |
9aeadc |
t->e = INVALID;
|
|
nsz |
2146d5 |
return 0;
|
|
nsz |
2146d5 |
}
|
|
nsz |
2146d5 |
int mpilogbf(struct t *t)
|
|
nsz |
2146d5 |
{
|
|
nsz |
2146d5 |
MPFR_DECL_INIT(mx, 24);
|
|
nsz |
2146d5 |
|
|
nsz |
2146d5 |
mpfr_set_flt(mx, t->x, MPFR_RNDN);
|
|
nsz |
2146d5 |
t->i = mpfr_get_exp(mx) - 1;
|
|
nsz |
2146d5 |
t->e = 0;
|
|
Szabolcs Nagy |
9aeadc |
if (isinf(t->x) || isnan(t->x) || t->x == 0)
|
|
Szabolcs Nagy |
9aeadc |
t->e = INVALID;
|
|
nsz |
2146d5 |
return 0;
|
|
nsz |
2146d5 |
}
|
|
nsz |
2146d5 |
int mpilogbl(struct t *t)
|
|
nsz |
2146d5 |
{
|
|
nsz |
2146d5 |
MPFR_DECL_INIT(mx, 64);
|
|
nsz |
2146d5 |
|
|
nsz |
2146d5 |
mpfr_set_ld(mx, t->x, MPFR_RNDN);
|
|
nsz |
2146d5 |
t->i = mpfr_get_exp(mx) - 1;
|
|
nsz |
2146d5 |
t->e = 0;
|
|
Szabolcs Nagy |
9aeadc |
if (isinf(t->x) || isnan(t->x) || t->x == 0)
|
|
Szabolcs Nagy |
9aeadc |
t->e = INVALID;
|
|
nsz |
2146d5 |
return 0;
|
|
nsz |
2146d5 |
}
|
|
nsz |
2146d5 |
|
|
nsz |
b5bbc6 |
// TODO: ll* is hard to do with mpfr
|
|
nsz |
b5bbc6 |
#define mp_f_i(n) \
|
|
nsz |
b5bbc6 |
int mp##n(struct t *t) \
|
|
nsz |
b5bbc6 |
{ \
|
|
nsz |
b5bbc6 |
setupfenv(t->r); \
|
|
nsz |
b5bbc6 |
t->i = n(t->x); \
|
|
nsz |
b5bbc6 |
t->e = getexcept(); \
|
|
Szabolcs Nagy |
c58b8e |
if (t->e & INVALID) \
|
|
Szabolcs Nagy |
c58b8e |
t->i = 0; \
|
|
nsz |
b5bbc6 |
return 0; \
|
|
nsz |
b5bbc6 |
}
|
|
nsz |
b5bbc6 |
|
|
nsz |
b5bbc6 |
mp_f_i(llrint)
|
|
nsz |
b5bbc6 |
mp_f_i(llrintf)
|
|
nsz |
b5bbc6 |
mp_f_i(llrintl)
|
|
nsz |
b5bbc6 |
mp_f_i(lrint)
|
|
nsz |
b5bbc6 |
mp_f_i(lrintf)
|
|
nsz |
b5bbc6 |
mp_f_i(lrintl)
|
|
nsz |
b5bbc6 |
mp_f_i(llround)
|
|
nsz |
b5bbc6 |
mp_f_i(llroundf)
|
|
nsz |
b5bbc6 |
mp_f_i(llroundl)
|
|
nsz |
b5bbc6 |
mp_f_i(lround)
|
|
nsz |
b5bbc6 |
mp_f_i(lroundf)
|
|
nsz |
b5bbc6 |
mp_f_i(lroundl)
|
|
nsz |
b5bbc6 |
|
|
nsz |
cb9f87 |
int mpmodf(struct t *t)
|
|
nsz |
cb9f87 |
{
|
|
nsz |
cb9f87 |
int e, r;
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
r = mpd1(t, wrap_trunc);
|
|
nsz |
cb9f87 |
if (r)
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
t->y2 = t->y;
|
|
nsz |
cb9f87 |
t->dy2 = t->dy;
|
|
Szabolcs Nagy |
9aeadc |
e = t->e & ~INEXACT;
|
|
nsz |
cb9f87 |
r = mpd1(t, mpfr_frac);
|
|
nsz |
cb9f87 |
t->e |= e;
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
int mpmodff(struct t *t)
|
|
nsz |
cb9f87 |
{
|
|
nsz |
cb9f87 |
int e, r;
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
r = mpf1(t, wrap_trunc);
|
|
nsz |
cb9f87 |
if (r)
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
t->y2 = t->y;
|
|
nsz |
cb9f87 |
t->dy2 = t->dy;
|
|
Szabolcs Nagy |
9aeadc |
e = t->e & ~INEXACT;
|
|
nsz |
cb9f87 |
r = mpf1(t, mpfr_frac);
|
|
nsz |
cb9f87 |
t->e |= e;
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
int mpmodfl(struct t *t)
|
|
nsz |
cb9f87 |
{
|
|
nsz |
cb9f87 |
int e, r;
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
r = mpl1(t, wrap_trunc);
|
|
nsz |
cb9f87 |
if (r)
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
t->y2 = t->y;
|
|
nsz |
cb9f87 |
t->dy2 = t->dy;
|
|
Szabolcs Nagy |
9aeadc |
e = t->e & ~INEXACT;
|
|
nsz |
cb9f87 |
r = mpl1(t, mpfr_frac);
|
|
nsz |
cb9f87 |
t->e |= e;
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
int mpsincos(struct t *t)
|
|
nsz |
cb9f87 |
{
|
|
nsz |
cb9f87 |
int e, r;
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
r = mpd1(t, mpfr_cos);
|
|
nsz |
cb9f87 |
if (r)
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
t->y2 = t->y;
|
|
nsz |
cb9f87 |
t->dy2 = t->dy;
|
|
nsz |
cb9f87 |
e = t->e;
|
|
nsz |
cb9f87 |
r = mpd1(t, mpfr_sin);
|
|
nsz |
cb9f87 |
t->e |= e;
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
int mpsincosf(struct t *t)
|
|
nsz |
cb9f87 |
{
|
|
nsz |
cb9f87 |
int e, r;
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
r = mpf1(t, mpfr_cos);
|
|
nsz |
cb9f87 |
if (r)
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
t->y2 = t->y;
|
|
nsz |
cb9f87 |
t->dy2 = t->dy;
|
|
nsz |
cb9f87 |
e = t->e;
|
|
nsz |
cb9f87 |
r = mpf1(t, mpfr_sin);
|
|
nsz |
cb9f87 |
t->e |= e;
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
int mpsincosl(struct t *t)
|
|
nsz |
cb9f87 |
{
|
|
nsz |
cb9f87 |
int e, r;
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
r = mpl1(t, mpfr_cos);
|
|
nsz |
cb9f87 |
if (r)
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
t->y2 = t->y;
|
|
nsz |
cb9f87 |
t->dy2 = t->dy;
|
|
nsz |
cb9f87 |
e = t->e;
|
|
nsz |
cb9f87 |
r = mpl1(t, mpfr_sin);
|
|
nsz |
cb9f87 |
t->e |= e;
|
|
nsz |
cb9f87 |
return r;
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
|
|
nsz |
588927 |
int mpremquo(struct t *t) { return mpd2(t, wrap_remquo) || (t->i = mpremquo_q, 0); }
|
|
nsz |
588927 |
int mpremquof(struct t *t) { return mpf2(t, wrap_remquo) || (t->i = mpremquo_q, 0); }
|
|
nsz |
588927 |
int mpremquol(struct t *t) { return mpl2(t, wrap_remquo) || (t->i = mpremquo_q, 0); }
|
|
nsz |
588927 |
|
|
nsz |
588927 |
int mpfma(struct t *t)
|
|
nsz |
588927 |
{
|
|
nsz |
588927 |
int tn;
|
|
nsz |
588927 |
int r = rmap(t->r);
|
|
nsz |
588927 |
MPFR_DECL_INIT(mx, 53);
|
|
nsz |
588927 |
MPFR_DECL_INIT(mx2, 53);
|
|
nsz |
588927 |
MPFR_DECL_INIT(mx3, 53);
|
|
nsz |
588927 |
MPFR_DECL_INIT(my, 128);
|
|
nsz |
588927 |
|
|
nsz |
588927 |
mpfr_clear_flags();
|
|
nsz |
588927 |
mpfr_set_d(mx, t->x, MPFR_RNDN);
|
|
nsz |
588927 |
mpfr_set_d(mx2, t->x2, MPFR_RNDN);
|
|
nsz |
588927 |
mpfr_set_d(mx3, t->x3, MPFR_RNDN);
|
|
nsz |
588927 |
tn = mpfr_fma(my, mx, mx2, mx3, r);
|
|
nsz |
588927 |
gend(t, my, tn, r);
|
|
nsz |
588927 |
return 0;
|
|
nsz |
588927 |
}
|
|
nsz |
588927 |
|
|
nsz |
588927 |
int mpfmaf(struct t *t)
|
|
nsz |
588927 |
{
|
|
nsz |
588927 |
int tn;
|
|
nsz |
588927 |
int r = rmap(t->r);
|
|
nsz |
588927 |
MPFR_DECL_INIT(mx, 24);
|
|
nsz |
588927 |
MPFR_DECL_INIT(mx2, 24);
|
|
nsz |
588927 |
MPFR_DECL_INIT(mx3, 24);
|
|
nsz |
588927 |
MPFR_DECL_INIT(my, 128);
|
|
nsz |
588927 |
|
|
nsz |
588927 |
mpfr_clear_flags();
|
|
nsz |
588927 |
mpfr_set_flt(mx, t->x, MPFR_RNDN);
|
|
nsz |
588927 |
mpfr_set_flt(mx2, t->x2, MPFR_RNDN);
|
|
nsz |
588927 |
mpfr_set_flt(mx3, t->x3, MPFR_RNDN);
|
|
nsz |
588927 |
tn = mpfr_fma(my, mx, mx2, mx3, r);
|
|
nsz |
588927 |
genf(t, my, tn, r);
|
|
nsz |
588927 |
return 0;
|
|
nsz |
588927 |
}
|
|
nsz |
588927 |
|
|
nsz |
588927 |
int mpfmal(struct t *t)
|
|
nsz |
588927 |
{
|
|
nsz |
588927 |
#if LDBL_MANT_DIG == 53
|
|
nsz |
588927 |
return mpfma(t);
|
|
nsz |
588927 |
#elif LDBL_MANT_DIG == 64
|
|
nsz |
588927 |
int tn;
|
|
nsz |
588927 |
int r = rmap(t->r);
|
|
nsz |
588927 |
MPFR_DECL_INIT(mx, 64);
|
|
nsz |
588927 |
MPFR_DECL_INIT(mx2, 64);
|
|
nsz |
588927 |
MPFR_DECL_INIT(mx3, 64);
|
|
nsz |
588927 |
MPFR_DECL_INIT(my, 128);
|
|
nsz |
588927 |
|
|
nsz |
588927 |
mpfr_clear_flags();
|
|
nsz |
588927 |
mpfr_set_ld(mx, t->x, MPFR_RNDN);
|
|
nsz |
588927 |
mpfr_set_ld(mx2, t->x2, MPFR_RNDN);
|
|
nsz |
588927 |
mpfr_set_ld(mx3, t->x3, MPFR_RNDN);
|
|
nsz |
588927 |
tn = mpfr_fma(my, mx, mx2, mx3, r);
|
|
nsz |
588927 |
genl(t, my, tn, r);
|
|
nsz |
588927 |
return 0;
|
|
nsz |
588927 |
#else
|
|
nsz |
588927 |
return -1;
|
|
nsz |
588927 |
#endif
|
|
nsz |
588927 |
}
|
|
nsz |
588927 |
|
|
nsz |
21dd45 |
int mpjn(struct t *t) { mpbessel_n = t->i; return mpd1(t, wrap_jn); }
|
|
nsz |
21dd45 |
int mpjnf(struct t *t) { mpbessel_n = t->i; return mpf1(t, wrap_jn); }
|
|
nsz |
21dd45 |
int mpjnl(struct t *t) { mpbessel_n = t->i; return mpl1(t, wrap_jn); }
|
|
nsz |
21dd45 |
int mpyn(struct t *t) { mpbessel_n = t->i; return mpd1(t, wrap_yn); }
|
|
nsz |
21dd45 |
int mpynf(struct t *t) { mpbessel_n = t->i; return mpf1(t, wrap_yn); }
|
|
nsz |
21dd45 |
int mpynl(struct t *t) { mpbessel_n = t->i; return mpl1(t, wrap_yn); }
|
|
nsz |
21dd45 |
|