12eac72dbSBarry Smith /* 22eac72dbSBarry Smith Include file for the matrix component of PETSc 32eac72dbSBarry Smith */ 4a4963045SJacob Faibussowitsch #pragma once 5ac09b921SBarry Smith 62c8e378dSBarry Smith #include <petscvec.h> 72eac72dbSBarry Smith 8ac09b921SBarry Smith /* SUBMANSEC = Mat */ 9ac09b921SBarry Smith 10d9274352SBarry Smith /*S 118f6c3df8SBarry Smith Mat - Abstract PETSc matrix object used to manage all linear operators in PETSc, even those without 12af27ebaaSBarry Smith an explicit sparse representation (such as matrix-free operators). Also used to hold representations of graphs 13af27ebaaSBarry Smith for graph operations such as coloring, `MatColoringCreate()` 142eac72dbSBarry Smith 15d91e6319SBarry Smith Level: beginner 16d91e6319SBarry Smith 172ef1f0ffSBarry Smith Note: 181cc06b55SBarry Smith See [](doc_matrix), [](ch_matrices) and `MatType` for available matrix types 192ef1f0ffSBarry Smith 201cc06b55SBarry Smith .seealso: [](doc_matrix), [](ch_matrices), `MatCreate()`, `MatType`, `MatSetType()`, `MatDestroy()` 21d9274352SBarry Smith S*/ 22d9274352SBarry Smith typedef struct _p_Mat *Mat; 23d9274352SBarry Smith 2476bdecfbSBarry Smith /*J 258f6c3df8SBarry Smith MatType - String with the name of a PETSc matrix type 26d9274352SBarry Smith 27d9274352SBarry Smith Level: beginner 28d9274352SBarry Smith 292ef1f0ffSBarry Smith Note: 302ef1f0ffSBarry Smith [](doc_matrix) for a table of available matrix types 312ef1f0ffSBarry Smith 321cc06b55SBarry Smith .seealso: [](doc_matrix), [](ch_matrices), `MatSetType()`, `Mat`, `MatSolverType`, `MatRegister()` 3376bdecfbSBarry Smith J*/ 3419fd82e9SBarry Smith typedef const char *MatType; 35273d9f13SBarry Smith #define MATSAME "same" 365a11e1b2SBarry Smith #define MATMAIJ "maij" 37273d9f13SBarry Smith #define MATSEQMAIJ "seqmaij" 38273d9f13SBarry Smith #define MATMPIMAIJ "mpimaij" 3949bd79ccSDebojyoti Ghosh #define MATKAIJ "kaij" 4049bd79ccSDebojyoti Ghosh #define MATSEQKAIJ "seqkaij" 4149bd79ccSDebojyoti Ghosh #define MATMPIKAIJ "mpikaij" 42273d9f13SBarry Smith #define MATIS "is" 435a11e1b2SBarry Smith #define MATAIJ "aij" 44273d9f13SBarry Smith #define MATSEQAIJ "seqaij" 45273d9f13SBarry Smith #define MATMPIAIJ "mpiaij" 465a11e1b2SBarry Smith #define MATAIJCRL "aijcrl" 475a11e1b2SBarry Smith #define MATSEQAIJCRL "seqaijcrl" 485a11e1b2SBarry Smith #define MATMPIAIJCRL "mpiaijcrl" 499ae82921SPaul Mullowney #define MATAIJCUSPARSE "aijcusparse" 509ae82921SPaul Mullowney #define MATSEQAIJCUSPARSE "seqaijcusparse" 519ae82921SPaul Mullowney #define MATMPIAIJCUSPARSE "mpiaijcusparse" 5247d993e7Ssuyashtn #define MATAIJHIPSPARSE "aijhipsparse" 5347d993e7Ssuyashtn #define MATSEQAIJHIPSPARSE "seqaijhipsparse" 5447d993e7Ssuyashtn #define MATMPIAIJHIPSPARSE "mpiaijhipsparse" 558c3ff71bSJunchao Zhang #define MATAIJKOKKOS "aijkokkos" 568c3ff71bSJunchao Zhang #define MATSEQAIJKOKKOS "seqaijkokkos" 578c3ff71bSJunchao Zhang #define MATMPIAIJKOKKOS "mpiaijkokkos" 58d67ff14aSKarl Rupp #define MATAIJVIENNACL "aijviennacl" 59d67ff14aSKarl Rupp #define MATSEQAIJVIENNACL "seqaijviennacl" 60d67ff14aSKarl Rupp #define MATMPIAIJVIENNACL "mpiaijviennacl" 615a11e1b2SBarry Smith #define MATAIJPERM "aijperm" 625a11e1b2SBarry Smith #define MATSEQAIJPERM "seqaijperm" 635a11e1b2SBarry Smith #define MATMPIAIJPERM "mpiaijperm" 644dfdc2d9SRichard Tran Mills #define MATAIJSELL "aijsell" 654dfdc2d9SRichard Tran Mills #define MATSEQAIJSELL "seqaijsell" 664dfdc2d9SRichard Tran Mills #define MATMPIAIJSELL "mpiaijsell" 674a2a386eSRichard Tran Mills #define MATAIJMKL "aijmkl" 684a2a386eSRichard Tran Mills #define MATSEQAIJMKL "seqaijmkl" 694a2a386eSRichard Tran Mills #define MATMPIAIJMKL "mpiaijmkl" 70b5b72c8aSIrina Sokolova #define MATBAIJMKL "baijmkl" 71b5b72c8aSIrina Sokolova #define MATSEQBAIJMKL "seqbaijmkl" 72b5b72c8aSIrina Sokolova #define MATMPIBAIJMKL "mpibaijmkl" 73273d9f13SBarry Smith #define MATSHELL "shell" 74c1fff1c6SRichard Tran Mills #define MATCENTERING "centering" 755a11e1b2SBarry Smith #define MATDENSE "dense" 76637a0070SStefano Zampini #define MATDENSECUDA "densecuda" 7747d993e7Ssuyashtn #define MATDENSEHIP "densehip" 78209238afSKris Buschelman #define MATSEQDENSE "seqdense" 79bfc799aaSStefano Zampini #define MATSEQDENSECUDA "seqdensecuda" 8047d993e7Ssuyashtn #define MATSEQDENSEHIP "seqdensehip" 81273d9f13SBarry Smith #define MATMPIDENSE "mpidense" 82637a0070SStefano Zampini #define MATMPIDENSECUDA "mpidensecuda" 8347d993e7Ssuyashtn #define MATMPIDENSEHIP "mpidensehip" 84db31f6deSJed Brown #define MATELEMENTAL "elemental" 85d24d4204SJose E. Roman #define MATSCALAPACK "scalapack" 865a11e1b2SBarry Smith #define MATBAIJ "baij" 87273d9f13SBarry Smith #define MATSEQBAIJ "seqbaij" 88273d9f13SBarry Smith #define MATMPIBAIJ "mpibaij" 89273d9f13SBarry Smith #define MATMPIADJ "mpiadj" 905a11e1b2SBarry Smith #define MATSBAIJ "sbaij" 91273d9f13SBarry Smith #define MATSEQSBAIJ "seqsbaij" 92273d9f13SBarry Smith #define MATMPISBAIJ "mpisbaij" 93cebc7f6cSBarry Smith #define MATMFFD "mffd" 94c8a8475eSBarry Smith #define MATNORMAL "normal" 95c5e4d11fSDmitry Karpeev #define MATNORMALHERMITIAN "normalh" 96ab92ecdeSBarry Smith #define MATLRC "lrc" 972a6744ebSBarry Smith #define MATSCATTER "scatter" 98421e10b8SBarry Smith #define MATBLOCKMAT "blockmat" 99793850ffSBarry Smith #define MATCOMPOSITE "composite" 1001f8c7532SHong Zhang #define MATFFT "fft" 1011f8c7532SHong Zhang #define MATFFTW "fftw" 102e133240eSMatthew G Knepley #define MATSEQCUFFT "seqcufft" 10347d993e7Ssuyashtn #define MATSEQHIPFFT "seqhipfft" 104edd03b47SJacob Faibussowitsch #define MATTRANSPOSEMAT PETSC_DEPRECATED_MACRO(3, 18, 0, "MATTRANSPOSEVIRTUAL", ) "transpose" 105013e2dc7SBarry Smith #define MATTRANSPOSEVIRTUAL "transpose" 106013e2dc7SBarry Smith #define MATHERMITIANTRANSPOSEVIRTUAL "hermitiantranspose" 10772ca8751SBarry Smith #define MATSCHURCOMPLEMENT "schurcomplement" 1081d6018f0SLisandro Dalcin #define MATPYTHON "python" 10963c07aadSStefano Zampini #define MATHYPRE "hypre" 110f91d8e95SBarry Smith #define MATHYPRESTRUCT "hyprestruct" 111a9e6138eSGlenn Hammond #define MATHYPRESSTRUCT "hypresstruct" 112ee1cef2cSJed Brown #define MATSUBMATRIX "submatrix" 1132c0dbf93SJed Brown #define MATLOCALREF "localref" 114d8588912SDave May #define MATNEST "nest" 115c094ef40SMatthew G. Knepley #define MATPREALLOCATOR "preallocator" 116d4002b98SHong Zhang #define MATSELL "sell" 117d4002b98SHong Zhang #define MATSEQSELL "seqsell" 118d4002b98SHong Zhang #define MATMPISELL "mpisell" 1192d1451d4SHong Zhang #define MATSELLCUDA "sellcuda" 1202d1451d4SHong Zhang #define MATSEQSELLCUDA "seqsellcuda" 1212d1451d4SHong Zhang #define MATMPISELLCUDA "mpisellcuda" 122*773bf0f6SHong Zhang #define MATSELLHIP "sellhip" 123*773bf0f6SHong Zhang #define MATSEQSELLHIP "seqsellhip" 124*773bf0f6SHong Zhang #define MATMPISELLHIP "mpisellhip" 125a3b2e22bSHong Zhang #define MATDUMMY "dummy" 126cd929ea3SAlp Dener #define MATLMVM "lmvm" 12778e4361aSAlp Dener #define MATLMVMDFP "lmvmdfp" 128bbb72809SHansol Suh #define MATLMVMDDFP "lmvmddfp" 12978e4361aSAlp Dener #define MATLMVMBFGS "lmvmbfgs" 130bbb72809SHansol Suh #define MATLMVMDBFGS "lmvmdbfgs" 131bbb72809SHansol Suh #define MATLMVMDQN "lmvmdqn" 13278e4361aSAlp Dener #define MATLMVMSR1 "lmvmsr1" 133864588a7SAlp Dener #define MATLMVMBROYDEN "lmvmbroyden" 134864588a7SAlp Dener #define MATLMVMBADBROYDEN "lmvmbadbroyden" 135864588a7SAlp Dener #define MATLMVMSYMBROYDEN "lmvmsymbroyden" 136864588a7SAlp Dener #define MATLMVMSYMBADBROYDEN "lmvmsymbadbroyden" 137864588a7SAlp Dener #define MATLMVMDIAGBROYDEN "lmvmdiagbroyden" 1383423f386SBarry Smith #define MATCONSTANTDIAGONAL "constantdiagonal" 139345a4b08SToby Isaac #define MATDIAGONAL "diagonal" 140c7a4214aSPierre Jolivet #define MATHTOOL "htool" 14153022affSStefano Zampini #define MATH2OPUS "h2opus" 142773941d6SBarry Smith 14376bdecfbSBarry Smith /*J 144af27ebaaSBarry Smith MatSolverType - String with the name of a PETSc factorization-based matrix solver type. 1459989ab13SBarry Smith 146c2b89b5dSBarry Smith For example: "petsc" indicates what PETSc provides, "superlu_dist" the parallel SuperLU_DIST package etc 1479989ab13SBarry Smith 1489989ab13SBarry Smith Level: beginner 1499989ab13SBarry Smith 1502ef1f0ffSBarry Smith Note: 15116a05f60SBarry Smith `MATSOLVERUMFPACK`, `MATSOLVERCHOLMOD`, `MATSOLVERKLU`, `MATSOLVERSPQR` form the SuiteSparse package; you can use `--download-suitesparse` as 15216a05f60SBarry Smith a ./configure option to install them 153c7ccbb75SBarry Smith 1541cc06b55SBarry Smith .seealso: [](sec_matfactor), [](ch_matrices), `MatGetFactor()`, `PCFactorSetMatSolverType()`, `PCFactorGetMatSolverType()` 15576bdecfbSBarry Smith J*/ 156ea799195SBarry Smith typedef const char *MatSolverType; 1572692d6eeSBarry Smith #define MATSOLVERSUPERLU "superlu" 1582692d6eeSBarry Smith #define MATSOLVERSUPERLU_DIST "superlu_dist" 15908f5efcfSPieter Ghysels #define MATSOLVERSTRUMPACK "strumpack" 1602692d6eeSBarry Smith #define MATSOLVERUMFPACK "umfpack" 16120db9a53SJed Brown #define MATSOLVERCHOLMOD "cholmod" 162d89f5e7aSBarry Smith #define MATSOLVERKLU "klu" 163d89f5e7aSBarry Smith #define MATSOLVERELEMENTAL "elemental" 164d24d4204SJose E. Roman #define MATSOLVERSCALAPACK "scalapack" 1652692d6eeSBarry Smith #define MATSOLVERESSL "essl" 1662692d6eeSBarry Smith #define MATSOLVERLUSOL "lusol" 1672692d6eeSBarry Smith #define MATSOLVERMUMPS "mumps" 168d615f992SSatish Balay #define MATSOLVERMKL_PARDISO "mkl_pardiso" 169d305a81bSVasiliy Kozyrev #define MATSOLVERMKL_CPARDISO "mkl_cpardiso" 1702692d6eeSBarry Smith #define MATSOLVERPASTIX "pastix" 1712692d6eeSBarry Smith #define MATSOLVERMATLAB "matlab" 1722692d6eeSBarry Smith #define MATSOLVERPETSC "petsc" 1732692d6eeSBarry Smith #define MATSOLVERBAS "bas" 1749ae82921SPaul Mullowney #define MATSOLVERCUSPARSE "cusparse" 175bfc799aaSStefano Zampini #define MATSOLVERCUDA "cuda" 17647d993e7Ssuyashtn #define MATSOLVERHIPSPARSE "hipsparse" 17747d993e7Ssuyashtn #define MATSOLVERHIP "hip" 178930e68a5SMark Adams #define MATSOLVERKOKKOS "kokkos" 179a2fc1e05SToby Isaac #define MATSOLVERSPQR "spqr" 180c0cdd4a1SDahai Guo 181b24902e0SBarry Smith /*E 182b24902e0SBarry Smith MatFactorType - indicates what type of factorization is requested 183b24902e0SBarry Smith 1842ef1f0ffSBarry Smith Values: 1852ef1f0ffSBarry Smith + `MAT_FACTOR_LU` - LU factorization 1862ef1f0ffSBarry Smith . `MAT_FACTOR_CHOLESKY` - Cholesky factorization 1872ef1f0ffSBarry Smith . `MAT_FACTOR_ILU` - ILU factorization 1882ef1f0ffSBarry Smith . `MAT_FACTOR_ICC` - incomplete Cholesky factorization 1892ef1f0ffSBarry Smith . `MAT_FACTOR_ILUDT` - ILU factorization with drop tolerance 1902ef1f0ffSBarry Smith - `MAT_FACTOR_QR` - QR factorization 191b24902e0SBarry Smith 19216a05f60SBarry Smith Level: beginner 19316a05f60SBarry Smith 1941cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSolverType`, `MatGetFactor()`, `MatGetFactorAvailable()`, `MatSolverTypeRegister()` 195b24902e0SBarry Smith E*/ 1969371c9d4SSatish Balay typedef enum { 1979371c9d4SSatish Balay MAT_FACTOR_NONE, 1989371c9d4SSatish Balay MAT_FACTOR_LU, 1999371c9d4SSatish Balay MAT_FACTOR_CHOLESKY, 2009371c9d4SSatish Balay MAT_FACTOR_ILU, 2019371c9d4SSatish Balay MAT_FACTOR_ICC, 2029371c9d4SSatish Balay MAT_FACTOR_ILUDT, 2039371c9d4SSatish Balay MAT_FACTOR_QR, 2049371c9d4SSatish Balay MAT_FACTOR_NUM_TYPES 2059371c9d4SSatish Balay } MatFactorType; 206014dd563SJed Brown PETSC_EXTERN const char *const MatFactorTypes[]; 207e92e720dSBarry Smith 208ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactor(Mat, MatSolverType, MatFactorType, Mat *); 209ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat, MatSolverType, MatFactorType, PetscBool *); 210f73b0415SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetCanUseOrdering(Mat, PetscBool *); 211edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 15, 0, "MatFactorGetCanUseOrdering()", ) static inline PetscErrorCode MatFactorGetUseOrdering(Mat A, PetscBool *b) 212d71ae5a4SJacob Faibussowitsch { 2139371c9d4SSatish Balay return MatFactorGetCanUseOrdering(A, b); 2149371c9d4SSatish Balay } 215ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetSolverType(Mat, MatSolverType *); 216014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetFactorType(Mat, MatFactorType *); 2177abd51d3SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatSetFactorType(Mat, MatFactorType); 2188434afd1SBarry Smith PETSC_EXTERN_TYPEDEF typedef PetscErrorCode(MatSolverFn)(Mat, MatFactorType, Mat *); 2198434afd1SBarry Smith PETSC_EXTERN_TYPEDEF typedef MatSolverFn *MatSolverFunction; 22007e0ed13SBarry Smith 2218434afd1SBarry Smith PETSC_EXTERN PetscErrorCode MatSolverTypeRegister(MatSolverType, MatType, MatFactorType, MatSolverFn *); 2228434afd1SBarry Smith PETSC_EXTERN PetscErrorCode MatSolverTypeGet(MatSolverType, MatType, MatFactorType, PetscBool *, PetscBool *, MatSolverFn **); 223edd03b47SJacob Faibussowitsch typedef MatSolverType MatSolverPackage PETSC_DEPRECATED_TYPEDEF(3, 9, 0, "MatSolverType", ); 2248434afd1SBarry Smith PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeRegister()", ) static inline PetscErrorCode MatSolverPackageRegister(MatSolverType stype, MatType mtype, MatFactorType ftype, MatSolverFn *f) 225d71ae5a4SJacob Faibussowitsch { 2269371c9d4SSatish Balay return MatSolverTypeRegister(stype, mtype, ftype, f); 2279371c9d4SSatish Balay } 2288434afd1SBarry Smith PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeGet()", ) static inline PetscErrorCode MatSolverPackageGet(MatSolverType stype, MatType mtype, MatFactorType ftype, PetscBool *foundmtype, PetscBool *foundstype, MatSolverFn **f) 229d71ae5a4SJacob Faibussowitsch { 2309371c9d4SSatish Balay return MatSolverTypeGet(stype, mtype, ftype, foundmtype, foundstype, f); 2319371c9d4SSatish Balay } 2329989ab13SBarry Smith 2334222ddf1SHong Zhang /*E 23495bd0b28SBarry Smith MatProductType - indicates what type of matrix product to compute 2354222ddf1SHong Zhang 2362ef1f0ffSBarry Smith Values: 2372ef1f0ffSBarry Smith + `MATPRODUCT_AB` - product of two matrices 2382ef1f0ffSBarry Smith . `MATPRODUCT_AtB` - product of the transpose of a given matrix with a matrix 2392ef1f0ffSBarry Smith . `MATPRODUCT_ABt` - product of a matrix with the transpose of another given matrix 2402ef1f0ffSBarry Smith . `MATPRODUCT_PtAP` - the triple product of the transpose of a matrix with another matrix and itself 2412ef1f0ffSBarry Smith . `MATPRODUCT_RARt` - the triple product of a matrix, another matrix and the transpose of the first matrix 2422ef1f0ffSBarry Smith - `MATPRODUCT_ABC` - the product of three matrices 2432ef1f0ffSBarry Smith 24416a05f60SBarry Smith Level: beginner 24516a05f60SBarry Smith 2461cc06b55SBarry Smith .seealso: [](sec_matmatproduct), [](ch_matrices), `MatProductSetType()` 2474222ddf1SHong Zhang E*/ 2489371c9d4SSatish Balay typedef enum { 2499371c9d4SSatish Balay MATPRODUCT_UNSPECIFIED = 0, 2509371c9d4SSatish Balay MATPRODUCT_AB, 2519371c9d4SSatish Balay MATPRODUCT_AtB, 2529371c9d4SSatish Balay MATPRODUCT_ABt, 2539371c9d4SSatish Balay MATPRODUCT_PtAP, 2549371c9d4SSatish Balay MATPRODUCT_RARt, 2559371c9d4SSatish Balay MATPRODUCT_ABC 2569371c9d4SSatish Balay } MatProductType; 257544a5e07SHong Zhang PETSC_EXTERN const char *const MatProductTypes[]; 2584222ddf1SHong Zhang 2594222ddf1SHong Zhang /*J 2604222ddf1SHong Zhang MatProductAlgorithm - String with the name of an algorithm for a PETSc matrix product implementation 2614222ddf1SHong Zhang 2624222ddf1SHong Zhang Level: beginner 2634222ddf1SHong Zhang 2641cc06b55SBarry Smith .seealso: [](sec_matmatproduct), [](ch_matrices), `MatSetType()`, `Mat`, `MatProductSetAlgorithm()`, `MatProductType` 2654222ddf1SHong Zhang J*/ 2664222ddf1SHong Zhang typedef const char *MatProductAlgorithm; 2673e662e0bSHong Zhang #define MATPRODUCTALGORITHMDEFAULT "default" 2683e662e0bSHong Zhang #define MATPRODUCTALGORITHMSORTED "sorted" 2693e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLE "scalable" 2703e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLEFAST "scalable_fast" 2713e662e0bSHong Zhang #define MATPRODUCTALGORITHMHEAP "heap" 2723e662e0bSHong Zhang #define MATPRODUCTALGORITHMBHEAP "btheap" 2733e662e0bSHong Zhang #define MATPRODUCTALGORITHMLLCONDENSED "llcondensed" 2743e662e0bSHong Zhang #define MATPRODUCTALGORITHMROWMERGE "rowmerge" 2753e662e0bSHong Zhang #define MATPRODUCTALGORITHMOUTERPRODUCT "outerproduct" 2763e662e0bSHong Zhang #define MATPRODUCTALGORITHMATB "at*b" 2773e662e0bSHong Zhang #define MATPRODUCTALGORITHMRAP "rap" 2783e662e0bSHong Zhang #define MATPRODUCTALGORITHMNONSCALABLE "nonscalable" 2793e662e0bSHong Zhang #define MATPRODUCTALGORITHMSEQMPI "seqmpi" 2803e662e0bSHong Zhang #define MATPRODUCTALGORITHMBACKEND "backend" 2813e662e0bSHong Zhang #define MATPRODUCTALGORITHMOVERLAPPING "overlapping" 2823e662e0bSHong Zhang #define MATPRODUCTALGORITHMMERGED "merged" 2833e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCE "allatonce" 2843e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCEMERGED "allatonce_merged" 2853e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLGATHERV "allgatherv" 2863e662e0bSHong Zhang #define MATPRODUCTALGORITHMCYCLIC "cyclic" 2873e662e0bSHong Zhang #if defined(PETSC_HAVE_HYPRE) 2883e662e0bSHong Zhang #define MATPRODUCTALGORITHMHYPRE "hypre" 2893e662e0bSHong Zhang #endif 2904222ddf1SHong Zhang 2914222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreate(Mat, Mat, Mat, Mat *); 2924222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreateWithMat(Mat, Mat, Mat, Mat); 2934222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetType(Mat, MatProductType); 2944222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetAlgorithm(Mat, MatProductAlgorithm); 2958fcac130SJose E. Roman PETSC_EXTERN PetscErrorCode MatProductGetAlgorithm(Mat, MatProductAlgorithm *); 2964222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFill(Mat, PetscReal); 2974222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFromOptions(Mat); 2984222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSymbolic(Mat); 2994222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductNumeric(Mat); 3004222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductReplaceMats(Mat, Mat, Mat, Mat); 3014417c5e8SHong Zhang PETSC_EXTERN PetscErrorCode MatProductClear(Mat); 3026718818eSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductView(Mat, PetscViewer); 303c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetType(Mat, MatProductType *); 304c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetMats(Mat, Mat *, Mat *, Mat *); 3054222ddf1SHong Zhang 306c06d978dSMatthew Knepley /* Logging support */ 3070700a824SBarry Smith #define MAT_FILE_CLASSID 1211216 /* used to indicate matrices in binary files */ 308014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_CLASSID; 309335efc43SPeter Brune PETSC_EXTERN PetscClassId MAT_COLORING_CLASSID; 310014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID; 311014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID; 312014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID; 313014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID; 314014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID; 315014dd563SJed Brown PETSC_EXTERN PetscClassId MATMFFD_CLASSID; 316c06d978dSMatthew Knepley 317ceb03754SKris Buschelman /*E 3182ef1f0ffSBarry Smith MatReuse - Indicates if matrices obtained from a previous call to `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatConvert()` or several other functions 319cf37664fSBarry Smith are to be reused to store the new matrix values. 320cf37664fSBarry Smith 3212ef1f0ffSBarry Smith Values: 3222ef1f0ffSBarry Smith + `MAT_INITIAL_MATRIX` - create a new matrix 3232ef1f0ffSBarry Smith . `MAT_REUSE_MATRIX` - reuse the matrix created with a previous call that used `MAT_INITIAL_MATRIX` 3242ef1f0ffSBarry Smith . `MAT_INPLACE_MATRIX` - replace the first input matrix with the new matrix (not applicable to all functions) 3252ef1f0ffSBarry Smith - `MAT_IGNORE_MATRIX` - do not create a new matrix or reuse a give matrix, just ignore that matrix argument (not applicable to all functions) 326ceb03754SKris Buschelman 327ceb03754SKris Buschelman Level: beginner 328ceb03754SKris Buschelman 3291cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatDestroyMatrices()`, `MatConvert()` 330ceb03754SKris Buschelman E*/ 3319371c9d4SSatish Balay typedef enum { 3329371c9d4SSatish Balay MAT_INITIAL_MATRIX, 3339371c9d4SSatish Balay MAT_REUSE_MATRIX, 3349371c9d4SSatish Balay MAT_IGNORE_MATRIX, 3359371c9d4SSatish Balay MAT_INPLACE_MATRIX 3369371c9d4SSatish Balay } MatReuse; 337ceb03754SKris Buschelman 3385494a064SHong Zhang /*E 3392ef1f0ffSBarry Smith MatCreateSubMatrixOption - Indicates if matrices obtained from a call to `MatCreateSubMatrices()` 3402ef1f0ffSBarry Smith include the matrix values. Currently it is only used by `MatGetSeqNonzeroStructure()`. 3415494a064SHong Zhang 3422ef1f0ffSBarry Smith Values: 3432ef1f0ffSBarry Smith + `MAT_DO_NOT_GET_VALUES` - do not copy the matrix values 3442ef1f0ffSBarry Smith - `MAT_GET_VALUES` - copy the matrix values 3452ef1f0ffSBarry Smith 34695bd0b28SBarry Smith Level: developer 34795bd0b28SBarry Smith 3482ef1f0ffSBarry Smith Developer Note: 3492ef1f0ffSBarry Smith Why is not just a boolean used for this information? 3502ef1f0ffSBarry Smith 3511cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatDuplicateOption`, `PetscCopyMode`, `MatGetSeqNonzeroStructure()` 3525494a064SHong Zhang E*/ 3539371c9d4SSatish Balay typedef enum { 3549371c9d4SSatish Balay MAT_DO_NOT_GET_VALUES, 3559371c9d4SSatish Balay MAT_GET_VALUES 3569371c9d4SSatish Balay } MatCreateSubMatrixOption; 3575494a064SHong Zhang 358607a6623SBarry Smith PETSC_EXTERN PetscErrorCode MatInitializePackage(void); 3594bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatFinalizePackage(void); 360c06d978dSMatthew Knepley 361014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm, Mat *); 36277433607SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFromOptions(MPI_Comm, const char *, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 363014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetSizes(Mat, PetscInt, PetscInt, PetscInt, PetscInt); 36419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatSetType(Mat, MatType); 3650d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatGetVecType(Mat, VecType *); 3660d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetVecType(Mat, VecType); 367014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat); 368fe2efc57SMark PETSC_EXTERN PetscErrorCode MatViewFromOptions(Mat, PetscObject, const char[]); 369bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatRegister(const char[], PetscErrorCode (*)(Mat)); 37023bebc0bSBarry Smith PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[], const char[], const char[]); 371014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat, const char[]); 37226cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOptionsPrefixFactor(Mat, const char[]); 37326cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefixFactor(Mat, const char[]); 374014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat, const char[]); 375014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat, const char *[]); 37684d44b13SHong Zhang PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat, PetscBool); 377f69a0ea3SMatthew Knepley 378140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatList; 379140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatColoringList; 380140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatPartitioningList; 38128988994SBarry Smith 3823b224e63SBarry Smith /*E 383aa6c7ce3SBarry Smith MatStructure - Indicates if two matrices have the same nonzero structure 3843b224e63SBarry Smith 3852ef1f0ffSBarry Smith Values: 3862ef1f0ffSBarry Smith + `SAME_NONZERO_PATTERN` - the two matrices have identical nonzero patterns 3872ef1f0ffSBarry Smith . `DIFFERENT_NONZERO_PATTERN` - the two matrices may have different nonzero patterns 3882ef1f0ffSBarry Smith . `SUBSET_NONZERO_PATTERN` - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix 3892ef1f0ffSBarry Smith - `UNKNOWN_NONZERO_PATTERN` - there is no known relationship between the nonzero patterns. In this case the implementations 3902ef1f0ffSBarry Smith may try to detect a relationship to optimize the operation 391531d0c6aSBarry Smith 39216a05f60SBarry Smith Level: beginner 39316a05f60SBarry Smith 394af27ebaaSBarry Smith Note: 395af27ebaaSBarry Smith Certain matrix operations (such as `MatAXPY()`) can run much faster if the sparsity pattern of the matrices are the same. But actually determining if 396af27ebaaSBarry Smith the patterns are the same may be costly. This provides a way for users who know something about the sparsity patterns to provide this information 397af27ebaaSBarry Smith to certain PETSc routines. 398af27ebaaSBarry Smith 3991cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCopy()`, `MatAXPY()`, `MatAYPX()` 4003b224e63SBarry Smith E*/ 4019371c9d4SSatish Balay typedef enum { 4029371c9d4SSatish Balay DIFFERENT_NONZERO_PATTERN, 4039371c9d4SSatish Balay SUBSET_NONZERO_PATTERN, 4049371c9d4SSatish Balay SAME_NONZERO_PATTERN, 4059371c9d4SSatish Balay UNKNOWN_NONZERO_PATTERN 4069371c9d4SSatish Balay } MatStructure; 407d60b7d5cSBarry Smith PETSC_EXTERN const char *const MatStructures[]; 4083b224e63SBarry Smith 4099779e05dSSatish Balay #if defined PETSC_HAVE_MKL_SPARSE 410ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 411ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 41280095d54SIrina Sokolova PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 413ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 41480095d54SIrina Sokolova #endif 415cd929ea3SAlp Dener 4164bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateMPIAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 4174bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 4184bf303faSJacob Faibussowitsch 419d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 420d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 421d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat, PetscInt, const PetscInt[]); 422d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 42307e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetFillRatio(Mat, PetscReal *); 42407e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetMaxSliceWidth(Mat, PetscInt *); 42507e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetAvgSliceWidth(Mat, PetscReal *); 42607e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetSliceHeight(Mat, PetscInt); 427b921024eSHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetVarSliceSize(Mat, PetscReal *); 42880095d54SIrina Sokolova 4294bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 4304bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 431fa078d78SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMPISELLGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *); 432fa078d78SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMPISELLGetSeqSELL(Mat, Mat *, Mat *, const PetscInt *[]); 4334bf303faSJacob Faibussowitsch 434014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 435014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 436014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 437014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 438014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 4398f8f2f0dSBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 4406a3d2595SBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArray(Mat, const PetscScalar[]); 441014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], PetscInt[], PetscInt[], PetscScalar[], Mat *); 4423b00a383SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm, Mat, Mat, const PetscInt[], Mat *); 4433b00a383SHong Zhang 444014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 445014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 446014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 4477e8381f9SStefano Zampini 448e8729f6fSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSetPreallocationCOO(Mat, PetscCount, PetscInt[], PetscInt[]); 44982a78a4eSJed Brown PETSC_EXTERN PetscErrorCode MatSetPreallocationCOOLocal(Mat, PetscCount, PetscInt[], PetscInt[]); 4507e8381f9SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetValuesCOO(Mat, const PetscScalar[], InsertMode); 451d21a29f3SJed Brown 452014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscInt[], Mat *); 453014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 454d21a29f3SJed Brown 455014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 456014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 45738f409ebSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 458014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 4594cce697cSJed Brown PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscInt[], const PetscInt[]); 460dfb205c3SBarry Smith 461014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, void *, Mat *); 462c1fff1c6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatCreateCentering(MPI_Comm, PetscInt, PetscInt, Mat *); 463014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat, Mat *); 464c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat, Mat *); 465986c4d72SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat, Mat, Vec, Mat, Mat *); 466267ca84cSJose E. Roman PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat, Mat *, Mat *, Vec *, Mat *); 467bcf2175cSMatthew Knepley PETSC_EXTERN PetscErrorCode MatLRCSetMats(Mat, Mat, Mat, Vec, Mat); 468c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, ISLocalToGlobalMapping, ISLocalToGlobalMapping, Mat *); 469014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 470014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 471c0cdd4a1SDahai Guo 472014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm, VecScatter, Mat *); 473014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat, VecScatter); 474014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat, VecScatter *); 475014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt *, Mat *); 476014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat, Mat); 477014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat); 4789371c9d4SSatish Balay typedef enum { 4799371c9d4SSatish Balay MAT_COMPOSITE_MERGE_RIGHT, 4809371c9d4SSatish Balay MAT_COMPOSITE_MERGE_LEFT 4819371c9d4SSatish Balay } MatCompositeMergeType; 4828c8613bfSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat, MatCompositeMergeType); 483014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm, PetscInt, const Mat *, Mat *); 4840da935d5SPierre Jolivet /*E 4850da935d5SPierre Jolivet MatCompositeType - indicates what type of `MATCOMPOSITE` is used 4860da935d5SPierre Jolivet 4870da935d5SPierre Jolivet Values: 4880da935d5SPierre Jolivet + `MAT_COMPOSITE_ADDITIVE` - sum of matrices (default) 4890da935d5SPierre Jolivet - `MAT_COMPOSITE_MULTIPLICATIVE` - product of matrices 4900da935d5SPierre Jolivet 4910da935d5SPierre Jolivet Level: beginner 4920da935d5SPierre Jolivet 4930da935d5SPierre Jolivet .seealso: [](ch_matrices), `MATCOMPOSITE`, `MatCompositeSetType()`, `MatCompositeGetType()` 4940da935d5SPierre Jolivet E*/ 4959371c9d4SSatish Balay typedef enum { 4969371c9d4SSatish Balay MAT_COMPOSITE_ADDITIVE, 4979371c9d4SSatish Balay MAT_COMPOSITE_MULTIPLICATIVE 4989371c9d4SSatish Balay } MatCompositeType; 499014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat, MatCompositeType); 5006dbc55e5SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat, MatCompositeType *); 5013b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat, MatStructure); 5023b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat, MatStructure *); 5036d0add67SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat, PetscInt *); 5048b5c3584SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat, PetscInt, Mat *); 50503049c21SJunchao Zhang PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat, const PetscScalar *); 5066d7c1e57SBarry Smith 50719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm, PetscInt, const PetscInt[], MatType, Mat *); 508014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm, PetscInt, const PetscInt[], Mat *); 509dedccee8SHong Zhang 510014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat, Mat *); 5118060fb66Sstefano_zampini PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat, Mat *); 512d0de2241SAndrew Spott PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat, Mat *); 51306511a5cSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat, Mat *); 514fa80d070SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalGetMat(Mat, Mat *); 51565f45395SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalHermitianGetMat(Mat, Mat *); 51654e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat, IS, IS, Mat *); 51754e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat, Mat, IS, IS); 518014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat, IS, IS, Mat *); 5193423f386SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar, Mat *); 520345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatCreateDiagonal(Vec, Mat *); 521345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalGetDiagonal(Mat, Vec *); 522345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalRestoreDiagonal(Mat, Vec *); 523345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalGetInverseDiagonal(Mat, Vec *); 524345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalRestoreInverseDiagonal(Mat, Vec *); 5251472f72bSBarry Smith 526978814f1SStefano Zampini #if defined(PETSC_HAVE_HYPRE) 527d975228cSstefano_zampini PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 528978814f1SStefano Zampini #endif 529978814f1SStefano Zampini 530014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat, const char[]); 531ebead697SStefano Zampini PETSC_EXTERN PetscErrorCode MatPythonGetType(Mat, const char *[]); 5321d6018f0SLisandro Dalcin 533846b4da1SFande Kong PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat); 534014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetUp(Mat); 535014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroy(Mat *); 536e56f5c9eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat, PetscObjectState *); 53721c89e3eSBarry Smith 538014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatConjugate(Mat); 539014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRealPart(Mat); 540014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat); 541014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat, Mat *); 542014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetTrace(Mat, PetscScalar *); 543713ccfa9SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat, const PetscScalar **); 5440da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat, PetscInt, const PetscInt *, PetscScalar *); 545479a70c0SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat, Mat); 5468a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockEnvelope(Mat, MatReuse, Mat *); 54720c04d79SPierre Jolivet PETSC_EXTERN PetscErrorCode MatComputeVariableBlockEnvelope(Mat); 54899cafbc1SBarry Smith 549014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 5508a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetValuesIS(Mat, IS, IS, const PetscScalar[], InsertMode); 551014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 552014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat, PetscInt, const PetscScalar[]); 553014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat, PetscInt, const PetscScalar[]); 554014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat, PetscInt, PetscInt, PetscInt[], const PetscScalar[]); 55573a71a0fSBarry Smith PETSC_EXTERN PetscErrorCode MatSetRandom(Mat, PetscRandom); 55684cb2905SBarry Smith 5572ef4de8bSBarry Smith /*S 5582ef1f0ffSBarry Smith MatStencil - Data structure (C struct) for storing information about rows and 5592ef1f0ffSBarry Smith columns of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()` 56062ef0227SBarry Smith 5612ef1f0ffSBarry Smith Level: beginner 5622ef1f0ffSBarry Smith 5632ef1f0ffSBarry Smith Notes: 56462ef0227SBarry Smith The i,j, and k represent the logical coordinates over the entire grid (for 2 and 1 dimensional problems the k and j entries are ignored). 56515229ffcSPierre Jolivet The c represents the degrees of freedom at each grid point (the dof argument to `DMDASetDOF()`). If dof is 1 then this entry is ignored. 56662ef0227SBarry Smith 56787497f52SBarry Smith For stencil access to vectors see `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`. 568be479b30SJed Brown 5692ef1f0ffSBarry Smith For staggered grids, see `DMStagStencil` 5702ef4de8bSBarry Smith 5712ef1f0ffSBarry Smith Fortran Note: 5722ef1f0ffSBarry Smith See `MatSetValuesStencil()` for details. 5732ef4de8bSBarry Smith 5741cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`, 5752ef1f0ffSBarry Smith `DMStagStencil` 5762ef4de8bSBarry Smith S*/ 577435da068SBarry Smith typedef struct { 578c1ac3661SBarry Smith PetscInt k, j, i, c; 579435da068SBarry Smith } MatStencil; 5802ef4de8bSBarry Smith 581014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode); 582014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode); 583014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetStencil(Mat, PetscInt, const PetscInt[], const PetscInt[], PetscInt); 584435da068SBarry Smith 585d91e6319SBarry Smith /*E 5862ef1f0ffSBarry Smith MatAssemblyType - Indicates if the process of setting values into the matrix is complete, and the matrix is ready for use 587d91e6319SBarry Smith 5882ef1f0ffSBarry Smith Values: 5892ef1f0ffSBarry Smith + `MAT_FLUSH_ASSEMBLY` - you will continue to put values into the matrix 5902ef1f0ffSBarry Smith - `MAT_FINAL_ASSEMBLY` - you wish to use the matrix with the values currently inserted 5912ef1f0ffSBarry Smith 59216a05f60SBarry Smith Level: beginner 59316a05f60SBarry Smith 5941cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetValues`, `MatAssemblyBegin()`, `MatAssemblyEnd()` 595d91e6319SBarry Smith E*/ 5969371c9d4SSatish Balay typedef enum { 5979371c9d4SSatish Balay MAT_FLUSH_ASSEMBLY = 1, 5989371c9d4SSatish Balay MAT_FINAL_ASSEMBLY = 0 5999371c9d4SSatish Balay } MatAssemblyType; 6004f58015eSStefano Zampini 601014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat, MatAssemblyType); 602014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat, MatAssemblyType); 603014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssembled(Mat, PetscBool *); 6044f9c727eSBarry Smith 605d91e6319SBarry Smith /*E 6062ef1f0ffSBarry Smith MatOption - Options that may be set for a matrix that indicate properties of the matrix or affect its behavior or storage 607d91e6319SBarry Smith 608d91e6319SBarry Smith Level: beginner 609d91e6319SBarry Smith 6102ef1f0ffSBarry Smith Note: 6112ef1f0ffSBarry Smith See `MatSetOption()` for the use of the options 6122ef1f0ffSBarry Smith 6132ef1f0ffSBarry Smith Developer Note: 61495452b02SPatrick Sanan Entries that are negative need not be called collectively by all processes. 615382164b0SBarry Smith 6161cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetOption()` 617d91e6319SBarry Smith E*/ 6189371c9d4SSatish Balay typedef enum { 6199371c9d4SSatish Balay MAT_OPTION_MIN = -3, 620c5e4d11fSDmitry Karpeev MAT_UNUSED_NONZERO_LOCATION_ERR = -2, 62192d4d306SBarry Smith MAT_ROW_ORIENTED = -1, 622382164b0SBarry Smith MAT_SYMMETRIC = 1, 623382164b0SBarry Smith MAT_STRUCTURALLY_SYMMETRIC = 2, 6248c78258cSHong Zhang MAT_FORCE_DIAGONAL_ENTRIES = 3, 625382164b0SBarry Smith MAT_IGNORE_OFF_PROC_ENTRIES = 4, 626382164b0SBarry Smith MAT_USE_HASH_TABLE = 5, 627382164b0SBarry Smith MAT_KEEP_NONZERO_PATTERN = 6, 628382164b0SBarry Smith MAT_IGNORE_ZERO_ENTRIES = 7, 629382164b0SBarry Smith MAT_USE_INODES = 8, 630382164b0SBarry Smith MAT_HERMITIAN = 9, 631382164b0SBarry Smith MAT_SYMMETRY_ETERNAL = 10, 632c5e4d11fSDmitry Karpeev MAT_NEW_NONZERO_LOCATION_ERR = 11, 633382164b0SBarry Smith MAT_IGNORE_LOWER_TRIANGULAR = 12, 634382164b0SBarry Smith MAT_ERROR_LOWER_TRIANGULAR = 13, 635382164b0SBarry Smith MAT_GETROW_UPPERTRIANGULAR = 14, 636382164b0SBarry Smith MAT_SPD = 15, 63792d4d306SBarry Smith MAT_NO_OFF_PROC_ZERO_ROWS = 16, 63892d4d306SBarry Smith MAT_NO_OFF_PROC_ENTRIES = 17, 63992d4d306SBarry Smith MAT_NEW_NONZERO_LOCATIONS = 18, 640c5e4d11fSDmitry Karpeev MAT_NEW_NONZERO_ALLOCATION_ERR = 19, 641c5e4d11fSDmitry Karpeev MAT_SUBSET_OFF_PROC_ENTRIES = 20, 642c10200c1SHong Zhang MAT_SUBMAT_SINGLEIS = 21, 643957cac9fSHong Zhang MAT_STRUCTURE_ONLY = 22, 644071fcb05SBarry Smith MAT_SORTED_FULL = 23, 6451a2c6b5cSJunchao Zhang MAT_FORM_EXPLICIT_TRANSPOSE = 24, 646b94d7dedSBarry Smith MAT_STRUCTURAL_SYMMETRY_ETERNAL = 25, 647b94d7dedSBarry Smith MAT_SPD_ETERNAL = 26, 6489371c9d4SSatish Balay MAT_OPTION_MAX = 27 6499371c9d4SSatish Balay } MatOption; 650e057df02SPaul Mullowney 6510f8fb01aSBarry Smith PETSC_EXTERN const char *const *MatOptions; 652014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOption(Mat, MatOption, PetscBool); 6537d68702bSBarry Smith PETSC_EXTERN PetscErrorCode MatGetOption(Mat, MatOption, PetscBool *); 654856afa8bSStefano Zampini PETSC_EXTERN PetscErrorCode MatPropagateSymmetryOptions(Mat, Mat); 65519fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatGetType(Mat, MatType *); 65684cb2905SBarry Smith 657014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]); 658014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]); 659014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]); 660014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowUpperTriangular(Mat); 661014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowUpperTriangular(Mat); 662014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnVector(Mat, Vec, PetscInt); 6638c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJGetArray(Mat, PetscScalar *[]); 6648f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayRead(Mat, const PetscScalar *[]); 665d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayWrite(Mat, PetscScalar *[]); 6668c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArray(Mat, PetscScalar *[]); 6678f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayRead(Mat, const PetscScalar *[]); 668d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayWrite(Mat, PetscScalar *[]); 66921e72a00SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJGetMaxRowNonzeros(Mat, PetscInt *); 670bd04181cSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetValuesLocalFast(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 6714099cc6bSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetType(Mat, MatType); 672ad7e164aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatSeqAIJKron(Mat, Mat, MatReuse, Mat *); 673388d47a6SSatish Balay PETSC_EXTERN PetscErrorCode MatSeqAIJRegister(const char[], PetscErrorCode (*)(Mat, MatType, MatReuse, Mat *)); 6744099cc6bSBarry Smith PETSC_EXTERN PetscFunctionList MatSeqAIJList; 675cda14afcSprj- PETSC_EXTERN PetscErrorCode MatSeqBAIJGetArray(Mat, PetscScalar *[]); 676cda14afcSprj- PETSC_EXTERN PetscErrorCode MatSeqBAIJRestoreArray(Mat, PetscScalar *[]); 6778397e458SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqSBAIJGetArray(Mat, PetscScalar *[]); 6788397e458SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqSBAIJRestoreArray(Mat, PetscScalar *[]); 6798c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetArray(Mat, PetscScalar *[]); 6808c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseRestoreArray(Mat, PetscScalar *[]); 681d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode MatDensePlaceArray(Mat, const PetscScalar[]); 682d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseReplaceArray(Mat, const PetscScalar[]); 683d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseResetArray(Mat); 6848572280aSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetArrayRead(Mat, const PetscScalar *[]); 6858572280aSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayRead(Mat, const PetscScalar *[]); 6866947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetArrayWrite(Mat, PetscScalar *[]); 6876947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWrite(Mat, PetscScalar *[]); 688cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseGetArrayAndMemType(Mat, PetscScalar *[], PetscMemType *); 689cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayAndMemType(Mat, PetscScalar *[]); 690cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseGetArrayReadAndMemType(Mat, const PetscScalar *[], PetscMemType *); 691cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayReadAndMemType(Mat, const PetscScalar *[]); 692cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseGetArrayWriteAndMemType(Mat, PetscScalar *[], PetscMemType *); 693cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWriteAndMemType(Mat, PetscScalar *[]); 694014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBlockSize(Mat, PetscInt *); 695014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSize(Mat, PetscInt); 696014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBlockSizes(Mat, PetscInt *, PetscInt *); 697014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSizes(Mat, PetscInt, PetscInt); 69833d57670SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSizesFromMats(Mat, Mat, Mat); 6990da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetVariableBlockSizes(Mat, PetscInt, PetscInt *); 7000da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetVariableBlockSizes(Mat, PetscInt *, const PetscInt **); 7010da83c2eSBarry Smith 70286aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat, PetscInt, PetscScalar *[]); 70386aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat, PetscScalar *[]); 7046947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVec(Mat, PetscInt, Vec *); 7056947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVec(Mat, PetscInt, Vec *); 7066947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecRead(Mat, PetscInt, Vec *); 7076947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecRead(Mat, PetscInt, Vec *); 7086947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecWrite(Mat, PetscInt, Vec *); 7096947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecWrite(Mat, PetscInt, Vec *); 710a2748737SPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseGetSubMatrix(Mat, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 7115ea7661aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseRestoreSubMatrix(Mat, Mat *); 7121620fd73SBarry Smith 713014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMult(Mat, Vec, Vec); 714014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat, Vec, Vec); 715014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAdd(Mat, Vec, Vec, Vec); 716014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat, Vec, Vec); 717014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat, Vec, Vec); 718014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat, Mat, PetscReal, PetscBool *); 719014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat, Mat, PetscReal, PetscBool *); 720014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat, Vec, Vec, Vec); 721014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat, Vec, Vec, Vec); 722014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatSolve(Mat, Mat, Mat); 723bdc285e1SStefano Zampini PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat, Mat, Mat); 724eb3ef3b2SHong Zhang PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat, Mat, Mat); 725f9426fe0SMark Adams PETSC_EXTERN PetscErrorCode MatResidual(Mat, Vec, Vec, Vec); 726f5edf698SHong Zhang 727d91e6319SBarry Smith /*E 728d91e6319SBarry Smith MatDuplicateOption - Indicates if a duplicated sparse matrix should have 729d91e6319SBarry Smith its numerical values copied over or just its nonzero structure. 730d91e6319SBarry Smith 7312ef1f0ffSBarry Smith Values: 7322ef1f0ffSBarry Smith + `MAT_DO_NOT_COPY_VALUES` - Create a matrix using the same nonzero pattern as the original matrix, 7332ef1f0ffSBarry Smith with zeros for the numerical values 7342ef1f0ffSBarry Smith . `MAT_COPY_VALUES` - Create a matrix with the same nonzero pattern as the original matrix 7352ef1f0ffSBarry Smith and with the same numerical values. 7362ef1f0ffSBarry Smith - `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix 7372ef1f0ffSBarry Smith and does not copy it, using zeros for the numerical values. The parent and 7382ef1f0ffSBarry Smith child matrices will share their index (i and j) arrays, and you cannot 7392ef1f0ffSBarry Smith insert new nonzero entries into either matrix 7400018da39SRichard Tran Mills 74116a05f60SBarry Smith Level: beginner 74216a05f60SBarry Smith 74387497f52SBarry Smith Note: 74487497f52SBarry Smith Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in 74587497f52SBarry Smith this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified. 74670dcbbb9SBarry Smith 7471cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatDuplicate()` 748d91e6319SBarry Smith E*/ 7499371c9d4SSatish Balay typedef enum { 7509371c9d4SSatish Balay MAT_DO_NOT_COPY_VALUES, 7519371c9d4SSatish Balay MAT_COPY_VALUES, 7529371c9d4SSatish Balay MAT_SHARE_NONZERO_PATTERN 7539371c9d4SSatish Balay } MatDuplicateOption; 7542e8a6d31SBarry Smith 75519fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatConvert(Mat, MatType, MatReuse, Mat *); 756014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDuplicate(Mat, MatDuplicateOption, Mat *); 75794a9d846SBarry Smith 758014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCopy(Mat, Mat, MatStructure); 759014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatView(Mat, PetscViewer); 760014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat, PetscReal, PetscBool *); 761014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat, PetscBool *); 762014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat, PetscReal, PetscBool *); 763014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat, PetscBool *, PetscBool *); 764014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat, PetscBool *, PetscBool *); 765b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetricKnown(Mat, PetscBool *, PetscBool *); 766b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsSPDKnown(Mat, PetscBool *, PetscBool *); 767014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMissingDiagonal(Mat, PetscBool *, PetscInt *); 768014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer); 7697b80b807SBarry Smith 7701a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 7711a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 7721a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 7731a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 774d4fbbf0eSBarry Smith 775d91e6319SBarry Smith /*S 77687497f52SBarry Smith MatInfo - Context of matrix information, used with `MatGetInfo()` 777d91e6319SBarry Smith 778d91e6319SBarry Smith Level: intermediate 779d91e6319SBarry Smith 7802ef1f0ffSBarry Smith Fortran Note: 7812ef1f0ffSBarry Smith Information is stored as a double-precision array of dimension `MAT_INFO_SIZE` 7822ef1f0ffSBarry Smith 7831cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetInfo()`, `MatInfoType` 784d91e6319SBarry Smith S*/ 7854e220ebcSLois Curfman McInnes typedef struct { 786b0a32e0cSBarry Smith PetscLogDouble block_size; /* block size */ 787b0a32e0cSBarry Smith PetscLogDouble nz_allocated, nz_used, nz_unneeded; /* number of nonzeros */ 788b0a32e0cSBarry Smith PetscLogDouble memory; /* memory allocated */ 789b0a32e0cSBarry Smith PetscLogDouble assemblies; /* number of matrix assemblies called */ 790b0a32e0cSBarry Smith PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 791b0a32e0cSBarry Smith PetscLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */ 792b0a32e0cSBarry Smith PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 7934e220ebcSLois Curfman McInnes } MatInfo; 7944e220ebcSLois Curfman McInnes 795d9274352SBarry Smith /*E 796d9274352SBarry Smith MatInfoType - Indicates if you want information about the local part of the matrix, 797d9274352SBarry Smith the entire parallel matrix or the maximum over all the local parts. 798d9274352SBarry Smith 7992ef1f0ffSBarry Smith Values: 8002ef1f0ffSBarry Smith + `MAT_LOCAL` - values for each MPI process part of the matrix 8012ef1f0ffSBarry Smith . `MAT_GLOBAL_MAX` - maximum of each value over all MPI processes 8022ef1f0ffSBarry Smith - `MAT_GLOBAL_SUM` - sum of each value over all MPI processes 803d9274352SBarry Smith 80416a05f60SBarry Smith Level: beginner 80516a05f60SBarry Smith 8061cc06b55SBarry Smith .seealso: [](ch_matrices), `MatGetInfo()`, `MatInfo` 807d9274352SBarry Smith E*/ 8089371c9d4SSatish Balay typedef enum { 8099371c9d4SSatish Balay MAT_LOCAL = 1, 8109371c9d4SSatish Balay MAT_GLOBAL_MAX = 2, 8119371c9d4SSatish Balay MAT_GLOBAL_SUM = 3 8129371c9d4SSatish Balay } MatInfoType; 813014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInfo(Mat, MatInfoType, MatInfo *); 814014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat, Vec); 815014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat, Vec, PetscInt[]); 816014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat, Vec, PetscInt[]); 817014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat, Vec, PetscInt[]); 818eede4a3fSMark Adams PETSC_EXTERN PetscErrorCode MatGetRowSumAbs(Mat, Vec); 819014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat, Vec, PetscInt[]); 820014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat, Vec); 821014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTranspose(Mat, MatReuse, Mat *); 8227fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSymbolic(Mat, Mat *); 8237fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSetPrecursor(Mat, Mat); 824014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat, MatReuse, Mat *); 825014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPermute(Mat, IS, IS, Mat *); 826014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat, Vec, Vec); 827014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat, Vec, InsertMode); 828a52676ecSHong Zhang 829014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatEqual(Mat, Mat, PetscBool *); 830014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultEqual(Mat, Mat, PetscInt, PetscBool *); 831014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat, Mat, PetscInt, PetscBool *); 832014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat, Mat, PetscInt, PetscBool *); 833014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *); 834e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeEqual(Mat, Mat, PetscInt, PetscBool *); 835e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *); 836a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 837a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 838cc48ffa7SToby Isaac PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 8394222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatPtAPMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 840447fed29SStefano Zampini PETSC_EXTERN PetscErrorCode MatRARtMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 84186919fd6SHong Zhang PETSC_EXTERN PetscErrorCode MatIsLinear(Mat, PetscInt, PetscBool *); 8427b80b807SBarry Smith 843014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNorm(Mat, NormType, PetscReal *); 844014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat, NormType, PetscReal *); 845857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSums(Mat, PetscScalar *); 846857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsRealPart(Mat, PetscReal *); 847857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsImaginaryPart(Mat, PetscReal *); 848857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeans(Mat, PetscScalar *); 849857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansRealPart(Mat, PetscReal *); 850857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansImaginaryPart(Mat, PetscReal *); 851857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnReductions(Mat, PetscInt, PetscReal *); 852014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat); 8531b2b9847SBarry Smith PETSC_EXTERN PetscErrorCode MatSetInf(Mat); 854014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRows(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 855014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat, IS, PetscScalar, Vec, Vec); 856014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec); 857014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec); 858014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 859014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat, IS, PetscScalar, Vec, Vec); 8607b80b807SBarry Smith 861014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSize(Mat, PetscInt *, PetscInt *); 862014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat, PetscInt *, PetscInt *); 863014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat, PetscInt *, PetscInt *); 864014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat, const PetscInt **); 865014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat, PetscInt *, PetscInt *); 866014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat, const PetscInt **); 867566876eaSJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat, IS *, IS *); 8685ef9f2a5SBarry Smith 8697dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]); 870edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 8, 0, "MatCreateSubMatrices()", ) static inline PetscErrorCode MatGetSubMatrices(Mat mat, PetscInt n, const IS irow[], const IS icol[], MatReuse scall, Mat *submat[]) 871d71ae5a4SJacob Faibussowitsch { 8729371c9d4SSatish Balay return MatCreateSubMatrices(mat, n, irow, icol, scall, submat); 8739371c9d4SSatish Balay } 8747dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]); 875edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 8, 0, "MatCreateSubMatricesMPI()", ) static inline PetscErrorCode MatGetSubMatricesMPI(Mat mat, PetscInt n, const IS irow[], const IS icol[], MatReuse scall, Mat *submat[]) 876d71ae5a4SJacob Faibussowitsch { 8779371c9d4SSatish Balay return MatCreateSubMatricesMPI(mat, n, irow, icol, scall, submat); 8789371c9d4SSatish Balay } 879014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt, Mat *[]); 880df750dc8SHong Zhang PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt, Mat *[]); 8817dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat, IS, IS, MatReuse, Mat *); 882edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 8, 0, "MatCreateSubMatrix()", ) static inline PetscErrorCode MatGetSubMatrix(Mat mat, IS isrow, IS iscol, MatReuse cll, Mat *newmat) 883d71ae5a4SJacob Faibussowitsch { 8849371c9d4SSatish Balay return MatCreateSubMatrix(mat, isrow, iscol, cll, newmat); 8859371c9d4SSatish Balay } 886014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat, IS, IS, Mat *); 887014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat, IS, IS, Mat *); 888014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat, Mat *); 889014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat *); 8907b80b807SBarry Smith 891014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm, Mat, PetscInt, PetscInt, MatReuse, Mat *); 892014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm, Mat, PetscInt, PetscInt, Mat *); 893014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat, Mat); 894014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat, MatReuse, Mat *); 8958a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatAIJGetLocalMat(Mat, Mat *); 896014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *); 897ed502f03SStefano Zampini PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatMerge(Mat, MatReuse, IS *, Mat *); 898f2afee66SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJGetNumberNonzeros(Mat, PetscCount *); 899014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat, Mat, MatReuse, IS *, IS *, Mat *); 900014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *, const PetscInt *[]); 9018efafbd8SBarry Smith 902014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat, PetscInt, IS[], PetscInt); 903aa1e27eaSFande Kong PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat mat, PetscInt n, IS is[], PetscInt ov); 904d2b2a242SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat, PetscBool); 9057b80b807SBarry Smith 906014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatMult(Mat, Mat, MatReuse, PetscReal, Mat *); 90722440eb1SKris Buschelman 9087bab7c10SHong Zhang PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat, Mat, Mat, MatReuse, PetscReal, Mat *); 9092df6c5c3SPatrick Farrell PETSC_EXTERN PetscErrorCode MatGalerkin(Mat, Mat, Mat, MatReuse, PetscReal, Mat *); 9107bab7c10SHong Zhang 911014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPtAP(Mat, Mat, MatReuse, PetscReal, Mat *); 912014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRARt(Mat, Mat, MatReuse, PetscReal, Mat *); 91322440eb1SKris Buschelman 914014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat, Mat, MatReuse, PetscReal, Mat *); 915014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat, Mat, MatReuse, PetscReal, Mat *); 916bc011b1eSHong Zhang 917014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAXPY(Mat, PetscScalar, Mat, MatStructure); 918014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAYPX(Mat, PetscScalar, Mat, MatStructure); 9191c741599SHong Zhang 920014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScale(Mat, PetscScalar); 921014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShift(Mat, PetscScalar); 9227b80b807SBarry Smith 923014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping, ISLocalToGlobalMapping); 924014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *); 925a93ff8c4SPeter Brune PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat, PetscLayout *, PetscLayout *); 92681fa06acSBarry Smith PETSC_EXTERN PetscErrorCode MatSetLayouts(Mat, PetscLayout, PetscLayout); 927014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 928014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat, IS, PetscScalar, Vec, Vec); 929014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 930014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat, IS, PetscScalar, Vec, Vec); 931e265f6d6SPatrick Sanan PETSC_EXTERN PetscErrorCode MatGetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]); 932014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 933014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 934052efed2SBarry Smith 935014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat, PetscInt, PetscInt); 936014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat, PetscInt *, PetscInt *, PetscInt *, PetscInt *); 93790f02eecSBarry Smith 938014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolate(Mat, Vec, Vec); 939014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat, Vec, Vec, Vec); 940014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestrict(Mat, Vec, Vec); 94130b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolate(Mat, Mat, Mat *); 94230b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolateAdd(Mat, Mat, Mat, Mat *); 94330b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatRestrict(Mat, Mat, Mat *); 9442a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat, Vec *, Vec *); 945edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 6, 0, "MatCreateVecs()", ) static inline PetscErrorCode MatGetVecs(Mat mat, Vec *x, Vec *y) 946d71ae5a4SJacob Faibussowitsch { 9479371c9d4SSatish Balay return MatCreateVecs(mat, x, y); 9489371c9d4SSatish Balay } 94953cd1579SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat, PetscInt, MPI_Comm, MatReuse, Mat *); 950014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat, MPI_Comm, MatReuse, Mat *); 951014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat, IS *); 9523a062f41SBarry Smith PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat, IS *); 9539c8f2541SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm, Mat, PetscInt, MatReuse, Mat *); 954bd481603SBarry Smith 955c8d6c325SJunchao Zhang /*@C 9561620fd73SBarry Smith MatSetValue - Set a single entry into a matrix. 9571620fd73SBarry Smith 958e1c5b2e2SJose E. Roman Not Collective 959a9834a7dSSatish Balay 9601620fd73SBarry Smith Input Parameters: 961c8d6c325SJunchao Zhang + mat - the matrix 96216a05f60SBarry Smith . i - the row location of the entry 96316a05f60SBarry Smith . j - the column location of the entry 96416a05f60SBarry Smith . va - the value to insert 96587497f52SBarry Smith - mode - either `INSERT_VALUES` or `ADD_VALUES` 9661620fd73SBarry Smith 9671620fd73SBarry Smith Level: beginner 9681620fd73SBarry Smith 96995bd0b28SBarry Smith Notes: 97095bd0b28SBarry Smith This value may be cached, so `MatAssemblyBegin()` and `MatAssemblyEnd()` 97195bd0b28SBarry Smith MUST be called after all calls to `MatSetValue()` have been completed. 97295bd0b28SBarry Smith 9732ef1f0ffSBarry Smith For efficiency one should use `MatSetValues()` and set several values simultaneously. 9742ef1f0ffSBarry Smith 975b43fc34aSPierre Jolivet .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `InsertMode`, `MatGetValue()`, `MatSetValues()`, 9762ef1f0ffSBarry Smith `MatSetValueLocal()`, `MatSetValuesLocal()` 977c8d6c325SJunchao Zhang @*/ 978c8d6c325SJunchao Zhang static inline PetscErrorCode MatSetValue(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode) 979d71ae5a4SJacob Faibussowitsch { 980c8d6c325SJunchao Zhang return MatSetValues(mat, 1, &i, 1, &j, &va, mode); 9819371c9d4SSatish Balay } 9821620fd73SBarry Smith 983e5e5a7b5SPatrick Sanan /*@C 984e5e5a7b5SPatrick Sanan MatGetValue - Gets a single value from a matrix 9851620fd73SBarry Smith 986e5e5a7b5SPatrick Sanan Not Collective; can only return a value owned by the given process 987e5e5a7b5SPatrick Sanan 988e5e5a7b5SPatrick Sanan Input Parameters: 989e5e5a7b5SPatrick Sanan + mat - the matrix 990e5e5a7b5SPatrick Sanan . row - the row location of the entry 991e5e5a7b5SPatrick Sanan - col - the column location of the entry 992e5e5a7b5SPatrick Sanan 993e5e5a7b5SPatrick Sanan Output Parameter: 994e5e5a7b5SPatrick Sanan . va - the value 995e5e5a7b5SPatrick Sanan 9962ef1f0ffSBarry Smith Level: advanced 9972ef1f0ffSBarry Smith 998e5e5a7b5SPatrick Sanan Notes: 999b43fc34aSPierre Jolivet The matrix must have been assembled with `MatAssemblyBegin()` and `MatAssemblyEnd()` before this call 10002ef1f0ffSBarry Smith 100187497f52SBarry Smith For efficiency one should use `MatGetValues()` and get several values simultaneously. 1002e5e5a7b5SPatrick Sanan 100387497f52SBarry Smith See notes for `MatGetValues()`. 1004e5e5a7b5SPatrick Sanan 1005b43fc34aSPierre Jolivet .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `MatSetValue()`, `MatGetValueLocal()`, `MatGetValues()` 1006e5e5a7b5SPatrick Sanan @*/ 1007d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode MatGetValue(Mat mat, PetscInt row, PetscInt col, PetscScalar *va) 1008d71ae5a4SJacob Faibussowitsch { 10099371c9d4SSatish Balay return MatGetValues(mat, 1, &row, 1, &col, va); 10109371c9d4SSatish Balay } 1011e5e5a7b5SPatrick Sanan 1012c8d6c325SJunchao Zhang /*@C 10132ef1f0ffSBarry Smith MatSetValueLocal - Inserts or adds a single value into a matrix, using a local numbering of the nodes. 1014e5e5a7b5SPatrick Sanan 1015e5e5a7b5SPatrick Sanan Not Collective 1016e5e5a7b5SPatrick Sanan 1017e5e5a7b5SPatrick Sanan Input Parameters: 1018c8d6c325SJunchao Zhang + mat - the matrix 101916a05f60SBarry Smith . i - the row location of the entry 102016a05f60SBarry Smith . j - the column location of the entry 102116a05f60SBarry Smith . va - the value to insert 102287497f52SBarry Smith - mode - either `INSERT_VALUES` or `ADD_VALUES` 1023e5e5a7b5SPatrick Sanan 10242ef1f0ffSBarry Smith Level: intermediate 10252ef1f0ffSBarry Smith 1026e5e5a7b5SPatrick Sanan Notes: 102787497f52SBarry Smith For efficiency one should use `MatSetValuesLocal()` and set several values simultaneously. 1028e5e5a7b5SPatrick Sanan 102987497f52SBarry Smith See notes for `MatSetValuesLocal()` for additional information on when and how this function can be used. 1030e5e5a7b5SPatrick Sanan 10311cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSetValue()`, `MatSetValuesLocal()` 1032c8d6c325SJunchao Zhang @*/ 1033c8d6c325SJunchao Zhang static inline PetscErrorCode MatSetValueLocal(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode) 1034d71ae5a4SJacob Faibussowitsch { 1035c8d6c325SJunchao Zhang return MatSetValuesLocal(mat, 1, &i, 1, &j, &va, mode); 10369371c9d4SSatish Balay } 10371620fd73SBarry Smith 10381620fd73SBarry Smith /*MC 1039d0609cedSBarry Smith MatPreallocateBegin - Begins the block of code that will count the number of nonzeros per 1040bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 1041bd481603SBarry Smith 1042bd481603SBarry Smith Synopsis: 1043aaa7dc30SBarry Smith #include <petscmat.h> 1044d0609cedSBarry Smith PetscErrorCode MatPreallocateBegin(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 1045bd481603SBarry Smith 1046d083f849SBarry Smith Collective 1047bd481603SBarry Smith 1048bd481603SBarry Smith Input Parameters: 1049bd481603SBarry Smith + comm - the communicator that will share the eventually allocated matrix 1050859fcb39SBarry Smith . nrows - the number of LOCAL rows in the matrix 1051859fcb39SBarry Smith - ncols - the number of LOCAL columns in the matrix 1052bd481603SBarry Smith 1053bd481603SBarry Smith Output Parameters: 1054bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 1055a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1056bd481603SBarry Smith 10572ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1058bd481603SBarry Smith 1059bd481603SBarry Smith Notes: 10602ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 10612ef1f0ffSBarry Smith the use of this routine 10622ef1f0ffSBarry Smith 1063d0609cedSBarry Smith This is a macro that handles its own error checking, it does not return an error code. 1064d0609cedSBarry Smith 10652ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1066bd481603SBarry Smith 10672ef1f0ffSBarry Smith Developer Note: 1068af27ebaaSBarry Smith This is a MACRO, not a function, because it has a leading { that is closed by `PetscPreallocateFinalize()`. 1069bd481603SBarry Smith 10701cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1071db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()` 1072bd481603SBarry Smith M*/ 10739371c9d4SSatish Balay #define MatPreallocateBegin(comm, nrows, ncols, dnz, onz) \ 10749371c9d4SSatish Balay do { \ 10753ba16761SJacob Faibussowitsch PetscInt __nrows = (nrows), __ncols = (ncols), __rstart, __end = 0; \ 10763ba16761SJacob Faibussowitsch PetscInt PETSC_UNUSED __start; \ 10779566063dSJacob Faibussowitsch PetscCall(PetscCalloc2(__nrows, &(dnz), __nrows, &(onz))); \ 10789566063dSJacob Faibussowitsch PetscCallMPI(MPI_Scan(&__ncols, &__end, 1, MPIU_INT, MPI_SUM, comm)); \ 10799371c9d4SSatish Balay __start = __end - __ncols; \ 10809371c9d4SSatish Balay (void)__start; \ 10819566063dSJacob Faibussowitsch PetscCallMPI(MPI_Scan(&__nrows, &__rstart, 1, MPIU_INT, MPI_SUM, comm)); \ 10825f80ce2aSJacob Faibussowitsch __rstart -= __nrows 10837c922b88SBarry Smith 1084edd03b47SJacob Faibussowitsch #define MatPreallocateInitialize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateBegin()", ) MatPreallocateBegin(__VA_ARGS__) 1085d0609cedSBarry Smith 1086bd481603SBarry Smith /*MC 1087bd481603SBarry Smith MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1088bd481603SBarry Smith inserted using a local number of the rows and columns 1089bd481603SBarry Smith 1090bd481603SBarry Smith Synopsis: 1091aaa7dc30SBarry Smith #include <petscmat.h> 1092c1ac3661SBarry Smith PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1093bd481603SBarry Smith 1094bd481603SBarry Smith Not Collective 1095bd481603SBarry Smith 1096bd481603SBarry Smith Input Parameters: 1097784ac674SJed Brown + map - the row mapping from local numbering to global numbering 1098bd481603SBarry Smith . nrows - the number of rows indicated 10991d73ed98SBarry Smith . rows - the indices of the rows 1100784ac674SJed Brown . cmap - the column mapping from local to global numbering 1101bd481603SBarry Smith . ncols - the number of columns in the matrix 1102bd481603SBarry Smith . cols - the columns indicated 1103bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1104a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1105bd481603SBarry Smith 11062ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1107bd481603SBarry Smith 1108bd481603SBarry Smith Notes: 11092ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 11102ef1f0ffSBarry Smith the use of this routine 1111bd481603SBarry Smith 11122ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1113bd481603SBarry Smith 11141cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1115db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocalRemoveDups()` 1116bd481603SBarry Smith M*/ 111794bad497SJacob Faibussowitsch #define MatPreallocateSetLocal(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 11189371c9d4SSatish Balay PetscMacroReturnStandard(PetscCall(ISLocalToGlobalMappingApply(rmap, nrows, rows, rows)); PetscCall(ISLocalToGlobalMappingApply(cmap, ncols, cols, cols)); for (PetscInt __l = 0; __l < nrows; __l++) PetscCall(MatPreallocateSet((rows)[__l], ncols, cols, dnz, onz));) 1119c4f061fbSSatish Balay 1120bd481603SBarry Smith /*MC 1121c1154cd5SBarry Smith MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1122c1154cd5SBarry Smith inserted using a local number of the rows and columns. This version removes any duplicate columns in cols 1123c1154cd5SBarry Smith 1124c1154cd5SBarry Smith Synopsis: 1125c1154cd5SBarry Smith #include <petscmat.h> 1126c1154cd5SBarry Smith PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1127c1154cd5SBarry Smith 1128c1154cd5SBarry Smith Not Collective 1129c1154cd5SBarry Smith 1130c1154cd5SBarry Smith Input Parameters: 1131c1154cd5SBarry Smith + map - the row mapping from local numbering to global numbering 1132c1154cd5SBarry Smith . nrows - the number of rows indicated 1133c1154cd5SBarry Smith . rows - the indices of the rows (these values are mapped to the global values) 1134c1154cd5SBarry Smith . cmap - the column mapping from local to global numbering 1135c1154cd5SBarry Smith . ncols - the number of columns in the matrix (this value will be changed if duplicate columns are found) 1136c1154cd5SBarry Smith . cols - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed) 1137c1154cd5SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1138a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1139c1154cd5SBarry Smith 11402ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1141c1154cd5SBarry Smith 1142c1154cd5SBarry Smith Notes: 11432ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 11442ef1f0ffSBarry Smith the use of this routine 1145c1154cd5SBarry Smith 11462ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1147c1154cd5SBarry Smith 11481cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1149db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()` 1150c1154cd5SBarry Smith M*/ 115194bad497SJacob Faibussowitsch #define MatPreallocateSetLocalRemoveDups(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 11529371c9d4SSatish Balay PetscMacroReturnStandard(PetscCall(ISLocalToGlobalMappingApply(rmap, nrows, rows, rows)); PetscCall(ISLocalToGlobalMappingApply(cmap, ncols, cols, cols)); PetscCall(PetscSortRemoveDupsInt(&ncols, cols)); for (PetscInt __l = 0; __l < nrows; __l++) PetscCall(MatPreallocateSet((rows)[__l], ncols, cols, dnz, onz));) 1153c1154cd5SBarry Smith 1154c1154cd5SBarry Smith /*MC 1155d6e23781SBarry Smith MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1156bd481603SBarry Smith inserted using a local number of the rows and columns 1157bd481603SBarry Smith 1158bd481603SBarry Smith Synopsis: 1159aaa7dc30SBarry Smith #include <petscmat.h> 1160d6e23781SBarry Smith PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1161d6e23781SBarry Smith 1162d6e23781SBarry Smith Not Collective 1163d6e23781SBarry Smith 1164d6e23781SBarry Smith Input Parameters: 1165d6e23781SBarry Smith + map - the row mapping from local numbering to global numbering 1166d6e23781SBarry Smith . nrows - the number of rows indicated 1167d6e23781SBarry Smith . rows - the indices of the rows 1168d6e23781SBarry Smith . cmap - the column mapping from local to global numbering 1169d6e23781SBarry Smith . ncols - the number of columns in the matrix 1170d6e23781SBarry Smith . cols - the columns indicated 1171d6e23781SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1172a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1173d6e23781SBarry Smith 11742ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1175d6e23781SBarry Smith 1176d6e23781SBarry Smith Notes: 11772ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 11782ef1f0ffSBarry Smith the use of this routine 1179d6e23781SBarry Smith 11802ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1181d6e23781SBarry Smith 11821cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1183db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()` 1184d6e23781SBarry Smith M*/ 118594bad497SJacob Faibussowitsch #define MatPreallocateSetLocalBlock(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 11869371c9d4SSatish Balay PetscMacroReturnStandard(PetscCall(ISLocalToGlobalMappingApplyBlock(rmap, nrows, rows, rows)); PetscCall(ISLocalToGlobalMappingApplyBlock(cmap, ncols, cols, cols)); for (PetscInt __l = 0; __l < nrows; __l++) PetscCall(MatPreallocateSet((rows)[__l], ncols, cols, dnz, onz));) 1187d6e23781SBarry Smith 1188d6e23781SBarry Smith /*MC 1189d6e23781SBarry Smith MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1190d6e23781SBarry Smith inserted using a local number of the rows and columns 1191d6e23781SBarry Smith 1192d6e23781SBarry Smith Synopsis: 1193d6e23781SBarry Smith #include <petscmat.h> 1194d6e23781SBarry Smith PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1195bd481603SBarry Smith 1196bd481603SBarry Smith Not Collective 1197bd481603SBarry Smith 1198bd481603SBarry Smith Input Parameters: 1199bd481603SBarry Smith + map - the mapping between local numbering and global numbering 1200bd481603SBarry Smith . nrows - the number of rows indicated 12011d73ed98SBarry Smith . rows - the indices of the rows 1202bd481603SBarry Smith . ncols - the number of columns in the matrix 1203bd481603SBarry Smith . cols - the columns indicated 1204bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1205a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1206bd481603SBarry Smith 12072ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1208bd481603SBarry Smith 1209bd481603SBarry Smith Notes: 12102ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 12112ef1f0ffSBarry Smith the use of this routine 1212bd481603SBarry Smith 12132ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 1214bd481603SBarry Smith 12151cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()` 1216db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSetLocal()` 1217bd481603SBarry Smith M*/ 121894bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetLocalBlock(map, nrows, rows, ncols, cols, dnz, onz) \ 12199371c9d4SSatish Balay PetscMacroReturnStandard(PetscCall(ISLocalToGlobalMappingApplyBlock(map, nrows, rows, rows)); PetscCall(ISLocalToGlobalMappingApplyBlock(map, ncols, cols, cols)); for (PetscInt __l = 0; __l < nrows; __l++) PetscCall(MatPreallocateSymmetricSetBlock((rows)[__l], ncols, cols, dnz, onz));) 1220e83a5d19SLisandro Dalcin 1221bd481603SBarry Smith /*MC 1222bd481603SBarry Smith MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1223bd481603SBarry Smith inserted using a local number of the rows and columns 1224bd481603SBarry Smith 1225bd481603SBarry Smith Synopsis: 1226aaa7dc30SBarry Smith #include <petscmat.h> 1227c1ac3661SBarry Smith PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1228bd481603SBarry Smith 1229bd481603SBarry Smith Not Collective 1230bd481603SBarry Smith 1231bd481603SBarry Smith Input Parameters: 123264075487SBarry Smith + row - the row 1233bd481603SBarry Smith . ncols - the number of columns in the matrix 1234a50f8bf6SHong Zhang - cols - the columns indicated 1235a50f8bf6SHong Zhang 1236a50f8bf6SHong Zhang Output Parameters: 1237a50f8bf6SHong Zhang + dnz - the array that will be passed to the matrix preallocation routines 1238a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1239bd481603SBarry Smith 12402ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1241bd481603SBarry Smith 1242bd481603SBarry Smith Notes: 12432ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 12442ef1f0ffSBarry Smith the use of this routine 1245bd481603SBarry Smith 12462ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 1247bd481603SBarry Smith 1248af27ebaaSBarry Smith This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin(). 12491620fd73SBarry Smith 12501cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1251db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSetLocal()` 1252bd481603SBarry Smith M*/ 12539371c9d4SSatish Balay #define MatPreallocateSet(row, nc, cols, dnz, onz) \ 12549371c9d4SSatish Balay PetscMacroReturnStandard(PetscCheck(row >= __rstart, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Trying to set preallocation for row %" PetscInt_FMT " less than first local row %" PetscInt_FMT, row, __rstart); PetscCheck(row < __rstart + __nrows, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Trying to set preallocation for row %" PetscInt_FMT " greater than last local row %" PetscInt_FMT, row, __rstart + __nrows - 1); for (PetscInt __i = 0; __i < nc; ++__i) { \ 125564075487SBarry Smith if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \ 1256a6042fd4SStefano Zampini else if (dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \ 12579371c9d4SSatish Balay }) 12587c922b88SBarry Smith 1259bd481603SBarry Smith /*MC 1260d6e23781SBarry Smith MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1261bd481603SBarry Smith inserted using a local number of the rows and columns 1262bd481603SBarry Smith 1263bd481603SBarry Smith Synopsis: 1264aaa7dc30SBarry Smith #include <petscmat.h> 1265d6e23781SBarry Smith PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1266bd481603SBarry Smith 1267bd481603SBarry Smith Not Collective 1268bd481603SBarry Smith 1269bd481603SBarry Smith Input Parameters: 1270bd481603SBarry Smith + nrows - the number of rows indicated 12711d73ed98SBarry Smith . rows - the indices of the rows 1272bd481603SBarry Smith . ncols - the number of columns in the matrix 1273bd481603SBarry Smith . cols - the columns indicated 1274bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1275a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1276bd481603SBarry Smith 12772ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1278bd481603SBarry Smith 1279bd481603SBarry Smith Notes: 12802ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 12812ef1f0ffSBarry Smith the use of this routine 1282bd481603SBarry Smith 12832ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 1284bd481603SBarry Smith 1285af27ebaaSBarry Smith This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin(). 12861620fd73SBarry Smith 12871cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateBegin()`, 1288db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()` 1289bd481603SBarry Smith M*/ 129094bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetBlock(row, nc, cols, dnz, onz) \ 12919371c9d4SSatish Balay PetscMacroReturnStandard(for (PetscInt __i = 0; __i < nc; __i++) { \ 1292d3d32019SBarry Smith if (cols[__i] >= __end) onz[row - __rstart]++; \ 1293a6042fd4SStefano Zampini else if (cols[__i] >= row && dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \ 12949371c9d4SSatish Balay }) 1295d3d32019SBarry Smith 1296bd481603SBarry Smith /*MC 1297a6042fd4SStefano Zampini MatPreallocateLocation - An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists 129816371a99SBarry Smith 129916371a99SBarry Smith Synopsis: 1300aaa7dc30SBarry Smith #include <petscmat.h> 130116371a99SBarry Smith PetscErrorCode MatPreallocateLocations(Mat A,PetscInt row,PetscInt ncols,PetscInt *cols,PetscInt *dnz,PetscInt *onz) 130216371a99SBarry Smith 130316371a99SBarry Smith Not Collective 130416371a99SBarry Smith 130516371a99SBarry Smith Input Parameters: 1306a2b725a8SWilliam Gropp + A - matrix 130716371a99SBarry Smith . row - row where values exist (must be local to this process) 130816371a99SBarry Smith . ncols - number of columns 130916371a99SBarry Smith . cols - columns with nonzeros 131016371a99SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1311a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 131216371a99SBarry Smith 13132ef1f0ffSBarry Smith Level: deprecated (since v3.19) 131416371a99SBarry Smith 131516371a99SBarry Smith Notes: 13162ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 13172ef1f0ffSBarry Smith the use of this routine 131816371a99SBarry Smith 13192ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 132016371a99SBarry Smith 1321af27ebaaSBarry Smith Developer Note: 1322af27ebaaSBarry Smith This is a MACRO, not a function, because it uses a bunch of variables private to the MatPreallocation.... routines. 132316371a99SBarry Smith 13241cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1325db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()` 132616371a99SBarry Smith M*/ 1327d0609cedSBarry Smith #define MatPreallocateLocation(A, row, ncols, cols, dnz, onz) (A ? MatSetValues(A, 1, &row, ncols, cols, NULL, INSERT_VALUES) : MatPreallocateSet(row, ncols, cols, dnz, onz)) 132816371a99SBarry Smith 132916371a99SBarry Smith /*MC 1330d0609cedSBarry Smith MatPreallocateEnd - Ends the block of code that will count the number of nonzeros per 1331bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 1332bd481603SBarry Smith 1333bd481603SBarry Smith Synopsis: 1334aaa7dc30SBarry Smith #include <petscmat.h> 1335d0609cedSBarry Smith PetscErrorCode MatPreallocateEnd(PetscInt *dnz, PetscInt *onz) 1336bd481603SBarry Smith 1337d083f849SBarry Smith Collective 1338bd481603SBarry Smith 1339bd481603SBarry Smith Input Parameters: 134016371a99SBarry Smith + dnz - the array that was be passed to the matrix preallocation routines 1341a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1342bd481603SBarry Smith 13432ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1344bd481603SBarry Smith 1345bd481603SBarry Smith Notes: 13462ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 13472ef1f0ffSBarry Smith the use of this routine 1348d0609cedSBarry Smith 13492ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1350bd481603SBarry Smith 13512ef1f0ffSBarry Smith Developer Note: 1352af27ebaaSBarry Smith This is a MACRO, not a function, because it closes the { started in MatPreallocateBegin(). 13531620fd73SBarry Smith 13541cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1355db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()` 1356bd481603SBarry Smith M*/ 13579371c9d4SSatish Balay #define MatPreallocateEnd(dnz, onz) \ 13589371c9d4SSatish Balay PetscCall(PetscFree2(dnz, onz)); \ 13599371c9d4SSatish Balay } \ 13609371c9d4SSatish Balay while (0) 1361d0609cedSBarry Smith 1362edd03b47SJacob Faibussowitsch #define MatPreallocateFinalize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateEnd()", ) MatPreallocateEnd(__VA_ARGS__) 13637c922b88SBarry Smith 13647b80b807SBarry Smith /* Routines unique to particular data structures */ 1365014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat, void *); 1366698d4c6aSKris Buschelman 1367014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat, IS *, IS *); 1368014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat, PetscInt *, PetscInt *[], PetscInt *); 1369698d4c6aSKris Buschelman 1370014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat, PetscInt[]); 1371014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat, PetscInt[]); 1372014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1373014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1374014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1375014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *, PetscInt, PetscBool); 13767b80b807SBarry Smith 1377a96a251dSBarry Smith #define MAT_SKIP_ALLOCATION -4 1378a96a251dSBarry Smith 1379014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1380014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1381014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat, PetscInt, const PetscInt[]); 138219b08ed1SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetTotalPreallocation(Mat, PetscInt); 1383273d9f13SBarry Smith 1384014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1385014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1386014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1387014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]); 1388014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 1389014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]); 1390014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 1391014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat, PetscInt[], PetscInt[], PetscInt[]); 1392b44e7856SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat, Mat *); 1393252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeqRankZero(Mat, Mat *); 1394014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat, PetscScalar[]); 1395014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat, PetscScalar[]); 13969230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat, Mat *, Mat *, const PetscInt *[]); 13979230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat, Mat *, Mat *, const PetscInt *[]); 1398014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat, Mat *); 1399273d9f13SBarry Smith 140049a6ff4bSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat, PetscInt *); 1401ad16ce7aSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseSetLDA(Mat, PetscInt); 1402edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatDenseSetLDA()", ) static inline PetscErrorCode MatSeqDenseSetLDA(Mat A, PetscInt lda) 1403d71ae5a4SJacob Faibussowitsch { 14049371c9d4SSatish Balay return MatDenseSetLDA(A, lda); 14059371c9d4SSatish Balay } 1406014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat, Mat *); 14071b807ce4Svictorle 1408621e819fSSatish Balay PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1409621e819fSSatish Balay 1410014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStoreValues(Mat); 1411014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat); 14122e8a6d31SBarry Smith 1413014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat, IS *); 14147cfe41e4SPatrick Farrell PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat, IS *); 14157b80b807SBarry Smith /* 14167b80b807SBarry Smith These routines are not usually accessed directly, rather solving is 141794b7f48cSBarry Smith done through the KSP and PC interfaces. 14187b80b807SBarry Smith */ 14197b80b807SBarry Smith 142076bdecfbSBarry Smith /*J 14212ef1f0ffSBarry Smith MatOrderingType - String with the name of a PETSc matrix ordering. These orderings are most commonly used 14222ef1f0ffSBarry Smith to reduce fill in sparse factorizations. 1423d9274352SBarry Smith 1424d9274352SBarry Smith Level: beginner 1425d9274352SBarry Smith 14262c7c0729SBarry Smith Notes: 142716a05f60SBarry Smith If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and instead the external factorization solver package called utilizes one 142816a05f60SBarry Smith of its own. 14292c7c0729SBarry Smith 14302ef1f0ffSBarry Smith There is no `MatOrdering` object, the ordering is obtained directly from the matrix with `MatGetOrdering()` 14312ef1f0ffSBarry Smith 14322ef1f0ffSBarry Smith Developer Note: 14332ef1f0ffSBarry Smith This API should be converted to an API similar to those for `MatColoring` and `MatPartitioning` 14342ef1f0ffSBarry Smith 14351cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `MatGetFactor()`, `MatGetOrdering()`, `MatColoringType`, `MatPartitioningType`, `MatCoarsenType`, `MatCoarsenType`, 14362ef1f0ffSBarry Smith `PCFactorSetOrderingType()` 143776bdecfbSBarry Smith J*/ 143819fd82e9SBarry Smith typedef const char *MatOrderingType; 14392692d6eeSBarry Smith #define MATORDERINGNATURAL "natural" 14402692d6eeSBarry Smith #define MATORDERINGND "nd" 14412692d6eeSBarry Smith #define MATORDERING1WD "1wd" 14422692d6eeSBarry Smith #define MATORDERINGRCM "rcm" 14432692d6eeSBarry Smith #define MATORDERINGQMD "qmd" 14442692d6eeSBarry Smith #define MATORDERINGROWLENGTH "rowlength" 1445510184a7SJed Brown #define MATORDERINGWBM "wbm" 1446fc1bef75SJed Brown #define MATORDERINGSPECTRAL "spectral" 1447312e372aSBarry Smith #define MATORDERINGAMD "amd" /* only works if UMFPACK is installed with PETSc */ 1448048412efSPablo Brubeck #define MATORDERINGMETISND "metisnd" /* only works if METIS is installed with PETSc */ 14499bd791bbSBarry Smith #define MATORDERINGNATURAL_OR_ND "natural_or_nd" /* special coase used for Cholesky and ICC, allows ND when AIJ matrix is used but Natural when SBAIJ is used */ 14502c7c0729SBarry Smith #define MATORDERINGEXTERNAL "external" /* uses an ordering type internal to the factorization package */ 1451b12f92e5SBarry Smith 145219fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOrdering(Mat, MatOrderingType, IS *, IS *); 1453140e18c1SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOrderingList(PetscFunctionList *); 1454bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatOrderingRegister(const char[], PetscErrorCode (*)(Mat, MatOrderingType, IS *, IS *)); 1455140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatOrderingList; 1456d4fbbf0eSBarry Smith 1457013e2dc7SBarry Smith #include "petscmatcoarsen.h" 1458013e2dc7SBarry Smith 1459014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat, PetscReal, IS, IS); 1460fc1bef75SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat, PetscReal, PetscBool, Mat *); 1461a2ce50c7SBarry Smith 14624ac6704cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetPreferredOrdering(Mat, MatFactorType, MatOrderingType *); 14634ac6704cSBarry Smith 1464d91e6319SBarry Smith /*S 14652ef1f0ffSBarry Smith MatFactorShiftType - Type of numeric shift used for factorizations 1466d90ac83dSHong Zhang 14672ef1f0ffSBarry Smith Values: 14682ef1f0ffSBarry Smith + `MAT_SHIFT_NONE` - do not shift the matrix diagonal entries 14692ef1f0ffSBarry Smith . `MAT_SHIFT_NONZERO` - shift the entries to be non-zero 14702ef1f0ffSBarry Smith . `MAT_SHIFT_POSITIVE_DEFINITE` - shift the entries to force the factorization to be positive definite 14712ef1f0ffSBarry Smith - `MAT_SHIFT_INBLOCKS` - only shift the factors inside the small dense diagonal blocks of the matrix, for example with `MATBAIJ` 1472d90ac83dSHong Zhang 14732ef1f0ffSBarry Smith Level: intermediate 14742ef1f0ffSBarry Smith 14751cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `PCFactorSetShiftType()` 1476d90ac83dSHong Zhang S*/ 14779371c9d4SSatish Balay typedef enum { 14789371c9d4SSatish Balay MAT_SHIFT_NONE, 14799371c9d4SSatish Balay MAT_SHIFT_NONZERO, 14809371c9d4SSatish Balay MAT_SHIFT_POSITIVE_DEFINITE, 14819371c9d4SSatish Balay MAT_SHIFT_INBLOCKS 14829371c9d4SSatish Balay } MatFactorShiftType; 14836a6fc655SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypes[]; 14845e9742b9SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypesDetail[]; 1485d90ac83dSHong Zhang 1486d90ac83dSHong Zhang /*S 1487ec5066bdSBarry Smith MatFactorError - indicates what type of error was generated in a matrix factorization 14889aa7eafdSHong Zhang 14892ef1f0ffSBarry Smith Values: 14902ef1f0ffSBarry Smith + `MAT_FACTOR_NOERROR` - there was no error during the factorization 14912ef1f0ffSBarry Smith . `MAT_FACTOR_STRUCT_ZEROPIVOT` - there was a missing entry in a diagonal location of the matrix 14922ef1f0ffSBarry Smith . `MAT_FACTOR_NUMERIC_ZEROPIVOT` - there was a (near) zero pivot during the factorization 14932ef1f0ffSBarry Smith . `MAT_FACTOR_OUTMEMORY` - the factorization has run out of memory 14942ef1f0ffSBarry Smith - `MAT_FACTOR_OTHER` - some other error has occurred. 14959aa7eafdSHong Zhang 14962ef1f0ffSBarry Smith Level: intermediate 149700e125f8SBarry Smith 14982ef1f0ffSBarry Smith Note: 14992ef1f0ffSBarry Smith When a factorization is done in a preconditioner `PC` the error may be propagated up to a `PCFailedReason` or a `KSPConvergedReason` 15002ef1f0ffSBarry Smith 15011cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `MatFactorGetError()`, `MatFactorGetErrorZeroPivot()`, `MatFactorClearError()`, 15022ef1f0ffSBarry Smith `PCFailedReason`, `PCGetFailedReason()`, `KSPConvergedReason` 15039aa7eafdSHong Zhang S*/ 15049371c9d4SSatish Balay typedef enum { 15059371c9d4SSatish Balay MAT_FACTOR_NOERROR, 15069371c9d4SSatish Balay MAT_FACTOR_STRUCT_ZEROPIVOT, 15079371c9d4SSatish Balay MAT_FACTOR_NUMERIC_ZEROPIVOT, 15089371c9d4SSatish Balay MAT_FACTOR_OUTMEMORY, 15099371c9d4SSatish Balay MAT_FACTOR_OTHER 15109371c9d4SSatish Balay } MatFactorError; 15119aa7eafdSHong Zhang 151200e125f8SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat, MatFactorError *); 1513b8b68cfdSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat); 15147b6c816cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat, PetscReal *, PetscInt *); 151500e125f8SBarry Smith 15169aa7eafdSHong Zhang /*S 1517422a814eSBarry Smith MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization 1518b00f7748SHong Zhang 1519b00f7748SHong Zhang Level: developer 1520b00f7748SHong Zhang 15212ef1f0ffSBarry Smith Note: 15222ef1f0ffSBarry Smith You can use `MatFactorInfoInitialize()` to set default values. 1523b00f7748SHong Zhang 15242ef1f0ffSBarry Smith Fortran Note: 15252ef1f0ffSBarry Smith The data is available in a double precision arrays of size `MAT_FACTORINFO_SIZE` 15262ef1f0ffSBarry Smith 15271cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatInfo`, `MatGetFactor()`, `MatLUFactorSymbolic()`, `MatILUFactorSymbolic()`, `MatCholeskyFactorSymbolic()`, 15282ef1f0ffSBarry Smith `MatICCFactorSymbolic()`, `MatICCFactor()`, `MatFactorInfoInitialize()` 1529b00f7748SHong Zhang S*/ 1530b00f7748SHong Zhang typedef struct { 153115e8a5b3SHong Zhang PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 153285317021SBarry Smith PetscReal usedt; 153315e8a5b3SHong Zhang PetscReal dt; /* drop tolerance */ 1534b00f7748SHong Zhang PetscReal dtcol; /* tolerance for pivoting */ 153515e8a5b3SHong Zhang PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 153667e28bfeSBarry Smith PetscReal fill; /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */ 1537348344bbSBarry Smith PetscReal levels; /* ICC/ILU(levels) */ 1538bcd9e38bSBarry Smith PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 1539bcd9e38bSBarry Smith factorization may be faster if do not pivot */ 154015e8a5b3SHong Zhang PetscReal zeropivot; /* pivot is called zero if less than this */ 1541f4db908eSBarry Smith PetscReal shifttype; /* type of shift added to matrix factor to prevent zero pivots */ 1542f4db908eSBarry Smith PetscReal shiftamount; /* how large the shift is */ 154315e8a5b3SHong Zhang } MatFactorInfo; 1544ffa6d0a5SLois Curfman McInnes 1545014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo *); 15469a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat, IS, const MatFactorInfo *); 15479a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 15489a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat, Mat, const MatFactorInfo *); 15499a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactor(Mat, IS, IS, const MatFactorInfo *); 15509a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactor(Mat, IS, IS, const MatFactorInfo *); 15519a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *); 15529a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *); 15539a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 15549a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactor(Mat, IS, const MatFactorInfo *); 15559a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat, Mat, const MatFactorInfo *); 15563f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactor(Mat, IS, const MatFactorInfo *); 15573f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 15583f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorNumeric(Mat, Mat, const MatFactorInfo *); 1559014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInertia(Mat, PetscInt *, PetscInt *, PetscInt *); 1560014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolve(Mat, Vec, Vec); 1561014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat, Vec, Vec); 1562014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat, Vec, Vec); 1563014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat, Vec, Vec, Vec); 1564014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat, Vec, Vec); 1565014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat, Vec, Vec, Vec); 1566014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolves(Mat, Vecs, Vecs); 15677c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat); 15687c2f51b8SStefano Zampini 15699371c9d4SSatish Balay typedef enum { 15709371c9d4SSatish Balay MAT_FACTOR_SCHUR_UNFACTORED, 15719371c9d4SSatish Balay MAT_FACTOR_SCHUR_FACTORED, 15729371c9d4SSatish Balay MAT_FACTOR_SCHUR_INVERTED 15739371c9d4SSatish Balay } MatFactorSchurStatus; 15748e7ba810SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat, IS); 15757c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat, Mat *, MatFactorSchurStatus *); 15767c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat, Mat *, MatFactorSchurStatus); 15775a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat); 15787c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat, Mat *, MatFactorSchurStatus *); 15795a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat, Vec, Vec); 15805a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat, Vec, Vec); 15816dba178dSStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat); 1582bb5a7306SBarry Smith 15838a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqDenseInvert(Mat); 1584d91e6319SBarry Smith /*E 1585d91e6319SBarry Smith MatSORType - What type of (S)SOR to perform 1586bb1eb677SSatish Balay 15872ef1f0ffSBarry Smith Values: 15882ef1f0ffSBarry Smith + `SOR_FORWARD_SWEEP` - do a sweep from the first row of the matrix to the last 15892ef1f0ffSBarry Smith . `SOR_BACKWARD_SWEEP` - do a sweep from the last row to the first 15902ef1f0ffSBarry Smith . `SOR_SYMMETRIC_SWEEP` - do a sweep from the first row to the last and then back to the first 1591af27ebaaSBarry Smith . `SOR_LOCAL_FORWARD_SWEEP` - each MPI process does its own forward sweep with no communication 1592af27ebaaSBarry Smith . `SOR_LOCAL_BACKWARD_SWEEP` - each MPI process does its own backward sweep with no communication 1593af27ebaaSBarry Smith . `SOR_LOCAL_SYMMETRIC_SWEEP` - each MPI process does its own symmetric sweep with no communication 15942ef1f0ffSBarry Smith . `SOR_ZERO_INITIAL_GUESS` - indicates the initial solution is zero so the sweep can avoid unneeded computation 15952ef1f0ffSBarry Smith . `SOR_EISENSTAT` - apply the Eisentat application of SOR, see `PCEISENSTAT` 15962ef1f0ffSBarry Smith . `SOR_APPLY_UPPER` - multiply by the upper triangular portion of the matrix 15972ef1f0ffSBarry Smith - `SOR_APPLY_LOWER` - multiply by the lower triangular portion of the matrix 15982ef1f0ffSBarry Smith 1599d91e6319SBarry Smith Level: beginner 1600d91e6319SBarry Smith 16012ef1f0ffSBarry Smith Note: 16022ef1f0ffSBarry Smith These may be bitwise ORd together 1603d9274352SBarry Smith 16042ef1f0ffSBarry Smith Developer Note: 16052ef1f0ffSBarry Smith Since `MatSORType` may be bitwise ORd together, so do not change the numerical values below 1606d91e6319SBarry Smith 16071cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSOR()` 1608d91e6319SBarry Smith E*/ 16099371c9d4SSatish Balay typedef enum { 16109371c9d4SSatish Balay SOR_FORWARD_SWEEP = 1, 16119371c9d4SSatish Balay SOR_BACKWARD_SWEEP = 2, 16129371c9d4SSatish Balay SOR_SYMMETRIC_SWEEP = 3, 16139371c9d4SSatish Balay SOR_LOCAL_FORWARD_SWEEP = 4, 16149371c9d4SSatish Balay SOR_LOCAL_BACKWARD_SWEEP = 8, 16159371c9d4SSatish Balay SOR_LOCAL_SYMMETRIC_SWEEP = 12, 16169371c9d4SSatish Balay SOR_ZERO_INITIAL_GUESS = 16, 16179371c9d4SSatish Balay SOR_EISENSTAT = 32, 16189371c9d4SSatish Balay SOR_APPLY_UPPER = 64, 16199371c9d4SSatish Balay SOR_APPLY_LOWER = 128 16209371c9d4SSatish Balay } MatSORType; 1621014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSOR(Mat, Vec, PetscReal, MatSORType, PetscReal, PetscInt, PetscInt, Vec); 16228ed539a5SBarry Smith 16237086a01eSPeter Brune /*S 16247086a01eSPeter Brune MatColoring - Object for managing the coloring of matrices. 16257086a01eSPeter Brune 16267086a01eSPeter Brune Level: beginner 16277086a01eSPeter Brune 1628ec5066bdSBarry Smith Notes: 162987497f52SBarry Smith Coloring of matrices can be computed directly from the sparse matrix nonzero structure via the `MatColoring` object or from the mesh from which the 163087497f52SBarry Smith matrix comes from via `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors). 1631ec5066bdSBarry Smith 163287497f52SBarry Smith Once a coloring is available `MatFDColoringCreate()` creates an object that can be used to efficiently compute Jacobians using that coloring. This 16332ef1f0ffSBarry Smith same object can also be used to efficiently convert data created by Automatic Differentiation tools to PETSc sparse matrices. 1634ec5066bdSBarry Smith 16351cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `MatFDColoringCreate()`, `MatColoringWeightType`, `ISColoring`, `MatFDColoring`, `DMCreateColoring()`, `MatColoringCreate()`, 16362ef1f0ffSBarry Smith `MatPartitioning`, `MatColoringType`, `MatPartitioningType`, `MatOrderingType`, `MatColoringSetWeightType()`, 16372ef1f0ffSBarry Smith `MatColoringSetWeights()`, `MatCoarsenType`, `MatCoarsen` 16387086a01eSPeter Brune S*/ 1639d4db15c4SBarry Smith typedef struct _p_MatColoring *MatColoring; 1640d4db15c4SBarry Smith 1641d4db15c4SBarry Smith /*J 1642d4db15c4SBarry Smith MatColoringType - String with the name of a PETSc matrix coloring 1643d9274352SBarry Smith 1644d9274352SBarry Smith Level: beginner 1645d9274352SBarry Smith 16461cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatFDColoringCreate()`, `MatColoringSetType()`, `MatColoring` 164776bdecfbSBarry Smith J*/ 164819fd82e9SBarry Smith typedef const char *MatColoringType; 16495567d71aSPeter Brune #define MATCOLORINGJP "jp" 1650b9acb617SPeter Brune #define MATCOLORINGPOWER "power" 16512692d6eeSBarry Smith #define MATCOLORINGNATURAL "natural" 16522692d6eeSBarry Smith #define MATCOLORINGSL "sl" 16532692d6eeSBarry Smith #define MATCOLORINGLF "lf" 16542692d6eeSBarry Smith #define MATCOLORINGID "id" 16558121bdceSPeter Brune #define MATCOLORINGGREEDY "greedy" 1656b12f92e5SBarry Smith 16578ac6da0aSPeter Brune /*E 16582ef1f0ffSBarry Smith MatColoringWeightType - Type of weight scheme used for the coloring algorithm 16598ac6da0aSPeter Brune 16602ef1f0ffSBarry Smith Values: 166187497f52SBarry Smith + `MAT_COLORING_RANDOM` - Random weights 166287497f52SBarry Smith . `MAT_COLORING_LEXICAL` - Lexical weighting based upon global numbering. 166387497f52SBarry Smith - `MAT_COLORING_LF` - Last-first weighting. 16648ac6da0aSPeter Brune 16658ac6da0aSPeter Brune Level: intermediate 16668ac6da0aSPeter Brune 16671cc06b55SBarry Smith .seealso: [](ch_matrices), `MatColoring`, `MatColoringCreate()`, `MatColoringSetWeightType()`, `MatColoringSetWeights()` 16688ac6da0aSPeter Brune E*/ 16699371c9d4SSatish Balay typedef enum { 16709371c9d4SSatish Balay MAT_COLORING_WEIGHT_RANDOM, 16719371c9d4SSatish Balay MAT_COLORING_WEIGHT_LEXICAL, 16729371c9d4SSatish Balay MAT_COLORING_WEIGHT_LF, 16739371c9d4SSatish Balay MAT_COLORING_WEIGHT_SL 16749371c9d4SSatish Balay } MatColoringWeightType; 16758ac6da0aSPeter Brune 1676335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat, MatColoring *); 1677d7f2a307SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat, PetscInt, PetscInt *); 1678335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring *); 1679335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring, PetscViewer); 1680335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring, MatColoringType); 1681335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring); 1682335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring, PetscInt); 1683335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring, PetscInt *); 1684335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring, PetscInt); 1685335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring, PetscInt *); 1686335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring, ISColoring *); 1687335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[], PetscErrorCode (*)(MatColoring)); 1688014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat, PetscInt, PetscInt, ISColoringValue[], ISColoring *); 16898ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring, MatColoringWeightType); 1690c29971fcSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring, PetscReal *, PetscInt *); 16918ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring, PetscReal **, PetscInt **lperm); 1692bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring, ISColoring); 1693edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 10, 0, "MatColoringTest()", ) static inline PetscErrorCode MatColoringTestValid(MatColoring matcoloring, ISColoring iscoloring) 1694d71ae5a4SJacob Faibussowitsch { 16959371c9d4SSatish Balay return MatColoringTest(matcoloring, iscoloring); 16969371c9d4SSatish Balay } 1697bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat, ISColoring); 1698639f9d9dSBarry Smith 1699d9274352SBarry Smith /*S 170087497f52SBarry Smith MatFDColoring - Object for computing a sparse Jacobian via finite differences with coloring 1701639f9d9dSBarry Smith 1702d9274352SBarry Smith Level: beginner 1703d9274352SBarry Smith 1704ec5066bdSBarry Smith Notes: 170587497f52SBarry Smith This object is creating utilizing a coloring provided by the `MatColoring` object or `DMCreateColoring()` 1706ec5066bdSBarry Smith 17072ef1f0ffSBarry Smith The `SNES` option `-snes_fd_coloring` will cause the Jacobian needed by `SNES` to be computed via a use of this object 17082ef1f0ffSBarry Smith 17091cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatFDColoringCreate()`, `MatFDColoringSetFunction()`, `MatColoring`, `DMCreateColoring()` 1710d9274352SBarry Smith S*/ 1711e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring; 1712639f9d9dSBarry Smith 1713014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat, ISColoring, MatFDColoring *); 1714014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring *); 1715014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring, PetscViewer); 1716014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring, PetscErrorCode (*)(void), void *); 1717014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring, PetscErrorCode (**)(void), void **); 1718014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring, PetscReal, PetscReal); 1719014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring); 1720d1e9a80fSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat, MatFDColoring, Vec, void *); 1721014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring, Vec); 1722edaa7c33SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring, PetscInt *, const PetscInt *[]); 1723f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat, ISColoring, MatFDColoring); 1724f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring, PetscInt, PetscInt); 1725bdaf1daeSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat, MatFDColoring, const PetscScalar *); 1726b1683b59SHong Zhang 1727b1683b59SHong Zhang /*S 1728af27ebaaSBarry Smith MatTransposeColoring - Object for computing a sparse matrix product $C = A*B^T$ via coloring 1729b1683b59SHong Zhang 17302ef1f0ffSBarry Smith Level: developer 1731b1683b59SHong Zhang 17321cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatProductType`, `MatTransposeColoringCreate()` 1733b1683b59SHong Zhang S*/ 1734b9af6bddSHong Zhang typedef struct _p_MatTransposeColoring *MatTransposeColoring; 1735b1683b59SHong Zhang 1736014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat, ISColoring, MatTransposeColoring *); 1737014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring, Mat, Mat); 1738014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring, Mat, Mat); 1739014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring *); 1740b1683b59SHong Zhang 1741d9274352SBarry Smith /*S 1742d9274352SBarry Smith MatPartitioning - Object for managing the partitioning of a matrix or graph 1743d9274352SBarry Smith 1744d9274352SBarry Smith Level: beginner 1745d9274352SBarry Smith 174687497f52SBarry Smith Note: 174787497f52SBarry Smith There is also a `PetscPartitioner` object that provides the same functionality. It can utilize the `MatPartitioning` operations 174887497f52SBarry Smith via `PetscPartitionerSetType`(p,`PETSCPARTITIONERMATPARTITIONING`) 1749ec5066bdSBarry Smith 1750b5e6e808SPierre Jolivet Developer Note: 17512ef1f0ffSBarry Smith It is an extra maintenance and documentation cost to have two objects with the same functionality. `PetscPartitioner` should be removed 1752ec5066bdSBarry Smith 17531cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioningType`, `MatColoring`, `MatGetOrdering()`, `MatOrderingType`, 17542ef1f0ffSBarry Smith `MatCoarsenType`, `MatCoarsenType` 1755d9274352SBarry Smith S*/ 175691e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning; 1757d9274352SBarry Smith 175876bdecfbSBarry Smith /*J 17598f6c3df8SBarry Smith MatPartitioningType - String with the name of a PETSc matrix partitioning 1760d9274352SBarry Smith 1761d9274352SBarry Smith Level: beginner 17620d04baf8SBarry Smith dm 17631cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioning`, `MatPartitioningSetType()`, `MatColoringType`, `MatOrderingType`, 17642ef1f0ffSBarry Smith `MatCoarsenType`, `MatCoarsenType` 176576bdecfbSBarry Smith J*/ 176619fd82e9SBarry Smith typedef const char *MatPartitioningType; 17672692d6eeSBarry Smith #define MATPARTITIONINGCURRENT "current" 1768aa1e27eaSFande Kong #define MATPARTITIONINGAVERAGE "average" 17692692d6eeSBarry Smith #define MATPARTITIONINGSQUARE "square" 17702692d6eeSBarry Smith #define MATPARTITIONINGPARMETIS "parmetis" 17712692d6eeSBarry Smith #define MATPARTITIONINGCHACO "chaco" 17722692d6eeSBarry Smith #define MATPARTITIONINGPARTY "party" 177350d91057SBarry Smith #define MATPARTITIONINGPTSCOTCH "ptscotch" 177488d2ac2bSFande Kong #define MATPARTITIONINGHIERARCH "hierarch" 177571306c60Sjroman 1776014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm, MatPartitioning *); 177719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning, MatPartitioningType); 1778014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning, PetscInt); 1779014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning, Mat); 1780252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetNumberVertexWeights(MatPartitioning, PetscInt); 1781014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning, const PetscInt[]); 1782014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning, const PetscReal[]); 1783ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningSetUseEdgeWeights(MatPartitioning, PetscBool); 1784ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningGetUseEdgeWeights(MatPartitioning, PetscBool *); 1785014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning, IS *); 1786fdd1c351SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning, IS *); 1787668144dbSFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning, IS); 1788f3ad2dabSStefano Zampini PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning, IS *); 1789014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning *); 1790bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[], PetscErrorCode (*)(MatPartitioning)); 1791014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning, PetscViewer); 1792fe2efc57SMark PETSC_EXTERN PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning, PetscObject, const char[]); 1793014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning); 179419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning, MatPartitioningType *); 1795ca161407SBarry Smith 179627538973SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning part); 1797014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 1798014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *); 17990752156aSBarry Smith 18009371c9d4SSatish Balay typedef enum { 18019371c9d4SSatish Balay MP_CHACO_MULTILEVEL = 1, 18029371c9d4SSatish Balay MP_CHACO_SPECTRAL = 2, 18039371c9d4SSatish Balay MP_CHACO_LINEAR = 4, 18049371c9d4SSatish Balay MP_CHACO_RANDOM = 5, 18059371c9d4SSatish Balay MP_CHACO_SCATTERED = 6 18069371c9d4SSatish Balay } MPChacoGlobalType; 18076a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoGlobalTypes[]; 18089371c9d4SSatish Balay typedef enum { 18099371c9d4SSatish Balay MP_CHACO_KERNIGHAN = 1, 18109371c9d4SSatish Balay MP_CHACO_NONE = 2 18119371c9d4SSatish Balay } MPChacoLocalType; 18126a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoLocalTypes[]; 18139371c9d4SSatish Balay typedef enum { 18149371c9d4SSatish Balay MP_CHACO_LANCZOS = 0, 18159371c9d4SSatish Balay MP_CHACO_RQI = 1 18169371c9d4SSatish Balay } MPChacoEigenType; 18176a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoEigenTypes[]; 1818b6956c12SJose Roman 1819014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType); 1820014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning, MPChacoGlobalType *); 1821014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType); 1822014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning, MPChacoLocalType *); 1823014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning, PetscReal); 1824014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning, MPChacoEigenType); 1825014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning, MPChacoEigenType *); 1826014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal); 1827014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning, PetscReal *); 1828014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt); 1829014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning, PetscInt *); 183071306c60Sjroman 183171306c60Sjroman #define MP_PARTY_OPT "opt" 183271306c60Sjroman #define MP_PARTY_LIN "lin" 183371306c60Sjroman #define MP_PARTY_SCA "sca" 183471306c60Sjroman #define MP_PARTY_RAN "ran" 183571306c60Sjroman #define MP_PARTY_GBF "gbf" 183671306c60Sjroman #define MP_PARTY_GCF "gcf" 183771306c60Sjroman #define MP_PARTY_BUB "bub" 183871306c60Sjroman #define MP_PARTY_DEF "def" 1839014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char *); 184071306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs" 184171306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl" 184271306c60Sjroman #define MP_PARTY_NONE "no" 1843014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char *); 1844014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning, PetscReal); 1845014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning, PetscBool); 1846014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning, PetscBool); 184771306c60Sjroman 18489371c9d4SSatish Balay typedef enum { 18499371c9d4SSatish Balay MP_PTSCOTCH_DEFAULT, 18509371c9d4SSatish Balay MP_PTSCOTCH_QUALITY, 18519371c9d4SSatish Balay MP_PTSCOTCH_SPEED, 18529371c9d4SSatish Balay MP_PTSCOTCH_BALANCE, 18539371c9d4SSatish Balay MP_PTSCOTCH_SAFETY, 18549371c9d4SSatish Balay MP_PTSCOTCH_SCALABILITY 18559371c9d4SSatish Balay } MPPTScotchStrategyType; 18566a6fc655SJed Brown PETSC_EXTERN const char *const MPPTScotchStrategyTypes[]; 1857e0f1cffaSJose Roman 1858014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning, PetscReal); 1859014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning, PetscReal *); 1860014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning, MPPTScotchStrategyType); 1861014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning, MPPTScotchStrategyType *); 186271306c60Sjroman 1863b43b03e9SMark F. Adams /* 18646294fa2bSFande Kong * hierarchical partitioning 18656294fa2bSFande Kong */ 18664e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning, IS *); 18674e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning, IS *); 18684e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning, PetscInt); 18694e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt); 18706294fa2bSFande Kong 1871014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat, PetscInt, Mat *); 1872591294e4SBarry Smith 18730752156aSBarry Smith /* 1874c786d857SStefano Zampini If you add entries here you must also add them to src/mat/f90-mod/petscmat.h 1875c786d857SStefano Zampini If any of the enum values are changed, also update dMatOps dict at src/binding/petsc4py/src/libpetsc4py/libpetsc4py.pyx 1876d4fbbf0eSBarry Smith */ 18779371c9d4SSatish Balay typedef enum { 18789371c9d4SSatish Balay MATOP_SET_VALUES = 0, 18791c1c02c0SLois Curfman McInnes MATOP_GET_ROW = 1, 18801c1c02c0SLois Curfman McInnes MATOP_RESTORE_ROW = 2, 18811c1c02c0SLois Curfman McInnes MATOP_MULT = 3, 18821c1c02c0SLois Curfman McInnes MATOP_MULT_ADD = 4, 18837c922b88SBarry Smith MATOP_MULT_TRANSPOSE = 5, 18847c922b88SBarry Smith MATOP_MULT_TRANSPOSE_ADD = 6, 18851c1c02c0SLois Curfman McInnes MATOP_SOLVE = 7, 18861c1c02c0SLois Curfman McInnes MATOP_SOLVE_ADD = 8, 18877c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE = 9, 18887c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE_ADD = 10, 18891c1c02c0SLois Curfman McInnes MATOP_LUFACTOR = 11, 18901c1c02c0SLois Curfman McInnes MATOP_CHOLESKYFACTOR = 12, 1891a714c06dSBarry Smith MATOP_SOR = 13, 18921c1c02c0SLois Curfman McInnes MATOP_TRANSPOSE = 14, 18931c1c02c0SLois Curfman McInnes MATOP_GETINFO = 15, 18941c1c02c0SLois Curfman McInnes MATOP_EQUAL = 16, 18951c1c02c0SLois Curfman McInnes MATOP_GET_DIAGONAL = 17, 18961c1c02c0SLois Curfman McInnes MATOP_DIAGONAL_SCALE = 18, 18971c1c02c0SLois Curfman McInnes MATOP_NORM = 19, 18981c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_BEGIN = 20, 18991c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_END = 21, 1900d519adbfSMatthew Knepley MATOP_SET_OPTION = 22, 1901d519adbfSMatthew Knepley MATOP_ZERO_ENTRIES = 23, 1902d519adbfSMatthew Knepley MATOP_ZERO_ROWS = 24, 1903d519adbfSMatthew Knepley MATOP_LUFACTOR_SYMBOLIC = 25, 1904d519adbfSMatthew Knepley MATOP_LUFACTOR_NUMERIC = 26, 1905d519adbfSMatthew Knepley MATOP_CHOLESKY_FACTOR_SYMBOLIC = 27, 1906d519adbfSMatthew Knepley MATOP_CHOLESKY_FACTOR_NUMERIC = 28, 1907e5f2d425SStefano Zampini MATOP_SETUP = 29, 1908d519adbfSMatthew Knepley MATOP_ILUFACTOR_SYMBOLIC = 30, 1909d519adbfSMatthew Knepley MATOP_ICCFACTOR_SYMBOLIC = 31, 1910a5b7ff6bSBarry Smith MATOP_GET_DIAGONAL_BLOCK = 32, 1911e5f2d425SStefano Zampini MATOP_SET_INF = 33, 1912d519adbfSMatthew Knepley MATOP_DUPLICATE = 34, 1913d519adbfSMatthew Knepley MATOP_FORWARD_SOLVE = 35, 1914d519adbfSMatthew Knepley MATOP_BACKWARD_SOLVE = 36, 1915d519adbfSMatthew Knepley MATOP_ILUFACTOR = 37, 1916d519adbfSMatthew Knepley MATOP_ICCFACTOR = 38, 1917d519adbfSMatthew Knepley MATOP_AXPY = 39, 19187dae84e0SHong Zhang MATOP_CREATE_SUBMATRICES = 40, 1919d519adbfSMatthew Knepley MATOP_INCREASE_OVERLAP = 41, 1920d519adbfSMatthew Knepley MATOP_GET_VALUES = 42, 1921d519adbfSMatthew Knepley MATOP_COPY = 43, 1922d519adbfSMatthew Knepley MATOP_GET_ROW_MAX = 44, 1923d519adbfSMatthew Knepley MATOP_SCALE = 45, 1924d519adbfSMatthew Knepley MATOP_SHIFT = 46, 192535153367SBarry Smith MATOP_DIAGONAL_SET = 47, 19269d39f69dSJed Brown MATOP_ZERO_ROWS_COLUMNS = 48, 19279d39f69dSJed Brown MATOP_SET_RANDOM = 49, 1928d519adbfSMatthew Knepley MATOP_GET_ROW_IJ = 50, 1929d519adbfSMatthew Knepley MATOP_RESTORE_ROW_IJ = 51, 1930d519adbfSMatthew Knepley MATOP_GET_COLUMN_IJ = 52, 1931d519adbfSMatthew Knepley MATOP_RESTORE_COLUMN_IJ = 53, 1932d519adbfSMatthew Knepley MATOP_FDCOLORING_CREATE = 54, 1933d519adbfSMatthew Knepley MATOP_COLORING_PATCH = 55, 1934d519adbfSMatthew Knepley MATOP_SET_UNFACTORED = 56, 1935d519adbfSMatthew Knepley MATOP_PERMUTE = 57, 1936d519adbfSMatthew Knepley MATOP_SET_VALUES_BLOCKED = 58, 19377dae84e0SHong Zhang MATOP_CREATE_SUBMATRIX = 59, 1938d519adbfSMatthew Knepley MATOP_DESTROY = 60, 1939d519adbfSMatthew Knepley MATOP_VIEW = 61, 1940d519adbfSMatthew Knepley MATOP_CONVERT_FROM = 62, 1941e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_63=63 */ 19427bab7c10SHong Zhang MATOP_MATMAT_MULT_SYMBOLIC = 64, 19437bab7c10SHong Zhang MATOP_MATMAT_MULT_NUMERIC = 65, 1944d519adbfSMatthew Knepley MATOP_SET_LOCAL_TO_GLOBAL_MAP = 66, 1945d519adbfSMatthew Knepley MATOP_SET_VALUES_LOCAL = 67, 1946d519adbfSMatthew Knepley MATOP_ZERO_ROWS_LOCAL = 68, 1947d519adbfSMatthew Knepley MATOP_GET_ROW_MAX_ABS = 69, 1948d519adbfSMatthew Knepley MATOP_GET_ROW_MIN_ABS = 70, 1949d519adbfSMatthew Knepley MATOP_CONVERT = 71, 1950e5f2d425SStefano Zampini MATOP_HAS_OPERATION = 72, 19519d39f69dSJed Brown /* MATOP_PLACEHOLDER_73=73, */ 1952d519adbfSMatthew Knepley MATOP_SET_VALUES_ADIFOR = 74, 1953d519adbfSMatthew Knepley MATOP_FD_COLORING_APPLY = 75, 1954d519adbfSMatthew Knepley MATOP_SET_FROM_OPTIONS = 76, 1955e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_77=77, */ 1956e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_78=78, */ 19579d39f69dSJed Brown MATOP_FIND_ZERO_DIAGONALS = 79, 1958d519adbfSMatthew Knepley MATOP_MULT_MULTIPLE = 80, 1959d519adbfSMatthew Knepley MATOP_SOLVE_MULTIPLE = 81, 1960d519adbfSMatthew Knepley MATOP_GET_INERTIA = 82, 1961d519adbfSMatthew Knepley MATOP_LOAD = 83, 1962d519adbfSMatthew Knepley MATOP_IS_SYMMETRIC = 84, 1963d519adbfSMatthew Knepley MATOP_IS_HERMITIAN = 85, 1964d519adbfSMatthew Knepley MATOP_IS_STRUCTURALLY_SYMMETRIC = 86, 1965820469bcSHong Zhang MATOP_SET_VALUES_BLOCKEDLOCAL = 87, 1966b41ce5d5SBarry Smith MATOP_CREATE_VECS = 88, 1967e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_89=89, */ 1968d519adbfSMatthew Knepley MATOP_MAT_MULT_SYMBOLIC = 90, 1969d519adbfSMatthew Knepley MATOP_MAT_MULT_NUMERIC = 91, 1970e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_92=92, */ 1971d519adbfSMatthew Knepley MATOP_PTAP_SYMBOLIC = 93, 1972d519adbfSMatthew Knepley MATOP_PTAP_NUMERIC = 94, 1973e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_95=95, */ 1974bda6c4cbSBarry Smith MATOP_MAT_TRANSPOSE_MULT_SYMBO = 96, 1975bda6c4cbSBarry Smith MATOP_MAT_TRANSPOSE_MULT_NUMER = 97, 1976e5f2d425SStefano Zampini MATOP_BIND_TO_CPU = 98, 19777a3c3d58SStefano Zampini MATOP_PRODUCTSETFROMOPTIONS = 99, 19787a3c3d58SStefano Zampini MATOP_PRODUCTSYMBOLIC = 100, 19797a3c3d58SStefano Zampini MATOP_PRODUCTNUMERIC = 101, 1980d519adbfSMatthew Knepley MATOP_CONJUGATE = 102, 1981e5f2d425SStefano Zampini MATOP_VIEW_NATIVE = 103, 1982d519adbfSMatthew Knepley MATOP_SET_VALUES_ROW = 104, 1983d519adbfSMatthew Knepley MATOP_REAL_PART = 105, 1984bda6c4cbSBarry Smith MATOP_IMAGINARY_PART = 106, 1985bda6c4cbSBarry Smith MATOP_GET_ROW_UPPER_TRIANGULAR = 107, 1986bda6c4cbSBarry Smith MATOP_RESTORE_ROW_UPPER_TRIANG = 108, 1987bda6c4cbSBarry Smith MATOP_MAT_SOLVE = 109, 198829eadf9eSStefano Zampini MATOP_MAT_SOLVE_TRANSPOSE = 110, 1989d519adbfSMatthew Knepley MATOP_GET_ROW_MIN = 111, 19900e8d04f7SBarry Smith MATOP_GET_COLUMN_VECTOR = 112, 1991d519adbfSMatthew Knepley MATOP_MISSING_DIAGONAL = 113, 19920e8d04f7SBarry Smith MATOP_GET_SEQ_NONZERO_STRUCTUR = 114, 199389c6957cSBarry Smith MATOP_CREATE = 115, 199489c6957cSBarry Smith MATOP_GET_GHOSTS = 116, 19950e8d04f7SBarry Smith MATOP_GET_LOCAL_SUB_MATRIX = 117, 19960e8d04f7SBarry Smith MATOP_RESTORE_LOCALSUB_MATRIX = 118, 1997eeffb40dSHong Zhang MATOP_MULT_DIAGONAL_BLOCK = 119, 19980e8d04f7SBarry Smith MATOP_HERMITIAN_TRANSPOSE = 120, 19990e8d04f7SBarry Smith MATOP_MULT_HERMITIAN_TRANSPOSE = 121, 20000e8d04f7SBarry Smith MATOP_MULT_HERMITIAN_TRANS_ADD = 122, 20010e8d04f7SBarry Smith MATOP_GET_MULTI_PROC_BLOCK = 123, 20029d39f69dSJed Brown MATOP_FIND_NONZERO_ROWS = 124, 20030e8d04f7SBarry Smith MATOP_GET_COLUMN_NORMS = 125, 20049d39f69dSJed Brown MATOP_INVERT_BLOCK_DIAGONAL = 126, 2005e5f2d425SStefano Zampini MATOP_INVERT_VBLOCK_DIAGONAL = 127, 2006b41ce5d5SBarry Smith MATOP_CREATE_SUB_MATRICES_MPI = 128, 20072b8ad9a3SHong Zhang MATOP_SET_VALUES_BATCH = 129, 2008e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_130=130, */ 20090e8d04f7SBarry Smith MATOP_TRANSPOSE_MAT_MULT_SYMBO = 131, 2010e9b602ebSSatish Balay MATOP_TRANSPOSE_MAT_MULT_NUMER = 132, 20110e8d04f7SBarry Smith MATOP_TRANSPOSE_COLORING_CREAT = 133, 20120e8d04f7SBarry Smith MATOP_TRANS_COLORING_APPLY_SPT = 134, 20130e8d04f7SBarry Smith MATOP_TRANS_COLORING_APPLY_DEN = 135, 2014e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_136=136, */ 20150e8d04f7SBarry Smith MATOP_RART_SYMBOLIC = 137, 20160e8d04f7SBarry Smith MATOP_RART_NUMERIC = 138, 2017e09a3074SHong Zhang MATOP_SET_BLOCK_SIZES = 139, 2018f9426fe0SMark Adams MATOP_AYPX = 140, 20191919a2e2SJed Brown MATOP_RESIDUAL = 141, 20209c8f2541SHong Zhang MATOP_FDCOLORING_SETUP = 142, 2021e5f2d425SStefano Zampini MATOP_FIND_OFFBLOCK_ENTRIES = 143, 20222d033e1fSHong Zhang MATOP_MPICONCATENATESEQ = 144, 2023bb01b7b0SPatrick Sanan MATOP_DESTROYSUBMATRICES = 145, 2024e265f6d6SPatrick Sanan MATOP_TRANSPOSE_SOLVE = 146, 2025e265f6d6SPatrick Sanan MATOP_GET_VALUES_LOCAL = 147 2026fae171e0SBarry Smith } MatOperation; 20270c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOperation(Mat, MatOperation, void (*)(void)); 2028976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatGetOperation(Mat, MatOperation, void (**)(void)); 2029976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatHasOperation(Mat, MatOperation, PetscBool *); 203094342113SStefano Zampini PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat, PetscBool *); 2031edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatProductClear()", ) static inline PetscErrorCode MatFreeIntermediateDataStructures(Mat A) 2032d71ae5a4SJacob Faibussowitsch { 20339371c9d4SSatish Balay return MatProductClear(A); 20349371c9d4SSatish Balay } 2035014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat, MatOperation, void (*)(void)); 2036014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat, MatOperation, void (**)(void)); 2037014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat, void *); 2038800f99ffSJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetContextDestroy(Mat, PetscErrorCode (*)(void *)); 2039db77db73SJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetVecType(Mat, VecType); 2040f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *); 2041f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *); 20420c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat); 2043b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatShellSetMatProductOperation(Mat, MatProductType, PetscErrorCode (*)(Mat, Mat, Mat, void **), PetscErrorCode (*)(Mat, Mat, Mat, void *), PetscErrorCode (*)(void *), MatType, MatType); 2044b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatIsShell(Mat, PetscBool *); 2045112a2221SBarry Smith 204690ace30eSBarry Smith /* 204790ace30eSBarry Smith Codes for matrices stored on disk. By default they are 204890ace30eSBarry Smith stored in a universal format. By changing the format with 20496a9046bcSBarry Smith PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will 205090ace30eSBarry Smith be stored in a way natural for the matrix, for example dense matrices 205190ace30eSBarry Smith would be stored as dense. Matrices stored this way may only be 2052f4403165SShri Abhyankar read into matrices of the same type. 205390ace30eSBarry Smith */ 205490ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1 205590ace30eSBarry Smith 2056014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat, PetscReal); 205775d48cdbSStefano Zampini 20588546b261SStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat, MatType); 205975d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 20604f58015eSStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetAllowRepeated(Mat, PetscBool); 20614f58015eSStefano Zampini PETSC_EXTERN PetscErrorCode MatISGetAllowRepeated(Mat, PetscBool *); 206275d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat, PetscBool); 2063f03112d0SStefano Zampini PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat, PetscBool); 2064014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat, Mat *); 20653b3b1effSJed Brown PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat, Mat *); 2066014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat, Mat); 2067e432b41dSStefano Zampini PETSC_EXTERN PetscErrorCode MatISGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *); 20681f4e1ec7SBarry Smith 2069d9274352SBarry Smith /*S 2070d9274352SBarry Smith MatNullSpace - Object that removes a null space from a vector, i.e. 2071cb6b9846SMatthew Knepley orthogonalizes the vector to a subspace 2072d9274352SBarry Smith 2073f7a9e4ceSBarry Smith Level: advanced 2074d9274352SBarry Smith 20751cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()` 2076d9274352SBarry Smith S*/ 207774637425SBarry Smith typedef struct _p_MatNullSpace *MatNullSpace; 2078d9274352SBarry Smith 2079014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm, PetscBool, PetscInt, const Vec[], MatNullSpace *); 2080014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace, PetscErrorCode (*)(MatNullSpace, Vec, void *), void *); 2081014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace *); 2082d0195637SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace, Vec); 2083014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *); 20845fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *); 20855fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat, MatNullSpace); 2086014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat, MatNullSpace); 2087014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat, MatNullSpace); 2088014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat, MatNullSpace *); 20894849c82aSBarry Smith PETSC_EXTERN PetscErrorCode MatGetNullSpaces(PetscInt, Mat[], MatNullSpace *[]); 20904849c82aSBarry Smith PETSC_EXTERN PetscErrorCode MatRestoreNullSpaces(PetscInt, Mat[], MatNullSpace *[]); 2091014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace, Mat, PetscBool *); 2092014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace, PetscViewer); 2093014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace, PetscBool *, PetscInt *, const Vec **); 2094014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec, MatNullSpace *); 209574637425SBarry Smith 2096014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat, IS); 2097014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat, PetscReal); 2098014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat, PetscInt *); 20993f1d51d7SBarry Smith 2100014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat, PetscInt, Mat *); 2101014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat, PetscInt, Mat *); 2102014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat, Mat *); 2103c4f061fbSSatish Balay 21040bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat, MatType, Mat *); 21050bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat, MatType, Mat *); 21060bacdadaSStefano Zampini 2107edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperator()", ) static inline PetscErrorCode MatComputeExplicitOperator(Mat A, Mat *B) 2108d71ae5a4SJacob Faibussowitsch { 2109f22e26b7SPierre Jolivet return MatComputeOperator(A, PETSC_NULLPTR, B); 21109371c9d4SSatish Balay } 2111edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperatorTranspose()", ) static inline PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A, Mat *B) 2112d71ae5a4SJacob Faibussowitsch { 2113f22e26b7SPierre Jolivet return MatComputeOperatorTranspose(A, PETSC_NULLPTR, B); 21149371c9d4SSatish Balay } 2115b0a32e0cSBarry Smith 211649bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat, PetscInt, PetscInt, const PetscScalar[], const PetscScalar[], Mat *); 211749bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat, Mat *); 2118a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat, PetscInt *, PetscInt *, PetscScalar **); 2119a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat, PetscInt *, PetscInt *, const PetscScalar **); 2120a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat, PetscScalar **); 2121a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat, const PetscScalar **); 2122a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat, PetscInt *, PetscInt *, PetscScalar **); 2123a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat, PetscInt *, PetscInt *, const PetscScalar **); 2124a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat, PetscScalar **); 2125a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat, const PetscScalar **); 2126dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat, Mat); 2127dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat, PetscInt, PetscInt, const PetscScalar[]); 2128dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat, PetscInt, PetscInt, const PetscScalar[]); 2129910cf402Sprj- PETSC_EXTERN PetscErrorCode MatKAIJGetScaledIdentity(Mat, PetscBool *); 213049bd79ccSDebojyoti Ghosh 2131014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat, Vec); 213204f1ad80SBarry Smith 21334bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMFFDInitializePackage(void); 21344bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMFFDFinalizePackage(void); 21354bf303faSJacob Faibussowitsch 2136014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 2137014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat, Vec, Vec); 2138014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat, PetscErrorCode (*)(void *, Vec, Vec), void *); 2139014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat, PetscErrorCode (*)(void *, PetscInt, Vec, PetscScalar *)); 2140014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat, PetscErrorCode (*)(void *, Vec)); 2141014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat, PetscScalar[], PetscInt); 2142014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat); 2143014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat, PetscReal); 2144014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat, PetscInt); 2145014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat, PetscScalar *); 2146014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat, const char[]); 2147014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void *, Vec, Vec, PetscScalar *); 2148014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat, PetscErrorCode (*)(void *, Vec, Vec, PetscScalar *), void *); 2149e884886fSBarry Smith 21506370053bSBarry Smith /*S 21516370053bSBarry Smith MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free 21526370053bSBarry Smith Jacobian vector products 2153e884886fSBarry Smith 21542ef1f0ffSBarry Smith Level: developer 21552ef1f0ffSBarry Smith 215695452b02SPatrick Sanan Notes: 215787497f52SBarry Smith `MATMFFD` is a specific `MatType` which uses the `MatMFFD` data structure 21586370053bSBarry Smith 21592ef1f0ffSBarry Smith MatMFFD*() methods actually take the `Mat` as their first argument. Not a `MatMFFD` data structure 21606370053bSBarry Smith 21612ef1f0ffSBarry Smith This functionality is often obtained using `MatCreateSNESMF()` or with `SNES` solvers using `-snes_mf` or `-snes_mf_operator` 21626370053bSBarry Smith 21631cc06b55SBarry Smith .seealso: [](ch_matrices), `MatMFFDType`, `MATMFFD`, `MatCreateMFFD()`, `MatMFFDSetFuction()`, `MatMFFDSetType()`, `MatMFFDRegister()`, 21642ef1f0ffSBarry Smith `MatCreateSNESMF()`, `SNES`, `-snes_mf`, `-snes_mf_operator` 21656370053bSBarry Smith S*/ 2166e884886fSBarry Smith typedef struct _p_MatMFFD *MatMFFD; 2167e884886fSBarry Smith 216876bdecfbSBarry Smith /*J 21692ef1f0ffSBarry Smith MatMFFDType - algorithm used to compute the `h` used in computing matrix-vector products via differencing of a function 2170e884886fSBarry Smith 217116a05f60SBarry Smith Values: 2172af27ebaaSBarry Smith + `MATMFFD_DS` - an algorithm described by Dennis and Schnabel {cite}`dennis:83` 2173af27ebaaSBarry Smith - `MATMFFD_WP` - the Walker-Pernice {cite}`pw98` strategy. 217416a05f60SBarry Smith 2175e884886fSBarry Smith Level: beginner 2176e884886fSBarry Smith 21771cc06b55SBarry Smith .seealso: [](ch_matrices), `MatMFFDSetType()`, `MatMFFDRegister()`, `MatMFFDSetFunction()`, `MatCreateMFFD()` 217876bdecfbSBarry Smith J*/ 217919fd82e9SBarry Smith typedef const char *MatMFFDType; 2180e884886fSBarry Smith #define MATMFFD_DS "ds" 2181e884886fSBarry Smith #define MATMFFD_WP "wp" 2182e884886fSBarry Smith 218319fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat, MatMFFDType); 2184bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[], PetscErrorCode (*)(MatMFFD)); 2185e884886fSBarry Smith 2186014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat, PetscReal); 2187014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat, PetscBool); 2188e884886fSBarry Smith 218961ab5df0SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring, MatMFFDType); 219061ab5df0SBarry Smith 2191014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *); 2192014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *); 21937dbadf16SMatthew Knepley 219453022affSStefano Zampini #ifdef PETSC_HAVE_H2OPUS 21958434afd1SBarry Smith PETSC_EXTERN_TYPEDEF typedef PetscScalar(MatH2OpusKernelFn)(PetscInt, PetscReal[], PetscReal[], void *); 21968434afd1SBarry Smith PETSC_EXTERN_TYPEDEF typedef MatH2OpusKernelFn *MatH2OpusKernel; 21978434afd1SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], PetscBool, MatH2OpusKernelFn *, void *, PetscReal, PetscInt, PetscInt, Mat *); 219853022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromMat(Mat, PetscInt, const PetscReal[], PetscBool, PetscReal, PetscInt, PetscInt, PetscInt, PetscReal, Mat *); 219953022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetSamplingMat(Mat, Mat, PetscInt, PetscReal); 220053022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusOrthogonalize(Mat); 220153022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusCompress(Mat, PetscReal); 220253022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetNativeMult(Mat, PetscBool); 220353022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetNativeMult(Mat, PetscBool *); 220453022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetIndexMap(Mat, IS *); 220553022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusMapVec(Mat, PetscBool, Vec, Vec *); 2206300d917bSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusLowRankUpdate(Mat, Mat, Mat, PetscScalar); 2207a0d2e7d8SStefano Zampini #endif 2208a0d2e7d8SStefano Zampini 2209c7a4214aSPierre Jolivet #ifdef PETSC_HAVE_HTOOL 22108434afd1SBarry Smith PETSC_EXTERN_TYPEDEF typedef PetscErrorCode(MatHtoolKernelFn)(PetscInt, PetscInt, PetscInt, const PetscInt *, const PetscInt *, PetscScalar *, void *); 22118434afd1SBarry Smith PETSC_EXTERN_TYPEDEF typedef MatHtoolKernelFn *MatHtoolKernel; 22128434afd1SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateHtoolFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], const PetscReal[], MatHtoolKernelFn *, void *, Mat *); 22138434afd1SBarry Smith PETSC_EXTERN PetscErrorCode MatHtoolSetKernel(Mat, MatHtoolKernelFn *, void *); 221498e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationSource(Mat, IS *); 221598e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationTarget(Mat, IS *); 221698e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolUsePermutation(Mat, PetscBool); 22172ef1f0ffSBarry Smith 2218c7a4214aSPierre Jolivet /*E 221987497f52SBarry Smith MatHtoolCompressorType - Indicates the type of compressor used by a `MATHTOOL` 2220c7a4214aSPierre Jolivet 2221c7a4214aSPierre Jolivet Values: 222287497f52SBarry Smith + `MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA` (default) - symmetric partial adaptive cross approximation 222387497f52SBarry Smith . `MAT_HTOOL_COMPRESSOR_FULL_ACA` - full adaptive cross approximation 222487497f52SBarry Smith - `MAT_HTOOL_COMPRESSOR_SVD` - singular value decomposition 2225c7a4214aSPierre Jolivet 222616a05f60SBarry Smith Level: intermediate 222716a05f60SBarry Smith 22281cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolClusteringType` 2229c7a4214aSPierre Jolivet E*/ 22309371c9d4SSatish Balay typedef enum { 22319371c9d4SSatish Balay MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA, 22329371c9d4SSatish Balay MAT_HTOOL_COMPRESSOR_FULL_ACA, 22339371c9d4SSatish Balay MAT_HTOOL_COMPRESSOR_SVD 22349371c9d4SSatish Balay } MatHtoolCompressorType; 22352ef1f0ffSBarry Smith 223698e73e17SPierre Jolivet /*E 223787497f52SBarry Smith MatHtoolClusteringType - Indicates the type of clustering used by a `MATHTOOL` 223898e73e17SPierre Jolivet 223998e73e17SPierre Jolivet Values: 224087497f52SBarry Smith + `MAT_HTOOL_CLUSTERING_PCA_REGULAR` (default) - axis computed via principle component analysis, split uniformly 224187497f52SBarry Smith . `MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC` - axis computed via principle component analysis, split barycentrically 224287497f52SBarry Smith . `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR` - axis along the largest extent of the bounding box, split uniformly 224387497f52SBarry Smith - `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC` - axis along the largest extent of the bounding box, split barycentrically 224498e73e17SPierre Jolivet 224516a05f60SBarry Smith Level: intermediate 224616a05f60SBarry Smith 22472ef1f0ffSBarry Smith Note: 22482ef1f0ffSBarry Smith Higher-dimensional clustering is not yet supported in Htool, but once it is, one should add BOUNDING_BOX_{2,3} types 224998e73e17SPierre Jolivet 22501cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolCompressorType` 225198e73e17SPierre Jolivet E*/ 22529371c9d4SSatish Balay typedef enum { 22539371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_PCA_REGULAR, 22549371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC, 22559371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR, 22569371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC 22579371c9d4SSatish Balay } MatHtoolClusteringType; 2258c7a4214aSPierre Jolivet #endif 2259c7a4214aSPierre Jolivet 226097969023SHong Zhang #ifdef PETSC_HAVE_MUMPS 2261014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat, PetscInt, PetscInt); 2262bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat, PetscInt, PetscInt *); 2263b9e9ea26SSatish Balay PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat, PetscInt, PetscReal); 2264bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat, PetscInt, PetscReal *); 2265bc6112feSHong Zhang 2266ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat, PetscInt, PetscInt *); 2267ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat, PetscInt, PetscInt *); 2268ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat, PetscInt, PetscReal *); 2269ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat, PetscInt, PetscReal *); 22705c0bae8cSAshish Patel PETSC_EXTERN PetscErrorCode MatMumpsGetNullPivots(Mat, PetscInt *, PetscInt **); 227189a9c03aSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat, Mat); 22720e6b8875SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat, Mat); 227397969023SHong Zhang #endif 227423a5497aSJed Brown 2275b500a6b7SJose David Bermeol #ifdef PETSC_HAVE_MKL_PARDISO 2276d615f992SSatish Balay PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat, PetscInt, PetscInt); 2277b500a6b7SJose David Bermeol #endif 2278b500a6b7SJose David Bermeol 2279d305a81bSVasiliy Kozyrev #ifdef PETSC_HAVE_MKL_CPARDISO 2280d305a81bSVasiliy Kozyrev PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat, PetscInt, PetscInt); 2281d305a81bSVasiliy Kozyrev #endif 2282d305a81bSVasiliy Kozyrev 2283d954db57SHong Zhang #ifdef PETSC_HAVE_SUPERLU 2284014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat, PetscReal); 2285d954db57SHong Zhang #endif 2286d954db57SHong Zhang 2287fb785984SHong Zhang #ifdef PETSC_HAVE_SUPERLU_DIST 2288fb785984SHong Zhang PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat, PetscScalar *); 2289fb785984SHong Zhang #endif 2290fb785984SHong Zhang 2291575704cbSPieter Ghysels #ifdef PETSC_HAVE_STRUMPACK 2292542aee0fSPieter Ghysels /*E 229329e0a805SPieter Ghysels MatSTRUMPACKReordering - sparsity reducing ordering to be used in `MATSOLVERSTRUMPACK` 2294542aee0fSPieter Ghysels 22952ef1f0ffSBarry Smith Values: 22962ef1f0ffSBarry Smith + `MAT_STRUMPACK_NATURAL` - use the current ordering 22972ef1f0ffSBarry Smith . `MAT_STRUMPACK_METIS` - use MeTis to compute an ordering 22982ef1f0ffSBarry Smith . `MAT_STRUMPACK_PARMETIS` - use ParMeTis to compute an ordering 22992ef1f0ffSBarry Smith . `MAT_STRUMPACK_SCOTCH` - use Scotch to compute an ordering 23002ef1f0ffSBarry Smith . `MAT_STRUMPACK_PTSCOTCH` - use parallel Scotch to compute an ordering 230129e0a805SPieter Ghysels . `MAT_STRUMPACK_RCM` - use an RCM ordering 230229e0a805SPieter Ghysels . `MAT_STRUMPACK_GEOMETRIC` - use a geometric ordering (needs mesh info from user) 230329e0a805SPieter Ghysels . `MAT_STRUMPACK_AMD` - approximate minimum degree 230429e0a805SPieter Ghysels . `MAT_STRUMPACK_MMD` - multiple minimum degree 230529e0a805SPieter Ghysels . `MAT_STRUMPACK_AND` - approximate nested dissection 230629e0a805SPieter Ghysels . `MAT_STRUMPACK_MLF` - minimum local fill 230729e0a805SPieter Ghysels - `MAT_STRUMPACK_SPECTRAL` - spectral nested dissection 23082ef1f0ffSBarry Smith 230916a05f60SBarry Smith Level: intermediate 231016a05f60SBarry Smith 23112ef1f0ffSBarry Smith Developer Note: 23122ef1f0ffSBarry Smith Should be called `MatSTRUMPACKReorderingType` 23132ef1f0ffSBarry Smith 231429e0a805SPieter Ghysels .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetReordering()` 2315542aee0fSPieter Ghysels E*/ 23169371c9d4SSatish Balay typedef enum { 231729e0a805SPieter Ghysels MAT_STRUMPACK_NATURAL, 231829e0a805SPieter Ghysels MAT_STRUMPACK_METIS, 231929e0a805SPieter Ghysels MAT_STRUMPACK_PARMETIS, 232029e0a805SPieter Ghysels MAT_STRUMPACK_SCOTCH, 232129e0a805SPieter Ghysels MAT_STRUMPACK_PTSCOTCH, 232229e0a805SPieter Ghysels MAT_STRUMPACK_RCM, 232329e0a805SPieter Ghysels MAT_STRUMPACK_GEOMETRIC, 232429e0a805SPieter Ghysels MAT_STRUMPACK_AMD, 232529e0a805SPieter Ghysels MAT_STRUMPACK_MMD, 232629e0a805SPieter Ghysels MAT_STRUMPACK_AND, 232729e0a805SPieter Ghysels MAT_STRUMPACK_MLF, 232829e0a805SPieter Ghysels MAT_STRUMPACK_SPECTRAL 23299371c9d4SSatish Balay } MatSTRUMPACKReordering; 23302ef1f0ffSBarry Smith 233134f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat, MatSTRUMPACKReordering); 233229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetReordering(Mat, MatSTRUMPACKReordering *); 233329e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricNxyz(Mat, PetscInt, PetscInt, PetscInt); 233429e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricComponents(Mat, PetscInt); 233529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricWidth(Mat, PetscInt); 2336575704cbSPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat, PetscBool); 233729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetColPerm(Mat, PetscBool *); 233829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGPU(Mat, PetscBool); 233929e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetGPU(Mat, PetscBool *); 234029e0a805SPieter Ghysels 234129e0a805SPieter Ghysels /*E 234229e0a805SPieter Ghysels MatSTRUMPACKCompressionType - Compression used in the approximate sparse factorization solver `MATSOLVERSTRUMPACK` 234329e0a805SPieter Ghysels 234429e0a805SPieter Ghysels Values: 234529e0a805SPieter Ghysels + `MAT_STRUMPACK_COMPRESSION_TYPE_NONE` - no compression, direct solver 234629e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_HSS` - hierarchically semi-separable 234729e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_BLR` - block low rank 234829e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_HODLR` - hierarchically off-diagonal low rank (requires ButterfyPACK support, configure with --download-butterflypack) 234929e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR` - hybrid of BLR and HODLR (requires ButterfyPACK support, configure with --download-butterflypack) 235029e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_ZFP_BLR_HODLR` - hybrid of lossy (ZFP), BLR and HODLR (requires ButterfyPACK and ZFP support, configure with --download-butterflypack --download-zfp) 235129e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS` - lossless compression (requires ZFP support, configure with --download-zfp) 235229e0a805SPieter Ghysels - `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY` - lossy compression (requires ZFP support, configure with --download-zfp) 235329e0a805SPieter Ghysels 235429e0a805SPieter Ghysels Level: intermediate 235529e0a805SPieter Ghysels 235629e0a805SPieter Ghysels .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetCompression()` 235729e0a805SPieter Ghysels E*/ 235829e0a805SPieter Ghysels typedef enum { 235929e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_NONE, 236029e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_HSS, 236129e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_BLR, 236229e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_HODLR, 236329e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR, 236429e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_ZFP_BLR_HODLR, 236529e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS, 236629e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY 236729e0a805SPieter Ghysels } MatSTRUMPACKCompressionType; 236829e0a805SPieter Ghysels 236929e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompression(Mat, MatSTRUMPACKCompressionType); 237029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompression(Mat, MatSTRUMPACKCompressionType *); 237129e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompRelTol(Mat, PetscReal); 237229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompRelTol(Mat, PetscReal *); 237329e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompAbsTol(Mat, PetscReal); 237429e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompAbsTol(Mat, PetscReal *); 237529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompMinSepSize(Mat, PetscInt); 237629e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompMinSepSize(Mat, PetscInt *); 237729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLeafSize(Mat, PetscInt); 237829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLeafSize(Mat, PetscInt *); 237929e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLossyPrecision(Mat, PetscInt); 238029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLossyPrecision(Mat, PetscInt *); 238129e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompButterflyLevels(Mat, PetscInt); 238229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompButterflyLevels(Mat, PetscInt *); 2383575704cbSPieter Ghysels #endif 2384575704cbSPieter Ghysels 2385b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatBindToCPU(Mat, PetscBool); 23862216c58aSStefano Zampini PETSC_EXTERN PetscErrorCode MatBoundToCPU(Mat, PetscBool *); 2387edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 13, 0, "MatBindToCPU()", ) static inline PetscErrorCode MatPinToCPU(Mat A, PetscBool flg) 2388d71ae5a4SJacob Faibussowitsch { 23899371c9d4SSatish Balay return MatBindToCPU(A, flg); 23909371c9d4SSatish Balay } 239165a9ecf2SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatSetBindingPropagates(Mat, PetscBool); 2392e9c74fd6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetBindingPropagates(Mat, PetscBool *); 2393e7e92044SBarry Smith 2394aa372e3fSPaul Mullowney #ifdef PETSC_HAVE_CUDA 23953f9c0db1SPaul Mullowney /*E 23962ef1f0ffSBarry Smith MatCUSPARSEStorageFormat - indicates the storage format for `MATAIJCUSPARSE` (GPU) 23972692e278SPaul Mullowney matrices. 2398e057df02SPaul Mullowney 23992ef1f0ffSBarry Smith Values: 240087497f52SBarry Smith + `MAT_CUSPARSE_CSR` - Compressed Sparse Row 240187497f52SBarry Smith . `MAT_CUSPARSE_ELL` - Ellpack (requires CUDA 4.2 or later). 240287497f52SBarry Smith - `MAT_CUSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later). 2403e057df02SPaul Mullowney 2404e057df02SPaul Mullowney Level: intermediate 2405e057df02SPaul Mullowney 24061cc06b55SBarry Smith .seealso: [](ch_matrices), `MATAIJCUSPARSE`, `MatCUSPARSESetFormat()`, `MatCUSPARSEFormatOperation` 2407e057df02SPaul Mullowney E*/ 2408e057df02SPaul Mullowney 24099371c9d4SSatish Balay typedef enum { 24109371c9d4SSatish Balay MAT_CUSPARSE_CSR, 24119371c9d4SSatish Balay MAT_CUSPARSE_ELL, 24129371c9d4SSatish Balay MAT_CUSPARSE_HYB 24139371c9d4SSatish Balay } MatCUSPARSEStorageFormat; 2414e057df02SPaul Mullowney 2415e057df02SPaul Mullowney /* these will be strings associated with enumerated type defined above */ 2416e057df02SPaul Mullowney PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[]; 2417e057df02SPaul Mullowney 24183f9c0db1SPaul Mullowney /*E 24192ef1f0ffSBarry Smith MatCUSPARSEFormatOperation - indicates the operation of `MATAIJCUSPARSE` (GPU) 24202692e278SPaul Mullowney matrices whose operation should use a particular storage format. 2421e057df02SPaul Mullowney 24222ef1f0ffSBarry Smith Values: 24234cf0e950SBarry Smith + `MAT_CUSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()` 24244cf0e950SBarry Smith . `MAT_CUSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()` 24254cf0e950SBarry Smith . `MAT_CUSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()` 24262ef1f0ffSBarry Smith - `MAT_CUSPARSE_ALL` - sets the storage format for all `MATAIJCUSPARSE` (GPU) matrices 2427e057df02SPaul Mullowney 2428e057df02SPaul Mullowney Level: intermediate 2429e057df02SPaul Mullowney 24301cc06b55SBarry Smith .seealso: [](ch_matrices), `MatCUSPARSESetFormat()`, `MatCUSPARSEStorageFormat` 2431e057df02SPaul Mullowney E*/ 24329371c9d4SSatish Balay typedef enum { 24339371c9d4SSatish Balay MAT_CUSPARSE_MULT_DIAG, 24349371c9d4SSatish Balay MAT_CUSPARSE_MULT_OFFDIAG, 24359371c9d4SSatish Balay MAT_CUSPARSE_MULT, 24369371c9d4SSatish Balay MAT_CUSPARSE_ALL 24379371c9d4SSatish Balay } MatCUSPARSEFormatOperation; 2438e057df02SPaul Mullowney 243910e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 244010e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 2441e057df02SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat, MatCUSPARSEFormatOperation, MatCUSPARSEStorageFormat); 2442365b711fSMark Adams PETSC_EXTERN PetscErrorCode MatCUSPARSESetUseCPUSolve(Mat, PetscBool); 24435f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetIJ(Mat, PetscBool, const int **, const int **); 24445f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreIJ(Mat, PetscBool, const int **, const int **); 24455f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayRead(Mat, const PetscScalar **); 24465f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayRead(Mat, const PetscScalar **); 24475f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayWrite(Mat, PetscScalar **); 24485f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayWrite(Mat, PetscScalar **); 24495f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArray(Mat, PetscScalar **); 24505f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArray(Mat, PetscScalar **); 2451637a0070SStefano Zampini 2452637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 2453637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 2454637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayWrite(Mat, PetscScalar **); 2455637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayRead(Mat, const PetscScalar **); 2456637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArray(Mat, PetscScalar **); 2457637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayWrite(Mat, PetscScalar **); 2458637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayRead(Mat, const PetscScalar **); 2459637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArray(Mat, PetscScalar **); 2460637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAPlaceArray(Mat, const PetscScalar *); 2461d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAReplaceArray(Mat, const PetscScalar *); 2462637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAResetArray(Mat); 24633d9668e3SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatDenseCUDASetPreallocation(Mat, PetscScalar *); 24642d1451d4SHong Zhang 24652d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 24662d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 24679ae82921SPaul Mullowney #endif 24689ae82921SPaul Mullowney 246947d993e7Ssuyashtn #ifdef PETSC_HAVE_HIP 247047d993e7Ssuyashtn /*E 24712ef1f0ffSBarry Smith MatHIPSPARSEStorageFormat - indicates the storage format for `MATAIJHIPSPARSE` (GPU) 247247d993e7Ssuyashtn matrices. 247347d993e7Ssuyashtn 24742ef1f0ffSBarry Smith Values: 24752ef1f0ffSBarry Smith + `MAT_HIPSPARSE_CSR` - Compressed Sparse Row 24762ef1f0ffSBarry Smith . `MAT_HIPSPARSE_ELL` - Ellpack 24772ef1f0ffSBarry Smith - `MAT_HIPSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format 247847d993e7Ssuyashtn 247916a05f60SBarry Smith Level: intermediate 248016a05f60SBarry Smith 24811cc06b55SBarry Smith .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEFormatOperation` 248247d993e7Ssuyashtn E*/ 248347d993e7Ssuyashtn 248447d993e7Ssuyashtn typedef enum { 248547d993e7Ssuyashtn MAT_HIPSPARSE_CSR, 248647d993e7Ssuyashtn MAT_HIPSPARSE_ELL, 248747d993e7Ssuyashtn MAT_HIPSPARSE_HYB 248847d993e7Ssuyashtn } MatHIPSPARSEStorageFormat; 248947d993e7Ssuyashtn 249047d993e7Ssuyashtn /* these will be strings associated with enumerated type defined above */ 249147d993e7Ssuyashtn PETSC_EXTERN const char *const MatHIPSPARSEStorageFormats[]; 249247d993e7Ssuyashtn 249347d993e7Ssuyashtn /*E 24942ef1f0ffSBarry Smith MatHIPSPARSEFormatOperation - indicates the operation of `MATAIJHIPSPARSE` (GPU) 249547d993e7Ssuyashtn matrices whose operation should use a particular storage format. 249647d993e7Ssuyashtn 24972ef1f0ffSBarry Smith Values: 24982ef1f0ffSBarry Smith + `MAT_HIPSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()` 24994cf0e950SBarry Smith . `MAT_HIPSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()` 25002ef1f0ffSBarry Smith . `MAT_HIPSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()` 25012ef1f0ffSBarry Smith - `MAT_HIPSPARSE_ALL` - sets the storage format for all HIPSPARSE (GPU) matrices 25022ef1f0ffSBarry Smith 250316a05f60SBarry Smith Level: intermediate 250416a05f60SBarry Smith 25051cc06b55SBarry Smith .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEStorageFormat` 250647d993e7Ssuyashtn E*/ 250747d993e7Ssuyashtn typedef enum { 250847d993e7Ssuyashtn MAT_HIPSPARSE_MULT_DIAG, 250947d993e7Ssuyashtn MAT_HIPSPARSE_MULT_OFFDIAG, 251047d993e7Ssuyashtn MAT_HIPSPARSE_MULT, 251147d993e7Ssuyashtn MAT_HIPSPARSE_ALL 251247d993e7Ssuyashtn } MatHIPSPARSEFormatOperation; 251347d993e7Ssuyashtn 251447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 251547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 251647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetFormat(Mat, MatHIPSPARSEFormatOperation, MatHIPSPARSEStorageFormat); 251747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetUseCPUSolve(Mat, PetscBool); 251847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetIJ(Mat, PetscBool, const int **, const int **); 251947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreIJ(Mat, PetscBool, const int **, const int **); 252047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayRead(Mat, const PetscScalar **); 252147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayRead(Mat, const PetscScalar **); 252247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayWrite(Mat, PetscScalar **); 252347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayWrite(Mat, PetscScalar **); 252447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArray(Mat, PetscScalar **); 252547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArray(Mat, PetscScalar **); 252647d993e7Ssuyashtn 252747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 252847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 252947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayWrite(Mat, PetscScalar **); 253047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayRead(Mat, const PetscScalar **); 253147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArray(Mat, PetscScalar **); 253247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayWrite(Mat, PetscScalar **); 253347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayRead(Mat, const PetscScalar **); 253447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArray(Mat, PetscScalar **); 253547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPPlaceArray(Mat, const PetscScalar *); 253647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPReplaceArray(Mat, const PetscScalar *); 253747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPResetArray(Mat); 25383d9668e3SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatDenseHIPSetPreallocation(Mat, PetscScalar *); 2539*773bf0f6SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELLHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 2540*773bf0f6SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELLHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 254147d993e7Ssuyashtn #endif 254247d993e7Ssuyashtn 2543d67ff14aSKarl Rupp #if defined(PETSC_HAVE_VIENNACL) 2544d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 2545d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 2546d67ff14aSKarl Rupp #endif 2547d67ff14aSKarl Rupp 25484bf303faSJacob Faibussowitsch #if PetscDefined(HAVE_KOKKOS) 25494bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 25504bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 25514bf303faSJacob Faibussowitsch #endif 25524bf303faSJacob Faibussowitsch 255354efbe56SHong Zhang #if defined(PETSC_HAVE_FFTW) 2554014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat, Vec, Vec); 2555014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat, Vec, Vec); 25562a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat, Vec *, Vec *, Vec *); 255754efbe56SHong Zhang #endif 255854efbe56SHong Zhang 2559d24d4204SJose E. Roman #if defined(PETSC_HAVE_SCALAPACK) 2560d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateScaLAPACK(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 2561d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKSetBlockSizes(Mat, PetscInt, PetscInt); 2562d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKGetBlockSizes(Mat, PetscInt *, PetscInt *); 2563d24d4204SJose E. Roman #endif 2564d24d4204SJose E. Roman 2565014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm, PetscInt, const IS[], PetscInt, const IS[], const Mat[], Mat *); 2566014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat, PetscInt *, PetscInt *); 2567014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat, IS[], IS[]); 2568014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat, IS[], IS[]); 2569014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat, PetscInt *, PetscInt *, Mat ***); 2570014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat, PetscInt, PetscInt, Mat *); 257119fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat, VecType); 2572014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat, PetscInt, const IS[], PetscInt, const IS[], const Mat[]); 2573014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat, PetscInt, PetscInt, Mat); 2574d8588912SDave May 25752ce66baaSPierre Jolivet PETSC_EXTERN PetscErrorCode MatFilter(Mat, PetscReal, PetscBool, PetscBool); 25762ce66baaSPierre Jolivet PETSC_DEPRECATED_FUNCTION(3, 20, 0, "MatFilter()", ) static inline PetscErrorCode MatChop(Mat A, PetscReal tol) 25772ce66baaSPierre Jolivet { 25782ce66baaSPierre Jolivet return MatFilter(A, tol, PETSC_FALSE, PETSC_FALSE); 25792ce66baaSPierre Jolivet } 2580e0a58c10SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat, PetscReal, PetscInt *); 25814325cce7SMatthew G Knepley 2582b541e6a4SDmitry Karpeev PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat, PetscInt, PetscInt *, IS **); 258353dd7562SDmitry Karpeev 2584c094ef40SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat, PetscBool, Mat); 2585c094ef40SMatthew G. Knepley 258602218ef1SBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderMerge(Mat, Mat *); 2587539c167fSBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat, Mat *); 25881a2c6b5cSJunchao Zhang 25897ee59b9bSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetCSRAndMemType(Mat, const PetscInt **, const PetscInt **, PetscScalar **, PetscMemType *); 259072833a62Smarkadams4 2591e02fb3cdSMark Adams PETSC_EXTERN PetscErrorCode MatCreateGraph(Mat, PetscBool, PetscBool, PetscReal, PetscInt, PetscInt[], Mat *); 259258c11ad4SPierre Jolivet PETSC_EXTERN PetscErrorCode MatEliminateZeros(Mat, PetscBool); 2593ad6ad4e1SHansol Suh 2594d16ceb75SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseFromVecType(MPI_Comm, VecType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar *, Mat *); 25953444e80cSBarry Smith 25963444e80cSBarry Smith PETSC_EXTERN PetscErrorCode MatSetHPL(Mat, int); 25973444e80cSBarry Smith #define PETSCBMHPL "hpl" 2598