| version 1.2, 2003/10/17 14:36:25 |
version 1.9, 2003/11/21 08:07:16 |
|
|
| load("solve")$
|
load("solve")$ |
|
|
load("gr")$ |
| def nonposdegchk(Res){
|
|
|
|
def nonzerovec(A){ |
| for(I=0;I<length(Res);I++)
|
|
| if(Res[I][1]<=0)
|
for(I=0;I<size(A)[0];I++) |
| return 0$
|
if(A[I]!=0) |
|
|
return 1$ |
| return 1$
|
|
| }
|
return 0$ |
|
|
} |
| def resvars(Res,Vars){
|
|
|
|
def junban(A,B){ |
| ResVars=newvect(length(Vars),Vars)$
|
return (A<B ? 1:(A>B ? -1:0))$ |
|
|
} |
| for(I=0;I<length(Res);I++){
|
|
|
|
def worder(A,B){ |
| for(J=0;J<size(ResVars)[0];J++)
|
return (A[0]<B[0] ? 1:(A[0]>B[0] ? -1:0))$ |
| if(Res[I][0]==ResVars[J])
|
} |
| break$
|
|
|
|
def wsort(A,B,C){ |
| ResVars[J]=Res[I][1]$
|
|
| }
|
D=newvect(length(B))$ |
|
|
for(I=0;I<length(B);I++) |
| return(ResVars)$
|
D[I]=[A[I],B[I],C[I]]$ |
| }
|
|
|
|
D=qsort(D,worder)$ |
| def makeret(Res,Vars,B){
|
E=[]$ |
|
|
for(I=0;I<length(B);I++) |
| VarsNum=length(Vars)$
|
E=cons(D[I][1],E)$ |
|
|
E=reverse(E)$ |
| ResMat=newvect(VarsNum)$
|
F=[]$ |
| for(I=0;I<VarsNum;I++)
|
for(I=0;I<length(B);I++) |
| ResMat[I]=newvect(2)$
|
F=cons(D[I][2],F)$ |
|
|
F=reverse(F)$ |
| for(I=0;I<VarsNum;I++){
|
|
| ResMat[I][0]=Vars[I]$
|
return [E,F]$ |
| ResMat[I][1]=Vars[I]$
|
} |
| }
|
|
|
|
def derase(A){ |
| for(F=0,L=1,D=0,M=1,I=0;I<length(Res);I++){
|
|
|
|
B=newvect(length(A),A)$ |
| for(J=0;J<size(ResMat)[0];J++)
|
B=qsort(B,junban)$ |
| if(Res[I][0]==ResMat[J][0])
|
C=[]$ |
| break$
|
for(I=0;I<size(B)[0];I++) |
|
|
if(car(C)!=B[I]) |
| if(J<VarsNum){
|
C=cons(B[I],C)$ |
| K=Res[I][1]$
|
|
| ResMat[J][1]=K$
|
return reverse(C)$ |
|
|
} |
| if(F==0 && type(K)==1){
|
|
| if(B==2){
|
def nonposdegchk(Res){ |
| L=ilcm(L,dn(K))$
|
|
| D=igcd(D,nm(K))$
|
for(I=0;I<length(Res);I++) |
| }
|
if(Res[I][1]<=0) |
| else{
|
return 0$ |
| if(K<M)
|
|
| M=K$
|
return 1$ |
| }
|
} |
| }
|
|
| else
|
def getgcd(A,B){ |
| F=1$
|
|
|
|
VarsNumA=length(A)$ |
| }
|
VarsNumB=length(B)$ |
| }
|
|
|
|
C=newvect(VarsNumB,B)$ |
| if(F==0)
|
|
| if(B==2)
|
for(I=0;I<VarsNumA;I++){ |
| for(I=0;I<VarsNum;I++)
|
|
| ResMat[I][1]=ResMat[I][1]*L/D$
|
for(J=0;J<VarsNumB;J++) |
| else
|
if(C[J]==A[I][0]) |
| for(I=0;I<VarsNum;I++)
|
break$ |
| ResMat[I][1]=ResMat[I][1]/M*1.0$
|
|
|
|
if(J<VarsNumB) |
| for(I=0;I<VarsNum;I++)
|
C[J]=A[I][1]$ |
| for(J=0;J<length(Vars);J++)
|
} |
| ResMat[I][1]=subst(ResMat[I][1],Vars[J],
|
|
| strtov(rtostr(Vars[J])+"_deg"))$
|
D=0$ |
|
|
for(I=0;I<VarsNumB;I++) |
| ResMat=map(vtol,ResMat)$
|
D=gcd(D,C[I])$ |
| return(vtol(ResMat))$
|
|
|
|
if(D!=0){ |
| }
|
C=C/D$ |
|
|
C=map(red,C)$ |
| def afo(A,B){
|
} |
|
|
|
| for(I=0;I<size(A)[0];I++){
|
for(L=1,D=0,I=0;I<VarsNumB;I++){ |
| if(A[I]<B[I])
|
if(type(TMP=dn(C[I]))==1) |
| return 1$
|
L=ilcm(L,TMP)$ |
|
|
|
| if(A[I]>B[I])
|
if(type(TMP=nm(C[I]))==1) |
| return -1$
|
D=igcd(D,TMP)$ |
| }
|
} |
|
|
|
| return 0$
|
C=C*L$ |
| }
|
if(D!=0) |
|
|
C=C/D$ |
| def weight(PolyList,Vars){
|
|
|
|
RET=[]$ |
| dp_ord(2)$
|
for(I=0;I<VarsNumB;I++) |
|
|
RET=cons([B[I],C[I]],RET)$ |
| PolyListNum=length(PolyList)$
|
|
|
|
return RET$ |
| ExpMat=[]$
|
} |
| for(I=0;I<PolyListNum;I++)
|
|
| for(Poly=dp_ptod(PolyList[I],Vars);Poly!=0;Poly=dp_rest(Poly))
|
def resvars(Res,Vars){ |
| ExpMat=cons(dp_etov(dp_ht(Poly)),ExpMat)$
|
|
|
|
ResVars=newvect(length(Vars),Vars)$ |
| ExpMat=reverse(ExpMat)$
|
for(I=0;I<length(Res);I++){ |
| ExpMat=newvect(length(ExpMat),ExpMat)$
|
|
|
|
for(J=0;J<size(ResVars)[0];J++) |
| ExpMatRowNum=size(ExpMat)[0]$
|
if(Res[I][0]==ResVars[J]) |
| ExpMatColNum=size(ExpMat[0])[0]$
|
break$ |
| ExtMatColNum=ExpMatColNum+PolyListNum$
|
|
|
|
if(J<size(ResVars)[0]) |
| OneMat=newvect(PolyListNum+1,[0])$
|
ResVars[J]=Res[I][1]$ |
| for(I=0,SUM=0;I<PolyListNum;I++){
|
} |
| SUM+=nmono(PolyList[I])$
|
return(ResVars)$ |
| OneMat[I+1]=SUM$
|
} |
| }
|
|
|
|
def makeret(Res,Vars){ |
| RevOneMat=newvect(ExpMatRowNum)$
|
|
| for(I=0;I<PolyListNum;I++)
|
ResNum=length(Res)$ |
| for(J=OneMat[I];J<OneMat[I+1];J++)
|
VarsNum=length(Vars)$ |
| RevOneMat[J]=I$
|
|
|
|
ResVec=newvect(ResNum)$ |
| NormMat=newmat(ExpMatColNum,ExtMatColNum)$
|
for(M=0,I=0;I<ResNum;I++){ |
|
|
if(member(Res[I][0],Vars)){ |
| for(I=0;I<ExpMatColNum;I++)
|
ResVec[I]=Res[I][1]$ |
| for(J=0;J<ExpMatColNum;J++)
|
|
| for(K=0;K<ExpMatRowNum;K++)
|
if(type(ResVec[I])==1){ |
| NormMat[I][J]+=ExpMat[K][I]*ExpMat[K][J]$
|
if(M==0) |
|
|
M=ResVec[I]$ |
| for(I=0;I<ExpMatColNum;I++)
|
else |
| for(J=0;J<PolyListNum-1;J++)
|
if(ResVec[I]<M) |
| for(K=OneMat[J];K<OneMat[J+1];K++)
|
M=ResVec[I]$ |
| 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]$
|
if(M!=0) |
|
|
ResVec=ResVec/M; |
| NormMat2=newmat(PolyListNum-1,ExpMatColNum+1)$
|
|
|
|
RET=newvect(VarsNum,Vars)$ |
| for(I=0;I<PolyListNum-1;I++)
|
|
| for(J=0;J<ExpMatColNum;J++)
|
for(I=0;I<ResNum;I++){ |
| for(K=OneMat[I];K<OneMat[I+1];K++)
|
for(J=0;J<VarsNum;J++) |
| NormMat2[I][J]-=ExpMat[K][J]$
|
if(Vars[J]==Res[I][0]) |
|
|
break$ |
| for(I=0;I<PolyListNum-1;I++)
|
|
| NormMat2[I][ExpMatColNum]=OneMat[I+1]-OneMat[I]$
|
if(J<VarsNum) |
|
|
RET[J]=ResVec[I]$ |
| ExtVars=Vars$
|
} |
| for(I=0;I<PolyListNum-1;I++)
|
|
| ExtVars=append(ExtVars,[uc()])$
|
for(I=0;I<VarsNum;I++) |
|
|
if(type(RET[I])!=1) |
| SolveList=[]$
|
return [1,RET]$ |
| for(I=0;I<ExpMatColNum;I++){
|
|
| TMP=0$
|
return [0,RET]$ |
| for(J=0;J<ExtMatColNum-1;J++)
|
} |
| TMP+=NormMat[I][J]*ExtVars[J]$
|
|
|
|
def roundret(V){ |
| TMP-=NormMat[I][ExtMatColNum-1]$
|
|
| SolveList=cons(TMP,SolveList)$
|
VN=size(V)[0]$ |
| }
|
|
|
|
RET0=V$ |
| for(I=0;I<PolyListNum-1;I++){
|
for(I=1;I<1000;I++){ |
| TMP=0$
|
RET1=I*RET0$ |
| for(J=0;J<ExpMatColNum;J++)
|
for(J=0;J<VN;J++){ |
| TMP+=NormMat2[I][J]*ExtVars[J]$
|
X=drint(RET1[J])$ |
|
|
if(dabs(X-RET1[J])<0.2) |
| TMP+=NormMat2[I][ExpMatColNum]*ExtVars[I+ExpMatColNum]$
|
RET1[J]=X$ |
|
|
else |
| SolveList=cons(TMP,SolveList)$
|
break$ |
| }
|
} |
|
|
if(J==VN) |
| ReaVars=vars(SolveList)$
|
break$ |
| Res=solve(SolveList,reverse(ExtVars))$
|
} |
|
|
|
| RET=[]$
|
if(I==1000) |
| if(nonposdegchk(Res)){
|
return []$ |
|
|
else |
| ResVars=resvars(Res,ExtVars)$
|
return RET1$ |
| ResVars=append(vtol(ResVars),[1])$
|
} |
|
|
|
| for(I=0;I<ExpMatRowNum;I++){
|
def chkou(L,ExpMat,CHAGORD){ |
| TMP=0$
|
|
| for(J=0;J<ExpMatColNum;J++)
|
for(P=1,I=0;I<L;I++){ |
| TMP+=ExpMat[I][J]*ResVars[J]$
|
Q=ExpMat[L][CHAGORD[I]]$ |
|
|
for(J=0;J<size(ExpMat[0])[0];J++){ |
| TMP-=ResVars[RevOneMat[I]+ExpMatColNum]$
|
ExpMat[L][CHAGORD[J]]=red((ExpMat[I][CHAGORD[I]] |
|
|
*ExpMat[L][CHAGORD[J]]- |
| if(TMP!=0)
|
Q*ExpMat[I][CHAGORD[J]])/P)$ |
| break$
|
} |
| }
|
|
|
|
P=ExpMat[I][CHAGORD[I]]$ |
| if(I==ExpMatRowNum){
|
} |
| print("complitely homogenized")$
|
|
| return([makeret(Res,Vars,2)])$
|
for(J=0;J<size(ExpMat[0])[0];J++) |
| }
|
if(ExpMat[L][CHAGORD[J]]!=0) |
| else
|
break$ |
| RET=cons(makeret(Res,Vars,1),RET)$
|
|
| }
|
if(J==size(ExpMat[0])[0]) |
|
|
return L$ |
| ExpMat=qsort(ExpMat,afo)$
|
else{ |
| ExpMat2=[]$
|
TMP=CHAGORD[L]$ |
| for(I=0;I<size(ExpMat)[0];I++)
|
CHAGORD[L]=CHAGORD[J]$ |
| if(car(ExpMat2)!=ExpMat[I])
|
CHAGORD[J]=TMP$ |
| ExpMat2=cons(ExpMat[I],ExpMat2)$
|
return (L+1)$ |
|
|
} |
| ExpMat=newvect(length(ExpMat2),ExpMat2)$
|
} |
| ExpMatRowNum=size(ExpMat)[0]$
|
|
| ExpMatColNum=size(ExpMat[0])[0]$
|
def qcheckmain(PolyList,Vars){ |
|
|
|
| NormMat=newmat(ExpMatColNum,ExpMatColNum+1)$
|
RET=[]$ |
|
|
PolyListNum=length(PolyList)$ |
| for(I=0;I<ExpMatColNum;I++)
|
VarsNum=length(Vars)$ |
| for(J=0;J<ExpMatColNum;J++)
|
|
| for(K=0;K<ExpMatRowNum;K++)
|
ExpMat=newvect(VarsNum)$ |
| NormMat[I][J]+=ExpMat[K][I]*ExpMat[K][J]$
|
CHAGORD=newvect(VarsNum)$ |
|
|
for(I=0;I<VarsNum;I++) |
| for(I=0;I<ExpMatColNum;I++)
|
CHAGORD[I]=I$ |
| for(J=0;J<ExpMatRowNum;J++)
|
|
| NormMat[I][ExpMatColNum]+=ExpMat[J][I]$
|
L=0$ |
|
|
for(I=0;I<PolyListNum;I++){ |
| SolveList=[]$
|
Poly=dp_ptod(PolyList[I],Vars)$ |
| for(I=0;I<ExpMatColNum;I++){
|
BASE0=dp_etov(dp_ht(Poly))$ |
| TMP=0$
|
Poly=dp_rest(Poly)$ |
| for(J=0;J<ExpMatColNum;J++)
|
for(;Poly!=0;Poly=dp_rest(Poly)){ |
| TMP+=NormMat[I][J]*Vars[J]$
|
ExpMat[L]=dp_etov(dp_ht(Poly))-BASE0$ |
|
|
L=chkou(L,ExpMat,CHAGORD)$ |
| TMP-=NormMat[I][ExpMatColNum]$
|
if(L==VarsNum-1) |
| SolveList=cons(TMP,SolveList)$
|
return [L,CHAGORD,ExpMat]$ |
| }
|
} |
|
|
} |
| Res=solve(SolveList,Vars)$
|
|
|
|
return [L,CHAGORD,ExpMat]$ |
| if(nonposdegchk(Res))
|
} |
| RET=cons(makeret(Res,Vars,1),RET)$
|
|
|
|
def inner(A,B){ |
| return reverse(RET)$
|
|
| }
|
SUM=0$ |
|
|
for(I=0;I<size(A)[0];I++) |
| end$
|
SUM+=A[I]*B[I]$ |
| |
|
| |
return SUM$ |
| |
} |
| |
|
| |
def checktd(PolyList,Vars,ResVars){ |
| |
|
| |
PolyListNum=length(PolyList)$ |
| |
VarsNum=length(Vars)$ |
| |
|
| |
L=0$ |
| |
for(I=0;I<PolyListNum;I++){ |
| |
Poly=dp_ptod(PolyList[I],Vars)$ |
| |
J0=inner(dp_etov(dp_ht(Poly)),ResVars)$ |
| |
Poly=dp_rest(Poly)$ |
| |
for(;Poly!=0;Poly=dp_rest(Poly)) |
| |
if(J0!=inner(dp_etov(dp_ht(Poly)),ResVars)) |
| |
return 0$ |
| |
} |
| |
|
| |
return 1$ |
| |
} |
| |
|
| |
def qcheck(PolyList,Vars){ |
| |
|
| |
Res=qcheckmain(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)$ |
| |
} |
| |
|
| |
Rea=vars(SolveList)$ |
| |
|
| |
VarsList=[]$ |
| |
for(I=0;I<VarsNum;I++) |
| |
if(member(Vars[CHAGORD[I]],Rea)) |
| |
VarsList=cons(Vars[CHAGORD[I]],VarsList)$ |
| |
|
| |
Res=solve(reverse(SolveList),reverse(VarsList))$ |
| |
Res=getgcd(Res,Rea)$ |
| |
|
| |
if(nonposdegchk(Res)){ |
| |
|
| |
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"))$ |
| |
|
| |
return [wsort(ResVars,Vars,ResVars)]$ |
| |
} |
| |
else |
| |
return []$ |
| |
} |
| |
else |
| |
return []$ |
| |
|
| |
} |
| |
|
| |
def leastsq(NormMat,ExpMat,Vars){ |
| |
|
| |
RET=[]$ |
| |
|
| |
ExpMatRowNum=size(ExpMat)[0]$ |
| |
ExpMatColNum=size(ExpMat[0])[0]$ |
| |
|
| |
if(NormMat==0){ |
| |
NormMat=newmat(ExpMatColNum,ExpMatColNum)$ |
| |
|
| |
for(I=0;I<ExpMatColNum;I++) |
| |
for(J=I;J<ExpMatColNum;J++) |
| |
for(K=0;K<ExpMatRowNum;K++) |
| |
NormMat[I][J]+= |
| |
ExpMat[K][I]*ExpMat[K][J]$ |
| |
} |
| |
|
| |
BVec=newvect(ExpMatColNum)$ |
| |
|
| |
for(I=0;I<ExpMatColNum;I++) |
| |
for(J=0;J<ExpMatRowNum;J++) |
| |
BVec[I]+=ExpMat[J][I]$ |
| |
|
| |
SolveList=[]$ |
| |
for(I=0;I<ExpMatColNum;I++){ |
| |
TMP=0$ |
| |
for(J=0;J<I;J++) |
| |
TMP+=NormMat[J][I]*Vars[J]$ |
| |
|
| |
for(J=I;J<ExpMatColNum;J++) |
| |
TMP+=NormMat[I][J]*Vars[J]$ |
| |
|
| |
TMP-=BVec[I]$ |
| |
SolveList=cons(TMP,SolveList)$ |
| |
} |
| |
|
| |
Rea=vars(SolveList)$ |
| |
|
| |
VarsList=[]$ |
| |
for(I=0;I<length(Vars);I++) |
| |
if(member(Vars[I],Rea)) |
| |
VarsList=cons(Vars[I],VarsList)$ |
| |
|
| |
Res=solve(SolveList,VarsList)$ |
| |
Res=getgcd(Res,Rea)$ |
| |
|
| |
if(nonposdegchk(Res)){ |
| |
TMP1=makeret(Res,Vars)$ |
| |
if(TMP1[0]==0){ |
| |
TMP=roundret(TMP1[1]*1.0)$ |
| |
if(TMP!=[]) |
| |
RET=cons(wsort(TMP1[1],Vars,TMP),RET)$ |
| |
|
| |
RET=cons(wsort(TMP1[1],Vars, |
| |
map(drint,TMP1[1]*1.0)),RET)$ |
| |
|
| |
return RET$ |
| |
} |
| |
else{ |
| |
RET=cons(wsort(TMP1[1],Vars,TMP1[1]*1.0),RET)$ |
| |
return RET$ |
| |
} |
| |
} |
| |
else |
| |
return RET$ |
| |
|
| |
} |
| |
|
| |
def weightr(ExpMat,Vars,PolyListNum,OneMat){ |
| |
|
| |
RET=[]$ |
| |
|
| |
ExpMatRowNum=size(ExpMat)[0]$ |
| |
ExpMatColNum=size(ExpMat[0])[0]$ |
| |
ExtMatColNum=ExpMatColNum+PolyListNum$ |
| |
|
| |
ExtVars=reverse(Vars)$ |
| |
for(I=0;I<PolyListNum;I++) |
| |
ExtVars=cons(uc(),ExtVars)$ |
| |
|
| |
ExtVars=reverse(ExtVars)$ |
| |
|
| |
NormMat=newmat(ExpMatColNum,ExtMatColNum)$ |
| |
|
| |
for(I=0;I<ExpMatColNum;I++) |
| |
for(J=I;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;J++) |
| |
for(K=OneMat[J];K<OneMat[J+1];K++) |
| |
NormMat[I][J+ExpMatColNum]-= |
| |
ExpMat[K][I]$ |
| |
|
| |
WVect=newvect(PolyListNum)$ |
| |
for(I=0;I<PolyListNum;I++) |
| |
WVect[I]=OneMat[I+1]-OneMat[I]$ |
| |
|
| |
for(F=0;F<ExtMatColNum;F++){ |
| |
SolveList=[]$ |
| |
for(I=0;I<ExpMatColNum;I++){ |
| |
if (F==I) |
| |
continue$ |
| |
|
| |
TMP=0$ |
| |
|
| |
for(J=0;J<I;J++) |
| |
if(J!=F) |
| |
TMP+=NormMat[J][I]*ExtVars[J]$ |
| |
|
| |
for(J=I;J<ExtMatColNum;J++) |
| |
if(J!=F) |
| |
TMP+=NormMat[I][J]*ExtVars[J]$ |
| |
|
| |
if(F<I) |
| |
TMP+=NormMat[F][I]$ |
| |
else |
| |
TMP+=NormMat[I][F]$ |
| |
|
| |
SolveList=cons(TMP,SolveList)$ |
| |
} |
| |
|
| |
for(I=0;I<PolyListNum;I++){ |
| |
if(F==(I+ExpMatColNum)) |
| |
continue$ |
| |
|
| |
TMP=0$ |
| |
for(J=0;J<ExpMatColNum;J++) |
| |
if(J!=F) |
| |
TMP+=NormMat[J][I+ExpMatColNum] |
| |
*ExtVars[J]$ |
| |
|
| |
TMP+=WVect[I]*ExtVars[I+ExpMatColNum]$ |
| |
|
| |
if(F<ExpMatColNum) |
| |
TMP+=NormMat[F][I+ExpMatColNum]$ |
| |
|
| |
SolveList=cons(TMP,SolveList)$ |
| |
} |
| |
|
| |
Rea=vars(SolveList)$ |
| |
|
| |
SolVars=[]$ |
| |
for(I=0;I<ExtMatColNum;I++) |
| |
if(I!=F && member(ExtVars[I],Rea)) |
| |
SolVars=cons(ExtVars[I],SolVars)$ |
| |
|
| |
Res=solve(SolveList,SolVars)$ |
| |
Res=cons([ExtVars[F],1],Res)$ |
| |
|
| |
TMP=[]$ |
| |
for(I=0;I<length(Rea);I++) |
| |
if(member(Rea[I],Vars)) |
| |
TMP=cons(Rea[I],TMP)$ |
| |
|
| |
TMP=cons(ExtVars[F],TMP)$ |
| |
Res=getgcd(Res,TMP)$ |
| |
|
| |
if(nonposdegchk(Res)){ |
| |
|
| |
TMP1=makeret(Res,Vars)$ |
| |
if(TMP1[0]==0){ |
| |
TMP=roundret(TMP1[1]*1.0)$ |
| |
if(TMP!=[]) |
| |
RET=cons(wsort(TMP1[1],Vars,TMP),RET)$ |
| |
|
| |
RET=cons(wsort(TMP1[1],Vars, |
| |
map(drint,TMP1[1]*1.0)),RET)$ |
| |
} |
| |
else{ |
| |
RET=cons(wsort(TMP1[1],Vars,TMP1[1]*1.0),RET)$ |
| |
} |
| |
} |
| |
|
| |
} |
| |
|
| |
return [NormMat,RET]$ |
| |
} |
| |
|
| |
def weight(PolyList,Vars,FLAG){ |
| |
|
| |
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(TMP!=[]){ |
| |
RET=append(RET,TMP)$ |
| |
return cons(1,RET)$ |
| |
} |
| |
|
| |
dp_ord(2)$ |
| |
|
| |
PolyListNum=length(PolyList)$ |
| |
|
| |
if(FLAG){ |
| |
|
| |
OneMat=newvect(PolyListNum+1,[0])$ |
| |
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)$ |
| |
} |
| |
OneMat[I+1]=length(ExpMat)$ |
| |
} |
| |
|
| |
ExpMat=reverse(ExpMat)$ |
| |
ExpMat=newvect(length(ExpMat),ExpMat)$ |
| |
|
| |
TMP=weightr(ExpMat,Vars,PolyListNum,OneMat)$ |
| |
RET=append(RET,TMP[1])$ |
| |
RET=append(RET,leastsq(TMP[0],ExpMat,Vars))$ |
| |
} |
| |
else{ |
| |
ExpMat=[]$ |
| |
for(I=0;I<PolyListNum;I++){ |
| |
for(Poly=dp_ptod(PolyList[I],Vars); |
| |
Poly!=0;Poly=dp_rest(Poly)){ |
| |
if(nonzerovec(TMP=dp_etov(dp_ht(Poly)))) |
| |
ExpMat=cons(TMP,ExpMat)$ |
| |
} |
| |
} |
| |
|
| |
ExpMat=reverse(ExpMat)$ |
| |
ExpMat=newvect(length(ExpMat),ExpMat)$ |
| |
|
| |
RET=append(RET,leastsq(0,ExpMat,Vars))$ |
| |
} |
| |
|
| |
ExpMat=qsort(ExpMat,junban)$ |
| |
|
| |
ExpMat2=[]$ |
| |
for(I=0;I<size(ExpMat)[0];I++) |
| |
if(car(ExpMat2)!=ExpMat[I]) |
| |
ExpMat2=cons(ExpMat[I],ExpMat2)$ |
| |
|
| |
if(size(ExpMat)[0]!=length(ExpMat2)){ |
| |
ExpMat=newvect(length(ExpMat2),ExpMat2)$ |
| |
RET=append(RET,leastsq(0,ExpMat,Vars))$ |
| |
} |
| |
|
| |
RET=derase(RET)$ |
| |
return cons(0,RET)$ |
| |
} |
| |
|
| |
end$ |