version 1.215, 2013/12/20 02:02:24 |
version 1.219, 2014/08/19 06:35:01 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.214 2013/09/27 07:00:45 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.218 2014/02/24 01:45:28 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 13 ND _nd_free_list; |
|
Line 13 ND _nd_free_list; |
|
ND_pairs _ndp_free_list; |
ND_pairs _ndp_free_list; |
NODE nd_hcf; |
NODE nd_hcf; |
|
|
|
Obj nd_top_weight; |
|
|
static NODE nd_subst; |
static NODE nd_subst; |
static VL nd_vc; |
static VL nd_vc; |
static int nd_ntrans; |
static int nd_ntrans; |
Line 497 int ndl_block_compare(UINT *d1,UINT *d2) |
|
Line 499 int ndl_block_compare(UINT *d1,UINT *d2) |
|
|
|
int ndl_matrix_compare(UINT *d1,UINT *d2) |
int ndl_matrix_compare(UINT *d1,UINT *d2) |
{ |
{ |
int i,j,s; |
int i,j,s,row; |
int *v; |
int *v; |
|
Q **mat; |
|
Q *w; |
|
Q t,t1,t2; |
|
|
for ( j = 0; j < nd_nvar; j++ ) |
for ( j = 0; j < nd_nvar; j++ ) |
nd_work_vector[j] = GET_EXP(d1,j)-GET_EXP(d2,j); |
nd_work_vector[j] = GET_EXP(d1,j)-GET_EXP(d2,j); |
|
if ( nd_top_weight ) { |
|
if ( OID(nd_top_weight) == O_VECT ) { |
|
mat = (Q **)&BDY((VECT)nd_top_weight); |
|
row = 1; |
|
} else { |
|
mat = (Q **)BDY((MAT)nd_top_weight); |
|
row = ((MAT)nd_top_weight)->row; |
|
} |
|
for ( i = 0; i < row; i++ ) { |
|
w = (Q *)mat[i]; |
|
for ( j = 0, t = 0; j < nd_nvar; j++ ) { |
|
STOQ(nd_work_vector[j],t1); |
|
mulq(w[j],t1,&t2); |
|
addq(t,t2,&t1); |
|
t = t1; |
|
} |
|
if ( t ) { |
|
s = SGN(t); |
|
if ( s > 0 ) return 1; |
|
else if ( s < 0 ) return -1; |
|
} |
|
} |
|
} |
for ( i = 0; i < nd_matrix_len; i++ ) { |
for ( i = 0; i < nd_matrix_len; i++ ) { |
v = nd_matrix[i]; |
v = nd_matrix[i]; |
for ( j = 0, s = 0; j < nd_nvar; j++ ) |
for ( j = 0, s = 0; j < nd_nvar; j++ ) |
Line 509 int ndl_matrix_compare(UINT *d1,UINT *d2) |
|
Line 537 int ndl_matrix_compare(UINT *d1,UINT *d2) |
|
if ( s > 0 ) return 1; |
if ( s > 0 ) return 1; |
else if ( s < 0 ) return -1; |
else if ( s < 0 ) return -1; |
} |
} |
|
if ( !ndl_equal(d1,d2) ) |
|
error("afo"); |
return 0; |
return 0; |
} |
} |
|
|
Line 2703 int ndv_newps(int m,NDV a,NDV aq,int f4) |
|
Line 2733 int ndv_newps(int m,NDV a,NDV aq,int f4) |
|
nd_ps[nd_psn] = a; |
nd_ps[nd_psn] = a; |
if ( aq ) { |
if ( aq ) { |
nd_ps_trace[nd_psn] = aq; |
nd_ps_trace[nd_psn] = aq; |
nd_ps_gz[nd_psn] = ndvtondvgz(aq); |
if ( !nd_vc ) nd_ps_gz[nd_psn] = ndvtondvgz(aq); |
register_hcf(aq); |
register_hcf(aq); |
nd_bound[nd_psn] = ndv_compute_bound(aq); |
nd_bound[nd_psn] = ndv_compute_bound(aq); |
SG(r) = SG(aq); ndl_copy(HDL(aq),DL(r)); |
SG(r) = SG(aq); ndl_copy(HDL(aq),DL(r)); |
Line 2711 int ndv_newps(int m,NDV a,NDV aq,int f4) |
|
Line 2741 int ndv_newps(int m,NDV a,NDV aq,int f4) |
|
if ( !m ) register_hcf(a); |
if ( !m ) register_hcf(a); |
nd_bound[nd_psn] = ndv_compute_bound(a); |
nd_bound[nd_psn] = ndv_compute_bound(a); |
SG(r) = SG(a); ndl_copy(HDL(a),DL(r)); |
SG(r) = SG(a); ndl_copy(HDL(a),DL(r)); |
if ( !m ) nd_ps_gz[nd_psn] = ndvtondvgz(a); |
if ( !m && !nd_vc ) nd_ps_gz[nd_psn] = ndvtondvgz(a); |
} |
} |
if ( nd_demand ) { |
if ( nd_demand ) { |
if ( aq ) { |
if ( aq ) { |
Line 2789 int ndv_setup(int mod,int trace,NODE f,int dont_sort,i |
|
Line 2819 int ndv_setup(int mod,int trace,NODE f,int dont_sort,i |
|
hc = HCU(w[i].p); |
hc = HCU(w[i].p); |
if ( trace ) { |
if ( trace ) { |
a = nd_ps_trace[i] = ndv_dup(0,w[i].p); |
a = nd_ps_trace[i] = ndv_dup(0,w[i].p); |
nd_ps_gz[i] = ndvtondvgz(a); |
if ( !nd_vc ) nd_ps_gz[i] = ndvtondvgz(a); |
if ( !dont_removecont) ndv_removecont(0,a); |
if ( !dont_removecont) ndv_removecont(0,a); |
register_hcf(a); |
register_hcf(a); |
am = nd_ps[i] = ndv_dup(mod,a); |
am = nd_ps[i] = ndv_dup(mod,a); |
Line 2799 int ndv_setup(int mod,int trace,NODE f,int dont_sort,i |
|
Line 2829 int ndv_setup(int mod,int trace,NODE f,int dont_sort,i |
|
ndv_removecont(mod,am); |
ndv_removecont(mod,am); |
} else { |
} else { |
a = nd_ps[i] = ndv_dup(mod,w[i].p); |
a = nd_ps[i] = ndv_dup(mod,w[i].p); |
if ( !mod ) nd_ps_gz[i] = ndvtondvgz(a); |
if ( !mod && !nd_vc ) nd_ps_gz[i] = ndvtondvgz(a); |
if ( mod || !dont_removecont ) ndv_removecont(mod,a); |
if ( mod || !dont_removecont ) ndv_removecont(mod,a); |
if ( !mod ) register_hcf(a); |
if ( !mod ) register_hcf(a); |
} |
} |
Line 6068 NODE nd_f4(int m,int **indp) |
|
Line 6098 NODE nd_f4(int m,int **indp) |
|
node = BDY((LIST)BDY(tn)); |
node = BDY((LIST)BDY(tn)); |
if ( QTOS((Q)ARG0(node)) == sugar ) break; |
if ( QTOS((Q)ARG0(node)) == sugar ) break; |
} |
} |
if ( !tn ) error("nd_f4 : inconsistent non-zero list"); |
if ( tn ) { |
for ( t = l, ll0 = 0; t; t = NEXT(t) ) { |
for ( t = l, ll0 = 0; t; t = NEXT(t) ) { |
for ( tn = BDY((LIST)ARG1(node)); tn; tn = NEXT(tn) ) { |
for ( tn = BDY((LIST)ARG1(node)); tn; tn = NEXT(tn) ) { |
i1s = QTOS((Q)ARG0(BDY((LIST)BDY(tn)))); |
i1s = QTOS((Q)ARG0(BDY((LIST)BDY(tn)))); |
i2s = QTOS((Q)ARG1(BDY((LIST)BDY(tn)))); |
i2s = QTOS((Q)ARG1(BDY((LIST)BDY(tn)))); |
if ( t->i1 == i1s && t->i2 == i2s ) break; |
if ( t->i1 == i1s && t->i2 == i2s ) break; |
} |
} |
if ( tn ) { |
if ( tn ) { |
if ( !ll0 ) ll0 = t; |
if ( !ll0 ) ll0 = t; |
else NEXT(ll) = t; |
else NEXT(ll) = t; |
ll = t; |
ll = t; |
} |
} |
} |
} |
if ( ll0 ) NEXT(ll) = 0; |
if ( ll0 ) NEXT(ll) = 0; |
l = ll0; |
l = ll0; |
|
} else l = 0; |
} |
} |
bucket = create_pbucket(); |
bucket = create_pbucket(); |
stat = nd_sp_f4(m,0,l,bucket); |
stat = nd_sp_f4(m,0,l,bucket); |
Line 6978 int nd_gauss_elim_gz(GZ **mat0,int *sugar,int row,int |
|
Line 7009 int nd_gauss_elim_gz(GZ **mat0,int *sugar,int row,int |
|
{ |
{ |
int i,j,t,c,rank,inv; |
int i,j,t,c,rank,inv; |
int *ci,*ri; |
int *ci,*ri; |
GZ *dn; |
GZ dn; |
MAT m,nm; |
MAT m,nm; |
|
|
NEWMAT(m); m->row = row; m->col = col; m->body = (pointer **)mat0; |
NEWMAT(m); m->row = row; m->col = col; m->body = (pointer **)mat0; |
dn = (GZ *)MALLOC(row*sizeof(GZ)); |
rank = gz_generic_gauss_elim(m,&nm,&dn,&ri,&ci); |
rank = gz_generic_gauss_elim2(m,&nm,dn,&ri,&ci); |
|
for ( i = 0; i < row; i++ ) |
for ( i = 0; i < row; i++ ) |
for ( j = 0; j < col; j++ ) |
for ( j = 0; j < col; j++ ) |
mat0[i][j] = 0; |
mat0[i][j] = 0; |
c = col-rank; |
c = col-rank; |
for ( i = 0; i < rank; i++ ) { |
for ( i = 0; i < rank; i++ ) { |
mat0[i][ri[i]] = dn[i]; |
mat0[i][ri[i]] = dn; |
for ( j = 0; j < c; j++ ) |
for ( j = 0; j < c; j++ ) |
mat0[i][ci[j]] = (GZ)BDY(nm)[i][j]; |
mat0[i][ci[j]] = (GZ)BDY(nm)[i][j]; |
} |
} |
Line 7948 MAT nd_btog(LIST f,LIST v,int mod,struct order_spec *o |
|
Line 7978 MAT nd_btog(LIST f,LIST v,int mod,struct order_spec *o |
|
pi0 = QTOS((Q)ARG0(pi)); pi1 = QTOS((Q)ARG1(pi)); |
pi0 = QTOS((Q)ARG0(pi)); pi1 = QTOS((Q)ARG1(pi)); |
p[pi0] = c = (ND *)MALLOC(nb*sizeof(ND)); |
p[pi0] = c = (ND *)MALLOC(nb*sizeof(ND)); |
ptomp(mod,(P)ARG2(pi),&inv); |
ptomp(mod,(P)ARG2(pi),&inv); |
|
((MQ)inv)->cont = invm(((MQ)inv)->cont,mod); |
u = ptond(CO,vv,(P)ONE); |
u = ptond(CO,vv,(P)ONE); |
HCM(u) = ((MQ)inv)->cont; |
HCM(u) = ((MQ)inv)->cont; |
c[pi1] = u; |
c[pi1] = u; |
Line 8019 VECT nd_btog_one(LIST f,LIST v,int mod,struct order_sp |
|
Line 8050 VECT nd_btog_one(LIST f,LIST v,int mod,struct order_sp |
|
pi = BDY((LIST)BDY(t)); |
pi = BDY((LIST)BDY(t)); |
pi0 = QTOS((Q)ARG0(pi)); pi1 = QTOS((Q)ARG1(pi)); |
pi0 = QTOS((Q)ARG0(pi)); pi1 = QTOS((Q)ARG1(pi)); |
if ( pi1 == pos ) { |
if ( pi1 == pos ) { |
ptomp(mod,(P)ARG2(pi),&inv); |
ptomp(mod,(P)ARG2(pi),&inv); |
|
((MQ)inv)->cont = invm(((MQ)inv)->cont,mod); |
u = ptond(CO,vv,(P)ONE); |
u = ptond(CO,vv,(P)ONE); |
HCM(u) = ((MQ)inv)->cont; |
HCM(u) = ((MQ)inv)->cont; |
p[pi0] = u; |
p[pi0] = u; |