mbm
Inscrit le: 31 Mar 2007 Messages: 7
|
Posté le: 17 Avr 2007 12:14 Sujet du message: Gauss modulaire pour calculer les polynomes caracteristique |
|
|
bon jour
j'ai rencontré des problemes quand je veut execute le programme suivant qui calcule les polynomes caracteristique un utilisant la methode de Gauss modulaire.
je utilise des sous programes qui marches tous mais je ne sais pas ou il ya le probleme?
s'il vous plais vous m'aides ?
***************************************************************************
Euclide:=proc(a,b)ocal r , u,v, q, i, u0, u1, v0, v1, r0, r1;;r0:=a; r1:=b; u0:=1; u1:=0; v0:=0; v1:=1;while r1<>0 do q:=iquo(r0,r1);r:=r0-r1*q; u:=u0-u1*q; v:=v0-v1*q; r0:=r1; r1:=r; u0:=u1; u1:=u; v0:=v1; v1:=v; end do; [r0,u0,v0]end proc:
> chinois:=proc(Lp,Lv)local i,q, v, n ,M,l,x;M:=convert(Lp,`*`);x:=0;n:=nops(Lp);for i from 1 to n do q:=M/Lp[i];l:=Euclide(q,Lp[i]);x:=x+Lv[i]*q*l[2];end do;mods(x,M) end proc:
> Hadamar:=proc(A)local i,j,n,m,B;n:=linalg[rowdim](A);m:=linalg[coldim](A) ;B:=product(sqrt(sum(abs(A[i,j])^2,i=1..n)),j=1..m);ceil(B)end proc:
> Premiers:=proc(B)local l,p,i;l:=[];p:=1;i:=1;while p<=2*B do l:=[op(l),ithprime(i)];
p:=p*ithprime(i);i:=i+1 end do;
l
end proc:
> gauss:=proc(A,p)
local n,i,j,piv,s,d,l,B,x,ipiv,k, eu,c;
n:=linalg[coldim](A); d:=1; B:=map(x->x mod p, evalm(A));
for i to n do j:=i; piv:=B[j,i] mod p;
while piv=0 and j<n do j:=j+1; piv:=B[j,i] mod p end do ;
if piv=0 then return(0) else d:=d*piv;
for k from i to n do c:=B[i,k]; B[i,k]:=B[j,k]; B[j,k]:=c end do; eu:=Euclide(piv,p); ipiv:=eu[2];
for k from j+1 to n do l:=B[k,i]*ipiv mod p;
for s from i to n do B[k,s]:=B[k,s]-l*B[i,s] end do ; end do;
end if ; end do; d end proc:
>
> gaussmod:= proc(A::matrix)
local C,L,i,j,n,k,Lh,Lp,LL,Id;
n:=linalg[coldim](A);
L:=[copy(A)];
Lh:=[];Lp:=[];LL:=[];
Id:=LinearAlgebra[IdentityMatrix](n);
for k to n do
L[k]:=evalm(A-k*Id);
L:=[op(L),L[k]];
end do;
for i to nops(L) do
Lh[i]:=Hadamar(L[i]);
Lh:=[op(Lh),Lh[i]];
Lp[i]:=Premiers(Lh[i]);end do;
Lp:=[seq(Lp[i],i=1..n)];
for j to nops(Lp[i]) do
LL[j]:=[seq(gauss(L[i],Lp[i]), i=1..n)];
end do;
for i to n do
C[i]:=chinois(Lp[i],LL[i]);
C:=[seq(C[i],i=1..n)];
end do;
end proc:
> trace(gaussmod);
> A:=linalg[matrix](8,8,[-3,3,0,-2,-3,1,-2,2,1,2,1,1,2,3,2,0,2,2,3,-3,3,0,-2,-3,-2,0,1,-2,0,0,-1,2,3,-3,3,3,2,3,0,3,3,2,3,-3,1,2,-1,-2,-3,3,3,2,3,1,-2,0,0,-1,-3,-1,-1,1,-1,-3]);
> gaussmod(A);
{--> enter gaussmod, args = A
<-- ERROR in gaussmod (now at top level) = out of bound assignment to a \
list}
Error, (in gaussmod) out of bound assignment to a list |
|