Actual source code: mhas.c

petsc-3.8.4 2018-03-24
Report Typos and Errors

  2:  #include <petsc/private/matimpl.h>

  4: /*@
  5:     MatHasOperation - Determines whether the given matrix supports the particular
  6:     operation.

  8:    Not Collective

 10:    Input Parameters:
 11: +  mat - the matrix
 12: -  op - the operation, for example, MATOP_GET_DIAGONAL

 14:    Output Parameter:
 15: .  has - either PETSC_TRUE or PETSC_FALSE

 17:    Level: advanced

 19:    Notes:
 20:    See the file include/petscmat.h for a complete list of matrix
 21:    operations, which all have the form MATOP_<OPERATION>, where
 22:    <OPERATION> is the name (in all capital letters) of the
 23:    user-level routine.  E.g., MatNorm() -> MATOP_NORM.

 25: .keywords: matrix, has, operation

 27: .seealso: MatCreateShell()
 28: @*/
 29: PetscErrorCode  MatHasOperation(Mat mat,MatOperation op,PetscBool  *has)
 30: {
 35:   if (mat->ops->hasoperation) {
 37:     (*mat->ops->hasoperation)(mat,op,has);
 38:   } else {
 39:     if (((void**)mat->ops)[op]) *has =  PETSC_TRUE;
 40:     else {
 41:       if (op == MATOP_CREATE_SUBMATRIX) {
 43:         PetscMPIInt    size;

 45:         MPI_Comm_size(PetscObjectComm((PetscObject)mat),&size);
 46:         if (size == 1) {
 47:           MatHasOperation(mat,MATOP_CREATE_SUBMATRICES,has);
 48:         } else {
 49:           *has = PETSC_FALSE;
 50:         }
 51:       } else {
 52:         *has = PETSC_FALSE;
 53:       }
 54:     }
 55:   }
 56:   return(0);
 57: }