version 1.6, 2000/07/13 05:09:00 |
version 1.8, 2000/08/21 08:31:19 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/builtin/gr.c,v 1.5 2000/05/29 08:54:45 noro Exp $ */ |
/* |
|
* Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED |
|
* All rights reserved. |
|
* |
|
* FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited, |
|
* non-exclusive and royalty-free license to use, copy, modify and |
|
* redistribute, solely for non-commercial and non-profit purposes, the |
|
* computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and |
|
* conditions of this Agreement. For the avoidance of doubt, you acquire |
|
* only a limited right to use the SOFTWARE hereunder, and FLL or any |
|
* third party developer retains all rights, including but not limited to |
|
* copyrights, in and to the SOFTWARE. |
|
* |
|
* (1) FLL does not grant you a license in any way for commercial |
|
* purposes. You may use the SOFTWARE only for non-commercial and |
|
* non-profit purposes only, such as academic, research and internal |
|
* business use. |
|
* (2) The SOFTWARE is protected by the Copyright Law of Japan and |
|
* international copyright treaties. If you make copies of the SOFTWARE, |
|
* with or without modification, as permitted hereunder, you shall affix |
|
* to all such copies of the SOFTWARE the above copyright notice. |
|
* (3) An explicit reference to this SOFTWARE and its copyright owner |
|
* shall be made on your publication or presentation in any form of the |
|
* results obtained by use of the SOFTWARE. |
|
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
|
* e-mail at risa-admin@flab.fujitsu.co.jp of the detailed specification |
|
* for such modification or the source code of the modified part of the |
|
* SOFTWARE. |
|
* |
|
* THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL |
|
* MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND |
|
* EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS |
|
* FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES' |
|
* RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY |
|
* MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY. |
|
* UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, |
|
* OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY |
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL |
|
* DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES |
|
* ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES |
|
* FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY |
|
* DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF |
|
* SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART |
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
|
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
|
* |
|
* $OpenXM: OpenXM_contrib2/asir2000/builtin/gr.c,v 1.7 2000/07/14 08:26:39 noro Exp $ |
|
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
#include "base.h" |
#include "base.h" |
Line 42 void print_stat(void); |
|
Line 90 void print_stat(void); |
|
void init_stat(void); |
void init_stat(void); |
int dp_load_t(int,DP *); |
int dp_load_t(int,DP *); |
void dp_load(int,DP *); |
void dp_load(int,DP *); |
void dp_save(int,DP); |
void dp_save(int,Obj,char *); |
void dp_make_flaglist(LIST *); |
void dp_make_flaglist(LIST *); |
void dp_set_flag(Obj,Obj); |
void dp_set_flag(Obj,Obj); |
int membercheck(NODE,NODE); |
int membercheck(NODE,NODE); |
Line 127 static char *Demand = 0; |
|
Line 175 static char *Demand = 0; |
|
static int PtozpRA = 0; |
static int PtozpRA = 0; |
LIST Dist = 0; |
LIST Dist = 0; |
int NoGCD = 0; |
int NoGCD = 0; |
|
int GenTrace = 0; |
|
int OXCheck = -1; |
int doing_f4; |
int doing_f4; |
|
NODE TraceList; |
|
|
void Pdp_gr_flags(arg,rp) |
void Pdp_gr_flags(arg,rp) |
NODE arg; |
NODE arg; |
|
|
int m; |
int m; |
{ |
{ |
int i; |
int i; |
NODE s,s0; |
NODE s,s0,f0; |
|
|
f = NODE_sortb(f,1); |
f0 = f = NODE_sortb(f,1); |
psn = length(f); pslen = 2*psn; |
psn = length(f); pslen = 2*psn; |
ps = (DP *)MALLOC(pslen*sizeof(DP)); |
ps = (DP *)MALLOC(pslen*sizeof(DP)); |
psh = (DL *)MALLOC(pslen*sizeof(DL)); |
psh = (DL *)MALLOC(pslen*sizeof(DL)); |
|
|
for ( i = 0; i < psn; i++, f = NEXT(f) ) { |
for ( i = 0; i < psn; i++, f = NEXT(f) ) { |
prim_part((DP)BDY(f),m,&ps[i]); |
prim_part((DP)BDY(f),m,&ps[i]); |
if ( Demand ) |
if ( Demand ) |
dp_save(i,ps[i]); |
dp_save(i,(Obj)ps[i],0); |
psh[i] = BDY(ps[i])->dl; |
psh[i] = BDY(ps[i])->dl; |
pss[i] = ps[i]->sugar; |
pss[i] = ps[i]->sugar; |
psc[i] = BDY(ps[i])->c; |
psc[i] = BDY(ps[i])->c; |
} |
} |
|
if ( GenTrace && (OXCheck >= 0) ) { |
|
Q q; |
|
STRING fname; |
|
LIST input; |
|
NODE arg; |
|
Obj dmy; |
|
|
|
STOQ(OXCheck,q); |
|
MKSTR(fname,"register_input"); |
|
MKLIST(input,f0); |
|
arg = mknode(3,q,fname,input); |
|
Pox_cmo_rpc(arg,&dmy); |
|
} |
for ( s0 = 0, i = 0; i < psn; i++ ) { |
for ( s0 = 0, i = 0; i < psn; i++ ) { |
NEXTNODE(s0,s); BDY(s) = (pointer)i; |
NEXTNODE(s0,s); BDY(s) = (pointer)i; |
} |
} |
Line 983 void prim_part(f,m,r) |
|
Line 1047 void prim_part(f,m,r) |
|
DP f,*r; |
DP f,*r; |
int m; |
int m; |
{ |
{ |
|
P d,t; |
|
|
if ( m > 0 ) { |
if ( m > 0 ) { |
if ( PCoeffs ) |
if ( PCoeffs ) |
dp_prim_mod(f,m,r); |
dp_prim_mod(f,m,r); |
|
|
dp_prim(f,r); |
dp_prim(f,r); |
else |
else |
dp_ptozp(f,r); |
dp_ptozp(f,r); |
|
if ( GenTrace && TraceList ) { |
|
divsp(CO,BDY(f)->c,BDY(*r)->c,&d); |
|
mulp(CO,(P)ARG3(BDY((LIST)BDY(TraceList))),d,&t); |
|
ARG3(BDY((LIST)BDY(TraceList))) = t; |
|
} |
} |
} |
} |
} |
|
|
|
|
} |
} |
get_eg(&tmp0); |
get_eg(&tmp0); |
dp_load(w[i],&ps[w[i]]); |
dp_load(w[i],&ps[w[i]]); |
_dp_nf(top,ps[w[i]],ps,1,&g); |
|
|
|
|
if ( GenTrace ) { |
|
Q q; |
|
NODE node; |
|
LIST hist; |
|
|
|
STOQ(w[i],q); |
|
node = mknode(4,ONE,q,ONE,ONE); |
|
MKLIST(hist,node); |
|
MKNODE(TraceList,hist,0); |
|
} |
if ( !PtozpRA || !Multiple ) |
if ( !PtozpRA || !Multiple ) |
_dp_nf(top,ps[w[i]],ps,1,&g); |
_dp_nf(top,ps[w[i]],ps,1,&g); |
else |
else |
|
|
ps[psn] = a; |
ps[psn] = a; |
else |
else |
ps[psn] = 0; |
ps[psn] = 0; |
dp_save(psn,a); |
dp_save(psn,(Obj)a,0); |
} else |
} else |
ps[psn] = a; |
ps[psn] = a; |
psh[psn] = BDY(a)->dl; |
psh[psn] = BDY(a)->dl; |
|
|
psc[psn] = BDY(a)->c; |
psc[psn] = BDY(a)->c; |
if ( m ) |
if ( m ) |
_dp_mod(a,m,subst,&psm[psn]); |
_dp_mod(a,m,subst,&psm[psn]); |
|
if ( GenTrace ) { |
|
NODE tn,tr,tr1; |
|
LIST trace; |
|
|
|
/* reverse the TraceList */ |
|
tn = TraceList; |
|
for ( tr = 0; tn; tn = NEXT(tn) ) { |
|
MKNODE(tr1,BDY(tn),tr); tr = tr1; |
|
} |
|
MKLIST(trace,tr); |
|
if ( OXCheck >= 0 ) { |
|
NODE arg; |
|
Q q1,q2; |
|
STRING fname; |
|
Obj dmy; |
|
|
|
STOQ(OXCheck,q1); |
|
MKSTR(fname,"check_trace"); |
|
STOQ(psn,q2); |
|
arg = mknode(5,q1,fname,a,q2,trace); |
|
Pox_cmo_rpc(arg,&dmy); |
|
} else |
|
dp_save(psn,(Obj)trace,"t"); |
|
TraceList = 0; |
|
} |
return psn++; |
return psn++; |
} |
} |
|
|
|
|
} |
} |
for ( top = 0, i = n-1; i >= 0; i-- ) |
for ( top = 0, i = n-1; i >= 0; i-- ) |
if ( r[i] >= 0 ) { |
if ( r[i] >= 0 ) { |
dp_load(r[i],&ps[r[i]]); dp_dehomo(ps[r[i]],&u); j = newps(u,0,0); |
dp_load(r[i],&ps[r[i]]); dp_dehomo(ps[r[i]],&u); |
|
if ( GenTrace ) { |
|
Q q; |
|
LIST hist; |
|
NODE node; |
|
|
|
STOQ(r[i],q); |
|
node = mknode(4,0,q,0,0); |
|
MKLIST(hist,node); |
|
MKNODE(TraceList,hist,0); |
|
} |
|
j = newps(u,0,0); |
MKNODE(t,j,top); top = t; |
MKNODE(t,j,top); top = t; |
} |
} |
*g = top; |
*g = top; |
|
|
struct oEGT tnf0,tnf1,tnfm0,tnfm1,tpz0,tpz1,tsp0,tsp1,tspm0,tspm1,tnp0,tnp1,tmp0,tmp1; |
struct oEGT tnf0,tnf1,tnfm0,tnfm1,tpz0,tpz1,tsp0,tsp1,tspm0,tspm1,tnp0,tnp1,tmp0,tmp1; |
int skip_nf_flag; |
int skip_nf_flag; |
double t_0; |
double t_0; |
|
Q q; |
int new_sugar; |
int new_sugar; |
static prev_sugar = -1; |
static prev_sugar = -1; |
|
|
|
|
} |
} |
} else |
} else |
dp_sp(ps[l->dp1],ps[l->dp2],&h); |
dp_sp(ps[l->dp1],ps[l->dp2],&h); |
|
if ( GenTrace ) { |
|
STOQ(l->dp1,q); ARG1(BDY((LIST)BDY(NEXT(TraceList)))) = q; |
|
STOQ(l->dp2,q); ARG1(BDY((LIST)BDY(TraceList))) = q; |
|
} |
new_sugar = h->sugar; |
new_sugar = h->sugar; |
get_eg(&tsp1); add_eg(&eg_sp,&tsp0,&tsp1); |
get_eg(&tsp1); add_eg(&eg_sp,&tsp0,&tsp1); |
get_eg(&tnf0); |
get_eg(&tnf0); |
|
|
int full; |
int full; |
DP *rp; |
DP *rp; |
{ |
{ |
DP u,p,d,s,t; |
DP u,p,d,s,t,mult; |
P dmy; |
P coef; |
NODE l; |
NODE l; |
MP m,mr; |
MP m,mr; |
int sugar,psugar; |
int sugar,psugar; |
|
|
for ( u = 0, l = b; l; l = NEXT(l) ) { |
for ( u = 0, l = b; l; l = NEXT(l) ) { |
if ( dl_redble(BDY(g)->dl,psh[(int)BDY(l)]) ) { |
if ( dl_redble(BDY(g)->dl,psh[(int)BDY(l)]) ) { |
dp_load((int)BDY(l),&p); |
dp_load((int)BDY(l),&p); |
dp_red(d,g,p,&t,&u,&dmy); |
/* t+u = coef*(d+g) - mult*p (t = coef*d) */ |
|
dp_red(d,g,p,&t,&u,&coef,&mult); |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
sugar = MAX(sugar,psugar); |
sugar = MAX(sugar,psugar); |
|
if ( GenTrace ) { |
|
LIST hist; |
|
Q cq; |
|
NODE node,node0; |
|
|
|
STOQ((int)BDY(l),cq); |
|
node0 = mknode(4,coef,cq,mult,ONE); |
|
MKLIST(hist,node0); |
|
MKNODE(node,hist,TraceList); TraceList = node; |
|
} |
if ( !u ) { |
if ( !u ) { |
if ( d ) |
if ( d ) |
d->sugar = sugar; |
d->sugar = sugar; |
|
|
|
|
double pz_t_e, pz_t_d, pz_t_d1, pz_t_c, im_t_s, im_t_r; |
double pz_t_e, pz_t_d, pz_t_d1, pz_t_c, im_t_s, im_t_r; |
|
|
|
extern int GenTrace; |
|
extern NODE TraceList; |
|
|
void _dp_nf_ptozp(b,g,ps,full,multiple,r) |
void _dp_nf_ptozp(b,g,ps,full,multiple,r) |
NODE b; |
NODE b; |
DP g; |
DP g; |
|
|
extern int kara_mag; |
extern int kara_mag; |
double get_rtime(); |
double get_rtime(); |
double t_0,t_00,tt,ttt,t_p,t_m,t_m1,t_m2,t_s,t_g,t_a; |
double t_0,t_00,tt,ttt,t_p,t_m,t_m1,t_m2,t_s,t_g,t_a; |
|
LIST hist; |
|
NODE node; |
|
Q rcred,mrcred; |
|
|
if ( !g ) { |
if ( !g ) { |
*r = 0; return; |
*r = 0; return; |
|
|
dc = 0; dp = 0; rc = ONE; rp = g; |
dc = 0; dp = 0; rc = ONE; rp = g; |
MKSTR(imul,"dp_imul_index"); |
MKSTR(imul,"dp_imul_index"); |
|
|
|
/* g = dc*dp+rc*rp */ |
for ( ; rp; ) { |
for ( ; rp; ) { |
for ( u = 0, l = b; l; l = NEXT(l) ) { |
for ( u = 0, l = b; l; l = NEXT(l) ) { |
if ( dl_redble(BDY(rp)->dl,psh[(int)BDY(l)]) ) { |
if ( dl_redble(BDY(rp)->dl,psh[(int)BDY(l)]) ) { |
|
|
|
|
psugar = (BDY(rp)->dl->td - BDY(red)->dl->td) + red->sugar; |
psugar = (BDY(rp)->dl->td - BDY(red)->dl->td) + red->sugar; |
sugar = MAX(sugar,psugar); |
sugar = MAX(sugar,psugar); |
|
if ( GenTrace ) { |
|
/* u = cr*rp + (-cred)*shift*red */ |
|
STOQ((int)BDY(l),cq); |
|
node = mknode(4,cr,cq,0,0); |
|
mulq(cred,rc,&rcred); |
|
chsgnnum((Num)rcred,(Num *)&mrcred); |
|
muldc(CO,shift,(P)mrcred,(DP *)&ARG2(node)); |
|
MKLIST(hist,node); |
|
} |
if ( !u ) { |
if ( !u ) { |
if ( dp ) |
if ( dp ) |
dp->sugar = sugar; |
dp->sugar = sugar; |
*r = dp; |
*r = dp; |
|
if ( GenTrace ) { |
|
ARG3(BDY(hist)) = ONE; |
|
MKNODE(node,hist,TraceList); TraceList = node; |
|
} |
goto final; |
goto final; |
} |
} |
break; |
break; |
|
|
tt = get_rtime()-t_0; t_a += tt; |
tt = get_rtime()-t_0; t_a += tt; |
rp = t; |
rp = t; |
hmag = multiple*HMAG(rp)/denom; |
hmag = multiple*HMAG(rp)/denom; |
|
if ( GenTrace ) { |
|
NTOQ(gn,1,gcd); |
|
ARG3(BDY(hist)) = (pointer)gcd; |
|
MKNODE(node,hist,TraceList); TraceList = node; |
|
} |
} else { |
} else { |
t_0 = get_rtime(); |
t_0 = get_rtime(); |
mulq(cr,dc,&dcq); dc = dcq; |
mulq(cr,dc,&dcq); dc = dcq; |
tt = get_rtime()-t_0; t_a += tt; |
tt = get_rtime()-t_0; t_a += tt; |
rp = u; |
rp = u; |
|
if ( GenTrace ) { |
|
ARG3(BDY(hist)) = (pointer)ONE; |
|
MKNODE(node,hist,TraceList); TraceList = node; |
|
} |
} |
} |
} else if ( !full ) { |
} else if ( !full ) { |
if ( rp ) { |
if ( rp ) { |
|
|
tt = get_rtime()-t_0; t_a += tt; |
tt = get_rtime()-t_0; t_a += tt; |
} |
} |
} |
} |
|
if ( GenTrace ) { |
|
mulq(ARG3(BDY((LIST)BDY(TraceList))),dc,&cq); |
|
ARG3(BDY((LIST)BDY(TraceList))) = (pointer)cq; |
|
} |
if ( dp ) |
if ( dp ) |
dp->sugar = sugar; |
dp->sugar = sugar; |
*r = dp; |
*r = dp; |
Line 2549 Obj name,value; |
|
Line 2714 Obj name,value; |
|
Denominator = v; |
Denominator = v; |
else if ( !strcmp(n,"PtozpRA") ) |
else if ( !strcmp(n,"PtozpRA") ) |
PtozpRA = v; |
PtozpRA = v; |
|
else if ( !strcmp(n,"GenTrace") ) |
|
GenTrace = v; |
|
else if ( !strcmp(n,"OXCheck") ) |
|
OXCheck = v; |
} |
} |
|
|
void dp_make_flaglist(list) |
void dp_make_flaglist(list) |
|
|
STOQ(Reverse,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Reverse"); MKNODE(n1,name,n); n = n1; |
STOQ(Reverse,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Reverse"); MKNODE(n1,name,n); n = n1; |
STOQ(Stat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Stat"); MKNODE(n1,name,n); n = n1; |
STOQ(Stat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Stat"); MKNODE(n1,name,n); n = n1; |
STOQ(Print,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Print"); MKNODE(n1,name,n); n = n1; |
STOQ(Print,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Print"); MKNODE(n1,name,n); n = n1; |
|
STOQ(OXCheck,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"OXCheck"); MKNODE(n1,name,n); n = n1; |
|
STOQ(GenTrace,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"GenTrace"); MKNODE(n1,name,n); n = n1; |
STOQ(PtozpRA,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"PtozpRA"); MKNODE(n1,name,n); n = n1; |
STOQ(PtozpRA,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"PtozpRA"); MKNODE(n1,name,n); n = n1; |
STOQ(ShowMag,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"ShowMag"); MKNODE(n1,name,n); n = n1; |
STOQ(ShowMag,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"ShowMag"); MKNODE(n1,name,n); n = n1; |
STOQ(Top,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Top"); MKNODE(n1,name,n); n = n1; |
STOQ(Top,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Top"); MKNODE(n1,name,n); n = n1; |
|
|
#define DELIM ':' |
#define DELIM ':' |
#endif |
#endif |
|
|
void dp_save(index,p) |
void dp_save(index,p,prefix) |
int index; |
int index; |
DP p; |
Obj p; |
|
char *prefix; |
{ |
{ |
FILE *fp; |
FILE *fp; |
char path[BUFSIZ]; |
char path[BUFSIZ]; |
|
|
sprintf(path,"%s%c%d",Demand,DELIM,index); |
if ( prefix ) |
|
sprintf(path,"%s%c%s%d",Demand,DELIM,prefix,index); |
|
else |
|
sprintf(path,"%s%c%d",Demand,DELIM,index); |
#if defined(VISUAL) || defined(THINK_C) |
#if defined(VISUAL) || defined(THINK_C) |
if ( !(fp = fopen(path,"wb") ) ) |
if ( !(fp = fopen(path,"wb") ) ) |
#else |
#else |
if ( !(fp = fopen(path,"w") ) ) |
if ( !(fp = fopen(path,"w") ) ) |
#endif |
#endif |
error("dp_save : cannot open a file"); |
error("dp_save : cannot open a file"); |
savevl(fp,VC); saveobj(fp,(Obj)p); fclose(fp); |
savevl(fp,VC); saveobj(fp,p); fclose(fp); |
} |
} |
|
|
void dp_load(index,p) |
void dp_load(index,p) |
|
|
int full,multiple; |
int full,multiple; |
DP *rp; |
DP *rp; |
{ |
{ |
DP u,p,d,s,t,dmy; |
P dmy; |
|
DP u,p,d,s,t,dmy1; |
NODE l; |
NODE l; |
MP m,mr; |
MP m,mr; |
int i,n; |
int i,n; |
|
|
for ( u = 0, l = b; l; l = NEXT(l) ) { |
for ( u = 0, l = b; l; l = NEXT(l) ) { |
if ( dl_redble(BDY(g)->dl,psh[(int)BDY(l)]) ) { |
if ( dl_redble(BDY(g)->dl,psh[(int)BDY(l)]) ) { |
dp_load((int)BDY(l),&p); |
dp_load((int)BDY(l),&p); |
dp_red(d,g,p,&t,&u,&dmy); |
dp_red(d,g,p,&t,&u,&dmy,&dmy1); |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
sugar = MAX(sugar,psugar); |
sugar = MAX(sugar,psugar); |
if ( !u ) { |
if ( !u ) { |