Skip to content

Commit

Permalink
Merged in ivan/missingdiagonal (pull request #149)
Browse files Browse the repository at this point in the history
Added MatMissingDiagonal_Python

Approved-by: Lisandro Dalcin
  • Loading branch information
IvanYashchuk authored and dalcinl committed May 14, 2020
2 parents 54650a1 + fcbb048 commit 0db95a9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/libpetsc4py/libpetsc4py.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ cdef extern from * nogil:
PetscErrorCode (*getdiagonal)(PetscMat,PetscVec) except IERR
PetscErrorCode (*setdiagonal"diagonalset")(PetscMat,PetscVec,InsertMode) except IERR
PetscErrorCode (*diagonalscale)(PetscMat,PetscVec,PetscVec) except IERR
PetscErrorCode (*missingdiagonal)(PetscMat,PetscBool*,PetscInt*) except IERR
PetscErrorCode (*norm)(PetscMat,NormType,PetscReal*) except IERR
PetscErrorCode (*realpart)(PetscMat) except IERR
PetscErrorCode (*imagpart"imaginarypart")(PetscMat) except IERR
Expand Down Expand Up @@ -587,6 +588,7 @@ cdef PetscErrorCode MatCreate_Python(
ops.getdiagonal = MatGetDiagonal_Python
ops.setdiagonal = MatSetDiagonal_Python
ops.diagonalscale = MatDiagonalScale_Python
ops.missingdiagonal = MatMissingDiagonal_Python
ops.norm = MatNorm_Python
ops.realpart = MatRealPart_Python
ops.imagpart = MatImagPart_Python
Expand Down Expand Up @@ -1116,6 +1118,21 @@ cdef PetscErrorCode MatDiagonalScale_Python(
diagonalScale(Mat_(mat), Vec_(l), Vec_(r))
return FunctionEnd()

cdef PetscErrorCode MatMissingDiagonal_Python(
PetscMat mat,
PetscBool *missing,
PetscInt *loc
) \
except IERR with gil:
FunctionBegin(b"MatMissingDiagonal_Python")
cdef missingDiagonal = PyMat(mat).missingDiagonal
if missingDiagonal is None: return UNSUPPORTED(b"missingDiagonal")
pymissing, pyloc = missingDiagonal(Mat_(mat))
missing[0] = <PetscBool>pymissing
if loc:
loc[0] = asInt(pyloc)
return FunctionEnd()

cdef PetscErrorCode MatNorm_Python(
PetscMat mat,
NormType ntype,
Expand Down

0 comments on commit 0db95a9

Please sign in to comment.