[SciPy-dev] feedback on scipy.sparse

Matthieu Brucher matthieu.brucher at gmail.com
Thu Dec 13 05:57:43 EST 2007


2007/12/13, Robert Cimrman <cimrman3 at ntc.zcu.cz>:
>
> Hi Matthieu,
>
> Matthieu Brucher wrote:
> > I thought I would use csr or csc as every row and column will have some
> > values, but not the same each time, so I don't think that coo is what I
> > need. But I will try lil when I have some time.
>
> Suppose you have:
>
> row, column, value
> 0, 10, 1.0
> 0, 11, 2.0
> 1, 50, 1.0
> 1, 55, 3.0
> 1, 100, 4.0
> - the values are not the same each time - there are two rows, each with
> own nonzero columns and values.
>
> then, as Nathan wrote:
> >> In [1]: from scipy import *
> >> In [2]: from scipy.sparse import *
> >> In [3]: row = array([0,0,1,1,1])
> >> In [4]: col = array([10,11,50,55,100])
> >> In [5]: data = array([1.,2.,1.,3.,4.])
> >> In [6]: A = coo_matrix((data,(row,col)),dims=(3,3))
>
> should construct such a matrix, no?
> r.


Yes, it should, I think I should go back to sleep...
Is there a way to create a sparse matrix from a list of lists directly and a
separate data array ? Just to know if I have to transform my list of lists
to the format (row, col).

Matthieu
-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20071213/b94302d3/attachment.html>


More information about the SciPy-Dev mailing list