dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #19905
Re: [Question #129481]: Writing matrices in Python
On Thursday October 14 2010 12:20:55 Andy R Terrel wrote:
> New question #129481 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/129481
>
> I need to write out some assembled matrices in Matrix Market format,
> hopefully from the Python interface. Easily for small matrices I can do:
>
> from dolfin import *
> from scipy.io import mmio
> from scipy.sparse import csr_matrix
> ...
> A = Matrix()
> b = Vector()
>
> assemble_system(a, L, bcs=bc0, A_tensor=A, b_tensor=b)
>
> mmio.mmwrite("A.mtx", csr_matrix(A.array()))
> mmio.mmwrite("b.mtx", csr_matrix(b.array()))
>
> But once A gets large calling "A.array()" takes forever. Is there a way in
> python that I can just query the sparsity structure of A?
>
> Any other ideas on how to do this quickly?
Shift backend to MTL4 or uBLAS and then:
rows, cols, values = A.data()
Johan
Follow ups
References