[SciPy-dev] feedback on scipy.sparse
Stefan van der Walt
stefan at sun.ac.za
Wed Dec 12 05:03:04 EST 2007
Hi Matthieu
On Wed, Dec 12, 2007 at 09:46:16AM +0100, Matthieu Brucher wrote:
> Also, feel free to respond with any other comments related to scipy.sparse
>
>
> I'd like to know if some fancy indexing will be available soon. I explain
> myself. I need to populate a sparse matrix with some weights for each line. I'd
> like to do s[i, indices] = weights but it does not seem to work. I could use a
> loop, but it would be slower and this is not acceptable (as it is possible to
> do so in Matlab).
The lil_matrix is used to construct matrices like that:
In [1]: import scipy.sparse as S
In [2]: x = S.lil_matrix((3,3))
In [3]: x[0,:] = 4
In [4]: x
Out[4]:
<3x3 sparse matrix of type '<type 'numpy.float64'>'
with 3 stored elements in LInked List format>
In [5]: x.todense()
Out[5]:
matrix([[ 4., 4., 4.],
[ 0., 0., 0.],
[ 0., 0., 0.]])
Regards
Stéfan
More information about the SciPy-Dev
mailing list