version 1.31, 2004/01/15 07:20:31 |
version 1.32, 2004/02/14 18:28:39 |
|
|
#define EPS 1E-6 |
#define EPS 1E-6 |
#define TINY 1E-20 |
#define TINY 1E-20 |
#define MAX_ITER 100 |
#define MAX_ITER 100 |
#define ROUND_THRESHOLD 0.4 |
|
|
|
def rotate(A,I,J,K,L,C,S){ |
def rotate(A,I,J,K,L,C,S){ |
|
|
Line 351 def roundret(V){ |
|
Line 350 def roundret(V){ |
|
|
|
VN=size(V)[0]$ |
VN=size(V)[0]$ |
|
|
|
K=1$ |
RET0=V$ |
RET0=V$ |
for(I=1;I<1000;I++){ |
RET1=map(drint,RET0)$ |
RET1=I*RET0$ |
S=0$ |
for(J=0;J<VN;J++){ |
for(J=0;J<VN;J++) |
X=drint(RET1[J])$ |
S+=(RET0[J]-RET1[J])^2$ |
if(dabs(X-RET1[J])<ROUND_THRESHOLD) |
|
RET1[J]=X$ |
for(I=2;I<10;I++){ |
else |
RET0=I*V$ |
break$ |
RET1=map(drint,RET0)$ |
} |
|
if(J==VN) |
T=0$ |
break$ |
for(J=0;J<VN;J++) |
|
T+=(RET0[J]-RET1[J])^2$ |
|
|
|
if(T<S){ |
|
K=I$ |
|
S=T$ |
|
} |
} |
} |
|
|
if(I==1000) |
return map(drint,K*V)$ |
return []$ |
|
else |
|
return RET1$ |
|
} |
} |
|
|
def chkou(L,ExpMat,CHAGORD){ |
def chkou(L,ExpMat,CHAGORD){ |
Line 523 def qcheck(PolyList,Vars,FLAG){ |
|
Line 526 def qcheck(PolyList,Vars,FLAG){ |
|
TMP=map(subst,TMP,TMP0[I][0],TMP0[I][1])$ |
TMP=map(subst,TMP,TMP0[I][0],TMP0[I][1])$ |
RET0=value2(Vars,TMP)$ |
RET0=value2(Vars,TMP)$ |
if(RET0!=[]) |
if(RET0!=[]) |
RET0=wsort(RET0,Vars,RET0,1/10)$ |
RET0=wsort(RET0,Vars,RET0,-1)$ |
} |
} |
|
|
TMP=vtol(TMP1[1])$ |
TMP=vtol(TMP1[1])$ |
Line 534 def qcheck(PolyList,Vars,FLAG){ |
|
Line 537 def qcheck(PolyList,Vars,FLAG){ |
|
RET0=value2(Vars,TMP)$ |
RET0=value2(Vars,TMP)$ |
|
|
if(RET0!=[]) |
if(RET0!=[]) |
RET0=wsort(RET0,Vars,RET0,1/10)$ |
RET0=wsort(RET0,Vars,RET0,-1)$ |
} |
} |
RET=append(RET,RET0)$ |
RET=append(RET,RET0)$ |
} |
} |
Line 547 def qcheck(PolyList,Vars,FLAG){ |
|
Line 550 def qcheck(PolyList,Vars,FLAG){ |
|
return RET$ |
return RET$ |
} |
} |
|
|
def leastsq(NormMat,ExpMat,Vars,FLAG,ID){ |
def unitweight2(NormMat0,ExpMat,Vars,FLAG,ID){ |
|
|
RET=[]$ |
RET=[]$ |
|
|
ExpMatRowNum=size(ExpMat)[0]$ |
ExpMatRowNum=size(ExpMat)[0]$ |
ExpMatColNum=size(ExpMat[0])[0]$ |
ExpMatColNum=size(ExpMat[0])[0]$ |
|
ExtMatColNum=ExpMatColNum+1$ |
|
|
|
ExtVars=append(Vars,[uc()])$ |
|
|
if(NormMat==0){ |
if(NormMat==0){ |
NormMat=newmat(ExpMatColNum,ExpMatColNum)$ |
|
|
|
|
NormMat0=newvect(ExtMatColNum)$ |
|
for(I=0;I<ExtMatColNum;I++) |
|
NormMat0[I]=newvect(ExtMatColNum)$ |
|
|
for(I=0;I<ExpMatColNum;I++) |
for(I=0;I<ExpMatColNum;I++) |
for(J=I;J<ExpMatColNum;J++) |
for(J=I;J<ExpMatColNum;J++) |
for(K=0;K<ExpMatRowNum;K++) |
for(K=0;K<ExpMatRowNum;K++) |
NormMat[I][J]+= |
NormMat0[I][J]+= |
ExpMat[K][I]*ExpMat[K][J]$ |
ExpMat[K][I]* |
|
ExpMat[K][J]$ |
} |
} |
|
|
BVec=newvect(ExpMatColNum)$ |
|
|
|
for(I=0;I<ExpMatColNum;I++) |
for(I=0;I<ExpMatColNum;I++) |
for(J=0;J<ExpMatRowNum;J++) |
for(K=0;K<ExpMatRowNum;K++) |
BVec[I]+=ExpMat[J][I]$ |
NormMat0[I][ExpMatColNum]-=ExpMat[K][I]$ |
|
|
SolveList=[]$ |
NormMat0[ExpMatColNum][ExpMatColNum]=ExpMatRowNum$ |
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++) |
WorkMat=newvect(ExtMatColNum)$ |
TMP+=NormMat[I][J]*Vars[J]$ |
for(I=0;I<ExtMatColNum;I++) |
|
WorkMat[I]=newvect(ExtMatColNum)$ |
|
|
TMP-=BVec[I]$ |
if(jacobi(ExtMatColNum,NormMat0,WorkMat)){ |
SolveList=cons(TMP,SolveList)$ |
|
} |
|
|
|
Rea=vars(SolveList)$ |
Res=newvect(ExtMatColNum)$ |
|
for(I=0;I<ExtMatColNum;I++){ |
|
Res[I]=newvect(2)$ |
|
Res[I][0]=ExtVars[I]$ |
|
Res[I][1]=WorkMat[ExtMatColNum-1][I]$ |
|
} |
|
|
VarsList=[]$ |
if(nonposdegchk(Res)){ |
for(I=0;I<length(Vars);I++) |
|
if(member(Vars[I],Rea)) |
|
VarsList=cons(Vars[I],VarsList)$ |
|
|
|
Res=solve(SolveList,VarsList)$ |
TMP1=makeret(Res,Vars,1)$ |
Res=getgcd(Res,Rea)$ |
|
|
|
if(nonposdegchk(Res)){ |
if(FLAG==0){ |
|
|
TMP1=makeret(Res,Vars,1)$ |
|
|
|
if(FLAG==0){ |
|
|
|
if(TMP1[0]==0){ |
|
|
|
TMP=roundret(TMP1[1])$ |
TMP=roundret(TMP1[1])$ |
|
|
RET=append(RET,wsort(TMP1[1],Vars,map(drint,TMP1[1]*1.0),ID))$ |
RET=append(RET,wsort(TMP1[1],Vars,map(drint,TMP1[1]*1.0),ID))$ |
Line 608 def leastsq(NormMat,ExpMat,Vars,FLAG,ID){ |
|
Line 605 def leastsq(NormMat,ExpMat,Vars,FLAG,ID){ |
|
if(TMP!=[]) |
if(TMP!=[]) |
RET=append(RET,wsort(TMP1[1],Vars,TMP,ID+1))$ |
RET=append(RET,wsort(TMP1[1],Vars,TMP,ID+1))$ |
} |
} |
else{ |
else if(FLAG==1) |
|
RET=append(RET,[[ID,Vars,vtol(TMP1[1])]])$ |
TMP=vtol(TMP1[1])$ |
|
RET0=[]$ |
|
if((TMP0=fixedpoint(TMP,0))!=[]){ |
|
|
|
for(I=0;I<length(TMP0);I++) |
|
TMP=map(subst,TMP,TMP0[I][0],TMP0[I][1])$ |
|
RET0=value2(Vars,TMP)$ |
|
if(RET0!=[]) |
|
RET0=wsort(RET0,Vars,RET0,ID+1/10)$ |
|
} |
|
|
|
TMP=vtol(TMP1[1])$ |
|
if(RET0==[] && (TMP0=fixedpoint(TMP,1))!=[]){ |
|
|
|
for(I=0;I<length(TMP0);I++) |
|
TMP=map(subst,TMP,TMP0[I][0],TMP0[I][1])$ |
|
RET0=value2(Vars,TMP)$ |
|
|
|
if(RET0!=[]) |
|
RET0=wsort(RET0,Vars,RET0,ID+1/10)$ |
|
} |
|
|
|
RET=append(RET,RET0)$ |
|
} |
|
|
|
} |
} |
else if(FLAG==1) |
} |
RET=append(RET,[[ID,Vars,vtol(TMP1[1])]])$ |
|
} |
|
|
|
return RET$ |
return RET$ |
} |
} |
|
|
def unitweight(ExpMat,Vars,PolyListNum,OneMat,FLAG){ |
def unitweight1(ExpMat,Vars,PolyListNum,OneMat,FLAG){ |
|
|
RET=[]$ |
RET=[]$ |
|
|
Line 657 def unitweight(ExpMat,Vars,PolyListNum,OneMat,FLAG){ |
|
Line 627 def unitweight(ExpMat,Vars,PolyListNum,OneMat,FLAG){ |
|
|
|
ExtVars=reverse(ExtVars)$ |
ExtVars=reverse(ExtVars)$ |
|
|
NormMat0=newvect(ExpMatColNum)$ |
NormMat0=newvect(ExpMatColNum+1)$ |
for(I=0;I<ExpMatColNum;I++) |
for(I=0;I<ExpMatColNum;I++) |
NormMat0[I]=newvect(ExpMatColNum)$ |
NormMat0[I]=newvect(ExpMatColNum+1)$ |
|
|
for(I=0;I<ExpMatColNum;I++) |
for(I=0;I<ExpMatColNum;I++) |
for(J=I;J<ExpMatColNum;J++) |
for(J=I;J<ExpMatColNum;J++) |
Line 672 def unitweight(ExpMat,Vars,PolyListNum,OneMat,FLAG){ |
|
Line 642 def unitweight(ExpMat,Vars,PolyListNum,OneMat,FLAG){ |
|
for(I=0;I<ExtMatColNum;I++) |
for(I=0;I<ExtMatColNum;I++) |
NormMat1[I]=newvect(ExtMatColNum)$ |
NormMat1[I]=newvect(ExtMatColNum)$ |
|
|
|
|
WorkMat=newvect(ExtMatColNum)$ |
WorkMat=newvect(ExtMatColNum)$ |
for(I=0;I<ExtMatColNum;I++) |
for(I=0;I<ExtMatColNum;I++) |
WorkMat[I]=newvect(ExtMatColNum)$ |
WorkMat[I]=newvect(ExtMatColNum)$ |
|
|
|
|
for(I=0;I<ExpMatColNum;I++) |
for(I=0;I<ExpMatColNum;I++) |
for(J=I;J<ExpMatColNum;J++) |
for(J=I;J<ExpMatColNum;J++) |
NormMat1[I][J]=NormMat0[I][J]$ |
NormMat1[I][J]=NormMat0[I][J]$ |
Line 755 def weight(PolyList,Vars,FLAG){ |
|
Line 723 def weight(PolyList,Vars,FLAG){ |
|
ExpMat=reverse(ExpMat)$ |
ExpMat=reverse(ExpMat)$ |
ExpMat=newvect(length(ExpMat),ExpMat)$ |
ExpMat=newvect(length(ExpMat),ExpMat)$ |
|
|
TMP=unitweight(ExpMat,Vars,PolyListNum,OneMat,FLAG)$ |
TMP=unitweight1(ExpMat,Vars,PolyListNum,OneMat,FLAG)$ |
|
|
RET=append(RET,TMP[1])$ |
RET=append(RET,TMP[1])$ |
|
|
TMP0=leastsq(TMP[0],ExpMat,Vars,FLAG,3)$ |
TMP=unitweight2(TMP[0],ExpMat,Vars,FLAG,3)$ |
|
|
RET=append(RET,TMP0)$ |
RET=append(RET,TMP)$ |
|
|
ExpMat=qsort(ExpMat,junban)$ |
ExpMat=qsort(ExpMat,junban)$ |
|
|
Line 772 def weight(PolyList,Vars,FLAG){ |
|
Line 740 def weight(PolyList,Vars,FLAG){ |
|
|
|
if(size(ExpMat)[0]!=length(ExpMat2)){ |
if(size(ExpMat)[0]!=length(ExpMat2)){ |
ExpMat=newvect(length(ExpMat2),ExpMat2)$ |
ExpMat=newvect(length(ExpMat2),ExpMat2)$ |
RET=append(RET,leastsq(0,ExpMat,Vars,FLAG,5))$ |
RET=append(RET,unitweight2(0,ExpMat,Vars,FLAG,5))$ |
} |
} |
else{ |
else{ |
TMP0=map(ltov,TMP0)$ |
TMP0=map(ltov,TMP0)$ |