# Construct a preconditioner for the linear system $Ax = b$ from a different matrix

When I use PETSc to solve my linear systems, I always use the subroutine

PetscErrorCode  KSPSetOperators(KSP ksp,Mat Amat,Mat Pmat)


where Amat refers to the matrix that defines my linear system and Pmat is the Matrix used in constructing the preconditioner.

I am not sure in which scenarios it would be advisable to use another matrix than $A$ or Amat to construct the preconditioner, i.e. to use a preconditioner from another (probably related) linear system.

EDIT Taking a look at the PETSc Manual, one possible occasion in which the matrices Amat and Pmat differ is

when a preconditioning matrix is obtained from a lower order method than that employed to form the linear system matrix.

• A preconditioner doesn't have to be an explicit matrix (see tutorial parabolic.c for SSOR preconditioner), in which case you can set it to call your own function to multiply it by a vector. Also, $A$ and $P$ should always differ, a preconditioner (depending on convention) is an approximation to the inverse $A^{-1}$, not the matrix itself (so you solve $PAx=Pb$, so multiplication by $P$ should be cheap). I don't really understand this question: why wouldn't you want the freedom to specify your own arbitrary preconditioner? – Kirill Feb 7 '15 at 11:31
• @Kirill I'm sorry if my question led to confusion. In fact Pmat is not equal to $P$, instead it is an approximate of $\tilde{A}$ of $A$ that is used to "construct" the preconditioner $P$. – el_tenedor Feb 7 '15 at 13:59
• I have no direct experience here, I looked at lines 1055-1077 of mcs.anl.gov/petsc/petsc-current/src/tao/pde_constrained/… and it uses KSPSetOperators to set its own preconditioner. Also, not all preconditioners are constructed directly from the matrix. They could come from a simpler equivalent system, mathematical considerations, or from somewhere else entirely, like FFT, wavelet transform. But maybe that's not relevant to KSPSetOperators, I don't know. – Kirill Feb 8 '15 at 1:59

• We precondition $\begin{pmatrix}A &B \\ B^T & 0\end{pmatrix}$ by a block triangular matrix.
• We precondition $A$ by one V-cycle based not on $A$ but based on an approximation $\tilde A$ that is simpler and emptier.
• We approximate the exact $S^{-1}$ in the block preconditioner by the application of a mass matrix.