{"id":408,"date":"2017-09-14T12:12:34","date_gmt":"2017-09-14T15:12:34","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=408"},"modified":"2017-09-14T12:12:34","modified_gmt":"2017-09-14T15:12:34","slug":"plu-m","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/plu-m\/","title":{"rendered":"plu.m"},"content":{"rendered":"<pre>function [P, L, U, pivcol, sign] = plu(A)\r\n\r\n% plu  Rectangular PA=LU factorization *with row exchanges*.\r\n%\r\n% [P, L, U] = plu(A), for a rectangular matrix A, uses Gaussian elimination\r\n% to compute a permutation matrix P, a lower triangular matrix L and \r\n% an upper trapezoidal matrix U so that PA = LU.\r\n% U is the same size as A.  \r\n% P and L are square, with as many rows as A.\r\n% sign = det(P); it is 1 or -1.\r\n%\r\n% See also elim, slu, lu, rref, partic, nulbasis, colbasis.\r\n\r\n[m, n] = size(A);\r\nP = eye(m, m);\r\nL = eye(m, m);\r\nU = zeros(m, n);\r\npivcol = [];\r\ntol = sqrt(eps);\r\nsign = 1;\r\n\r\np = 1;\r\nfor k = 1:min(m, n)\r\n   [r, p] = findpiv(A(k:m, p:n), k, p, tol);\r\n   if r ~= k\r\n      A([r k], 1:n) = A([k r], 1:n);\r\n      if k &gt; 1, L([r k], 1:k-1) = L([k r], 1:k-1); end\r\n      P([r k], 1:m) = P([k r], 1:m);\r\n      sign = -sign;\r\n   end\r\n   if abs(A(k, p)) &gt;= tol\r\n      pivcol = [pivcol p];\r\n      for i = k+1:m\r\n         L(i, k) = A(i, p) \/ A(k, p);\r\n         for j = k+1:n\r\n            A(i,j) = A(i, j) - L(i, k)*A(k, j);\r\n         end\r\n      end\r\n   end\r\n   for j = k:n\r\n      U(k, j) = A(k, j) * (abs(A(k, j)) &gt;= tol);\r\n   end\r\n   if p &lt; n, p = p+1; end\r\nend\r\n\r\nif nargout &lt; 4\r\n   nopiv = 1:n;\r\n   nopiv(pivcol) = [];\r\n   if ~isempty(pivcol), disp('Pivots in columns:'), disp(pivcol); end\r\n   if ~isempty(nopiv), disp('No pivots in columns:'), disp(nopiv); end\r\n   rank = length(pivcol);\r\n   if rank &gt; 0\r\n      roworder = P*(1:m)';\r\n      disp('Pivots in rows:'), disp(roworder(1:rank)'); end\r\n   end\r\nend<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>function [P, L, U, pivcol, sign] = plu(A) % plu Rectangular PA=LU factorization *with row exchanges*. % % [P, L, U] = plu(A), for a rectangular matrix A, uses Gaussian elimination % to compute a permutation matrix P, a lower triangular matrix L and % an upper trapezoidal matrix U so that PA = LU. [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-408","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=408"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/408\/revisions"}],"predecessor-version":[{"id":409,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/408\/revisions\/409"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}