[petsc-users] Check for inf or nan in PETSc matrix
Barry Smith
bsmith at mcs.anl.gov
Fri Oct 3 13:20:53 CDT 2014
It is possible to check an individual number to see if it has a Nan or Inf with PetscIsInfOrNanScalar() but we don’t have code for checking in a matrix directly.
For vectors you can use VecGetArrayRead() and loop over the local entries with PetscIsInfOrNanScalar()
For dense matrices you can use MatDenseGetArray() or MatSeqAIJGetArray(). For MPIAIJ matrices you can use MatMPIAIJGetSeqAIJ() and then do the test on each of the two SeqAIJ matrices. You can do the same thing with BAIJ matrices by using BAIJ in the above calls instead of AIJ.
Barry
On Oct 2, 2014, at 7:25 PM, TAY wee-beng <zonexo at gmail.com> wrote:
> Hi,
>
> I have a PETSc matrix. How can I check for inf or nan in its values?
>
> I understand that there's a subroutine "PetscIsInfOrNanScalar" but not sure how to use it.
>
> --
> Thank you.
>
> Yours sincerely,
>
> TAY wee-beng
>
More information about the petsc-users
mailing list