文件
em3d-mt/bin/RMT3d/umfpack_MT.m
刘明宏 1e31390ba6 code
Signed-off-by: 刘明宏 <liuminghong@mail.sdu.edu.cn>
2025-04-29 07:11:41 +00:00

27 行
754 B
Matlab

function [x,res] = umfpack_MT(A,b)
% Solve for x in linear system A * x = b.
fprintf ('Solution to Ax=b via UMFPACK\n') ;
% Compute the numeric factorization via UMFPACK.
t = tic;
[L,U,P,Q,R,Info] = umfpack (A, struct ('details',0));
time(1) = toc(t);
fprintf (['The LU factorization time is ' num2str(time(1)) 's\n']) ;
% Compute the solution x using the symbolic factorization.
t = tic;
x = Q*(U\(L\(P*(R\b))));
x = full(x);
time(2) = toc(t);
fprintf (['The symbolic factorization time is ' num2str(time(2)) 's\n']) ;
% Compute the residuals.
for i = 1:2%size(b,2)
res(i) = norm(A*x(:,i)-b(:,i))/norm(b(:,i));
fprintf('%s %d\n',['Normalized residual from SuiteSparse for rhs' num2str(i) ' is'], res(i));
end
end