[SciPy-user] math operations on sparse matrices
Nathan Bell
wnbell at gmail.com
Sat Feb 21 22:50:29 EST 2009
On Sat, Feb 21, 2009 at 8:33 PM, <josef.pktd at gmail.com> wrote:
>
> That was also my first guess, however
>
>>>> M
> <50x50 sparse matrix of type '<type 'numpy.float64'>'
> with 208 stored elements in Dictionary Of Keys format>
>>>> M.data
> Traceback (most recent call last):
> File "<pyshell#78>", line 1, in <module>
> M.data
> 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 wnbell at gmail.com
http://graphics.cs.uiuc.edu/~wnbell/
More information about the SciPy-User
mailing list