version 1.26, 2003/08/22 08:14:45 |
version 1.30, 2004/04/14 07:27:41 |
|
|
* 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/engine/dist.c,v 1.25 2003/07/09 07:11:08 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.29 2004/03/05 02:26:52 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
Line 72 int (*primitive_cmpdl[3])() = {cmpdl_revgradlex,cmpdl_ |
|
Line 72 int (*primitive_cmpdl[3])() = {cmpdl_revgradlex,cmpdl_ |
|
int do_weyl; |
int do_weyl; |
|
|
int dp_nelim,dp_fcoeffs; |
int dp_nelim,dp_fcoeffs; |
struct order_spec dp_current_spec; |
struct order_spec *dp_current_spec; |
int *dp_dl_work; |
int *dp_dl_work; |
|
|
void comm_muld_trunc(VL vl,DP p1,DP p2,DL dl,DP *pr); |
void comm_muld_trunc(VL vl,DP p1,DP p2,DL dl,DP *pr); |
Line 80 void comm_quod(VL vl,DP p1,DP p2,DP *pr); |
|
Line 80 void comm_quod(VL vl,DP p1,DP p2,DP *pr); |
|
void muldm_trunc(VL vl,DP p,MP m0,DL dl,DP *pr); |
void muldm_trunc(VL vl,DP p,MP m0,DL dl,DP *pr); |
void muldc_trunc(VL vl,DP p,P c,DL dl,DP *pr); |
void muldc_trunc(VL vl,DP p,P c,DL dl,DP *pr); |
|
|
|
void order_init() |
|
{ |
|
struct order_spec *spec; |
|
|
|
create_order_spec(0,0,&spec); |
|
initd(spec); |
|
} |
|
|
int has_sfcoef(DP f) |
int has_sfcoef(DP f) |
{ |
{ |
MP t; |
MP t; |
Line 111 int has_sfcoef_p(P f) |
|
Line 119 int has_sfcoef_p(P f) |
|
void initd(struct order_spec *spec) |
void initd(struct order_spec *spec) |
{ |
{ |
switch ( spec->id ) { |
switch ( spec->id ) { |
|
case 3: |
|
cmpdl = cmpdl_composite; |
|
dp_dl_work = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int)); |
|
break; |
case 2: |
case 2: |
cmpdl = cmpdl_matrix; |
cmpdl = cmpdl_matrix; |
dp_dl_work = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int)); |
dp_dl_work = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int)); |
Line 151 void initd(struct order_spec *spec) |
|
Line 163 void initd(struct order_spec *spec) |
|
} |
} |
break; |
break; |
} |
} |
dp_current_spec = *spec; |
dp_current_spec = spec; |
} |
} |
|
|
void ptod(VL vl,VL dvl,P p,DP *pr) |
void ptod(VL vl,VL dvl,P p,DP *pr) |
Line 286 void addd(VL vl,DP p1,DP p2,DP *pr) |
|
Line 298 void addd(VL vl,DP p1,DP p2,DP *pr) |
|
int n; |
int n; |
MP m1,m2,mr,mr0; |
MP m1,m2,mr,mr0; |
P t; |
P t; |
|
DL d; |
|
|
if ( !p1 ) |
if ( !p1 ) |
*pr = p2; |
*pr = p2; |
else if ( !p2 ) |
else if ( !p2 ) |
*pr = p1; |
*pr = p1; |
else { |
else { |
|
if ( OID(p1) <= O_R ) { |
|
n = NV(p2); NEWDL(d,n); |
|
NEWMP(m1); m1->dl = d; C(m1) = p1; NEXT(m1) = 0; |
|
MKDP(n,m1,p1); (p1)->sugar = 0; |
|
} |
|
if ( OID(p2) <= O_R ) { |
|
n = NV(p1); NEWDL(d,n); |
|
NEWMP(m2); m2->dl = d; C(m2) = p2; NEXT(m2) = 0; |
|
MKDP(n,m2,p2); (p2)->sugar = 0; |
|
} |
for ( n = NV(p1), m1 = BDY(p1), m2 = BDY(p2), mr0 = 0; m1 && m2; ) |
for ( n = NV(p1), m1 = BDY(p1), m2 = BDY(p2), mr0 = 0; m1 && m2; ) |
switch ( (*cmpdl)(n,m1->dl,m2->dl) ) { |
switch ( (*cmpdl)(n,m1->dl,m2->dl) ) { |
case 0: |
case 0: |
Line 1467 int cmpdl_order_pair(int n,DL d1,DL d2) |
|
Line 1490 int cmpdl_order_pair(int n,DL d1,DL d2) |
|
int len,head; |
int len,head; |
struct order_pair *pair; |
struct order_pair *pair; |
|
|
len = dp_current_spec.ord.block.length; |
len = dp_current_spec->ord.block.length; |
pair = dp_current_spec.ord.block.order_pair; |
pair = dp_current_spec->ord.block.order_pair; |
|
|
head = 0; |
head = 0; |
for ( i = 0, t1 = d1->d, t2 = d2->d; i < len; i++ ) { |
for ( i = 0, t1 = d1->d, t2 = d2->d; i < len; i++ ) { |
Line 1517 int cmpdl_order_pair(int n,DL d1,DL d2) |
|
Line 1540 int cmpdl_order_pair(int n,DL d1,DL d2) |
|
return 0; |
return 0; |
} |
} |
|
|
|
int cmpdl_composite(int nv,DL d1,DL d2) |
|
{ |
|
int n,i,j,k,start,s,len; |
|
int *dw; |
|
struct sparse_weight *sw; |
|
struct weight_or_block *worb; |
|
int *w,*t1,*t2; |
|
|
|
n = dp_current_spec->ord.composite.length; |
|
worb = dp_current_spec->ord.composite.w_or_b; |
|
w = dp_dl_work; |
|
for ( i = 0, t1 = d1->d, t2 = d2->d; i < nv; i++ ) |
|
w[i] = t1[i]-t2[i]; |
|
for ( i = 0; i < n; i++, worb++ ) { |
|
len = worb->length; |
|
switch ( worb->type ) { |
|
case IS_DENSE_WEIGHT: |
|
dw = worb->body.dense_weight; |
|
for ( j = 0, s = 0; j < len; j++ ) |
|
s += dw[j]*w[j]; |
|
if ( s > 0 ) return 1; |
|
else if ( s < 0 ) return -1; |
|
break; |
|
case IS_SPARSE_WEIGHT: |
|
sw = worb->body.sparse_weight; |
|
for ( j = 0, s = 0; j < len; j++ ) |
|
s += sw[j].value*w[sw[j].pos]; |
|
if ( s > 0 ) return 1; |
|
else if ( s < 0 ) return -1; |
|
break; |
|
case IS_BLOCK: |
|
start = worb->body.block.start; |
|
switch ( worb->body.block.order ) { |
|
case 0: |
|
for ( j = 0, k = start, s = 0; j < len; j++, k++ ) { |
|
s += MUL_WEIGHT(w[k],k); |
|
} |
|
if ( s > 0 ) return 1; |
|
else if ( s < 0 ) return -1; |
|
else { |
|
for ( j = k-1; j >= start && w[j] == 0; j-- ); |
|
if ( j >= start ) |
|
return w[j] < 0 ? 1 : -1; |
|
} |
|
break; |
|
case 1: |
|
for ( j = 0, k = start, s = 0; j < len; j++, k++ ) { |
|
s += MUL_WEIGHT(w[k],k); |
|
} |
|
if ( s > 0 ) return 1; |
|
else if ( s < 0 ) return -1; |
|
else { |
|
for ( j = 0, k = start; j < len && w[j] == 0; j++, k++ ); |
|
if ( j < len ) |
|
return w[j] > 0 ? 1 : -1; |
|
} |
|
break; |
|
case 2: |
|
for ( j = 0, k = start; j < len && w[j] == 0; j++, k++ ); |
|
if ( j < len ) |
|
return w[j] > 0 ? 1 : -1; |
|
break; |
|
} |
|
break; |
|
} |
|
} |
|
return 0; |
|
} |
|
|
int cmpdl_matrix(int n,DL d1,DL d2) |
int cmpdl_matrix(int n,DL d1,DL d2) |
{ |
{ |
int *v,*w,*t1,*t2; |
int *v,*w,*t1,*t2; |
Line 1525 int cmpdl_matrix(int n,DL d1,DL d2) |
|
Line 1617 int cmpdl_matrix(int n,DL d1,DL d2) |
|
|
|
for ( i = 0, t1 = d1->d, t2 = d2->d, w = dp_dl_work; i < n; i++ ) |
for ( i = 0, t1 = d1->d, t2 = d2->d, w = dp_dl_work; i < n; i++ ) |
w[i] = t1[i]-t2[i]; |
w[i] = t1[i]-t2[i]; |
len = dp_current_spec.ord.matrix.row; |
len = dp_current_spec->ord.matrix.row; |
matrix = dp_current_spec.ord.matrix.matrix; |
matrix = dp_current_spec->ord.matrix.matrix; |
for ( j = 0; j < len; j++ ) { |
for ( j = 0; j < len; j++ ) { |
v = matrix[j]; |
v = matrix[j]; |
for ( i = 0, s = 0; i < n; i++ ) |
for ( i = 0, s = 0; i < n; i++ ) |