Converting matrices from pysparse
Hi all, Just now I have installed pysparse via http://people.web.psi.ch/geus/pyfemax/download.html. It works fine for me ! Is it possible to convert matrices from the pysparse specific format into a format such that I can visualize them with pylab.spy ?
type(A) <type 'sss_mat'>
from pylab import spy, show spy(A) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib64/python2.4/site-packages/matplotlib/pylab.py", line 2281, in spy ret = gca().spy(*args, **kwargs) File "/usr/lib64/python2.4/site-packages/matplotlib/axes.py", line 5089, in spy nr, nc = Z.shape ValueError: need more than 0 values to unpack
I have used the following example from the website from pysparse import itsolvers, poisson, precon, jdsym A = poisson.poisson2d_sym(200).to_sss() K = precon.ssor(A) k_conv, lmbd, Q, it, it_inner = \ jdsym.jdsym(A, None, K, 5, 0.0, 1e-10, 150, itsolvers.qmrs, clvl=1) Nils
Nils Wagner wrote:
Hi all,
Just now I have installed pysparse via http://people.web.psi.ch/geus/pyfemax/download.html. It works fine for me !
Is it possible to convert matrices from the pysparse specific format into a format such that I can visualize them with pylab.spy ?
type(A)
<type 'sss_mat'>
Hi Nils, In Pysparse, it is much easier to deal with the linked-list format (ll_mat) for matrix updates/visualization. The compressed sparse row (csr) and sparse skyline (sss) formats are useful when it comes to computation (e.g., csr is faster for matrix-vector products). In NLPy (nlpy.sf.net), which is based on Pysparse, I wrote a sparsity pattern visualizer for ll_mat matrices and Matplotlib. This is how it goes: import sparsetools import pylab M = sparsetools.rdm( 200, nnz = 250 ) # Create a random ll_mat (a,h) = sparsetools.spymatll( M, color = True ) pylab.show() I have been using Pysparse, Pylab and Python to combine efficient optimization building blocks into an environment in which it is easy to write optimization algorithms. If there is an interest, I'd be ready to join efforts. Dominique
participants (2)
-
Dominique Orban -
Nils Wagner