Skip to main content
`Ctrl`+`K`

# PetscUseMethod

Queries a `PetscObject` for a method added with `PetscObjectComposeFunction()`, if it exists then calls it, otherwise generates an error.

## Synopsis

    #include "petsc/private/petscimpl.h"
    PetscUseMethod(PetscObject obj, const char *name, (arg_types), (arg_value))

## Input Parameters

- obj - the object, for example a `Mat`, that does not need to be cast to `PetscObject`

- name - the name of the method, for example, “KSPGMRESSetRestart_C” for the function `KSPGMRESSetRestart()`

- arg_types - the argument types for the method, for example, (KSP,PetscInt)

- args - the arguments for the method, for example, (ksp,restart))

## Notes

This does not return an error code, it is a macro that returns from the subroutine with an error code on error.

Use `PetscUseTypeMethod()` or `PetscTryTypeMethod()` to call functions that are included in the object’s function table, the `ops` array in the object.

## See Also

`PetscTryMethod()`, `PetscCall()`, `PetscUseTypeMethod()`, `PetscTryTypeMethod()`, `PetscCheck()`, `PetscObject`

## Level

developer

## Location

include/petsc/private/petscimpl.h

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