help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sparse symmetric matrices


From: Bill Greene
Subject: sparse symmetric matrices
Date: Sat, 11 Jun 2011 13:11:10 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9

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];
      [1,1,3]; [1,2,-2];
      [2,2,5]; [2,3,-3]; [3,3,10]; [3,4,4]; [4,4,10]];
 for i = 1:2
   K(:,i) += 1;
 end
 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.

Thanks.

Bill Greene



reply via email to

[Prev in Thread] Current Thread [Next in Thread]