[petsc-users] storing a matrix in petsc binary form

Jose E. Roman jroman at dsic.upv.es
Thu Mar 8 01:42:39 CST 2012


El 08/03/2012, a las 08:29, Wu Degang escribió:

> Hi,
> 
> I need to convert a matrix (in standard c array form) to the "pestc binary form" so that I can pass it to a slepc program which solves the eigenvalue spectrum for the matrix. I found someone else has raised this question long before (http://lists.mcs.anl.gov/pipermail/petsc-users/2011-July/009326.html), but the code cannot be compiled with petsc 3.2 (perhaps the code is for an older version?). Can anyone give me some guidance? or even some code?
> 
> Thanks.
> 
> Regards,
> Wu Degang

In 3.2 it would be something like this:

PetscViewer viewer;
Mat A;
MatCreateSeqDense(PETSC_COMM_SELF,n,n,values,&A);
PetscViewerBinaryOpen(PETSC_COMM_WORLD,"mymatrix.petsc",FILE_MODE_WRITE,&viewer);
MatView(A,viewer);
PetscViewerDestroy(&viewer);
MatDestroy(A);

Jose



More information about the petsc-users mailing list