version 1.5, 2015/08/07 05:30:35 |
version 1.7, 2015/08/07 08:00:30 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/builtin/bfaux.c,v 1.4 2015/08/06 23:41:52 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/builtin/bfaux.c,v 1.6 2015/08/07 06:15:00 takayama Exp $ */ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
void Peval(), Psetprec(), Psetbprec(), Ptodouble(), Psetround(); |
void Peval(), Psetprec(), Psetbprec(), Ptodouble(), Psetround(); |
void Pmpfr_gamma(); |
void Pmpfr_gamma(), Pmpfr_floor(), Pmpfr_round(); |
|
|
struct ftab bf_tab[] = { |
struct ftab bf_tab[] = { |
{"eval",Peval,-2}, |
{"eval",Peval,-2}, |
Line 12 struct ftab bf_tab[] = { |
|
Line 12 struct ftab bf_tab[] = { |
|
{"setround",Psetround,-1}, |
{"setround",Psetround,-1}, |
{"todouble",Ptodouble,1}, |
{"todouble",Ptodouble,1}, |
{"mpfr_gamma",Pmpfr_gamma,-2}, |
{"mpfr_gamma",Pmpfr_gamma,-2}, |
|
{"mpfr_floor",Pmpfr_floor,-1}, |
|
{"mpfr_round",Pmpfr_round,-1}, |
{0,0,0}, |
{0,0,0}, |
}; |
}; |
|
|
Line 392 void Pmpfr_gamma(NODE arg,BF *rp) |
|
Line 394 void Pmpfr_gamma(NODE arg,BF *rp) |
|
prec ? mpfr_init2(r->body,prec) : mpfr_init(r->body); |
prec ? mpfr_init2(r->body,prec) : mpfr_init(r->body); |
mpfr_gamma(r->body,((BF)a)->body,mpfr_roundmode); |
mpfr_gamma(r->body,((BF)a)->body,mpfr_roundmode); |
*rp = r; |
*rp = r; |
|
} |
|
|
|
void Pmpfr_floor(NODE arg,Q *rp) |
|
{ |
|
Num a; |
|
int prec; |
|
BF r; |
|
mpz_t t; |
|
GZ rz; |
|
|
|
prec = NEXT(arg) ? QTOS((Q)ARG1(arg)) : 0; |
|
prec *= 3.32193; |
|
a = tobf(ARG0(arg),prec); |
|
NEWBF(r); |
|
prec ? mpfr_init2(r->body,prec) : mpfr_init(r->body); |
|
mpfr_floor(r->body,((BF)a)->body); |
|
mpz_init(t); |
|
mpfr_get_z(t,r->body,mpfr_roundmode); |
|
MPZTOGZ(t,rz); |
|
*rp = gztoz(rz); |
|
} |
|
|
|
void Pmpfr_round(NODE arg,Q *rp) |
|
{ |
|
Num a; |
|
int prec; |
|
BF r; |
|
mpz_t t; |
|
GZ rz; |
|
|
|
prec = NEXT(arg) ? QTOS((Q)ARG1(arg)) : 0; |
|
prec *= 3.32193; |
|
a = tobf(ARG0(arg),prec); |
|
NEWBF(r); |
|
prec ? mpfr_init2(r->body,prec) : mpfr_init(r->body); |
|
mpfr_round(r->body,((BF)a)->body); |
|
mpz_init(t); |
|
mpfr_get_z(t,r->body,mpfr_roundmode); |
|
MPZTOGZ(t,rz); |
|
*rp = gztoz(rz); |
} |
} |