version 1.31, 2004/01/15 07:20:31 |
version 1.40, 2004/05/23 02:48:47 |
|
|
#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 307 def makeret(Res,Vars,FLAG){ |
|
Line 306 def makeret(Res,Vars,FLAG){ |
|
else |
else |
M=-1$ |
M=-1$ |
|
|
for(I=0;I<ResNum;I++){ |
for(I=0;I<ResNum;I++){ |
if(member(Res[I][0],Vars)){ |
if(member(Res[I][0],Vars)){ |
ResVec[I]=Res[I][1]$ |
ResVec[I]=Res[I][1]$ |
|
|
if(FLAG){ |
if(FLAG){ |
if(type(ResVec[I])==1){ |
if(type(ResVec[I])==1){ |
if(M==0) |
if(M==0) |
M=ResVec[I]$ |
M=ResVec[I]$ |
else |
else |
if(ResVec[I]<M) |
if(ResVec[I]<M) |
M=ResVec[I]$ |
M=ResVec[I]$ |
} |
} |
else |
else |
M=-1$ |
M=-1$ |
} |
} |
} |
} |
} |
} |
|
|
|
|
if(M!=-1) |
if(M!=-1) |
ResVec=ResVec/M; |
ResVec=map(red,ResVec/M)$ |
|
|
RET=newvect(VarsNum,Vars)$ |
RET=newvect(VarsNum,Vars)$ |
|
|
Line 342 def makeret(Res,Vars,FLAG){ |
|
Line 340 def makeret(Res,Vars,FLAG){ |
|
|
|
for(I=0;I<VarsNum;I++) |
for(I=0;I<VarsNum;I++) |
if(type(RET[I])!=1) |
if(type(RET[I])!=1) |
return [1,RET]$ |
return [1,vtol(RET)]$ |
|
|
return [0,RET]$ |
return [0,vtol(RET)]$ |
} |
} |
|
|
def roundret(V){ |
def roundret(V){ |
|
|
VN=size(V)[0]$ |
VN=length(V)$ |
|
|
|
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*ltov(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,vtol(K*ltov(V)))$ |
return []$ |
|
else |
|
return RET1$ |
|
} |
} |
|
|
def chkou(L,ExpMat,CHAGORD){ |
def chkou(L,ExpMat,CHAGORD){ |
Line 414 def qcheckmain(PolyList,Vars){ |
|
Line 416 def qcheckmain(PolyList,Vars){ |
|
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(;L!=VarsNum && 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) |
Line 452 def checktd(PolyList,Vars,ResVars){ |
|
Line 454 def checktd(PolyList,Vars,ResVars){ |
|
return 1$ |
return 1$ |
} |
} |
|
|
def value2(Vars,Ans){ |
def value2(Vars,Ans,Ba,FLAG){ |
|
|
N=length(Vars)$ |
N=length(Vars)$ |
Res=newvect(N)$ |
Res=newvect(N)$ |
for(I=0;I<N;I++){ |
for(I=0;I<N;I++){ |
Res[I]=newvect(2)$ |
Res[I]=newvect(2)$ |
Res[I][0]=Vars[I]$ |
Res[I][0]=Vars[I]$ |
Res[I][1]=Ans[I]$ |
Res[I][1]=Ba*Ans[I]$ |
} |
} |
Res=map(vtol,Res)$ |
Res=map(vtol,Res)$ |
Res=vtol(Res)$ |
Res=vtol(Res)$ |
|
|
Res=getgcd(Res,Vars)$ |
Res=getgcd(Res,Vars)$ |
|
|
if(nonposdegchk(Res)){ |
if(nonposdegchk(Res)) |
TMP1=makeret(Res,Vars,1)$ |
return makeret(Res,Vars,FLAG)$ |
return vtol(TMP1[1])$ |
|
} |
|
else |
else |
return []$ |
return []$ |
} |
} |
Line 511 def qcheck(PolyList,Vars,FLAG){ |
|
Line 511 def qcheck(PolyList,Vars,FLAG){ |
|
|
|
if(FLAG==0){ |
if(FLAG==0){ |
|
|
if(TMP1[0]==0) |
if(TMP1[0]==0){ |
RET=append(RET,wsort(TMP1[1],Vars,TMP1[1],0))$ |
RET=append(RET,wsort(TMP1[1],Vars,TMP1[1],0))$ |
|
} |
else{ |
else{ |
|
|
TMP=vtol(TMP1[1])$ |
TMP=TMP1[1]$ |
RET0=[]$ |
RET1=[]$ |
if((TMP0=fixedpoint(TMP,0))!=[]){ |
if((TMP0=fixedpoint(TMP,0))!=[]){ |
|
|
for(I=0;I<length(TMP0);I++) |
for(I=0;I<length(TMP0);I++) |
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,1,0)$ |
|
|
if(RET0!=[]) |
if(RET0!=[]) |
RET0=wsort(RET0,Vars,RET0,1/10)$ |
RET1=wsort(RET0[1],Vars,RET0[1],-1)$ |
} |
} |
|
|
TMP=vtol(TMP1[1])$ |
TMP=TMP1[1]$ |
if(RET0==[] && (TMP0=fixedpoint(TMP,1))!=[]){ |
if(RET1==[] && (TMP0=fixedpoint(TMP,1))!=[]){ |
|
|
for(I=0;I<length(TMP0);I++) |
for(I=0;I<length(TMP0);I++) |
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,-1,0)$ |
|
|
if(RET0!=[]) |
if(RET0!=[]) |
RET0=wsort(RET0,Vars,RET0,1/10)$ |
RET1=wsort(RET0[1],Vars,RET0[1],-1)$ |
} |
} |
RET=append(RET,RET0)$ |
|
|
if(RET1!=[]) |
|
RET=append(RET,RET1)$ |
|
|
} |
} |
|
|
} |
} |
else if(FLAG==1) |
else if(FLAG==1) |
RET=append(RET,[[0,Vars,vtol(TMP1[1])]])$ |
RET=append(RET,[[0,Vars,TMP1[1]]])$ |
} |
} |
} |
} |
|
|
return RET$ |
return RET$ |
} |
} |
|
|
|
def unitweight1(ExpMat,Vars,PolyListNum,OneMat,FLAG){ |
|
|
|
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)$ |
|
|
|
NormMat0=newvect(ExpMatColNum+1)$ |
|
for(I=0;I<ExpMatColNum;I++) |
|
NormMat0[I]=newvect(ExpMatColNum+1)$ |
|
|
|
for(I=0;I<ExpMatColNum;I++) |
|
for(J=I;J<ExpMatColNum;J++) |
|
for(K=0;K<ExpMatRowNum;K++) |
|
NormMat0[I][J]+= |
|
ExpMat[K][I]* |
|
ExpMat[K][J]$ |
|
|
|
NormMat1=newvect(ExtMatColNum)$ |
|
for(I=0;I<ExtMatColNum;I++) |
|
NormMat1[I]=newvect(ExtMatColNum)$ |
|
|
|
WorkMat=newvect(ExtMatColNum)$ |
|
for(I=0;I<ExtMatColNum;I++) |
|
WorkMat[I]=newvect(ExtMatColNum)$ |
|
|
|
for(I=0;I<ExpMatColNum;I++) |
|
for(J=I;J<ExpMatColNum;J++) |
|
NormMat1[I][J]=NormMat0[I][J]$ |
|
|
|
for(I=0;I<ExpMatColNum;I++) |
|
for(J=0;J<PolyListNum;J++) |
|
for(K=OneMat[J];K<OneMat[J+1];K++) |
|
NormMat1[I][J+ExpMatColNum]-=ExpMat[K][I]$ |
|
|
|
for(I=0;I<PolyListNum;I++) |
|
NormMat1[I+ExpMatColNum][I+ExpMatColNum]=OneMat[I+1]-OneMat[I]$ |
|
|
|
if(jacobi(ExtMatColNum,NormMat1,WorkMat)){ |
|
|
|
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]$ |
|
} |
|
|
|
if(nonposdegchk(Res)){ |
|
|
|
TMP1=makeret(Res,Vars,1)$ |
|
|
|
if(FLAG==0){ |
|
RET=append(RET,wsort(TMP1[1],Vars,map(drint,TMP1[1]),1))$ |
|
|
|
TMP=roundret(TMP1[1])$ |
|
if(TMP!=[]) |
|
RET=append(RET,wsort(TMP1[1],Vars,TMP,2))$ |
|
|
|
} |
|
else if(FLAG==1) |
|
RET=append(RET,[[1,Vars,TMP1[1]]])$ |
|
} |
|
} |
|
|
|
return [NormMat0,RET]$ |
|
} |
|
|
def leastsq(NormMat,ExpMat,Vars,FLAG,ID){ |
def leastsq(NormMat,ExpMat,Vars,FLAG,ID){ |
|
|
RET=[]$ |
RET=[]$ |
Line 600 def leastsq(NormMat,ExpMat,Vars,FLAG,ID){ |
|
Line 682 def leastsq(NormMat,ExpMat,Vars,FLAG,ID){ |
|
if(FLAG==0){ |
if(FLAG==0){ |
|
|
if(TMP1[0]==0){ |
if(TMP1[0]==0){ |
|
RET=append(RET,wsort(TMP1[1],Vars,map(drint,TMP1[1]),ID))$ |
|
|
TMP=roundret(TMP1[1])$ |
TMP=roundret(TMP1[1])$ |
|
|
RET=append(RET,wsort(TMP1[1],Vars,map(drint,TMP1[1]*1.0),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{ |
|
|
TMP=vtol(TMP1[1])$ |
TMP=TMP1[1]$ |
RET0=[]$ |
RET1=[]$ |
if((TMP0=fixedpoint(TMP,0))!=[]){ |
if((TMP0=fixedpoint(TMP,0))!=[]){ |
|
|
for(I=0;I<length(TMP0);I++) |
for(I=0;I<length(TMP0);I++) |
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,1,1)$ |
|
|
if(RET0!=[]) |
if(RET0!=[]) |
RET0=wsort(RET0,Vars,RET0,ID+1/10)$ |
RET1=wsort(RET0[1],Vars,map(drint,RET0[1]),-ID)$ |
|
|
} |
} |
|
|
TMP=vtol(TMP1[1])$ |
TMP=TMP1[1]$ |
if(RET0==[] && (TMP0=fixedpoint(TMP,1))!=[]){ |
if(RET1==[] && (TMP0=fixedpoint(TMP,1))!=[]){ |
|
|
for(I=0;I<length(TMP0);I++) |
for(I=0;I<length(TMP0);I++) |
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,-1,1)$ |
|
|
if(RET0!=[]) |
if(RET0!=[]) |
RET0=wsort(RET0,Vars,RET0,ID+1/10)$ |
RET1=wsort(RET0[1],Vars,map(drint,RET0[1]),-ID)$ |
} |
} |
|
|
RET=append(RET,RET0)$ |
if(RET1!=[]){ |
|
RET=append(RET,RET1)$ |
|
TMP=roundret(RET0[1])$ |
|
if(TMP!=[]) |
|
RET=append(RET,wsort(RET0[1],Vars,TMP,-(ID+1)))$ |
|
} |
|
|
} |
} |
|
|
} |
} |
else if(FLAG==1) |
else if(FLAG==1) |
RET=append(RET,[[ID,Vars,vtol(TMP1[1])]])$ |
RET=append(RET,[[ID,Vars,TMP1[1]]])$ |
} |
} |
|
|
return RET$ |
|
} |
|
|
|
def unitweight(ExpMat,Vars,PolyListNum,OneMat,FLAG){ |
|
|
|
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)$ |
|
|
|
NormMat0=newvect(ExpMatColNum)$ |
|
for(I=0;I<ExpMatColNum;I++) |
|
NormMat0[I]=newvect(ExpMatColNum)$ |
|
|
|
for(I=0;I<ExpMatColNum;I++) |
|
for(J=I;J<ExpMatColNum;J++) |
|
for(K=0;K<ExpMatRowNum;K++) |
|
NormMat0[I][J]+= |
|
ExpMat[K][I]* |
|
ExpMat[K][J]$ |
|
|
|
NormMat1=newvect(ExtMatColNum)$ |
|
for(I=0;I<ExtMatColNum;I++) |
|
NormMat1[I]=newvect(ExtMatColNum)$ |
|
|
|
|
|
WorkMat=newvect(ExtMatColNum)$ |
|
for(I=0;I<ExtMatColNum;I++) |
|
WorkMat[I]=newvect(ExtMatColNum)$ |
|
|
|
|
|
for(I=0;I<ExpMatColNum;I++) |
|
for(J=I;J<ExpMatColNum;J++) |
|
NormMat1[I][J]=NormMat0[I][J]$ |
|
|
|
for(I=0;I<ExpMatColNum;I++) |
|
for(J=0;J<PolyListNum;J++) |
|
for(K=OneMat[J];K<OneMat[J+1];K++) |
|
NormMat1[I][J+ExpMatColNum]-=ExpMat[K][I]$ |
|
|
|
for(I=0;I<PolyListNum;I++) |
|
NormMat1[I+ExpMatColNum][I+ExpMatColNum]=OneMat[I+1]-OneMat[I]$ |
|
|
|
if(jacobi(ExtMatColNum,NormMat1,WorkMat)){ |
|
|
|
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]$ |
|
} |
|
|
|
if(nonposdegchk(Res)){ |
|
|
|
TMP1=makeret(Res,Vars,1)$ |
|
|
|
if(FLAG==0){ |
|
TMP=roundret(TMP1[1])$ |
|
|
|
RET=append(RET,wsort(TMP1[1],Vars,map(drint,TMP1[1]*1.0),1))$ |
|
|
|
if(TMP!=[]) |
|
RET=append(RET,wsort(TMP1[1],Vars,TMP,2))$ |
|
} |
|
else if(FLAG==1) |
|
RET=append(RET,[[1,Vars,vtol(TMP1[1])]])$ |
|
} |
|
} |
|
|
|
return [NormMat0,RET]$ |
return [NormMat0,RET]$ |
} |
} |
|
|
Line 755 def weight(PolyList,Vars,FLAG){ |
|
Line 768 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)$ |
|
if(TMP[1]!=[]) |
|
RET=append(RET,TMP[1])$ |
|
|
RET=append(RET,TMP[1])$ |
TMP=leastsq(0,ExpMat,Vars,FLAG,3)$ |
|
if(TMP[1]!=[]) |
|
RET=append(RET,TMP[1])$ |
|
|
TMP0=leastsq(TMP[0],ExpMat,Vars,FLAG,3)$ |
|
|
|
RET=append(RET,TMP0)$ |
|
|
|
ExpMat=qsort(ExpMat,junban)$ |
ExpMat=qsort(ExpMat,junban)$ |
|
|
ExpMat2=[]$ |
ExpMat2=[]$ |
Line 772 def weight(PolyList,Vars,FLAG){ |
|
Line 785 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))$ |
TMP=leastsq(0,ExpMat,Vars,FLAG,5)$ |
|
if(TMP[1]!=[]) |
|
RET=append(RET,TMP[1])$ |
} |
} |
else{ |
else{ |
TMP0=map(ltov,TMP0)$ |
TMP=map(ltov,TMP[1])$ |
|
|
for(I=0;I<length(TMP0);I++) |
for(I=0;I<length(TMP);I++){ |
if(TMP0[I][0]==3) |
if(TMP[I][0]==3) |
TMP0[I][0]=5$ |
TMP[I][0]=5$ |
else if(TMP0[I][0]==4) |
else if(TMP[I][0]==4) |
TMP0[I][0]=6$ |
TMP[I][0]=6$ |
|
else if(TMP[I][0]==-3) |
|
TMP[I][0]=-5$ |
|
else if(TMP[I][0]==-4) |
|
TMP[I][0]=-6$ |
|
|
TMP0=map(vtol,TMP0)$ |
} |
|
|
RET=append(RET,TMP0)$ |
TMP=map(vtol,TMP)$ |
|
|
|
RET=append(RET,TMP)$ |
} |
} |
|
|
return RET$ |
return RET$ |
} |
} |
|
|
end$ |
end$ |
|
|
|
|