[petsc-users] MatGetDiagonal

hg hgbk2008 at gmail.com
Mon Dec 9 11:51:24 CST 2019


Dear Mark

Yes, that is correct. I'm working on square matrix all the time. My point
is that looking initially in the manual page of MatGetDiagonal:

https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetDiagonal.html

one does not automatically know what is the resultant vector is. After some
investigation (coding + printing) I know that would be a VECMPI if the
matrix is MPIAIJ. In my case I would like to get an image of the global
diagonal in the local proc, subsequently I have to use VecScatter to get it.

Giang


On Mon, Dec 9, 2019 at 6:31 PM Mark Adams <mfadams at lbl.gov> wrote:

>
>
> On Mon, Dec 9, 2019 at 10:57 AM hg <hgbk2008 at gmail.com> wrote:
>
>> I think the manual is also insufficient in this case. The vector must be
>> VECMPI and contains only the portion in the local process. Is that correct?
>>
>
> The vector and matrix (row) maps must match. This is assumed for any
> method that I can think of that takes a matrix and a vector(s). This will
> dictate if its MPI and the data layout.
>
> Perhaps there is some ambiguity as to whether it is the row or column map,
> but they are usually the same for a square matrix and MatGetDiagonal makes
> no sense for a rectangular matrix.
>
>
>>
>> Giang
>>
>>
>> On Wed, Jan 23, 2013 at 5:24 PM Nachiket Gokhale <gokhalen at gmail.com>
>> wrote:
>>
>>> Thanks, I guess I misinterpreted the manual.
>>>
>>> -Nachiket
>>>
>>> On Wed, Jan 23, 2013 at 11:20 AM, Jed Brown <jedbrown at mcs.anl.gov>
>>> wrote:
>>> > It works in serial. In parallel, it currently gives the diagonal of the
>>> > "diagonal blocks" induced by the row and column distributions. That
>>> only
>>> > matches the true diagonal for square matrices, though an actual
>>> diagonal
>>> > doesn't typically make algorithmic sense for a non-square parallel
>>> matrix.
>>> >
>>> >
>>> > On Wed, Jan 23, 2013 at 10:16 AM, Nachiket Gokhale <gokhalen at gmail.com
>>> >
>>> > wrote:
>>> >>
>>> >> Any chance of making this work in serial?
>>> >>
>>> >>
>>> >>
>>> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetDiagonal.html
>>> >>
>>> >> Not a show stopper, I am trying to get the diagonal  of some small
>>> >> projected, dense matrices (which come from large sparse matrices).  I
>>> >> am running in serial because 1) Since my projected matrices are small,
>>> >> and 2) PETSc does not do certain matrix multiplications involving a
>>> >> dense matrix in parallel,
>>> >>
>>> >> -Nachiket
>>> >
>>> >
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20191209/500c69c0/attachment.html>


More information about the petsc-users mailing list