[petsc-users] Finding nonzero indices
Matthew Knepley
knepley at gmail.com
Mon Feb 25 09:29:24 CST 2019
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/20190225/4b11113c/attachment.html>
More information about the petsc-users
mailing list