Matrix Partial Pivoting, Gauss Elimination
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!