[SciPy-dev] feedback on scipy.sparse
Thu Dec 13 04:57:43 CST 2007
2007/12/13, Robert Cimrman <firstname.lastname@example.org>:
> 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 : from scipy import *
> >> In : from scipy.sparse import *
> >> In : row = array([0,0,1,1,1])
> >> In : col = array([10,11,50,55,100])
> >> In : data = array([1.,2.,1.,3.,4.])
> >> In : A = coo_matrix((data,(row,col)),dims=(3,3))
> should construct such a matrix, no?
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).
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...
More information about the Scipy-dev