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 128f6c3df8SBarry Smith an explicit sparse representation (such as matrix-free operators) 132eac72dbSBarry Smith 14d91e6319SBarry Smith Level: beginner 15d91e6319SBarry Smith 162ef1f0ffSBarry Smith Note: 171cc06b55SBarry Smith See [](doc_matrix), [](ch_matrices) and `MatType` for available matrix types 182ef1f0ffSBarry Smith 191cc06b55SBarry Smith .seealso: [](doc_matrix), [](ch_matrices), `MatCreate()`, `MatType`, `MatSetType()`, `MatDestroy()` 20d9274352SBarry Smith S*/ 21d9274352SBarry Smith typedef struct _p_Mat *Mat; 22d9274352SBarry Smith 2376bdecfbSBarry Smith /*J 248f6c3df8SBarry Smith MatType - String with the name of a PETSc matrix type 25d9274352SBarry Smith 26d9274352SBarry Smith Level: beginner 27d9274352SBarry Smith 282ef1f0ffSBarry Smith Note: 292ef1f0ffSBarry Smith [](doc_matrix) for a table of available matrix types 302ef1f0ffSBarry Smith 311cc06b55SBarry Smith .seealso: [](doc_matrix), [](ch_matrices), `MatSetType()`, `Mat`, `MatSolverType`, `MatRegister()` 3276bdecfbSBarry Smith J*/ 3319fd82e9SBarry Smith typedef const char *MatType; 34273d9f13SBarry Smith #define MATSAME "same" 355a11e1b2SBarry Smith #define MATMAIJ "maij" 36273d9f13SBarry Smith #define MATSEQMAIJ "seqmaij" 37273d9f13SBarry Smith #define MATMPIMAIJ "mpimaij" 3849bd79ccSDebojyoti Ghosh #define MATKAIJ "kaij" 3949bd79ccSDebojyoti Ghosh #define MATSEQKAIJ "seqkaij" 4049bd79ccSDebojyoti Ghosh #define MATMPIKAIJ "mpikaij" 41273d9f13SBarry Smith #define MATIS "is" 425a11e1b2SBarry Smith #define MATAIJ "aij" 43273d9f13SBarry Smith #define MATSEQAIJ "seqaij" 44273d9f13SBarry Smith #define MATMPIAIJ "mpiaij" 455a11e1b2SBarry Smith #define MATAIJCRL "aijcrl" 465a11e1b2SBarry Smith #define MATSEQAIJCRL "seqaijcrl" 475a11e1b2SBarry Smith #define MATMPIAIJCRL "mpiaijcrl" 489ae82921SPaul Mullowney #define MATAIJCUSPARSE "aijcusparse" 499ae82921SPaul Mullowney #define MATSEQAIJCUSPARSE "seqaijcusparse" 509ae82921SPaul Mullowney #define MATMPIAIJCUSPARSE "mpiaijcusparse" 5147d993e7Ssuyashtn #define MATAIJHIPSPARSE "aijhipsparse" 5247d993e7Ssuyashtn #define MATSEQAIJHIPSPARSE "seqaijhipsparse" 5347d993e7Ssuyashtn #define MATMPIAIJHIPSPARSE "mpiaijhipsparse" 548c3ff71bSJunchao Zhang #define MATAIJKOKKOS "aijkokkos" 558c3ff71bSJunchao Zhang #define MATSEQAIJKOKKOS "seqaijkokkos" 568c3ff71bSJunchao Zhang #define MATMPIAIJKOKKOS "mpiaijkokkos" 57d67ff14aSKarl Rupp #define MATAIJVIENNACL "aijviennacl" 58d67ff14aSKarl Rupp #define MATSEQAIJVIENNACL "seqaijviennacl" 59d67ff14aSKarl Rupp #define MATMPIAIJVIENNACL "mpiaijviennacl" 605a11e1b2SBarry Smith #define MATAIJPERM "aijperm" 615a11e1b2SBarry Smith #define MATSEQAIJPERM "seqaijperm" 625a11e1b2SBarry Smith #define MATMPIAIJPERM "mpiaijperm" 634dfdc2d9SRichard Tran Mills #define MATAIJSELL "aijsell" 644dfdc2d9SRichard Tran Mills #define MATSEQAIJSELL "seqaijsell" 654dfdc2d9SRichard Tran Mills #define MATMPIAIJSELL "mpiaijsell" 664a2a386eSRichard Tran Mills #define MATAIJMKL "aijmkl" 674a2a386eSRichard Tran Mills #define MATSEQAIJMKL "seqaijmkl" 684a2a386eSRichard Tran Mills #define MATMPIAIJMKL "mpiaijmkl" 69b5b72c8aSIrina Sokolova #define MATBAIJMKL "baijmkl" 70b5b72c8aSIrina Sokolova #define MATSEQBAIJMKL "seqbaijmkl" 71b5b72c8aSIrina Sokolova #define MATMPIBAIJMKL "mpibaijmkl" 72273d9f13SBarry Smith #define MATSHELL "shell" 73c1fff1c6SRichard Tran Mills #define MATCENTERING "centering" 745a11e1b2SBarry Smith #define MATDENSE "dense" 75637a0070SStefano Zampini #define MATDENSECUDA "densecuda" 7647d993e7Ssuyashtn #define MATDENSEHIP "densehip" 77209238afSKris Buschelman #define MATSEQDENSE "seqdense" 78bfc799aaSStefano Zampini #define MATSEQDENSECUDA "seqdensecuda" 7947d993e7Ssuyashtn #define MATSEQDENSEHIP "seqdensehip" 80273d9f13SBarry Smith #define MATMPIDENSE "mpidense" 81637a0070SStefano Zampini #define MATMPIDENSECUDA "mpidensecuda" 8247d993e7Ssuyashtn #define MATMPIDENSEHIP "mpidensehip" 83db31f6deSJed Brown #define MATELEMENTAL "elemental" 84d24d4204SJose E. Roman #define MATSCALAPACK "scalapack" 855a11e1b2SBarry Smith #define MATBAIJ "baij" 86273d9f13SBarry Smith #define MATSEQBAIJ "seqbaij" 87273d9f13SBarry Smith #define MATMPIBAIJ "mpibaij" 88273d9f13SBarry Smith #define MATMPIADJ "mpiadj" 895a11e1b2SBarry Smith #define MATSBAIJ "sbaij" 90273d9f13SBarry Smith #define MATSEQSBAIJ "seqsbaij" 91273d9f13SBarry Smith #define MATMPISBAIJ "mpisbaij" 92cebc7f6cSBarry Smith #define MATMFFD "mffd" 93c8a8475eSBarry Smith #define MATNORMAL "normal" 94c5e4d11fSDmitry Karpeev #define MATNORMALHERMITIAN "normalh" 95ab92ecdeSBarry Smith #define MATLRC "lrc" 962a6744ebSBarry Smith #define MATSCATTER "scatter" 97421e10b8SBarry Smith #define MATBLOCKMAT "blockmat" 98793850ffSBarry Smith #define MATCOMPOSITE "composite" 991f8c7532SHong Zhang #define MATFFT "fft" 1001f8c7532SHong Zhang #define MATFFTW "fftw" 101e133240eSMatthew G Knepley #define MATSEQCUFFT "seqcufft" 10247d993e7Ssuyashtn #define MATSEQHIPFFT "seqhipfft" 103edd03b47SJacob Faibussowitsch #define MATTRANSPOSEMAT PETSC_DEPRECATED_MACRO(3, 18, 0, "MATTRANSPOSEVIRTUAL", ) "transpose" 104013e2dc7SBarry Smith #define MATTRANSPOSEVIRTUAL "transpose" 105013e2dc7SBarry Smith #define MATHERMITIANTRANSPOSEVIRTUAL "hermitiantranspose" 10672ca8751SBarry Smith #define MATSCHURCOMPLEMENT "schurcomplement" 1071d6018f0SLisandro Dalcin #define MATPYTHON "python" 10863c07aadSStefano Zampini #define MATHYPRE "hypre" 109f91d8e95SBarry Smith #define MATHYPRESTRUCT "hyprestruct" 110a9e6138eSGlenn Hammond #define MATHYPRESSTRUCT "hypresstruct" 111ee1cef2cSJed Brown #define MATSUBMATRIX "submatrix" 1122c0dbf93SJed Brown #define MATLOCALREF "localref" 113d8588912SDave May #define MATNEST "nest" 114c094ef40SMatthew G. Knepley #define MATPREALLOCATOR "preallocator" 115d4002b98SHong Zhang #define MATSELL "sell" 116d4002b98SHong Zhang #define MATSEQSELL "seqsell" 117d4002b98SHong Zhang #define MATMPISELL "mpisell" 1182d1451d4SHong Zhang #define MATSELLCUDA "sellcuda" 1192d1451d4SHong Zhang #define MATSEQSELLCUDA "seqsellcuda" 1202d1451d4SHong Zhang #define MATMPISELLCUDA "mpisellcuda" 121a3b2e22bSHong Zhang #define MATDUMMY "dummy" 122cd929ea3SAlp Dener #define MATLMVM "lmvm" 12378e4361aSAlp Dener #define MATLMVMDFP "lmvmdfp" 12478e4361aSAlp Dener #define MATLMVMBFGS "lmvmbfgs" 12578e4361aSAlp Dener #define MATLMVMSR1 "lmvmsr1" 126864588a7SAlp Dener #define MATLMVMBROYDEN "lmvmbroyden" 127864588a7SAlp Dener #define MATLMVMBADBROYDEN "lmvmbadbroyden" 128864588a7SAlp Dener #define MATLMVMSYMBROYDEN "lmvmsymbroyden" 129864588a7SAlp Dener #define MATLMVMSYMBADBROYDEN "lmvmsymbadbroyden" 130864588a7SAlp Dener #define MATLMVMDIAGBROYDEN "lmvmdiagbroyden" 1313423f386SBarry Smith #define MATCONSTANTDIAGONAL "constantdiagonal" 132345a4b08SToby Isaac #define MATDIAGONAL "diagonal" 133c7a4214aSPierre Jolivet #define MATHTOOL "htool" 13453022affSStefano Zampini #define MATH2OPUS "h2opus" 135773941d6SBarry Smith 13676bdecfbSBarry Smith /*J 13716a05f60SBarry Smith MatSolverType - String with the name of a PETSc factorization based matrix solver type. 1389989ab13SBarry Smith 139c2b89b5dSBarry Smith For example: "petsc" indicates what PETSc provides, "superlu_dist" the parallel SuperLU_DIST package etc 1409989ab13SBarry Smith 1419989ab13SBarry Smith Level: beginner 1429989ab13SBarry Smith 1432ef1f0ffSBarry Smith Note: 14416a05f60SBarry Smith `MATSOLVERUMFPACK`, `MATSOLVERCHOLMOD`, `MATSOLVERKLU`, `MATSOLVERSPQR` form the SuiteSparse package; you can use `--download-suitesparse` as 14516a05f60SBarry Smith a ./configure option to install them 146c7ccbb75SBarry Smith 1471cc06b55SBarry Smith .seealso: [](sec_matfactor), [](ch_matrices), `MatGetFactor()`, `PCFactorSetMatSolverType()`, `PCFactorGetMatSolverType()` 14876bdecfbSBarry Smith J*/ 149ea799195SBarry Smith typedef const char *MatSolverType; 1502692d6eeSBarry Smith #define MATSOLVERSUPERLU "superlu" 1512692d6eeSBarry Smith #define MATSOLVERSUPERLU_DIST "superlu_dist" 15208f5efcfSPieter Ghysels #define MATSOLVERSTRUMPACK "strumpack" 1532692d6eeSBarry Smith #define MATSOLVERUMFPACK "umfpack" 15420db9a53SJed Brown #define MATSOLVERCHOLMOD "cholmod" 155d89f5e7aSBarry Smith #define MATSOLVERKLU "klu" 156d89f5e7aSBarry Smith #define MATSOLVERELEMENTAL "elemental" 157d24d4204SJose E. Roman #define MATSOLVERSCALAPACK "scalapack" 1582692d6eeSBarry Smith #define MATSOLVERESSL "essl" 1592692d6eeSBarry Smith #define MATSOLVERLUSOL "lusol" 1602692d6eeSBarry Smith #define MATSOLVERMUMPS "mumps" 161d615f992SSatish Balay #define MATSOLVERMKL_PARDISO "mkl_pardiso" 162d305a81bSVasiliy Kozyrev #define MATSOLVERMKL_CPARDISO "mkl_cpardiso" 1632692d6eeSBarry Smith #define MATSOLVERPASTIX "pastix" 1642692d6eeSBarry Smith #define MATSOLVERMATLAB "matlab" 1652692d6eeSBarry Smith #define MATSOLVERPETSC "petsc" 1662692d6eeSBarry Smith #define MATSOLVERBAS "bas" 1679ae82921SPaul Mullowney #define MATSOLVERCUSPARSE "cusparse" 168bfc799aaSStefano Zampini #define MATSOLVERCUDA "cuda" 16947d993e7Ssuyashtn #define MATSOLVERHIPSPARSE "hipsparse" 17047d993e7Ssuyashtn #define MATSOLVERHIP "hip" 171930e68a5SMark Adams #define MATSOLVERKOKKOS "kokkos" 172a2fc1e05SToby Isaac #define MATSOLVERSPQR "spqr" 173c0cdd4a1SDahai Guo 174b24902e0SBarry Smith /*E 175b24902e0SBarry Smith MatFactorType - indicates what type of factorization is requested 176b24902e0SBarry Smith 1772ef1f0ffSBarry Smith Values: 1782ef1f0ffSBarry Smith + `MAT_FACTOR_LU` - LU factorization 1792ef1f0ffSBarry Smith . `MAT_FACTOR_CHOLESKY` - Cholesky factorization 1802ef1f0ffSBarry Smith . `MAT_FACTOR_ILU` - ILU factorization 1812ef1f0ffSBarry Smith . `MAT_FACTOR_ICC` - incomplete Cholesky factorization 1822ef1f0ffSBarry Smith . `MAT_FACTOR_ILUDT` - ILU factorization with drop tolerance 1832ef1f0ffSBarry Smith - `MAT_FACTOR_QR` - QR factorization 184b24902e0SBarry Smith 18516a05f60SBarry Smith Level: beginner 18616a05f60SBarry Smith 1871cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSolverType`, `MatGetFactor()`, `MatGetFactorAvailable()`, `MatSolverTypeRegister()` 188b24902e0SBarry Smith E*/ 1899371c9d4SSatish Balay typedef enum { 1909371c9d4SSatish Balay MAT_FACTOR_NONE, 1919371c9d4SSatish Balay MAT_FACTOR_LU, 1929371c9d4SSatish Balay MAT_FACTOR_CHOLESKY, 1939371c9d4SSatish Balay MAT_FACTOR_ILU, 1949371c9d4SSatish Balay MAT_FACTOR_ICC, 1959371c9d4SSatish Balay MAT_FACTOR_ILUDT, 1969371c9d4SSatish Balay MAT_FACTOR_QR, 1979371c9d4SSatish Balay MAT_FACTOR_NUM_TYPES 1989371c9d4SSatish Balay } MatFactorType; 199014dd563SJed Brown PETSC_EXTERN const char *const MatFactorTypes[]; 200e92e720dSBarry Smith 201ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactor(Mat, MatSolverType, MatFactorType, Mat *); 202ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat, MatSolverType, MatFactorType, PetscBool *); 203f73b0415SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetCanUseOrdering(Mat, PetscBool *); 204edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 15, 0, "MatFactorGetCanUseOrdering()", ) static inline PetscErrorCode MatFactorGetUseOrdering(Mat A, PetscBool *b) 205d71ae5a4SJacob Faibussowitsch { 2069371c9d4SSatish Balay return MatFactorGetCanUseOrdering(A, b); 2079371c9d4SSatish Balay } 208ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetSolverType(Mat, MatSolverType *); 209014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetFactorType(Mat, MatFactorType *); 2107abd51d3SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatSetFactorType(Mat, MatFactorType); 2112430ea28SJose E. Roman PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatSolverFunction)(Mat, MatFactorType, Mat *); 2122430ea28SJose E. Roman PETSC_EXTERN PetscErrorCode MatSolverTypeRegister(MatSolverType, MatType, MatFactorType, MatSolverFunction); 2132430ea28SJose E. Roman PETSC_EXTERN PetscErrorCode MatSolverTypeGet(MatSolverType, MatType, MatFactorType, PetscBool *, PetscBool *, MatSolverFunction *); 214edd03b47SJacob Faibussowitsch typedef MatSolverType MatSolverPackage PETSC_DEPRECATED_TYPEDEF(3, 9, 0, "MatSolverType", ); 215edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeRegister()", ) static inline PetscErrorCode MatSolverPackageRegister(MatSolverType stype, MatType mtype, MatFactorType ftype, MatSolverFunction f) 216d71ae5a4SJacob Faibussowitsch { 2179371c9d4SSatish Balay return MatSolverTypeRegister(stype, mtype, ftype, f); 2189371c9d4SSatish Balay } 219edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeGet()", ) static inline PetscErrorCode MatSolverPackageGet(MatSolverType stype, MatType mtype, MatFactorType ftype, PetscBool *foundmtype, PetscBool *foundstype, MatSolverFunction *f) 220d71ae5a4SJacob Faibussowitsch { 2219371c9d4SSatish Balay return MatSolverTypeGet(stype, mtype, ftype, foundmtype, foundstype, f); 2229371c9d4SSatish Balay } 2239989ab13SBarry Smith 2244222ddf1SHong Zhang /*E 2254222ddf1SHong Zhang MatProductType - indicates what type of matrix product is requested 2264222ddf1SHong Zhang 2272ef1f0ffSBarry Smith Values: 2282ef1f0ffSBarry Smith + `MATPRODUCT_AB` - product of two matrices 2292ef1f0ffSBarry Smith . `MATPRODUCT_AtB` - product of the transpose of a given matrix with a matrix 2302ef1f0ffSBarry Smith . `MATPRODUCT_ABt` - product of a matrix with the transpose of another given matrix 2312ef1f0ffSBarry Smith . `MATPRODUCT_PtAP` - the triple product of the transpose of a matrix with another matrix and itself 2322ef1f0ffSBarry Smith . `MATPRODUCT_RARt` - the triple product of a matrix, another matrix and the transpose of the first matrix 2332ef1f0ffSBarry Smith - `MATPRODUCT_ABC` - the product of three matrices 2342ef1f0ffSBarry Smith 23516a05f60SBarry Smith Level: beginner 23616a05f60SBarry Smith 2371cc06b55SBarry Smith .seealso: [](sec_matmatproduct), [](ch_matrices), `MatProductSetType()` 2384222ddf1SHong Zhang E*/ 2399371c9d4SSatish Balay typedef enum { 2409371c9d4SSatish Balay MATPRODUCT_UNSPECIFIED = 0, 2419371c9d4SSatish Balay MATPRODUCT_AB, 2429371c9d4SSatish Balay MATPRODUCT_AtB, 2439371c9d4SSatish Balay MATPRODUCT_ABt, 2449371c9d4SSatish Balay MATPRODUCT_PtAP, 2459371c9d4SSatish Balay MATPRODUCT_RARt, 2469371c9d4SSatish Balay MATPRODUCT_ABC 2479371c9d4SSatish Balay } MatProductType; 248544a5e07SHong Zhang PETSC_EXTERN const char *const MatProductTypes[]; 2494222ddf1SHong Zhang 2504222ddf1SHong Zhang /*J 2514222ddf1SHong Zhang MatProductAlgorithm - String with the name of an algorithm for a PETSc matrix product implementation 2524222ddf1SHong Zhang 2534222ddf1SHong Zhang Level: beginner 2544222ddf1SHong Zhang 2551cc06b55SBarry Smith .seealso: [](sec_matmatproduct), [](ch_matrices), `MatSetType()`, `Mat`, `MatProductSetAlgorithm()`, `MatProductType` 2564222ddf1SHong Zhang J*/ 2574222ddf1SHong Zhang typedef const char *MatProductAlgorithm; 2583e662e0bSHong Zhang #define MATPRODUCTALGORITHMDEFAULT "default" 2593e662e0bSHong Zhang #define MATPRODUCTALGORITHMSORTED "sorted" 2603e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLE "scalable" 2613e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLEFAST "scalable_fast" 2623e662e0bSHong Zhang #define MATPRODUCTALGORITHMHEAP "heap" 2633e662e0bSHong Zhang #define MATPRODUCTALGORITHMBHEAP "btheap" 2643e662e0bSHong Zhang #define MATPRODUCTALGORITHMLLCONDENSED "llcondensed" 2653e662e0bSHong Zhang #define MATPRODUCTALGORITHMROWMERGE "rowmerge" 2663e662e0bSHong Zhang #define MATPRODUCTALGORITHMOUTERPRODUCT "outerproduct" 2673e662e0bSHong Zhang #define MATPRODUCTALGORITHMATB "at*b" 2683e662e0bSHong Zhang #define MATPRODUCTALGORITHMRAP "rap" 2693e662e0bSHong Zhang #define MATPRODUCTALGORITHMNONSCALABLE "nonscalable" 2703e662e0bSHong Zhang #define MATPRODUCTALGORITHMSEQMPI "seqmpi" 2713e662e0bSHong Zhang #define MATPRODUCTALGORITHMBACKEND "backend" 2723e662e0bSHong Zhang #define MATPRODUCTALGORITHMOVERLAPPING "overlapping" 2733e662e0bSHong Zhang #define MATPRODUCTALGORITHMMERGED "merged" 2743e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCE "allatonce" 2753e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCEMERGED "allatonce_merged" 2763e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLGATHERV "allgatherv" 2773e662e0bSHong Zhang #define MATPRODUCTALGORITHMCYCLIC "cyclic" 2783e662e0bSHong Zhang #if defined(PETSC_HAVE_HYPRE) 2793e662e0bSHong Zhang #define MATPRODUCTALGORITHMHYPRE "hypre" 2803e662e0bSHong Zhang #endif 2814222ddf1SHong Zhang 2824222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreate(Mat, Mat, Mat, Mat *); 2834222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreateWithMat(Mat, Mat, Mat, Mat); 2844222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetType(Mat, MatProductType); 2854222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetAlgorithm(Mat, MatProductAlgorithm); 2864222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFill(Mat, PetscReal); 2874222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFromOptions(Mat); 2884222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSymbolic(Mat); 2894222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductNumeric(Mat); 2904222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductReplaceMats(Mat, Mat, Mat, Mat); 2914417c5e8SHong Zhang PETSC_EXTERN PetscErrorCode MatProductClear(Mat); 2926718818eSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductView(Mat, PetscViewer); 293c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetType(Mat, MatProductType *); 294c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetMats(Mat, Mat *, Mat *, Mat *); 2954222ddf1SHong Zhang 296c06d978dSMatthew Knepley /* Logging support */ 2970700a824SBarry Smith #define MAT_FILE_CLASSID 1211216 /* used to indicate matrices in binary files */ 298014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_CLASSID; 299335efc43SPeter Brune PETSC_EXTERN PetscClassId MAT_COLORING_CLASSID; 300014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID; 301014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID; 302014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID; 303014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID; 304014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID; 305014dd563SJed Brown PETSC_EXTERN PetscClassId MATMFFD_CLASSID; 306c06d978dSMatthew Knepley 307ceb03754SKris Buschelman /*E 3082ef1f0ffSBarry Smith MatReuse - Indicates if matrices obtained from a previous call to `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatConvert()` or several other functions 309cf37664fSBarry Smith are to be reused to store the new matrix values. 310cf37664fSBarry Smith 3112ef1f0ffSBarry Smith Values: 3122ef1f0ffSBarry Smith + `MAT_INITIAL_MATRIX` - create a new matrix 3132ef1f0ffSBarry Smith . `MAT_REUSE_MATRIX` - reuse the matrix created with a previous call that used `MAT_INITIAL_MATRIX` 3142ef1f0ffSBarry Smith . `MAT_INPLACE_MATRIX` - replace the first input matrix with the new matrix (not applicable to all functions) 3152ef1f0ffSBarry 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) 316ceb03754SKris Buschelman 317ceb03754SKris Buschelman Level: beginner 318ceb03754SKris Buschelman 3191cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatDestroyMatrices()`, `MatConvert()` 320ceb03754SKris Buschelman E*/ 3219371c9d4SSatish Balay typedef enum { 3229371c9d4SSatish Balay MAT_INITIAL_MATRIX, 3239371c9d4SSatish Balay MAT_REUSE_MATRIX, 3249371c9d4SSatish Balay MAT_IGNORE_MATRIX, 3259371c9d4SSatish Balay MAT_INPLACE_MATRIX 3269371c9d4SSatish Balay } MatReuse; 327ceb03754SKris Buschelman 3285494a064SHong Zhang /*E 3292ef1f0ffSBarry Smith MatCreateSubMatrixOption - Indicates if matrices obtained from a call to `MatCreateSubMatrices()` 3302ef1f0ffSBarry Smith include the matrix values. Currently it is only used by `MatGetSeqNonzeroStructure()`. 3315494a064SHong Zhang 3322ef1f0ffSBarry Smith Level: developer 3335494a064SHong Zhang 3342ef1f0ffSBarry Smith Values: 3352ef1f0ffSBarry Smith + `MAT_DO_NOT_GET_VALUES` - do not copy the matrix values 3362ef1f0ffSBarry Smith - `MAT_GET_VALUES` - copy the matrix values 3372ef1f0ffSBarry Smith 3382ef1f0ffSBarry Smith Developer Note: 3392ef1f0ffSBarry Smith Why is not just a boolean used for this information? 3402ef1f0ffSBarry Smith 3411cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatDuplicateOption`, `PetscCopyMode`, `MatGetSeqNonzeroStructure()` 3425494a064SHong Zhang E*/ 3439371c9d4SSatish Balay typedef enum { 3449371c9d4SSatish Balay MAT_DO_NOT_GET_VALUES, 3459371c9d4SSatish Balay MAT_GET_VALUES 3469371c9d4SSatish Balay } MatCreateSubMatrixOption; 3475494a064SHong Zhang 348607a6623SBarry Smith PETSC_EXTERN PetscErrorCode MatInitializePackage(void); 3494bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatFinalizePackage(void); 350c06d978dSMatthew Knepley 351014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm, Mat *); 35277433607SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFromOptions(MPI_Comm, const char *, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 353014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetSizes(Mat, PetscInt, PetscInt, PetscInt, PetscInt); 35419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatSetType(Mat, MatType); 3550d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatGetVecType(Mat, VecType *); 3560d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetVecType(Mat, VecType); 357014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat); 358fe2efc57SMark PETSC_EXTERN PetscErrorCode MatViewFromOptions(Mat, PetscObject, const char[]); 359bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatRegister(const char[], PetscErrorCode (*)(Mat)); 36023bebc0bSBarry Smith PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[], const char[], const char[]); 361014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat, const char[]); 36226cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOptionsPrefixFactor(Mat, const char[]); 36326cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefixFactor(Mat, const char[]); 364014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat, const char[]); 365014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat, const char *[]); 36684d44b13SHong Zhang PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat, PetscBool); 367f69a0ea3SMatthew Knepley 368140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatList; 369140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatColoringList; 370140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatPartitioningList; 37128988994SBarry Smith 3723b224e63SBarry Smith /*E 373aa6c7ce3SBarry Smith MatStructure - Indicates if two matrices have the same nonzero structure 3743b224e63SBarry Smith 3752ef1f0ffSBarry Smith Values: 3762ef1f0ffSBarry Smith + `SAME_NONZERO_PATTERN` - the two matrices have identical nonzero patterns 3772ef1f0ffSBarry Smith . `DIFFERENT_NONZERO_PATTERN` - the two matrices may have different nonzero patterns 3782ef1f0ffSBarry Smith . `SUBSET_NONZERO_PATTERN` - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix 3792ef1f0ffSBarry Smith - `UNKNOWN_NONZERO_PATTERN` - there is no known relationship between the nonzero patterns. In this case the implementations 3802ef1f0ffSBarry Smith may try to detect a relationship to optimize the operation 381531d0c6aSBarry Smith 38216a05f60SBarry Smith Level: beginner 38316a05f60SBarry Smith 3841cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCopy()`, `MatAXPY()`, `MatAYPX()` 3853b224e63SBarry Smith E*/ 3869371c9d4SSatish Balay typedef enum { 3879371c9d4SSatish Balay DIFFERENT_NONZERO_PATTERN, 3889371c9d4SSatish Balay SUBSET_NONZERO_PATTERN, 3899371c9d4SSatish Balay SAME_NONZERO_PATTERN, 3909371c9d4SSatish Balay UNKNOWN_NONZERO_PATTERN 3919371c9d4SSatish Balay } MatStructure; 392d60b7d5cSBarry Smith PETSC_EXTERN const char *const MatStructures[]; 3933b224e63SBarry Smith 3949779e05dSSatish Balay #if defined PETSC_HAVE_MKL_SPARSE 395ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 396ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 39780095d54SIrina Sokolova PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 398ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 39980095d54SIrina Sokolova #endif 400cd929ea3SAlp Dener 4014bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateMPIAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 4024bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 4034bf303faSJacob Faibussowitsch 404d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 405d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 406d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat, PetscInt, const PetscInt[]); 407d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 40807e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetFillRatio(Mat, PetscReal *); 40907e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetMaxSliceWidth(Mat, PetscInt *); 41007e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetAvgSliceWidth(Mat, PetscReal *); 41107e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetSliceHeight(Mat, PetscInt); 412b921024eSHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetVarSliceSize(Mat, PetscReal *); 41380095d54SIrina Sokolova 4144bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 4154bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 416fa078d78SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMPISELLGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *); 417fa078d78SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMPISELLGetSeqSELL(Mat, Mat *, Mat *, const PetscInt *[]); 4184bf303faSJacob Faibussowitsch 419014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 420014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 421014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 422014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 423014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 4248f8f2f0dSBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 4256a3d2595SBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArray(Mat, const PetscScalar[]); 426014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], PetscInt[], PetscInt[], PetscScalar[], Mat *); 4273b00a383SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm, Mat, Mat, const PetscInt[], Mat *); 4283b00a383SHong Zhang 429014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 430014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 431014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 4327e8381f9SStefano Zampini 433e8729f6fSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSetPreallocationCOO(Mat, PetscCount, PetscInt[], PetscInt[]); 43482a78a4eSJed Brown PETSC_EXTERN PetscErrorCode MatSetPreallocationCOOLocal(Mat, PetscCount, PetscInt[], PetscInt[]); 4357e8381f9SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetValuesCOO(Mat, const PetscScalar[], InsertMode); 436d21a29f3SJed Brown 437014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscInt[], Mat *); 438014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 439d21a29f3SJed Brown 440014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 441014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 44238f409ebSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 443014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 4444cce697cSJed Brown PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscInt[], const PetscInt[]); 445dfb205c3SBarry Smith 446014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, void *, Mat *); 447c1fff1c6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatCreateCentering(MPI_Comm, PetscInt, PetscInt, Mat *); 448014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat, Mat *); 449c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat, Mat *); 450986c4d72SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat, Mat, Vec, Mat, Mat *); 451267ca84cSJose E. Roman PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat, Mat *, Mat *, Vec *, Mat *); 452bcf2175cSMatthew Knepley PETSC_EXTERN PetscErrorCode MatLRCSetMats(Mat, Mat, Mat, Vec, Mat); 453c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, ISLocalToGlobalMapping, ISLocalToGlobalMapping, Mat *); 454014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 455014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 456c0cdd4a1SDahai Guo 457014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm, VecScatter, Mat *); 458014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat, VecScatter); 459014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat, VecScatter *); 460014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt *, Mat *); 461014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat, Mat); 462014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat); 4639371c9d4SSatish Balay typedef enum { 4649371c9d4SSatish Balay MAT_COMPOSITE_MERGE_RIGHT, 4659371c9d4SSatish Balay MAT_COMPOSITE_MERGE_LEFT 4669371c9d4SSatish Balay } MatCompositeMergeType; 4678c8613bfSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat, MatCompositeMergeType); 468014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm, PetscInt, const Mat *, Mat *); 4699371c9d4SSatish Balay typedef enum { 4709371c9d4SSatish Balay MAT_COMPOSITE_ADDITIVE, 4719371c9d4SSatish Balay MAT_COMPOSITE_MULTIPLICATIVE 4729371c9d4SSatish Balay } MatCompositeType; 473014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat, MatCompositeType); 4746dbc55e5SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat, MatCompositeType *); 4753b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat, MatStructure); 4763b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat, MatStructure *); 4776d0add67SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat, PetscInt *); 4788b5c3584SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat, PetscInt, Mat *); 47903049c21SJunchao Zhang PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat, const PetscScalar *); 4806d7c1e57SBarry Smith 48119fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm, PetscInt, const PetscInt[], MatType, Mat *); 482014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm, PetscInt, const PetscInt[], Mat *); 483dedccee8SHong Zhang 484014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat, Mat *); 4858060fb66Sstefano_zampini PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat, Mat *); 486d0de2241SAndrew Spott PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat, Mat *); 48706511a5cSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat, Mat *); 488fa80d070SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalGetMat(Mat, Mat *); 48965f45395SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalHermitianGetMat(Mat, Mat *); 49054e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat, IS, IS, Mat *); 49154e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat, Mat, IS, IS); 492014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat, IS, IS, Mat *); 4933423f386SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar, Mat *); 494345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatCreateDiagonal(Vec, Mat *); 495345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalGetDiagonal(Mat, Vec *); 496345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalRestoreDiagonal(Mat, Vec *); 497345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalGetInverseDiagonal(Mat, Vec *); 498345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalRestoreInverseDiagonal(Mat, Vec *); 4991472f72bSBarry Smith 500978814f1SStefano Zampini #if defined(PETSC_HAVE_HYPRE) 501d975228cSstefano_zampini PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 502978814f1SStefano Zampini #endif 503978814f1SStefano Zampini 504014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat, const char[]); 505ebead697SStefano Zampini PETSC_EXTERN PetscErrorCode MatPythonGetType(Mat, const char *[]); 5061d6018f0SLisandro Dalcin 507846b4da1SFande Kong PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat); 508014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetUp(Mat); 509014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroy(Mat *); 510e56f5c9eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat, PetscObjectState *); 51121c89e3eSBarry Smith 512014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatConjugate(Mat); 513014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRealPart(Mat); 514014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat); 515014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat, Mat *); 516014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetTrace(Mat, PetscScalar *); 517713ccfa9SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat, const PetscScalar **); 5180da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat, PetscInt, const PetscInt *, PetscScalar *); 519479a70c0SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat, Mat); 5208a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockEnvelope(Mat, MatReuse, Mat *); 52120c04d79SPierre Jolivet PETSC_EXTERN PetscErrorCode MatComputeVariableBlockEnvelope(Mat); 52299cafbc1SBarry Smith 523014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 5248a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetValuesIS(Mat, IS, IS, const PetscScalar[], InsertMode); 525014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 526014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat, PetscInt, const PetscScalar[]); 527014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat, PetscInt, const PetscScalar[]); 528014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat, PetscInt, PetscInt, PetscInt[], const PetscScalar[]); 52973a71a0fSBarry Smith PETSC_EXTERN PetscErrorCode MatSetRandom(Mat, PetscRandom); 53084cb2905SBarry Smith 5312ef4de8bSBarry Smith /*S 5322ef1f0ffSBarry Smith MatStencil - Data structure (C struct) for storing information about rows and 5332ef1f0ffSBarry Smith columns of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()` 53462ef0227SBarry Smith 5352ef1f0ffSBarry Smith Level: beginner 5362ef1f0ffSBarry Smith 5372ef1f0ffSBarry Smith Notes: 53862ef0227SBarry 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). 53987497f52SBarry Smith The c represents the the degrees of freedom at each grid point (the dof argument to `DMDASetDOF()`). If dof is 1 then this entry is ignored. 54062ef0227SBarry Smith 54187497f52SBarry Smith For stencil access to vectors see `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`. 542be479b30SJed Brown 5432ef1f0ffSBarry Smith For staggered grids, see `DMStagStencil` 5442ef4de8bSBarry Smith 5452ef1f0ffSBarry Smith Fortran Note: 5462ef1f0ffSBarry Smith See `MatSetValuesStencil()` for details. 5472ef4de8bSBarry Smith 5481cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`, 5492ef1f0ffSBarry Smith `DMStagStencil` 5502ef4de8bSBarry Smith S*/ 551435da068SBarry Smith typedef struct { 552c1ac3661SBarry Smith PetscInt k, j, i, c; 553435da068SBarry Smith } MatStencil; 5542ef4de8bSBarry Smith 555014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode); 556014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode); 557014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetStencil(Mat, PetscInt, const PetscInt[], const PetscInt[], PetscInt); 558435da068SBarry Smith 559d91e6319SBarry Smith /*E 5602ef1f0ffSBarry Smith MatAssemblyType - Indicates if the process of setting values into the matrix is complete, and the matrix is ready for use 561d91e6319SBarry Smith 5622ef1f0ffSBarry Smith Values: 5632ef1f0ffSBarry Smith + `MAT_FLUSH_ASSEMBLY` - you will continue to put values into the matrix 5642ef1f0ffSBarry Smith - `MAT_FINAL_ASSEMBLY` - you wish to use the matrix with the values currently inserted 5652ef1f0ffSBarry Smith 56616a05f60SBarry Smith Level: beginner 56716a05f60SBarry Smith 5681cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetValues`, `MatAssemblyBegin()`, `MatAssemblyEnd()` 569d91e6319SBarry Smith E*/ 5709371c9d4SSatish Balay typedef enum { 5719371c9d4SSatish Balay MAT_FLUSH_ASSEMBLY = 1, 5729371c9d4SSatish Balay MAT_FINAL_ASSEMBLY = 0 5739371c9d4SSatish Balay } MatAssemblyType; 574014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat, MatAssemblyType); 575014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat, MatAssemblyType); 576014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssembled(Mat, PetscBool *); 5774f9c727eSBarry Smith 578d91e6319SBarry Smith /*E 5792ef1f0ffSBarry Smith MatOption - Options that may be set for a matrix that indicate properties of the matrix or affect its behavior or storage 580d91e6319SBarry Smith 581d91e6319SBarry Smith Level: beginner 582d91e6319SBarry Smith 5832ef1f0ffSBarry Smith Note: 5842ef1f0ffSBarry Smith See `MatSetOption()` for the use of the options 5852ef1f0ffSBarry Smith 5862ef1f0ffSBarry Smith Developer Note: 58795452b02SPatrick Sanan Entries that are negative need not be called collectively by all processes. 588382164b0SBarry Smith 5891cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetOption()` 590d91e6319SBarry Smith E*/ 5919371c9d4SSatish Balay typedef enum { 5929371c9d4SSatish Balay MAT_OPTION_MIN = -3, 593c5e4d11fSDmitry Karpeev MAT_UNUSED_NONZERO_LOCATION_ERR = -2, 59492d4d306SBarry Smith MAT_ROW_ORIENTED = -1, 595382164b0SBarry Smith MAT_SYMMETRIC = 1, 596382164b0SBarry Smith MAT_STRUCTURALLY_SYMMETRIC = 2, 5978c78258cSHong Zhang MAT_FORCE_DIAGONAL_ENTRIES = 3, 598382164b0SBarry Smith MAT_IGNORE_OFF_PROC_ENTRIES = 4, 599382164b0SBarry Smith MAT_USE_HASH_TABLE = 5, 600382164b0SBarry Smith MAT_KEEP_NONZERO_PATTERN = 6, 601382164b0SBarry Smith MAT_IGNORE_ZERO_ENTRIES = 7, 602382164b0SBarry Smith MAT_USE_INODES = 8, 603382164b0SBarry Smith MAT_HERMITIAN = 9, 604382164b0SBarry Smith MAT_SYMMETRY_ETERNAL = 10, 605c5e4d11fSDmitry Karpeev MAT_NEW_NONZERO_LOCATION_ERR = 11, 606382164b0SBarry Smith MAT_IGNORE_LOWER_TRIANGULAR = 12, 607382164b0SBarry Smith MAT_ERROR_LOWER_TRIANGULAR = 13, 608382164b0SBarry Smith MAT_GETROW_UPPERTRIANGULAR = 14, 609382164b0SBarry Smith MAT_SPD = 15, 61092d4d306SBarry Smith MAT_NO_OFF_PROC_ZERO_ROWS = 16, 61192d4d306SBarry Smith MAT_NO_OFF_PROC_ENTRIES = 17, 61292d4d306SBarry Smith MAT_NEW_NONZERO_LOCATIONS = 18, 613c5e4d11fSDmitry Karpeev MAT_NEW_NONZERO_ALLOCATION_ERR = 19, 614c5e4d11fSDmitry Karpeev MAT_SUBSET_OFF_PROC_ENTRIES = 20, 615c10200c1SHong Zhang MAT_SUBMAT_SINGLEIS = 21, 616957cac9fSHong Zhang MAT_STRUCTURE_ONLY = 22, 617071fcb05SBarry Smith MAT_SORTED_FULL = 23, 6181a2c6b5cSJunchao Zhang MAT_FORM_EXPLICIT_TRANSPOSE = 24, 619b94d7dedSBarry Smith MAT_STRUCTURAL_SYMMETRY_ETERNAL = 25, 620b94d7dedSBarry Smith MAT_SPD_ETERNAL = 26, 6219371c9d4SSatish Balay MAT_OPTION_MAX = 27 6229371c9d4SSatish Balay } MatOption; 623e057df02SPaul Mullowney 6240f8fb01aSBarry Smith PETSC_EXTERN const char *const *MatOptions; 625014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOption(Mat, MatOption, PetscBool); 6267d68702bSBarry Smith PETSC_EXTERN PetscErrorCode MatGetOption(Mat, MatOption, PetscBool *); 627856afa8bSStefano Zampini PETSC_EXTERN PetscErrorCode MatPropagateSymmetryOptions(Mat, Mat); 62819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatGetType(Mat, MatType *); 62984cb2905SBarry Smith 630014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]); 631014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]); 632014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]); 633014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowUpperTriangular(Mat); 634014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowUpperTriangular(Mat); 635014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnVector(Mat, Vec, PetscInt); 6368c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJGetArray(Mat, PetscScalar *[]); 6378f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayRead(Mat, const PetscScalar *[]); 638d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayWrite(Mat, PetscScalar *[]); 6398c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArray(Mat, PetscScalar *[]); 6408f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayRead(Mat, const PetscScalar *[]); 641d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayWrite(Mat, PetscScalar *[]); 64221e72a00SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJGetMaxRowNonzeros(Mat, PetscInt *); 643bd04181cSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetValuesLocalFast(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 6444099cc6bSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetType(Mat, MatType); 645ad7e164aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatSeqAIJKron(Mat, Mat, MatReuse, Mat *); 646388d47a6SSatish Balay PETSC_EXTERN PetscErrorCode MatSeqAIJRegister(const char[], PetscErrorCode (*)(Mat, MatType, MatReuse, Mat *)); 6474099cc6bSBarry Smith PETSC_EXTERN PetscFunctionList MatSeqAIJList; 648cda14afcSprj- PETSC_EXTERN PetscErrorCode MatSeqBAIJGetArray(Mat, PetscScalar *[]); 649cda14afcSprj- PETSC_EXTERN PetscErrorCode MatSeqBAIJRestoreArray(Mat, PetscScalar *[]); 6508397e458SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqSBAIJGetArray(Mat, PetscScalar *[]); 6518397e458SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqSBAIJRestoreArray(Mat, PetscScalar *[]); 6528c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetArray(Mat, PetscScalar *[]); 6538c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseRestoreArray(Mat, PetscScalar *[]); 654d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode MatDensePlaceArray(Mat, const PetscScalar[]); 655d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseReplaceArray(Mat, const PetscScalar[]); 656d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseResetArray(Mat); 6578572280aSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetArrayRead(Mat, const PetscScalar *[]); 6588572280aSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayRead(Mat, const PetscScalar *[]); 6596947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetArrayWrite(Mat, PetscScalar *[]); 6606947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWrite(Mat, PetscScalar *[]); 661cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseGetArrayAndMemType(Mat, PetscScalar *[], PetscMemType *); 662cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayAndMemType(Mat, PetscScalar *[]); 663cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseGetArrayReadAndMemType(Mat, const PetscScalar *[], PetscMemType *); 664cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayReadAndMemType(Mat, const PetscScalar *[]); 665cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseGetArrayWriteAndMemType(Mat, PetscScalar *[], PetscMemType *); 666cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWriteAndMemType(Mat, PetscScalar *[]); 667014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBlockSize(Mat, PetscInt *); 668014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSize(Mat, PetscInt); 669014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBlockSizes(Mat, PetscInt *, PetscInt *); 670014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSizes(Mat, PetscInt, PetscInt); 67133d57670SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSizesFromMats(Mat, Mat, Mat); 6720da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetVariableBlockSizes(Mat, PetscInt, PetscInt *); 6730da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetVariableBlockSizes(Mat, PetscInt *, const PetscInt **); 6740da83c2eSBarry Smith 67586aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat, PetscInt, PetscScalar *[]); 67686aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat, PetscScalar *[]); 6776947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVec(Mat, PetscInt, Vec *); 6786947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVec(Mat, PetscInt, Vec *); 6796947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecRead(Mat, PetscInt, Vec *); 6806947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecRead(Mat, PetscInt, Vec *); 6816947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecWrite(Mat, PetscInt, Vec *); 6826947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecWrite(Mat, PetscInt, Vec *); 683a2748737SPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseGetSubMatrix(Mat, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 6845ea7661aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseRestoreSubMatrix(Mat, Mat *); 6851620fd73SBarry Smith 686014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMult(Mat, Vec, Vec); 687014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat, Vec, Vec); 688014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAdd(Mat, Vec, Vec, Vec); 689014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat, Vec, Vec); 690014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat, Vec, Vec); 691014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat, Mat, PetscReal, PetscBool *); 692014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat, Mat, PetscReal, PetscBool *); 693014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat, Vec, Vec, Vec); 694014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat, Vec, Vec, Vec); 695014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatSolve(Mat, Mat, Mat); 696bdc285e1SStefano Zampini PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat, Mat, Mat); 697eb3ef3b2SHong Zhang PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat, Mat, Mat); 698f9426fe0SMark Adams PETSC_EXTERN PetscErrorCode MatResidual(Mat, Vec, Vec, Vec); 699f5edf698SHong Zhang 700d91e6319SBarry Smith /*E 701d91e6319SBarry Smith MatDuplicateOption - Indicates if a duplicated sparse matrix should have 702d91e6319SBarry Smith its numerical values copied over or just its nonzero structure. 703d91e6319SBarry Smith 7042ef1f0ffSBarry Smith Values: 7052ef1f0ffSBarry Smith + `MAT_DO_NOT_COPY_VALUES` - Create a matrix using the same nonzero pattern as the original matrix, 7062ef1f0ffSBarry Smith with zeros for the numerical values 7072ef1f0ffSBarry Smith . `MAT_COPY_VALUES` - Create a matrix with the same nonzero pattern as the original matrix 7082ef1f0ffSBarry Smith and with the same numerical values. 7092ef1f0ffSBarry Smith - `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix 7102ef1f0ffSBarry Smith and does not copy it, using zeros for the numerical values. The parent and 7112ef1f0ffSBarry Smith child matrices will share their index (i and j) arrays, and you cannot 7122ef1f0ffSBarry Smith insert new nonzero entries into either matrix 7130018da39SRichard Tran Mills 71416a05f60SBarry Smith Level: beginner 71516a05f60SBarry Smith 71687497f52SBarry Smith Note: 71787497f52SBarry Smith Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in 71887497f52SBarry Smith this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified. 71970dcbbb9SBarry Smith 7201cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatDuplicate()` 721d91e6319SBarry Smith E*/ 7229371c9d4SSatish Balay typedef enum { 7239371c9d4SSatish Balay MAT_DO_NOT_COPY_VALUES, 7249371c9d4SSatish Balay MAT_COPY_VALUES, 7259371c9d4SSatish Balay MAT_SHARE_NONZERO_PATTERN 7269371c9d4SSatish Balay } MatDuplicateOption; 7272e8a6d31SBarry Smith 72819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatConvert(Mat, MatType, MatReuse, Mat *); 729014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDuplicate(Mat, MatDuplicateOption, Mat *); 73094a9d846SBarry Smith 731014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCopy(Mat, Mat, MatStructure); 732014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatView(Mat, PetscViewer); 733014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat, PetscReal, PetscBool *); 734014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat, PetscBool *); 735014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat, PetscReal, PetscBool *); 736014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat, PetscBool *, PetscBool *); 737014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat, PetscBool *, PetscBool *); 738b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetricKnown(Mat, PetscBool *, PetscBool *); 739b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsSPDKnown(Mat, PetscBool *, PetscBool *); 740014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMissingDiagonal(Mat, PetscBool *, PetscInt *); 741014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer); 7427b80b807SBarry Smith 7431a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 7441a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 7451a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 7461a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 747d4fbbf0eSBarry Smith 748d91e6319SBarry Smith /*S 74987497f52SBarry Smith MatInfo - Context of matrix information, used with `MatGetInfo()` 750d91e6319SBarry Smith 751d91e6319SBarry Smith Level: intermediate 752d91e6319SBarry Smith 7532ef1f0ffSBarry Smith Fortran Note: 7542ef1f0ffSBarry Smith Information is stored as a double-precision array of dimension `MAT_INFO_SIZE` 7552ef1f0ffSBarry Smith 7561cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetInfo()`, `MatInfoType` 757d91e6319SBarry Smith S*/ 7584e220ebcSLois Curfman McInnes typedef struct { 759b0a32e0cSBarry Smith PetscLogDouble block_size; /* block size */ 760b0a32e0cSBarry Smith PetscLogDouble nz_allocated, nz_used, nz_unneeded; /* number of nonzeros */ 761b0a32e0cSBarry Smith PetscLogDouble memory; /* memory allocated */ 762b0a32e0cSBarry Smith PetscLogDouble assemblies; /* number of matrix assemblies called */ 763b0a32e0cSBarry Smith PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 764b0a32e0cSBarry Smith PetscLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */ 765b0a32e0cSBarry Smith PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 7664e220ebcSLois Curfman McInnes } MatInfo; 7674e220ebcSLois Curfman McInnes 768d9274352SBarry Smith /*E 769d9274352SBarry Smith MatInfoType - Indicates if you want information about the local part of the matrix, 770d9274352SBarry Smith the entire parallel matrix or the maximum over all the local parts. 771d9274352SBarry Smith 7722ef1f0ffSBarry Smith Values: 7732ef1f0ffSBarry Smith + `MAT_LOCAL` - values for each MPI process part of the matrix 7742ef1f0ffSBarry Smith . `MAT_GLOBAL_MAX` - maximum of each value over all MPI processes 7752ef1f0ffSBarry Smith - `MAT_GLOBAL_SUM` - sum of each value over all MPI processes 776d9274352SBarry Smith 77716a05f60SBarry Smith Level: beginner 77816a05f60SBarry Smith 7791cc06b55SBarry Smith .seealso: [](ch_matrices), `MatGetInfo()`, `MatInfo` 780d9274352SBarry Smith E*/ 7819371c9d4SSatish Balay typedef enum { 7829371c9d4SSatish Balay MAT_LOCAL = 1, 7839371c9d4SSatish Balay MAT_GLOBAL_MAX = 2, 7849371c9d4SSatish Balay MAT_GLOBAL_SUM = 3 7859371c9d4SSatish Balay } MatInfoType; 786014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInfo(Mat, MatInfoType, MatInfo *); 787014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat, Vec); 788014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat, Vec, PetscInt[]); 789014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat, Vec, PetscInt[]); 790014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat, Vec, PetscInt[]); 791014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat, Vec, PetscInt[]); 792014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat, Vec); 793014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTranspose(Mat, MatReuse, Mat *); 7947fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSymbolic(Mat, Mat *); 7957fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSetPrecursor(Mat, Mat); 796014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat, MatReuse, Mat *); 797014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPermute(Mat, IS, IS, Mat *); 798014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat, Vec, Vec); 799014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat, Vec, InsertMode); 800a52676ecSHong Zhang 801014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatEqual(Mat, Mat, PetscBool *); 802014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultEqual(Mat, Mat, PetscInt, PetscBool *); 803014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat, Mat, PetscInt, PetscBool *); 804014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat, Mat, PetscInt, PetscBool *); 805014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *); 806e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeEqual(Mat, Mat, PetscInt, PetscBool *); 807e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *); 808a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 809a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 810cc48ffa7SToby Isaac PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 8114222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatPtAPMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 812447fed29SStefano Zampini PETSC_EXTERN PetscErrorCode MatRARtMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 81386919fd6SHong Zhang PETSC_EXTERN PetscErrorCode MatIsLinear(Mat, PetscInt, PetscBool *); 8147b80b807SBarry Smith 815014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNorm(Mat, NormType, PetscReal *); 816014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat, NormType, PetscReal *); 817857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSums(Mat, PetscScalar *); 818857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsRealPart(Mat, PetscReal *); 819857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsImaginaryPart(Mat, PetscReal *); 820857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeans(Mat, PetscScalar *); 821857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansRealPart(Mat, PetscReal *); 822857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansImaginaryPart(Mat, PetscReal *); 823857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnReductions(Mat, PetscInt, PetscReal *); 824014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat); 8251b2b9847SBarry Smith PETSC_EXTERN PetscErrorCode MatSetInf(Mat); 826014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRows(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 827014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat, IS, PetscScalar, Vec, Vec); 828014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec); 829014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec); 830014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 831014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat, IS, PetscScalar, Vec, Vec); 8327b80b807SBarry Smith 833014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSize(Mat, PetscInt *, PetscInt *); 834014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat, PetscInt *, PetscInt *); 835014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat, PetscInt *, PetscInt *); 836014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat, const PetscInt **); 837014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat, PetscInt *, PetscInt *); 838014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat, const PetscInt **); 839566876eaSJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat, IS *, IS *); 8405ef9f2a5SBarry Smith 8417dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]); 842edd03b47SJacob 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[]) 843d71ae5a4SJacob Faibussowitsch { 8449371c9d4SSatish Balay return MatCreateSubMatrices(mat, n, irow, icol, scall, submat); 8459371c9d4SSatish Balay } 8467dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]); 847edd03b47SJacob 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[]) 848d71ae5a4SJacob Faibussowitsch { 8499371c9d4SSatish Balay return MatCreateSubMatricesMPI(mat, n, irow, icol, scall, submat); 8509371c9d4SSatish Balay } 851014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt, Mat *[]); 852df750dc8SHong Zhang PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt, Mat *[]); 8537dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat, IS, IS, MatReuse, Mat *); 854edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 8, 0, "MatCreateSubMatrix()", ) static inline PetscErrorCode MatGetSubMatrix(Mat mat, IS isrow, IS iscol, MatReuse cll, Mat *newmat) 855d71ae5a4SJacob Faibussowitsch { 8569371c9d4SSatish Balay return MatCreateSubMatrix(mat, isrow, iscol, cll, newmat); 8579371c9d4SSatish Balay } 858014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat, IS, IS, Mat *); 859014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat, IS, IS, Mat *); 860014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat, Mat *); 861014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat *); 8627b80b807SBarry Smith 863014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm, Mat, PetscInt, PetscInt, MatReuse, Mat *); 864014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm, Mat, PetscInt, PetscInt, Mat *); 865014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat, Mat); 866014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat, MatReuse, Mat *); 8678a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatAIJGetLocalMat(Mat, Mat *); 868014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *); 869ed502f03SStefano Zampini PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatMerge(Mat, MatReuse, IS *, Mat *); 870f2afee66SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJGetNumberNonzeros(Mat, PetscCount *); 871014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat, Mat, MatReuse, IS *, IS *, Mat *); 872014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *, const PetscInt *[]); 8738efafbd8SBarry Smith 874014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat, PetscInt, IS[], PetscInt); 875aa1e27eaSFande Kong PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat mat, PetscInt n, IS is[], PetscInt ov); 876d2b2a242SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat, PetscBool); 8777b80b807SBarry Smith 878014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatMult(Mat, Mat, MatReuse, PetscReal, Mat *); 87922440eb1SKris Buschelman 8807bab7c10SHong Zhang PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat, Mat, Mat, MatReuse, PetscReal, Mat *); 8812df6c5c3SPatrick Farrell PETSC_EXTERN PetscErrorCode MatGalerkin(Mat, Mat, Mat, MatReuse, PetscReal, Mat *); 8827bab7c10SHong Zhang 883014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPtAP(Mat, Mat, MatReuse, PetscReal, Mat *); 884014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRARt(Mat, Mat, MatReuse, PetscReal, Mat *); 88522440eb1SKris Buschelman 886014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat, Mat, MatReuse, PetscReal, Mat *); 887014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat, Mat, MatReuse, PetscReal, Mat *); 888bc011b1eSHong Zhang 889014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAXPY(Mat, PetscScalar, Mat, MatStructure); 890014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAYPX(Mat, PetscScalar, Mat, MatStructure); 8911c741599SHong Zhang 892014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScale(Mat, PetscScalar); 893014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShift(Mat, PetscScalar); 8947b80b807SBarry Smith 895014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping, ISLocalToGlobalMapping); 896014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *); 897a93ff8c4SPeter Brune PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat, PetscLayout *, PetscLayout *); 89881fa06acSBarry Smith PETSC_EXTERN PetscErrorCode MatSetLayouts(Mat, PetscLayout, PetscLayout); 899014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 900014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat, IS, PetscScalar, Vec, Vec); 901014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 902014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat, IS, PetscScalar, Vec, Vec); 903e265f6d6SPatrick Sanan PETSC_EXTERN PetscErrorCode MatGetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]); 904014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 905014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 906052efed2SBarry Smith 907014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat, PetscInt, PetscInt); 908014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat, PetscInt *, PetscInt *, PetscInt *, PetscInt *); 90990f02eecSBarry Smith 910014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolate(Mat, Vec, Vec); 911014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat, Vec, Vec, Vec); 912014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestrict(Mat, Vec, Vec); 91330b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolate(Mat, Mat, Mat *); 91430b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolateAdd(Mat, Mat, Mat, Mat *); 91530b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatRestrict(Mat, Mat, Mat *); 9162a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat, Vec *, Vec *); 917edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 6, 0, "MatCreateVecs()", ) static inline PetscErrorCode MatGetVecs(Mat mat, Vec *x, Vec *y) 918d71ae5a4SJacob Faibussowitsch { 9199371c9d4SSatish Balay return MatCreateVecs(mat, x, y); 9209371c9d4SSatish Balay } 92153cd1579SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat, PetscInt, MPI_Comm, MatReuse, Mat *); 922014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat, MPI_Comm, MatReuse, Mat *); 923014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat, IS *); 9243a062f41SBarry Smith PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat, IS *); 9259c8f2541SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm, Mat, PetscInt, MatReuse, Mat *); 926bd481603SBarry Smith 927c8d6c325SJunchao Zhang /*@C 9281620fd73SBarry Smith MatSetValue - Set a single entry into a matrix. 9291620fd73SBarry Smith 930e1c5b2e2SJose E. Roman This value may be cached, so `MatAssemblyBegin()` and `MatAssemblyEnd()` 931e1c5b2e2SJose E. Roman MUST be called after all calls to `MatSetValue()` have been completed. 9321620fd73SBarry Smith 933e1c5b2e2SJose E. Roman Not Collective 934a9834a7dSSatish Balay 9351620fd73SBarry Smith Input Parameters: 936c8d6c325SJunchao Zhang + mat - the matrix 93716a05f60SBarry Smith . i - the row location of the entry 93816a05f60SBarry Smith . j - the column location of the entry 93916a05f60SBarry Smith . va - the value to insert 94087497f52SBarry Smith - mode - either `INSERT_VALUES` or `ADD_VALUES` 9411620fd73SBarry Smith 9421620fd73SBarry Smith Level: beginner 9431620fd73SBarry Smith 9442ef1f0ffSBarry Smith Note: 9452ef1f0ffSBarry Smith For efficiency one should use `MatSetValues()` and set several values simultaneously. 9462ef1f0ffSBarry Smith 947b43fc34aSPierre Jolivet .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `InsertMode`, `MatGetValue()`, `MatSetValues()`, 9482ef1f0ffSBarry Smith `MatSetValueLocal()`, `MatSetValuesLocal()` 949c8d6c325SJunchao Zhang @*/ 950c8d6c325SJunchao Zhang static inline PetscErrorCode MatSetValue(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode) 951d71ae5a4SJacob Faibussowitsch { 952c8d6c325SJunchao Zhang return MatSetValues(mat, 1, &i, 1, &j, &va, mode); 9539371c9d4SSatish Balay } 9541620fd73SBarry Smith 955e5e5a7b5SPatrick Sanan /*@C 956e5e5a7b5SPatrick Sanan MatGetValue - Gets a single value from a matrix 9571620fd73SBarry Smith 958e5e5a7b5SPatrick Sanan Not Collective; can only return a value owned by the given process 959e5e5a7b5SPatrick Sanan 960e5e5a7b5SPatrick Sanan Input Parameters: 961e5e5a7b5SPatrick Sanan + mat - the matrix 962e5e5a7b5SPatrick Sanan . row - the row location of the entry 963e5e5a7b5SPatrick Sanan - col - the column location of the entry 964e5e5a7b5SPatrick Sanan 965e5e5a7b5SPatrick Sanan Output Parameter: 966e5e5a7b5SPatrick Sanan . va - the value 967e5e5a7b5SPatrick Sanan 9682ef1f0ffSBarry Smith Level: advanced 9692ef1f0ffSBarry Smith 970e5e5a7b5SPatrick Sanan Notes: 971b43fc34aSPierre Jolivet The matrix must have been assembled with `MatAssemblyBegin()` and `MatAssemblyEnd()` before this call 9722ef1f0ffSBarry Smith 97387497f52SBarry Smith For efficiency one should use `MatGetValues()` and get several values simultaneously. 974e5e5a7b5SPatrick Sanan 97587497f52SBarry Smith See notes for `MatGetValues()`. 976e5e5a7b5SPatrick Sanan 977b43fc34aSPierre Jolivet .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `MatSetValue()`, `MatGetValueLocal()`, `MatGetValues()` 978e5e5a7b5SPatrick Sanan @*/ 979d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode MatGetValue(Mat mat, PetscInt row, PetscInt col, PetscScalar *va) 980d71ae5a4SJacob Faibussowitsch { 9819371c9d4SSatish Balay return MatGetValues(mat, 1, &row, 1, &col, va); 9829371c9d4SSatish Balay } 983e5e5a7b5SPatrick Sanan 984c8d6c325SJunchao Zhang /*@C 9852ef1f0ffSBarry Smith MatSetValueLocal - Inserts or adds a single value into a matrix, using a local numbering of the nodes. 986e5e5a7b5SPatrick Sanan 987e5e5a7b5SPatrick Sanan Not Collective 988e5e5a7b5SPatrick Sanan 989e5e5a7b5SPatrick Sanan Input Parameters: 990c8d6c325SJunchao Zhang + mat - the matrix 99116a05f60SBarry Smith . i - the row location of the entry 99216a05f60SBarry Smith . j - the column location of the entry 99316a05f60SBarry Smith . va - the value to insert 99487497f52SBarry Smith - mode - either `INSERT_VALUES` or `ADD_VALUES` 995e5e5a7b5SPatrick Sanan 9962ef1f0ffSBarry Smith Level: intermediate 9972ef1f0ffSBarry Smith 998e5e5a7b5SPatrick Sanan Notes: 99987497f52SBarry Smith For efficiency one should use `MatSetValuesLocal()` and set several values simultaneously. 1000e5e5a7b5SPatrick Sanan 100187497f52SBarry Smith See notes for `MatSetValuesLocal()` for additional information on when and how this function can be used. 1002e5e5a7b5SPatrick Sanan 10031cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSetValue()`, `MatSetValuesLocal()` 1004c8d6c325SJunchao Zhang @*/ 1005c8d6c325SJunchao Zhang static inline PetscErrorCode MatSetValueLocal(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode) 1006d71ae5a4SJacob Faibussowitsch { 1007c8d6c325SJunchao Zhang return MatSetValuesLocal(mat, 1, &i, 1, &j, &va, mode); 10089371c9d4SSatish Balay } 10091620fd73SBarry Smith 10101620fd73SBarry Smith /*MC 1011d0609cedSBarry Smith MatPreallocateBegin - Begins the block of code that will count the number of nonzeros per 1012bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 1013bd481603SBarry Smith 1014bd481603SBarry Smith Synopsis: 1015aaa7dc30SBarry Smith #include <petscmat.h> 1016d0609cedSBarry Smith PetscErrorCode MatPreallocateBegin(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 1017bd481603SBarry Smith 1018d083f849SBarry Smith Collective 1019bd481603SBarry Smith 1020bd481603SBarry Smith Input Parameters: 1021bd481603SBarry Smith + comm - the communicator that will share the eventually allocated matrix 1022859fcb39SBarry Smith . nrows - the number of LOCAL rows in the matrix 1023859fcb39SBarry Smith - ncols - the number of LOCAL columns in the matrix 1024bd481603SBarry Smith 1025bd481603SBarry Smith Output Parameters: 1026bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 1027a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1028bd481603SBarry Smith 10292ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1030bd481603SBarry Smith 1031bd481603SBarry Smith Notes: 10322ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 10332ef1f0ffSBarry Smith the use of this routine 10342ef1f0ffSBarry Smith 1035d0609cedSBarry Smith This is a macro that handles its own error checking, it does not return an error code. 1036d0609cedSBarry Smith 10372ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1038bd481603SBarry Smith 10392ef1f0ffSBarry Smith Developer Note: 10402ef1f0ffSBarry Smith This is a MACRO not a function because it has a leading { that is closed by `PetscPreallocateFinalize()`. 1041bd481603SBarry Smith 10421cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1043db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()` 1044bd481603SBarry Smith M*/ 10459371c9d4SSatish Balay #define MatPreallocateBegin(comm, nrows, ncols, dnz, onz) \ 10469371c9d4SSatish Balay do { \ 10473ba16761SJacob Faibussowitsch PetscInt __nrows = (nrows), __ncols = (ncols), __rstart, __end = 0; \ 10483ba16761SJacob Faibussowitsch PetscInt PETSC_UNUSED __start; \ 10499566063dSJacob Faibussowitsch PetscCall(PetscCalloc2(__nrows, &(dnz), __nrows, &(onz))); \ 10509566063dSJacob Faibussowitsch PetscCallMPI(MPI_Scan(&__ncols, &__end, 1, MPIU_INT, MPI_SUM, comm)); \ 10519371c9d4SSatish Balay __start = __end - __ncols; \ 10529371c9d4SSatish Balay (void)__start; \ 10539566063dSJacob Faibussowitsch PetscCallMPI(MPI_Scan(&__nrows, &__rstart, 1, MPIU_INT, MPI_SUM, comm)); \ 10545f80ce2aSJacob Faibussowitsch __rstart -= __nrows 10557c922b88SBarry Smith 1056edd03b47SJacob Faibussowitsch #define MatPreallocateInitialize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateBegin()", ) MatPreallocateBegin(__VA_ARGS__) 1057d0609cedSBarry Smith 1058bd481603SBarry Smith /*MC 1059bd481603SBarry Smith MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1060bd481603SBarry Smith inserted using a local number of the rows and columns 1061bd481603SBarry Smith 1062bd481603SBarry Smith Synopsis: 1063aaa7dc30SBarry Smith #include <petscmat.h> 1064c1ac3661SBarry Smith PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1065bd481603SBarry Smith 1066bd481603SBarry Smith Not Collective 1067bd481603SBarry Smith 1068bd481603SBarry Smith Input Parameters: 1069784ac674SJed Brown + map - the row mapping from local numbering to global numbering 1070bd481603SBarry Smith . nrows - the number of rows indicated 10711d73ed98SBarry Smith . rows - the indices of the rows 1072784ac674SJed Brown . cmap - the column mapping from local to global numbering 1073bd481603SBarry Smith . ncols - the number of columns in the matrix 1074bd481603SBarry Smith . cols - the columns indicated 1075bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1076a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1077bd481603SBarry Smith 10782ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1079bd481603SBarry Smith 1080bd481603SBarry Smith Notes: 10812ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 10822ef1f0ffSBarry Smith the use of this routine 1083bd481603SBarry Smith 10842ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1085bd481603SBarry Smith 10861cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1087db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocalRemoveDups()` 1088bd481603SBarry Smith M*/ 108994bad497SJacob Faibussowitsch #define MatPreallocateSetLocal(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 10909371c9d4SSatish 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));) 1091c4f061fbSSatish Balay 1092bd481603SBarry Smith /*MC 1093c1154cd5SBarry Smith MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1094c1154cd5SBarry Smith inserted using a local number of the rows and columns. This version removes any duplicate columns in cols 1095c1154cd5SBarry Smith 1096c1154cd5SBarry Smith Synopsis: 1097c1154cd5SBarry Smith #include <petscmat.h> 1098c1154cd5SBarry Smith PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1099c1154cd5SBarry Smith 1100c1154cd5SBarry Smith Not Collective 1101c1154cd5SBarry Smith 1102c1154cd5SBarry Smith Input Parameters: 1103c1154cd5SBarry Smith + map - the row mapping from local numbering to global numbering 1104c1154cd5SBarry Smith . nrows - the number of rows indicated 1105c1154cd5SBarry Smith . rows - the indices of the rows (these values are mapped to the global values) 1106c1154cd5SBarry Smith . cmap - the column mapping from local to global numbering 1107c1154cd5SBarry Smith . ncols - the number of columns in the matrix (this value will be changed if duplicate columns are found) 1108c1154cd5SBarry Smith . cols - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed) 1109c1154cd5SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1110a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1111c1154cd5SBarry Smith 11122ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1113c1154cd5SBarry Smith 1114c1154cd5SBarry Smith Notes: 11152ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 11162ef1f0ffSBarry Smith the use of this routine 1117c1154cd5SBarry Smith 11182ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1119c1154cd5SBarry Smith 11201cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1121db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()` 1122c1154cd5SBarry Smith M*/ 112394bad497SJacob Faibussowitsch #define MatPreallocateSetLocalRemoveDups(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 11249371c9d4SSatish 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));) 1125c1154cd5SBarry Smith 1126c1154cd5SBarry Smith /*MC 1127d6e23781SBarry Smith MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1128bd481603SBarry Smith inserted using a local number of the rows and columns 1129bd481603SBarry Smith 1130bd481603SBarry Smith Synopsis: 1131aaa7dc30SBarry Smith #include <petscmat.h> 1132d6e23781SBarry Smith PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1133d6e23781SBarry Smith 1134d6e23781SBarry Smith Not Collective 1135d6e23781SBarry Smith 1136d6e23781SBarry Smith Input Parameters: 1137d6e23781SBarry Smith + map - the row mapping from local numbering to global numbering 1138d6e23781SBarry Smith . nrows - the number of rows indicated 1139d6e23781SBarry Smith . rows - the indices of the rows 1140d6e23781SBarry Smith . cmap - the column mapping from local to global numbering 1141d6e23781SBarry Smith . ncols - the number of columns in the matrix 1142d6e23781SBarry Smith . cols - the columns indicated 1143d6e23781SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1144a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1145d6e23781SBarry Smith 11462ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1147d6e23781SBarry Smith 1148d6e23781SBarry Smith Notes: 11492ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 11502ef1f0ffSBarry Smith the use of this routine 1151d6e23781SBarry Smith 11522ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1153d6e23781SBarry Smith 11541cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1155db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()` 1156d6e23781SBarry Smith M*/ 115794bad497SJacob Faibussowitsch #define MatPreallocateSetLocalBlock(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 11589371c9d4SSatish 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));) 1159d6e23781SBarry Smith 1160d6e23781SBarry Smith /*MC 1161d6e23781SBarry Smith MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1162d6e23781SBarry Smith inserted using a local number of the rows and columns 1163d6e23781SBarry Smith 1164d6e23781SBarry Smith Synopsis: 1165d6e23781SBarry Smith #include <petscmat.h> 1166d6e23781SBarry Smith PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1167bd481603SBarry Smith 1168bd481603SBarry Smith Not Collective 1169bd481603SBarry Smith 1170bd481603SBarry Smith Input Parameters: 1171bd481603SBarry Smith + map - the mapping between local numbering and global numbering 1172bd481603SBarry Smith . nrows - the number of rows indicated 11731d73ed98SBarry Smith . rows - the indices of the rows 1174bd481603SBarry Smith . ncols - the number of columns in the matrix 1175bd481603SBarry Smith . cols - the columns indicated 1176bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1177a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1178bd481603SBarry Smith 11792ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1180bd481603SBarry Smith 1181bd481603SBarry Smith Notes: 11822ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 11832ef1f0ffSBarry Smith the use of this routine 1184bd481603SBarry Smith 11852ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 1186bd481603SBarry Smith 11871cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()` 1188db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSetLocal()` 1189bd481603SBarry Smith M*/ 119094bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetLocalBlock(map, nrows, rows, ncols, cols, dnz, onz) \ 11919371c9d4SSatish 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));) 1192e83a5d19SLisandro Dalcin 1193bd481603SBarry Smith /*MC 1194bd481603SBarry Smith MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1195bd481603SBarry Smith inserted using a local number of the rows and columns 1196bd481603SBarry Smith 1197bd481603SBarry Smith Synopsis: 1198aaa7dc30SBarry Smith #include <petscmat.h> 1199c1ac3661SBarry Smith PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1200bd481603SBarry Smith 1201bd481603SBarry Smith Not Collective 1202bd481603SBarry Smith 1203bd481603SBarry Smith Input Parameters: 120464075487SBarry Smith + row - the row 1205bd481603SBarry Smith . ncols - the number of columns in the matrix 1206a50f8bf6SHong Zhang - cols - the columns indicated 1207a50f8bf6SHong Zhang 1208a50f8bf6SHong Zhang Output Parameters: 1209a50f8bf6SHong Zhang + dnz - the array that will be passed to the matrix preallocation routines 1210a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1211bd481603SBarry Smith 12122ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1213bd481603SBarry Smith 1214bd481603SBarry Smith Notes: 12152ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 12162ef1f0ffSBarry Smith the use of this routine 1217bd481603SBarry Smith 12182ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 1219bd481603SBarry Smith 1220d0609cedSBarry Smith This is a MACRO not a function because it uses variables declared in MatPreallocateBegin(). 12211620fd73SBarry Smith 12221cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1223db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSetLocal()` 1224bd481603SBarry Smith M*/ 12259371c9d4SSatish Balay #define MatPreallocateSet(row, nc, cols, dnz, onz) \ 12269371c9d4SSatish 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) { \ 122764075487SBarry Smith if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \ 1228a6042fd4SStefano Zampini else if (dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \ 12299371c9d4SSatish Balay }) 12307c922b88SBarry Smith 1231bd481603SBarry Smith /*MC 1232d6e23781SBarry Smith MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1233bd481603SBarry Smith inserted using a local number of the rows and columns 1234bd481603SBarry Smith 1235bd481603SBarry Smith Synopsis: 1236aaa7dc30SBarry Smith #include <petscmat.h> 1237d6e23781SBarry Smith PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1238bd481603SBarry Smith 1239bd481603SBarry Smith Not Collective 1240bd481603SBarry Smith 1241bd481603SBarry Smith Input Parameters: 1242bd481603SBarry Smith + nrows - the number of rows indicated 12431d73ed98SBarry Smith . rows - the indices of the rows 1244bd481603SBarry Smith . ncols - the number of columns in the matrix 1245bd481603SBarry Smith . cols - the columns indicated 1246bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1247a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1248bd481603SBarry Smith 12492ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1250bd481603SBarry Smith 1251bd481603SBarry Smith Notes: 12522ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 12532ef1f0ffSBarry Smith the use of this routine 1254bd481603SBarry Smith 12552ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 1256bd481603SBarry Smith 1257d0609cedSBarry Smith This is a MACRO not a function because it uses variables declared in MatPreallocateBegin(). 12581620fd73SBarry Smith 12591cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateBegin()`, 1260db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()` 1261bd481603SBarry Smith M*/ 126294bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetBlock(row, nc, cols, dnz, onz) \ 12639371c9d4SSatish Balay PetscMacroReturnStandard(for (PetscInt __i = 0; __i < nc; __i++) { \ 1264d3d32019SBarry Smith if (cols[__i] >= __end) onz[row - __rstart]++; \ 1265a6042fd4SStefano Zampini else if (cols[__i] >= row && dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \ 12669371c9d4SSatish Balay }) 1267d3d32019SBarry Smith 1268bd481603SBarry Smith /*MC 1269a6042fd4SStefano Zampini MatPreallocateLocation - An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists 127016371a99SBarry Smith 127116371a99SBarry Smith Synopsis: 1272aaa7dc30SBarry Smith #include <petscmat.h> 127316371a99SBarry Smith PetscErrorCode MatPreallocateLocations(Mat A,PetscInt row,PetscInt ncols,PetscInt *cols,PetscInt *dnz,PetscInt *onz) 127416371a99SBarry Smith 127516371a99SBarry Smith Not Collective 127616371a99SBarry Smith 127716371a99SBarry Smith Input Parameters: 1278a2b725a8SWilliam Gropp + A - matrix 127916371a99SBarry Smith . row - row where values exist (must be local to this process) 128016371a99SBarry Smith . ncols - number of columns 128116371a99SBarry Smith . cols - columns with nonzeros 128216371a99SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1283a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 128416371a99SBarry Smith 12852ef1f0ffSBarry Smith Level: deprecated (since v3.19) 128616371a99SBarry Smith 128716371a99SBarry Smith Notes: 12882ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 12892ef1f0ffSBarry Smith the use of this routine 129016371a99SBarry Smith 12912ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 129216371a99SBarry Smith 129316371a99SBarry Smith This is a MACRO not a function because it uses a bunch of variables private to the MatPreallocation.... routines. 129416371a99SBarry Smith 12951cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1296db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()` 129716371a99SBarry Smith M*/ 1298d0609cedSBarry 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)) 129916371a99SBarry Smith 130016371a99SBarry Smith /*MC 1301d0609cedSBarry Smith MatPreallocateEnd - Ends the block of code that will count the number of nonzeros per 1302bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 1303bd481603SBarry Smith 1304bd481603SBarry Smith Synopsis: 1305aaa7dc30SBarry Smith #include <petscmat.h> 1306d0609cedSBarry Smith PetscErrorCode MatPreallocateEnd(PetscInt *dnz, PetscInt *onz) 1307bd481603SBarry Smith 1308d083f849SBarry Smith Collective 1309bd481603SBarry Smith 1310bd481603SBarry Smith Input Parameters: 131116371a99SBarry Smith + dnz - the array that was be passed to the matrix preallocation routines 1312a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1313bd481603SBarry Smith 13142ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1315bd481603SBarry Smith 1316bd481603SBarry Smith Notes: 13172ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 13182ef1f0ffSBarry Smith the use of this routine 1319d0609cedSBarry Smith 13202ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1321bd481603SBarry Smith 13222ef1f0ffSBarry Smith Developer Note: 1323d0609cedSBarry Smith This is a MACRO not a function because it closes the { started in MatPreallocateBegin(). 13241620fd73SBarry Smith 13251cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1326db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()` 1327bd481603SBarry Smith M*/ 13289371c9d4SSatish Balay #define MatPreallocateEnd(dnz, onz) \ 13299371c9d4SSatish Balay PetscCall(PetscFree2(dnz, onz)); \ 13309371c9d4SSatish Balay } \ 13319371c9d4SSatish Balay while (0) 1332d0609cedSBarry Smith 1333edd03b47SJacob Faibussowitsch #define MatPreallocateFinalize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateEnd()", ) MatPreallocateEnd(__VA_ARGS__) 13347c922b88SBarry Smith 13357b80b807SBarry Smith /* Routines unique to particular data structures */ 1336014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat, void *); 1337698d4c6aSKris Buschelman 1338014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat, IS *, IS *); 1339014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat, PetscInt *, PetscInt *[], PetscInt *); 1340698d4c6aSKris Buschelman 1341014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat, PetscInt[]); 1342014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat, PetscInt[]); 1343014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1344014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1345014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1346014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *, PetscInt, PetscBool); 13477b80b807SBarry Smith 1348a96a251dSBarry Smith #define MAT_SKIP_ALLOCATION -4 1349a96a251dSBarry Smith 1350014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1351014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1352014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat, PetscInt, const PetscInt[]); 135319b08ed1SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetTotalPreallocation(Mat, PetscInt); 1354273d9f13SBarry Smith 1355014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1356014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1357014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1358014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]); 1359014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 1360014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]); 1361014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 1362014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat, PetscInt[], PetscInt[], PetscInt[]); 1363b44e7856SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat, Mat *); 1364252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeqRankZero(Mat, Mat *); 1365014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat, PetscScalar[]); 1366014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat, PetscScalar[]); 13679230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat, Mat *, Mat *, const PetscInt *[]); 13689230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat, Mat *, Mat *, const PetscInt *[]); 1369014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat, Mat *); 1370273d9f13SBarry Smith 137149a6ff4bSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat, PetscInt *); 1372ad16ce7aSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseSetLDA(Mat, PetscInt); 1373edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatDenseSetLDA()", ) static inline PetscErrorCode MatSeqDenseSetLDA(Mat A, PetscInt lda) 1374d71ae5a4SJacob Faibussowitsch { 13759371c9d4SSatish Balay return MatDenseSetLDA(A, lda); 13769371c9d4SSatish Balay } 1377014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat, Mat *); 13781b807ce4Svictorle 1379621e819fSSatish Balay PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1380621e819fSSatish Balay 1381014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStoreValues(Mat); 1382014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat); 13832e8a6d31SBarry Smith 1384014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat, IS *); 13857cfe41e4SPatrick Farrell PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat, IS *); 13867b80b807SBarry Smith /* 13877b80b807SBarry Smith These routines are not usually accessed directly, rather solving is 138894b7f48cSBarry Smith done through the KSP and PC interfaces. 13897b80b807SBarry Smith */ 13907b80b807SBarry Smith 139176bdecfbSBarry Smith /*J 13922ef1f0ffSBarry Smith MatOrderingType - String with the name of a PETSc matrix ordering. These orderings are most commonly used 13932ef1f0ffSBarry Smith to reduce fill in sparse factorizations. 1394d9274352SBarry Smith 1395d9274352SBarry Smith Level: beginner 1396d9274352SBarry Smith 13972c7c0729SBarry Smith Notes: 139816a05f60SBarry Smith If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and instead the external factorization solver package called utilizes one 139916a05f60SBarry Smith of its own. 14002c7c0729SBarry Smith 14012ef1f0ffSBarry Smith There is no `MatOrdering` object, the ordering is obtained directly from the matrix with `MatGetOrdering()` 14022ef1f0ffSBarry Smith 14032ef1f0ffSBarry Smith Developer Note: 14042ef1f0ffSBarry Smith This API should be converted to an API similar to those for `MatColoring` and `MatPartitioning` 14052ef1f0ffSBarry Smith 14061cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `MatGetFactor()`, `MatGetOrdering()`, `MatColoringType`, `MatPartitioningType`, `MatCoarsenType`, `MatCoarsenType`, 14072ef1f0ffSBarry Smith `PCFactorSetOrderingType()` 140876bdecfbSBarry Smith J*/ 140919fd82e9SBarry Smith typedef const char *MatOrderingType; 14102692d6eeSBarry Smith #define MATORDERINGNATURAL "natural" 14112692d6eeSBarry Smith #define MATORDERINGND "nd" 14122692d6eeSBarry Smith #define MATORDERING1WD "1wd" 14132692d6eeSBarry Smith #define MATORDERINGRCM "rcm" 14142692d6eeSBarry Smith #define MATORDERINGQMD "qmd" 14152692d6eeSBarry Smith #define MATORDERINGROWLENGTH "rowlength" 1416510184a7SJed Brown #define MATORDERINGWBM "wbm" 1417fc1bef75SJed Brown #define MATORDERINGSPECTRAL "spectral" 1418312e372aSBarry Smith #define MATORDERINGAMD "amd" /* only works if UMFPACK is installed with PETSc */ 1419048412efSPablo Brubeck #define MATORDERINGMETISND "metisnd" /* only works if METIS is installed with PETSc */ 14209bd791bbSBarry 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 */ 14212c7c0729SBarry Smith #define MATORDERINGEXTERNAL "external" /* uses an ordering type internal to the factorization package */ 1422b12f92e5SBarry Smith 142319fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOrdering(Mat, MatOrderingType, IS *, IS *); 1424140e18c1SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOrderingList(PetscFunctionList *); 1425bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatOrderingRegister(const char[], PetscErrorCode (*)(Mat, MatOrderingType, IS *, IS *)); 1426140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatOrderingList; 1427d4fbbf0eSBarry Smith 1428013e2dc7SBarry Smith #include "petscmatcoarsen.h" 1429013e2dc7SBarry Smith 1430014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat, PetscReal, IS, IS); 1431fc1bef75SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat, PetscReal, PetscBool, Mat *); 1432a2ce50c7SBarry Smith 14334ac6704cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetPreferredOrdering(Mat, MatFactorType, MatOrderingType *); 14344ac6704cSBarry Smith 1435d91e6319SBarry Smith /*S 14362ef1f0ffSBarry Smith MatFactorShiftType - Type of numeric shift used for factorizations 1437d90ac83dSHong Zhang 14382ef1f0ffSBarry Smith Values: 14392ef1f0ffSBarry Smith + `MAT_SHIFT_NONE` - do not shift the matrix diagonal entries 14402ef1f0ffSBarry Smith . `MAT_SHIFT_NONZERO` - shift the entries to be non-zero 14412ef1f0ffSBarry Smith . `MAT_SHIFT_POSITIVE_DEFINITE` - shift the entries to force the factorization to be positive definite 14422ef1f0ffSBarry Smith - `MAT_SHIFT_INBLOCKS` - only shift the factors inside the small dense diagonal blocks of the matrix, for example with `MATBAIJ` 1443d90ac83dSHong Zhang 14442ef1f0ffSBarry Smith Level: intermediate 14452ef1f0ffSBarry Smith 14461cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `PCFactorSetShiftType()` 1447d90ac83dSHong Zhang S*/ 14489371c9d4SSatish Balay typedef enum { 14499371c9d4SSatish Balay MAT_SHIFT_NONE, 14509371c9d4SSatish Balay MAT_SHIFT_NONZERO, 14519371c9d4SSatish Balay MAT_SHIFT_POSITIVE_DEFINITE, 14529371c9d4SSatish Balay MAT_SHIFT_INBLOCKS 14539371c9d4SSatish Balay } MatFactorShiftType; 14546a6fc655SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypes[]; 14555e9742b9SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypesDetail[]; 1456d90ac83dSHong Zhang 1457d90ac83dSHong Zhang /*S 1458ec5066bdSBarry Smith MatFactorError - indicates what type of error was generated in a matrix factorization 14599aa7eafdSHong Zhang 14602ef1f0ffSBarry Smith Values: 14612ef1f0ffSBarry Smith + `MAT_FACTOR_NOERROR` - there was no error during the factorization 14622ef1f0ffSBarry Smith . `MAT_FACTOR_STRUCT_ZEROPIVOT` - there was a missing entry in a diagonal location of the matrix 14632ef1f0ffSBarry Smith . `MAT_FACTOR_NUMERIC_ZEROPIVOT` - there was a (near) zero pivot during the factorization 14642ef1f0ffSBarry Smith . `MAT_FACTOR_OUTMEMORY` - the factorization has run out of memory 14652ef1f0ffSBarry Smith - `MAT_FACTOR_OTHER` - some other error has occurred. 14669aa7eafdSHong Zhang 14672ef1f0ffSBarry Smith Level: intermediate 146800e125f8SBarry Smith 14692ef1f0ffSBarry Smith Note: 14702ef1f0ffSBarry Smith When a factorization is done in a preconditioner `PC` the error may be propagated up to a `PCFailedReason` or a `KSPConvergedReason` 14712ef1f0ffSBarry Smith 14721cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `MatFactorGetError()`, `MatFactorGetErrorZeroPivot()`, `MatFactorClearError()`, 14732ef1f0ffSBarry Smith `PCFailedReason`, `PCGetFailedReason()`, `KSPConvergedReason` 14749aa7eafdSHong Zhang S*/ 14759371c9d4SSatish Balay typedef enum { 14769371c9d4SSatish Balay MAT_FACTOR_NOERROR, 14779371c9d4SSatish Balay MAT_FACTOR_STRUCT_ZEROPIVOT, 14789371c9d4SSatish Balay MAT_FACTOR_NUMERIC_ZEROPIVOT, 14799371c9d4SSatish Balay MAT_FACTOR_OUTMEMORY, 14809371c9d4SSatish Balay MAT_FACTOR_OTHER 14819371c9d4SSatish Balay } MatFactorError; 14829aa7eafdSHong Zhang 148300e125f8SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat, MatFactorError *); 1484b8b68cfdSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat); 14857b6c816cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat, PetscReal *, PetscInt *); 148600e125f8SBarry Smith 14879aa7eafdSHong Zhang /*S 1488422a814eSBarry Smith MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization 1489b00f7748SHong Zhang 1490b00f7748SHong Zhang Level: developer 1491b00f7748SHong Zhang 14922ef1f0ffSBarry Smith Note: 14932ef1f0ffSBarry Smith You can use `MatFactorInfoInitialize()` to set default values. 1494b00f7748SHong Zhang 14952ef1f0ffSBarry Smith Fortran Note: 14962ef1f0ffSBarry Smith The data is available in a double precision arrays of size `MAT_FACTORINFO_SIZE` 14972ef1f0ffSBarry Smith 14981cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatInfo`, `MatGetFactor()`, `MatLUFactorSymbolic()`, `MatILUFactorSymbolic()`, `MatCholeskyFactorSymbolic()`, 14992ef1f0ffSBarry Smith `MatICCFactorSymbolic()`, `MatICCFactor()`, `MatFactorInfoInitialize()` 1500b00f7748SHong Zhang S*/ 1501b00f7748SHong Zhang typedef struct { 150215e8a5b3SHong Zhang PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 150385317021SBarry Smith PetscReal usedt; 150415e8a5b3SHong Zhang PetscReal dt; /* drop tolerance */ 1505b00f7748SHong Zhang PetscReal dtcol; /* tolerance for pivoting */ 150615e8a5b3SHong Zhang PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 150767e28bfeSBarry Smith PetscReal fill; /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */ 1508348344bbSBarry Smith PetscReal levels; /* ICC/ILU(levels) */ 1509bcd9e38bSBarry Smith PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 1510bcd9e38bSBarry Smith factorization may be faster if do not pivot */ 151115e8a5b3SHong Zhang PetscReal zeropivot; /* pivot is called zero if less than this */ 1512f4db908eSBarry Smith PetscReal shifttype; /* type of shift added to matrix factor to prevent zero pivots */ 1513f4db908eSBarry Smith PetscReal shiftamount; /* how large the shift is */ 151415e8a5b3SHong Zhang } MatFactorInfo; 1515ffa6d0a5SLois Curfman McInnes 1516014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo *); 15179a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat, IS, const MatFactorInfo *); 15189a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 15199a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat, Mat, const MatFactorInfo *); 15209a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactor(Mat, IS, IS, const MatFactorInfo *); 15219a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactor(Mat, IS, IS, const MatFactorInfo *); 15229a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *); 15239a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *); 15249a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 15259a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactor(Mat, IS, const MatFactorInfo *); 15269a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat, Mat, const MatFactorInfo *); 15273f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactor(Mat, IS, const MatFactorInfo *); 15283f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 15293f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorNumeric(Mat, Mat, const MatFactorInfo *); 1530014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInertia(Mat, PetscInt *, PetscInt *, PetscInt *); 1531014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolve(Mat, Vec, Vec); 1532014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat, Vec, Vec); 1533014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat, Vec, Vec); 1534014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat, Vec, Vec, Vec); 1535014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat, Vec, Vec); 1536014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat, Vec, Vec, Vec); 1537014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolves(Mat, Vecs, Vecs); 15387c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat); 15397c2f51b8SStefano Zampini 15409371c9d4SSatish Balay typedef enum { 15419371c9d4SSatish Balay MAT_FACTOR_SCHUR_UNFACTORED, 15429371c9d4SSatish Balay MAT_FACTOR_SCHUR_FACTORED, 15439371c9d4SSatish Balay MAT_FACTOR_SCHUR_INVERTED 15449371c9d4SSatish Balay } MatFactorSchurStatus; 15458e7ba810SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat, IS); 15467c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat, Mat *, MatFactorSchurStatus *); 15477c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat, Mat *, MatFactorSchurStatus); 15485a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat); 15497c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat, Mat *, MatFactorSchurStatus *); 15505a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat, Vec, Vec); 15515a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat, Vec, Vec); 15526dba178dSStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat); 1553bb5a7306SBarry Smith 15548a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqDenseInvert(Mat); 1555d91e6319SBarry Smith /*E 1556d91e6319SBarry Smith MatSORType - What type of (S)SOR to perform 1557bb1eb677SSatish Balay 15582ef1f0ffSBarry Smith Values: 15592ef1f0ffSBarry Smith + `SOR_FORWARD_SWEEP` - do a sweep from the first row of the matrix to the last 15602ef1f0ffSBarry Smith . `SOR_BACKWARD_SWEEP` - do a sweep from the last row to the first 15612ef1f0ffSBarry Smith . `SOR_SYMMETRIC_SWEEP` - do a sweep from the first row to the last and then back to the first 15622ef1f0ffSBarry Smith . `SOR_LOCAL_FORWARD_SWEEP` - each MPI rank does its own forward sweep with no communication 15632ef1f0ffSBarry Smith . `SOR_LOCAL_BACKWARD_SWEEP` - each MPI rank does its own backward sweep with no communication 15642ef1f0ffSBarry Smith . `SOR_LOCAL_SYMMETRIC_SWEEP` - each MPI rank does its own symmetric sweep with no communication 15652ef1f0ffSBarry Smith . `SOR_ZERO_INITIAL_GUESS` - indicates the initial solution is zero so the sweep can avoid unneeded computation 15662ef1f0ffSBarry Smith . `SOR_EISENSTAT` - apply the Eisentat application of SOR, see `PCEISENSTAT` 15672ef1f0ffSBarry Smith . `SOR_APPLY_UPPER` - multiply by the upper triangular portion of the matrix 15682ef1f0ffSBarry Smith - `SOR_APPLY_LOWER` - multiply by the lower triangular portion of the matrix 15692ef1f0ffSBarry Smith 1570d91e6319SBarry Smith Level: beginner 1571d91e6319SBarry Smith 15722ef1f0ffSBarry Smith Note: 15732ef1f0ffSBarry Smith These may be bitwise ORd together 1574d9274352SBarry Smith 15752ef1f0ffSBarry Smith Developer Note: 15762ef1f0ffSBarry Smith Since `MatSORType` may be bitwise ORd together, so do not change the numerical values below 1577d91e6319SBarry Smith 15781cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSOR()` 1579d91e6319SBarry Smith E*/ 15809371c9d4SSatish Balay typedef enum { 15819371c9d4SSatish Balay SOR_FORWARD_SWEEP = 1, 15829371c9d4SSatish Balay SOR_BACKWARD_SWEEP = 2, 15839371c9d4SSatish Balay SOR_SYMMETRIC_SWEEP = 3, 15849371c9d4SSatish Balay SOR_LOCAL_FORWARD_SWEEP = 4, 15859371c9d4SSatish Balay SOR_LOCAL_BACKWARD_SWEEP = 8, 15869371c9d4SSatish Balay SOR_LOCAL_SYMMETRIC_SWEEP = 12, 15879371c9d4SSatish Balay SOR_ZERO_INITIAL_GUESS = 16, 15889371c9d4SSatish Balay SOR_EISENSTAT = 32, 15899371c9d4SSatish Balay SOR_APPLY_UPPER = 64, 15909371c9d4SSatish Balay SOR_APPLY_LOWER = 128 15919371c9d4SSatish Balay } MatSORType; 1592014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSOR(Mat, Vec, PetscReal, MatSORType, PetscReal, PetscInt, PetscInt, Vec); 15938ed539a5SBarry Smith 15947086a01eSPeter Brune /*S 15957086a01eSPeter Brune MatColoring - Object for managing the coloring of matrices. 15967086a01eSPeter Brune 15977086a01eSPeter Brune Level: beginner 15987086a01eSPeter Brune 1599ec5066bdSBarry Smith Notes: 160087497f52SBarry 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 160187497f52SBarry Smith matrix comes from via `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors). 1602ec5066bdSBarry Smith 160387497f52SBarry Smith Once a coloring is available `MatFDColoringCreate()` creates an object that can be used to efficiently compute Jacobians using that coloring. This 16042ef1f0ffSBarry Smith same object can also be used to efficiently convert data created by Automatic Differentiation tools to PETSc sparse matrices. 1605ec5066bdSBarry Smith 16061cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `MatFDColoringCreate()`, `MatColoringWeightType`, `ISColoring`, `MatFDColoring`, `DMCreateColoring()`, `MatColoringCreate()`, 16072ef1f0ffSBarry Smith `MatPartitioning`, `MatColoringType`, `MatPartitioningType`, `MatOrderingType`, `MatColoringSetWeightType()`, 16082ef1f0ffSBarry Smith `MatColoringSetWeights()`, `MatCoarsenType`, `MatCoarsen` 16097086a01eSPeter Brune S*/ 1610d4db15c4SBarry Smith typedef struct _p_MatColoring *MatColoring; 1611d4db15c4SBarry Smith 1612d4db15c4SBarry Smith /*J 1613d4db15c4SBarry Smith MatColoringType - String with the name of a PETSc matrix coloring 1614d9274352SBarry Smith 1615d9274352SBarry Smith Level: beginner 1616d9274352SBarry Smith 16171cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatFDColoringCreate()`, `MatColoringSetType()`, `MatColoring` 161876bdecfbSBarry Smith J*/ 161919fd82e9SBarry Smith typedef const char *MatColoringType; 16205567d71aSPeter Brune #define MATCOLORINGJP "jp" 1621b9acb617SPeter Brune #define MATCOLORINGPOWER "power" 16222692d6eeSBarry Smith #define MATCOLORINGNATURAL "natural" 16232692d6eeSBarry Smith #define MATCOLORINGSL "sl" 16242692d6eeSBarry Smith #define MATCOLORINGLF "lf" 16252692d6eeSBarry Smith #define MATCOLORINGID "id" 16268121bdceSPeter Brune #define MATCOLORINGGREEDY "greedy" 1627b12f92e5SBarry Smith 16288ac6da0aSPeter Brune /*E 16292ef1f0ffSBarry Smith MatColoringWeightType - Type of weight scheme used for the coloring algorithm 16308ac6da0aSPeter Brune 16312ef1f0ffSBarry Smith Values: 163287497f52SBarry Smith + `MAT_COLORING_RANDOM` - Random weights 163387497f52SBarry Smith . `MAT_COLORING_LEXICAL` - Lexical weighting based upon global numbering. 163487497f52SBarry Smith - `MAT_COLORING_LF` - Last-first weighting. 16358ac6da0aSPeter Brune 16368ac6da0aSPeter Brune Level: intermediate 16378ac6da0aSPeter Brune 16381cc06b55SBarry Smith .seealso: [](ch_matrices), `MatColoring`, `MatColoringCreate()`, `MatColoringSetWeightType()`, `MatColoringSetWeights()` 16398ac6da0aSPeter Brune E*/ 16409371c9d4SSatish Balay typedef enum { 16419371c9d4SSatish Balay MAT_COLORING_WEIGHT_RANDOM, 16429371c9d4SSatish Balay MAT_COLORING_WEIGHT_LEXICAL, 16439371c9d4SSatish Balay MAT_COLORING_WEIGHT_LF, 16449371c9d4SSatish Balay MAT_COLORING_WEIGHT_SL 16459371c9d4SSatish Balay } MatColoringWeightType; 16468ac6da0aSPeter Brune 1647335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat, MatColoring *); 1648d7f2a307SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat, PetscInt, PetscInt *); 1649335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring *); 1650335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring, PetscViewer); 1651335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring, MatColoringType); 1652335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring); 1653335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring, PetscInt); 1654335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring, PetscInt *); 1655335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring, PetscInt); 1656335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring, PetscInt *); 1657335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring, ISColoring *); 1658335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[], PetscErrorCode (*)(MatColoring)); 1659014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat, PetscInt, PetscInt, ISColoringValue[], ISColoring *); 16608ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring, MatColoringWeightType); 1661c29971fcSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring, PetscReal *, PetscInt *); 16628ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring, PetscReal **, PetscInt **lperm); 1663bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring, ISColoring); 1664edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 10, 0, "MatColoringTest()", ) static inline PetscErrorCode MatColoringTestValid(MatColoring matcoloring, ISColoring iscoloring) 1665d71ae5a4SJacob Faibussowitsch { 16669371c9d4SSatish Balay return MatColoringTest(matcoloring, iscoloring); 16679371c9d4SSatish Balay } 1668bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat, ISColoring); 1669639f9d9dSBarry Smith 1670d9274352SBarry Smith /*S 167187497f52SBarry Smith MatFDColoring - Object for computing a sparse Jacobian via finite differences with coloring 1672639f9d9dSBarry Smith 1673d9274352SBarry Smith Level: beginner 1674d9274352SBarry Smith 1675ec5066bdSBarry Smith Notes: 167687497f52SBarry Smith This object is creating utilizing a coloring provided by the `MatColoring` object or `DMCreateColoring()` 1677ec5066bdSBarry Smith 16782ef1f0ffSBarry Smith The `SNES` option `-snes_fd_coloring` will cause the Jacobian needed by `SNES` to be computed via a use of this object 16792ef1f0ffSBarry Smith 16801cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatFDColoringCreate()`, `MatFDColoringSetFunction()`, `MatColoring`, `DMCreateColoring()` 1681d9274352SBarry Smith S*/ 1682e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring; 1683639f9d9dSBarry Smith 1684014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat, ISColoring, MatFDColoring *); 1685014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring *); 1686014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring, PetscViewer); 1687014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring, PetscErrorCode (*)(void), void *); 1688014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring, PetscErrorCode (**)(void), void **); 1689014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring, PetscReal, PetscReal); 1690014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring); 1691d1e9a80fSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat, MatFDColoring, Vec, void *); 1692014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring, Vec); 1693edaa7c33SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring, PetscInt *, const PetscInt *[]); 1694f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat, ISColoring, MatFDColoring); 1695f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring, PetscInt, PetscInt); 1696bdaf1daeSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat, MatFDColoring, const PetscScalar *); 1697b1683b59SHong Zhang 1698b1683b59SHong Zhang /*S 1699b9af6bddSHong Zhang MatTransposeColoring - Object for computing a sparse matrix product C=A*B^T via coloring 1700b1683b59SHong Zhang 17012ef1f0ffSBarry Smith Level: developer 1702b1683b59SHong Zhang 17031cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatProductType`, `MatTransposeColoringCreate()` 1704b1683b59SHong Zhang S*/ 1705b9af6bddSHong Zhang typedef struct _p_MatTransposeColoring *MatTransposeColoring; 1706b1683b59SHong Zhang 1707014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat, ISColoring, MatTransposeColoring *); 1708014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring, Mat, Mat); 1709014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring, Mat, Mat); 1710014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring *); 1711b1683b59SHong Zhang 1712d9274352SBarry Smith /*S 1713d9274352SBarry Smith MatPartitioning - Object for managing the partitioning of a matrix or graph 1714d9274352SBarry Smith 1715d9274352SBarry Smith Level: beginner 1716d9274352SBarry Smith 171787497f52SBarry Smith Note: 171887497f52SBarry Smith There is also a `PetscPartitioner` object that provides the same functionality. It can utilize the `MatPartitioning` operations 171987497f52SBarry Smith via `PetscPartitionerSetType`(p,`PETSCPARTITIONERMATPARTITIONING`) 1720ec5066bdSBarry Smith 1721ec5066bdSBarry Smith Developers Note: 17222ef1f0ffSBarry Smith It is an extra maintenance and documentation cost to have two objects with the same functionality. `PetscPartitioner` should be removed 1723ec5066bdSBarry Smith 17241cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioningType`, `MatColoring`, `MatGetOrdering()`, `MatOrderingType`, 17252ef1f0ffSBarry Smith `MatCoarsenType`, `MatCoarsenType` 1726d9274352SBarry Smith S*/ 172791e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning; 1728d9274352SBarry Smith 172976bdecfbSBarry Smith /*J 17308f6c3df8SBarry Smith MatPartitioningType - String with the name of a PETSc matrix partitioning 1731d9274352SBarry Smith 1732d9274352SBarry Smith Level: beginner 17330d04baf8SBarry Smith dm 17341cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioning`, `MatPartitioningSetType()`, `MatColoringType`, `MatOrderingType`, 17352ef1f0ffSBarry Smith `MatCoarsenType`, `MatCoarsenType` 173676bdecfbSBarry Smith J*/ 173719fd82e9SBarry Smith typedef const char *MatPartitioningType; 17382692d6eeSBarry Smith #define MATPARTITIONINGCURRENT "current" 1739aa1e27eaSFande Kong #define MATPARTITIONINGAVERAGE "average" 17402692d6eeSBarry Smith #define MATPARTITIONINGSQUARE "square" 17412692d6eeSBarry Smith #define MATPARTITIONINGPARMETIS "parmetis" 17422692d6eeSBarry Smith #define MATPARTITIONINGCHACO "chaco" 17432692d6eeSBarry Smith #define MATPARTITIONINGPARTY "party" 174450d91057SBarry Smith #define MATPARTITIONINGPTSCOTCH "ptscotch" 174588d2ac2bSFande Kong #define MATPARTITIONINGHIERARCH "hierarch" 174671306c60Sjroman 1747014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm, MatPartitioning *); 174819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning, MatPartitioningType); 1749014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning, PetscInt); 1750014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning, Mat); 1751252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetNumberVertexWeights(MatPartitioning, PetscInt); 1752014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning, const PetscInt[]); 1753014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning, const PetscReal[]); 1754ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningSetUseEdgeWeights(MatPartitioning, PetscBool); 1755ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningGetUseEdgeWeights(MatPartitioning, PetscBool *); 1756014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning, IS *); 1757fdd1c351SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning, IS *); 1758668144dbSFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning, IS); 1759f3ad2dabSStefano Zampini PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning, IS *); 1760014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning *); 1761bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[], PetscErrorCode (*)(MatPartitioning)); 1762014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning, PetscViewer); 1763fe2efc57SMark PETSC_EXTERN PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning, PetscObject, const char[]); 1764014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning); 176519fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning, MatPartitioningType *); 1766ca161407SBarry Smith 176727538973SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning part); 1768014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 1769014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *); 17700752156aSBarry Smith 17719371c9d4SSatish Balay typedef enum { 17729371c9d4SSatish Balay MP_CHACO_MULTILEVEL = 1, 17739371c9d4SSatish Balay MP_CHACO_SPECTRAL = 2, 17749371c9d4SSatish Balay MP_CHACO_LINEAR = 4, 17759371c9d4SSatish Balay MP_CHACO_RANDOM = 5, 17769371c9d4SSatish Balay MP_CHACO_SCATTERED = 6 17779371c9d4SSatish Balay } MPChacoGlobalType; 17786a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoGlobalTypes[]; 17799371c9d4SSatish Balay typedef enum { 17809371c9d4SSatish Balay MP_CHACO_KERNIGHAN = 1, 17819371c9d4SSatish Balay MP_CHACO_NONE = 2 17829371c9d4SSatish Balay } MPChacoLocalType; 17836a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoLocalTypes[]; 17849371c9d4SSatish Balay typedef enum { 17859371c9d4SSatish Balay MP_CHACO_LANCZOS = 0, 17869371c9d4SSatish Balay MP_CHACO_RQI = 1 17879371c9d4SSatish Balay } MPChacoEigenType; 17886a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoEigenTypes[]; 1789b6956c12SJose Roman 1790014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType); 1791014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning, MPChacoGlobalType *); 1792014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType); 1793014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning, MPChacoLocalType *); 1794014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning, PetscReal); 1795014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning, MPChacoEigenType); 1796014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning, MPChacoEigenType *); 1797014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal); 1798014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning, PetscReal *); 1799014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt); 1800014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning, PetscInt *); 180171306c60Sjroman 180271306c60Sjroman #define MP_PARTY_OPT "opt" 180371306c60Sjroman #define MP_PARTY_LIN "lin" 180471306c60Sjroman #define MP_PARTY_SCA "sca" 180571306c60Sjroman #define MP_PARTY_RAN "ran" 180671306c60Sjroman #define MP_PARTY_GBF "gbf" 180771306c60Sjroman #define MP_PARTY_GCF "gcf" 180871306c60Sjroman #define MP_PARTY_BUB "bub" 180971306c60Sjroman #define MP_PARTY_DEF "def" 1810014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char *); 181171306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs" 181271306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl" 181371306c60Sjroman #define MP_PARTY_NONE "no" 1814014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char *); 1815014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning, PetscReal); 1816014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning, PetscBool); 1817014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning, PetscBool); 181871306c60Sjroman 18199371c9d4SSatish Balay typedef enum { 18209371c9d4SSatish Balay MP_PTSCOTCH_DEFAULT, 18219371c9d4SSatish Balay MP_PTSCOTCH_QUALITY, 18229371c9d4SSatish Balay MP_PTSCOTCH_SPEED, 18239371c9d4SSatish Balay MP_PTSCOTCH_BALANCE, 18249371c9d4SSatish Balay MP_PTSCOTCH_SAFETY, 18259371c9d4SSatish Balay MP_PTSCOTCH_SCALABILITY 18269371c9d4SSatish Balay } MPPTScotchStrategyType; 18276a6fc655SJed Brown PETSC_EXTERN const char *const MPPTScotchStrategyTypes[]; 1828e0f1cffaSJose Roman 1829014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning, PetscReal); 1830014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning, PetscReal *); 1831014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning, MPPTScotchStrategyType); 1832014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning, MPPTScotchStrategyType *); 183371306c60Sjroman 1834b43b03e9SMark F. Adams /* 18356294fa2bSFande Kong * hierarchical partitioning 18366294fa2bSFande Kong */ 18374e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning, IS *); 18384e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning, IS *); 18394e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning, PetscInt); 18404e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt); 18416294fa2bSFande Kong 1842014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat, PetscInt, Mat *); 1843591294e4SBarry Smith 18440752156aSBarry Smith /* 1845c786d857SStefano Zampini If you add entries here you must also add them to src/mat/f90-mod/petscmat.h 1846c786d857SStefano Zampini If any of the enum values are changed, also update dMatOps dict at src/binding/petsc4py/src/libpetsc4py/libpetsc4py.pyx 1847d4fbbf0eSBarry Smith */ 18489371c9d4SSatish Balay typedef enum { 18499371c9d4SSatish Balay MATOP_SET_VALUES = 0, 18501c1c02c0SLois Curfman McInnes MATOP_GET_ROW = 1, 18511c1c02c0SLois Curfman McInnes MATOP_RESTORE_ROW = 2, 18521c1c02c0SLois Curfman McInnes MATOP_MULT = 3, 18531c1c02c0SLois Curfman McInnes MATOP_MULT_ADD = 4, 18547c922b88SBarry Smith MATOP_MULT_TRANSPOSE = 5, 18557c922b88SBarry Smith MATOP_MULT_TRANSPOSE_ADD = 6, 18561c1c02c0SLois Curfman McInnes MATOP_SOLVE = 7, 18571c1c02c0SLois Curfman McInnes MATOP_SOLVE_ADD = 8, 18587c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE = 9, 18597c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE_ADD = 10, 18601c1c02c0SLois Curfman McInnes MATOP_LUFACTOR = 11, 18611c1c02c0SLois Curfman McInnes MATOP_CHOLESKYFACTOR = 12, 1862a714c06dSBarry Smith MATOP_SOR = 13, 18631c1c02c0SLois Curfman McInnes MATOP_TRANSPOSE = 14, 18641c1c02c0SLois Curfman McInnes MATOP_GETINFO = 15, 18651c1c02c0SLois Curfman McInnes MATOP_EQUAL = 16, 18661c1c02c0SLois Curfman McInnes MATOP_GET_DIAGONAL = 17, 18671c1c02c0SLois Curfman McInnes MATOP_DIAGONAL_SCALE = 18, 18681c1c02c0SLois Curfman McInnes MATOP_NORM = 19, 18691c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_BEGIN = 20, 18701c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_END = 21, 1871d519adbfSMatthew Knepley MATOP_SET_OPTION = 22, 1872d519adbfSMatthew Knepley MATOP_ZERO_ENTRIES = 23, 1873d519adbfSMatthew Knepley MATOP_ZERO_ROWS = 24, 1874d519adbfSMatthew Knepley MATOP_LUFACTOR_SYMBOLIC = 25, 1875d519adbfSMatthew Knepley MATOP_LUFACTOR_NUMERIC = 26, 1876d519adbfSMatthew Knepley MATOP_CHOLESKY_FACTOR_SYMBOLIC = 27, 1877d519adbfSMatthew Knepley MATOP_CHOLESKY_FACTOR_NUMERIC = 28, 1878e5f2d425SStefano Zampini MATOP_SETUP = 29, 1879d519adbfSMatthew Knepley MATOP_ILUFACTOR_SYMBOLIC = 30, 1880d519adbfSMatthew Knepley MATOP_ICCFACTOR_SYMBOLIC = 31, 1881a5b7ff6bSBarry Smith MATOP_GET_DIAGONAL_BLOCK = 32, 1882e5f2d425SStefano Zampini MATOP_SET_INF = 33, 1883d519adbfSMatthew Knepley MATOP_DUPLICATE = 34, 1884d519adbfSMatthew Knepley MATOP_FORWARD_SOLVE = 35, 1885d519adbfSMatthew Knepley MATOP_BACKWARD_SOLVE = 36, 1886d519adbfSMatthew Knepley MATOP_ILUFACTOR = 37, 1887d519adbfSMatthew Knepley MATOP_ICCFACTOR = 38, 1888d519adbfSMatthew Knepley MATOP_AXPY = 39, 18897dae84e0SHong Zhang MATOP_CREATE_SUBMATRICES = 40, 1890d519adbfSMatthew Knepley MATOP_INCREASE_OVERLAP = 41, 1891d519adbfSMatthew Knepley MATOP_GET_VALUES = 42, 1892d519adbfSMatthew Knepley MATOP_COPY = 43, 1893d519adbfSMatthew Knepley MATOP_GET_ROW_MAX = 44, 1894d519adbfSMatthew Knepley MATOP_SCALE = 45, 1895d519adbfSMatthew Knepley MATOP_SHIFT = 46, 189635153367SBarry Smith MATOP_DIAGONAL_SET = 47, 18979d39f69dSJed Brown MATOP_ZERO_ROWS_COLUMNS = 48, 18989d39f69dSJed Brown MATOP_SET_RANDOM = 49, 1899d519adbfSMatthew Knepley MATOP_GET_ROW_IJ = 50, 1900d519adbfSMatthew Knepley MATOP_RESTORE_ROW_IJ = 51, 1901d519adbfSMatthew Knepley MATOP_GET_COLUMN_IJ = 52, 1902d519adbfSMatthew Knepley MATOP_RESTORE_COLUMN_IJ = 53, 1903d519adbfSMatthew Knepley MATOP_FDCOLORING_CREATE = 54, 1904d519adbfSMatthew Knepley MATOP_COLORING_PATCH = 55, 1905d519adbfSMatthew Knepley MATOP_SET_UNFACTORED = 56, 1906d519adbfSMatthew Knepley MATOP_PERMUTE = 57, 1907d519adbfSMatthew Knepley MATOP_SET_VALUES_BLOCKED = 58, 19087dae84e0SHong Zhang MATOP_CREATE_SUBMATRIX = 59, 1909d519adbfSMatthew Knepley MATOP_DESTROY = 60, 1910d519adbfSMatthew Knepley MATOP_VIEW = 61, 1911d519adbfSMatthew Knepley MATOP_CONVERT_FROM = 62, 1912e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_63=63 */ 19137bab7c10SHong Zhang MATOP_MATMAT_MULT_SYMBOLIC = 64, 19147bab7c10SHong Zhang MATOP_MATMAT_MULT_NUMERIC = 65, 1915d519adbfSMatthew Knepley MATOP_SET_LOCAL_TO_GLOBAL_MAP = 66, 1916d519adbfSMatthew Knepley MATOP_SET_VALUES_LOCAL = 67, 1917d519adbfSMatthew Knepley MATOP_ZERO_ROWS_LOCAL = 68, 1918d519adbfSMatthew Knepley MATOP_GET_ROW_MAX_ABS = 69, 1919d519adbfSMatthew Knepley MATOP_GET_ROW_MIN_ABS = 70, 1920d519adbfSMatthew Knepley MATOP_CONVERT = 71, 1921e5f2d425SStefano Zampini MATOP_HAS_OPERATION = 72, 19229d39f69dSJed Brown /* MATOP_PLACEHOLDER_73=73, */ 1923d519adbfSMatthew Knepley MATOP_SET_VALUES_ADIFOR = 74, 1924d519adbfSMatthew Knepley MATOP_FD_COLORING_APPLY = 75, 1925d519adbfSMatthew Knepley MATOP_SET_FROM_OPTIONS = 76, 1926e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_77=77, */ 1927e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_78=78, */ 19289d39f69dSJed Brown MATOP_FIND_ZERO_DIAGONALS = 79, 1929d519adbfSMatthew Knepley MATOP_MULT_MULTIPLE = 80, 1930d519adbfSMatthew Knepley MATOP_SOLVE_MULTIPLE = 81, 1931d519adbfSMatthew Knepley MATOP_GET_INERTIA = 82, 1932d519adbfSMatthew Knepley MATOP_LOAD = 83, 1933d519adbfSMatthew Knepley MATOP_IS_SYMMETRIC = 84, 1934d519adbfSMatthew Knepley MATOP_IS_HERMITIAN = 85, 1935d519adbfSMatthew Knepley MATOP_IS_STRUCTURALLY_SYMMETRIC = 86, 1936820469bcSHong Zhang MATOP_SET_VALUES_BLOCKEDLOCAL = 87, 1937b41ce5d5SBarry Smith MATOP_CREATE_VECS = 88, 1938e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_89=89, */ 1939d519adbfSMatthew Knepley MATOP_MAT_MULT_SYMBOLIC = 90, 1940d519adbfSMatthew Knepley MATOP_MAT_MULT_NUMERIC = 91, 1941e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_92=92, */ 1942d519adbfSMatthew Knepley MATOP_PTAP_SYMBOLIC = 93, 1943d519adbfSMatthew Knepley MATOP_PTAP_NUMERIC = 94, 1944e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_95=95, */ 1945bda6c4cbSBarry Smith MATOP_MAT_TRANSPOSE_MULT_SYMBO = 96, 1946bda6c4cbSBarry Smith MATOP_MAT_TRANSPOSE_MULT_NUMER = 97, 1947e5f2d425SStefano Zampini MATOP_BIND_TO_CPU = 98, 19487a3c3d58SStefano Zampini MATOP_PRODUCTSETFROMOPTIONS = 99, 19497a3c3d58SStefano Zampini MATOP_PRODUCTSYMBOLIC = 100, 19507a3c3d58SStefano Zampini MATOP_PRODUCTNUMERIC = 101, 1951d519adbfSMatthew Knepley MATOP_CONJUGATE = 102, 1952e5f2d425SStefano Zampini MATOP_VIEW_NATIVE = 103, 1953d519adbfSMatthew Knepley MATOP_SET_VALUES_ROW = 104, 1954d519adbfSMatthew Knepley MATOP_REAL_PART = 105, 1955bda6c4cbSBarry Smith MATOP_IMAGINARY_PART = 106, 1956bda6c4cbSBarry Smith MATOP_GET_ROW_UPPER_TRIANGULAR = 107, 1957bda6c4cbSBarry Smith MATOP_RESTORE_ROW_UPPER_TRIANG = 108, 1958bda6c4cbSBarry Smith MATOP_MAT_SOLVE = 109, 195929eadf9eSStefano Zampini MATOP_MAT_SOLVE_TRANSPOSE = 110, 1960d519adbfSMatthew Knepley MATOP_GET_ROW_MIN = 111, 19610e8d04f7SBarry Smith MATOP_GET_COLUMN_VECTOR = 112, 1962d519adbfSMatthew Knepley MATOP_MISSING_DIAGONAL = 113, 19630e8d04f7SBarry Smith MATOP_GET_SEQ_NONZERO_STRUCTUR = 114, 196489c6957cSBarry Smith MATOP_CREATE = 115, 196589c6957cSBarry Smith MATOP_GET_GHOSTS = 116, 19660e8d04f7SBarry Smith MATOP_GET_LOCAL_SUB_MATRIX = 117, 19670e8d04f7SBarry Smith MATOP_RESTORE_LOCALSUB_MATRIX = 118, 1968eeffb40dSHong Zhang MATOP_MULT_DIAGONAL_BLOCK = 119, 19690e8d04f7SBarry Smith MATOP_HERMITIAN_TRANSPOSE = 120, 19700e8d04f7SBarry Smith MATOP_MULT_HERMITIAN_TRANSPOSE = 121, 19710e8d04f7SBarry Smith MATOP_MULT_HERMITIAN_TRANS_ADD = 122, 19720e8d04f7SBarry Smith MATOP_GET_MULTI_PROC_BLOCK = 123, 19739d39f69dSJed Brown MATOP_FIND_NONZERO_ROWS = 124, 19740e8d04f7SBarry Smith MATOP_GET_COLUMN_NORMS = 125, 19759d39f69dSJed Brown MATOP_INVERT_BLOCK_DIAGONAL = 126, 1976e5f2d425SStefano Zampini MATOP_INVERT_VBLOCK_DIAGONAL = 127, 1977b41ce5d5SBarry Smith MATOP_CREATE_SUB_MATRICES_MPI = 128, 19782b8ad9a3SHong Zhang MATOP_SET_VALUES_BATCH = 129, 1979e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_130=130, */ 19800e8d04f7SBarry Smith MATOP_TRANSPOSE_MAT_MULT_SYMBO = 131, 1981e9b602ebSSatish Balay MATOP_TRANSPOSE_MAT_MULT_NUMER = 132, 19820e8d04f7SBarry Smith MATOP_TRANSPOSE_COLORING_CREAT = 133, 19830e8d04f7SBarry Smith MATOP_TRANS_COLORING_APPLY_SPT = 134, 19840e8d04f7SBarry Smith MATOP_TRANS_COLORING_APPLY_DEN = 135, 1985e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_136=136, */ 19860e8d04f7SBarry Smith MATOP_RART_SYMBOLIC = 137, 19870e8d04f7SBarry Smith MATOP_RART_NUMERIC = 138, 1988e09a3074SHong Zhang MATOP_SET_BLOCK_SIZES = 139, 1989f9426fe0SMark Adams MATOP_AYPX = 140, 19901919a2e2SJed Brown MATOP_RESIDUAL = 141, 19919c8f2541SHong Zhang MATOP_FDCOLORING_SETUP = 142, 1992e5f2d425SStefano Zampini MATOP_FIND_OFFBLOCK_ENTRIES = 143, 19932d033e1fSHong Zhang MATOP_MPICONCATENATESEQ = 144, 1994bb01b7b0SPatrick Sanan MATOP_DESTROYSUBMATRICES = 145, 1995e265f6d6SPatrick Sanan MATOP_TRANSPOSE_SOLVE = 146, 1996e265f6d6SPatrick Sanan MATOP_GET_VALUES_LOCAL = 147 1997fae171e0SBarry Smith } MatOperation; 19980c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOperation(Mat, MatOperation, void (*)(void)); 1999976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatGetOperation(Mat, MatOperation, void (**)(void)); 2000976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatHasOperation(Mat, MatOperation, PetscBool *); 200194342113SStefano Zampini PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat, PetscBool *); 2002edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatProductClear()", ) static inline PetscErrorCode MatFreeIntermediateDataStructures(Mat A) 2003d71ae5a4SJacob Faibussowitsch { 20049371c9d4SSatish Balay return MatProductClear(A); 20059371c9d4SSatish Balay } 2006014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat, MatOperation, void (*)(void)); 2007014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat, MatOperation, void (**)(void)); 2008014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat, void *); 2009800f99ffSJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetContextDestroy(Mat, PetscErrorCode (*)(void *)); 2010db77db73SJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetVecType(Mat, VecType); 2011f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *); 2012f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *); 20130c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat); 2014b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatShellSetMatProductOperation(Mat, MatProductType, PetscErrorCode (*)(Mat, Mat, Mat, void **), PetscErrorCode (*)(Mat, Mat, Mat, void *), PetscErrorCode (*)(void *), MatType, MatType); 2015b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatIsShell(Mat, PetscBool *); 2016112a2221SBarry Smith 201790ace30eSBarry Smith /* 201890ace30eSBarry Smith Codes for matrices stored on disk. By default they are 201990ace30eSBarry Smith stored in a universal format. By changing the format with 20206a9046bcSBarry Smith PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will 202190ace30eSBarry Smith be stored in a way natural for the matrix, for example dense matrices 202290ace30eSBarry Smith would be stored as dense. Matrices stored this way may only be 2023f4403165SShri Abhyankar read into matrices of the same type. 202490ace30eSBarry Smith */ 202590ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1 202690ace30eSBarry Smith 2027014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat, PetscReal); 202875d48cdbSStefano Zampini 20298546b261SStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat, MatType); 203075d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 203175d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat, PetscBool); 2032f03112d0SStefano Zampini PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat, PetscBool); 2033014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat, Mat *); 20343b3b1effSJed Brown PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat, Mat *); 2035014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat, Mat); 2036e432b41dSStefano Zampini PETSC_EXTERN PetscErrorCode MatISGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *); 2037edd03b47SJacob Faibussowitsch PETSC_EXTERN PETSC_DEPRECATED_FUNCTION(3, 10, 0, "MatConvert()", ) PetscErrorCode MatISGetMPIXAIJ(Mat, MatReuse, Mat *); 20381f4e1ec7SBarry Smith 2039d9274352SBarry Smith /*S 2040d9274352SBarry Smith MatNullSpace - Object that removes a null space from a vector, i.e. 2041cb6b9846SMatthew Knepley orthogonalizes the vector to a subspace 2042d9274352SBarry Smith 2043f7a9e4ceSBarry Smith Level: advanced 2044d9274352SBarry Smith 20451cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()` 2046d9274352SBarry Smith S*/ 204774637425SBarry Smith typedef struct _p_MatNullSpace *MatNullSpace; 2048d9274352SBarry Smith 2049014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm, PetscBool, PetscInt, const Vec[], MatNullSpace *); 2050014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace, PetscErrorCode (*)(MatNullSpace, Vec, void *), void *); 2051014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace *); 2052d0195637SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace, Vec); 2053014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *); 20545fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *); 20555fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat, MatNullSpace); 2056014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat, MatNullSpace); 2057014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat, MatNullSpace); 2058014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat, MatNullSpace *); 2059014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace, Mat, PetscBool *); 2060014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace, PetscViewer); 2061014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace, PetscBool *, PetscInt *, const Vec **); 2062014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec, MatNullSpace *); 206374637425SBarry Smith 2064014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat, IS); 2065014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat, PetscReal); 2066014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat, PetscInt *); 20673f1d51d7SBarry Smith 2068014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat, PetscInt, Mat *); 2069014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat, PetscInt, Mat *); 2070014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat, Mat *); 2071c4f061fbSSatish Balay 20720bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat, MatType, Mat *); 20730bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat, MatType, Mat *); 20740bacdadaSStefano Zampini 2075edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperator()", ) static inline PetscErrorCode MatComputeExplicitOperator(Mat A, Mat *B) 2076d71ae5a4SJacob Faibussowitsch { 2077f22e26b7SPierre Jolivet return MatComputeOperator(A, PETSC_NULLPTR, B); 20789371c9d4SSatish Balay } 2079edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperatorTranspose()", ) static inline PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A, Mat *B) 2080d71ae5a4SJacob Faibussowitsch { 2081f22e26b7SPierre Jolivet return MatComputeOperatorTranspose(A, PETSC_NULLPTR, B); 20829371c9d4SSatish Balay } 2083b0a32e0cSBarry Smith 208449bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat, PetscInt, PetscInt, const PetscScalar[], const PetscScalar[], Mat *); 208549bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat, Mat *); 2086a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat, PetscInt *, PetscInt *, PetscScalar **); 2087a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat, PetscInt *, PetscInt *, const PetscScalar **); 2088a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat, PetscScalar **); 2089a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat, const PetscScalar **); 2090a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat, PetscInt *, PetscInt *, PetscScalar **); 2091a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat, PetscInt *, PetscInt *, const PetscScalar **); 2092a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat, PetscScalar **); 2093a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat, const PetscScalar **); 2094dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat, Mat); 2095dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat, PetscInt, PetscInt, const PetscScalar[]); 2096dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat, PetscInt, PetscInt, const PetscScalar[]); 2097910cf402Sprj- PETSC_EXTERN PetscErrorCode MatKAIJGetScaledIdentity(Mat, PetscBool *); 209849bd79ccSDebojyoti Ghosh 2099014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat, Vec); 210004f1ad80SBarry Smith 21014bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMFFDInitializePackage(void); 21024bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMFFDFinalizePackage(void); 21034bf303faSJacob Faibussowitsch 2104014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 2105014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat, Vec, Vec); 2106014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat, PetscErrorCode (*)(void *, Vec, Vec), void *); 2107014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat, PetscErrorCode (*)(void *, PetscInt, Vec, PetscScalar *)); 2108014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat, PetscErrorCode (*)(void *, Vec)); 2109014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat, PetscScalar[], PetscInt); 2110014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat); 2111014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat, PetscReal); 2112014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat, PetscInt); 2113014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat, PetscScalar *); 2114014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat, const char[]); 2115014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void *, Vec, Vec, PetscScalar *); 2116014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat, PetscErrorCode (*)(void *, Vec, Vec, PetscScalar *), void *); 2117e884886fSBarry Smith 21186370053bSBarry Smith /*S 21196370053bSBarry Smith MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free 21206370053bSBarry Smith Jacobian vector products 2121e884886fSBarry Smith 21222ef1f0ffSBarry Smith Level: developer 21232ef1f0ffSBarry Smith 212495452b02SPatrick Sanan Notes: 212587497f52SBarry Smith `MATMFFD` is a specific `MatType` which uses the `MatMFFD` data structure 21266370053bSBarry Smith 21272ef1f0ffSBarry Smith MatMFFD*() methods actually take the `Mat` as their first argument. Not a `MatMFFD` data structure 21286370053bSBarry Smith 21292ef1f0ffSBarry Smith This functionality is often obtained using `MatCreateSNESMF()` or with `SNES` solvers using `-snes_mf` or `-snes_mf_operator` 21306370053bSBarry Smith 21311cc06b55SBarry Smith .seealso: [](ch_matrices), `MatMFFDType`, `MATMFFD`, `MatCreateMFFD()`, `MatMFFDSetFuction()`, `MatMFFDSetType()`, `MatMFFDRegister()`, 21322ef1f0ffSBarry Smith `MatCreateSNESMF()`, `SNES`, `-snes_mf`, `-snes_mf_operator` 21336370053bSBarry Smith S*/ 2134e884886fSBarry Smith typedef struct _p_MatMFFD *MatMFFD; 2135e884886fSBarry Smith 213676bdecfbSBarry Smith /*J 21372ef1f0ffSBarry Smith MatMFFDType - algorithm used to compute the `h` used in computing matrix-vector products via differencing of a function 2138e884886fSBarry Smith 213916a05f60SBarry Smith Values: 214016a05f60SBarry Smith + `MATMFFD_DS` - an algorithm described by Dennis and Schnabel 214116a05f60SBarry Smith - `MATMFFD_WP` - the Walker-Pernice strategy. 214216a05f60SBarry Smith 2143e884886fSBarry Smith Level: beginner 2144e884886fSBarry Smith 21451cc06b55SBarry Smith .seealso: [](ch_matrices), `MatMFFDSetType()`, `MatMFFDRegister()`, `MatMFFDSetFunction()`, `MatCreateMFFD()` 214676bdecfbSBarry Smith J*/ 214719fd82e9SBarry Smith typedef const char *MatMFFDType; 2148e884886fSBarry Smith #define MATMFFD_DS "ds" 2149e884886fSBarry Smith #define MATMFFD_WP "wp" 2150e884886fSBarry Smith 215119fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat, MatMFFDType); 2152bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[], PetscErrorCode (*)(MatMFFD)); 2153e884886fSBarry Smith 2154014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat, PetscReal); 2155014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat, PetscBool); 2156e884886fSBarry Smith 215761ab5df0SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring, MatMFFDType); 215861ab5df0SBarry Smith 2159014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *); 2160014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *); 21617dbadf16SMatthew Knepley 216253022affSStefano Zampini #ifdef PETSC_HAVE_H2OPUS 216353022affSStefano Zampini PETSC_EXTERN_TYPEDEF typedef PetscScalar (*MatH2OpusKernel)(PetscInt, PetscReal[], PetscReal[], void *); 216453022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], PetscBool, MatH2OpusKernel, void *, PetscReal, PetscInt, PetscInt, Mat *); 216553022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromMat(Mat, PetscInt, const PetscReal[], PetscBool, PetscReal, PetscInt, PetscInt, PetscInt, PetscReal, Mat *); 216653022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetSamplingMat(Mat, Mat, PetscInt, PetscReal); 216753022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusOrthogonalize(Mat); 216853022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusCompress(Mat, PetscReal); 216953022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetNativeMult(Mat, PetscBool); 217053022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetNativeMult(Mat, PetscBool *); 217153022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetIndexMap(Mat, IS *); 217253022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusMapVec(Mat, PetscBool, Vec, Vec *); 2173300d917bSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusLowRankUpdate(Mat, Mat, Mat, PetscScalar); 2174a0d2e7d8SStefano Zampini #endif 2175a0d2e7d8SStefano Zampini 2176c7a4214aSPierre Jolivet #ifdef PETSC_HAVE_HTOOL 217798e73e17SPierre Jolivet PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatHtoolKernel)(PetscInt, PetscInt, PetscInt, const PetscInt *, const PetscInt *, PetscScalar *, void *); 2178c7a4214aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatCreateHtoolFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], const PetscReal[], MatHtoolKernel, void *, Mat *); 2179c7a4214aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolSetKernel(Mat, MatHtoolKernel, void *); 218098e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationSource(Mat, IS *); 218198e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationTarget(Mat, IS *); 218298e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolUsePermutation(Mat, PetscBool); 21832ef1f0ffSBarry Smith 2184c7a4214aSPierre Jolivet /*E 218587497f52SBarry Smith MatHtoolCompressorType - Indicates the type of compressor used by a `MATHTOOL` 2186c7a4214aSPierre Jolivet 2187c7a4214aSPierre Jolivet Values: 218887497f52SBarry Smith + `MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA` (default) - symmetric partial adaptive cross approximation 218987497f52SBarry Smith . `MAT_HTOOL_COMPRESSOR_FULL_ACA` - full adaptive cross approximation 219087497f52SBarry Smith - `MAT_HTOOL_COMPRESSOR_SVD` - singular value decomposition 2191c7a4214aSPierre Jolivet 219216a05f60SBarry Smith Level: intermediate 219316a05f60SBarry Smith 21941cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolClusteringType` 2195c7a4214aSPierre Jolivet E*/ 21969371c9d4SSatish Balay typedef enum { 21979371c9d4SSatish Balay MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA, 21989371c9d4SSatish Balay MAT_HTOOL_COMPRESSOR_FULL_ACA, 21999371c9d4SSatish Balay MAT_HTOOL_COMPRESSOR_SVD 22009371c9d4SSatish Balay } MatHtoolCompressorType; 22012ef1f0ffSBarry Smith 220298e73e17SPierre Jolivet /*E 220387497f52SBarry Smith MatHtoolClusteringType - Indicates the type of clustering used by a `MATHTOOL` 220498e73e17SPierre Jolivet 220598e73e17SPierre Jolivet Values: 220687497f52SBarry Smith + `MAT_HTOOL_CLUSTERING_PCA_REGULAR` (default) - axis computed via principle component analysis, split uniformly 220787497f52SBarry Smith . `MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC` - axis computed via principle component analysis, split barycentrically 220887497f52SBarry Smith . `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR` - axis along the largest extent of the bounding box, split uniformly 220987497f52SBarry Smith - `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC` - axis along the largest extent of the bounding box, split barycentrically 221098e73e17SPierre Jolivet 221116a05f60SBarry Smith Level: intermediate 221216a05f60SBarry Smith 22132ef1f0ffSBarry Smith Note: 22142ef1f0ffSBarry Smith Higher-dimensional clustering is not yet supported in Htool, but once it is, one should add BOUNDING_BOX_{2,3} types 221598e73e17SPierre Jolivet 22161cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolCompressorType` 221798e73e17SPierre Jolivet E*/ 22189371c9d4SSatish Balay typedef enum { 22199371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_PCA_REGULAR, 22209371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC, 22219371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR, 22229371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC 22239371c9d4SSatish Balay } MatHtoolClusteringType; 2224c7a4214aSPierre Jolivet #endif 2225c7a4214aSPierre Jolivet 222697969023SHong Zhang #ifdef PETSC_HAVE_MUMPS 2227014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat, PetscInt, PetscInt); 2228bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat, PetscInt, PetscInt *); 2229b9e9ea26SSatish Balay PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat, PetscInt, PetscReal); 2230bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat, PetscInt, PetscReal *); 2231bc6112feSHong Zhang 2232ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat, PetscInt, PetscInt *); 2233ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat, PetscInt, PetscInt *); 2234ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat, PetscInt, PetscReal *); 2235ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat, PetscInt, PetscReal *); 22365c0bae8cSAshish Patel PETSC_EXTERN PetscErrorCode MatMumpsGetNullPivots(Mat, PetscInt *, PetscInt **); 223789a9c03aSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat, Mat); 22380e6b8875SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat, Mat); 223997969023SHong Zhang #endif 224023a5497aSJed Brown 2241b500a6b7SJose David Bermeol #ifdef PETSC_HAVE_MKL_PARDISO 2242d615f992SSatish Balay PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat, PetscInt, PetscInt); 2243b500a6b7SJose David Bermeol #endif 2244b500a6b7SJose David Bermeol 2245d305a81bSVasiliy Kozyrev #ifdef PETSC_HAVE_MKL_CPARDISO 2246d305a81bSVasiliy Kozyrev PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat, PetscInt, PetscInt); 2247d305a81bSVasiliy Kozyrev #endif 2248d305a81bSVasiliy Kozyrev 2249d954db57SHong Zhang #ifdef PETSC_HAVE_SUPERLU 2250014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat, PetscReal); 2251d954db57SHong Zhang #endif 2252d954db57SHong Zhang 2253fb785984SHong Zhang #ifdef PETSC_HAVE_SUPERLU_DIST 2254fb785984SHong Zhang PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat, PetscScalar *); 2255fb785984SHong Zhang #endif 2256fb785984SHong Zhang 2257575704cbSPieter Ghysels #ifdef PETSC_HAVE_STRUMPACK 2258542aee0fSPieter Ghysels /*E 225929e0a805SPieter Ghysels MatSTRUMPACKReordering - sparsity reducing ordering to be used in `MATSOLVERSTRUMPACK` 2260542aee0fSPieter Ghysels 22612ef1f0ffSBarry Smith Values: 22622ef1f0ffSBarry Smith + `MAT_STRUMPACK_NATURAL` - use the current ordering 22632ef1f0ffSBarry Smith . `MAT_STRUMPACK_METIS` - use MeTis to compute an ordering 22642ef1f0ffSBarry Smith . `MAT_STRUMPACK_PARMETIS` - use ParMeTis to compute an ordering 22652ef1f0ffSBarry Smith . `MAT_STRUMPACK_SCOTCH` - use Scotch to compute an ordering 22662ef1f0ffSBarry Smith . `MAT_STRUMPACK_PTSCOTCH` - use parallel Scotch to compute an ordering 226729e0a805SPieter Ghysels . `MAT_STRUMPACK_RCM` - use an RCM ordering 226829e0a805SPieter Ghysels . `MAT_STRUMPACK_GEOMETRIC` - use a geometric ordering (needs mesh info from user) 226929e0a805SPieter Ghysels . `MAT_STRUMPACK_AMD` - approximate minimum degree 227029e0a805SPieter Ghysels . `MAT_STRUMPACK_MMD` - multiple minimum degree 227129e0a805SPieter Ghysels . `MAT_STRUMPACK_AND` - approximate nested dissection 227229e0a805SPieter Ghysels . `MAT_STRUMPACK_MLF` - minimum local fill 227329e0a805SPieter Ghysels - `MAT_STRUMPACK_SPECTRAL` - spectral nested dissection 22742ef1f0ffSBarry Smith 227516a05f60SBarry Smith Level: intermediate 227616a05f60SBarry Smith 22772ef1f0ffSBarry Smith Developer Note: 22782ef1f0ffSBarry Smith Should be called `MatSTRUMPACKReorderingType` 22792ef1f0ffSBarry Smith 228029e0a805SPieter Ghysels .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetReordering()` 2281542aee0fSPieter Ghysels E*/ 22829371c9d4SSatish Balay typedef enum { 228329e0a805SPieter Ghysels MAT_STRUMPACK_NATURAL, 228429e0a805SPieter Ghysels MAT_STRUMPACK_METIS, 228529e0a805SPieter Ghysels MAT_STRUMPACK_PARMETIS, 228629e0a805SPieter Ghysels MAT_STRUMPACK_SCOTCH, 228729e0a805SPieter Ghysels MAT_STRUMPACK_PTSCOTCH, 228829e0a805SPieter Ghysels MAT_STRUMPACK_RCM, 228929e0a805SPieter Ghysels MAT_STRUMPACK_GEOMETRIC, 229029e0a805SPieter Ghysels MAT_STRUMPACK_AMD, 229129e0a805SPieter Ghysels MAT_STRUMPACK_MMD, 229229e0a805SPieter Ghysels MAT_STRUMPACK_AND, 229329e0a805SPieter Ghysels MAT_STRUMPACK_MLF, 229429e0a805SPieter Ghysels MAT_STRUMPACK_SPECTRAL 22959371c9d4SSatish Balay } MatSTRUMPACKReordering; 22962ef1f0ffSBarry Smith 229734f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat, MatSTRUMPACKReordering); 229829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetReordering(Mat, MatSTRUMPACKReordering *); 229929e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricNxyz(Mat, PetscInt, PetscInt, PetscInt); 230029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricComponents(Mat, PetscInt); 230129e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricWidth(Mat, PetscInt); 2302575704cbSPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat, PetscBool); 230329e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetColPerm(Mat, PetscBool *); 230429e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGPU(Mat, PetscBool); 230529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetGPU(Mat, PetscBool *); 230629e0a805SPieter Ghysels 230729e0a805SPieter Ghysels /*E 230829e0a805SPieter Ghysels MatSTRUMPACKCompressionType - Compression used in the approximate sparse factorization solver `MATSOLVERSTRUMPACK` 230929e0a805SPieter Ghysels 231029e0a805SPieter Ghysels Values: 231129e0a805SPieter Ghysels + `MAT_STRUMPACK_COMPRESSION_TYPE_NONE` - no compression, direct solver 231229e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_HSS` - hierarchically semi-separable 231329e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_BLR` - block low rank 231429e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_HODLR` - hierarchically off-diagonal low rank (requires ButterfyPACK support, configure with --download-butterflypack) 231529e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR` - hybrid of BLR and HODLR (requires ButterfyPACK support, configure with --download-butterflypack) 231629e0a805SPieter 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) 231729e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS` - lossless compression (requires ZFP support, configure with --download-zfp) 231829e0a805SPieter Ghysels - `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY` - lossy compression (requires ZFP support, configure with --download-zfp) 231929e0a805SPieter Ghysels 232029e0a805SPieter Ghysels Level: intermediate 232129e0a805SPieter Ghysels 232229e0a805SPieter Ghysels .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetCompression()` 232329e0a805SPieter Ghysels E*/ 232429e0a805SPieter Ghysels typedef enum { 232529e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_NONE, 232629e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_HSS, 232729e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_BLR, 232829e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_HODLR, 232929e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR, 233029e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_ZFP_BLR_HODLR, 233129e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS, 233229e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY 233329e0a805SPieter Ghysels } MatSTRUMPACKCompressionType; 233429e0a805SPieter Ghysels 233529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompression(Mat, MatSTRUMPACKCompressionType); 233629e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompression(Mat, MatSTRUMPACKCompressionType *); 233729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompRelTol(Mat, PetscReal); 233829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompRelTol(Mat, PetscReal *); 233929e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompAbsTol(Mat, PetscReal); 234029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompAbsTol(Mat, PetscReal *); 234129e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompMinSepSize(Mat, PetscInt); 234229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompMinSepSize(Mat, PetscInt *); 234329e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLeafSize(Mat, PetscInt); 234429e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLeafSize(Mat, PetscInt *); 234529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLossyPrecision(Mat, PetscInt); 234629e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLossyPrecision(Mat, PetscInt *); 234729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompButterflyLevels(Mat, PetscInt); 234829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompButterflyLevels(Mat, PetscInt *); 2349575704cbSPieter Ghysels #endif 2350575704cbSPieter Ghysels 2351b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatBindToCPU(Mat, PetscBool); 23522216c58aSStefano Zampini PETSC_EXTERN PetscErrorCode MatBoundToCPU(Mat, PetscBool *); 2353edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 13, 0, "MatBindToCPU()", ) static inline PetscErrorCode MatPinToCPU(Mat A, PetscBool flg) 2354d71ae5a4SJacob Faibussowitsch { 23559371c9d4SSatish Balay return MatBindToCPU(A, flg); 23569371c9d4SSatish Balay } 235765a9ecf2SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatSetBindingPropagates(Mat, PetscBool); 2358e9c74fd6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetBindingPropagates(Mat, PetscBool *); 2359e7e92044SBarry Smith 2360aa372e3fSPaul Mullowney #ifdef PETSC_HAVE_CUDA 23613f9c0db1SPaul Mullowney /*E 23622ef1f0ffSBarry Smith MatCUSPARSEStorageFormat - indicates the storage format for `MATAIJCUSPARSE` (GPU) 23632692e278SPaul Mullowney matrices. 2364e057df02SPaul Mullowney 23652ef1f0ffSBarry Smith Values: 236687497f52SBarry Smith + `MAT_CUSPARSE_CSR` - Compressed Sparse Row 236787497f52SBarry Smith . `MAT_CUSPARSE_ELL` - Ellpack (requires CUDA 4.2 or later). 236887497f52SBarry Smith - `MAT_CUSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later). 2369e057df02SPaul Mullowney 2370e057df02SPaul Mullowney Level: intermediate 2371e057df02SPaul Mullowney 23721cc06b55SBarry Smith .seealso: [](ch_matrices), `MATAIJCUSPARSE`, `MatCUSPARSESetFormat()`, `MatCUSPARSEFormatOperation` 2373e057df02SPaul Mullowney E*/ 2374e057df02SPaul Mullowney 23759371c9d4SSatish Balay typedef enum { 23769371c9d4SSatish Balay MAT_CUSPARSE_CSR, 23779371c9d4SSatish Balay MAT_CUSPARSE_ELL, 23789371c9d4SSatish Balay MAT_CUSPARSE_HYB 23799371c9d4SSatish Balay } MatCUSPARSEStorageFormat; 2380e057df02SPaul Mullowney 2381e057df02SPaul Mullowney /* these will be strings associated with enumerated type defined above */ 2382e057df02SPaul Mullowney PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[]; 2383e057df02SPaul Mullowney 23843f9c0db1SPaul Mullowney /*E 23852ef1f0ffSBarry Smith MatCUSPARSEFormatOperation - indicates the operation of `MATAIJCUSPARSE` (GPU) 23862692e278SPaul Mullowney matrices whose operation should use a particular storage format. 2387e057df02SPaul Mullowney 23882ef1f0ffSBarry Smith Values: 23894cf0e950SBarry Smith + `MAT_CUSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()` 23904cf0e950SBarry Smith . `MAT_CUSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()` 23914cf0e950SBarry Smith . `MAT_CUSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()` 23922ef1f0ffSBarry Smith - `MAT_CUSPARSE_ALL` - sets the storage format for all `MATAIJCUSPARSE` (GPU) matrices 2393e057df02SPaul Mullowney 2394e057df02SPaul Mullowney Level: intermediate 2395e057df02SPaul Mullowney 23961cc06b55SBarry Smith .seealso: [](ch_matrices), `MatCUSPARSESetFormat()`, `MatCUSPARSEStorageFormat` 2397e057df02SPaul Mullowney E*/ 23989371c9d4SSatish Balay typedef enum { 23999371c9d4SSatish Balay MAT_CUSPARSE_MULT_DIAG, 24009371c9d4SSatish Balay MAT_CUSPARSE_MULT_OFFDIAG, 24019371c9d4SSatish Balay MAT_CUSPARSE_MULT, 24029371c9d4SSatish Balay MAT_CUSPARSE_ALL 24039371c9d4SSatish Balay } MatCUSPARSEFormatOperation; 2404e057df02SPaul Mullowney 240510e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 240610e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 2407e057df02SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat, MatCUSPARSEFormatOperation, MatCUSPARSEStorageFormat); 2408365b711fSMark Adams PETSC_EXTERN PetscErrorCode MatCUSPARSESetUseCPUSolve(Mat, PetscBool); 24095f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetIJ(Mat, PetscBool, const int **, const int **); 24105f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreIJ(Mat, PetscBool, const int **, const int **); 24115f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayRead(Mat, const PetscScalar **); 24125f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayRead(Mat, const PetscScalar **); 24135f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayWrite(Mat, PetscScalar **); 24145f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayWrite(Mat, PetscScalar **); 24155f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArray(Mat, PetscScalar **); 24165f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArray(Mat, PetscScalar **); 2417637a0070SStefano Zampini 2418637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 2419637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 2420637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayWrite(Mat, PetscScalar **); 2421637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayRead(Mat, const PetscScalar **); 2422637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArray(Mat, PetscScalar **); 2423637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayWrite(Mat, PetscScalar **); 2424637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayRead(Mat, const PetscScalar **); 2425637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArray(Mat, PetscScalar **); 2426637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAPlaceArray(Mat, const PetscScalar *); 2427d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAReplaceArray(Mat, const PetscScalar *); 2428637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAResetArray(Mat); 24293d9668e3SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatDenseCUDASetPreallocation(Mat, PetscScalar *); 24302d1451d4SHong Zhang 24312d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 24322d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 24339ae82921SPaul Mullowney #endif 24349ae82921SPaul Mullowney 243547d993e7Ssuyashtn #ifdef PETSC_HAVE_HIP 243647d993e7Ssuyashtn /*E 24372ef1f0ffSBarry Smith MatHIPSPARSEStorageFormat - indicates the storage format for `MATAIJHIPSPARSE` (GPU) 243847d993e7Ssuyashtn matrices. 243947d993e7Ssuyashtn 24402ef1f0ffSBarry Smith Values: 24412ef1f0ffSBarry Smith + `MAT_HIPSPARSE_CSR` - Compressed Sparse Row 24422ef1f0ffSBarry Smith . `MAT_HIPSPARSE_ELL` - Ellpack 24432ef1f0ffSBarry Smith - `MAT_HIPSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format 244447d993e7Ssuyashtn 244516a05f60SBarry Smith Level: intermediate 244616a05f60SBarry Smith 24471cc06b55SBarry Smith .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEFormatOperation` 244847d993e7Ssuyashtn E*/ 244947d993e7Ssuyashtn 245047d993e7Ssuyashtn typedef enum { 245147d993e7Ssuyashtn MAT_HIPSPARSE_CSR, 245247d993e7Ssuyashtn MAT_HIPSPARSE_ELL, 245347d993e7Ssuyashtn MAT_HIPSPARSE_HYB 245447d993e7Ssuyashtn } MatHIPSPARSEStorageFormat; 245547d993e7Ssuyashtn 245647d993e7Ssuyashtn /* these will be strings associated with enumerated type defined above */ 245747d993e7Ssuyashtn PETSC_EXTERN const char *const MatHIPSPARSEStorageFormats[]; 245847d993e7Ssuyashtn 245947d993e7Ssuyashtn /*E 24602ef1f0ffSBarry Smith MatHIPSPARSEFormatOperation - indicates the operation of `MATAIJHIPSPARSE` (GPU) 246147d993e7Ssuyashtn matrices whose operation should use a particular storage format. 246247d993e7Ssuyashtn 24632ef1f0ffSBarry Smith Values: 24642ef1f0ffSBarry Smith + `MAT_HIPSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()` 24654cf0e950SBarry Smith . `MAT_HIPSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()` 24662ef1f0ffSBarry Smith . `MAT_HIPSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()` 24672ef1f0ffSBarry Smith - `MAT_HIPSPARSE_ALL` - sets the storage format for all HIPSPARSE (GPU) matrices 24682ef1f0ffSBarry Smith 246916a05f60SBarry Smith Level: intermediate 247016a05f60SBarry Smith 24711cc06b55SBarry Smith .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEStorageFormat` 247247d993e7Ssuyashtn E*/ 247347d993e7Ssuyashtn typedef enum { 247447d993e7Ssuyashtn MAT_HIPSPARSE_MULT_DIAG, 247547d993e7Ssuyashtn MAT_HIPSPARSE_MULT_OFFDIAG, 247647d993e7Ssuyashtn MAT_HIPSPARSE_MULT, 247747d993e7Ssuyashtn MAT_HIPSPARSE_ALL 247847d993e7Ssuyashtn } MatHIPSPARSEFormatOperation; 247947d993e7Ssuyashtn 248047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 248147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 248247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetFormat(Mat, MatHIPSPARSEFormatOperation, MatHIPSPARSEStorageFormat); 248347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetUseCPUSolve(Mat, PetscBool); 248447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetIJ(Mat, PetscBool, const int **, const int **); 248547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreIJ(Mat, PetscBool, const int **, const int **); 248647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayRead(Mat, const PetscScalar **); 248747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayRead(Mat, const PetscScalar **); 248847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayWrite(Mat, PetscScalar **); 248947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayWrite(Mat, PetscScalar **); 249047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArray(Mat, PetscScalar **); 249147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArray(Mat, PetscScalar **); 249247d993e7Ssuyashtn 249347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 249447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 249547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayWrite(Mat, PetscScalar **); 249647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayRead(Mat, const PetscScalar **); 249747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArray(Mat, PetscScalar **); 249847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayWrite(Mat, PetscScalar **); 249947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayRead(Mat, const PetscScalar **); 250047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArray(Mat, PetscScalar **); 250147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPPlaceArray(Mat, const PetscScalar *); 250247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPReplaceArray(Mat, const PetscScalar *); 250347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPResetArray(Mat); 25043d9668e3SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatDenseHIPSetPreallocation(Mat, PetscScalar *); 250547d993e7Ssuyashtn #endif 250647d993e7Ssuyashtn 2507d67ff14aSKarl Rupp #if defined(PETSC_HAVE_VIENNACL) 2508d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 2509d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 2510d67ff14aSKarl Rupp #endif 2511d67ff14aSKarl Rupp 25124bf303faSJacob Faibussowitsch #if PetscDefined(HAVE_KOKKOS) 25134bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 25144bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 25154bf303faSJacob Faibussowitsch #endif 25164bf303faSJacob Faibussowitsch 251754efbe56SHong Zhang #if defined(PETSC_HAVE_FFTW) 2518014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat, Vec, Vec); 2519014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat, Vec, Vec); 25202a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat, Vec *, Vec *, Vec *); 252154efbe56SHong Zhang #endif 252254efbe56SHong Zhang 2523d24d4204SJose E. Roman #if defined(PETSC_HAVE_SCALAPACK) 2524d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateScaLAPACK(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 2525d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKSetBlockSizes(Mat, PetscInt, PetscInt); 2526d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKGetBlockSizes(Mat, PetscInt *, PetscInt *); 2527d24d4204SJose E. Roman #endif 2528d24d4204SJose E. Roman 2529014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm, PetscInt, const IS[], PetscInt, const IS[], const Mat[], Mat *); 2530014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat, PetscInt *, PetscInt *); 2531014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat, IS[], IS[]); 2532014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat, IS[], IS[]); 2533014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat, PetscInt *, PetscInt *, Mat ***); 2534014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat, PetscInt, PetscInt, Mat *); 253519fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat, VecType); 2536014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat, PetscInt, const IS[], PetscInt, const IS[], const Mat[]); 2537014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat, PetscInt, PetscInt, Mat); 2538d8588912SDave May 25392ce66baaSPierre Jolivet PETSC_EXTERN PetscErrorCode MatFilter(Mat, PetscReal, PetscBool, PetscBool); 25402ce66baaSPierre Jolivet PETSC_DEPRECATED_FUNCTION(3, 20, 0, "MatFilter()", ) static inline PetscErrorCode MatChop(Mat A, PetscReal tol) 25412ce66baaSPierre Jolivet { 25422ce66baaSPierre Jolivet return MatFilter(A, tol, PETSC_FALSE, PETSC_FALSE); 25432ce66baaSPierre Jolivet } 2544e0a58c10SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat, PetscReal, PetscInt *); 25454325cce7SMatthew G Knepley 2546b541e6a4SDmitry Karpeev PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat, PetscInt, PetscInt *, IS **); 254753dd7562SDmitry Karpeev 2548c094ef40SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat, PetscBool, Mat); 2549c094ef40SMatthew G. Knepley 2550539c167fSBarry Smith PETSC_INTERN PetscErrorCode MatHeaderMerge(Mat, Mat *); 2551539c167fSBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat, Mat *); 25521a2c6b5cSJunchao Zhang 25537ee59b9bSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetCSRAndMemType(Mat, const PetscInt **, const PetscInt **, PetscScalar **, PetscMemType *); 255472833a62Smarkadams4 2555*e02fb3cdSMark Adams PETSC_EXTERN PetscErrorCode MatCreateGraph(Mat, PetscBool, PetscBool, PetscReal, PetscInt, PetscInt[], Mat *); 255658c11ad4SPierre Jolivet PETSC_EXTERN PetscErrorCode MatEliminateZeros(Mat, PetscBool); 2557ad6ad4e1SHansol Suh 2558d16ceb75SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseFromVecType(MPI_Comm, VecType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar *, Mat *); 25593444e80cSBarry Smith 25603444e80cSBarry Smith PETSC_EXTERN PetscErrorCode MatSetHPL(Mat, int); 25613444e80cSBarry Smith #define PETSCBMHPL "hpl" 2562