[petsc-users] Storing a matrix in PETSc binary form?

John Chludzinski jchludzinski at gmail.com
Wed Jul 13 00:21:54 CDT 2011


They're dense.  I'm trying to use a SLEPc generalized eigenvalue example
that expects matrices stored in PETSc binary files.

---John


On Wed, Jul 13, 2011 at 1:02 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
>   If it is truly a dense matrix then it isn't clear that you want to store
> it as a PETSc binary matrix but you can using the following code
>
>   PetscInt   n;
>   PetscScalar *values;
>
>   allocate values the correct size; read the entries into values then call
> MatCreateSeqDense(PETSC_COMM_SELF,n,n,values,&A); the call
> MatView(A,PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD));
>
>   Barry
>
> On Jul 12, 2011, at 11:41 PM, John Chludzinski wrote:
>
> > I have a matrix stored as a sequential list of binary values (not PETSc
> binary form) that I read in with a single block read:
> >
> >    read( (void *)K, sizeof(double), SIZE*SIZE, fpK ).
> >
> > How do I convert this simple binary file of (sequentially stored) doubles
> into a "PETSc binary matrix file"?
> >
> > ---John
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110713/2cedc279/attachment.htm>


More information about the petsc-users mailing list