Matrix Partial Pivoting, Gauss Elimination
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Original Question:
Function: gauss_banded.m
Modify the Gauss Elimination with Partial Pivoting algorithm we’ve developed to take advantage of the lower bandwidth to prevent any unneccesary computation. That is, no arithmetic should be performed on any element that is known to be zero.
Inputs: A The coefficient matrix.
b The right-hand-side vector
lb The lower bandwidth, i.e., the number of stripes below the matrix diagonal that have non-zero elements.
Outputs:
U The upper triangular result
d The transformed right-hand-side vector
. .
.
This is what I have so far:
%hw7_#3
function G = gauss_banded( A, b, 1b)
%A = coefficient matrix; b= right hand side vector; 1b= lower bandwith
format short
m= length(A(:,1)); %number rows
n= length(A(1,:)); % number of columns
for p= 1:m-1
a_max_p= max(abs(A(p:m,p)));
if a_max_p == 0
q=p;
else;
q= find(A(:,p)== a_max_p);
if isempty(q)
q= find(A(:,p)== -a_max_p);
end
end
temp= A(q,:);
A(q,:)= A(p,:);
A(p,:)= temp;
end
if A(p,p) ~= 0
for i= ((p+1):m
Lij = A(i,p)/A(p,p);
for j= p:n
A(i,j) = A(i,j) - Lij*A(p,j);
end
end
end
end
G= A
Im really not sure how to get the outputs
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!