Advertisement
Guest User

Untitled

a guest
Apr 25th, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. % COPYRIGHT: ANTON PUIU
  2. function [L, U] = crout(A = [2 -1 3; 4 5 1; 2 1 2])
  3. [m, n] = size(A);
  4. L = zeros(n, n);
  5. U = eye(n);
  6. if m != n
  7. return
  8. end
  9. for j = 1:n
  10. L(j:n, j) = A(j:n, j) - L(j:n, 1:j-1) * U(1:j-1, j);
  11. U(j, j+1:n) = 1 / L(j, j) * (A(j, j+1:n) - L(j, 1:j-1) * U(1:j-1, j+1:n));
  12. end
  13. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement