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