| 1 |
function X = LUbsolve(LUdata, B) |
| 2 |
% function X = LUbsolve(LUdata, B) |
| 3 |
% |
| 4 |
% Solve for the diagonal blocks from LUfactor. |
| 5 |
% LUfactor must be called first. Schur complement must be solved and then |
| 6 |
% LUbsolve should be used. |
| 7 |
% |
| 8 |
% Erik Boman, Sandia National Labs, 2010. |
| 9 |
% Siva Rajamanickam, Sandia National Labs, 2010. |
| 10 |
|
| 11 |
k = LUdata.nblocks; |
| 12 |
A = LUdata.A; |
| 13 |
Xhat{k+1} = LUdata.Xhat; % Solution for the Schur complement |
| 14 |
|
| 15 |
% Solve for diagonal blocks. |
| 16 |
for i= 1:k |
| 17 |
% b_i = b_i - A_{i,k+1} x_{k+1} |
| 18 |
Bi = B(LUdata.p{i},:) - A(LUdata.p{i},LUdata.q{k+1}) * Xhat{k+1}; |
| 19 |
% x_i = A_ii \ b_i |
| 20 |
Xhat{i} = LUdata.U{i} \ (LUdata.L{i} \ Bi); |
| 21 |
end |
| 22 |
|
| 23 |
% Assemble solution in X. |
| 24 |
for i= 1:k |
| 25 |
X(LUdata.q{i},:) = Xhat{i}; |
| 26 |
end |
| 27 |
X(LUdata.q{k+1},:) = Xhat{k+1}; |