[SciPy-user] arbitrary submatrices of a sparse matrix?
David Warde-Farley
dwf@cs.toronto....
Thu Dec 13 19:23:50 CST 2007
On 13-Dec-07, at 6:15 PM, David Warde-Farley wrote:
> Hi there,
>
> I'm porting some MATLAB code that makes use of the Matlab convention
> of multiple index vectors to pull out an arbitrary submatrix, i.e.
>
> x([4,6,2,7],[1,7,3]) would give you a 4x3 matrix containing rows
> 4,5,6,7 and cols 1,2,3 of the original matrix.
>
> I've figured out how to do this for full matrices (either x
> [[4,6,2,7],:][:,1,7,3] or by playing with take()) but I'm at a loss
> for how to do it with a sparse matrix, if it's even possible (not
> sure how matlab pulls it off).
Hmm, I've just noticed that get_submatrix() in SVN *claims* to do
what I want it to do, but actually doesn't. It works fine with
slices, but with tuples it always returns a 1x1. Is it supposed to do
that? (There's no test case for this particular functionality and the
documentation is, shall we say, sparse)
If there's some easy way to permute the rows and columns of a CSR/CSC
matrix then I would be able to get the job done with slices... Is
there? Or is there some way to do this that I'm not seeing?
Thanks again,
David
More information about the SciPy-user
mailing list