From fcbb0485e0a8246124df6f8d0ff8068be170548c Mon Sep 17 00:00:00 2001 From: Ivan Yashchuk Date: Thu, 14 May 2020 18:04:33 +0300 Subject: [PATCH] Added MatMissingDiagonal_Python --- src/libpetsc4py/libpetsc4py.pyx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/libpetsc4py/libpetsc4py.pyx b/src/libpetsc4py/libpetsc4py.pyx index a5dc97a2..f0ea9b05 100644 --- a/src/libpetsc4py/libpetsc4py.pyx +++ b/src/libpetsc4py/libpetsc4py.pyx @@ -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 @@ -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 @@ -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] = pymissing + if loc: + loc[0] = asInt(pyloc) + return FunctionEnd() + cdef PetscErrorCode MatNorm_Python( PetscMat mat, NormType ntype,