version 1.23, 2004/07/13 07:59:54 |
version 1.28, 2017/08/31 02:36:21 |
|
|
* 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/cpexpr.c,v 1.22 2004/05/14 06:02:54 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/io/cpexpr.c,v 1.27 2015/08/04 06:20:45 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
#include "al.h" |
#include "al.h" |
#include "base.h" |
#include "base.h" |
#if PARI |
|
#include "genpari.h" |
|
#endif |
|
|
|
#ifndef CPRINT |
#ifndef CPRINT |
#define CPRINT |
#define CPRINT |
Line 80 static int total_length; |
|
Line 77 static int total_length; |
|
#define PRINTSTR length_str |
#define PRINTSTR length_str |
#define PRINTCOMP length_comp |
#define PRINTCOMP length_comp |
#define PRINTDP length_dp |
#define PRINTDP length_dp |
|
#define PRINTDPM length_dpm |
#define PRINTUI length_ui |
#define PRINTUI length_ui |
#define PRINTGF2MAT length_gf2mat |
#define PRINTGF2MAT length_gf2mat |
#define PRINTGFMMAT length_gfmmat |
#define PRINTGFMMAT length_gfmmat |
Line 90 static int total_length; |
|
Line 88 static int total_length; |
|
#define PRINTRANGE length_RANGE |
#define PRINTRANGE length_RANGE |
#define PRINTTB length_TB |
#define PRINTTB length_TB |
#define PRINTDPV length_DPV |
#define PRINTDPV length_DPV |
|
#define PRINTNBP length_nbp |
#define PRINTERR length_err |
#define PRINTERR length_err |
#define PRINTLF length_lf |
#define PRINTLF length_lf |
#define PRINTLOP length_lop |
#define PRINTLOP length_lop |
Line 116 int estimate_length(VL vl,pointer p) |
|
Line 115 int estimate_length(VL vl,pointer p) |
|
return total_length; |
return total_length; |
} |
} |
|
|
#if defined(PARI) |
|
void PRINTBF(BF a) |
void PRINTBF(BF a) |
{ |
{ |
char *str; |
char *str; |
char *GENtostr0(); |
int dprec; |
void myoutbrute(); |
char fbuf[BUFSIZ]; |
|
|
if ( double_output ) { |
dprec = a->body->_mpfr_prec*0.30103; |
str = GENtostr0(a->body,myoutbrute); |
sprintf(fbuf,"%%.%dR%c",dprec,double_output?'f':'g'); |
} else { |
mpfr_asprintf(&str,fbuf,a->body); |
str = GENtostr(a->body); |
|
} |
|
total_length += strlen(str); |
total_length += strlen(str); |
free(str); |
mpfr_free_str(str); |
} |
} |
#endif |
|
|
|
void PRINTNUM(Num q) |
void PRINTNUM(Num q) |
{ |
{ |
|
DAlg d; |
|
DP nm; |
|
Q dn; |
|
|
if ( !q ) { |
if ( !q ) { |
PUTS("0"); |
PUTS("0"); |
return; |
return; |
Line 157 void PRINTNUM(Num q) |
|
Line 156 void PRINTNUM(Num q) |
|
case N_A: |
case N_A: |
PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")"); |
PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")"); |
break; |
break; |
#if defined(PARI) |
|
case N_B: |
case N_B: |
PRINTBF((BF)q); break; |
PRINTBF((BF)q); break; |
#endif |
|
case N_C: |
case N_C: |
PRINTCPLX((C)q); break; |
PRINTCPLX((C)q); break; |
case N_M: |
case N_M: |
Line 183 void PRINTNUM(Num q) |
|
Line 180 void PRINTNUM(Num q) |
|
case N_GFSN: |
case N_GFSN: |
PRINTUM(BDY((GFSN)q)); |
PRINTUM(BDY((GFSN)q)); |
break; |
break; |
|
case N_DA: |
|
d = (DAlg)q; |
|
nm = d->nm; |
|
dn = d->dn; |
|
if ( SGN((Q)dn) == -1 ) PUTS("-"); |
|
PUTS("("); |
|
PRINTDP(CO,((DAlg)q)->nm); |
|
PUTS(")"); |
|
if ( !UNIN(NM(dn)) ) { |
|
PUTS("/"); |
|
PRINTN(NM(dn)); |
|
} |
|
break; |
default: |
default: |
break; |
break; |
} |
} |
Line 286 void PRINTDP(VL vl,DP d) |
|
Line 296 void PRINTDP(VL vl,DP d) |
|
} |
} |
} |
} |
|
|
|
void PRINTDPM(VL vl,DPM d) |
|
{ |
|
int n,i; |
|
DMM m; |
|
DL dl; |
|
|
|
for ( n = d->nv, m = BDY(d); m; m = NEXT(m) ) { |
|
PUTS("("); PRINTEXPR(vl,(pointer)m->c); PUTS(")*<<"); |
|
for ( i = 0, dl = m->dl; i < n-1; i++ ) { |
|
total_length += 11; |
|
} |
|
total_length += 10; |
|
total_length += 11; /* for ':pos' */ |
|
PUTS(">>"); |
|
if ( NEXT(m) ) |
|
PUTS("+"); |
|
} |
|
} |
|
|
|
|
void PRINTUI(VL vl,USINT u) |
void PRINTUI(VL vl,USINT u) |
{ |
{ |
total_length += 10; |
total_length += 10; |
Line 460 void PRINTUM(UM n) |
|
Line 490 void PRINTUM(UM n) |
|
} |
} |
} |
} |
PUTS(")"); |
PUTS(")"); |
|
} |
|
} |
|
|
|
void PRINTNBP(VL vl,NBP p) |
|
{ |
|
NODE t; |
|
NBM m; |
|
int d,i; |
|
unsigned int *b; |
|
if ( !p ) PUTS("0"); |
|
else { |
|
for ( t = BDY(p); t; t = NEXT(t) ) { |
|
m = (NBM)BDY(t); |
|
PRINTEXPR(vl,(Obj)m->c); |
|
d = m->d; |
|
b = m->b; |
|
if ( d ) |
|
for ( i = 0; i < d; i++ ) { |
|
if ( NBM_GET(b,i) ) PUTS("x"); |
|
else PUTS("y"); |
|
} |
|
else PUTS("1"); |
|
if ( NEXT(t) ) PUTS("+"); |
|
} |
} |
} |
} |
} |
|
|