-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSparseLU.m
30 lines (27 loc) · 948 Bytes
/
SparseLU.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Code implementing the paper "Large-Scale Bounded Distortion Mappings".
% Disclaimer: The code is provided as-is for academic use only and without any guarantees.
% Please contact the author to report any bugs.
% Written by Shahar Kovalsky (http://www.wisdom.weizmann.ac.il/~shaharko/)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
classdef SparseLU < handle
properties
LHS;
L;
U;
p;
q;
end
methods
function obj = SparseLU(LHS)
if ~issparse(LHS)
error('Argument must be a sparse matrix')
end
obj.LHS = LHS;
[obj.L,obj.U, obj.p, obj.q] = lu(LHS, 'vector');
end
function x = solve(obj,RHS)
x(obj.q,:) = obj.U\(obj.L\(RHS(obj.p,:)));
end
end
end