[SciPy-user] math operations on sparse matrices
Sat Feb 21 21:50:29 CST 2009
On Sat, Feb 21, 2009 at 8:33 PM, <firstname.lastname@example.org> wrote:
> That was also my first guess, however
> <50x50 sparse matrix of type '<type 'numpy.float64'>'
> with 208 stored elements in Dictionary Of Keys format>
> Traceback (most recent call last):
> File "<pyshell#78>", line 1, in <module>
> File "\Programs\Python25\Lib\site-packages\scipy\sparse\base.py",
> line 429, in __getattr__
> AttributeError: data not found
Note the .tocsr() in the first step:
>>> M = M.tocsr()
>>> M.data = np.exp(M.data)
> From the graphical results it seems to work, but since this is my
> first try with scipy.sparse.linalg, I'm not sure what the methods to
> in detail.
You'll want to convert to CSR (or CSC) before calling those solvers
anyway. CSR/CSC offer much faster matrix-vector products, the main
cost in most iterative methods.
Nathan Bell email@example.com
More information about the SciPy-user