I'm trying to solve a linear system with a sparse,
symmetric matrix and have some questions I'm hoping
someone can help me with. I'm using Octave-3.2.4,
by the way.
I'm calling chol() directly and providing only entries
in the upper triangle of the matrix. This works fine
even though the Octave doc does not say specifically that
only the upper triangle is needed.
However, if I first call amd() to order the matrix, I get
a permutation that puts the entries in both upper and lower
triangles so chol() fails.
My questions are:
1) Is there a fundamentally better way to deal with this type
of system (I strongly prefer storing only 1/2 the matrix)?
2) Is there a method (with good performance) that will
rearrange my permuted sparse matrix to move all the lower
entries to the upper triangle?
Here is a code sample that works:
K = [[0,0,2]; [0,1,-2]; [0,4, -1];
[2,2,5]; [2,3,-3]; [3,3,10]; [3,4,4]; [4,4,10]];
for i = 1:2
K(:,i) += 1;
ks = sparse(K(:,1), K(:,2), K(:,3));
b = [0,1,0,0,0];
lt = chol(ks);
u = lt \ (lt'\b')
But if I replace the relevant lines with:
p = amd(ks)
lt = chol(ks(p,p));
x = lt \ (lt'\b(p)');
u = x(p);
I run into the problem described above.