That is the default ASCII format.<br><br> Matt<br><br><div class="gmail_quote">On Tue, Feb 24, 2009 at 2:55 PM, Yixun Liu <span dir="ltr"><<a href="mailto:enjoywm@cs.wm.edu">enjoywm@cs.wm.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
You mean PETSc has no option to only output non-zero values with the<br>
format (row, column, value)?<br>
<div><div></div><div class="Wj3C7c"><br>
Khan, Irfan wrote:<br>
> I don't think so. Petsc has its own way to output matrix information in binary format that is platform independent.<br>
> However, I found that after loading into matlab, you can save or output the matrix in a format that you want.<br>
><br>
> Irfan<br>
><br>
> ----- Original Message -----<br>
> From: "Yixun Liu" <<a href="mailto:enjoywm@cs.wm.edu">enjoywm@cs.wm.edu</a>><br>
> To: "PETSc users list" <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>
> Sent: Tuesday, February 24, 2009 3:39:51 PM GMT -05:00 US/Canada Eastern<br>
> Subject: Re: output to matlab readable format<br>
><br>
> Thanks!<br>
><br>
> Can I save matrix into (row, column, value) format?<br>
><br>
><br>
> Khan, Irfan wrote:<br>
><br>
>> You will need to open a binary file to output the data. Try the following.<br>
>><br>
>><br>
>> PetscViewer viewer;<br>
>> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, "matrix", FILE_MODE_WRITE, &viewer);<br>
>> ierr = MatView(Amat,viewer);<br>
>> PetscViewerDestroy(viewer);<br>
>><br>
>> In order to load the file into matlab do the following<br>
>><br>
>> % $PETSC_DIR/bin/matlab/PetscBinaryRead("<path_to_file>")<br>
>><br>
>> Irfan<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> Hi,<br>
>> I use the following code to output matrix into file which can be read by<br>
>> matlab,<br>
>><br>
>> PetscViewer aviewer;<br>
>> PetscViewerCreate(PETSC_COMM_WORLD, &aviewer);<br>
>> PetscViewerSetType(aviewer, PETSC_VIEWER_ASCII);<br>
>> //PetscObjectSetName((PetscObject)sparseMechanicalStiffnessMatrix,<br>
>> aname);<br>
>> PetscViewerSetFormat(aviewer, PETSC_VIEWER_ASCII_MATLAB);<br>
>> PetscViewerFileSetName(aviewer, aname);<br>
>> MatView(sparseMechanicalStiffnessMatrix, aviewer);<br>
>> PetscViewerDestroy(aviewer);<br>
>><br>
>><br>
>><br>
>> The error is ASCII format file doesn't allow the matrix exceeds 512<br>
>> rows. So I change PETSC_VIEWER_ASCII to PETSC_VIEWER_BINARY, but it seem<br>
>> that PETSc outputs to screen.<br>
>><br>
>> Thanks.<br>
>><br>
>><br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>