restart;
taille:=proc(A)
local t,u,n,p;
t:=[op(2,evalm(A))];
n:=op(2,t[1]);p:=op(2,t[2]);
[n,p];
end:Permut_ligne:=proc(i,j,A)
local B,k,t;
t:=taille(A);
B:=array(1..t[1],1..t[2]);
B:=evalm(A);
for k from 1 to t[2] do
B[i,k]:=A[j,k]; B[j,k]:=A[i,k];
od;
evalm(B);
end: Dilat_ligne:=proc(a,i,A)
local k,t,B;
t:=taille(A);
B:=array(1..t[1],1..t[2]);
B:=evalm(A);
for k from 1 to t[2] do
B[i,k]:=a*A[i,k];
od;
evalm(B);
end:Transvect_ligne:=proc(i,a,j,A)
local k,t,B;
t:=taille(A);
B:=array(1..t[1],1..t[2]);
B:=evalm(A);
for k from 1 to t[2] do
B[i,k]:=A[i,k]+a*A[j,k];
od;
evalm(B);
end:CherchePivot_colonne:=proc(A,i)
local t,k;
t:=taille(A);
if is(i>t[1])then RETURN(IMPOSSIBLE); fi;
for k from i to t[1] do
if is(A[k,i]<>0) then RETURN(k); fi;
od;
RETURN(0);
end:Permut_colonne:=proc(i,j,A)
local B,k,t;
t:=taille(A);
B:=array(1..t[1],1..t[2]);
B:=evalm(A);
for k from 1 to t[1] do
B[k,i]:=A[k,j]; B[k,j]:=A[k,i];
od;
evalm(B);
end: zero_sous_pivot:=proc(i,A)
local t,B,k;
t:=taille(A);
B:=array(1..t[1],1..t[2]);
B:=evalm(A);
if is(i>t[2]) or is(i>t[1]) or is(B[i,i]=0) then RETURN(IMPOSSIBLE); fi;
B:=Dilat_ligne(1/B[i,i],i,B); Li <--1/a(ii) *Li
for k from i+1 to t[1] do
B:=Transvect_ligne(k,-B[k,i],i,B); Lk <-- Lk- a(ki)*L1
od;
evalm(B);
end:
Exercice 4question a)On modifie la proc\351dure Gauss_systeme en ajoutant la possibilit\351 de permuter les colonnes afin d'obtenir un pivot non nul sur la diagonale concern\351eGauss_rang:=proc(A)
local T,i,j,k,t;
t:=taille(A);
T:=array(1..t[1],1..t[2]);
T:=evalm(A); T contient une copie exact de A, mais T est modifiable contrairement \340 A
for j from 1 to min(t[1],t[2]) do
i:=CherchePivot_colonne(T,j);
k:=j+1; k est lindice de la colonne susceptible d'\352tre permut\351e avec la colonne j \351tudi\351e
while(i=0 and k<t[2]+1) do tant que l'on ne trouve pas de pivot non nul sous le coefficient a(jj) et tant qu'il reste des colonnes avec qui permuter
T:=Permut_colonne(j,k,T); on permute la colonne \351tudi\351e et avec une des colonnes suivantes
i:=CherchePivot_colonne(T,j); on chercher un pivot dans notre nouvelle colonne j
k:=k+1
od;
if i<>0 then T:=Permut_ligne(i,j,T);
T:=zero_sous_pivot(j,T);
fi;
od;
evalm(T);
end:B:=array(1..4,1..3,[[0,0,4],[0,0,5],[0,1,1],[0,1,1]]):B=evalm(B);Gauss_rang(B);question b)rang:=proc(A)
local t,k,B;
t:=taille(A);
B:=Gauss_rang(A);
sum(B[k,k],k=1..min(t[1],t[2])); le rang est \351gal au nombre (donc la somme) des coefficients valant 1 sur la diagonale apr\350s Gaussianisation
end:
rang(B);