[petsc-users] Finding nonzero indices
Matthew Knepley
knepley at gmail.com
Mon Feb 25 08:30:56 CST 2019
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/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190225/8152b2c7/attachment.html>
More information about the petsc-users
mailing list