version 1.12, 2019/09/04 05:32:10 |
version 1.16, 2019/10/11 03:45:56 |
|
|
* 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/asir2018/builtin/dp.c,v 1.11 2019/09/04 01:12:02 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/builtin/dp.c,v 1.15 2019/09/19 06:29:47 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
Line 79 void Pdp_nf_mod(),Pdp_true_nf_mod(); |
|
Line 79 void Pdp_nf_mod(),Pdp_true_nf_mod(); |
|
void Pdp_criB(),Pdp_nelim(); |
void Pdp_criB(),Pdp_nelim(); |
void Pdp_minp(),Pdp_sp_mod(); |
void Pdp_minp(),Pdp_sp_mod(); |
void Pdp_homo(),Pdp_dehomo(); |
void Pdp_homo(),Pdp_dehomo(); |
|
void Pdpm_homo(),Pdpm_dehomo(); |
void Pdp_gr_mod_main(),Pdp_gr_f_main(); |
void Pdp_gr_mod_main(),Pdp_gr_f_main(); |
void Pdp_gr_main(),Pdp_gr_hm_main(),Pdp_gr_d_main(),Pdp_gr_flags(); |
void Pdp_gr_main(),Pdp_gr_hm_main(),Pdp_gr_d_main(),Pdp_gr_flags(); |
void Pdp_interreduce(); |
void Pdp_interreduce(); |
Line 91 void Pdp_gr_checklist(); |
|
Line 92 void Pdp_gr_checklist(); |
|
void Pdp_ltod(),Pdpv_ord(),Pdpv_ht(),Pdpv_hm(),Pdpv_hc(); |
void Pdp_ltod(),Pdpv_ord(),Pdpv_ht(),Pdpv_hm(),Pdpv_hc(); |
void Pdpm_ltod(),Pdpm_dtol(),Pdpm_set_schreyer(),Pdpm_nf(),Pdpm_weyl_nf(),Pdpm_sp(),Pdpm_weyl_sp(),Pdpm_nf_and_quotient(); |
void Pdpm_ltod(),Pdpm_dtol(),Pdpm_set_schreyer(),Pdpm_nf(),Pdpm_weyl_nf(),Pdpm_sp(),Pdpm_weyl_sp(),Pdpm_nf_and_quotient(); |
void Pdpm_hm(),Pdpm_ht(),Pdpm_hc(),Pdpm_hp(),Pdpm_rest(),Pdpm_shift(),Pdpm_split(),Pdpm_sort(),Pdpm_dptodpm(),Pdpm_redble(); |
void Pdpm_hm(),Pdpm_ht(),Pdpm_hc(),Pdpm_hp(),Pdpm_rest(),Pdpm_shift(),Pdpm_split(),Pdpm_sort(),Pdpm_dptodpm(),Pdpm_redble(); |
void Pdpm_schreyer_base(),Pdpm_simplify_syz(); |
void Pdpm_schreyer_base(),Pdpm_simplify_syz(),Pdpm_td(); |
|
|
void Pdp_weyl_red(); |
void Pdp_weyl_red(); |
void Pdp_weyl_sp(); |
void Pdp_weyl_sp(); |
Line 277 struct ftab dp_supp_tab[] = { |
|
Line 278 struct ftab dp_supp_tab[] = { |
|
|
|
{"dpm_ltod",Pdpm_ltod,2}, |
{"dpm_ltod",Pdpm_ltod,2}, |
{"dpm_dptodpm",Pdpm_dptodpm,2}, |
{"dpm_dptodpm",Pdpm_dptodpm,2}, |
{"dpm_dtol",Pdpm_dtol,3}, |
{"dpm_dtol",Pdpm_dtol,2}, |
|
{"dpm_homo",Pdpm_homo,1}, |
|
{"dpm_dehomo",Pdpm_dehomo,1}, |
|
|
/* criteria */ |
/* criteria */ |
{"dp_cri1",Pdp_cri1,2}, |
{"dp_cri1",Pdp_cri1,2}, |
Line 311 struct ftab dp_supp_tab[] = { |
|
Line 314 struct ftab dp_supp_tab[] = { |
|
{"dp_mag",Pdp_mag,1}, |
{"dp_mag",Pdp_mag,1}, |
{"dp_sugar",Pdp_sugar,1}, |
{"dp_sugar",Pdp_sugar,1}, |
{"dp_set_sugar",Pdp_set_sugar,2}, |
{"dp_set_sugar",Pdp_set_sugar,2}, |
|
{"dpm_td",Pdpm_td,1}, |
|
|
/* misc */ |
/* misc */ |
{"dp_mbase",Pdp_mbase,1}, |
{"dp_mbase",Pdp_mbase,1}, |
Line 929 void Pdp_ord(NODE arg,Obj *rp) |
|
Line 933 void Pdp_ord(NODE arg,Obj *rp) |
|
else if ( !create_order_spec(0,(Obj)ARG0(arg),&spec) ) |
else if ( !create_order_spec(0,(Obj)ARG0(arg),&spec) ) |
error("dp_ord : invalid order specification"); |
error("dp_ord : invalid order specification"); |
initd(spec); *rp = spec->obj; |
initd(spec); *rp = spec->obj; |
if ( spec->id >= 256 ) dpm_ordtype = spec->ispot; |
if ( spec->id >= 256 ) dpm_ordtype = spec->module_ordtype; |
} |
} |
} |
} |
|
|
Line 1094 void Pdpm_dptodpm(NODE arg,DPM *rp) |
|
Line 1098 void Pdpm_dptodpm(NODE arg,DPM *rp) |
|
{ |
{ |
DP p; |
DP p; |
MP mp; |
MP mp; |
int pos; |
int pos,shift; |
DMM m0,m; |
DMM m0,m; |
|
|
p = (DP)ARG0(arg); |
p = (DP)ARG0(arg); |
Line 1106 void Pdpm_dptodpm(NODE arg,DPM *rp) |
|
Line 1110 void Pdpm_dptodpm(NODE arg,DPM *rp) |
|
for ( m0 = 0, mp = BDY(p); mp; mp = NEXT(mp) ) { |
for ( m0 = 0, mp = BDY(p); mp; mp = NEXT(mp) ) { |
NEXTDMM(m0,m); m->dl = mp->dl; m->c = mp->c; m->pos = pos; |
NEXTDMM(m0,m); m->dl = mp->dl; m->c = mp->c; m->pos = pos; |
} |
} |
MKDPM(p->nv,m0,*rp); (*rp)->sugar = p->sugar; |
if ( dp_current_spec->module_rank ) { |
|
if ( pos > dp_current_spec->module_rank ) |
|
error("dpm_dptodpm : inconsistent order spec"); |
|
shift = dp_current_spec->module_top_weight[pos-1]; |
|
m->dl->td += shift; |
|
} else |
|
shift = 0; |
|
|
|
MKDPM(p->nv,m0,*rp); (*rp)->sugar = p->sugar+shift; |
} |
} |
} |
} |
|
|
Line 1124 void Pdpm_dtol(NODE arg,LIST *rp) |
|
Line 1136 void Pdpm_dtol(NODE arg,LIST *rp) |
|
Obj s; |
Obj s; |
|
|
a = (DPM)ARG0(arg); |
a = (DPM)ARG0(arg); |
|
if ( !a ) { |
|
MKLIST(*rp,0); |
|
return; |
|
} |
for ( vl = 0, nd = BDY((LIST)ARG1(arg)), nv = 0; nd; nd = NEXT(nd), nv++ ) { |
for ( vl = 0, nd = BDY((LIST)ARG1(arg)), nv = 0; nd; nd = NEXT(nd), nv++ ) { |
if ( !vl ) { |
if ( !vl ) { |
NEWVL(vl); tvl = vl; |
NEWVL(vl); tvl = vl; |
Line 1134 void Pdpm_dtol(NODE arg,LIST *rp) |
|
Line 1150 void Pdpm_dtol(NODE arg,LIST *rp) |
|
} |
} |
if ( vl ) |
if ( vl ) |
NEXT(tvl) = 0; |
NEXT(tvl) = 0; |
n = ZTOS((Q)ARG2(arg)); |
for ( t = BDY(a), n = 0; t; t = NEXT(t) ) |
|
if ( t->pos > n ) n = t->pos; |
w = (MP *)CALLOC(n,sizeof(MP)); |
w = (MP *)CALLOC(n,sizeof(MP)); |
for ( t = BDY(a), len = 0; t; t = NEXT(t) ) len++; |
for ( t = BDY(a), len = 0; t; t = NEXT(t) ) len++; |
wa = (DMM *)MALLOC(len*sizeof(DMM)); |
wa = (DMM *)MALLOC(len*sizeof(DMM)); |
Line 1142 void Pdpm_dtol(NODE arg,LIST *rp) |
|
Line 1159 void Pdpm_dtol(NODE arg,LIST *rp) |
|
for ( i = len-1; i >= 0; i-- ) { |
for ( i = len-1; i >= 0; i-- ) { |
NEWMP(m); m->dl = wa[i]->dl; C(m) = C(wa[i]); |
NEWMP(m); m->dl = wa[i]->dl; C(m) = C(wa[i]); |
pos = wa[i]->pos; |
pos = wa[i]->pos; |
NEXT(m) = w[pos]; |
NEXT(m) = w[pos-1]; |
w[pos] = m; |
w[pos-1] = m; |
} |
} |
nd = 0; |
nd = 0; |
for ( i = n-1; i >= 0; i-- ) { |
for ( i = n-1; i >= 0; i-- ) { |
Line 1879 void Pdpm_schreyer_base(NODE arg,LIST *rp) |
|
Line 1896 void Pdpm_schreyer_base(NODE arg,LIST *rp) |
|
dpm_schreyer_base((LIST)ARG0(arg),rp); |
dpm_schreyer_base((LIST)ARG0(arg),rp); |
} |
} |
|
|
void dpm_simplify_syz(LIST m,LIST s,LIST *m1,LIST *s1); |
void dpm_simplify_syz(LIST m,LIST s,LIST *m1,LIST *s1,LIST *w1); |
|
|
void Pdpm_simplify_syz(NODE arg,LIST *rp) |
void Pdpm_simplify_syz(NODE arg,LIST *rp) |
{ |
{ |
LIST s1,m1; |
LIST s1,m1,w1; |
NODE t; |
NODE t; |
|
|
asir_assert(ARG0(arg),O_LIST,"dpm_simplify_syz"); |
asir_assert(ARG0(arg),O_LIST,"dpm_simplify_syz"); |
asir_assert(ARG1(arg),O_LIST,"dpm_simplify_syz"); |
asir_assert(ARG1(arg),O_LIST,"dpm_simplify_syz"); |
dpm_simplify_syz((LIST)ARG0(arg),(LIST)ARG1(arg),&s1,&m1); |
dpm_simplify_syz((LIST)ARG0(arg),(LIST)ARG1(arg),&s1,&m1,&w1); |
t = mknode(2,s1,m1); |
t = mknode(3,s1,m1,w1); |
MKLIST(*rp,t); |
MKLIST(*rp,t); |
} |
} |
|
|
Line 2177 void Pdp_td(NODE arg,Z *rp) |
|
Line 2194 void Pdp_td(NODE arg,Z *rp) |
|
STOZ(BDY(p)->dl->td,*rp); |
STOZ(BDY(p)->dl->td,*rp); |
} |
} |
|
|
|
void Pdpm_td(NODE arg,Z *rp) |
|
{ |
|
DPM p; |
|
|
|
p = (DPM)ARG0(arg); asir_assert(p,O_DPM,"dpm_td"); |
|
if ( !p ) |
|
*rp = 0; |
|
else |
|
STOZ(BDY(p)->dl->td,*rp); |
|
} |
|
|
void Pdp_sugar(NODE arg,Z *rp) |
void Pdp_sugar(NODE arg,Z *rp) |
{ |
{ |
DP p; |
DP p; |
Line 2417 void Pdp_dehomo(NODE arg,DP *rp) |
|
Line 2445 void Pdp_dehomo(NODE arg,DP *rp) |
|
dp_dehomo((DP)ARG0(arg),rp); |
dp_dehomo((DP)ARG0(arg),rp); |
} |
} |
|
|
|
void dpm_homo(DPM a,DPM *b); |
|
void dpm_dehomo(DPM a,DPM *b); |
|
|
|
void Pdpm_homo(NODE arg,DPM *rp) |
|
{ |
|
asir_assert(ARG0(arg),O_DPM,"dpm_homo"); |
|
dpm_homo((DPM)ARG0(arg),rp); |
|
} |
|
|
|
void Pdpm_dehomo(NODE arg,DPM *rp) |
|
{ |
|
asir_assert(ARG0(arg),O_DPM,"dpm_dehomo"); |
|
dpm_dehomo((DPM)ARG0(arg),rp); |
|
} |
|
|
|
|
void Pdp_gr_flags(NODE arg,LIST *rp) |
void Pdp_gr_flags(NODE arg,LIST *rp) |
{ |
{ |
Obj name,value; |
Obj name,value; |
Line 3915 void Pdpv_ord(NODE arg,Obj *rp) |
|
Line 3959 void Pdpv_ord(NODE arg,Obj *rp) |
|
} |
} |
|
|
extern int dpm_ordtype; |
extern int dpm_ordtype; |
|
extern DMMstack dmm_stack; |
|
|
void set_schreyer_order(LIST n); |
void set_schreyer_order(LIST n); |
|
|
LIST schreyer_obj; |
|
|
|
void Pdpm_set_schreyer(NODE arg,LIST *rp) |
void Pdpm_set_schreyer(NODE arg,LIST *rp) |
{ |
{ |
if ( argc(arg) ) { |
if ( argc(arg) ) { |
schreyer_obj = (LIST)ARG0(arg); |
set_schreyer_order((LIST)ARG0(arg)); |
set_schreyer_order(schreyer_obj); |
|
} |
} |
*rp = schreyer_obj; |
*rp = dmm_stack->obj; |
} |
} |
|
|
void Pdpm_hm(NODE arg,DPM *rp) |
void Pdpm_hm(NODE arg,DPM *rp) |
Line 4006 void Pdpm_split(NODE arg,LIST *rp) |
|
Line 4048 void Pdpm_split(NODE arg,LIST *rp) |
|
} |
} |
|
|
|
|
void Pdpm_hc(NODE arg,Obj *rp) |
void Pdpm_hc(NODE arg,DP *rp) |
{ |
{ |
|
DPM p; |
|
DP d; |
|
MP m; |
|
|
asir_assert(ARG0(arg),O_DPM,"dpm_hc"); |
asir_assert(ARG0(arg),O_DPM,"dpm_hc"); |
if ( !ARG0(arg) ) |
if ( !ARG0(arg) ) |
*rp = 0; |
*rp = 0; |
else |
else { |
*rp = BDY((DPM)ARG0(arg))->c; |
p = (DPM)ARG0(arg); |
|
NEWMP(m); |
|
m->dl = BDY(p)->dl; |
|
m->c = BDY(p)->c; |
|
NEXT(m) = 0; |
|
MKDP(NV(p),m,d); d->sugar = p->sugar; |
|
*rp = d; |
|
} |
} |
} |
|
|
|
|
void Pdpv_ht(NODE arg,LIST *rp) |
void Pdpv_ht(NODE arg,LIST *rp) |
{ |
{ |