Skip to main content
`Ctrl`+`K`

# MatShellSetContextDestroy

sets the destroy function for a `MATSHELL` shell matrix context

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatShellSetContextDestroy(Mat mat, PetscCtxDestroyFn *f)

Logically Collective

## Input Parameters

- mat - the shell matrix

- f - the context destroy function, see `PetscCtxDestroyFn` for calling sequence

## Note

If the `MatShell` is never duplicated, the behavior of this function is equivalent to `MatShellSetOperation`(`Mat`,`MATOP_DESTROY`,f). However, `MatShellSetContextDestroy()` ensures proper reference counting for the user provided context data in the case that the `MATSHELL` is duplicated.

## See Also

Matrices, `Mat`, `MATSHELL`, `MatCreateShell()`, `MatShellSetContext()`, `PetscCtxDestroyFn`

## Level

advanced

## Location

src/mat/impls/shell/shell.c

## Implementations

MatShellSetContextDestroy_Shell() in src/mat/impls/shell/shell.c
MatShellSetContextDestroy_Immutable() in src/mat/impls/shell/shell.c

Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages