I don't think so. Petsc has its own way to output matrix information in binary format that is platform independent. However, I found that after loading into matlab, you can save or output the matrix in a format that you want.
Irfan ----- Original Message ----- From: "Yixun Liu" <[email protected]> To: "PETSc users list" <petsc-users at mcs.anl.gov> Sent: Tuesday, February 24, 2009 3:39:51 PM GMT -05:00 US/Canada Eastern Subject: Re: output to matlab readable format Thanks! Can I save matrix into (row, column, value) format? Khan, Irfan wrote: > You will need to open a binary file to output the data. Try the following. > > > PetscViewer viewer; > ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, "matrix", > FILE_MODE_WRITE, &viewer); > ierr = MatView(Amat,viewer); > PetscViewerDestroy(viewer); > > In order to load the file into matlab do the following > > % $PETSC_DIR/bin/matlab/PetscBinaryRead("<path_to_file>") > > Irfan > > > > > > > > > > Hi, > I use the following code to output matrix into file which can be read by > matlab, > > PetscViewer aviewer; > PetscViewerCreate(PETSC_COMM_WORLD, &aviewer); > PetscViewerSetType(aviewer, PETSC_VIEWER_ASCII); > //PetscObjectSetName((PetscObject)sparseMechanicalStiffnessMatrix, > aname); > PetscViewerSetFormat(aviewer, PETSC_VIEWER_ASCII_MATLAB); > PetscViewerFileSetName(aviewer, aname); > MatView(sparseMechanicalStiffnessMatrix, aviewer); > PetscViewerDestroy(aviewer); > > > > The error is ASCII format file doesn't allow the matrix exceeds 512 > rows. So I change PETSC_VIEWER_ASCII to PETSC_VIEWER_BINARY, but it seem > that PETSc outputs to screen. > > Thanks. >
