version 1.22, 2002/12/27 07:37:57 |
version 1.25, 2003/01/18 02:38:56 |
|
|
* 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/builtin/dp-supp.c,v 1.21 2002/01/28 00:54:41 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/dp-supp.c,v 1.24 2003/01/15 04:53:03 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
Line 387 int have_sf_coef(P p) |
|
Line 387 int have_sf_coef(P p) |
|
} |
} |
} |
} |
|
|
|
void head_coef(P p,Num *c) |
|
{ |
|
if ( !p ) |
|
*c = 0; |
|
else if ( NUM(p) ) |
|
*c = (Num)p; |
|
else |
|
head_coef(COEF(DC(p)),c); |
|
} |
|
|
|
void dp_monic_sf(DP p,DP *rp) |
|
{ |
|
Num c; |
|
|
|
if ( !p ) |
|
*rp = 0; |
|
else { |
|
head_coef(BDY(p)->c,&c); |
|
divsdc(CO,p,(P)c,rp); |
|
} |
|
} |
|
|
void dp_prim(DP p,DP *rp) |
void dp_prim(DP p,DP *rp) |
{ |
{ |
P t,g; |
P t,g; |
Line 399 void dp_prim(DP p,DP *rp) |
|
Line 421 void dp_prim(DP p,DP *rp) |
|
|
|
if ( !p ) |
if ( !p ) |
*rp = 0; |
*rp = 0; |
else if ( dp_fcoeffs ) { |
else if ( dp_fcoeffs == N_GFS ) { |
for ( m = BDY(p); m; m = NEXT(m) ) { |
for ( m = BDY(p); m; m = NEXT(m) ) |
if ( OID(m->c) == O_N ) { |
if ( OID(m->c) == O_N ) { |
/* GCD of coeffs = 1 */ |
/* GCD of coeffs = 1 */ |
*rp = p; |
dp_monic_sf(p,rp); |
return; |
return; |
} else if ( have_sf_coef(m->c) ) { |
} else break; |
/* compute GCD over the finite fieid */ |
/* compute GCD over the finite fieid */ |
for ( m = BDY(p), n = 0; m; m = NEXT(m), n++ ); |
for ( m = BDY(p), n = 0; m; m = NEXT(m), n++ ); |
w = (P *)ALLOCA(n*sizeof(P)); |
w = (P *)ALLOCA(n*sizeof(P)); |
for ( m = BDY(p), i = 0; i < n; m = NEXT(m), i++ ) |
for ( m = BDY(p), i = 0; i < n; m = NEXT(m), i++ ) |
w[i] = m->c; |
w[i] = m->c; |
gcdsf(CO,w,n,&g); |
gcdsf(CO,w,n,&g); |
if ( NUM(g) ) |
if ( NUM(g) ) |
*rp = p; |
dp_monic_sf(p,rp); |
else { |
else { |
for ( mr0 = 0, m = BDY(p); m; m = NEXT(m) ) { |
for ( mr0 = 0, m = BDY(p); m; m = NEXT(m) ) { |
NEXTMP(mr0,mr); divsp(CO,m->c,g,&mr->c); mr->dl = m->dl; |
NEXTMP(mr0,mr); divsp(CO,m->c,g,&mr->c); mr->dl = m->dl; |
} |
|
NEXT(mr) = 0; MKDP(p->nv,mr0,*rp); (*rp)->sugar = p->sugar; |
|
} |
|
return; |
|
} |
} |
|
NEXT(mr) = 0; MKDP(p->nv,mr0,p1); p1->sugar = p->sugar; |
|
dp_monic_sf(p1,rp); |
} |
} |
/* all coeffs are poly over Q */ |
return; |
|
} else if ( dp_fcoeffs ) |
*rp = p; |
*rp = p; |
} else if ( NoGCD ) |
else if ( NoGCD ) |
dp_ptozp(p,rp); |
dp_ptozp(p,rp); |
else { |
else { |
dp_ptozp(p,&p1); p = p1; |
dp_ptozp(p,&p1); p = p1; |
Line 728 void dp_red(DP p0,DP p1,DP p2,DP *head,DP *rest,P *dnp |
|
Line 749 void dp_red(DP p0,DP p1,DP p2,DP *head,DP *rest,P *dnp |
|
Q c,c1,c2; |
Q c,c1,c2; |
N gn,tn; |
N gn,tn; |
P g,a; |
P g,a; |
|
P p[2]; |
|
|
n = p1->nv; d1 = BDY(p1)->dl; d2 = BDY(p2)->dl; |
n = p1->nv; d1 = BDY(p1)->dl; d2 = BDY(p2)->dl; |
NEWDL(d,n); d->td = d1->td - d2->td; |
NEWDL(d,n); d->td = d1->td - d2->td; |
for ( i = 0; i < n; i++ ) |
for ( i = 0; i < n; i++ ) |
d->d[i] = d1->d[i]-d2->d[i]; |
d->d[i] = d1->d[i]-d2->d[i]; |
c1 = (Q)BDY(p1)->c; c2 = (Q)BDY(p2)->c; |
c1 = (Q)BDY(p1)->c; c2 = (Q)BDY(p2)->c; |
if ( dp_fcoeffs ) { |
if ( dp_fcoeffs == N_GFS ) { |
|
p[0] = (P)c1; p[1] = (P)c2; |
|
gcdsf(CO,p,2,&g); |
|
divsp(CO,(P)c1,g,&a); c1 = (Q)a; divsp(CO,(P)c2,g,&a); c2 = (Q)a; |
|
} else if ( dp_fcoeffs ) { |
/* do nothing */ |
/* do nothing */ |
} else if ( INT(c1) && INT(c2) ) { |
} else if ( INT(c1) && INT(c2) ) { |
gcdn(NM(c1),NM(c2),&gn); |
gcdn(NM(c1),NM(c2),&gn); |
Line 1258 void dp_nf_tab_mod(DP p,LIST *tab,int mod,DP *rp) |
|
Line 1284 void dp_nf_tab_mod(DP p,LIST *tab,int mod,DP *rp) |
|
i++; |
i++; |
mulmdc(CO,mod,(DP)BDY(NEXT(BDY(tab[i]))),m->c,&t); |
mulmdc(CO,mod,(DP)BDY(NEXT(BDY(tab[i]))),m->c,&t); |
addmd(CO,mod,s,t,&u); s = u; |
addmd(CO,mod,s,t,&u); s = u; |
|
} |
|
*rp = s; |
|
} |
|
|
|
void dp_nf_tab_f(DP p,LIST *tab,DP *rp) |
|
{ |
|
DP s,t,u; |
|
MP m; |
|
DL h; |
|
int i,n; |
|
|
|
if ( !p ) { |
|
*rp = p; return; |
|
} |
|
n = p->nv; |
|
for ( s = 0, i = 0, m = BDY(p); m; m = NEXT(m) ) { |
|
h = m->dl; |
|
while ( !dl_equal(n,h,BDY((DP)BDY(BDY(tab[i])))->dl ) ) |
|
i++; |
|
muldc(CO,(DP)BDY(NEXT(BDY(tab[i]))),m->c,&t); |
|
addd(CO,s,t,&u); s = u; |
} |
} |
*rp = s; |
*rp = s; |
} |
} |