%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function r=rayons(A) // //calcule le rayon spectral d'une matrice r= norm(spec(A),'inf') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function C=MatMult(A,B) // // Multplication de deux matrices // tester si les dimensions sont compatibles [m,n]=size(A);p=size(B,2); C=zeros(m,p) for i=1:m for j=1:p C(i,j)=A(i,:)*B(:,j); end; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function C=MatMultTriI(A,B) // // Multplication se deux matrices triangulaires inf. [m,n]=size(A);p=size(B,2); C=zeros(m,p) for i=1:m for j=1:i C(i,j)=A(i,j:i)*B(j:i,j); end; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function MatAffiche(a) // // visualise les elements d'une matrice // on choisit quelques couleurs, voir la palette // proposee, commande xset() couleur(1)= 1;couleur(2)=25;couleur(3)=26; couleur(4)=27;couleur(5)=28;couleur(6)=29; couleur(7)=30;couleur(8)=31;couleur(9)= 8; n=size(a,1);m=size(a,2); x=zeros(4,n*m);y=zeros(4,n*m); aa=abs(a);Grand=max(aa);petit=min(aa); if Grand~=petit then c=9+8*petit/(Grand-petit);d=-8/(Grand-petit); else c=0;d=1; end coloriage=round(d*aa+c); for i=1:length(coloriage) coloriage(i)=couleur(coloriage(i)); end; for j=1:m for i=1:n k=(j-1)*n+i; x(1,k)=i-.5;x(2,k)=i+.5;x(3,k)=i+.5;x(4,k)=i-.5; y(1,k)=j+.5;y(2,k)=j+.5;y(3,k)=j-.5;y(4,k)=j-.5; end; end; plot3d(x,y,list(zeros(4,n*m),coloriage),0,0,"@@",[2,2,3]) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function MatAfficheC(a,s) // // visualise le caractere creux d'une matrice : // met a 0 les elements d'une matrice // inferieurs en norme a s // et a 1 les autres [sortie, entree]=argn(0); if (entree==1) then,s=%eps; end; // valeur par defaut u=find(abs(a)>s);v=find(abs(a)<=s); a(u)=1;a(v)=0; MatAffiche(a) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [i,j]=indices(k,n,m) // // n = nombre de lignes // m = nombre de colonnes [sortie, entree]=argn(0); if entree==2 then, m=n; end; if k>n*m | n<1 |m<1 then error('erreur : indice hors tableau'),end; j= int((k-1)/n)+1; i=k-(j-1)*n; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function B=permuteC(A,i,j) // [m,n]=size(A); if i>n | j>n then error('probleme d''indices') end B=A; u=B(:,i); B(:,i)=B(:,j); B(:,j)=u; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function B=permuteL(A,i,j) // [m,n]=size(A); if i>m | j>m then error('probleme d''indices') end B=A; u=B(i,:); B(i,:)=B(j,:); B(j,:)=u;