csr_matrix with mtl4

Asked by Melanie Jahny

I'd like to write a matrix in a compressed row storage format
using the csr_matrix - function from scipy. According the
FEniCS Documentation I use the MTL4 as linear algebra backend.
I updated FEniCS to Version 1:1.0-beta2-2~ppa1~natty1
and now, importing MTL4 I get the following error:

parameters["linear_algebra_backend"] ="MTL4"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/dolfin/cpp.py", line 1957, in __setitem__
    par._assign(value)
RuntimeError: *** Error: Illegal value for parameter. Allowed values are: [Epetra, PETSc, STL, uBLAS]

Isn't it possible to use MTL4 anymore? Or is something wrong with my installation?
Can I use the csr_matrix-function with another linear algebra backend?
I know that uBLAS also works, but I think only for 1d arrays. I'd like to do:

mesh = Rectangle(0,0, 10,10,10,10)
mesh.order()

U = FunctionSpace(mesh, "Raviart-Thomas", 1)
W = FunctionSpace(mesh, "DG", 0)
psi_c = TestFunction(U)
phi = TrialFunction(W)

int_psi = phi*div(psi_c)*dx
C_mat = assemble(int_psi)

rows, columns, values = C_mat.data()
C_arr = sp.sparse.csr.csr_matrix(values, rows, columns)

Thanks for any help!!!

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Anders Logg
Solved:
Last query:
Last reply:
Revision history for this message
Best Anders Logg (logg) said :
#1

On Tue, Nov 08, 2011 at 03:55:45PM -0000, Melanie Jahny wrote:
> New question #178040 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/178040
>
> I'd like to write a matrix in a compressed row storage format
> using the csr_matrix - function from scipy. According the
> FEniCS Documentation I use the MTL4 as linear algebra backend.
> I updated FEniCS to Version 1:1.0-beta2-2~ppa1~natty1
> and now, importing MTL4 I get the following error:
>
> parameters["linear_algebra_backend"] ="MTL4"
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/python2.7/dist-packages/dolfin/cpp.py", line 1957, in __setitem__
> par._assign(value)
> RuntimeError: *** Error: Illegal value for parameter. Allowed values are: [Epetra, PETSc, STL, uBLAS]

It looks like the package is built without MTL4. You can check which
backends are available by calling

  list_linear_algebra_backends()

> Isn't it possible to use MTL4 anymore? Or is something wrong with my installation?
> Can I use the csr_matrix-function with another linear algebra backend?
> I know that uBLAS also works, but I think only for 1d arrays. I'd like to do:
>
> mesh = Rectangle(0,0, 10,10,10,10)
> mesh.order()
>
> U = FunctionSpace(mesh, "Raviart-Thomas", 1)
> W = FunctionSpace(mesh, "DG", 0)
> psi_c = TestFunction(U)
> phi = TrialFunction(W)
>
> int_psi = phi*div(psi_c)*dx
> C_mat = assemble(int_psi)
>
> rows, columns, values = C_mat.data()
> C_arr = sp.sparse.csr.csr_matrix(values, rows, columns)

This has been changed in SciPy. You now need to do this:

  csr = csr_matrix((values, columns, rows))

--
Anders

Revision history for this message
Melanie Jahny (melanie-jahny) said :
#2

Thanks Anders for the fast and helpfull answer.
I think it was build without MTL4. And also, I
have the use the new scipy syntax for csr-matrices.

Revision history for this message
Johannes Ring (johannr) said :
#3

JFYI: The DOLFIN package in Ubuntu is built without support for MTL4
because MTL4 is not available as a package in Ubuntu.

Revision history for this message
Melanie Jahny (melanie-jahny) said :
#4

Thank you for that information! So I don't have to
try to install it.

Revision history for this message
Johannes Ring (johannr) said :
#5

No. If you need DOLFIN with MTL4 you will have to build DOLFIN from source. You can use Dorsal, which will do this automatically for you.