Actual source code: mhas.c
petsc-3.7.3 2016-08-01
2: #include <petsc/private/matimpl.h> /*I "petscmat.h" I*/
6: /*@
7: MatHasOperation - Determines whether the given matrix supports the particular
8: operation.
10: Not Collective
12: Input Parameters:
13: + mat - the matrix
14: - op - the operation, for example, MATOP_GET_DIAGONAL
16: Output Parameter:
17: . has - either PETSC_TRUE or PETSC_FALSE
19: Level: advanced
21: Notes:
22: See the file include/petscmat.h for a complete list of matrix
23: operations, which all have the form MATOP_<OPERATION>, where
24: <OPERATION> is the name (in all capital letters) of the
25: user-level routine. E.g., MatNorm() -> MATOP_NORM.
27: .keywords: matrix, has, operation
29: .seealso: MatCreateShell()
30: @*/
31: PetscErrorCode MatHasOperation(Mat mat,MatOperation op,PetscBool *has)
32: {
37: if (((void**)mat->ops)[op]) *has = PETSC_TRUE;
38: else {
39: if (op == MATOP_GET_SUBMATRIX) {
41: PetscMPIInt size;
43: MPI_Comm_size(PetscObjectComm((PetscObject)mat),&size);
44: if (size == 1) {
45: MatHasOperation(mat,MATOP_GET_SUBMATRICES,has);
46: } else {
47: *has = PETSC_FALSE;
48: }
49: } else {
50: *has = PETSC_FALSE;
51: }
52: }
53: return(0);
54: }