[SciPy-user] arbitrary submatrices of a sparse matrix?

David Warde-Farley dwf@cs.toronto....
Thu Dec 13 17:15:29 CST 2007

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).

Any ideas?



More information about the SciPy-user mailing list