version 1.1.1.1, 1999/12/03 07:39:07 |
version 1.4, 2000/12/05 01:24:49 |
|
|
/* $OpenXM: OpenXM/src/asir99/builtin/dp-supp.c,v 1.2 1999/11/18 05:42:01 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@sec.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/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" |
#include "parse.h" |
#include "parse.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 |
|