version 1.57, 2010/05/01 02:17:49 |
version 1.63, 2016/03/31 07:33:32 |
|
|
* 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.56 2009/10/15 07:08:40 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/dp-supp.c,v 1.62 2016/03/31 01:40:10 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
Line 651 void dp_sp(DP p1,DP p2,DP *rp) |
|
Line 651 void dp_sp(DP p1,DP p2,DP *rp) |
|
LIST hist; |
LIST hist; |
NODE node; |
NODE node; |
|
|
node = mknode(4,ONE,0,s1,ONE); |
node = mknode(4,ONE,NULLP,s1,ONE); |
MKLIST(hist,node); |
MKLIST(hist,node); |
MKNODE(TraceList,hist,0); |
MKNODE(TraceList,hist,0); |
|
|
node = mknode(4,ONE,0,0,ONE); |
node = mknode(4,ONE,NULLP,NULLP,ONE); |
chsgnd(s2,(DP *)&ARG2(node)); |
chsgnd(s2,(DP *)&ARG2(node)); |
MKLIST(hist,node); |
MKLIST(hist,node); |
MKNODE(node,hist,TraceList); TraceList = node; |
MKNODE(node,hist,TraceList); TraceList = node; |
Line 704 void _dp_sp_dup(DP p1,DP p2,DP *rp) |
|
Line 704 void _dp_sp_dup(DP p1,DP p2,DP *rp) |
|
LIST hist; |
LIST hist; |
NODE node; |
NODE node; |
|
|
node = mknode(4,ONE,0,s1,ONE); |
node = mknode(4,ONE,NULLP,s1,ONE); |
MKLIST(hist,node); |
MKLIST(hist,node); |
MKNODE(TraceList,hist,0); |
MKNODE(TraceList,hist,0); |
|
|
node = mknode(4,ONE,0,0,ONE); |
node = mknode(4,ONE,NULLP,NULLP,ONE); |
chsgnd(s2,(DP *)&ARG2(node)); |
chsgnd(s2,(DP *)&ARG2(node)); |
MKLIST(hist,node); |
MKLIST(hist,node); |
MKNODE(node,hist,TraceList); TraceList = node; |
MKNODE(node,hist,TraceList); TraceList = node; |
Line 1065 void dp_true_nf(NODE b,DP g,DP *ps,int full,DP *rp,P * |
|
Line 1065 void dp_true_nf(NODE b,DP g,DP *ps,int full,DP *rp,P * |
|
*rp = d; *dnp = dn; |
*rp = d; *dnp = dn; |
} |
} |
|
|
|
DP *dp_true_nf_and_quotient(NODE b,DP g,DP *ps,DP *rp,P *dnp) |
|
{ |
|
DP u,p,d,s,t,dmy,hp,mult; |
|
DP *q; |
|
NODE l; |
|
MP m,mr; |
|
int i,n,j; |
|
int *wb; |
|
int sugar,psugar,multiple; |
|
P nm,tnm1,dn,tdn,tdn1; |
|
Q cont; |
|
|
|
dn = (P)ONE; |
|
if ( !g ) { |
|
*rp = 0; *dnp = dn; return 0; |
|
} |
|
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
|
wb = (int *)ALLOCA(n*sizeof(int)); |
|
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
|
wb[i] = QTOS((Q)BDY(l)); |
|
q = (DP *)MALLOC(n*sizeof(DP)); |
|
for ( i = 0; i < n; i++ ) q[i] = 0; |
|
sugar = g->sugar; |
|
for ( d = 0; g; ) { |
|
for ( u = 0, i = 0; i < n; i++ ) { |
|
if ( dp_redble(g,ps[wb[i]]) ) { |
|
p = ps[wb[i]]; |
|
dp_red(d,g,p,&t,&u,&tdn,&mult); |
|
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
|
sugar = MAX(sugar,psugar); |
|
for ( j = 0; j < n; j++ ) { |
|
muldc(CO,q[j],(P)tdn,&dmy); q[j] = dmy; |
|
} |
|
addd(CO,q[wb[i]],mult,&dmy); q[wb[i]] = dmy; |
|
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
|
d = t; |
|
if ( !u ) goto last; |
|
break; |
|
} |
|
} |
|
if ( u ) { |
|
g = u; |
|
} else { |
|
m = BDY(g); NEWMP(mr); mr->dl = m->dl; mr->c = m->c; |
|
NEXT(mr) = 0; MKDP(g->nv,mr,t); t->sugar = mr->dl->td; |
|
addd(CO,d,t,&s); d = s; |
|
dp_rest(g,&t); g = t; |
|
} |
|
} |
|
last: |
|
if ( d ) d->sugar = sugar; |
|
*rp = d; *dnp = dn; |
|
return q; |
|
} |
|
|
void dp_removecont2(DP p1,DP p2,DP *r1p,DP *r2p,Q *contp) |
void dp_removecont2(DP p1,DP p2,DP *r1p,DP *r2p,Q *contp) |
{ |
{ |
struct oVECT v; |
struct oVECT v; |
Line 1249 DP *dp_true_nf_and_quotient_marked (NODE b,DP g,DP *ps |
|
Line 1304 DP *dp_true_nf_and_quotient_marked (NODE b,DP g,DP *ps |
|
|
|
dn = (P)ONE; |
dn = (P)ONE; |
if ( !g ) { |
if ( !g ) { |
*rp = 0; *dnp = dn; return; |
*rp = 0; *dnp = dn; return 0; |
} |
} |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
wb = (int *)ALLOCA(n*sizeof(int)); |
wb = (int *)ALLOCA(n*sizeof(int)); |
Line 1306 DP *dp_true_nf_and_quotient_marked_mod(NODE b,DP g,DP |
|
Line 1361 DP *dp_true_nf_and_quotient_marked_mod(NODE b,DP g,DP |
|
for ( i = 0; i < n; i++ ) q[i] = 0; |
for ( i = 0; i < n; i++ ) q[i] = 0; |
dn = (P)ONEM; |
dn = (P)ONEM; |
if ( !g ) { |
if ( !g ) { |
*rp = 0; *dnp = dn; return; |
*rp = 0; *dnp = dn; return 0; |
} |
} |
wb = (int *)ALLOCA(n*sizeof(int)); |
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
Line 1735 void dp_nf_tab_f(DP p,LIST *tab,DP *rp) |
|
Line 1790 void dp_nf_tab_f(DP p,LIST *tab,DP *rp) |
|
|
|
int create_order_spec(VL vl,Obj obj,struct order_spec **specp) |
int create_order_spec(VL vl,Obj obj,struct order_spec **specp) |
{ |
{ |
int i,j,n,s,row,col,ret; |
int i,j,n,s,row,col,ret,wlen; |
struct order_spec *spec; |
struct order_spec *spec; |
struct order_pair *l; |
struct order_pair *l; |
NODE node,t,tn; |
Obj wp,wm; |
|
NODE node,t,tn,wpair; |
MAT m; |
MAT m; |
VECT v; |
VECT v; |
pointer **b,*bv; |
pointer **b,*bv; |
Line 1757 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
Line 1813 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
spec->ord.simple = QTOS((Q)obj); |
spec->ord.simple = QTOS((Q)obj); |
return 1; |
return 1; |
} else if ( OID(obj) == O_LIST ) { |
} else if ( OID(obj) == O_LIST ) { |
|
/* module order; obj = [0|1,w,ord] or [0|1,ord] */ |
node = BDY((LIST)obj); |
node = BDY((LIST)obj); |
if ( !BDY(node) || NUM(BDY(node)) ) { |
if ( !BDY(node) || NUM(BDY(node)) ) { |
if ( length(node) < 2 ) |
switch ( length(node) ) { |
error("create_order_spec : invalid argument"); |
case 2: |
create_order_spec(0,(Obj)BDY(NEXT(node)),&spec); |
create_order_spec(0,(Obj)BDY(NEXT(node)),&spec); |
spec->id += 256; spec->obj = obj; |
spec->id += 256; spec->obj = obj; |
spec->ispot = (BDY(node)!=0); |
spec->top_weight = 0; |
if ( spec->ispot ) { |
spec->module_rank = 0; |
n = QTOS((Q)BDY(node)); |
spec->module_top_weight = 0; |
if ( n < 0 ) |
spec->ispot = (BDY(node)!=0); |
spec->pot_nelim = -n; |
if ( spec->ispot ) { |
else |
n = QTOS((Q)BDY(node)); |
spec->pot_nelim = 0; |
if ( n < 0 ) |
} |
spec->pot_nelim = -n; |
|
else |
|
spec->pot_nelim = 0; |
|
} |
|
break; |
|
|
|
case 3: |
|
create_order_spec(0,(Obj)BDY(NEXT(NEXT(node))),&spec); |
|
spec->id += 256; spec->obj = obj; |
|
spec->ispot = (BDY(node)!=0); |
|
node = NEXT(node); |
|
if ( !BDY(node) || OID(BDY(node)) != O_LIST ) |
|
error("create_order_spec : [weight_for_poly,weight_for_modlue] must be specified as a module topweight"); |
|
wpair = BDY((LIST)BDY(node)); |
|
if ( length(wpair) != 2 ) |
|
error("create_order_spec : [weight_for_poly,weight_for_modlue] must be specified as a module topweight"); |
|
|
|
wp = BDY(wpair); |
|
wm = BDY(NEXT(wpair)); |
|
if ( !wp || OID(wp) != O_LIST || !wm || OID(wm) != O_LIST ) |
|
error("create_order_spec : [weight_for_poly,weight_for_modlue] must be specified as a module topweight"); |
|
spec->nv = length(BDY((LIST)wp)); |
|
spec->top_weight = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int)); |
|
for ( i = 0, t = BDY((LIST)wp); i < spec->nv; t = NEXT(t), i++ ) |
|
spec->top_weight[i] = QTOS((Q)BDY(t)); |
|
|
|
spec->module_rank = length(BDY((LIST)wm)); |
|
spec->module_top_weight = (int *)MALLOC_ATOMIC(spec->module_rank*sizeof(int)); |
|
for ( i = 0, t = BDY((LIST)wm); i < spec->module_rank; t = NEXT(t), i++ ) |
|
spec->module_top_weight[i] = QTOS((Q)BDY(t)); |
|
break; |
|
default: |
|
error("create_order_spec : invalid arguments for module order"); |
|
} |
|
|
*specp = spec; |
*specp = spec; |
return 1; |
return 1; |
} |
} else { |
|
/* block order in polynomial ring */ |
for ( n = 0, t = node; t; t = NEXT(t), n++ ); |
for ( n = 0, t = node; t; t = NEXT(t), n++ ); |
l = (struct order_pair *)MALLOC_ATOMIC(n*sizeof(struct order_pair)); |
l = (struct order_pair *)MALLOC_ATOMIC(n*sizeof(struct order_pair)); |
for ( i = 0, t = node, s = 0; i < n; t = NEXT(t), i++ ) { |
for ( i = 0, t = node, s = 0; i < n; t = NEXT(t), i++ ) { |
tn = BDY((LIST)BDY(t)); l[i].order = QTOS((Q)BDY(tn)); |
tn = BDY((LIST)BDY(t)); l[i].order = QTOS((Q)BDY(tn)); |
tn = NEXT(tn); l[i].length = QTOS((Q)BDY(tn)); |
tn = NEXT(tn); l[i].length = QTOS((Q)BDY(tn)); |
s += l[i].length; |
s += l[i].length; |
} |
} |
spec->id = 1; spec->obj = obj; |
spec->id = 1; spec->obj = obj; |
spec->ord.block.order_pair = l; |
spec->ord.block.order_pair = l; |
spec->ord.block.length = n; spec->nv = s; |
spec->ord.block.length = n; spec->nv = s; |
return 1; |
return 1; |
|
} |
} else if ( OID(obj) == O_MAT ) { |
} else if ( OID(obj) == O_MAT ) { |
m = (MAT)obj; row = m->row; col = m->col; b = BDY(m); |
m = (MAT)obj; row = m->row; col = m->col; b = BDY(m); |
w = almat(row,col); |
w = almat(row,col); |