[petsc-users] petsc4py for numpy array <-> MATDENSE binary
Smith, Barry F.
bsmith at mcs.anl.gov
Fri Feb 1 16:50:09 CST 2019
Hmm, do you really want to store it as a PETSc dense matrix, or rather as a PETSc vector? I ask because it is natural to think of multidimensional arrays unrolled as a vector but a little strange for a multidimensional array to also be a dense matrix OPERATOR (since PETSc dense matrices are really linear operators that map vectors not 2 dimensional representations of vectors).
Anyways in C you would use MatCreateDense() and pass the 3D array (conceptually unrolled into a one dimensional array) as input. I do not know if PETSc4py has similar functionality.
Barry
> On Jan 31, 2019, at 7:07 PM, Sajid Ali via petsc-users <petsc-users at mcs.anl.gov> wrote:
>
> Hi,
>
> I have a large (~25k x 25k x 50) 3D array that I want to store as binary PETSc readable matrix using the MATDENSE format. I've currently achieved this (for smaller arrays) by writing the matrix out to an ASCII file and converting this ASCII file to binary, one number at a time using a C script.
>
> Does petsc4py support converting a 3d numpy array (complex valued) to MATDENSE (MPI) binary format directly ?
>
> I saw some discussion on this topic back in 2012 on the mailing list but it's not clear to me what happened after that.
>
> Thank You,
> Sajid Ali
> Applied Physics
> Northwestern University
More information about the petsc-users
mailing list