:orphan: # MatGetFactor Returns a matrix suitable to calls to MatXXFactorSymbolic() ## Synopsis ``` #include "petscmat.h" PetscErrorCode MatGetFactor(Mat mat, MatSolverType type, MatFactorType ftype, Mat *f) ``` Collective ## Input Parameters - ***mat -*** the matrix - ***type -*** name of solver type, for example, superlu, petsc (to use PETSc's default) - ***ftype -*** factor type, `MAT_FACTOR_LU`, `MAT_FACTOR_CHOLESKY`, `MAT_FACTOR_ICC`, `MAT_FACTOR_ILU`, `MAT_FACTOR_QR` ## Output Parameter - ***f -*** the factor matrix used with MatXXFactorSymbolic() calls ## Options Database Key - ***-mat_factor_bind_factorization -*** Where to do matrix factorization? Default is device (might consume more device memory. One can choose host to save device memory). Currently only supported with `MATSEQAIJCUSPARSE` matrices. ## Notes Users usually access the factorization solvers via `KSP` Some PETSc matrix formats have alternative solvers available that are contained in alternative packages such as pastix, superlu, mumps etc. PETSc must have been ./configure to use the external solver, using the option --download-package Some of the packages have options for controlling the factorization, these are in the form -prefix_mat_packagename_packageoption where prefix is normally obtained from the calling `KSP`/`PC`. If `MatGetFactor()` is called directly one can set call `MatSetOptionsPrefixFactor()` on the originating matrix or `MatSetOptionsPrefix()` on the resulting factor matrix. ## Developer Note This should actually be called `MatCreateFactor()` since it creates a new factor object ## See Also [](ch_matrices), `Mat`, [Matrix Factorization](sec_matfactor), `KSP`, `MatSolverType`, `MatFactorType`, `MatCopy()`, `MatDuplicate()`, `MatGetFactorAvailable()`, `MatFactorGetCanUseOrdering()`, `MatSolverTypeRegister()`, `MAT_FACTOR_LU`, `MAT_FACTOR_CHOLESKY`, `MAT_FACTOR_ICC`, `MAT_FACTOR_ILU`, `MAT_FACTOR_QR` ## Level intermediate ## Location src/mat/interface/matrix.c ## Examples src/ksp/ksp/tutorials/ex52.c
--- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/interface/matrix.c) [Index of all Mat routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)