Problem: I have a sparse matrix A in petsc format (petsc4py.PETSc.Mat) and would like to create a sparse csr_matrix in scipy, without having to copy the data (if this is possible?)
Constraints: I'm stuck with version 1.4, using PETSc and uBLAS (and STL) as possible backends.
Solution so far:
ai, aj, av = A.getValuesCSR()
Asp = scipy.sparse.csr_matrix((av, aj, ai))
However this copies the data.
If I could somehow do Ablas = dolfin.uBLASMatrix(A)
like I can do dolfin.PETScMatrix(A)
, then I could use the following answer
http://fenicsproject.org/qa/9463/how-to-extract-sparse-matrix-from-assembled-form
But I cannot. Any ideas?