你已经派生过 em3d-mt
镜像自地址
https://gitee.com/sduem/em3d-mt.git
已同步 2025-08-04 11:46:51 +08:00
27 行
754 B
Matlab
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
|