version 1.19, 2015/08/14 13:51:55 |
version 1.20, 2015/08/18 02:26:05 |
|
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* $OpenXM: OpenXM_contrib2/asir2000/io/cio.c,v 1.18 2015/08/13 00:13:03 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/io/cio.c,v 1.19 2015/08/14 13:51:55 fujimoto Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 68 int valid_as_cmo(Obj obj) |
|
Line 68 int valid_as_cmo(Obj obj) |
|
return 1; |
return 1; |
case O_N: |
case O_N: |
nid = NID((Num)obj); |
nid = NID((Num)obj); |
if ( nid == N_Q || nid == N_R || nid == N_B ) |
if ( nid == N_Q || nid == N_R || nid == N_B || nid == N_C ) |
return 1; |
return 1; |
else |
else |
return 0; |
return 0; |
Line 106 void write_cmo(FILE *s,Obj obj) |
|
Line 106 void write_cmo(FILE *s,Obj obj) |
|
case N_B: |
case N_B: |
write_cmo_bf(s,(BF)obj); |
write_cmo_bf(s,(BF)obj); |
break; |
break; |
|
case N_C: |
|
write_cmo_complex(s,(C)obj); |
|
break; |
default: |
default: |
sprintf(errmsg, "write_cmo : number id=%d not implemented.", |
sprintf(errmsg, "write_cmo : number id=%d not implemented.", |
NID((Num)obj)); |
NID((Num)obj)); |
Line 174 int cmo_tag(Obj obj,int *tag) |
|
Line 177 int cmo_tag(Obj obj,int *tag) |
|
*tag = CMO_IEEE_DOUBLE_FLOAT; break; |
*tag = CMO_IEEE_DOUBLE_FLOAT; break; |
case N_B: |
case N_B: |
*tag = CMO_BIGFLOAT; break; |
*tag = CMO_BIGFLOAT; break; |
|
case N_C: |
|
*tag = CMO_COMPLEX; break; |
default: |
default: |
return 0; |
return 0; |
} |
} |
Line 256 void write_cmo_bf(FILE *s,BF bf) |
|
Line 261 void write_cmo_bf(FILE *s,BF bf) |
|
len = MPFR_LIMB_SIZE(bf->body); |
len = MPFR_LIMB_SIZE(bf->body); |
#if SIZEOF_LONG == 4 |
#if SIZEOF_LONG == 4 |
write_int(s,&len); |
write_int(s,&len); |
write_intarray(s,MPFR_MANT(bf->body),len); |
write_intarray(s,(int *)MPFR_MANT(bf->body),len); |
#else /* SIZEOF_LONG == 8 */ |
#else /* SIZEOF_LONG == 8 */ |
t = (MPFR_PREC(bf->body)+31)/32; |
t = (MPFR_PREC(bf->body)+31)/32; |
write_int(s,&t); |
write_int(s,&t); |
Line 347 void write_cmo_r(FILE *s,R f) |
|
Line 352 void write_cmo_r(FILE *s,R f) |
|
write_cmo(s,(Obj)DN(f)); |
write_cmo(s,(Obj)DN(f)); |
} |
} |
|
|
|
void write_cmo_complex(FILE *s,C f) |
|
{ |
|
int r; |
|
|
|
r = CMO_COMPLEX; write_int(s,&r); |
|
write_cmo(s,(Obj)f->r); |
|
write_cmo(s,(Obj)f->i); |
|
} |
|
|
void write_cmo_dp(FILE *s,DP dp) |
void write_cmo_dp(FILE *s,DP dp) |
{ |
{ |
int i,n,nv,r; |
int i,n,nv,r; |
Line 482 void read_cmo(FILE *s,Obj *rp) |
|
Line 496 void read_cmo(FILE *s,Obj *rp) |
|
N nm,dn; |
N nm,dn; |
P p,pnm,pdn; |
P p,pnm,pdn; |
Real real; |
Real real; |
|
C c; |
double dbl; |
double dbl; |
STRING str; |
STRING str; |
USINT t; |
USINT t; |
Line 540 void read_cmo(FILE *s,Obj *rp) |
|
Line 555 void read_cmo(FILE *s,Obj *rp) |
|
case CMO_BIGFLOAT: |
case CMO_BIGFLOAT: |
read_cmo_bf(s,&bf); *rp = (Obj)bf; |
read_cmo_bf(s,&bf); *rp = (Obj)bf; |
break; |
break; |
|
case CMO_COMPLEX: |
|
NEWC(c); |
|
read_cmo(s,(Obj *)&c->r); |
|
read_cmo(s,(Obj *)&c->i); |
|
*rp = (Obj)c; |
|
break; |
case CMO_DISTRIBUTED_POLYNOMIAL: |
case CMO_DISTRIBUTED_POLYNOMIAL: |
read_cmo_dp(s,&dp); *rp = (Obj)dp; |
read_cmo_dp(s,&dp); *rp = (Obj)dp; |
break; |
break; |
Line 652 void read_cmo_bf(FILE *s,BF *bf) |
|
Line 673 void read_cmo_bf(FILE *s,BF *bf) |
|
MPFR_SIGN(r->body) = sgn; |
MPFR_SIGN(r->body) = sgn; |
MPFR_EXP(r->body) = exp; |
MPFR_EXP(r->body) = exp; |
#if SIZEOF_LONG == 4 |
#if SIZEOF_LONG == 4 |
read_intarray(s,MPFR_MANT(r->body),len); |
read_intarray(s,(int *)MPFR_MANT(r->body),len); |
#else /* SIZEOF_LONG == 8 */ |
#else /* SIZEOF_LONG == 8 */ |
read_longarray(s,MPFR_MANT(r->body),len); |
read_longarray(s,MPFR_MANT(r->body),len); |
#endif |
#endif |