version 1.7, 2010/06/02 04:25:46 |
version 1.12, 2014/09/05 11:55:19 |
|
|
|
/* $OpenXM: OpenXM/src/asir-contrib/testing/noro/pd.rr,v 1.11 2010/08/20 04:21:18 noro Exp $ */ |
import("gr")$ |
import("gr")$ |
module noro_pd$ |
module noro_pd$ |
|
|
static GBCheck,F4,Procs,SatHomo$ |
static GBCheck,F4,Procs,SatHomo$ |
|
|
localf init_procs, kill_procs, syca_dec, syc_dec, find_separating_ideal0$ |
localf init_procs, kill_procs, syca_dec, syc_dec, find_separating_ideal0$ |
|
|
while ( 1 ) { |
while ( 1 ) { |
if ( type(Gt[0])==1 ) break; |
if ( type(Gt[0])==1 ) break; |
T0 = time(); |
T0 = time(); |
Pt = prime_dec(Gt,V|indep=1,nolexdec=Nolexdec,mod=Mod); |
PtR = prime_dec(Gt,V|indep=1,nolexdec=Nolexdec,mod=Mod,radical=1); |
T1 = time(); Tass += T1[0]-T0[0]+T1[1]-T0[1]; Rass += T1[3]-T0[3]; |
T1 = time(); Tass += T1[0]-T0[0]+T1[1]-T0[1]; Rass += T1[3]-T0[3]; |
|
Pt = PtR[0]; IntPt = PtR[1]; |
|
if ( gen_gb_comp(Gt,IntPt,Mod) ) { |
|
/* Gt is radical and Gt = cap Pt */ |
|
for ( T = Pt, Qt = []; T != []; T = cdr(T) ) |
|
Qt = cons([car(T)[0],car(T)[0]],Qt); |
|
if ( First ) |
|
return [Qt,[]]; |
|
else |
|
Q0 = append(Qt,Q0); |
|
break; |
|
} |
T0 = time(); |
T0 = time(); |
Qt = iso_comp(Gt,Pt,V,Ord|mod=Mod,isgb=1); |
Qt = iso_comp(Gt,Pt,V,Ord|mod=Mod,isgb=1); |
T1 = time(); Tiso += T1[0]-T0[0]+T1[1]-T0[1]; Riso += T1[3]-T0[3]; |
T1 = time(); Tiso += T1[0]-T0[0]+T1[1]-T0[1]; Riso += T1[3]-T0[3]; |
IntQt = ideal_list_intersection(map(first_element,Qt),V,Ord|mod=Mod); |
IntQt = ideal_list_intersection(map(first_element,Qt),V,Ord|mod=Mod); |
IntPt = ideal_list_intersection(map(first_element,Pt),V,Ord|mod=Mod); |
|
if ( First ) { |
if ( First ) { |
IntQ0 = IntQ = IntQt; IntP = IntPt; Qi = Qt; First = 0; |
IntQ0 = IntQ = IntQt; IntP = IntPt; Qi = Qt; First = 0; |
} else { |
} else { |
|
|
else if ( SepIdeal == 2 ) |
else if ( SepIdeal == 2 ) |
Ok = find_separating_ideal2(C,G,IntQ,IntP,V,Ord|mod=Mod); |
Ok = find_separating_ideal2(C,G,IntQ,IntP,V,Ord|mod=Mod); |
G1 = append(Ok,G); |
G1 = append(Ok,G); |
Gt1 = fast_gb(G1,V,Mod,Ord); |
Gt1 = incremental_gb(G1,V,Ord|mod=Mod); |
T1 = time(); Tsep += T1[0]-T0[0]+T1[1]-T0[1]; Rsep += T1[3]-T0[3]; |
T1 = time(); Tsep += T1[0]-T0[0]+T1[1]-T0[1]; Rsep += T1[3]-T0[3]; |
#if 0 |
#if 0 |
if ( ideal_inclusion(Gt1,Gt,V,Ord|mod=Mod) ) { |
if ( ideal_inclusion(Gt1,Gt,V,Ord|mod=Mod) ) { |
|
|
while ( 1 ) { |
while ( 1 ) { |
if ( type(Gt[0])==1 ) break; |
if ( type(Gt[0])==1 ) break; |
T0 = time(); |
T0 = time(); |
Pt = prime_dec(Gt,V|indep=1,nolexdec=Nolexdec,mod=Mod); |
PtR = prime_dec(Gt,V|indep=1,nolexdec=Nolexdec,mod=Mod,radical=1); |
T1 = time(); Tass += T1[0]-T0[0]+T1[1]-T0[1]; Rass += T1[3]-T0[3]; |
T1 = time(); Tass += T1[0]-T0[0]+T1[1]-T0[1]; Rass += T1[3]-T0[3]; |
|
Pt = PtR[0]; IntPt = PtR[1]; |
|
if ( gen_gb_comp(Gt,IntPt,Mod) ) { |
|
/* Gt is radical and Gt = cap Pt */ |
|
for ( T = Pt, Qt = []; T != []; T = cdr(T) ) |
|
Qt = cons([car(T)[0],car(T)[0]],Qt); |
|
if ( First ) |
|
return [Qt,[]]; |
|
else |
|
Q = append(Qt,Q); |
|
break; |
|
} |
|
|
T0 = time(); |
T0 = time(); |
Qt = iso_comp(Gt,Pt,V,Ord|mod=Mod,isgb=1); |
Qt = iso_comp(Gt,Pt,V,Ord|mod=Mod,isgb=1); |
T1 = time(); Tiso += T1[0]-T0[0]+T1[1]-T0[1]; Riso += T1[3]-T0[3]; |
T1 = time(); Tiso += T1[0]-T0[0]+T1[1]-T0[1]; Riso += T1[3]-T0[3]; |
IntQt = ideal_list_intersection(map(first_element,Qt),V,Ord|mod=Mod); |
IntQt = ideal_list_intersection(map(first_element,Qt),V,Ord|mod=Mod); |
IntPt = ideal_list_intersection(map(first_element,Pt),V,Ord|mod=Mod); |
|
if ( First ) { |
if ( First ) { |
IntQ = IntQt; Qi = Qt; First = 0; |
IntQ = IntQt; Qi = Qt; First = 0; |
} else { |
} else { |
|
|
else if ( SepIdeal == 2 ) |
else if ( SepIdeal == 2 ) |
Ok = find_separating_ideal2(C,Gt,IntQt,IntPt,V,Ord|mod=Mod); |
Ok = find_separating_ideal2(C,Gt,IntQt,IntPt,V,Ord|mod=Mod); |
G1 = append(Ok,Gt); |
G1 = append(Ok,Gt); |
Gt = fast_gb(G1,V,Mod,Ord); |
Gt = incremental_gb(G1,V,Ord|mod=Mod); |
T1 = time(); Tsep += T1[0]-T0[0]+T1[1]-T0[1]; Rsep += T1[3]-T0[3]; |
T1 = time(); Tsep += T1[0]-T0[0]+T1[1]-T0[1]; Rsep += T1[3]-T0[3]; |
} |
} |
T0 = time(); |
T0 = time(); |
Line 255 def find_separating_ideal1(C,G,Q,Rad,V,Ord) { |
|
Line 276 def find_separating_ideal1(C,G,Q,Rad,V,Ord) { |
|
/* check whether (Q cap (G+S)) = G */ |
/* check whether (Q cap (G+S)) = G */ |
if ( gen_gb_comp(Int,G,Mod) ) return reverse(S); |
if ( gen_gb_comp(Int,G,Mod) ) return reverse(S); |
|
|
/* or qsort(C,comp_tdeg) */ |
/* or qsort(C,noro_pd.comp_tdeg) */ |
C = qsort(S,comp_tdeg); |
C = qsort(S,noro_pd.comp_tdeg); |
|
|
Tmp = ttttt; TV = cons(Tmp,V); Ord1 = [[0,1],[Ord,length(V)]]; |
Tmp = ttttt; TV = cons(Tmp,V); Ord1 = [[0,1],[Ord,length(V)]]; |
Int0 = incremental_gb(append(vtol(ltov(G)*Tmp),vtol(ltov(Q)*(1-Tmp))), |
Int0 = incremental_gb(append(vtol(ltov(G)*Tmp),vtol(ltov(Q)*(1-Tmp))), |
TV,Ord1|gbblock=[[0,length(G)]],mod=Mod); |
TV,Ord1|gbblock=[[0,length(G)]],mod=Mod); |
|
Dp = dp_gr_print(); dp_gr_print(0); |
for ( T = C, S = []; T != []; T = cdr(T) ) { |
for ( T = C, S = []; T != []; T = cdr(T) ) { |
if ( !gen_nf(car(T),Rad,V,Ord,Mod) ) continue; |
if ( !gen_nf(car(T),Rad,V,Ord,Mod) ) continue; |
Ui = U = car(T); |
Ui = U = car(T); |
Line 271 def find_separating_ideal1(C,G,Q,Rad,V,Ord) { |
|
Line 293 def find_separating_ideal1(C,G,Q,Rad,V,Ord) { |
|
else |
else |
Ui = gen_nf(Ui*U,G,V,Ord,Mod); |
Ui = gen_nf(Ui*U,G,V,Ord,Mod); |
} |
} |
|
print([length(T),I],2); |
Int1 = incremental_gb(append(Int0,[Tmp*Ui]),TV,Ord1 |
Int1 = incremental_gb(append(Int0,[Tmp*Ui]),TV,Ord1 |
|gbblock=[[0,length(Int0)]],mod=Mod); |
|gbblock=[[0,length(Int0)]],mod=Mod); |
Int = elimination(Int1,V); |
Int = elimination(Int1,V); |
if ( !gen_gb_comp(Int,G,Mod) ) |
if ( !gen_gb_comp(Int,G,Mod) ) { |
break; |
break; |
else { |
} else { |
Int0 = Int1; |
Int0 = Int1; |
S = cons(Ui,S); |
S = cons(Ui,S); |
} |
} |
} |
} |
|
print(""); |
|
dp_gr_print(Dp); |
return reverse(S); |
return reverse(S); |
} |
} |
|
|
Line 295 def find_separating_ideal2(C,G,Q,Rad,V,Ord) { |
|
Line 320 def find_separating_ideal2(C,G,Q,Rad,V,Ord) { |
|
/* check whether (Q cap (G+S)) = G */ |
/* check whether (Q cap (G+S)) = G */ |
if ( gen_gb_comp(Int,G,Mod) ) return reverse(S); |
if ( gen_gb_comp(Int,G,Mod) ) return reverse(S); |
|
|
/* or qsort(S,comp_tdeg) */ |
/* or qsort(S,noro_pd.comp_tdeg) */ |
C = qsort(C,comp_tdeg); |
C = qsort(C,noro_pd.comp_tdeg); |
Dp = dp_gr_print(); dp_gr_print(0); |
Dp = dp_gr_print(); dp_gr_print(0); |
for ( T = C, S = []; T != []; T = cdr(T) ) { |
for ( T = C, S = []; T != []; T = cdr(T) ) { |
if ( !gen_nf(car(T),Rad,V,Ord,Mod) ) continue; |
if ( !gen_nf(car(T),Rad,V,Ord,Mod) ) continue; |
Line 313 def find_separating_ideal2(C,G,Q,Rad,V,Ord) { |
|
Line 338 def find_separating_ideal2(C,G,Q,Rad,V,Ord) { |
|
S = cons(Ui,S); |
S = cons(Ui,S); |
} |
} |
print(""); |
print(""); |
S = qsort(S,comp_tdeg); |
S = qsort(S,noro_pd.comp_tdeg); |
/* S = reverse(S); */ |
End = Len = length(S); |
Len = length(S); |
|
|
|
Tmp = ttttt; TV = cons(Tmp,V); Ord1 = [[0,1],[Ord,length(V)]]; |
Tmp = ttttt; TV = cons(Tmp,V); Ord1 = [[0,1],[Ord,length(V)]]; |
if ( Len > 1 ) { |
Prev = 1; |
Prev = 1; |
G1 = append(G,[S[0]]); |
|
Int0 = incremental_gb(append(vtol(ltov(G1)*Tmp),vtol(ltov(Q)*(1-Tmp))), |
|
TV,Ord1|gbblock=[[0,length(G)]],mod=Mod); |
|
if ( End > 1 ) { |
Cur = 2; |
Cur = 2; |
G1 = append(G,[S[0]]); |
|
Int0 = incremental_gb(append(vtol(ltov(G1)*Tmp),vtol(ltov(Q)*(1-Tmp))), |
|
TV,Ord1|gbblock=[[0,length(G)]],mod=Mod); |
|
while ( Prev < Cur ) { |
while ( Prev < Cur ) { |
for ( St = [], I = Prev; I < Cur; I++ ) St = cons(Tmp*S[I],St); |
for ( St = [], I = Prev; I < Cur; I++ ) St = cons(Tmp*S[I],St); |
Int1 = incremental_gb(append(Int0,St),TV,Ord1 |
Int1 = incremental_gb(append(Int0,St),TV,Ord1 |
|gbblock=[[0,length(Int0)]],mod=Mod); |
|gbblock=[[0,length(Int0)]],mod=Mod); |
Int = elimination(Int1,V); |
Int = elimination(Int1,V); |
if ( gen_gb_comp(Int,G,Mod) ) { |
if ( gen_gb_comp(Int,G,Mod) ) { |
print(Cur); |
print([Cur],2); |
Prev = Cur; |
Prev = Cur; |
Cur = Cur+idiv(Len-Cur+1,2); |
Cur = Cur+idiv(End-Cur+1,2); |
Int0 = Int1; |
Int0 = Int1; |
} else { |
} else { |
|
End = Cur; |
Cur = Prev + idiv(Cur-Prev,2); |
Cur = Prev + idiv(Cur-Prev,2); |
} |
} |
} |
} |
for ( St = [], I = 0; I < Prev; I++ ) St = cons(S[I],St); |
for ( St = [], I = 0; I < Prev; I++ ) St = cons(S[I],St); |
Ok = reverse(St); |
|
} else |
} else |
Ok = [S[0]]; |
St = [S[0]]; |
|
print(""); |
|
for ( I = Prev; I < Len; I++ ) { |
|
Int1 = incremental_gb(append(Int0,[Tmp*S[I]]),TV,Ord1 |
|
|gbblock=[[0,length(Int0)]],mod=Mod); |
|
Int = elimination(Int1,V); |
|
if ( gen_gb_comp(Int,G,Mod) ) { |
|
print([I],2); |
|
St = cons(S[I],St); |
|
Int0 = Int1; |
|
} |
|
} |
|
Ok = reverse(St); |
|
print(""); |
print([length(S),length(Ok)]); |
print([length(S),length(Ok)]); |
dp_gr_print(Dp); |
dp_gr_print(Dp); |
return Ok; |
return Ok; |
Line 399 def pseudo_dec(G,L,V,Ord) |
|
Line 436 def pseudo_dec(G,L,V,Ord) |
|
for ( I = 0; I < N; I++ ) { |
for ( I = 0; I < N; I++ ) { |
LI = setminus(L0,[L0[I]]); |
LI = setminus(L0,[L0[I]]); |
PI = ideal_list_intersection(LI,V,Ord|mod=Mod); |
PI = ideal_list_intersection(LI,V,Ord|mod=Mod); |
PI = qsort(PI,comp_tdeg); |
PI = qsort(PI,noro_pd.comp_tdeg); |
for ( T = PI; T != []; T = cdr(T) ) |
for ( T = PI; T != []; T = cdr(T) ) |
if ( gen_nf(car(T),L0[I],V,Ord,Mod) ) break; |
if ( gen_nf(car(T),L0[I],V,Ord,Mod) ) break; |
if ( T == [] ) error("separator : cannot happen"); |
if ( T == [] ) error("separator : cannot happen"); |
SI = satind(G,car(T),V|mod=Mod); |
SI = sat_ind(G,car(T),V|mod=Mod); |
QI = SI[0]; |
QI = SI[0]; |
S[I] = car(T)^SI[1]; |
S[I] = car(T)^SI[1]; |
PV = L[I][1]; |
PV = L[I][1]; |
Line 417 def pseudo_dec(G,L,V,Ord) |
|
Line 454 def pseudo_dec(G,L,V,Ord) |
|
#endif |
#endif |
LCFI = lcfactor(GI,V0,Ord,Mod); |
LCFI = lcfactor(GI,V0,Ord,Mod); |
for ( F = 1, T = LCFI, Gt = QI; T != []; T = cdr(T) ) { |
for ( F = 1, T = LCFI, Gt = QI; T != []; T = cdr(T) ) { |
St = satind(Gt,T[0],V|mod=Mod); |
St = sat_ind(Gt,T[0],V|mod=Mod); |
Gt = St[0]; F *= T[0]^St[1]; |
Gt = St[0]; F *= T[0]^St[1]; |
} |
} |
Q[I] = [Gt,L0[I]]; |
Q[I] = [Gt,L0[I]]; |
Line 473 def prima_dec(B,V) |
|
Line 510 def prima_dec(B,V) |
|
L = zprimacomp(G,V0|mod=Mod); |
L = zprimacomp(G,V0|mod=Mod); |
F = 1; |
F = 1; |
for ( T = LCF, G2 = G; T != []; T = cdr(T) ) { |
for ( T = LCF, G2 = G; T != []; T = cdr(T) ) { |
S = satind(G2,T[0],V1|mod=Mod); |
S = sat_ind(G2,T[0],V1|mod=Mod); |
G2 = S[0]; F *= T[0]^S[1]; |
G2 = S[0]; F *= T[0]^S[1]; |
} |
} |
for ( T = L, QL = []; T != []; T = cdr(T) ) |
for ( T = L, QL = []; T != []; T = cdr(T) ) |
Line 495 def prime_dec(B,V) |
|
Line 532 def prime_dec(B,V) |
|
if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; |
if ( type(Mod=getopt(mod)) == -1 ) Mod = 0; |
if ( type(Indep=getopt(indep)) == -1 ) Indep = 0; |
if ( type(Indep=getopt(indep)) == -1 ) Indep = 0; |
if ( type(NoLexDec=getopt(nolexdec)) == -1 ) NoLexDec = 0; |
if ( type(NoLexDec=getopt(nolexdec)) == -1 ) NoLexDec = 0; |
|
if ( type(Rad=getopt(radical)) == -1 ) Rad = 0; |
B = map(sq,B,Mod); |
B = map(sq,B,Mod); |
if ( !NoLexDec ) |
if ( !NoLexDec ) |
PD = lex_predec1(B,V|mod=Mod); |
PD = lex_predec1(B,V|mod=Mod); |
Line 512 def prime_dec(B,V) |
|
Line 550 def prime_dec(B,V) |
|
G = ideal_list_intersection(R,V,0|mod=Mod); |
G = ideal_list_intersection(R,V,0|mod=Mod); |
if ( !NoLexDec ) R = pd_remove_redundant_comp(G,R,V,0|mod=Mod); |
if ( !NoLexDec ) R = pd_remove_redundant_comp(G,R,V,0|mod=Mod); |
} |
} |
return R; |
return Rad ? [R,G] : R; |
} |
} |
|
|
def prime_dec_main(B,V) |
def prime_dec_main(B,V) |
Line 1179 def ideal_product(A,B,V) |
|
Line 1217 def ideal_product(A,B,V) |
|
for ( T = PA; T != []; T = cdr(T) ) |
for ( T = PA; T != []; T = cdr(T) ) |
for ( S = PB; S != []; S = cdr(S) ) |
for ( S = PB; S != []; S = cdr(S) ) |
R = cons([car(T)[0]*car(S)[0],car(T)[1]+car(S)[1]],R); |
R = cons([car(T)[0]*car(S)[0],car(T)[1]+car(S)[1]],R); |
T = qsort(R,comp_by_second); |
T = qsort(R,noro_pd.comp_by_second); |
T = map(first_element,T); |
T = map(first_element,T); |
Len = length(A)>length(B)?length(A):length(B); |
Len = length(A)>length(B)?length(A):length(B); |
Len *= 2; |
Len *= 2; |