[petsc-users] Return value of PCFactorGetMatrix

Hong Zhang hzhang at mcs.anl.gov
Tue Dec 13 21:26:55 CST 2011


Uwe,
Petsc supports Cholesky factorization for seqaij matrix format.
The factored matrix is in seqsbaij, thus
MatGetInertia() works for it.

ex33.c is written for sbaij matrix, but also works for aij matrix. You
can comment out 2 lines
//ierr = MatSetOption(B,MAT_IGNORE_LOWER_TRIANGULAR,PETSC_TRUE);CHKERRQ(ierr);
then run it with option '-mat_type aij' and get its inertia.
e.g., I get

./ex33 -mat_type seqaij -sigma 2.0
 MatInertia: nneg: 17, nzero: 0, npos: 83

'-mat_view_info' display more detailed info about the matrices being
used in the example.

Hong

On Tue, Dec 13, 2011 at 12:54 PM, Matthew Knepley <knepley at gmail.com> wrote:
> On Tue, Dec 13, 2011 at 12:51 PM, Uwe Schlifkowitz
> <uwe.schlifkowitz at uibk.ac.at> wrote:
>>
>> On 13.12.2011, at 19:03, Hong Zhang wrote:
>> >> I found MatGetInertia in petsc's documentation and i am not sure how to
>> >> use it. I found an old example from petsc-2.3.1
>> >> (http://www.mcs.anl.gov/petsc/petsc-2.3.1/src/ksp/ksp/examples/tutorials/ex10.c.html
>> >> ), but things seem to have changed since that version. Can you give an
>> >> example?
>> >
>> > petsc-3.2/src/ksp/ksp/examples/tests/ex33.c and ex36.c
>> >
>> > Hong
>>
>> Thank you. I already looked into ex33. My input matrix however is not in
>> sbaij format:
>>
>> [0]PETSC ERROR: --------------------- Error Message
>> ------------------------------------
>> [0]PETSC ERROR: No support for this operation for this object type!
>> [0]PETSC ERROR: Mat type seqaij!
>>
>> How do i convert the matrix to sbaij? I tried MatConvert as in ex36.c, but
>> after that the matrix is not symmetric anymore.
>
>
> It is time to read the manual. If you convert to SBAIJ, your matrix is
> symmetric by definition.
>
>    Matt
>
>>
>>
>> Uwe
>
>
>
>
> --
> 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


More information about the petsc-users mailing list