Skip to main content
`Ctrl`+`K`

# MatSolve

Solves \(A x = b\), given a factored matrix.

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatSolve(Mat mat, Vec b, Vec x)

Neighbor-wise Collective

## Input Parameters

- mat - the factored matrix

- b - the right-hand-side vector

## Output Parameter

- x - the result vector

## Notes

The vectors `b` and `x` cannot be the same. I.e., one cannot call `MatSolve`(A,x,x).

Most users should employ the `KSP` interface for linear solvers instead of working directly with matrix algebra routines such as this. See, e.g., `KSPCreate()`.

## See Also

Matrices, `Mat`, Matrix Factorization, `MatGetFactor()`, `MatLUFactor()`, `MatSolveAdd()`, `MatSolveTranspose()`, `MatSolveTransposeAdd()`

## Level

developer

## Location

src/mat/interface/matrix.c

## Examples

src/tao/unconstrained/tutorials/eptorsion3.c
src/tao/unconstrained/tutorials/rosenbrock1.c
src/tao/unconstrained/tutorials/eptorsion1.c

## Implementations

MatSolve_MKL_CPARDISO() in src/mat/impls/aij/mpi/mkl_cpardiso/mkl_cpardiso.c
MatSolve_MUMPS() in src/mat/impls/aij/mpi/mumps/mumps.c
MatSolve_PaStiX() in src/mat/impls/aij/mpi/pastix/pastix.c
MatSolve_STRUMPACK() in src/mat/impls/aij/mpi/strumpack/strumpack.c
MatSolve_SuperLU_DIST() in src/mat/impls/aij/mpi/superlu_dist/superlu_dist.c
MatSolve_SeqAIJ() in src/mat/impls/aij/seq/aijfact.c
MatSolve_Essl() in src/mat/impls/aij/seq/essl/essl.c
MatSolve_KLU() in src/mat/impls/aij/seq/klu/klu.c
MatSolve_SeqAIJKokkos() in src/mat/impls/aij/seq/kokkos/aijkok.kokkos.cxx
MatSolve_LUSOL() in src/mat/impls/aij/seq/lusol/lusol.c
MatSolve_Matlab() in src/mat/impls/aij/seq/matlab/aijmatlab.c
MatSolve_MKL_PARDISO() in src/mat/impls/aij/seq/mkl_pardiso/mkl_pardiso.c
MatSolve_SeqAIJCUSPARSE() in src/mat/impls/aij/seq/seqcusparse/aijcusparse.cu
MatSolve_SeqAIJHIPSPARSE() in src/mat/impls/aij/seq/seqhipsparse/aijhipsparse.hip.c
MatSolve_SPQR() in src/mat/impls/aij/seq/spqr/aijspqr.c
MatSolve_SuperLU() in src/mat/impls/aij/seq/superlu/superlu.c
MatSolve_UMFPACK() in src/mat/impls/aij/seq/umfpack/umfpack.c
MatSolve_ConstantDiagonal() in src/mat/impls/cdiagonal/cdiagonal.c
MatSolve_Diagonal() in src/mat/impls/diagonal/diagonal.c
MatSolve_Elemental() in src/mat/impls/elemental/matelem.cxx
MatSolve_Htool() in src/mat/impls/htool/htool.cxx
MatSolve_Htool() in src/mat/impls/htool/htool.cxx
MatSolve_CHOLMOD() in src/mat/impls/sbaij/seq/cholmod/sbaijcholmod.c
MatSolve_ScaLAPACK() in src/mat/impls/scalapack/matscalapack.c

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