version 1.1, 2018/09/19 05:45:06 |
version 1.5, 2020/11/10 04:48:49 |
|
|
/* $OpenXM$ */ |
/* $OpenXM: OpenXM_contrib2/asir2018/builtin/parif.c,v 1.4 2020/08/26 06:40:36 noro Exp $ */ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
#include "ox.h" |
#include "ox.h" |
Line 20 void Pmpfr_floor(), Pmpfr_round(), Pmpfr_ceil(); |
|
Line 20 void Pmpfr_floor(), Pmpfr_round(), Pmpfr_ceil(); |
|
|
|
void Pox_shutdown(NODE arg,Q *rp); |
void Pox_shutdown(NODE arg,Q *rp); |
void Pox_launch_nox(NODE arg,Obj *rp); |
void Pox_launch_nox(NODE arg,Obj *rp); |
|
void Pox_launch(NODE arg,Obj *rp); |
void Pox_push_cmo(NODE arg,Obj *rp); |
void Pox_push_cmo(NODE arg,Obj *rp); |
void Pox_pop_cmo(NODE arg,Obj *rp); |
void Pox_pop_cmo(NODE arg,Obj *rp); |
void Pox_execute_function(NODE arg,Obj *rp); |
void Pox_execute_function(NODE arg,Obj *rp); |
|
|
|
int debug_pari; |
|
|
struct mpfr_tab_rec { |
struct mpfr_tab_rec { |
char *name; |
char *name; |
mpfr_func func; |
mpfr_func func; |
Line 107 void reset_ox_pari() |
|
Line 110 void reset_ox_pari() |
|
} |
} |
} |
} |
|
|
|
void pari_setprec(long n) |
|
{ |
|
struct oFUNC f; |
|
Z z; |
|
NODE arg; |
|
|
|
f.name = f.fullname = "pari_setprec"; |
|
f.id = A_PARI; |
|
f.argc = 1; |
|
f.f.binf = 0; |
|
STOZ(n,z); |
|
arg = mknode(1,z); |
|
evalparif(&f,arg); |
|
} |
|
|
|
/* decimal precision */ |
|
long mpfrprec = 0; |
|
|
pointer evalparif(FUNC f,NODE arg) |
pointer evalparif(FUNC f,NODE arg) |
{ |
{ |
int ac,intarg,opt,prec; |
long prec; |
|
int ac,intarg,opt; |
Q q,r,cmd; |
Q q,r,cmd; |
Z narg; |
Z narg; |
Real sec; |
Real sec; |
Line 121 pointer evalparif(FUNC f,NODE arg) |
|
Line 143 pointer evalparif(FUNC f,NODE arg) |
|
mpfr_func mpfr_function; |
mpfr_func mpfr_function; |
V v; |
V v; |
|
|
if ( arg && ARG0(arg) && NID((Num)ARG0(arg)) != N_C |
if ( arg && (!ARG0(arg) || (NUM(ARG0(arg)) && NID((Num)ARG0(arg)) != N_C)) |
&& (mpfr_function = mpfr_search(f->name)) ) { |
&& (mpfr_function = mpfr_search(f->name)) ) { |
(*mpfr_function)(arg,&ret); |
(*mpfr_function)(arg,&ret); |
return (pointer) ret; |
return (pointer) ret; |
Line 139 pointer evalparif(FUNC f,NODE arg) |
|
Line 161 pointer evalparif(FUNC f,NODE arg) |
|
#if !defined(VISUAL) |
#if !defined(VISUAL) |
MKSTR(name,"ox_pari"); |
MKSTR(name,"ox_pari"); |
nd = mknode(2,NULL,name); |
nd = mknode(2,NULL,name); |
Pox_launch_nox(nd,(Obj *)&r); |
if ( debug_pari ) |
|
Pox_launch(nd,(Obj *)&r); |
|
else |
|
Pox_launch_nox(nd,(Obj *)&r); |
#else |
#else |
error("Please load names.rr from latest asir-contrib library before using pari functions."); |
error("Please load names.rr from latest asir-contrib library before using pari functions."); |
#endif |
#endif |
Line 148 pointer evalparif(FUNC f,NODE arg) |
|
Line 173 pointer evalparif(FUNC f,NODE arg) |
|
ox_pari_stream_initialized = 1; |
ox_pari_stream_initialized = 1; |
} |
} |
|
|
|
prec = mpfr_get_default_prec()*0.30103+1; |
|
if ( prec != mpfrprec ) { |
|
mpfrprec = prec; |
|
pari_setprec(prec); |
|
} |
ac = argc(arg); |
ac = argc(arg); |
/* reverse the arg list */ |
/* reverse the arg list */ |
for ( n = arg, t = 0; n; n = NEXT(n) ) { |
for ( n = arg, t = 0; n; n = NEXT(n) ) { |
Line 159 pointer evalparif(FUNC f,NODE arg) |
|
Line 189 pointer evalparif(FUNC f,NODE arg) |
|
Pox_push_cmo(oxarg,&dmy); |
Pox_push_cmo(oxarg,&dmy); |
} |
} |
MKSTR(name,f->name); |
MKSTR(name,f->name); |
STOQ(ac,narg); |
STOZ(ac,narg); |
oxarg = mknode(3,ox_pari_stream,name,narg); |
oxarg = mknode(3,ox_pari_stream,name,narg); |
Pox_execute_function(oxarg,&dmy); |
Pox_execute_function(oxarg,&dmy); |
ox_get_pari_result = 1; |
ox_get_pari_result = 1; |
#if defined(VISUAL) || defined(__MINGW32__) |
#if defined(VISUAL) || defined(__MINGW32__) |
#define SM_popCMO 262 |
#define SM_popCMO 262 |
STOQ(SM_popCMO,cmd); |
STOZ(SM_popCMO,cmd); |
oxarg = mknode(2,ox_pari_stream,cmd); |
oxarg = mknode(2,ox_pari_stream,cmd); |
Pox_push_cmd(oxarg,&dmy); |
Pox_push_cmd(oxarg,&dmy); |
nd = mknode(1,ox_pari_stream); |
nd = mknode(1,ox_pari_stream); |