| version 1.3, 2003/11/05 08:26:57 |
version 1.4, 2003/11/11 05:10:24 |
|
|
| load("solve")$
|
load("solve")$ |
| load("gr")$
|
load("gr")$ |
|
|
|
| def nonposdegchk(Res){
|
def nonposdegchk(Res){ |
|
|
|
| for(I=0;I<length(Res);I++)
|
for(I=0;I<length(Res);I++) |
| if(Res[I][1]<=0)
|
if(Res[I][1]<=0) |
| return 0$
|
return 0$ |
|
|
|
| return 1$
|
return 1$ |
| }
|
} |
|
|
|
| def resvars(Res,Vars){
|
def resvars(Res,Vars){ |
|
|
|
| ResVars=newvect(length(Vars),Vars)$
|
ResVars=newvect(length(Vars),Vars)$ |
|
|
for(I=0;I<length(Res);I++){ |
| for(I=0;I<length(Res);I++){
|
|
|
|
for(J=0;J<size(ResVars)[0];J++) |
| for(J=0;J<size(ResVars)[0];J++)
|
if(Res[I][0]==ResVars[J]) |
| if(Res[I][0]==ResVars[J])
|
break$ |
| break$
|
|
|
|
if(J<size(ResVars)[0]) |
| ResVars[J]=Res[I][1]$
|
ResVars[J]=Res[I][1]$ |
| }
|
} |
|
|
return(ResVars)$ |
| return(ResVars)$
|
} |
| }
|
|
|
|
def makeret1(Res,Vars){ |
| def makeret1(Res,Vars){
|
|
|
|
VarsNum=length(Vars)$ |
| VarsNum=length(Vars)$
|
|
|
|
ResVec=newvect(VarsNum,Vars)$ |
| ResVec=newvect(VarsNum,Vars)$
|
|
|
|
for(I=0,M=0;I<length(Res);I++){ |
| for(I=0,M=0;I<length(Res);I++){
|
|
|
|
for(J=0;J<VarsNum;J++) |
| for(J=0;J<VarsNum;J++)
|
if(Res[I][0]==Vars[J]) |
| if(Res[I][0]==Vars[J])
|
break$ |
| break$
|
|
|
|
if(J<VarsNum){ |
| if(J<VarsNum){
|
ResVec[J]=Res[I][1]$ |
| ResVec[J]=Res[I][1]$
|
|
|
|
if(type(ResVec[J])==1){ |
| if(type(ResVec[J])==1){
|
if(M==0) |
| if(M==0)
|
M=ResVec[J]$ |
| M=ResVec[J]$
|
else |
| else
|
if(ResVec[J]<M) |
| if(ResVec[J]<M)
|
M=ResVec[J]$ |
| M=ResVec[J]$
|
} |
| }
|
} |
| }
|
|
|
|
} |
| }
|
|
|
|
for(F=0,I=0;I<VarsNum;I++) |
| for(F=0,I=0;I<VarsNum;I++)
|
if(type(ResVec[I])!=1){ |
| if(type(ResVec[I])!=1){
|
F=1$ |
| F=1$
|
break$ |
| break$
|
} |
| }
|
|
|
|
if(F==0) |
| if(F==0)
|
for(I=0;I<VarsNum;I++) |
| for(I=0;I<VarsNum;I++)
|
ResVec[I]=ResVec[I]/M*1.0$ |
| ResVec[I]=ResVec[I]/M*1.0$
|
|
|
|
for(I=0;I<VarsNum;I++) |
| for(I=0;I<VarsNum;I++)
|
for(J=0;J<length(Vars);J++) |
| for(J=0;J<length(Vars);J++)
|
ResVec[I]=subst(ResVec[I],Vars[J], |
| ResVec[I]=subst(ResVec[I],Vars[J],
|
strtov(rtostr(Vars[J])+"_deg"))$ |
| strtov(rtostr(Vars[J])+"_deg"))$
|
|
|
|
ResVec=cons(F,vtol(ResVec))$ |
| ResVec=cons(F,vtol(ResVec))$
|
return ResVec$ |
| return ResVec$
|
} |
| }
|
|
|
|
def junban1(A,B){ |
| def junban1(A,B){
|
return (nmono(A)<nmono(B) ? -1:(nmono(A)>nmono(B) ? 1:0))$ |
| return (nmono(A)<nmono(B) ? -1:(nmono(A)>nmono(B) ? 1:0))$
|
} |
| }
|
|
|
|
def junban2(A,B){ |
| def junban2(A,B){
|
|
|
|
for(I=0;I<size(A)[0];I++){ |
| for(I=0;I<size(A)[0];I++){
|
if(A[I]<B[I]) |
| if(A[I]<B[I])
|
return 1$ |
| return 1$
|
|
|
|
if(A[I]>B[I]) |
| if(A[I]>B[I])
|
return -1$ |
| return -1$
|
} |
| }
|
|
|
|
return 0$ |
| return 0$
|
} |
| }
|
|
|
|
def roundret(V){ |
| def roundret(V){
|
|
|
|
VN=length(V)$ |
| VN=length(V)$
|
RET0=newvect(VN,V)$ |
| RET0=newvect(VN,V)$
|
|
|
|
for(I=1;I<1000;I++){ |
| for(I=1;I<1000;I++){
|
RET1=I*RET0$ |
| RET1=I*RET0$
|
for(J=0;J<VN;J++){ |
| for(J=0;J<VN;J++){
|
X=drint(RET1[J])$ |
| X=drint(RET1[J])$
|
if(dabs(X-RET1[J])<0.2) |
| if(dabs(X-RET1[J])<0.2)
|
RET1[J]=X$ |
| RET1[J]=X$
|
else |
| else
|
break$ |
| break$
|
} |
| }
|
if(J==VN) |
| if(J==VN)
|
break$ |
| break$
|
} |
| }
|
|
|
|
if(I==1000) |
| if(I==1000)
|
return []$ |
| return []$
|
else |
| else
|
return RET1$ |
| return RET1$
|
} |
| }
|
|
|
|
def chkou(L,ExpMat,CHAGORD){ |
| def chkou(L,ExpMat,CHAGORD){
|
|
|
|
P=1$ |
| P=1$
|
F=ExpMat[L]$ |
| F=ExpMat[L]$
|
|
|
|
for(I=0;I<L;I++){ |
| for(I=0;I<L;I++){
|
Q=ExpMat[L][CHAGORD[I]]$ |
| Q=ExpMat[L][CHAGORD[I]]$
|
for(J=0;J<size(ExpMat[0])[0];J++){ |
| for(J=0;J<size(ExpMat[0])[0];J++){
|
ExpMat[L][CHAGORD[J]]=red((ExpMat[I][CHAGORD[I]] |
| ExpMat[L][CHAGORD[J]]=red((ExpMat[I][CHAGORD[I]]
|
*ExpMat[L][CHAGORD[J]]- |
| *ExpMat[L][CHAGORD[J]]-
|
Q*ExpMat[I][CHAGORD[J]])/P)$ |
| Q*ExpMat[I][CHAGORD[J]])/P)$
|
} |
| }
|
|
|
|
P=ExpMat[I][CHAGORD[I]]$ |
| P=ExpMat[I][CHAGORD[I]]$
|
} |
| }
|
|
|
|
for(J=0;J<size(ExpMat[0])[0];J++) |
| for(J=0;J<size(ExpMat[0])[0];J++)
|
if(ExpMat[L][CHAGORD[J]]!=0) |
| if(ExpMat[L][CHAGORD[J]]!=0)
|
break$ |
| break$
|
|
|
|
if(J==size(ExpMat[0])[0]) |
| if(J==size(ExpMat[0])[0])
|
return L$ |
| return L$
|
else{ |
| else{
|
TMP=CHAGORD[L]$ |
| TMP=CHAGORD[L]$
|
CHAGORD[L]=CHAGORD[J]$ |
| CHAGORD[L]=CHAGORD[J]$
|
CHAGORD[J]=TMP$ |
| CHAGORD[J]=TMP$
|
return (L+1)$ |
| return (L+1)$
|
} |
| }
|
} |
| }
|
|
|
|
def qcheck0(PolyList,Vars){ |
| def qcheck0(PolyList,Vars){
|
|
|
|
RET=[]$ |
| RET=[]$
|
PolyListNum=length(PolyList)$ |
| PolyListNum=length(PolyList)$
|
VarsNum=length(Vars)$ |
| VarsNum=length(Vars)$
|
|
|
|
ExpMat=newvect(VarsNum)$ |
| ExpMat=newvect(VarsNum)$
|
CHAGORD=newvect(VarsNum)$ |
| CHAGORD=newvect(VarsNum)$
|
for(I=0;I<VarsNum;I++) |
| for(I=0;I<VarsNum;I++)
|
CHAGORD[I]=I$ |
| CHAGORD[I]=I$
|
|
|
|
L=0$ |
| L=0$
|
for(I=0;I<PolyListNum;I++){ |
| for(I=0;I<PolyListNum;I++){
|
Poly=dp_ptod(PolyList[I],Vars)$ |
| Poly=dp_ptod(PolyList[I],Vars)$
|
BASE0=dp_etov(dp_ht(Poly))$ |
| BASE0=dp_etov(dp_ht(Poly))$
|
Poly=dp_rest(Poly)$ |
| Poly=dp_rest(Poly)$
|
for(;Poly!=0;Poly=dp_rest(Poly)){ |
| for(;Poly!=0;Poly=dp_rest(Poly)){
|
ExpMat[L]=dp_etov(dp_ht(Poly))-BASE0$ |
| ExpMat[L]=dp_etov(dp_ht(Poly))-BASE0$
|
L=chkou(L,ExpMat,CHAGORD)$ |
| L=chkou(L,ExpMat,CHAGORD)$
|
if(L==VarsNum-1){ |
| if(L==VarsNum-1){
|
RET=cons(ExpMat,RET)$ |
| RET=cons(ExpMat,RET)$
|
RET=cons(CHAGORD,RET)$ |
| RET=cons(CHAGORD,RET)$
|
RET=cons(L,RET)$ |
| RET=cons(L,RET)$
|
return RET$ |
| return RET$
|
} |
| }
|
} |
| }
|
} |
| }
|
|
|
|
RET=cons(ExpMat,RET)$ |
| RET=cons(ExpMat,RET)$
|
RET=cons(CHAGORD,RET)$ |
| RET=cons(CHAGORD,RET)$
|
RET=cons(L,RET)$ |
| RET=cons(L,RET)$
|
return RET$ |
| return RET$
|
} |
| }
|
|
|
|
def inner(A,B){ |
| def inner(A,B){
|
|
|
|
SUM=0$ |
| SUM=0$
|
for(I=0;I<size(A)[0];I++) |
| for(I=0;I<size(A)[0];I++)
|
SUM+=A[I]*B[I]$ |
| SUM+=A[I]*B[I]$
|
|
|
|
return SUM$ |
| return SUM$
|
} |
| }
|
|
|
|
def checktd(PolyList,Vars,ResVars){ |
| def checktd(PolyList,Vars,ResVars){
|
|
|
|
PolyListNum=length(PolyList)$ |
| PolyListNum=length(PolyList)$
|
VarsNum=length(Vars)$ |
| VarsNum=length(Vars)$
|
|
|
|
L=0$ |
| L=0$
|
for(I=0;I<PolyListNum;I++){ |
| for(I=0;I<PolyListNum;I++){
|
Poly=dp_ptod(PolyList[I],Vars)$ |
| Poly=dp_ptod(PolyList[I],Vars)$
|
J0=inner(dp_etov(dp_ht(Poly)),ResVars)$ |
| J0=inner(dp_etov(dp_ht(Poly)),ResVars)$
|
Poly=dp_rest(Poly)$ |
| Poly=dp_rest(Poly)$
|
for(;Poly!=0;Poly=dp_rest(Poly)) |
| for(;Poly!=0;Poly=dp_rest(Poly))
|
if(J0!=inner(dp_etov(dp_ht(Poly)),ResVars)) |
| if(J0!=inner(dp_etov(dp_ht(Poly)),ResVars))
|
return 0$ |
| return 0$
|
} |
| }
|
|
|
|
return 1$ |
| return 1$
|
} |
| }
|
|
|
|
def getgcd(A,B){ |
| def getgcd(A,B){
|
|
|
|
VarsNumA=length(A)$ |
| VarsNumA=length(A)$
|
VarsNumB=length(B)$ |
| VarsNumB=length(B)$
|
|
|
|
C=newvect(VarsNumB,B)$ |
| C=newvect(VarsNumB,B)$
|
|
|
|
for(I=0;I<VarsNumA;I++){ |
| for(I=0;I<VarsNumA;I++){
|
|
|
|
for(J=0;J<VarsNumB;J++) |
| for(J=0;J<VarsNumB;J++)
|
if(C[J]==A[I][0]) |
| if(C[J]==A[I][0])
|
break$ |
| break$
|
|
|
|
C[J]=A[I][1]$ |
| C[J]=A[I][1]$
|
} |
| }
|
|
|
|
D=0$ |
| D=0$
|
for(I=0;I<VarsNumB;I++) |
| for(I=0;I<VarsNumB;I++)
|
D=gcd(D,C[I])$ |
| D=gcd(D,C[I])$
|
|
|
|
if(D!=0){ |
| if(D!=0){
|
|
|
|
for(I=0;I<VarsNumB;I++) |
| for(I=0;I<VarsNumB;I++)
|
C[I]=red(C[I]/D)$ |
| C[I]=red(C[I]/D)$
|
|
|
|
} |
| }
|
|
|
|
for(L=1,D=0,I=0;I<VarsNumB;I++) |
| for(L=1,D=0,I=0;I<VarsNumB;I++){
|
if(type(C[I])==1){ |
|
|
L=ilcm(L,dn(C[I]))$ |
| if(type(C[I])==1){
|
D=igcd(D,nm(C[I]))$ |
| L=ilcm(L,dn(C[I]))$
|
} |
| D=igcd(D,nm(C[I]))$
|
|
| }
|
for(I=0;I<VarsNumB;I++) |
| else
|
C[I]=C[I]*L$ |
| break$
|
|
|
|
if(D!=0) |
| }
|
for(I=0;I<VarsNumB;I++) |
|
|
C[I]=C[I]/D$ |
| if(I==VarsNumB)
|
|
| for(I=0;I<VarsNumB;I++)
|
|
| C[I]=C[I]*L/D$
|
RET=newvect(VarsNumB)$ |
|
|
for(I=0;I<VarsNumB;I++){ |
| RET=newvect(VarsNumB)$
|
RET[I]=newvect(2)$ |
| for(I=0;I<VarsNumB;I++){
|
RET[I][0]=B[I]$ |
| RET[I]=newvect(2)$
|
RET[I][1]=C[I]$ |
| RET[I][0]=B[I]$
|
} |
| RET[I][1]=C[I]$
|
|
| }
|
return vtol(map(vtol,RET))$ |
|
|
} |
| return vtol(map(vtol,RET))$
|
|
| }
|
def qcheck(PolyList,Vars){ |
|
|
|
| def qcheck(PolyList,Vars){
|
RET=[]$ |
|
|
Res=qcheck0(PolyList,Vars)$ |
| RET=[]$
|
VarsNum=length(Vars)$ |
| Res=qcheck0(PolyList,Vars)$
|
|
| VarsNum=length(Vars)$
|
IndNum=Res[0]$ |
|
|
CHAGORD=Res[1]$ |
| IndNum=Res[0]$
|
ExpMat=Res[2]$ |
| CHAGORD=Res[1]$
|
|
| ExpMat=Res[2]$
|
SolveList=[]$ |
|
|
for(I=0;I<IndNum;I++){ |
| SolveList=[]$
|
TMP=0$ |
| for(I=0;I<IndNum;I++){
|
for(J=0;J<VarsNum;J++) |
| TMP=0$
|
TMP+=ExpMat[I][CHAGORD[J]]*Vars[CHAGORD[J]]$ |
| for(J=0;J<VarsNum;J++)
|
|
| TMP+=ExpMat[I][CHAGORD[J]]*Vars[CHAGORD[J]]$
|
SolveList=cons(TMP,SolveList)$ |
|
|
} |
| SolveList=cons(TMP,SolveList)$
|
|
| }
|
VarsList=[]$ |
|
|
for(I=0;I<VarsNum;I++) |
| VarsList=[]$
|
VarsList=cons(Vars[CHAGORD[I]],VarsList)$ |
| for(I=0;I<VarsNum;I++)
|
|
| VarsList=cons(Vars[CHAGORD[I]],VarsList)$
|
Rea=vars(SolveList)$ |
|
|
Res=solve(reverse(SolveList),reverse(VarsList))$ |
| Rea=vars(SolveList)$
|
|
| Res=solve(reverse(SolveList),reverse(VarsList))$
|
if(nonposdegchk(Res)){ |
|
|
|
| if(nonposdegchk(Res)){
|
Res=getgcd(Res,Rea)$ |
|
|
ResVars=resvars(Res,Vars)$ |
| Res=getgcd(Res,Rea)$
|
|
| ResVars=resvars(Res,Vars)$
|
if(checktd(PolyList,Vars,ResVars)==1){ |
|
|
|
| if(checktd(PolyList,Vars,ResVars)==1){
|
for(J=0;J<length(Vars);J++) |
|
|
ResVars=map(subst,ResVars,Vars[J], |
| for(J=0;J<length(Vars);J++)
|
strtov(rtostr(Vars[J])+"_deg"))$ |
| ResVars=map(subst,ResVars,Vars[J],
|
|
| strtov(rtostr(Vars[J])+"_deg"))$
|
RET=cons([vtol(ResVars),ResVars,[]],RET)$ |
|
|
return cons(1,RET)$ |
| RET=cons([vtol(ResVars),ResVars,[]],RET)$
|
} |
| return cons(1,RET)$
|
else |
| }
|
return cons(0,RET)$ |
| else
|
} |
| return cons(0,RET)$
|
else |
| }
|
return cons(0,RET)$ |
| else
|
|
| return cons(0,RET)$
|
} |
|
|
|
| }
|
def weight(PolyList,Vars){ |
|
|
|
| def weight(PolyList,Vars){
|
Vars0=vars(PolyList)$ |
|
|
Vars1=[]$ |
| Vars0=vars(PolyList)$
|
for(I=0;I<length(Vars);I++) |
| Vars1=[]$
|
if(member(Vars[I],Vars0)) |
| for(I=0;I<length(Vars);I++)
|
Vars1=cons(Vars[I],Vars1)$ |
| if(member(Vars[I],Vars0))
|
|
| Vars1=cons(Vars[I],Vars1)$
|
Vars=reverse(Vars1)$ |
|
|
|
| Vars=reverse(Vars1)$
|
RET=[]$ |
|
|
|
| RET=[]$
|
TMP=qcheck(PolyList,Vars)$ |
|
|
|
| TMP=qcheck(PolyList,Vars)$
|
if(car(TMP)==1){ |
|
|
RET=cdr(TMP)$ |
| if(car(TMP)==1){
|
RET=cons(Vars,RET)$ |
| RET=cdr(TMP)$
|
RET=cons(1,RET)$ |
| RET=cons(Vars,RET)$
|
return RET$ |
| RET=cons(1,RET)$
|
} |
| return RET$
|
|
| }
|
dp_ord(2)$ |
|
|
|
| dp_ord(2)$
|
PolyListNum=length(PolyList)$ |
|
|
VPolyList=qsort(newvect(PolyListNum,PolyList),junban1)$ |
| PolyListNum=length(PolyList)$
|
VPolyList=vtol(VPolyList)$ |
| VPolyList=qsort(newvect(PolyListNum,PolyList),junban1)$
|
|
| VPolyList=vtol(VPolyList)$
|
ExpMat=[]$ |
|
|
for(I=0;I<PolyListNum;I++) |
| ExpMat=[]$
|
for(Poly=dp_ptod(VPolyList[I],Vars);Poly!=0;Poly=dp_rest(Poly)) |
| for(I=0;I<PolyListNum;I++)
|
ExpMat=cons(dp_etov(dp_ht(Poly)),ExpMat)$ |
| for(Poly=dp_ptod(VPolyList[I],Vars);Poly!=0;Poly=dp_rest(Poly))
|
|
| ExpMat=cons(dp_etov(dp_ht(Poly)),ExpMat)$
|
ExpMat=reverse(ExpMat)$ |
|
|
ExpMat=newvect(length(ExpMat),ExpMat)$ |
| ExpMat=reverse(ExpMat)$
|
|
| ExpMat=newvect(length(ExpMat),ExpMat)$
|
|
|
|
/* first */ |
|
|
|
| /* first */
|
ExpMatRowNum=size(ExpMat)[0]$ |
|
|
ExpMatColNum=size(ExpMat[0])[0]$ |
| ExpMatRowNum=size(ExpMat)[0]$
|
ExtMatColNum=ExpMatColNum+PolyListNum$ |
| ExpMatColNum=size(ExpMat[0])[0]$
|
|
| ExtMatColNum=ExpMatColNum+PolyListNum$
|
OneMat=newvect(PolyListNum+1,[0])$ |
|
|
for(I=0,SUM=0;I<PolyListNum;I++){ |
| OneMat=newvect(PolyListNum+1,[0])$
|
SUM+=nmono(VPolyList[I])$ |
| for(I=0,SUM=0;I<PolyListNum;I++){
|
OneMat[I+1]=SUM$ |
| SUM+=nmono(VPolyList[I])$
|
} |
| OneMat[I+1]=SUM$
|
|
| }
|
RevOneMat=newvect(ExpMatRowNum)$ |
|
|
for(I=0;I<PolyListNum;I++) |
| RevOneMat=newvect(ExpMatRowNum)$
|
for(J=OneMat[I];J<OneMat[I+1];J++) |
| for(I=0;I<PolyListNum;I++)
|
RevOneMat[J]=I$ |
| for(J=OneMat[I];J<OneMat[I+1];J++)
|
|
| RevOneMat[J]=I$
|
NormMat=newmat(ExpMatColNum,ExtMatColNum)$ |
|
|
|
| NormMat=newmat(ExpMatColNum,ExtMatColNum)$
|
for(I=0;I<ExpMatColNum;I++) |
|
|
for(J=0;J<ExpMatColNum;J++) |
| for(I=0;I<ExpMatColNum;I++)
|
for(K=0;K<ExpMatRowNum;K++) |
| for(J=0;J<ExpMatColNum;J++)
|
NormMat[I][J]+=ExpMat[K][I]*ExpMat[K][J]$ |
| for(K=0;K<ExpMatRowNum;K++)
|
|
| NormMat[I][J]+=ExpMat[K][I]*ExpMat[K][J]$
|
for(I=0;I<ExpMatColNum;I++) |
|
|
for(J=0;J<PolyListNum-1;J++) |
| for(I=0;I<ExpMatColNum;I++)
|
for(K=OneMat[J];K<OneMat[J+1];K++) |
| for(J=0;J<PolyListNum-1;J++)
|
NormMat[I][J+ExpMatColNum]-=ExpMat[K][I]$ |
| for(K=OneMat[J];K<OneMat[J+1];K++)
|
|
| NormMat[I][J+ExpMatColNum]-=ExpMat[K][I]$
|
for(I=0;I<ExpMatColNum;I++) |
|
|
for(J=OneMat[PolyListNum-1];J<OneMat[PolyListNum];J++) |
| for(I=0;I<ExpMatColNum;I++)
|
NormMat[I][ExtMatColNum-1]+=ExpMat[J][I]$ |
| for(J=OneMat[PolyListNum-1];J<OneMat[PolyListNum];J++)
|
|
| NormMat[I][ExtMatColNum-1]+=ExpMat[J][I]$
|
NormMat2=newmat(PolyListNum-1,ExpMatColNum+1)$ |
|
|
|
| NormMat2=newmat(PolyListNum-1,ExpMatColNum+1)$
|
for(I=0;I<PolyListNum-1;I++) |
|
|
for(J=0;J<ExpMatColNum;J++) |
| for(I=0;I<PolyListNum-1;I++)
|
for(K=OneMat[I];K<OneMat[I+1];K++) |
| for(J=0;J<ExpMatColNum;J++)
|
NormMat2[I][J]-=ExpMat[K][J]$ |
| for(K=OneMat[I];K<OneMat[I+1];K++)
|
|
| NormMat2[I][J]-=ExpMat[K][J]$
|
for(I=0;I<PolyListNum-1;I++) |
|
|
NormMat2[I][ExpMatColNum]=OneMat[I+1]-OneMat[I]$ |
| for(I=0;I<PolyListNum-1;I++)
|
|
| NormMat2[I][ExpMatColNum]=OneMat[I+1]-OneMat[I]$
|
ExtVars=Vars$ |
|
|
for(I=0;I<PolyListNum-1;I++) |
| ExtVars=Vars$
|
ExtVars=append(ExtVars,[uc()])$ |
| for(I=0;I<PolyListNum-1;I++)
|
|
| ExtVars=append(ExtVars,[uc()])$
|
SolveList=[]$ |
|
|
for(I=0;I<ExpMatColNum;I++){ |
| SolveList=[]$
|
TMP=0$ |
| for(I=0;I<ExpMatColNum;I++){
|
for(J=0;J<ExtMatColNum-1;J++) |
| TMP=0$
|
TMP+=NormMat[I][J]*ExtVars[J]$ |
| for(J=0;J<ExtMatColNum-1;J++)
|
|
| TMP+=NormMat[I][J]*ExtVars[J]$
|
TMP-=NormMat[I][ExtMatColNum-1]$ |
|
|
SolveList=cons(TMP,SolveList)$ |
| TMP-=NormMat[I][ExtMatColNum-1]$
|
} |
| SolveList=cons(TMP,SolveList)$
|
|
| }
|
for(I=0;I<PolyListNum-1;I++){ |
|
|
TMP=0$ |
| for(I=0;I<PolyListNum-1;I++){
|
for(J=0;J<ExpMatColNum;J++) |
| TMP=0$
|
TMP+=NormMat2[I][J]*ExtVars[J]$ |
| for(J=0;J<ExpMatColNum;J++)
|
|
| TMP+=NormMat2[I][J]*ExtVars[J]$
|
TMP+=NormMat2[I][ExpMatColNum]*ExtVars[I+ExpMatColNum]$ |
|
|
|
| TMP+=NormMat2[I][ExpMatColNum]*ExtVars[I+ExpMatColNum]$
|
SolveList=cons(TMP,SolveList)$ |
|
|
} |
| SolveList=cons(TMP,SolveList)$
|
|
| }
|
Rea=vars(SolveList)$ |
|
|
Res=solve(SolveList,reverse(ExtVars))$ |
| Rea=vars(SolveList)$
|
|
| Res=solve(SolveList,reverse(ExtVars))$
|
if(nonposdegchk(Res)){ |
|
|
Res=getgcd(Res,Rea)$ |
| if(nonposdegchk(Res)){
|
TMP1=makeret1(Res,Vars); |
| Res=getgcd(Res,Rea)$
|
if(car(TMP1)==0){ |
| TMP1=makeret1(Res,Vars);
|
TMP2=roundret(cdr(TMP1)); |
| if(car(TMP1)==0){
|
TMP3=map(drint,cdr(TMP1))$ |
| TMP2=roundret(cdr(TMP1));
|
RET=cons([cdr(TMP1),newvect(length(TMP3),TMP3),TMP2],RET)$ |
| TMP3=map(drint,cdr(TMP1))$
|
} |
| RET=cons([cdr(TMP1),newvect(length(TMP3),TMP3),TMP2],RET)$
|
else |
| }
|
RET=cons([cdr(TMP1),[],[]],RET)$ |
| else
|
} |
| RET=cons([cdr(TMP1),[],[]],RET)$
|
|
| }
|
/* second */ |
|
|
|
| /* second */
|
NormMat=newmat(ExpMatColNum,ExpMatColNum+1)$ |
|
|
|
| NormMat=newmat(ExpMatColNum,ExpMatColNum+1)$
|
for(I=0;I<ExpMatColNum;I++) |
|
|
for(J=0;J<ExpMatColNum;J++) |
| for(I=0;I<ExpMatColNum;I++)
|
for(K=0;K<ExpMatRowNum;K++) |
| for(J=0;J<ExpMatColNum;J++)
|
NormMat[I][J]+=ExpMat[K][I]*ExpMat[K][J]$ |
| for(K=0;K<ExpMatRowNum;K++)
|
|
| NormMat[I][J]+=ExpMat[K][I]*ExpMat[K][J]$
|
for(I=0;I<ExpMatColNum;I++) |
|
|
for(J=0;J<ExpMatRowNum;J++) |
| for(I=0;I<ExpMatColNum;I++)
|
NormMat[I][ExpMatColNum]+=ExpMat[J][I]$ |
| for(J=0;J<ExpMatRowNum;J++)
|
|
| NormMat[I][ExpMatColNum]+=ExpMat[J][I]$
|
SolveList=[]$ |
|
|
for(I=0;I<ExpMatColNum;I++){ |
| SolveList=[]$
|
TMP=0$ |
| for(I=0;I<ExpMatColNum;I++){
|
for(J=0;J<ExpMatColNum;J++) |
| TMP=0$
|
TMP+=NormMat[I][J]*Vars[J]$ |
| for(J=0;J<ExpMatColNum;J++)
|
|
| TMP+=NormMat[I][J]*Vars[J]$
|
TMP-=NormMat[I][ExpMatColNum]$ |
|
|
SolveList=cons(TMP,SolveList)$ |
| TMP-=NormMat[I][ExpMatColNum]$
|
} |
| SolveList=cons(TMP,SolveList)$
|
|
| }
|
Rea=vars(SolveList)$ |
|
|
Res=solve(SolveList,Vars)$ |
| Rea=vars(SolveList)$
|
|
| Res=solve(SolveList,Vars)$
|
if(nonposdegchk(Res)){ |
|
|
Res=getgcd(Res,Rea)$ |
| if(nonposdegchk(Res)){
|
TMP1=makeret1(Res,Vars); |
| Res=getgcd(Res,Rea)$
|
if(car(TMP1)==0){ |
| TMP1=makeret1(Res,Vars);
|
TMP2=roundret(cdr(TMP1)); |
| if(car(TMP1)==0){
|
TMP3=map(drint,cdr(TMP1))$ |
| TMP2=roundret(cdr(TMP1));
|
RET=cons([cdr(TMP1),newvect(length(TMP3),TMP3),TMP2],RET)$ |
| TMP3=map(drint,cdr(TMP1))$
|
} |
| RET=cons([cdr(TMP1),newvect(length(TMP3),TMP3),TMP2],RET)$
|
else |
| }
|
RET=cons([cdr(TMP1),[],[]],RET)$ |
| else
|
} |
| RET=cons([cdr(TMP1),[],[]],RET)$
|
|
| }
|
/* third */ |
|
|
|
| /* third */
|
ExpMat=qsort(ExpMat,junban2)$ |
|
|
ExpMat2=[]$ |
| ExpMat=qsort(ExpMat,junban2)$
|
for(I=0;I<size(ExpMat)[0];I++) |
| ExpMat2=[]$
|
if(car(ExpMat2)!=ExpMat[I]) |
| for(I=0;I<size(ExpMat)[0];I++)
|
ExpMat2=cons(ExpMat[I],ExpMat2)$ |
| if(car(ExpMat2)!=ExpMat[I])
|
|
| ExpMat2=cons(ExpMat[I],ExpMat2)$
|
ExpMat=newvect(length(ExpMat2),ExpMat2)$ |
|
|
ExpMatRowNum=size(ExpMat)[0]$ |
| ExpMat=newvect(length(ExpMat2),ExpMat2)$
|
ExpMatColNum=size(ExpMat[0])[0]$ |
| ExpMatRowNum=size(ExpMat)[0]$
|
|
| ExpMatColNum=size(ExpMat[0])[0]$
|
NormMat=newmat(ExpMatColNum,ExpMatColNum+1)$ |
|
|
|
| NormMat=newmat(ExpMatColNum,ExpMatColNum+1)$
|
for(I=0;I<ExpMatColNum;I++) |
|
|
for(J=0;J<ExpMatColNum;J++) |
| for(I=0;I<ExpMatColNum;I++)
|
for(K=0;K<ExpMatRowNum;K++) |
| for(J=0;J<ExpMatColNum;J++)
|
NormMat[I][J]+=ExpMat[K][I]*ExpMat[K][J]$ |
| for(K=0;K<ExpMatRowNum;K++)
|
|
| NormMat[I][J]+=ExpMat[K][I]*ExpMat[K][J]$
|
for(I=0;I<ExpMatColNum;I++) |
|
|
for(J=0;J<ExpMatRowNum;J++) |
| for(I=0;I<ExpMatColNum;I++)
|
NormMat[I][ExpMatColNum]+=ExpMat[J][I]$ |
| for(J=0;J<ExpMatRowNum;J++)
|
|
| NormMat[I][ExpMatColNum]+=ExpMat[J][I]$
|
SolveList=[]$ |
|
|
for(I=0;I<ExpMatColNum;I++){ |
| SolveList=[]$
|
TMP=0$ |
| for(I=0;I<ExpMatColNum;I++){
|
for(J=0;J<ExpMatColNum;J++) |
| TMP=0$
|
TMP+=NormMat[I][J]*Vars[J]$ |
| for(J=0;J<ExpMatColNum;J++)
|
|
| TMP+=NormMat[I][J]*Vars[J]$
|
TMP-=NormMat[I][ExpMatColNum]$ |
|
|
SolveList=cons(TMP,SolveList)$ |
| TMP-=NormMat[I][ExpMatColNum]$
|
} |
| SolveList=cons(TMP,SolveList)$
|
|
| }
|
Rea=vars(SolveList)$ |
|
|
Res=solve(SolveList,Vars)$ |
| Rea=vars(SolveList)$
|
|
| Res=solve(SolveList,Vars)$
|
if(nonposdegchk(Res)){ |
|
|
Res=getgcd(Res,Rea)$ |
| if(nonposdegchk(Res)){
|
TMP1=makeret1(Res,Vars); |
| Res=getgcd(Res,Rea)$
|
if(car(TMP1)==0){ |
| TMP1=makeret1(Res,Vars);
|
TMP2=roundret(cdr(TMP1)); |
| if(car(TMP1)==0){
|
TMP3=map(drint,cdr(TMP1))$ |
| TMP2=roundret(cdr(TMP1));
|
RET=cons([cdr(TMP1),newvect(length(TMP3),TMP3),TMP2],RET)$ |
| TMP3=map(drint,cdr(TMP1))$
|
} |
| RET=cons([cdr(TMP1),newvect(length(TMP3),TMP3),TMP2],RET)$
|
else |
| }
|
RET=cons([cdr(TMP1),[],[]],RET)$ |
| else
|
} |
| RET=cons([cdr(TMP1),[],[]],RET)$
|
|
| }
|
RET=cons(Vars,reverse(RET))$ |
|
|
RET=cons(0,RET)$ |
| RET=cons(Vars,reverse(RET))$
|
return RET$ |
| RET=cons(0,RET)$
|
} |
| return RET$
|
|
| }
|
def average(PolyList,Vars){ |
|
|
|
| def average(PolyList,Vars){
|
RET=[]$ |
|
|
dp_ord(2)$ |
| RET=[]$
|
|
| dp_ord(2)$
|
PolyListNum=length(PolyList)$ |
|
|
|
| PolyListNum=length(PolyList)$
|
ExpMat=[]$ |
|
|
for(I=0;I<PolyListNum;I++) |
| ExpMat=[]$
|
for(Poly=dp_ptod(PolyList[I],Vars);Poly!=0;Poly=dp_rest(Poly)) |
| for(I=0;I<PolyListNum;I++)
|
ExpMat=cons(dp_etov(dp_ht(Poly)),ExpMat)$ |
| for(Poly=dp_ptod(PolyList[I],Vars);Poly!=0;Poly=dp_rest(Poly))
|
|
| ExpMat=cons(dp_etov(dp_ht(Poly)),ExpMat)$
|
ExpMat=reverse(ExpMat)$ |
|
|
ExpMat=newvect(length(ExpMat),ExpMat)$ |
| ExpMat=reverse(ExpMat)$
|
|
| ExpMat=newvect(length(ExpMat),ExpMat)$
|
ExpMat=qsort(ExpMat,junban2)$ |
|
|
ExpMat2=[]$ |
| ExpMat=qsort(ExpMat,junban2)$
|
for(I=0;I<size(ExpMat)[0];I++) |
| ExpMat2=[]$
|
if(car(ExpMat2)!=ExpMat[I]) |
| for(I=0;I<size(ExpMat)[0];I++)
|
ExpMat2=cons(ExpMat[I],ExpMat2)$ |
| if(car(ExpMat2)!=ExpMat[I])
|
|
| ExpMat2=cons(ExpMat[I],ExpMat2)$
|
ExpMat=newvect(length(ExpMat2),ExpMat2)$ |
|
|
ExpMatRowNum=size(ExpMat)[0]$ |
| ExpMat=newvect(length(ExpMat2),ExpMat2)$
|
ExpMatColNum=size(ExpMat[0])[0]$ |
| ExpMatRowNum=size(ExpMat)[0]$
|
|
| ExpMatColNum=size(ExpMat[0])[0]$
|
Res=newvect(ExpMatColNum); |
|
|
for(I=0;I<ExpMatColNum;I++) |
| Res=newvect(ExpMatColNum);
|
Res[I]=newvect(2,[Vars[I]])$ |
| for(I=0;I<ExpMatColNum;I++)
|
|
| Res[I]=newvect(2,[Vars[I]])$
|
for(I=0;I<ExpMatRowNum;I++) |
|
|
for(J=0;J<ExpMatColNum;J++) |
| for(I=0;I<ExpMatRowNum;I++)
|
Res[J][1]+=ExpMat[I][J]$ |
| for(J=0;J<ExpMatColNum;J++)
|
|
| Res[J][1]+=ExpMat[I][J]$
|
for(I=0;I<ExpMatColNum;I++) |
|
|
if(Res[I][1]==0) |
| for(I=0;I<ExpMatColNum;I++)
|
Res[I][1]=1$ |
| if(Res[I][1]==0)
|
else |
| Res[I][1]=1$
|
Res[I][1]=1/Res[I][1]$ |
| else
|
|
| Res[I][1]=1/Res[I][1]$
|
RET=cons(makeret(vtol(Res),Vars,1),RET)$ |
|
|
RET=cons(Vars,RET)$ |
| RET=cons(makeret(vtol(Res),Vars,1),RET)$
|
|
| RET=cons(Vars,RET)$
|
return RET$ |
|
|
} |
| return RET$
|
|
| }
|
end$ |
|
|
|
| end$
|
|