Presentation is loading. Please wait.

Presentation is loading. Please wait.

Function [C]=cholesky(A) [n,m]=size(A); C=zeros(n,n); if (A(1,1)<%eps) then error('racine d un nombre negatif'); end C(1,1)=sqrt(A(1,1)); C(2:n,1)=A(2:n,1)/C(1,1);

Similar presentations


Presentation on theme: "Function [C]=cholesky(A) [n,m]=size(A); C=zeros(n,n); if (A(1,1)<%eps) then error('racine d un nombre negatif'); end C(1,1)=sqrt(A(1,1)); C(2:n,1)=A(2:n,1)/C(1,1);"— Presentation transcript:

1 function [C]=cholesky(A) [n,m]=size(A); C=zeros(n,n); if (A(1,1)<%eps) then error('racine d un nombre negatif'); end C(1,1)=sqrt(A(1,1)); C(2:n,1)=A(2:n,1)/C(1,1); for j=2:n sum1=C(j,1:j-1)*C(j,1:j-1)'; if (A(j,j)-sum1)<%eps then error('racine d un nombre negatif'); end C(j,j)=sqrt(A(j,j)-sum1); C(j+1:n,j)=(A(j+1:n,j)-C(j+1:n,1:j-1)*C(j,1:j-1)')/C(j,j); end endfunction

2 function [x]= solinf(U,b) [n,m]=size(U); x=zeros(n,1); if abs(U(1,1))<%eps error('un pivot de Gauss n''est pas défini'); end x(1)=b(1)/U(1,1); for i=2:n if abs(U(i,i))<%eps error('un pivot de Gauss n''est pas défini'); end x(i)=(b(i)-U(i,1:i-1)*x(1:i-1))/U(i,i); end endfunction function [x]= solsup(U,b) [n,m]=size(U); x=zeros(n,1); if abs(U(n,n))<%eps error('un pivot de Gauss n''est pas défini'); end x(n)=b(n)/U(n,n); for i=n-1:-1:1 if abs(U(i,i))<%eps error('un pivot de Gauss n''est pas défini'); end x(i)=(b(i)-U(i,i+1:n)*x(i+1:n))/U(i,i); end endfunction

3 function [x]=resolchol(A,b) getf solinf.sci; getf solsup.sci; getf cholesky.sci; C=cholesky(A); y=solinf(C,b); x=solsup(C',y); endfunction function [i]=place(T,t) n=length(T) if (t T(n)) error('erreur : t n''est pas dans l''intervalle'); end MIN=1; MAX=n; while (MAX-MIN)>1 MIL=floor((MAX+MIN)/2); if (t>=T(MIL)) MIN=MIL; else MAX=MIL; end i=MIN; endfunction

4 function [A]=construct(t,r) getf place.sci; n=length(t); m=length(r); A=zeros(m,n); for j=1:m i=place(t,r(j)); A(j,i)=(r(j)-t(i+1))/(t(i)-t(i+1)); A(j,i+1)=(r(j)-t(i))/(t(i+1)-t(i)); end endfunction function [z]=mcnorm(A,y) getf resolchol.sci B=A'*A; x=A'*y; z=resolchol(B,x); endfunction


Download ppt "Function [C]=cholesky(A) [n,m]=size(A); C=zeros(n,n); if (A(1,1)<%eps) then error('racine d un nombre negatif'); end C(1,1)=sqrt(A(1,1)); C(2:n,1)=A(2:n,1)/C(1,1);"

Similar presentations


Ads by Google