[petsc-users] MatGetRow for global rows of a parallel matrix

Matthew Knepley knepley at gmail.com
Wed Jun 10 08:03:40 CDT 2020


On Wed, Jun 10, 2020 at 8:56 AM Eda Oktay <eda.oktay at metu.edu.tr> wrote:

> Hi all,
>
> I am trying to get all the rows of a parallel matrix as individual
> vectors. For instance, if I have 72*4 matrix, I want to get 72
> different vectors having size 4.
>
> As far as I understood, MatGetRow is only for local rows, so
> MatGetOwnershipRange is used, however, when I tried this one, I
> couldn't get the whole and desired row vectors.
>
> In MatGetRow explanation, it is written that I should use
> MatCreateSubMatrices first, then use MatGetRow. But I couldn't
> understand to which extent I should create submatrices. I just need to
> have all 72 rows as 72 different vectors each having 4 elements.
>

1) For sparse matrices, the storage is always divided by row, so that
values can only be retrieved for local rows with MatGetRow()

2) Is this matrix sparse? It sounds like it is dense.

3) Are you asking to get all matrix values on all processes? If so, I think
the easiest thing to do is first wrap a Vec around the
    values, then use VecScatterToAll(), then wrap each one in a MatDense
again.

  Thanks,

     Matt


> Thanks!
>
> 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/20200610/0f7a25ee/attachment-0001.html>


More information about the petsc-users mailing list