dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #19236
Re: [Question #121973]: Get sparse matrix data
Hello Dominique!
The CRS representation of a sparse matrix is LA backend dependent. It only
works for uBLAS and MTL4. So before you do your assemble, make sure that:
parameters.linear_algebra_backend = "uBLAS" or "MTL4"
then:
rows, cols, values = A.data()
The transposed matrix vector product is not wrapped to a more simpler syntax
(if that is what you are asking for?). Not sure what operator in Python we
need to overload to make that both pretty and without to much copying of data.
Cheers!
Johan
On Friday August 20 2010 03:22:31 Dominique wrote:
> New question #121973 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/121973
>
> Hello,
>
> The questions below are PETSc-related so please let me know if I really
> should ask them elsewhere.
>
> I'm generating a sparse coefficient matrix A using
>
> A = assemble(a)
>
> where a is some bilinear form. I'm wondering how I can access the arrays
> that describe A in compressed sparse row format. I thought A.data would do
> the job but:
>
> In [61]: A.data?
> Type: instancemethod
> Base Class: <type 'instancemethod'>
> String Form: <bound method Matrix.data of <dolfin.cpp.Matrix; proxy of
> <Swig Object of type 'dolfin::Matrix *' at 0x916ab18> >>
> Namespace: Interactive
> File: /home/orban/Work/FEniCS/lib/python2.6/site-
packages/dolfin/cpp.py
> Definition: A.data(self)
> Docstring:
> Return arrays to underlying compresssed row/column storage data
>
>
> In [62]: A.data()
> ---------------------------------------------------------------------------
> RuntimeError Traceback (most recent call last)
>
> /home/orban/Envs/sparse/dev/fenics/<ipython console> in <module>()
>
> /home/orban/Work/FEniCS/lib/python2.6/site-packages/dolfin/cpp.pyc in
> data(self) 2124 """ Return arrays to underlying compresssed
> row/column storage data """ 2125
> -> 2126 return self._data()
> 2127
> 2128 def __getitem__(self,indices):
>
> RuntimeError: *** Error: Unable to return pointers to underlying matrix
> data.
>
>
> I'm using FEniCS under Fedora.
>
> Also, I can compute matrix-vector products with A*x, but is there a better
> way to compute transpose matrix-vector products than with A.transpmult?
>
> Thanks!
> Dominique
Follow ups
References