Actual source code: mhas.c
1: #define PETSCMAT_DLL
3: #include private/matimpl.h
4:
7: /*@
8: MatHasOperation - Determines whether the given matrix supports the particular
9: operation.
11: Collective on Mat
13: Input Parameters:
14: + mat - the matrix
15: - op - the operation, for example, MATOP_GET_DIAGONAL
17: Output Parameter:
18: . has - either PETSC_TRUE or PETSC_FALSE
20: Level: advanced
22: Notes:
23: See the file include/petscmat.h for a complete list of matrix
24: operations, which all have the form MATOP_<OPERATION>, where
25: <OPERATION> is the name (in all capital letters) of the
26: user-level routine. E.g., MatNorm() -> MATOP_NORM.
28: .keywords: matrix, has, operation
30: .seealso: MatCreateShell()
31: @*/
32: PetscErrorCode MatHasOperation(Mat mat,MatOperation op,PetscTruth *has)
33: {
38: if (((void **)mat->ops)[op]) {*has = PETSC_TRUE;}
39: else {
40: if (op == MATOP_GET_SUBMATRIX) {
42: PetscMPIInt size;
44: MPI_Comm_size(((PetscObject)mat)->comm,&size);
45: if (size == 1) {
46: MatHasOperation(mat,MATOP_GET_SUBMATRICES,has);
47: } else {
48: *has = PETSC_FALSE;
49: }
50: } else {
51: *has = PETSC_FALSE;
52: }
53: }
54: return(0);
55: }