Question: I need someone to write a Matlab function? The factorization PA=LU in gaussian elimination with partial pivoting to the input matrix (linpack ) The function
% rp - array containing information about the row interchanges used in the elimination process % flag - error flag (set to 0 if a is invertible, and set to k>0 if a nonzero pivot could not be found for column k) The calling sequence is [f, rp, flag] = lufac2 (a) [m,n] -size(a) If m ~= n matrix. ') end disp( 'The matrix must be a square return f = a; rp = zeros ( n , 1 ) ; for j=1:n-1 [mx , p] = max (abs ( f ( j: n, j) ) ) ; If mx == 0 flag j; return end p=p+j-1; rp ( j) = p; if p--j temp = f(j,j:n); f(p,j:n) temp ; end end if f(n,n)0 else end flag = n; flag 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
