petsc-3.7.1 2016-05-15
Report Typos and Errors

# PCSetOperators

Sets the matrix associated with the linear system and a (possibly) different one associated with the preconditioner.

### Synopsis

    #include "petscksp.h"
    PetscErrorCode  PCSetOperators(PC pc,Mat Amat,Mat Pmat)

Logically Collective on PC and Mat Many br

### Input Parameters

| pc | - the preconditioner context Many br
| Amat | - the matrix that defines the linear system Many br
| Pmat | - the matrix to be used in constructing the preconditioner, usually the same as Amat. Many br

### Notes

Passing a NULL for Amat or Pmat removes the matrix that is currently used. Many br

If you wish to replace either Amat or Pmat but leave the other one untouched then Many brfirst call KSPGetOperators() to get the one you wish to keep, call PetscObjectReference() Many bron it and then pass it back in in your call to KSPSetOperators(). Many br

### More Notes about Repeated Solution of Linear Systems

PETSc does NOT reset the matrix entries of either Amat or Pmat Many brto zero after a linear solve; the user is completely responsible for Many brmatrix assembly. See the routine MatZeroEntries() if desiring to Many brzero all elements of a matrix. Many br

Many br

### Keywords

PC, set, operators, matrix, linear system

### See Also

PCGetOperators(), MatZeroEntries()

Level:intermediate
Location:src/ksp/pc/interface/precon.c
Index of all PC routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/ksp/examples/tutorials/ex21f.F.html
src/snes/examples/tutorials/ex74f.F90.html