<div><div><br></div><div><br><div class="gmail_quote"></div></div></div><div><div dir="ltr">On Tue, 26 Feb 2019 at 08:50, Eda Oktay via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Okay, but here is another silly question:<div><br><div>From MatGetRow(), I get number of nonzeros in row, column indices and values right? </div></div></div></blockquote><div dir="auto"><br></div></div><div><div dir="auto">Yes</div></div><div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Also, PetscBinaryWrite() needs a buffer p and the number of items to write n. </div><div><br></div><div>I need both row,column indices and values. </div></div></div></blockquote><div dir="auto"><br></div></div><div><div dir="auto">Row index was proved to MatGetRow as an input arg - MatGetRow returns the rest of what you need.</div></div><div><div dir="auto"><br></div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>So, what should I write into PetscBinaryWrite? </div></div></div></blockquote><div dir="auto"><br></div></div><div><div dir="auto">That's up to you. You are in control of the format of your binary file.</div></div><div><div><div class="gmail_quote"><div dir="auto"><br></div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Does this for loop give me these 3 arrays (arrays consist of row indices,column indices and values)?</div></div></div></blockquote><div dir="auto"><br></div><div dir="auto">Yes but you don't have an array for row indices - you only have a single value. If you use Matt's loop you would be writing the matrix row by row to your binary file.</div><div dir="auto"><br></div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div></div></div><div><br></div><div>Eda</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>, 25 Şub 2019 Pzt, 18:37 tarihinde şunu yazdı:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Mon, Feb 25, 2019 at 10:20 AM Eda Oktay <<a href="mailto:eda.oktay@metu.edu.tr" target="_blank">eda.oktay@metu.edu.tr</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr" class="m_1728740245207335293m_-5222231133915338510gmail-m_-6790546421713569230gmail-m_-3405181345356183051m_-1049986864477567111gmail-m_-5742471195181837873gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Thank you for your answer Matt, but I have some questions about PetscBinaryWrite() since I am a new user.<div><br></div><div>Since I am going to use this function, I guess I have to open a new binary file with <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewerBinaryOpen.html#PetscViewerBinaryOpen" target="_blank">PetscViewerBinaryOpen</a> and <span style="color:rgb(0,0,0)"> </span><a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewerBinaryGetDescriptor.html#PetscViewerBinaryGetDescriptor" target="_blank">PetscViewerBinaryGetDescriptor</a>, and destroy viewer by <span style="color:rgb(0,0,0)"> </span><a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewerDestroy.html#PetscViewerDestroy" target="_blank">PetscViewerDestroy</a>. Do I write these functions into for loop or not?</div></div></div></div></div></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>No, they go outside.</div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr" class="m_1728740245207335293m_-5222231133915338510gmail-m_-6790546421713569230gmail-m_-3405181345356183051m_-1049986864477567111gmail-m_-5742471195181837873gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div>Eda</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>, 25 Şub 2019 Pzt, 17:31 tarihinde şunu yazdı:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Mon, Feb 25, 2019 at 5:25 AM Eda Oktay via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I am trying to find the indices (both row and column separately) of nonzero entries of a sparse matrix in Petsc Binary Format. I found MatGetSeqNonzeroStructure but it gives me a struct and I don't know whether this is what I want or not.</div></div></blockquote><div><br></div><div>I would not do it that way, since it is fragile. I would write a loop like this:</div><div><br></div><div>MAtGetOwnershipRange();</div><div>for (row = rStart; row < rEnd; ++row) {</div><div>  MatGetRow()</div><div>  PetscBinaryWrite()</div><div>  MatRestoreRow()</div><div>}</div><div><br></div><div>This will work for any matrix.</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Best regards,</div><div><br></div><div>Eda</div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_1728740245207335293m_-5222231133915338510gmail-m_-6790546421713569230gmail-m_-3405181345356183051gmail-m_-1049986864477567111gmail-m_-5742471195181837873gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a></div></div></div></div></div></div></div></div></blockquote></div></div></div></div></div></div></div></div></div>
</blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_1728740245207335293m_-5222231133915338510gmail-m_-6790546421713569230gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div>
</blockquote></div></div>
</div>