version 1.14, 2004/12/10 07:36:35 |
version 1.19, 2017/08/31 09:11:04 |
|
|
* 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/bsave.c,v 1.13 2003/12/22 09:33:47 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/io/bsave.c,v 1.18 2015/08/13 00:13:03 noro Exp $ |
*/ |
*/ |
/* saveXXX must not use GC_malloc(), GC_malloc_atomic(). */ |
/* saveXXX must not use GC_malloc(), GC_malloc_atomic(). */ |
|
|
|
|
#include "parse.h" |
#include "parse.h" |
#include "com.h" |
#include "com.h" |
|
|
#if defined(PARI) |
void savenbp(FILE *s,NBP p); |
#include "genpari.h" |
|
int get_lg(GEN); |
|
#endif |
|
|
|
void (*savef[])() = { 0, savenum, savep, saver, savelist, savevect, |
void (*savef[])() = { 0, savenum, savep, saver, savelist, savevect, |
savemat, savestring, 0, savedp, saveui, saveerror,0,0,0,savegfmmat, savebytearray }; |
savemat, savestring, 0, savedp, saveui, saveerror,0,0,0,savegfmmat, |
|
savebytearray, 0, 0, 0, 0, 0, 0, 0, 0, savenbp }; |
#if defined(INTERVAL) |
#if defined(INTERVAL) |
void saveitv(); |
void saveitv(); |
void saveitvd(); |
void saveitvd(); |
Line 112 void savereal(FILE *s,Real p) |
|
Line 110 void savereal(FILE *s,Real p) |
|
|
|
void savebf(FILE *s,BF p) |
void savebf(FILE *s,BF p) |
{ |
{ |
#if defined(PARI) |
unsigned int zero = 0; |
GEN z; |
unsigned int prec; |
int sign; |
L exp; |
unsigned long expo; |
int sgn,len,t; |
unsigned int len,t; |
|
|
|
z = (GEN)BDY(p); |
prec = MPFR_PREC(p->body); |
sign = signe(z); |
exp = MPFR_EXP(p->body); |
len = lg(z)-2; |
sgn = MPFR_SIGN(p->body); |
expo = expo(z); |
len = MPFR_LIMB_SIZE(p->body); |
|
|
write_int(s,&sign); |
write_int(s,&sgn); |
|
write_int(s,(int *)&prec); |
#if defined(LONG_IS_32BIT) |
write_int64(s,(UL *)&exp); |
write_int(s,(int *)&zeroval); /* expo>>32 is always 0 */ |
#if defined(VISUAL) |
write_int(s,(int *)&expo); |
#if !defined(_WIN64) |
write_int(s,&len); |
write_int(s,&len); |
write_intarray(s,(int *)&z[2],len); |
write_intarray(s,p->body->_mpfr_d,len); |
#elif defined(LONG_IS_64BIT) |
#else |
t = expo>>32; write_int(s,(int *)&t); |
t = (prec+31)/32; |
t = expo&0xffffffff; write_int(s,&t); |
write_int(s,&t); |
t = 2*len; write_int(s,&t); |
write_longarray(s,(long long *)p->body->_mpfr_d,t); |
write_longarray(s,&z[2],len); |
|
#endif |
#endif |
#else |
#else |
error("savebf : PARI is not combined"); |
#if SIZEOF_LONG == 4 |
|
write_int(s,&len); |
|
write_intarray(s,p->body->_mpfr_d,len); |
|
#else /* SIZEOF_LONG == 8 */ |
|
t = (prec+31)/32; |
|
write_int(s,&t); |
|
write_longarray(s,p->body->_mpfr_d,t); |
#endif |
#endif |
|
#endif |
} |
} |
|
|
#if defined(INTERVAL) |
#if defined(INTERVAL) |
Line 203 void savegfsn(FILE *s,GFSN p) |
|
Line 206 void savegfsn(FILE *s,GFSN p) |
|
|
|
void savedalg(FILE *s,DAlg p) |
void savedalg(FILE *s,DAlg p) |
{ |
{ |
saveobj(s,p->nm); |
saveobj(s,(Obj)p->nm); |
saveobj(s,p->dn); |
saveobj(s,(Obj)p->dn); |
} |
} |
|
|
void savep(FILE *s,P p) |
void savep(FILE *s,P p) |
Line 344 void savebytearray(FILE *s,BYTEARRAY p) |
|
Line 347 void savebytearray(FILE *s,BYTEARRAY p) |
|
{ |
{ |
write_short(s,&OID(p)); write_int(s,&p->len); |
write_short(s,&OID(p)); write_int(s,&p->len); |
write_string(s,p->body,p->len); |
write_string(s,p->body,p->len); |
|
} |
|
|
|
void savenbp(FILE *s,NBP p) |
|
{ |
|
int i,n; |
|
NODE t; |
|
NBM m; |
|
|
|
write_short(s,&OID(p)); |
|
for ( n = 0, t = BDY(p); t; t = NEXT(t), n++ ); |
|
write_int(s,&n); |
|
for ( i = 0, t = BDY(p); i < n; t = NEXT(t), i++ ) { |
|
m = (NBM)BDY(t); |
|
saveobj(s,(Obj)m->c); |
|
write_int(s,&m->d); |
|
write_intarray(s,m->b,(m->d+31)/32); |
|
} |
} |
} |