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

Eda Oktay eda.oktay at metu.edu.tr
Wed Jun 10 08:08:22 CDT 2020


Dear Matt,

Matthew Knepley <knepley at gmail.com>, 10 Haz 2020 Çar, 16:03 tarihinde
şunu yazdı:
>
> 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.

Matrix 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.

Yes, I want all row vectors on all processes. In a dense matrix,
should I still wrap a Vec around the values? I know I should use
scatter but I couldn't even wrap a Vec around them.

Thanks so much!

Eda

>
>   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/


More information about the petsc-users mailing list