version 1.3, 2000/08/22 05:03:57 |
version 1.4, 2000/12/05 01:24:49 |
|
|
* 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.2 2000/08/21 08:31:19 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/dp-supp.c,v 1.3 2000/08/22 05:03:57 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
|
|
} |
} |
} |
} |
|
|
#if INET |
|
void dp_ptozp_d_old(dist,ndist,p,rp) |
void dp_ptozp_d_old(dist,ndist,p,rp) |
NODE dist; |
NODE dist; |
int ndist; |
int ndist; |
|
|
r->sugar = p1->sugar; |
r->sugar = p1->sugar; |
*hp = h; *rp = r; |
*hp = h; *rp = r; |
} |
} |
#endif |
|
|
|
/* |
|
* Old codes |
|
*/ |
|
|
|
#if 0 |
|
void Pdp_sep(arg,rp) |
|
NODE arg; |
|
VECT *rp; |
|
{ |
|
DP p,s; |
|
MP m,t,mr,mr0; |
|
int i,j,n,d,r,q,q1,nv; |
|
VECT w; |
|
pointer *pw; |
|
|
|
p = (DP)ARG0(arg); m = BDY(p); |
|
d = QTOS((Q)ARG1(arg)); |
|
for ( t = m, n = 0; t; t = NEXT(t), n++ ); |
|
if ( d > n ) |
|
d = n; |
|
q = n/d; r = n%d; q1 = q+1; |
|
MKVECT(w,d); *rp = w; |
|
t = m; pw = BDY(w); nv = p->nv; |
|
for ( i = 0; i < r; i++ ) { |
|
for ( mr0 = 0, j = 0; j < q1; j++, t = NEXT(t) ) { |
|
NEXTMP(mr0,mr); |
|
mr->c = t->c; |
|
mr->dl = t->dl; |
|
} |
|
NEXT(mr) = 0; MKDP(nv,mr0,s); s->sugar = p->sugar; |
|
pw[i] = (pointer)s; |
|
} |
|
for ( ; i < d; i++ ) { |
|
for ( mr0 = 0, j = 0; j < q; j++, t = NEXT(t) ) { |
|
NEXTMP(mr0,mr); |
|
mr->c = t->c; |
|
mr->dl = t->dl; |
|
} |
|
NEXT(mr) = 0; MKDP(nv,mr0,s); s->sugar = p->sugar; |
|
pw[i] = (pointer)s; |
|
} |
|
} |
|
|
|
void dp_ptozp_mpi(dist,ndist,p,rp) |
|
NODE dist; |
|
int ndist; |
|
DP p,*rp; |
|
{ |
|
int i,j,k,l,n,nsep; |
|
MP m; |
|
NODE tn,n0,n1,n2,n3; |
|
struct oVECT v; |
|
VECT c,cs; |
|
VECT qi,ri; |
|
LIST *qr; |
|
int id; |
|
Obj dmy; |
|
Q d0,d1,gcd,a,u,u1; |
|
Q *q,*r; |
|
STRING iqr_v; |
|
pointer *b; |
|
N qn,gn; |
|
double get_rtime(); |
|
int blen; |
|
double t0; |
|
double t_e,t_d,t_d1,t_c; |
|
|
|
if ( !p ) |
|
*rp = 0; |
|
else { |
|
for ( m = BDY(p), n = 0; m; m = NEXT(m), n++ ); |
|
nsep = ndist + 1; |
|
if ( n <= nsep ) { |
|
dp_ptozp(p,rp); return; |
|
} |
|
t0 = get_rtime(); |
|
dp_dtov(p,&c); |
|
igcdv_estimate(c,&d0); |
|
t_e = get_rtime()-t0; |
|
t0 = get_rtime(); |
|
dp_dtov(p,&c); |
|
sepvect(c,nsep,&cs); |
|
MKSTR(iqr_v,"iqr"); |
|
qr = (LIST *)CALLOC(nsep,sizeof(LIST)); |
|
q = (Q *)CALLOC(n,sizeof(Q)); |
|
r = (Q *)CALLOC(n,sizeof(Q)); |
|
for ( i = 0, tn = dist, b = BDY(cs); i < ndist; |
|
i++, tn = NEXT(tn) ) { |
|
div_vect_mpi(QTOS((Q)BDY(tn)),b[i],d0); |
|
} |
|
iqrv(b[i],d0,&qr[i]); |
|
dp_dtov(p,&c); |
|
for ( i = j = 0, tn = dist; i < ndist; i++, tn = NEXT(tn) ) { |
|
get_div_vect_mpi(QTOS((Q)BDY(tn)),&qr[i]); |
|
} |
|
t_d = get_rtime()-t0; |
|
t_d1 = t_d/n; |
|
t0 = get_rtime(); |
|
for ( i = j = 0; i < nsep; i++ ) { |
|
tn = BDY(qr[i]); qi = (VECT)BDY(tn); ri = (VECT)BDY(NEXT(tn)); |
|
for ( k = 0, l = qi->len; k < l; k++, j++ ) { |
|
q[j] = (Q)BDY(qi)[k]; r[j] = (Q)BDY(ri)[k]; |
|
} |
|
} |
|
v.id = O_VECT; v.len = n; v.body = (pointer *)r; igcdv(&v,&d1); |
|
if ( d1 ) { |
|
gcdn(NM(d0),NM(d1),&gn); NTOQ(gn,1,gcd); |
|
divsn(NM(d0),gn,&qn); NTOQ(qn,1,a); |
|
for ( i = 0; i < n; i++ ) { |
|
mulq(a,q[i],&u); |
|
if ( r[i] ) { |
|
divsn(NM(r[i]),gn,&qn); NTOQ(qn,SGN(r[i]),u1); |
|
addq(u,u1,&q[i]); |
|
} else |
|
q[i] = u; |
|
} |
|
} else |
|
gcd = d0; |
|
dp_vtod(q,p,rp); |
|
t_c = get_rtime()-t0; |
|
blen=p_mag(gcd); |
|
pz_t_e += t_e; pz_t_d += t_d; pz_t_d1 += t_d1; pz_t_c += t_c; |
|
if ( 0 ) |
|
fprintf(stderr,"(%d,%d)",p_mag(d0)-blen,blen); |
|
} |
|
} |
|
|
|
void dp_ptozp_d(dist,ndist,p,rp) |
|
NODE dist; |
|
int ndist; |
|
DP p,*rp; |
|
{ |
|
DP d,s,u,su; |
|
MP m,mr,mr0; |
|
MP *w0,*w; |
|
Q *g; |
|
int i,n,nv,nsep; |
|
P t; |
|
NODE tn,n0,n1,n2; |
|
struct oVECT v; |
|
int sindex,id; |
|
Obj dmy; |
|
Q gcd; |
|
STRING gcd_h,div_h; |
|
|
|
if ( !p ) |
|
*rp = 0; |
|
else { |
|
for ( m = BDY(p), n = 0; m; m = NEXT(m), n++ ); |
|
nsep = ndist + 1; |
|
if ( n <= nsep ) { |
|
dp_ptozp(p,rp); return; |
|
} |
|
nv = p->nv; |
|
w0 = (MP *)MALLOC(nsep*sizeof(MP)); bzero(w0,nsep*sizeof(MP)); |
|
w = (MP *)MALLOC(nsep*sizeof(MP)); bzero(w,nsep*sizeof(MP)); |
|
g = (Q *)MALLOC(nsep*sizeof(Q)); bzero(g,nsep*sizeof(Q)); |
|
for ( m = BDY(p), i = 0; m; m = NEXT(m), i++, i %= nsep ) { |
|
NEXTMP(w0[i],w[i]); w[i]->c = m->c; w[i]->dl = m->dl; |
|
} |
|
MKSTR(gcd_h,"dp_igcdv_hist"); MKSTR(div_h,"dp_idivv_hist"); |
|
|
|
for ( i = 0, tn = dist; i < ndist; i++, tn = NEXT(tn) ) { |
|
NEXT(w[i]) = 0; MKDP(nv,w0[i],d); d->sugar = p->sugar; |
|
MKNODE(n2,d,0); MKNODE(n1,gcd_h,n2); MKNODE(n0,BDY(tn),n1); |
|
Pox_rpc(n0,&dmy); |
|
} |
|
NEXT(w[i]) = 0; MKDP(nv,w0[i],d); d->sugar = p->sugar; |
|
dp_igcdv_hist(d,&g[i]); |
|
|
|
for ( i = 0, tn = dist; i < ndist; i++, tn = NEXT(tn) ) |
|
Pox_pop_local(tn,&g[i]); |
|
v.id = O_VECT; v.len = nsep; v.body = (pointer *)g; igcdv(&v,&gcd); |
|
|
|
for ( i = 0, tn = dist; i < ndist; i++, tn = NEXT(tn) ) { |
|
MKNODE(n2,gcd,0); MKNODE(n1,div_h,n2); MKNODE(n0,BDY(tn),n1); |
|
Pox_rpc(n0,&dmy); |
|
} |
|
dp_idivv_hist(gcd,&s); |
|
|
|
for ( i = 0, tn = dist; i < ndist; i++, tn = NEXT(tn) ) { |
|
Pox_pop_local(tn,&u); |
|
addd(CO,s,u,&su); s = su; |
|
} |
|
*rp = s; |
|
} |
|
} |
|
#endif |
|