[petsc-users] Finding nonzero indices
Eda Oktay
eda.oktay at metu.edu.tr
Tue Feb 26 01:49:43 CST 2019
Okay, but here is another silly question:
>From MatGetRow(), I get number of nonzeros in row, column indices and
values right? Also, PetscBinaryWrite() needs a buffer p and the number of
items to write n.
I need both row,column indices and values. So, what should I write into
PetscBinaryWrite? Does this for loop give me these 3 arrays (arrays consist
of row indices,column indices and values)?
Eda
Matthew Knepley <knepley at gmail.com>, 25 Şub 2019 Pzt, 18:37 tarihinde şunu
yazdı:
> On Mon, Feb 25, 2019 at 10:20 AM Eda Oktay <eda.oktay at metu.edu.tr> wrote:
>
>> Thank you for your answer Matt, but I have some questions about
>>> PetscBinaryWrite() since I am a new user.
>>>
>>> Since I am going to use this function, I guess I have to open a new
>>> binary file with PetscViewerBinaryOpen
>>> <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewerBinaryOpen.html#PetscViewerBinaryOpen>
>>> and PetscViewerBinaryGetDescriptor
>>> <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewerBinaryGetDescriptor.html#PetscViewerBinaryGetDescriptor>,
>>> and destroy viewer by PetscViewerDestroy
>>> <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewerDestroy.html#PetscViewerDestroy>.
>>> Do I write these functions into for loop or not?
>>>
>>
> No, they go outside.
>
> Thanks,
>
> Matt
>
>
>> Eda
>>>
>>> Matthew Knepley <knepley at gmail.com>, 25 Şub 2019 Pzt, 17:31 tarihinde
>>> şunu yazdı:
>>>
>>>> On Mon, Feb 25, 2019 at 5:25 AM Eda Oktay via petsc-users <
>>>> petsc-users at mcs.anl.gov> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> 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.
>>>>>
>>>>
>>>> I would not do it that way, since it is fragile. I would write a loop
>>>> like this:
>>>>
>>>> MAtGetOwnershipRange();
>>>> for (row = rStart; row < rEnd; ++row) {
>>>> MatGetRow()
>>>> PetscBinaryWrite()
>>>> MatRestoreRow()
>>>> }
>>>>
>>>> This will work for any matrix.
>>>>
>>>> Matt
>>>>
>>>>
>>>>> Best regards,
>>>>>
>>>>> Eda
>>>>>
>>>>
>>>>
>>>> --
>>>> What most experimenters take for granted before they begin their
>>>> experiments is infinitely more interesting than any results to which their
>>>> experiments lead.
>>>> -- Norbert Wiener
>>>>
>>>> https://www.cse.buffalo.edu/~knepley/
>>>> <http://www.cse.buffalo.edu/~knepley/>
>>>>
>>>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/
> <http://www.cse.buffalo.edu/~knepley/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190226/69d4ee8b/attachment.html>
More information about the petsc-users
mailing list