Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [ B ] = inv_by_czarek( A )
- %[ B ] = inv_by_czarek( A ) The function calculates inverse of matrix A
- %using double Gauss elimintation concept
- [r, c] = size(A);
- if (r == c)
- Z=[A,eye(r)];
- for i=1:c-1;
- for j=i+1:r;
- Z(j,:)=Z(j,:)-Z(j,i)/Z(i,i)*Z(i,:);
- end;
- end;
- for i=c:-1:2;
- for j=i-1:-1:1;
- Z(j,:)=Z(j,:)-Z(j,i)/Z(i,i)*Z(i,:);
- end
- end
- B=Z;
- else
- disp('Dear user of my function,');
- disp ('you should be so smart enough to know that the matrix A must be sqare one!');
- end;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement