version 1.4, 2019/11/12 10:53:23 |
version 1.5, 2020/10/06 06:31:20 |
|
|
* 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/asir2018/io/bload.c,v 1.3 2019/08/28 23:27:34 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/io/bload.c,v 1.4 2019/11/12 10:53:23 kondoh Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 71 void loadobj(FILE *s,Obj *p) |
|
Line 71 void loadobj(FILE *s,Obj *p) |
|
{ |
{ |
short id; |
short id; |
|
|
read_short(s,&id); |
read_short(s,(unsigned short *)&id); |
if ( !id ) |
if ( !id ) |
*p = 0; |
*p = 0; |
else if ( !loadf[id] ) |
else if ( !loadf[id] ) |
Line 84 void loadnum(FILE *s,Num *p) |
|
Line 84 void loadnum(FILE *s,Num *p) |
|
{ |
{ |
char nid; |
char nid; |
|
|
read_char(s,&nid); |
read_char(s,(unsigned char *)&nid); |
if ( !nloadf[nid] ) |
if ( !nloadf[nid] ) |
error("loadnum : not implemented"); |
error("loadnum : not implemented"); |
else |
else |
Line 100 void loadq(FILE *s,Q *p) |
|
Line 100 void loadq(FILE *s,Q *p) |
|
mpz_t z; |
mpz_t z; |
Z nm,dn; |
Z nm,dn; |
|
|
read_char(s,&sgn); read_intarray(s,size,len); |
read_char(s,(unsigned char *)&sgn); read_intarray(s,(unsigned int *)size,len); |
bnm = (int *)MALLOC(size[0]*sizeof(int)); |
bnm = (int *)MALLOC(size[0]*sizeof(int)); |
read_intarray(s,bnm,size[0]); |
read_intarray(s,(unsigned int *)bnm,size[0]); |
mpz_init(z); |
mpz_init(z); |
mpz_import(z,size[0],-1,sizeof(int),0,0,bnm); |
mpz_import(z,size[0],-1,sizeof(int),0,0,bnm); |
if ( sgn < 0 ) mpz_neg(z,z); |
if ( sgn < 0 ) mpz_neg(z,z); |
MPZTOZ(z,nm); |
MPZTOZ(z,nm); |
if ( size[1] ) { |
if ( size[1] ) { |
bdn = (int *)MALLOC(size[1]*sizeof(int)); |
bdn = (int *)MALLOC(size[1]*sizeof(int)); |
read_intarray(s,bdn,size[1]); |
read_intarray(s,(unsigned int *)bdn,size[1]); |
mpz_init(z); |
mpz_init(z); |
mpz_import(z,size[1],-1,sizeof(int),0,0,bdn); |
mpz_import(z,size[1],-1,sizeof(int),0,0,bdn); |
MPZTOZ(z,dn); |
MPZTOZ(z,dn); |
Line 123 void loadreal(FILE *s,Real *p) |
|
Line 123 void loadreal(FILE *s,Real *p) |
|
Real q; |
Real q; |
char dmy; |
char dmy; |
|
|
read_char(s,&dmy); |
read_char(s,(unsigned char *)&dmy); |
NEWReal(q); read_double(s,&BDY(q)); |
NEWReal(q); read_double(s,&BDY(q)); |
*p = q; |
*p = q; |
} |
} |
Line 136 void loadbf(FILE *s,BF *p) |
|
Line 136 void loadbf(FILE *s,BF *p) |
|
UL exp; |
UL exp; |
|
|
int len; |
int len; |
read_char(s,&dmy); |
read_char(s,(unsigned char *)&dmy); |
NEWBF(r); |
NEWBF(r); |
read_int(s,&sgn); |
read_int(s,(unsigned int *)&sgn); |
read_int(s,&prec); |
read_int(s,(unsigned int *)&prec); |
read_int64(s,&exp); |
read_int64(s,&exp); |
read_int(s,&len); |
read_int(s,(unsigned int *)&len); |
mpfr_init2(r->body,prec); |
mpfr_init2(r->body,prec); |
MPFR_SIGN(r->body) = sgn; |
MPFR_SIGN(r->body) = sgn; |
MPFR_EXP(r->body) = (int)exp; |
MPFR_EXP(r->body) = (int)exp; |
#if defined(VISUAL) |
#if defined(VISUAL) |
#if !defined(_WIN64) |
#if !defined(_WIN64) |
read_intarray(s,(int *)r->body->_mpfr_d,len); |
read_intarray(s,r->body->_mpfr_d,len); |
#else |
#else |
read_longarray(s,(long long*)r->body->_mpfr_d,len); |
read_longarray(s,(long long*)r->body->_mpfr_d,len); |
#endif |
#endif |
#else |
#else |
#if SIZEOF_LONG == 4 |
#if SIZEOF_LONG == 4 |
read_intarray(s,(int *)r->body->_mpfr_d,len); |
read_intarray(s,r->body->_mpfr_d,len); |
#else /* SIZEOF_LONG == 8 */ |
#else /* SIZEOF_LONG == 8 */ |
read_longarray(s,(long *)r->body->_mpfr_d,len); |
read_longarray(s,(unsigned long *)r->body->_mpfr_d,len); |
#endif |
#endif |
#endif |
#endif |
*p = r; |
*p = r; |
Line 167 void loaditv(FILE *s,Itv *p) |
|
Line 167 void loaditv(FILE *s,Itv *p) |
|
Itv q; |
Itv q; |
char dmy; |
char dmy; |
|
|
read_char(s,&dmy); |
read_char(s,(unsigned char *)&dmy); |
NEWItvP(q); loadobj(s,(Obj *)&INF(q)); loadobj(s,(Obj *)&SUP(q)); |
NEWItvP(q); loadobj(s,(Obj *)&INF(q)); loadobj(s,(Obj *)&SUP(q)); |
*p = q; |
*p = q; |
} |
} |
Line 177 void loaditvd(FILE *s,IntervalDouble *p) |
|
Line 177 void loaditvd(FILE *s,IntervalDouble *p) |
|
IntervalDouble q; |
IntervalDouble q; |
char dmy; |
char dmy; |
|
|
read_char(s,&dmy); |
read_char(s,(unsigned char *)&dmy); |
NEWIntervalDouble(q); |
NEWIntervalDouble(q); |
read_double(s,&INF(q)); |
read_double(s,&INF(q)); |
read_double(s,&SUP(q)); |
read_double(s,&SUP(q)); |
Line 190 void loadcplx(FILE *s,C *p) |
|
Line 190 void loadcplx(FILE *s,C *p) |
|
C q; |
C q; |
char dmy; |
char dmy; |
|
|
read_char(s,&dmy); |
read_char(s,(unsigned char *)&dmy); |
NEWC(q); loadobj(s,(Obj *)&q->r); loadobj(s,(Obj *)&q->i); |
NEWC(q); loadobj(s,(Obj *)&q->r); loadobj(s,(Obj *)&q->i); |
*p = q; |
*p = q; |
} |
} |
Line 200 void loadmi(FILE *s,MQ *p) |
|
Line 200 void loadmi(FILE *s,MQ *p) |
|
MQ q; |
MQ q; |
char dmy; |
char dmy; |
|
|
read_char(s,&dmy); |
read_char(s,(unsigned char *)&dmy); |
NEWMQ(q); read_int(s,(int *)&CONT(q)); |
NEWMQ(q); read_int(s,(unsigned int *)&CONT(q)); |
*p = q; |
*p = q; |
} |
} |
|
|
Line 212 void loadlm(FILE *s,LM *p) |
|
Line 212 void loadlm(FILE *s,LM *p) |
|
int *b; |
int *b; |
mpz_t z; |
mpz_t z; |
|
|
read_char(s,&dmy); read_int(s,&size); |
read_char(s,(unsigned char *)&dmy); read_int(s,(unsigned int *)&size); |
b = (int *)MALLOC(size*sizeof(int)); |
b = (int *)MALLOC(size*sizeof(int)); |
read_intarray(s,b,size); |
read_intarray(s,(unsigned int *)b,size); |
mpz_init(z); |
mpz_init(z); |
mpz_import(z,size,-1,sizeof(int),0,0,b); |
mpz_import(z,size,-1,sizeof(int),0,0,b); |
MKLM(z,*p); |
MKLM(z,*p); |
Line 226 void loadgf2n(FILE *s,GF2N *p) |
|
Line 226 void loadgf2n(FILE *s,GF2N *p) |
|
int len; |
int len; |
UP2 body; |
UP2 body; |
|
|
read_char(s,&dmy); read_int(s,&len); |
read_char(s,(unsigned char *)&dmy); read_int(s,(unsigned int *)&len); |
NEWUP2(body,len); body->w = len; |
NEWUP2(body,len); body->w = len; |
read_intarray(s,body->b,len); |
read_intarray(s,(unsigned int *)body->b,len); |
MKGF2N(body,*p); |
MKGF2N(body,*p); |
} |
} |
|
|
Line 238 void loadgfpn(FILE *s,GFPN *p) |
|
Line 238 void loadgfpn(FILE *s,GFPN *p) |
|
int d,i; |
int d,i; |
UP body; |
UP body; |
|
|
read_char(s,&dmy); read_int(s,&d); |
read_char(s,(unsigned char *)&dmy); read_int(s,(unsigned int *)&d); |
body = UPALLOC(d); |
body = UPALLOC(d); |
body->d = d; |
body->d = d; |
for ( i = 0; i <= d; i++ ) |
for ( i = 0; i <= d; i++ ) |
Line 251 void loadgfs(FILE *s,GFS *p) |
|
Line 251 void loadgfs(FILE *s,GFS *p) |
|
GFS q; |
GFS q; |
char dmy; |
char dmy; |
|
|
read_char(s,&dmy); |
read_char(s,(unsigned char *)&dmy); |
NEWGFS(q); read_int(s,(int *)&CONT(q)); |
NEWGFS(q); read_int(s,(unsigned int *)&CONT(q)); |
*p = q; |
*p = q; |
} |
} |
|
|
Line 262 void loadgfsn(FILE *s,GFSN *p) |
|
Line 262 void loadgfsn(FILE *s,GFSN *p) |
|
int d; |
int d; |
UM body; |
UM body; |
|
|
read_char(s,&dmy); read_int(s,&d); |
read_char(s,(unsigned char *)&dmy); read_int(s,(unsigned int *)&d); |
body = UMALLOC(d); DEG(body) = d; |
body = UMALLOC(d); DEG(body) = d; |
read_intarray(s,COEF(body),d+1); |
read_intarray(s,(unsigned int *)COEF(body),d+1); |
MKGFSN(body,*p); |
MKGFSN(body,*p); |
} |
} |
|
|
Line 273 void loaddalg(FILE *s,DAlg *p) |
|
Line 273 void loaddalg(FILE *s,DAlg *p) |
|
char dmy; |
char dmy; |
Obj nm,dn; |
Obj nm,dn; |
|
|
read_char(s,&dmy); |
read_char(s,(unsigned char *)&dmy); |
loadobj(s,&nm); |
loadobj(s,&nm); |
loadobj(s,&dn); |
loadobj(s,&dn); |
MKDAlg((DP)nm,(Z)dn,*p); |
MKDAlg((DP)nm,(Z)dn,*p); |
Line 286 void loadp(FILE *s,P *p) |
|
Line 286 void loadp(FILE *s,P *p) |
|
DCP dc,dc0; |
DCP dc,dc0; |
P t; |
P t; |
|
|
read_int(s,&vindex); |
read_int(s,(unsigned int *)&vindex); |
if ( vindex < 0 ) |
if ( vindex < 0 ) |
/* v is a pure function */ |
/* v is a pure function */ |
v = loadpfins(s); |
v = loadpfins(s); |
else |
else |
v = (V)load_convv(vindex); |
v = (V)load_convv(vindex); |
read_int(s,&n); |
read_int(s,(unsigned int *)&n); |
for ( dc0 = 0; n; n-- ) { |
for ( dc0 = 0; n; n-- ) { |
NEXTDC(dc0,dc); loadobj(s,(Obj *)&DEG(dc)); loadobj(s,(Obj *)&COEF(dc)); |
NEXTDC(dc0,dc); loadobj(s,(Obj *)&DEG(dc)); loadobj(s,(Obj *)&COEF(dc)); |
} |
} |
Line 320 V loadpfins(FILE *s) |
|
Line 320 V loadpfins(FILE *s) |
|
P u; |
P u; |
|
|
loadstr(s,&name); |
loadstr(s,&name); |
read_int(s,&argc); |
read_int(s,(unsigned int *)&argc); |
searchpf(name,&fp); |
searchpf(name,&fp); |
if ( fp ) { |
if ( fp ) { |
pf = fp->f.puref; |
pf = fp->f.puref; |
Line 341 V loadpfins(FILE *s) |
|
Line 341 V loadpfins(FILE *s) |
|
} |
} |
darray = (int *)ALLOCA(argc*sizeof(int)); |
darray = (int *)ALLOCA(argc*sizeof(int)); |
args = (Obj *)ALLOCA(argc*sizeof(int)); |
args = (Obj *)ALLOCA(argc*sizeof(int)); |
read_intarray(s,darray,argc); |
read_intarray(s,(unsigned int *)darray,argc); |
for ( i = 0; i < argc; i++ ) |
for ( i = 0; i < argc; i++ ) |
loadobj(s,&args[i]); |
loadobj(s,&args[i]); |
_mkpfins_with_darray(pf,args,darray,&v); |
_mkpfins_with_darray(pf,args,darray,&v); |
Line 352 void loadr(FILE *s,R *p) |
|
Line 352 void loadr(FILE *s,R *p) |
|
{ |
{ |
R r; |
R r; |
|
|
NEWR(r); read_short(s,&r->reduced); |
NEWR(r); read_short(s,(unsigned short *)&r->reduced); |
loadobj(s,(Obj *)&NM(r)); loadobj(s,(Obj *)&DN(r)); *p = r; |
loadobj(s,(Obj *)&NM(r)); loadobj(s,(Obj *)&DN(r)); *p = r; |
} |
} |
|
|
Line 361 void loadlist(FILE *s,LIST *p) |
|
Line 361 void loadlist(FILE *s,LIST *p) |
|
int n; |
int n; |
NODE tn,tn0; |
NODE tn,tn0; |
|
|
read_int(s,&n); |
read_int(s,(unsigned int *)&n); |
for ( tn0 = 0; n; n-- ) { |
for ( tn0 = 0; n; n-- ) { |
NEXTNODE(tn0,tn); loadobj(s,(Obj *)&BDY(tn)); |
NEXTNODE(tn0,tn); loadobj(s,(Obj *)&BDY(tn)); |
} |
} |
Line 375 void loadvect(FILE *s,VECT *p) |
|
Line 375 void loadvect(FILE *s,VECT *p) |
|
int i,len; |
int i,len; |
VECT vect; |
VECT vect; |
|
|
read_int(s,&len); MKVECT(vect,len); |
read_int(s,(unsigned int *)&len); MKVECT(vect,len); |
for ( i = 0; i < len; i++ ) |
for ( i = 0; i < len; i++ ) |
loadobj(s,(Obj *)&BDY(vect)[i]); |
loadobj(s,(Obj *)&BDY(vect)[i]); |
*p = vect; |
*p = vect; |
Line 386 void loadmat(FILE *s,MAT *p) |
|
Line 386 void loadmat(FILE *s,MAT *p) |
|
int row,col,i,j; |
int row,col,i,j; |
MAT mat; |
MAT mat; |
|
|
read_int(s,&row); read_int(s,&col); MKMAT(mat,row,col); |
read_int(s,(unsigned int *)&row); read_int(s,(unsigned int *)&col); MKMAT(mat,row,col); |
for ( i = 0; i < row; i++ ) |
for ( i = 0; i < row; i++ ) |
for ( j = 0; j < col; j++ ) |
for ( j = 0; j < col; j++ ) |
loadobj(s,(Obj *)&BDY(mat)[i][j]); |
loadobj(s,(Obj *)&BDY(mat)[i][j]); |
Line 405 void loadstr(FILE *s,char **p) |
|
Line 405 void loadstr(FILE *s,char **p) |
|
int len; |
int len; |
char *t; |
char *t; |
|
|
read_int(s,&len); |
read_int(s,(unsigned int *)&len); |
if ( len ) { |
if ( len ) { |
t = (char *)MALLOC(len+1); read_string(s,t,len); t[len] = 0; |
t = (char *)MALLOC(len+1); read_string(s,(unsigned char *)t,len); t[len] = 0; |
} else |
} else |
t = ""; |
t = ""; |
*p = t; |
*p = t; |
Line 418 void loadbytearray(FILE *s,BYTEARRAY *p) |
|
Line 418 void loadbytearray(FILE *s,BYTEARRAY *p) |
|
int len; |
int len; |
BYTEARRAY array; |
BYTEARRAY array; |
|
|
read_int(s,&len); |
read_int(s,(unsigned int *)&len); |
MKBYTEARRAY(array,len); |
MKBYTEARRAY(array,len); |
if ( len ) { |
if ( len ) { |
read_string(s,array->body,len); |
read_string(s,array->body,len); |
Line 433 void loaddp(FILE *s,DP *p) |
|
Line 433 void loaddp(FILE *s,DP *p) |
|
MP m,m0; |
MP m,m0; |
DL dl; |
DL dl; |
|
|
read_int(s,&nv); read_int(s,&sugar); read_int(s,&n); |
read_int(s,(unsigned int *)&nv); read_int(s,(unsigned int *)&sugar); read_int(s,(unsigned int *)&n); |
for ( i = 0, m0 = 0; i < n; i++ ) { |
for ( i = 0, m0 = 0; i < n; i++ ) { |
NEXTMP(m0,m); |
NEXTMP(m0,m); |
loadobj(s,(Obj *)&(m->c)); |
loadobj(s,(Obj *)&(m->c)); |
NEWDL(dl,nv); m->dl = dl; |
NEWDL(dl,nv); m->dl = dl; |
read_int(s,&dl->td); read_intarray(s,&(dl->d[0]),nv); |
read_int(s,(unsigned int *)&dl->td); read_intarray(s,(unsigned int *)&(dl->d[0]),nv); |
} |
} |
NEXT(m) = 0; MKDP(nv,m0,dp); dp->sugar = sugar; *p = dp; |
NEXT(m) = 0; MKDP(nv,m0,dp); dp->sugar = sugar; *p = dp; |
} |
} |
Line 450 void loaddpm(FILE *s,DPM *p) |
|
Line 450 void loaddpm(FILE *s,DPM *p) |
|
DMM m,m0; |
DMM m,m0; |
DL dl; |
DL dl; |
|
|
read_int(s,&nv); read_int(s,&sugar); read_int(s,&n); |
read_int(s,(unsigned int *)&nv); read_int(s,(unsigned int *)&sugar); read_int(s,(unsigned int *)&n); |
for ( i = 0, m0 = 0; i < n; i++ ) { |
for ( i = 0, m0 = 0; i < n; i++ ) { |
NEXTDMM(m0,m); |
NEXTDMM(m0,m); |
loadobj(s,(Obj *)&(m->c)); |
loadobj(s,(Obj *)&(m->c)); |
read_int(s,&m->pos); |
read_int(s,(unsigned int *)&m->pos); |
NEWDL(dl,nv); m->dl = dl; |
NEWDL(dl,nv); m->dl = dl; |
read_int(s,&dl->td); read_intarray(s,&(dl->d[0]),nv); |
read_int(s,(unsigned int *)&dl->td); read_intarray(s,(unsigned int *)&(dl->d[0]),nv); |
} |
} |
NEXT(m) = 0; MKDPM(nv,m0,dp); dp->sugar = sugar; *p = dp; |
NEXT(m) = 0; MKDPM(nv,m0,dp); dp->sugar = sugar; *p = dp; |
} |
} |
Line 482 void loadgfmmat(FILE *s,GFMMAT *p) |
|
Line 482 void loadgfmmat(FILE *s,GFMMAT *p) |
|
unsigned int **a; |
unsigned int **a; |
GFMMAT mat; |
GFMMAT mat; |
|
|
read_int(s,&row); read_int(s,&col); |
read_int(s,(unsigned int *)&row); read_int(s,(unsigned int *)&col); |
a = (unsigned int **)almat(row,col); |
a = (unsigned int **)almat(row,col); |
TOGFMMAT(row,col,a,mat); |
TOGFMMAT(row,col,a,mat); |
for ( i = 0; i < row; i++ ) |
for ( i = 0; i < row; i++ ) |
Line 496 void loadnbp(FILE *s,NBP *p) |
|
Line 496 void loadnbp(FILE *s,NBP *p) |
|
NBM m; |
NBM m; |
NODE r0,r; |
NODE r0,r; |
|
|
read_int(s,&n); |
read_int(s,(unsigned int *)&n); |
for ( i = 0, r0 = 0; i < n; i++ ) { |
for ( i = 0, r0 = 0; i < n; i++ ) { |
NEWNBM(m); |
NEWNBM(m); |
loadobj(s,(Obj *)&m->c); |
loadobj(s,(Obj *)&m->c); |
read_int(s,&m->d); |
read_int(s,(unsigned int *)&m->d); |
NEWNBMBDY(m,m->d); read_intarray(s,m->b,(m->d+31)/32); |
NEWNBMBDY(m,m->d); read_intarray(s,(unsigned int *)m->b,(m->d+31)/32); |
NEXTNODE(r0,r); BDY(r) = (pointer)m; |
NEXTNODE(r0,r); BDY(r) = (pointer)m; |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |