[petsc-users] petsc4py and numpy
Lisandro Dalcin
dalcinl at gmail.com
Tue May 8 10:15:19 CDT 2012
On 8 May 2012 12:04, Matthew Knepley <knepley at gmail.com> wrote:
> On Tue, May 8, 2012 at 11:00 AM, Christian Staudt
> <christian.staudt at ira.uka.de> wrote:
>>
>> Matthew Knepley <knepley at gmail.com> wrote:
>>
>> a) Is there an easy and efficient way to convert a numpy.ndarray to a
>>
>> PETSc.Vec or PETSc.Mat (and vice-versa)? (A PETSc.Vec.getArray() returns
>> a
>>
>> numpy.ndarray, though I have found no such method for PETSc.Mat yet. )
>>
>>
>>
>> If you are using dense matrices (MATDENSE) then MatGetArray() works.
>>
>>
>> I don't think this is implemented in petsc4py: At least, there's no method
>> PETSc.Mat.getArray()
>
>
> If you ask Lisandro for it, he will put it in.
>
Matt, I've never put that in just because I'm not sure how to make it
general. PETSc have many different matrix formats, and MatGetArray()
call is like a hack, where you can get very different things (the "1D"
values of an AIJ matrix, the "2D" values of a dense matrix in Fortran
order). What about MPIAIJ, what should I return to users? Can you
suggest some approach or API to implement this (I mean, how to get
arrays for the various matrix types)?
--
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
3000 Santa Fe, Argentina
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169
More information about the petsc-users
mailing list