MatShellSetContext — PETSc 3.22.5 documentation

Skip to main content
`Ctrl`+`K`

# MatShellSetContext

sets the context for a `MATSHELL` shell matrix

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatShellSetContext(Mat mat, void *ctx)

Logically Collective

## Input Parameters

- mat - the `MATSHELL` shell matrix

- ctx - the context

## Note

This provides an easy way, along with `MatCreateShell()` and `MatShellSetOperation()` to provide a custom matrix format specifically for your application.

## Fortran Notes

You must write a Fortran interface definition for this function that tells Fortran the Fortran derived data type that you are passing in as the `ctx` argument.

## See Also

Matrices, `Mat`, `MATSHELL`, `MatCreateShell()`, `MatShellGetContext()`, `MatShellGetOperation()`

## Level

advanced

## Location

src/mat/impls/shell/shell.c

## Examples

src/snes/tutorials/ex36.c
src/ts/tutorials/ex50.c
src/snes/tutorials/ex12.c
src/mat/tutorials/ex6f.F90

## Implementations

MatShellSetContext_Shell() in src/mat/impls/shell/shell.c
MatShellSetContext_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