Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: sparse matrix reordering
Date: Sun, 14 Dec 2008 08:38:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <gi2glb$q9r$1@fred.mathworks.com>
References: <ghu3ei$nl7$1@fred.mathworks.com> <ghuon6$n4n$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1229243883 26939 172.30.248.37 (14 Dec 2008 08:38:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 14 Dec 2008 08:38:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1337510
Xref: news.mathworks.com comp.soft-sys.matlab:506833


> The vector p can be considered a function whose input is k where k is a row/column index in the *new* matrix, and the output is i where i is a row/column of the old (unpermuted) matrix.  that is, i=p(k).  But if you want to change the *old* row/column indices to the *new* ones to use in sparse(...) then you need the inverse of this function, k=inverse_of_p(i).  You can compute the inverse permutation vector using:
> 
> n = size(A,1);
> invp = zeros (1,n) ;
> invp (p) = 1:n ;
> 
> then do
> 
> A1 = sparse (invp (row), invp (col), val) ;
> 
> by the way, p=amd(A) is faster than symamd.


if there's a sparse matrix problem, there's always a tim davis :-)

i would never have come up with using the inverse, as i always considered the vector p to be a function whose's input is the row/column index of the old matrix and the output the indices of the new one.

thanks, that helped a lot.