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 12*af27ebaaSBarry Smith an explicit sparse representation (such as matrix-free operators). Also used to hold representations of graphs 13*af27ebaaSBarry Smith for graph operations such as coloring, `MatColoringCreate()` 142eac72dbSBarry Smith 15d91e6319SBarry Smith Level: beginner 16d91e6319SBarry Smith 172ef1f0ffSBarry Smith Note: 181cc06b55SBarry Smith See [](doc_matrix), [](ch_matrices) and `MatType` for available matrix types 192ef1f0ffSBarry Smith 201cc06b55SBarry Smith .seealso: [](doc_matrix), [](ch_matrices), `MatCreate()`, `MatType`, `MatSetType()`, `MatDestroy()` 21d9274352SBarry Smith S*/ 22d9274352SBarry Smith typedef struct _p_Mat *Mat; 23d9274352SBarry Smith 2476bdecfbSBarry Smith /*J 258f6c3df8SBarry Smith MatType - String with the name of a PETSc matrix type 26d9274352SBarry Smith 27d9274352SBarry Smith Level: beginner 28d9274352SBarry Smith 292ef1f0ffSBarry Smith Note: 302ef1f0ffSBarry Smith [](doc_matrix) for a table of available matrix types 312ef1f0ffSBarry Smith 321cc06b55SBarry Smith .seealso: [](doc_matrix), [](ch_matrices), `MatSetType()`, `Mat`, `MatSolverType`, `MatRegister()` 3376bdecfbSBarry Smith J*/ 3419fd82e9SBarry Smith typedef const char *MatType; 35273d9f13SBarry Smith #define MATSAME "same" 365a11e1b2SBarry Smith #define MATMAIJ "maij" 37273d9f13SBarry Smith #define MATSEQMAIJ "seqmaij" 38273d9f13SBarry Smith #define MATMPIMAIJ "mpimaij" 3949bd79ccSDebojyoti Ghosh #define MATKAIJ "kaij" 4049bd79ccSDebojyoti Ghosh #define MATSEQKAIJ "seqkaij" 4149bd79ccSDebojyoti Ghosh #define MATMPIKAIJ "mpikaij" 42273d9f13SBarry Smith #define MATIS "is" 435a11e1b2SBarry Smith #define MATAIJ "aij" 44273d9f13SBarry Smith #define MATSEQAIJ "seqaij" 45273d9f13SBarry Smith #define MATMPIAIJ "mpiaij" 465a11e1b2SBarry Smith #define MATAIJCRL "aijcrl" 475a11e1b2SBarry Smith #define MATSEQAIJCRL "seqaijcrl" 485a11e1b2SBarry Smith #define MATMPIAIJCRL "mpiaijcrl" 499ae82921SPaul Mullowney #define MATAIJCUSPARSE "aijcusparse" 509ae82921SPaul Mullowney #define MATSEQAIJCUSPARSE "seqaijcusparse" 519ae82921SPaul Mullowney #define MATMPIAIJCUSPARSE "mpiaijcusparse" 5247d993e7Ssuyashtn #define MATAIJHIPSPARSE "aijhipsparse" 5347d993e7Ssuyashtn #define MATSEQAIJHIPSPARSE "seqaijhipsparse" 5447d993e7Ssuyashtn #define MATMPIAIJHIPSPARSE "mpiaijhipsparse" 558c3ff71bSJunchao Zhang #define MATAIJKOKKOS "aijkokkos" 568c3ff71bSJunchao Zhang #define MATSEQAIJKOKKOS "seqaijkokkos" 578c3ff71bSJunchao Zhang #define MATMPIAIJKOKKOS "mpiaijkokkos" 58d67ff14aSKarl Rupp #define MATAIJVIENNACL "aijviennacl" 59d67ff14aSKarl Rupp #define MATSEQAIJVIENNACL "seqaijviennacl" 60d67ff14aSKarl Rupp #define MATMPIAIJVIENNACL "mpiaijviennacl" 615a11e1b2SBarry Smith #define MATAIJPERM "aijperm" 625a11e1b2SBarry Smith #define MATSEQAIJPERM "seqaijperm" 635a11e1b2SBarry Smith #define MATMPIAIJPERM "mpiaijperm" 644dfdc2d9SRichard Tran Mills #define MATAIJSELL "aijsell" 654dfdc2d9SRichard Tran Mills #define MATSEQAIJSELL "seqaijsell" 664dfdc2d9SRichard Tran Mills #define MATMPIAIJSELL "mpiaijsell" 674a2a386eSRichard Tran Mills #define MATAIJMKL "aijmkl" 684a2a386eSRichard Tran Mills #define MATSEQAIJMKL "seqaijmkl" 694a2a386eSRichard Tran Mills #define MATMPIAIJMKL "mpiaijmkl" 70b5b72c8aSIrina Sokolova #define MATBAIJMKL "baijmkl" 71b5b72c8aSIrina Sokolova #define MATSEQBAIJMKL "seqbaijmkl" 72b5b72c8aSIrina Sokolova #define MATMPIBAIJMKL "mpibaijmkl" 73273d9f13SBarry Smith #define MATSHELL "shell" 74c1fff1c6SRichard Tran Mills #define MATCENTERING "centering" 755a11e1b2SBarry Smith #define MATDENSE "dense" 76637a0070SStefano Zampini #define MATDENSECUDA "densecuda" 7747d993e7Ssuyashtn #define MATDENSEHIP "densehip" 78209238afSKris Buschelman #define MATSEQDENSE "seqdense" 79bfc799aaSStefano Zampini #define MATSEQDENSECUDA "seqdensecuda" 8047d993e7Ssuyashtn #define MATSEQDENSEHIP "seqdensehip" 81273d9f13SBarry Smith #define MATMPIDENSE "mpidense" 82637a0070SStefano Zampini #define MATMPIDENSECUDA "mpidensecuda" 8347d993e7Ssuyashtn #define MATMPIDENSEHIP "mpidensehip" 84db31f6deSJed Brown #define MATELEMENTAL "elemental" 85d24d4204SJose E. Roman #define MATSCALAPACK "scalapack" 865a11e1b2SBarry Smith #define MATBAIJ "baij" 87273d9f13SBarry Smith #define MATSEQBAIJ "seqbaij" 88273d9f13SBarry Smith #define MATMPIBAIJ "mpibaij" 89273d9f13SBarry Smith #define MATMPIADJ "mpiadj" 905a11e1b2SBarry Smith #define MATSBAIJ "sbaij" 91273d9f13SBarry Smith #define MATSEQSBAIJ "seqsbaij" 92273d9f13SBarry Smith #define MATMPISBAIJ "mpisbaij" 93cebc7f6cSBarry Smith #define MATMFFD "mffd" 94c8a8475eSBarry Smith #define MATNORMAL "normal" 95c5e4d11fSDmitry Karpeev #define MATNORMALHERMITIAN "normalh" 96ab92ecdeSBarry Smith #define MATLRC "lrc" 972a6744ebSBarry Smith #define MATSCATTER "scatter" 98421e10b8SBarry Smith #define MATBLOCKMAT "blockmat" 99793850ffSBarry Smith #define MATCOMPOSITE "composite" 1001f8c7532SHong Zhang #define MATFFT "fft" 1011f8c7532SHong Zhang #define MATFFTW "fftw" 102e133240eSMatthew G Knepley #define MATSEQCUFFT "seqcufft" 10347d993e7Ssuyashtn #define MATSEQHIPFFT "seqhipfft" 104edd03b47SJacob Faibussowitsch #define MATTRANSPOSEMAT PETSC_DEPRECATED_MACRO(3, 18, 0, "MATTRANSPOSEVIRTUAL", ) "transpose" 105013e2dc7SBarry Smith #define MATTRANSPOSEVIRTUAL "transpose" 106013e2dc7SBarry Smith #define MATHERMITIANTRANSPOSEVIRTUAL "hermitiantranspose" 10772ca8751SBarry Smith #define MATSCHURCOMPLEMENT "schurcomplement" 1081d6018f0SLisandro Dalcin #define MATPYTHON "python" 10963c07aadSStefano Zampini #define MATHYPRE "hypre" 110f91d8e95SBarry Smith #define MATHYPRESTRUCT "hyprestruct" 111a9e6138eSGlenn Hammond #define MATHYPRESSTRUCT "hypresstruct" 112ee1cef2cSJed Brown #define MATSUBMATRIX "submatrix" 1132c0dbf93SJed Brown #define MATLOCALREF "localref" 114d8588912SDave May #define MATNEST "nest" 115c094ef40SMatthew G. Knepley #define MATPREALLOCATOR "preallocator" 116d4002b98SHong Zhang #define MATSELL "sell" 117d4002b98SHong Zhang #define MATSEQSELL "seqsell" 118d4002b98SHong Zhang #define MATMPISELL "mpisell" 1192d1451d4SHong Zhang #define MATSELLCUDA "sellcuda" 1202d1451d4SHong Zhang #define MATSEQSELLCUDA "seqsellcuda" 1212d1451d4SHong Zhang #define MATMPISELLCUDA "mpisellcuda" 122a3b2e22bSHong Zhang #define MATDUMMY "dummy" 123cd929ea3SAlp Dener #define MATLMVM "lmvm" 12478e4361aSAlp Dener #define MATLMVMDFP "lmvmdfp" 12578e4361aSAlp Dener #define MATLMVMBFGS "lmvmbfgs" 12678e4361aSAlp Dener #define MATLMVMSR1 "lmvmsr1" 127864588a7SAlp Dener #define MATLMVMBROYDEN "lmvmbroyden" 128864588a7SAlp Dener #define MATLMVMBADBROYDEN "lmvmbadbroyden" 129864588a7SAlp Dener #define MATLMVMSYMBROYDEN "lmvmsymbroyden" 130864588a7SAlp Dener #define MATLMVMSYMBADBROYDEN "lmvmsymbadbroyden" 131864588a7SAlp Dener #define MATLMVMDIAGBROYDEN "lmvmdiagbroyden" 1323423f386SBarry Smith #define MATCONSTANTDIAGONAL "constantdiagonal" 133345a4b08SToby Isaac #define MATDIAGONAL "diagonal" 134c7a4214aSPierre Jolivet #define MATHTOOL "htool" 13553022affSStefano Zampini #define MATH2OPUS "h2opus" 136773941d6SBarry Smith 13776bdecfbSBarry Smith /*J 138*af27ebaaSBarry Smith MatSolverType - String with the name of a PETSc factorization-based matrix solver type. 1399989ab13SBarry Smith 140c2b89b5dSBarry Smith For example: "petsc" indicates what PETSc provides, "superlu_dist" the parallel SuperLU_DIST package etc 1419989ab13SBarry Smith 1429989ab13SBarry Smith Level: beginner 1439989ab13SBarry Smith 1442ef1f0ffSBarry Smith Note: 14516a05f60SBarry Smith `MATSOLVERUMFPACK`, `MATSOLVERCHOLMOD`, `MATSOLVERKLU`, `MATSOLVERSPQR` form the SuiteSparse package; you can use `--download-suitesparse` as 14616a05f60SBarry Smith a ./configure option to install them 147c7ccbb75SBarry Smith 1481cc06b55SBarry Smith .seealso: [](sec_matfactor), [](ch_matrices), `MatGetFactor()`, `PCFactorSetMatSolverType()`, `PCFactorGetMatSolverType()` 14976bdecfbSBarry Smith J*/ 150ea799195SBarry Smith typedef const char *MatSolverType; 1512692d6eeSBarry Smith #define MATSOLVERSUPERLU "superlu" 1522692d6eeSBarry Smith #define MATSOLVERSUPERLU_DIST "superlu_dist" 15308f5efcfSPieter Ghysels #define MATSOLVERSTRUMPACK "strumpack" 1542692d6eeSBarry Smith #define MATSOLVERUMFPACK "umfpack" 15520db9a53SJed Brown #define MATSOLVERCHOLMOD "cholmod" 156d89f5e7aSBarry Smith #define MATSOLVERKLU "klu" 157d89f5e7aSBarry Smith #define MATSOLVERELEMENTAL "elemental" 158d24d4204SJose E. Roman #define MATSOLVERSCALAPACK "scalapack" 1592692d6eeSBarry Smith #define MATSOLVERESSL "essl" 1602692d6eeSBarry Smith #define MATSOLVERLUSOL "lusol" 1612692d6eeSBarry Smith #define MATSOLVERMUMPS "mumps" 162d615f992SSatish Balay #define MATSOLVERMKL_PARDISO "mkl_pardiso" 163d305a81bSVasiliy Kozyrev #define MATSOLVERMKL_CPARDISO "mkl_cpardiso" 1642692d6eeSBarry Smith #define MATSOLVERPASTIX "pastix" 1652692d6eeSBarry Smith #define MATSOLVERMATLAB "matlab" 1662692d6eeSBarry Smith #define MATSOLVERPETSC "petsc" 1672692d6eeSBarry Smith #define MATSOLVERBAS "bas" 1689ae82921SPaul Mullowney #define MATSOLVERCUSPARSE "cusparse" 169bfc799aaSStefano Zampini #define MATSOLVERCUDA "cuda" 17047d993e7Ssuyashtn #define MATSOLVERHIPSPARSE "hipsparse" 17147d993e7Ssuyashtn #define MATSOLVERHIP "hip" 172930e68a5SMark Adams #define MATSOLVERKOKKOS "kokkos" 173a2fc1e05SToby Isaac #define MATSOLVERSPQR "spqr" 174c0cdd4a1SDahai Guo 175b24902e0SBarry Smith /*E 176b24902e0SBarry Smith MatFactorType - indicates what type of factorization is requested 177b24902e0SBarry Smith 1782ef1f0ffSBarry Smith Values: 1792ef1f0ffSBarry Smith + `MAT_FACTOR_LU` - LU factorization 1802ef1f0ffSBarry Smith . `MAT_FACTOR_CHOLESKY` - Cholesky factorization 1812ef1f0ffSBarry Smith . `MAT_FACTOR_ILU` - ILU factorization 1822ef1f0ffSBarry Smith . `MAT_FACTOR_ICC` - incomplete Cholesky factorization 1832ef1f0ffSBarry Smith . `MAT_FACTOR_ILUDT` - ILU factorization with drop tolerance 1842ef1f0ffSBarry Smith - `MAT_FACTOR_QR` - QR factorization 185b24902e0SBarry Smith 18616a05f60SBarry Smith Level: beginner 18716a05f60SBarry Smith 1881cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSolverType`, `MatGetFactor()`, `MatGetFactorAvailable()`, `MatSolverTypeRegister()` 189b24902e0SBarry Smith E*/ 1909371c9d4SSatish Balay typedef enum { 1919371c9d4SSatish Balay MAT_FACTOR_NONE, 1929371c9d4SSatish Balay MAT_FACTOR_LU, 1939371c9d4SSatish Balay MAT_FACTOR_CHOLESKY, 1949371c9d4SSatish Balay MAT_FACTOR_ILU, 1959371c9d4SSatish Balay MAT_FACTOR_ICC, 1969371c9d4SSatish Balay MAT_FACTOR_ILUDT, 1979371c9d4SSatish Balay MAT_FACTOR_QR, 1989371c9d4SSatish Balay MAT_FACTOR_NUM_TYPES 1999371c9d4SSatish Balay } MatFactorType; 200014dd563SJed Brown PETSC_EXTERN const char *const MatFactorTypes[]; 201e92e720dSBarry Smith 202ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactor(Mat, MatSolverType, MatFactorType, Mat *); 203ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat, MatSolverType, MatFactorType, PetscBool *); 204f73b0415SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetCanUseOrdering(Mat, PetscBool *); 205edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 15, 0, "MatFactorGetCanUseOrdering()", ) static inline PetscErrorCode MatFactorGetUseOrdering(Mat A, PetscBool *b) 206d71ae5a4SJacob Faibussowitsch { 2079371c9d4SSatish Balay return MatFactorGetCanUseOrdering(A, b); 2089371c9d4SSatish Balay } 209ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetSolverType(Mat, MatSolverType *); 210014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetFactorType(Mat, MatFactorType *); 2117abd51d3SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatSetFactorType(Mat, MatFactorType); 2122430ea28SJose E. Roman PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatSolverFunction)(Mat, MatFactorType, Mat *); 2132430ea28SJose E. Roman PETSC_EXTERN PetscErrorCode MatSolverTypeRegister(MatSolverType, MatType, MatFactorType, MatSolverFunction); 2142430ea28SJose E. Roman PETSC_EXTERN PetscErrorCode MatSolverTypeGet(MatSolverType, MatType, MatFactorType, PetscBool *, PetscBool *, MatSolverFunction *); 215edd03b47SJacob Faibussowitsch typedef MatSolverType MatSolverPackage PETSC_DEPRECATED_TYPEDEF(3, 9, 0, "MatSolverType", ); 216edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeRegister()", ) static inline PetscErrorCode MatSolverPackageRegister(MatSolverType stype, MatType mtype, MatFactorType ftype, MatSolverFunction f) 217d71ae5a4SJacob Faibussowitsch { 2189371c9d4SSatish Balay return MatSolverTypeRegister(stype, mtype, ftype, f); 2199371c9d4SSatish Balay } 220edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeGet()", ) static inline PetscErrorCode MatSolverPackageGet(MatSolverType stype, MatType mtype, MatFactorType ftype, PetscBool *foundmtype, PetscBool *foundstype, MatSolverFunction *f) 221d71ae5a4SJacob Faibussowitsch { 2229371c9d4SSatish Balay return MatSolverTypeGet(stype, mtype, ftype, foundmtype, foundstype, f); 2239371c9d4SSatish Balay } 2249989ab13SBarry Smith 2254222ddf1SHong Zhang /*E 22695bd0b28SBarry Smith MatProductType - indicates what type of matrix product to compute 2274222ddf1SHong Zhang 2282ef1f0ffSBarry Smith Values: 2292ef1f0ffSBarry Smith + `MATPRODUCT_AB` - product of two matrices 2302ef1f0ffSBarry Smith . `MATPRODUCT_AtB` - product of the transpose of a given matrix with a matrix 2312ef1f0ffSBarry Smith . `MATPRODUCT_ABt` - product of a matrix with the transpose of another given matrix 2322ef1f0ffSBarry Smith . `MATPRODUCT_PtAP` - the triple product of the transpose of a matrix with another matrix and itself 2332ef1f0ffSBarry Smith . `MATPRODUCT_RARt` - the triple product of a matrix, another matrix and the transpose of the first matrix 2342ef1f0ffSBarry Smith - `MATPRODUCT_ABC` - the product of three matrices 2352ef1f0ffSBarry Smith 23616a05f60SBarry Smith Level: beginner 23716a05f60SBarry Smith 2381cc06b55SBarry Smith .seealso: [](sec_matmatproduct), [](ch_matrices), `MatProductSetType()` 2394222ddf1SHong Zhang E*/ 2409371c9d4SSatish Balay typedef enum { 2419371c9d4SSatish Balay MATPRODUCT_UNSPECIFIED = 0, 2429371c9d4SSatish Balay MATPRODUCT_AB, 2439371c9d4SSatish Balay MATPRODUCT_AtB, 2449371c9d4SSatish Balay MATPRODUCT_ABt, 2459371c9d4SSatish Balay MATPRODUCT_PtAP, 2469371c9d4SSatish Balay MATPRODUCT_RARt, 2479371c9d4SSatish Balay MATPRODUCT_ABC 2489371c9d4SSatish Balay } MatProductType; 249544a5e07SHong Zhang PETSC_EXTERN const char *const MatProductTypes[]; 2504222ddf1SHong Zhang 2514222ddf1SHong Zhang /*J 2524222ddf1SHong Zhang MatProductAlgorithm - String with the name of an algorithm for a PETSc matrix product implementation 2534222ddf1SHong Zhang 2544222ddf1SHong Zhang Level: beginner 2554222ddf1SHong Zhang 2561cc06b55SBarry Smith .seealso: [](sec_matmatproduct), [](ch_matrices), `MatSetType()`, `Mat`, `MatProductSetAlgorithm()`, `MatProductType` 2574222ddf1SHong Zhang J*/ 2584222ddf1SHong Zhang typedef const char *MatProductAlgorithm; 2593e662e0bSHong Zhang #define MATPRODUCTALGORITHMDEFAULT "default" 2603e662e0bSHong Zhang #define MATPRODUCTALGORITHMSORTED "sorted" 2613e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLE "scalable" 2623e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLEFAST "scalable_fast" 2633e662e0bSHong Zhang #define MATPRODUCTALGORITHMHEAP "heap" 2643e662e0bSHong Zhang #define MATPRODUCTALGORITHMBHEAP "btheap" 2653e662e0bSHong Zhang #define MATPRODUCTALGORITHMLLCONDENSED "llcondensed" 2663e662e0bSHong Zhang #define MATPRODUCTALGORITHMROWMERGE "rowmerge" 2673e662e0bSHong Zhang #define MATPRODUCTALGORITHMOUTERPRODUCT "outerproduct" 2683e662e0bSHong Zhang #define MATPRODUCTALGORITHMATB "at*b" 2693e662e0bSHong Zhang #define MATPRODUCTALGORITHMRAP "rap" 2703e662e0bSHong Zhang #define MATPRODUCTALGORITHMNONSCALABLE "nonscalable" 2713e662e0bSHong Zhang #define MATPRODUCTALGORITHMSEQMPI "seqmpi" 2723e662e0bSHong Zhang #define MATPRODUCTALGORITHMBACKEND "backend" 2733e662e0bSHong Zhang #define MATPRODUCTALGORITHMOVERLAPPING "overlapping" 2743e662e0bSHong Zhang #define MATPRODUCTALGORITHMMERGED "merged" 2753e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCE "allatonce" 2763e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCEMERGED "allatonce_merged" 2773e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLGATHERV "allgatherv" 2783e662e0bSHong Zhang #define MATPRODUCTALGORITHMCYCLIC "cyclic" 2793e662e0bSHong Zhang #if defined(PETSC_HAVE_HYPRE) 2803e662e0bSHong Zhang #define MATPRODUCTALGORITHMHYPRE "hypre" 2813e662e0bSHong Zhang #endif 2824222ddf1SHong Zhang 2834222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreate(Mat, Mat, Mat, Mat *); 2844222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreateWithMat(Mat, Mat, Mat, Mat); 2854222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetType(Mat, MatProductType); 2864222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetAlgorithm(Mat, MatProductAlgorithm); 2874222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFill(Mat, PetscReal); 2884222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFromOptions(Mat); 2894222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSymbolic(Mat); 2904222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductNumeric(Mat); 2914222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductReplaceMats(Mat, Mat, Mat, Mat); 2924417c5e8SHong Zhang PETSC_EXTERN PetscErrorCode MatProductClear(Mat); 2936718818eSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductView(Mat, PetscViewer); 294c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetType(Mat, MatProductType *); 295c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetMats(Mat, Mat *, Mat *, Mat *); 2964222ddf1SHong Zhang 297c06d978dSMatthew Knepley /* Logging support */ 2980700a824SBarry Smith #define MAT_FILE_CLASSID 1211216 /* used to indicate matrices in binary files */ 299014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_CLASSID; 300335efc43SPeter Brune PETSC_EXTERN PetscClassId MAT_COLORING_CLASSID; 301014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID; 302014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID; 303014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID; 304014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID; 305014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID; 306014dd563SJed Brown PETSC_EXTERN PetscClassId MATMFFD_CLASSID; 307c06d978dSMatthew Knepley 308ceb03754SKris Buschelman /*E 3092ef1f0ffSBarry Smith MatReuse - Indicates if matrices obtained from a previous call to `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatConvert()` or several other functions 310cf37664fSBarry Smith are to be reused to store the new matrix values. 311cf37664fSBarry Smith 3122ef1f0ffSBarry Smith Values: 3132ef1f0ffSBarry Smith + `MAT_INITIAL_MATRIX` - create a new matrix 3142ef1f0ffSBarry Smith . `MAT_REUSE_MATRIX` - reuse the matrix created with a previous call that used `MAT_INITIAL_MATRIX` 3152ef1f0ffSBarry Smith . `MAT_INPLACE_MATRIX` - replace the first input matrix with the new matrix (not applicable to all functions) 3162ef1f0ffSBarry 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) 317ceb03754SKris Buschelman 318ceb03754SKris Buschelman Level: beginner 319ceb03754SKris Buschelman 3201cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatDestroyMatrices()`, `MatConvert()` 321ceb03754SKris Buschelman E*/ 3229371c9d4SSatish Balay typedef enum { 3239371c9d4SSatish Balay MAT_INITIAL_MATRIX, 3249371c9d4SSatish Balay MAT_REUSE_MATRIX, 3259371c9d4SSatish Balay MAT_IGNORE_MATRIX, 3269371c9d4SSatish Balay MAT_INPLACE_MATRIX 3279371c9d4SSatish Balay } MatReuse; 328ceb03754SKris Buschelman 3295494a064SHong Zhang /*E 3302ef1f0ffSBarry Smith MatCreateSubMatrixOption - Indicates if matrices obtained from a call to `MatCreateSubMatrices()` 3312ef1f0ffSBarry Smith include the matrix values. Currently it is only used by `MatGetSeqNonzeroStructure()`. 3325494a064SHong Zhang 3332ef1f0ffSBarry Smith Values: 3342ef1f0ffSBarry Smith + `MAT_DO_NOT_GET_VALUES` - do not copy the matrix values 3352ef1f0ffSBarry Smith - `MAT_GET_VALUES` - copy the matrix values 3362ef1f0ffSBarry Smith 33795bd0b28SBarry Smith Level: developer 33895bd0b28SBarry Smith 3392ef1f0ffSBarry Smith Developer Note: 3402ef1f0ffSBarry Smith Why is not just a boolean used for this information? 3412ef1f0ffSBarry Smith 3421cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatDuplicateOption`, `PetscCopyMode`, `MatGetSeqNonzeroStructure()` 3435494a064SHong Zhang E*/ 3449371c9d4SSatish Balay typedef enum { 3459371c9d4SSatish Balay MAT_DO_NOT_GET_VALUES, 3469371c9d4SSatish Balay MAT_GET_VALUES 3479371c9d4SSatish Balay } MatCreateSubMatrixOption; 3485494a064SHong Zhang 349607a6623SBarry Smith PETSC_EXTERN PetscErrorCode MatInitializePackage(void); 3504bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatFinalizePackage(void); 351c06d978dSMatthew Knepley 352014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm, Mat *); 35377433607SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFromOptions(MPI_Comm, const char *, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 354014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetSizes(Mat, PetscInt, PetscInt, PetscInt, PetscInt); 35519fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatSetType(Mat, MatType); 3560d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatGetVecType(Mat, VecType *); 3570d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetVecType(Mat, VecType); 358014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat); 359fe2efc57SMark PETSC_EXTERN PetscErrorCode MatViewFromOptions(Mat, PetscObject, const char[]); 360bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatRegister(const char[], PetscErrorCode (*)(Mat)); 36123bebc0bSBarry Smith PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[], const char[], const char[]); 362014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat, const char[]); 36326cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOptionsPrefixFactor(Mat, const char[]); 36426cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefixFactor(Mat, const char[]); 365014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat, const char[]); 366014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat, const char *[]); 36784d44b13SHong Zhang PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat, PetscBool); 368f69a0ea3SMatthew Knepley 369140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatList; 370140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatColoringList; 371140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatPartitioningList; 37228988994SBarry Smith 3733b224e63SBarry Smith /*E 374aa6c7ce3SBarry Smith MatStructure - Indicates if two matrices have the same nonzero structure 3753b224e63SBarry Smith 3762ef1f0ffSBarry Smith Values: 3772ef1f0ffSBarry Smith + `SAME_NONZERO_PATTERN` - the two matrices have identical nonzero patterns 3782ef1f0ffSBarry Smith . `DIFFERENT_NONZERO_PATTERN` - the two matrices may have different nonzero patterns 3792ef1f0ffSBarry Smith . `SUBSET_NONZERO_PATTERN` - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix 3802ef1f0ffSBarry Smith - `UNKNOWN_NONZERO_PATTERN` - there is no known relationship between the nonzero patterns. In this case the implementations 3812ef1f0ffSBarry Smith may try to detect a relationship to optimize the operation 382531d0c6aSBarry Smith 38316a05f60SBarry Smith Level: beginner 38416a05f60SBarry Smith 385*af27ebaaSBarry Smith Note: 386*af27ebaaSBarry Smith Certain matrix operations (such as `MatAXPY()`) can run much faster if the sparsity pattern of the matrices are the same. But actually determining if 387*af27ebaaSBarry Smith the patterns are the same may be costly. This provides a way for users who know something about the sparsity patterns to provide this information 388*af27ebaaSBarry Smith to certain PETSc routines. 389*af27ebaaSBarry Smith 3901cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCopy()`, `MatAXPY()`, `MatAYPX()` 3913b224e63SBarry Smith E*/ 3929371c9d4SSatish Balay typedef enum { 3939371c9d4SSatish Balay DIFFERENT_NONZERO_PATTERN, 3949371c9d4SSatish Balay SUBSET_NONZERO_PATTERN, 3959371c9d4SSatish Balay SAME_NONZERO_PATTERN, 3969371c9d4SSatish Balay UNKNOWN_NONZERO_PATTERN 3979371c9d4SSatish Balay } MatStructure; 398d60b7d5cSBarry Smith PETSC_EXTERN const char *const MatStructures[]; 3993b224e63SBarry Smith 4009779e05dSSatish Balay #if defined PETSC_HAVE_MKL_SPARSE 401ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 402ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 40380095d54SIrina Sokolova PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 404ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 40580095d54SIrina Sokolova #endif 406cd929ea3SAlp Dener 4074bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateMPIAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 4084bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 4094bf303faSJacob Faibussowitsch 410d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 411d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 412d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat, PetscInt, const PetscInt[]); 413d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 41407e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetFillRatio(Mat, PetscReal *); 41507e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetMaxSliceWidth(Mat, PetscInt *); 41607e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetAvgSliceWidth(Mat, PetscReal *); 41707e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetSliceHeight(Mat, PetscInt); 418b921024eSHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetVarSliceSize(Mat, PetscReal *); 41980095d54SIrina Sokolova 4204bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 4214bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 422fa078d78SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMPISELLGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *); 423fa078d78SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMPISELLGetSeqSELL(Mat, Mat *, Mat *, const PetscInt *[]); 4244bf303faSJacob Faibussowitsch 425014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 426014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 427014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 428014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 429014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 4308f8f2f0dSBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 4316a3d2595SBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArray(Mat, const PetscScalar[]); 432014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], PetscInt[], PetscInt[], PetscScalar[], Mat *); 4333b00a383SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm, Mat, Mat, const PetscInt[], Mat *); 4343b00a383SHong Zhang 435014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 436014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 437014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 4387e8381f9SStefano Zampini 439e8729f6fSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSetPreallocationCOO(Mat, PetscCount, PetscInt[], PetscInt[]); 44082a78a4eSJed Brown PETSC_EXTERN PetscErrorCode MatSetPreallocationCOOLocal(Mat, PetscCount, PetscInt[], PetscInt[]); 4417e8381f9SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetValuesCOO(Mat, const PetscScalar[], InsertMode); 442d21a29f3SJed Brown 443014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscInt[], Mat *); 444014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 445d21a29f3SJed Brown 446014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 447014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 44838f409ebSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 449014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 4504cce697cSJed Brown PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscInt[], const PetscInt[]); 451dfb205c3SBarry Smith 452014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, void *, Mat *); 453c1fff1c6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatCreateCentering(MPI_Comm, PetscInt, PetscInt, Mat *); 454014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat, Mat *); 455c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat, Mat *); 456986c4d72SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat, Mat, Vec, Mat, Mat *); 457267ca84cSJose E. Roman PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat, Mat *, Mat *, Vec *, Mat *); 458bcf2175cSMatthew Knepley PETSC_EXTERN PetscErrorCode MatLRCSetMats(Mat, Mat, Mat, Vec, Mat); 459c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, ISLocalToGlobalMapping, ISLocalToGlobalMapping, Mat *); 460014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 461014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 462c0cdd4a1SDahai Guo 463014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm, VecScatter, Mat *); 464014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat, VecScatter); 465014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat, VecScatter *); 466014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt *, Mat *); 467014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat, Mat); 468014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat); 4699371c9d4SSatish Balay typedef enum { 4709371c9d4SSatish Balay MAT_COMPOSITE_MERGE_RIGHT, 4719371c9d4SSatish Balay MAT_COMPOSITE_MERGE_LEFT 4729371c9d4SSatish Balay } MatCompositeMergeType; 4738c8613bfSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat, MatCompositeMergeType); 474014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm, PetscInt, const Mat *, Mat *); 4759371c9d4SSatish Balay typedef enum { 4769371c9d4SSatish Balay MAT_COMPOSITE_ADDITIVE, 4779371c9d4SSatish Balay MAT_COMPOSITE_MULTIPLICATIVE 4789371c9d4SSatish Balay } MatCompositeType; 479014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat, MatCompositeType); 4806dbc55e5SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat, MatCompositeType *); 4813b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat, MatStructure); 4823b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat, MatStructure *); 4836d0add67SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat, PetscInt *); 4848b5c3584SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat, PetscInt, Mat *); 48503049c21SJunchao Zhang PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat, const PetscScalar *); 4866d7c1e57SBarry Smith 48719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm, PetscInt, const PetscInt[], MatType, Mat *); 488014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm, PetscInt, const PetscInt[], Mat *); 489dedccee8SHong Zhang 490014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat, Mat *); 4918060fb66Sstefano_zampini PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat, Mat *); 492d0de2241SAndrew Spott PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat, Mat *); 49306511a5cSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat, Mat *); 494fa80d070SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalGetMat(Mat, Mat *); 49565f45395SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalHermitianGetMat(Mat, Mat *); 49654e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat, IS, IS, Mat *); 49754e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat, Mat, IS, IS); 498014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat, IS, IS, Mat *); 4993423f386SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar, Mat *); 500345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatCreateDiagonal(Vec, Mat *); 501345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalGetDiagonal(Mat, Vec *); 502345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalRestoreDiagonal(Mat, Vec *); 503345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalGetInverseDiagonal(Mat, Vec *); 504345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalRestoreInverseDiagonal(Mat, Vec *); 5051472f72bSBarry Smith 506978814f1SStefano Zampini #if defined(PETSC_HAVE_HYPRE) 507d975228cSstefano_zampini PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 508978814f1SStefano Zampini #endif 509978814f1SStefano Zampini 510014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat, const char[]); 511ebead697SStefano Zampini PETSC_EXTERN PetscErrorCode MatPythonGetType(Mat, const char *[]); 5121d6018f0SLisandro Dalcin 513846b4da1SFande Kong PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat); 514014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetUp(Mat); 515014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroy(Mat *); 516e56f5c9eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat, PetscObjectState *); 51721c89e3eSBarry Smith 518014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatConjugate(Mat); 519014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRealPart(Mat); 520014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat); 521014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat, Mat *); 522014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetTrace(Mat, PetscScalar *); 523713ccfa9SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat, const PetscScalar **); 5240da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat, PetscInt, const PetscInt *, PetscScalar *); 525479a70c0SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat, Mat); 5268a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockEnvelope(Mat, MatReuse, Mat *); 52720c04d79SPierre Jolivet PETSC_EXTERN PetscErrorCode MatComputeVariableBlockEnvelope(Mat); 52899cafbc1SBarry Smith 529014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 5308a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetValuesIS(Mat, IS, IS, const PetscScalar[], InsertMode); 531014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 532014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat, PetscInt, const PetscScalar[]); 533014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat, PetscInt, const PetscScalar[]); 534014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat, PetscInt, PetscInt, PetscInt[], const PetscScalar[]); 53573a71a0fSBarry Smith PETSC_EXTERN PetscErrorCode MatSetRandom(Mat, PetscRandom); 53684cb2905SBarry Smith 5372ef4de8bSBarry Smith /*S 5382ef1f0ffSBarry Smith MatStencil - Data structure (C struct) for storing information about rows and 5392ef1f0ffSBarry Smith columns of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()` 54062ef0227SBarry Smith 5412ef1f0ffSBarry Smith Level: beginner 5422ef1f0ffSBarry Smith 5432ef1f0ffSBarry Smith Notes: 54462ef0227SBarry 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). 54587497f52SBarry 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. 54662ef0227SBarry Smith 54787497f52SBarry Smith For stencil access to vectors see `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`. 548be479b30SJed Brown 5492ef1f0ffSBarry Smith For staggered grids, see `DMStagStencil` 5502ef4de8bSBarry Smith 5512ef1f0ffSBarry Smith Fortran Note: 5522ef1f0ffSBarry Smith See `MatSetValuesStencil()` for details. 5532ef4de8bSBarry Smith 5541cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`, 5552ef1f0ffSBarry Smith `DMStagStencil` 5562ef4de8bSBarry Smith S*/ 557435da068SBarry Smith typedef struct { 558c1ac3661SBarry Smith PetscInt k, j, i, c; 559435da068SBarry Smith } MatStencil; 5602ef4de8bSBarry Smith 561014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode); 562014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode); 563014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetStencil(Mat, PetscInt, const PetscInt[], const PetscInt[], PetscInt); 564435da068SBarry Smith 565d91e6319SBarry Smith /*E 5662ef1f0ffSBarry Smith MatAssemblyType - Indicates if the process of setting values into the matrix is complete, and the matrix is ready for use 567d91e6319SBarry Smith 5682ef1f0ffSBarry Smith Values: 5692ef1f0ffSBarry Smith + `MAT_FLUSH_ASSEMBLY` - you will continue to put values into the matrix 5702ef1f0ffSBarry Smith - `MAT_FINAL_ASSEMBLY` - you wish to use the matrix with the values currently inserted 5712ef1f0ffSBarry Smith 57216a05f60SBarry Smith Level: beginner 57316a05f60SBarry Smith 5741cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetValues`, `MatAssemblyBegin()`, `MatAssemblyEnd()` 575d91e6319SBarry Smith E*/ 5769371c9d4SSatish Balay typedef enum { 5779371c9d4SSatish Balay MAT_FLUSH_ASSEMBLY = 1, 5789371c9d4SSatish Balay MAT_FINAL_ASSEMBLY = 0 5799371c9d4SSatish Balay } MatAssemblyType; 580014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat, MatAssemblyType); 581014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat, MatAssemblyType); 582014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssembled(Mat, PetscBool *); 5834f9c727eSBarry Smith 584d91e6319SBarry Smith /*E 5852ef1f0ffSBarry Smith MatOption - Options that may be set for a matrix that indicate properties of the matrix or affect its behavior or storage 586d91e6319SBarry Smith 587d91e6319SBarry Smith Level: beginner 588d91e6319SBarry Smith 5892ef1f0ffSBarry Smith Note: 5902ef1f0ffSBarry Smith See `MatSetOption()` for the use of the options 5912ef1f0ffSBarry Smith 5922ef1f0ffSBarry Smith Developer Note: 59395452b02SPatrick Sanan Entries that are negative need not be called collectively by all processes. 594382164b0SBarry Smith 5951cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetOption()` 596d91e6319SBarry Smith E*/ 5979371c9d4SSatish Balay typedef enum { 5989371c9d4SSatish Balay MAT_OPTION_MIN = -3, 599c5e4d11fSDmitry Karpeev MAT_UNUSED_NONZERO_LOCATION_ERR = -2, 60092d4d306SBarry Smith MAT_ROW_ORIENTED = -1, 601382164b0SBarry Smith MAT_SYMMETRIC = 1, 602382164b0SBarry Smith MAT_STRUCTURALLY_SYMMETRIC = 2, 6038c78258cSHong Zhang MAT_FORCE_DIAGONAL_ENTRIES = 3, 604382164b0SBarry Smith MAT_IGNORE_OFF_PROC_ENTRIES = 4, 605382164b0SBarry Smith MAT_USE_HASH_TABLE = 5, 606382164b0SBarry Smith MAT_KEEP_NONZERO_PATTERN = 6, 607382164b0SBarry Smith MAT_IGNORE_ZERO_ENTRIES = 7, 608382164b0SBarry Smith MAT_USE_INODES = 8, 609382164b0SBarry Smith MAT_HERMITIAN = 9, 610382164b0SBarry Smith MAT_SYMMETRY_ETERNAL = 10, 611c5e4d11fSDmitry Karpeev MAT_NEW_NONZERO_LOCATION_ERR = 11, 612382164b0SBarry Smith MAT_IGNORE_LOWER_TRIANGULAR = 12, 613382164b0SBarry Smith MAT_ERROR_LOWER_TRIANGULAR = 13, 614382164b0SBarry Smith MAT_GETROW_UPPERTRIANGULAR = 14, 615382164b0SBarry Smith MAT_SPD = 15, 61692d4d306SBarry Smith MAT_NO_OFF_PROC_ZERO_ROWS = 16, 61792d4d306SBarry Smith MAT_NO_OFF_PROC_ENTRIES = 17, 61892d4d306SBarry Smith MAT_NEW_NONZERO_LOCATIONS = 18, 619c5e4d11fSDmitry Karpeev MAT_NEW_NONZERO_ALLOCATION_ERR = 19, 620c5e4d11fSDmitry Karpeev MAT_SUBSET_OFF_PROC_ENTRIES = 20, 621c10200c1SHong Zhang MAT_SUBMAT_SINGLEIS = 21, 622957cac9fSHong Zhang MAT_STRUCTURE_ONLY = 22, 623071fcb05SBarry Smith MAT_SORTED_FULL = 23, 6241a2c6b5cSJunchao Zhang MAT_FORM_EXPLICIT_TRANSPOSE = 24, 625b94d7dedSBarry Smith MAT_STRUCTURAL_SYMMETRY_ETERNAL = 25, 626b94d7dedSBarry Smith MAT_SPD_ETERNAL = 26, 6279371c9d4SSatish Balay MAT_OPTION_MAX = 27 6289371c9d4SSatish Balay } MatOption; 629e057df02SPaul Mullowney 6300f8fb01aSBarry Smith PETSC_EXTERN const char *const *MatOptions; 631014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOption(Mat, MatOption, PetscBool); 6327d68702bSBarry Smith PETSC_EXTERN PetscErrorCode MatGetOption(Mat, MatOption, PetscBool *); 633856afa8bSStefano Zampini PETSC_EXTERN PetscErrorCode MatPropagateSymmetryOptions(Mat, Mat); 63419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatGetType(Mat, MatType *); 63584cb2905SBarry Smith 636014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]); 637014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]); 638014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]); 639014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowUpperTriangular(Mat); 640014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowUpperTriangular(Mat); 641014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnVector(Mat, Vec, PetscInt); 6428c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJGetArray(Mat, PetscScalar *[]); 6438f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayRead(Mat, const PetscScalar *[]); 644d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayWrite(Mat, PetscScalar *[]); 6458c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArray(Mat, PetscScalar *[]); 6468f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayRead(Mat, const PetscScalar *[]); 647d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayWrite(Mat, PetscScalar *[]); 64821e72a00SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJGetMaxRowNonzeros(Mat, PetscInt *); 649bd04181cSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetValuesLocalFast(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 6504099cc6bSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetType(Mat, MatType); 651ad7e164aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatSeqAIJKron(Mat, Mat, MatReuse, Mat *); 652388d47a6SSatish Balay PETSC_EXTERN PetscErrorCode MatSeqAIJRegister(const char[], PetscErrorCode (*)(Mat, MatType, MatReuse, Mat *)); 6534099cc6bSBarry Smith PETSC_EXTERN PetscFunctionList MatSeqAIJList; 654cda14afcSprj- PETSC_EXTERN PetscErrorCode MatSeqBAIJGetArray(Mat, PetscScalar *[]); 655cda14afcSprj- PETSC_EXTERN PetscErrorCode MatSeqBAIJRestoreArray(Mat, PetscScalar *[]); 6568397e458SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqSBAIJGetArray(Mat, PetscScalar *[]); 6578397e458SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqSBAIJRestoreArray(Mat, PetscScalar *[]); 6588c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetArray(Mat, PetscScalar *[]); 6598c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseRestoreArray(Mat, PetscScalar *[]); 660d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode MatDensePlaceArray(Mat, const PetscScalar[]); 661d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseReplaceArray(Mat, const PetscScalar[]); 662d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseResetArray(Mat); 6638572280aSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetArrayRead(Mat, const PetscScalar *[]); 6648572280aSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayRead(Mat, const PetscScalar *[]); 6656947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetArrayWrite(Mat, PetscScalar *[]); 6666947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWrite(Mat, PetscScalar *[]); 667cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseGetArrayAndMemType(Mat, PetscScalar *[], PetscMemType *); 668cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayAndMemType(Mat, PetscScalar *[]); 669cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseGetArrayReadAndMemType(Mat, const PetscScalar *[], PetscMemType *); 670cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayReadAndMemType(Mat, const PetscScalar *[]); 671cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseGetArrayWriteAndMemType(Mat, PetscScalar *[], PetscMemType *); 672cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWriteAndMemType(Mat, PetscScalar *[]); 673014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBlockSize(Mat, PetscInt *); 674014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSize(Mat, PetscInt); 675014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBlockSizes(Mat, PetscInt *, PetscInt *); 676014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSizes(Mat, PetscInt, PetscInt); 67733d57670SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSizesFromMats(Mat, Mat, Mat); 6780da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetVariableBlockSizes(Mat, PetscInt, PetscInt *); 6790da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetVariableBlockSizes(Mat, PetscInt *, const PetscInt **); 6800da83c2eSBarry Smith 68186aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat, PetscInt, PetscScalar *[]); 68286aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat, PetscScalar *[]); 6836947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVec(Mat, PetscInt, Vec *); 6846947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVec(Mat, PetscInt, Vec *); 6856947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecRead(Mat, PetscInt, Vec *); 6866947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecRead(Mat, PetscInt, Vec *); 6876947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecWrite(Mat, PetscInt, Vec *); 6886947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecWrite(Mat, PetscInt, Vec *); 689a2748737SPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseGetSubMatrix(Mat, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 6905ea7661aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseRestoreSubMatrix(Mat, Mat *); 6911620fd73SBarry Smith 692014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMult(Mat, Vec, Vec); 693014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat, Vec, Vec); 694014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAdd(Mat, Vec, Vec, Vec); 695014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat, Vec, Vec); 696014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat, Vec, Vec); 697014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat, Mat, PetscReal, PetscBool *); 698014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat, Mat, PetscReal, PetscBool *); 699014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat, Vec, Vec, Vec); 700014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat, Vec, Vec, Vec); 701014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatSolve(Mat, Mat, Mat); 702bdc285e1SStefano Zampini PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat, Mat, Mat); 703eb3ef3b2SHong Zhang PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat, Mat, Mat); 704f9426fe0SMark Adams PETSC_EXTERN PetscErrorCode MatResidual(Mat, Vec, Vec, Vec); 705f5edf698SHong Zhang 706d91e6319SBarry Smith /*E 707d91e6319SBarry Smith MatDuplicateOption - Indicates if a duplicated sparse matrix should have 708d91e6319SBarry Smith its numerical values copied over or just its nonzero structure. 709d91e6319SBarry Smith 7102ef1f0ffSBarry Smith Values: 7112ef1f0ffSBarry Smith + `MAT_DO_NOT_COPY_VALUES` - Create a matrix using the same nonzero pattern as the original matrix, 7122ef1f0ffSBarry Smith with zeros for the numerical values 7132ef1f0ffSBarry Smith . `MAT_COPY_VALUES` - Create a matrix with the same nonzero pattern as the original matrix 7142ef1f0ffSBarry Smith and with the same numerical values. 7152ef1f0ffSBarry Smith - `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix 7162ef1f0ffSBarry Smith and does not copy it, using zeros for the numerical values. The parent and 7172ef1f0ffSBarry Smith child matrices will share their index (i and j) arrays, and you cannot 7182ef1f0ffSBarry Smith insert new nonzero entries into either matrix 7190018da39SRichard Tran Mills 72016a05f60SBarry Smith Level: beginner 72116a05f60SBarry Smith 72287497f52SBarry Smith Note: 72387497f52SBarry Smith Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in 72487497f52SBarry Smith this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified. 72570dcbbb9SBarry Smith 7261cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatDuplicate()` 727d91e6319SBarry Smith E*/ 7289371c9d4SSatish Balay typedef enum { 7299371c9d4SSatish Balay MAT_DO_NOT_COPY_VALUES, 7309371c9d4SSatish Balay MAT_COPY_VALUES, 7319371c9d4SSatish Balay MAT_SHARE_NONZERO_PATTERN 7329371c9d4SSatish Balay } MatDuplicateOption; 7332e8a6d31SBarry Smith 73419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatConvert(Mat, MatType, MatReuse, Mat *); 735014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDuplicate(Mat, MatDuplicateOption, Mat *); 73694a9d846SBarry Smith 737014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCopy(Mat, Mat, MatStructure); 738014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatView(Mat, PetscViewer); 739014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat, PetscReal, PetscBool *); 740014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat, PetscBool *); 741014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat, PetscReal, PetscBool *); 742014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat, PetscBool *, PetscBool *); 743014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat, PetscBool *, PetscBool *); 744b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetricKnown(Mat, PetscBool *, PetscBool *); 745b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsSPDKnown(Mat, PetscBool *, PetscBool *); 746014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMissingDiagonal(Mat, PetscBool *, PetscInt *); 747014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer); 7487b80b807SBarry Smith 7491a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 7501a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 7511a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 7521a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 753d4fbbf0eSBarry Smith 754d91e6319SBarry Smith /*S 75587497f52SBarry Smith MatInfo - Context of matrix information, used with `MatGetInfo()` 756d91e6319SBarry Smith 757d91e6319SBarry Smith Level: intermediate 758d91e6319SBarry Smith 7592ef1f0ffSBarry Smith Fortran Note: 7602ef1f0ffSBarry Smith Information is stored as a double-precision array of dimension `MAT_INFO_SIZE` 7612ef1f0ffSBarry Smith 7621cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetInfo()`, `MatInfoType` 763d91e6319SBarry Smith S*/ 7644e220ebcSLois Curfman McInnes typedef struct { 765b0a32e0cSBarry Smith PetscLogDouble block_size; /* block size */ 766b0a32e0cSBarry Smith PetscLogDouble nz_allocated, nz_used, nz_unneeded; /* number of nonzeros */ 767b0a32e0cSBarry Smith PetscLogDouble memory; /* memory allocated */ 768b0a32e0cSBarry Smith PetscLogDouble assemblies; /* number of matrix assemblies called */ 769b0a32e0cSBarry Smith PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 770b0a32e0cSBarry Smith PetscLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */ 771b0a32e0cSBarry Smith PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 7724e220ebcSLois Curfman McInnes } MatInfo; 7734e220ebcSLois Curfman McInnes 774d9274352SBarry Smith /*E 775d9274352SBarry Smith MatInfoType - Indicates if you want information about the local part of the matrix, 776d9274352SBarry Smith the entire parallel matrix or the maximum over all the local parts. 777d9274352SBarry Smith 7782ef1f0ffSBarry Smith Values: 7792ef1f0ffSBarry Smith + `MAT_LOCAL` - values for each MPI process part of the matrix 7802ef1f0ffSBarry Smith . `MAT_GLOBAL_MAX` - maximum of each value over all MPI processes 7812ef1f0ffSBarry Smith - `MAT_GLOBAL_SUM` - sum of each value over all MPI processes 782d9274352SBarry Smith 78316a05f60SBarry Smith Level: beginner 78416a05f60SBarry Smith 7851cc06b55SBarry Smith .seealso: [](ch_matrices), `MatGetInfo()`, `MatInfo` 786d9274352SBarry Smith E*/ 7879371c9d4SSatish Balay typedef enum { 7889371c9d4SSatish Balay MAT_LOCAL = 1, 7899371c9d4SSatish Balay MAT_GLOBAL_MAX = 2, 7909371c9d4SSatish Balay MAT_GLOBAL_SUM = 3 7919371c9d4SSatish Balay } MatInfoType; 792014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInfo(Mat, MatInfoType, MatInfo *); 793014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat, Vec); 794014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat, Vec, PetscInt[]); 795014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat, Vec, PetscInt[]); 796014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat, Vec, PetscInt[]); 797014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat, Vec, PetscInt[]); 798014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat, Vec); 799014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTranspose(Mat, MatReuse, Mat *); 8007fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSymbolic(Mat, Mat *); 8017fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSetPrecursor(Mat, Mat); 802014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat, MatReuse, Mat *); 803014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPermute(Mat, IS, IS, Mat *); 804014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat, Vec, Vec); 805014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat, Vec, InsertMode); 806a52676ecSHong Zhang 807014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatEqual(Mat, Mat, PetscBool *); 808014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultEqual(Mat, Mat, PetscInt, PetscBool *); 809014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat, Mat, PetscInt, PetscBool *); 810014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat, Mat, PetscInt, PetscBool *); 811014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *); 812e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeEqual(Mat, Mat, PetscInt, PetscBool *); 813e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *); 814a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 815a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 816cc48ffa7SToby Isaac PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 8174222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatPtAPMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 818447fed29SStefano Zampini PETSC_EXTERN PetscErrorCode MatRARtMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 81986919fd6SHong Zhang PETSC_EXTERN PetscErrorCode MatIsLinear(Mat, PetscInt, PetscBool *); 8207b80b807SBarry Smith 821014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNorm(Mat, NormType, PetscReal *); 822014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat, NormType, PetscReal *); 823857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSums(Mat, PetscScalar *); 824857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsRealPart(Mat, PetscReal *); 825857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsImaginaryPart(Mat, PetscReal *); 826857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeans(Mat, PetscScalar *); 827857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansRealPart(Mat, PetscReal *); 828857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansImaginaryPart(Mat, PetscReal *); 829857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnReductions(Mat, PetscInt, PetscReal *); 830014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat); 8311b2b9847SBarry Smith PETSC_EXTERN PetscErrorCode MatSetInf(Mat); 832014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRows(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 833014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat, IS, PetscScalar, Vec, Vec); 834014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec); 835014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec); 836014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 837014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat, IS, PetscScalar, Vec, Vec); 8387b80b807SBarry Smith 839014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSize(Mat, PetscInt *, PetscInt *); 840014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat, PetscInt *, PetscInt *); 841014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat, PetscInt *, PetscInt *); 842014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat, const PetscInt **); 843014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat, PetscInt *, PetscInt *); 844014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat, const PetscInt **); 845566876eaSJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat, IS *, IS *); 8465ef9f2a5SBarry Smith 8477dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]); 848edd03b47SJacob 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[]) 849d71ae5a4SJacob Faibussowitsch { 8509371c9d4SSatish Balay return MatCreateSubMatrices(mat, n, irow, icol, scall, submat); 8519371c9d4SSatish Balay } 8527dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]); 853edd03b47SJacob 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[]) 854d71ae5a4SJacob Faibussowitsch { 8559371c9d4SSatish Balay return MatCreateSubMatricesMPI(mat, n, irow, icol, scall, submat); 8569371c9d4SSatish Balay } 857014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt, Mat *[]); 858df750dc8SHong Zhang PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt, Mat *[]); 8597dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat, IS, IS, MatReuse, Mat *); 860edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 8, 0, "MatCreateSubMatrix()", ) static inline PetscErrorCode MatGetSubMatrix(Mat mat, IS isrow, IS iscol, MatReuse cll, Mat *newmat) 861d71ae5a4SJacob Faibussowitsch { 8629371c9d4SSatish Balay return MatCreateSubMatrix(mat, isrow, iscol, cll, newmat); 8639371c9d4SSatish Balay } 864014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat, IS, IS, Mat *); 865014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat, IS, IS, Mat *); 866014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat, Mat *); 867014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat *); 8687b80b807SBarry Smith 869014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm, Mat, PetscInt, PetscInt, MatReuse, Mat *); 870014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm, Mat, PetscInt, PetscInt, Mat *); 871014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat, Mat); 872014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat, MatReuse, Mat *); 8738a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatAIJGetLocalMat(Mat, Mat *); 874014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *); 875ed502f03SStefano Zampini PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatMerge(Mat, MatReuse, IS *, Mat *); 876f2afee66SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJGetNumberNonzeros(Mat, PetscCount *); 877014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat, Mat, MatReuse, IS *, IS *, Mat *); 878014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *, const PetscInt *[]); 8798efafbd8SBarry Smith 880014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat, PetscInt, IS[], PetscInt); 881aa1e27eaSFande Kong PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat mat, PetscInt n, IS is[], PetscInt ov); 882d2b2a242SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat, PetscBool); 8837b80b807SBarry Smith 884014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatMult(Mat, Mat, MatReuse, PetscReal, Mat *); 88522440eb1SKris Buschelman 8867bab7c10SHong Zhang PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat, Mat, Mat, MatReuse, PetscReal, Mat *); 8872df6c5c3SPatrick Farrell PETSC_EXTERN PetscErrorCode MatGalerkin(Mat, Mat, Mat, MatReuse, PetscReal, Mat *); 8887bab7c10SHong Zhang 889014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPtAP(Mat, Mat, MatReuse, PetscReal, Mat *); 890014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRARt(Mat, Mat, MatReuse, PetscReal, Mat *); 89122440eb1SKris Buschelman 892014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat, Mat, MatReuse, PetscReal, Mat *); 893014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat, Mat, MatReuse, PetscReal, Mat *); 894bc011b1eSHong Zhang 895014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAXPY(Mat, PetscScalar, Mat, MatStructure); 896014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAYPX(Mat, PetscScalar, Mat, MatStructure); 8971c741599SHong Zhang 898014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScale(Mat, PetscScalar); 899014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShift(Mat, PetscScalar); 9007b80b807SBarry Smith 901014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping, ISLocalToGlobalMapping); 902014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *); 903a93ff8c4SPeter Brune PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat, PetscLayout *, PetscLayout *); 90481fa06acSBarry Smith PETSC_EXTERN PetscErrorCode MatSetLayouts(Mat, PetscLayout, PetscLayout); 905014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 906014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat, IS, PetscScalar, Vec, Vec); 907014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 908014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat, IS, PetscScalar, Vec, Vec); 909e265f6d6SPatrick Sanan PETSC_EXTERN PetscErrorCode MatGetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]); 910014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 911014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 912052efed2SBarry Smith 913014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat, PetscInt, PetscInt); 914014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat, PetscInt *, PetscInt *, PetscInt *, PetscInt *); 91590f02eecSBarry Smith 916014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolate(Mat, Vec, Vec); 917014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat, Vec, Vec, Vec); 918014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestrict(Mat, Vec, Vec); 91930b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolate(Mat, Mat, Mat *); 92030b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolateAdd(Mat, Mat, Mat, Mat *); 92130b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatRestrict(Mat, Mat, Mat *); 9222a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat, Vec *, Vec *); 923edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 6, 0, "MatCreateVecs()", ) static inline PetscErrorCode MatGetVecs(Mat mat, Vec *x, Vec *y) 924d71ae5a4SJacob Faibussowitsch { 9259371c9d4SSatish Balay return MatCreateVecs(mat, x, y); 9269371c9d4SSatish Balay } 92753cd1579SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat, PetscInt, MPI_Comm, MatReuse, Mat *); 928014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat, MPI_Comm, MatReuse, Mat *); 929014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat, IS *); 9303a062f41SBarry Smith PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat, IS *); 9319c8f2541SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm, Mat, PetscInt, MatReuse, Mat *); 932bd481603SBarry Smith 933c8d6c325SJunchao Zhang /*@C 9341620fd73SBarry Smith MatSetValue - Set a single entry into a matrix. 9351620fd73SBarry Smith 936e1c5b2e2SJose E. Roman Not Collective 937a9834a7dSSatish Balay 9381620fd73SBarry Smith Input Parameters: 939c8d6c325SJunchao Zhang + mat - the matrix 94016a05f60SBarry Smith . i - the row location of the entry 94116a05f60SBarry Smith . j - the column location of the entry 94216a05f60SBarry Smith . va - the value to insert 94387497f52SBarry Smith - mode - either `INSERT_VALUES` or `ADD_VALUES` 9441620fd73SBarry Smith 9451620fd73SBarry Smith Level: beginner 9461620fd73SBarry Smith 94795bd0b28SBarry Smith Notes: 94895bd0b28SBarry Smith This value may be cached, so `MatAssemblyBegin()` and `MatAssemblyEnd()` 94995bd0b28SBarry Smith MUST be called after all calls to `MatSetValue()` have been completed. 95095bd0b28SBarry Smith 9512ef1f0ffSBarry Smith For efficiency one should use `MatSetValues()` and set several values simultaneously. 9522ef1f0ffSBarry Smith 953b43fc34aSPierre Jolivet .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `InsertMode`, `MatGetValue()`, `MatSetValues()`, 9542ef1f0ffSBarry Smith `MatSetValueLocal()`, `MatSetValuesLocal()` 955c8d6c325SJunchao Zhang @*/ 956c8d6c325SJunchao Zhang static inline PetscErrorCode MatSetValue(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode) 957d71ae5a4SJacob Faibussowitsch { 958c8d6c325SJunchao Zhang return MatSetValues(mat, 1, &i, 1, &j, &va, mode); 9599371c9d4SSatish Balay } 9601620fd73SBarry Smith 961e5e5a7b5SPatrick Sanan /*@C 962e5e5a7b5SPatrick Sanan MatGetValue - Gets a single value from a matrix 9631620fd73SBarry Smith 964e5e5a7b5SPatrick Sanan Not Collective; can only return a value owned by the given process 965e5e5a7b5SPatrick Sanan 966e5e5a7b5SPatrick Sanan Input Parameters: 967e5e5a7b5SPatrick Sanan + mat - the matrix 968e5e5a7b5SPatrick Sanan . row - the row location of the entry 969e5e5a7b5SPatrick Sanan - col - the column location of the entry 970e5e5a7b5SPatrick Sanan 971e5e5a7b5SPatrick Sanan Output Parameter: 972e5e5a7b5SPatrick Sanan . va - the value 973e5e5a7b5SPatrick Sanan 9742ef1f0ffSBarry Smith Level: advanced 9752ef1f0ffSBarry Smith 976e5e5a7b5SPatrick Sanan Notes: 977b43fc34aSPierre Jolivet The matrix must have been assembled with `MatAssemblyBegin()` and `MatAssemblyEnd()` before this call 9782ef1f0ffSBarry Smith 97987497f52SBarry Smith For efficiency one should use `MatGetValues()` and get several values simultaneously. 980e5e5a7b5SPatrick Sanan 98187497f52SBarry Smith See notes for `MatGetValues()`. 982e5e5a7b5SPatrick Sanan 983b43fc34aSPierre Jolivet .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `MatSetValue()`, `MatGetValueLocal()`, `MatGetValues()` 984e5e5a7b5SPatrick Sanan @*/ 985d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode MatGetValue(Mat mat, PetscInt row, PetscInt col, PetscScalar *va) 986d71ae5a4SJacob Faibussowitsch { 9879371c9d4SSatish Balay return MatGetValues(mat, 1, &row, 1, &col, va); 9889371c9d4SSatish Balay } 989e5e5a7b5SPatrick Sanan 990c8d6c325SJunchao Zhang /*@C 9912ef1f0ffSBarry Smith MatSetValueLocal - Inserts or adds a single value into a matrix, using a local numbering of the nodes. 992e5e5a7b5SPatrick Sanan 993e5e5a7b5SPatrick Sanan Not Collective 994e5e5a7b5SPatrick Sanan 995e5e5a7b5SPatrick Sanan Input Parameters: 996c8d6c325SJunchao Zhang + mat - the matrix 99716a05f60SBarry Smith . i - the row location of the entry 99816a05f60SBarry Smith . j - the column location of the entry 99916a05f60SBarry Smith . va - the value to insert 100087497f52SBarry Smith - mode - either `INSERT_VALUES` or `ADD_VALUES` 1001e5e5a7b5SPatrick Sanan 10022ef1f0ffSBarry Smith Level: intermediate 10032ef1f0ffSBarry Smith 1004e5e5a7b5SPatrick Sanan Notes: 100587497f52SBarry Smith For efficiency one should use `MatSetValuesLocal()` and set several values simultaneously. 1006e5e5a7b5SPatrick Sanan 100787497f52SBarry Smith See notes for `MatSetValuesLocal()` for additional information on when and how this function can be used. 1008e5e5a7b5SPatrick Sanan 10091cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSetValue()`, `MatSetValuesLocal()` 1010c8d6c325SJunchao Zhang @*/ 1011c8d6c325SJunchao Zhang static inline PetscErrorCode MatSetValueLocal(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode) 1012d71ae5a4SJacob Faibussowitsch { 1013c8d6c325SJunchao Zhang return MatSetValuesLocal(mat, 1, &i, 1, &j, &va, mode); 10149371c9d4SSatish Balay } 10151620fd73SBarry Smith 10161620fd73SBarry Smith /*MC 1017d0609cedSBarry Smith MatPreallocateBegin - Begins the block of code that will count the number of nonzeros per 1018bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 1019bd481603SBarry Smith 1020bd481603SBarry Smith Synopsis: 1021aaa7dc30SBarry Smith #include <petscmat.h> 1022d0609cedSBarry Smith PetscErrorCode MatPreallocateBegin(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 1023bd481603SBarry Smith 1024d083f849SBarry Smith Collective 1025bd481603SBarry Smith 1026bd481603SBarry Smith Input Parameters: 1027bd481603SBarry Smith + comm - the communicator that will share the eventually allocated matrix 1028859fcb39SBarry Smith . nrows - the number of LOCAL rows in the matrix 1029859fcb39SBarry Smith - ncols - the number of LOCAL columns in the matrix 1030bd481603SBarry Smith 1031bd481603SBarry Smith Output Parameters: 1032bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 1033a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1034bd481603SBarry Smith 10352ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1036bd481603SBarry Smith 1037bd481603SBarry Smith Notes: 10382ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 10392ef1f0ffSBarry Smith the use of this routine 10402ef1f0ffSBarry Smith 1041d0609cedSBarry Smith This is a macro that handles its own error checking, it does not return an error code. 1042d0609cedSBarry Smith 10432ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1044bd481603SBarry Smith 10452ef1f0ffSBarry Smith Developer Note: 1046*af27ebaaSBarry Smith This is a MACRO, not a function, because it has a leading { that is closed by `PetscPreallocateFinalize()`. 1047bd481603SBarry Smith 10481cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1049db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()` 1050bd481603SBarry Smith M*/ 10519371c9d4SSatish Balay #define MatPreallocateBegin(comm, nrows, ncols, dnz, onz) \ 10529371c9d4SSatish Balay do { \ 10533ba16761SJacob Faibussowitsch PetscInt __nrows = (nrows), __ncols = (ncols), __rstart, __end = 0; \ 10543ba16761SJacob Faibussowitsch PetscInt PETSC_UNUSED __start; \ 10559566063dSJacob Faibussowitsch PetscCall(PetscCalloc2(__nrows, &(dnz), __nrows, &(onz))); \ 10569566063dSJacob Faibussowitsch PetscCallMPI(MPI_Scan(&__ncols, &__end, 1, MPIU_INT, MPI_SUM, comm)); \ 10579371c9d4SSatish Balay __start = __end - __ncols; \ 10589371c9d4SSatish Balay (void)__start; \ 10599566063dSJacob Faibussowitsch PetscCallMPI(MPI_Scan(&__nrows, &__rstart, 1, MPIU_INT, MPI_SUM, comm)); \ 10605f80ce2aSJacob Faibussowitsch __rstart -= __nrows 10617c922b88SBarry Smith 1062edd03b47SJacob Faibussowitsch #define MatPreallocateInitialize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateBegin()", ) MatPreallocateBegin(__VA_ARGS__) 1063d0609cedSBarry Smith 1064bd481603SBarry Smith /*MC 1065bd481603SBarry Smith MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1066bd481603SBarry Smith inserted using a local number of the rows and columns 1067bd481603SBarry Smith 1068bd481603SBarry Smith Synopsis: 1069aaa7dc30SBarry Smith #include <petscmat.h> 1070c1ac3661SBarry Smith PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1071bd481603SBarry Smith 1072bd481603SBarry Smith Not Collective 1073bd481603SBarry Smith 1074bd481603SBarry Smith Input Parameters: 1075784ac674SJed Brown + map - the row mapping from local numbering to global numbering 1076bd481603SBarry Smith . nrows - the number of rows indicated 10771d73ed98SBarry Smith . rows - the indices of the rows 1078784ac674SJed Brown . cmap - the column mapping from local to global numbering 1079bd481603SBarry Smith . ncols - the number of columns in the matrix 1080bd481603SBarry Smith . cols - the columns indicated 1081bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1082a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1083bd481603SBarry Smith 10842ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1085bd481603SBarry Smith 1086bd481603SBarry Smith Notes: 10872ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 10882ef1f0ffSBarry Smith the use of this routine 1089bd481603SBarry Smith 10902ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1091bd481603SBarry Smith 10921cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1093db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocalRemoveDups()` 1094bd481603SBarry Smith M*/ 109594bad497SJacob Faibussowitsch #define MatPreallocateSetLocal(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 10969371c9d4SSatish 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));) 1097c4f061fbSSatish Balay 1098bd481603SBarry Smith /*MC 1099c1154cd5SBarry Smith MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1100c1154cd5SBarry Smith inserted using a local number of the rows and columns. This version removes any duplicate columns in cols 1101c1154cd5SBarry Smith 1102c1154cd5SBarry Smith Synopsis: 1103c1154cd5SBarry Smith #include <petscmat.h> 1104c1154cd5SBarry Smith PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1105c1154cd5SBarry Smith 1106c1154cd5SBarry Smith Not Collective 1107c1154cd5SBarry Smith 1108c1154cd5SBarry Smith Input Parameters: 1109c1154cd5SBarry Smith + map - the row mapping from local numbering to global numbering 1110c1154cd5SBarry Smith . nrows - the number of rows indicated 1111c1154cd5SBarry Smith . rows - the indices of the rows (these values are mapped to the global values) 1112c1154cd5SBarry Smith . cmap - the column mapping from local to global numbering 1113c1154cd5SBarry Smith . ncols - the number of columns in the matrix (this value will be changed if duplicate columns are found) 1114c1154cd5SBarry Smith . cols - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed) 1115c1154cd5SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1116a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1117c1154cd5SBarry Smith 11182ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1119c1154cd5SBarry Smith 1120c1154cd5SBarry Smith Notes: 11212ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 11222ef1f0ffSBarry Smith the use of this routine 1123c1154cd5SBarry Smith 11242ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1125c1154cd5SBarry Smith 11261cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1127db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()` 1128c1154cd5SBarry Smith M*/ 112994bad497SJacob Faibussowitsch #define MatPreallocateSetLocalRemoveDups(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 11309371c9d4SSatish 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));) 1131c1154cd5SBarry Smith 1132c1154cd5SBarry Smith /*MC 1133d6e23781SBarry Smith MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1134bd481603SBarry Smith inserted using a local number of the rows and columns 1135bd481603SBarry Smith 1136bd481603SBarry Smith Synopsis: 1137aaa7dc30SBarry Smith #include <petscmat.h> 1138d6e23781SBarry Smith PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1139d6e23781SBarry Smith 1140d6e23781SBarry Smith Not Collective 1141d6e23781SBarry Smith 1142d6e23781SBarry Smith Input Parameters: 1143d6e23781SBarry Smith + map - the row mapping from local numbering to global numbering 1144d6e23781SBarry Smith . nrows - the number of rows indicated 1145d6e23781SBarry Smith . rows - the indices of the rows 1146d6e23781SBarry Smith . cmap - the column mapping from local to global numbering 1147d6e23781SBarry Smith . ncols - the number of columns in the matrix 1148d6e23781SBarry Smith . cols - the columns indicated 1149d6e23781SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1150a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1151d6e23781SBarry Smith 11522ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1153d6e23781SBarry Smith 1154d6e23781SBarry Smith Notes: 11552ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 11562ef1f0ffSBarry Smith the use of this routine 1157d6e23781SBarry Smith 11582ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1159d6e23781SBarry Smith 11601cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1161db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()` 1162d6e23781SBarry Smith M*/ 116394bad497SJacob Faibussowitsch #define MatPreallocateSetLocalBlock(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 11649371c9d4SSatish 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));) 1165d6e23781SBarry Smith 1166d6e23781SBarry Smith /*MC 1167d6e23781SBarry Smith MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1168d6e23781SBarry Smith inserted using a local number of the rows and columns 1169d6e23781SBarry Smith 1170d6e23781SBarry Smith Synopsis: 1171d6e23781SBarry Smith #include <petscmat.h> 1172d6e23781SBarry Smith PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1173bd481603SBarry Smith 1174bd481603SBarry Smith Not Collective 1175bd481603SBarry Smith 1176bd481603SBarry Smith Input Parameters: 1177bd481603SBarry Smith + map - the mapping between local numbering and global numbering 1178bd481603SBarry Smith . nrows - the number of rows indicated 11791d73ed98SBarry Smith . rows - the indices of the rows 1180bd481603SBarry Smith . ncols - the number of columns in the matrix 1181bd481603SBarry Smith . cols - the columns indicated 1182bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1183a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1184bd481603SBarry Smith 11852ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1186bd481603SBarry Smith 1187bd481603SBarry Smith Notes: 11882ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 11892ef1f0ffSBarry Smith the use of this routine 1190bd481603SBarry Smith 11912ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 1192bd481603SBarry Smith 11931cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()` 1194db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSetLocal()` 1195bd481603SBarry Smith M*/ 119694bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetLocalBlock(map, nrows, rows, ncols, cols, dnz, onz) \ 11979371c9d4SSatish 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));) 1198e83a5d19SLisandro Dalcin 1199bd481603SBarry Smith /*MC 1200bd481603SBarry Smith MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1201bd481603SBarry Smith inserted using a local number of the rows and columns 1202bd481603SBarry Smith 1203bd481603SBarry Smith Synopsis: 1204aaa7dc30SBarry Smith #include <petscmat.h> 1205c1ac3661SBarry Smith PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1206bd481603SBarry Smith 1207bd481603SBarry Smith Not Collective 1208bd481603SBarry Smith 1209bd481603SBarry Smith Input Parameters: 121064075487SBarry Smith + row - the row 1211bd481603SBarry Smith . ncols - the number of columns in the matrix 1212a50f8bf6SHong Zhang - cols - the columns indicated 1213a50f8bf6SHong Zhang 1214a50f8bf6SHong Zhang Output Parameters: 1215a50f8bf6SHong Zhang + dnz - the array that will be passed to the matrix preallocation routines 1216a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1217bd481603SBarry Smith 12182ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1219bd481603SBarry Smith 1220bd481603SBarry Smith Notes: 12212ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 12222ef1f0ffSBarry Smith the use of this routine 1223bd481603SBarry Smith 12242ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 1225bd481603SBarry Smith 1226*af27ebaaSBarry Smith This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin(). 12271620fd73SBarry Smith 12281cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1229db781477SPatrick Sanan `MatPreallocateBegin()`, `MatPreallocateSetLocal()` 1230bd481603SBarry Smith M*/ 12319371c9d4SSatish Balay #define MatPreallocateSet(row, nc, cols, dnz, onz) \ 12329371c9d4SSatish 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) { \ 123364075487SBarry Smith if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \ 1234a6042fd4SStefano Zampini else if (dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \ 12359371c9d4SSatish Balay }) 12367c922b88SBarry Smith 1237bd481603SBarry Smith /*MC 1238d6e23781SBarry Smith MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1239bd481603SBarry Smith inserted using a local number of the rows and columns 1240bd481603SBarry Smith 1241bd481603SBarry Smith Synopsis: 1242aaa7dc30SBarry Smith #include <petscmat.h> 1243d6e23781SBarry Smith PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1244bd481603SBarry Smith 1245bd481603SBarry Smith Not Collective 1246bd481603SBarry Smith 1247bd481603SBarry Smith Input Parameters: 1248bd481603SBarry Smith + nrows - the number of rows indicated 12491d73ed98SBarry Smith . rows - the indices of the rows 1250bd481603SBarry Smith . ncols - the number of columns in the matrix 1251bd481603SBarry Smith . cols - the columns indicated 1252bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1253a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1254bd481603SBarry Smith 12552ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1256bd481603SBarry Smith 1257bd481603SBarry Smith Notes: 12582ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 12592ef1f0ffSBarry Smith the use of this routine 1260bd481603SBarry Smith 12612ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 1262bd481603SBarry Smith 1263*af27ebaaSBarry Smith This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin(). 12641620fd73SBarry Smith 12651cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateBegin()`, 1266db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()` 1267bd481603SBarry Smith M*/ 126894bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetBlock(row, nc, cols, dnz, onz) \ 12699371c9d4SSatish Balay PetscMacroReturnStandard(for (PetscInt __i = 0; __i < nc; __i++) { \ 1270d3d32019SBarry Smith if (cols[__i] >= __end) onz[row - __rstart]++; \ 1271a6042fd4SStefano Zampini else if (cols[__i] >= row && dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \ 12729371c9d4SSatish Balay }) 1273d3d32019SBarry Smith 1274bd481603SBarry Smith /*MC 1275a6042fd4SStefano Zampini MatPreallocateLocation - An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists 127616371a99SBarry Smith 127716371a99SBarry Smith Synopsis: 1278aaa7dc30SBarry Smith #include <petscmat.h> 127916371a99SBarry Smith PetscErrorCode MatPreallocateLocations(Mat A,PetscInt row,PetscInt ncols,PetscInt *cols,PetscInt *dnz,PetscInt *onz) 128016371a99SBarry Smith 128116371a99SBarry Smith Not Collective 128216371a99SBarry Smith 128316371a99SBarry Smith Input Parameters: 1284a2b725a8SWilliam Gropp + A - matrix 128516371a99SBarry Smith . row - row where values exist (must be local to this process) 128616371a99SBarry Smith . ncols - number of columns 128716371a99SBarry Smith . cols - columns with nonzeros 128816371a99SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 1289a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 129016371a99SBarry Smith 12912ef1f0ffSBarry Smith Level: deprecated (since v3.19) 129216371a99SBarry Smith 129316371a99SBarry Smith Notes: 12942ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 12952ef1f0ffSBarry Smith the use of this routine 129616371a99SBarry Smith 12972ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz` that is handled internally by these routines 129816371a99SBarry Smith 1299*af27ebaaSBarry Smith Developer Note: 1300*af27ebaaSBarry Smith This is a MACRO, not a function, because it uses a bunch of variables private to the MatPreallocation.... routines. 130116371a99SBarry Smith 13021cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1303db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()` 130416371a99SBarry Smith M*/ 1305d0609cedSBarry 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)) 130616371a99SBarry Smith 130716371a99SBarry Smith /*MC 1308d0609cedSBarry Smith MatPreallocateEnd - Ends the block of code that will count the number of nonzeros per 1309bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 1310bd481603SBarry Smith 1311bd481603SBarry Smith Synopsis: 1312aaa7dc30SBarry Smith #include <petscmat.h> 1313d0609cedSBarry Smith PetscErrorCode MatPreallocateEnd(PetscInt *dnz, PetscInt *onz) 1314bd481603SBarry Smith 1315d083f849SBarry Smith Collective 1316bd481603SBarry Smith 1317bd481603SBarry Smith Input Parameters: 131816371a99SBarry Smith + dnz - the array that was be passed to the matrix preallocation routines 1319a6042fd4SStefano Zampini - onz - the other array passed to the matrix preallocation routines 1320bd481603SBarry Smith 13212ef1f0ffSBarry Smith Level: deprecated (since v3.19) 1322bd481603SBarry Smith 1323bd481603SBarry Smith Notes: 13242ef1f0ffSBarry Smith This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than 13252ef1f0ffSBarry Smith the use of this routine 1326d0609cedSBarry Smith 13272ef1f0ffSBarry Smith Do not malloc or free `dnz` and `onz`, that is handled internally by these routines 1328bd481603SBarry Smith 13292ef1f0ffSBarry Smith Developer Note: 1330*af27ebaaSBarry Smith This is a MACRO, not a function, because it closes the { started in MatPreallocateBegin(). 13311620fd73SBarry Smith 13321cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1333db781477SPatrick Sanan `MatPreallocateSymmetricSetLocalBlock()` 1334bd481603SBarry Smith M*/ 13359371c9d4SSatish Balay #define MatPreallocateEnd(dnz, onz) \ 13369371c9d4SSatish Balay PetscCall(PetscFree2(dnz, onz)); \ 13379371c9d4SSatish Balay } \ 13389371c9d4SSatish Balay while (0) 1339d0609cedSBarry Smith 1340edd03b47SJacob Faibussowitsch #define MatPreallocateFinalize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateEnd()", ) MatPreallocateEnd(__VA_ARGS__) 13417c922b88SBarry Smith 13427b80b807SBarry Smith /* Routines unique to particular data structures */ 1343014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat, void *); 1344698d4c6aSKris Buschelman 1345014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat, IS *, IS *); 1346014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat, PetscInt *, PetscInt *[], PetscInt *); 1347698d4c6aSKris Buschelman 1348014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat, PetscInt[]); 1349014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat, PetscInt[]); 1350014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1351014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1352014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1353014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *, PetscInt, PetscBool); 13547b80b807SBarry Smith 1355a96a251dSBarry Smith #define MAT_SKIP_ALLOCATION -4 1356a96a251dSBarry Smith 1357014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1358014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1359014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat, PetscInt, const PetscInt[]); 136019b08ed1SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetTotalPreallocation(Mat, PetscInt); 1361273d9f13SBarry Smith 1362014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1363014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1364014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1365014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]); 1366014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 1367014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]); 1368014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 1369014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat, PetscInt[], PetscInt[], PetscInt[]); 1370b44e7856SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat, Mat *); 1371252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeqRankZero(Mat, Mat *); 1372014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat, PetscScalar[]); 1373014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat, PetscScalar[]); 13749230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat, Mat *, Mat *, const PetscInt *[]); 13759230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat, Mat *, Mat *, const PetscInt *[]); 1376014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat, Mat *); 1377273d9f13SBarry Smith 137849a6ff4bSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat, PetscInt *); 1379ad16ce7aSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseSetLDA(Mat, PetscInt); 1380edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatDenseSetLDA()", ) static inline PetscErrorCode MatSeqDenseSetLDA(Mat A, PetscInt lda) 1381d71ae5a4SJacob Faibussowitsch { 13829371c9d4SSatish Balay return MatDenseSetLDA(A, lda); 13839371c9d4SSatish Balay } 1384014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat, Mat *); 13851b807ce4Svictorle 1386621e819fSSatish Balay PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1387621e819fSSatish Balay 1388014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStoreValues(Mat); 1389014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat); 13902e8a6d31SBarry Smith 1391014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat, IS *); 13927cfe41e4SPatrick Farrell PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat, IS *); 13937b80b807SBarry Smith /* 13947b80b807SBarry Smith These routines are not usually accessed directly, rather solving is 139594b7f48cSBarry Smith done through the KSP and PC interfaces. 13967b80b807SBarry Smith */ 13977b80b807SBarry Smith 139876bdecfbSBarry Smith /*J 13992ef1f0ffSBarry Smith MatOrderingType - String with the name of a PETSc matrix ordering. These orderings are most commonly used 14002ef1f0ffSBarry Smith to reduce fill in sparse factorizations. 1401d9274352SBarry Smith 1402d9274352SBarry Smith Level: beginner 1403d9274352SBarry Smith 14042c7c0729SBarry Smith Notes: 140516a05f60SBarry Smith If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and instead the external factorization solver package called utilizes one 140616a05f60SBarry Smith of its own. 14072c7c0729SBarry Smith 14082ef1f0ffSBarry Smith There is no `MatOrdering` object, the ordering is obtained directly from the matrix with `MatGetOrdering()` 14092ef1f0ffSBarry Smith 14102ef1f0ffSBarry Smith Developer Note: 14112ef1f0ffSBarry Smith This API should be converted to an API similar to those for `MatColoring` and `MatPartitioning` 14122ef1f0ffSBarry Smith 14131cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `MatGetFactor()`, `MatGetOrdering()`, `MatColoringType`, `MatPartitioningType`, `MatCoarsenType`, `MatCoarsenType`, 14142ef1f0ffSBarry Smith `PCFactorSetOrderingType()` 141576bdecfbSBarry Smith J*/ 141619fd82e9SBarry Smith typedef const char *MatOrderingType; 14172692d6eeSBarry Smith #define MATORDERINGNATURAL "natural" 14182692d6eeSBarry Smith #define MATORDERINGND "nd" 14192692d6eeSBarry Smith #define MATORDERING1WD "1wd" 14202692d6eeSBarry Smith #define MATORDERINGRCM "rcm" 14212692d6eeSBarry Smith #define MATORDERINGQMD "qmd" 14222692d6eeSBarry Smith #define MATORDERINGROWLENGTH "rowlength" 1423510184a7SJed Brown #define MATORDERINGWBM "wbm" 1424fc1bef75SJed Brown #define MATORDERINGSPECTRAL "spectral" 1425312e372aSBarry Smith #define MATORDERINGAMD "amd" /* only works if UMFPACK is installed with PETSc */ 1426048412efSPablo Brubeck #define MATORDERINGMETISND "metisnd" /* only works if METIS is installed with PETSc */ 14279bd791bbSBarry 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 */ 14282c7c0729SBarry Smith #define MATORDERINGEXTERNAL "external" /* uses an ordering type internal to the factorization package */ 1429b12f92e5SBarry Smith 143019fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOrdering(Mat, MatOrderingType, IS *, IS *); 1431140e18c1SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOrderingList(PetscFunctionList *); 1432bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatOrderingRegister(const char[], PetscErrorCode (*)(Mat, MatOrderingType, IS *, IS *)); 1433140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatOrderingList; 1434d4fbbf0eSBarry Smith 1435013e2dc7SBarry Smith #include "petscmatcoarsen.h" 1436013e2dc7SBarry Smith 1437014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat, PetscReal, IS, IS); 1438fc1bef75SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat, PetscReal, PetscBool, Mat *); 1439a2ce50c7SBarry Smith 14404ac6704cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetPreferredOrdering(Mat, MatFactorType, MatOrderingType *); 14414ac6704cSBarry Smith 1442d91e6319SBarry Smith /*S 14432ef1f0ffSBarry Smith MatFactorShiftType - Type of numeric shift used for factorizations 1444d90ac83dSHong Zhang 14452ef1f0ffSBarry Smith Values: 14462ef1f0ffSBarry Smith + `MAT_SHIFT_NONE` - do not shift the matrix diagonal entries 14472ef1f0ffSBarry Smith . `MAT_SHIFT_NONZERO` - shift the entries to be non-zero 14482ef1f0ffSBarry Smith . `MAT_SHIFT_POSITIVE_DEFINITE` - shift the entries to force the factorization to be positive definite 14492ef1f0ffSBarry Smith - `MAT_SHIFT_INBLOCKS` - only shift the factors inside the small dense diagonal blocks of the matrix, for example with `MATBAIJ` 1450d90ac83dSHong Zhang 14512ef1f0ffSBarry Smith Level: intermediate 14522ef1f0ffSBarry Smith 14531cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `PCFactorSetShiftType()` 1454d90ac83dSHong Zhang S*/ 14559371c9d4SSatish Balay typedef enum { 14569371c9d4SSatish Balay MAT_SHIFT_NONE, 14579371c9d4SSatish Balay MAT_SHIFT_NONZERO, 14589371c9d4SSatish Balay MAT_SHIFT_POSITIVE_DEFINITE, 14599371c9d4SSatish Balay MAT_SHIFT_INBLOCKS 14609371c9d4SSatish Balay } MatFactorShiftType; 14616a6fc655SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypes[]; 14625e9742b9SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypesDetail[]; 1463d90ac83dSHong Zhang 1464d90ac83dSHong Zhang /*S 1465ec5066bdSBarry Smith MatFactorError - indicates what type of error was generated in a matrix factorization 14669aa7eafdSHong Zhang 14672ef1f0ffSBarry Smith Values: 14682ef1f0ffSBarry Smith + `MAT_FACTOR_NOERROR` - there was no error during the factorization 14692ef1f0ffSBarry Smith . `MAT_FACTOR_STRUCT_ZEROPIVOT` - there was a missing entry in a diagonal location of the matrix 14702ef1f0ffSBarry Smith . `MAT_FACTOR_NUMERIC_ZEROPIVOT` - there was a (near) zero pivot during the factorization 14712ef1f0ffSBarry Smith . `MAT_FACTOR_OUTMEMORY` - the factorization has run out of memory 14722ef1f0ffSBarry Smith - `MAT_FACTOR_OTHER` - some other error has occurred. 14739aa7eafdSHong Zhang 14742ef1f0ffSBarry Smith Level: intermediate 147500e125f8SBarry Smith 14762ef1f0ffSBarry Smith Note: 14772ef1f0ffSBarry Smith When a factorization is done in a preconditioner `PC` the error may be propagated up to a `PCFailedReason` or a `KSPConvergedReason` 14782ef1f0ffSBarry Smith 14791cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `MatFactorGetError()`, `MatFactorGetErrorZeroPivot()`, `MatFactorClearError()`, 14802ef1f0ffSBarry Smith `PCFailedReason`, `PCGetFailedReason()`, `KSPConvergedReason` 14819aa7eafdSHong Zhang S*/ 14829371c9d4SSatish Balay typedef enum { 14839371c9d4SSatish Balay MAT_FACTOR_NOERROR, 14849371c9d4SSatish Balay MAT_FACTOR_STRUCT_ZEROPIVOT, 14859371c9d4SSatish Balay MAT_FACTOR_NUMERIC_ZEROPIVOT, 14869371c9d4SSatish Balay MAT_FACTOR_OUTMEMORY, 14879371c9d4SSatish Balay MAT_FACTOR_OTHER 14889371c9d4SSatish Balay } MatFactorError; 14899aa7eafdSHong Zhang 149000e125f8SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat, MatFactorError *); 1491b8b68cfdSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat); 14927b6c816cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat, PetscReal *, PetscInt *); 149300e125f8SBarry Smith 14949aa7eafdSHong Zhang /*S 1495422a814eSBarry Smith MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization 1496b00f7748SHong Zhang 1497b00f7748SHong Zhang Level: developer 1498b00f7748SHong Zhang 14992ef1f0ffSBarry Smith Note: 15002ef1f0ffSBarry Smith You can use `MatFactorInfoInitialize()` to set default values. 1501b00f7748SHong Zhang 15022ef1f0ffSBarry Smith Fortran Note: 15032ef1f0ffSBarry Smith The data is available in a double precision arrays of size `MAT_FACTORINFO_SIZE` 15042ef1f0ffSBarry Smith 15051cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatInfo`, `MatGetFactor()`, `MatLUFactorSymbolic()`, `MatILUFactorSymbolic()`, `MatCholeskyFactorSymbolic()`, 15062ef1f0ffSBarry Smith `MatICCFactorSymbolic()`, `MatICCFactor()`, `MatFactorInfoInitialize()` 1507b00f7748SHong Zhang S*/ 1508b00f7748SHong Zhang typedef struct { 150915e8a5b3SHong Zhang PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 151085317021SBarry Smith PetscReal usedt; 151115e8a5b3SHong Zhang PetscReal dt; /* drop tolerance */ 1512b00f7748SHong Zhang PetscReal dtcol; /* tolerance for pivoting */ 151315e8a5b3SHong Zhang PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 151467e28bfeSBarry Smith PetscReal fill; /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */ 1515348344bbSBarry Smith PetscReal levels; /* ICC/ILU(levels) */ 1516bcd9e38bSBarry Smith PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 1517bcd9e38bSBarry Smith factorization may be faster if do not pivot */ 151815e8a5b3SHong Zhang PetscReal zeropivot; /* pivot is called zero if less than this */ 1519f4db908eSBarry Smith PetscReal shifttype; /* type of shift added to matrix factor to prevent zero pivots */ 1520f4db908eSBarry Smith PetscReal shiftamount; /* how large the shift is */ 152115e8a5b3SHong Zhang } MatFactorInfo; 1522ffa6d0a5SLois Curfman McInnes 1523014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo *); 15249a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat, IS, const MatFactorInfo *); 15259a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 15269a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat, Mat, const MatFactorInfo *); 15279a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactor(Mat, IS, IS, const MatFactorInfo *); 15289a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactor(Mat, IS, IS, const MatFactorInfo *); 15299a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *); 15309a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *); 15319a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 15329a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactor(Mat, IS, const MatFactorInfo *); 15339a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat, Mat, const MatFactorInfo *); 15343f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactor(Mat, IS, const MatFactorInfo *); 15353f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 15363f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorNumeric(Mat, Mat, const MatFactorInfo *); 1537014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInertia(Mat, PetscInt *, PetscInt *, PetscInt *); 1538014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolve(Mat, Vec, Vec); 1539014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat, Vec, Vec); 1540014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat, Vec, Vec); 1541014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat, Vec, Vec, Vec); 1542014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat, Vec, Vec); 1543014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat, Vec, Vec, Vec); 1544014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolves(Mat, Vecs, Vecs); 15457c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat); 15467c2f51b8SStefano Zampini 15479371c9d4SSatish Balay typedef enum { 15489371c9d4SSatish Balay MAT_FACTOR_SCHUR_UNFACTORED, 15499371c9d4SSatish Balay MAT_FACTOR_SCHUR_FACTORED, 15509371c9d4SSatish Balay MAT_FACTOR_SCHUR_INVERTED 15519371c9d4SSatish Balay } MatFactorSchurStatus; 15528e7ba810SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat, IS); 15537c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat, Mat *, MatFactorSchurStatus *); 15547c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat, Mat *, MatFactorSchurStatus); 15555a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat); 15567c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat, Mat *, MatFactorSchurStatus *); 15575a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat, Vec, Vec); 15585a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat, Vec, Vec); 15596dba178dSStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat); 1560bb5a7306SBarry Smith 15618a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqDenseInvert(Mat); 1562d91e6319SBarry Smith /*E 1563d91e6319SBarry Smith MatSORType - What type of (S)SOR to perform 1564bb1eb677SSatish Balay 15652ef1f0ffSBarry Smith Values: 15662ef1f0ffSBarry Smith + `SOR_FORWARD_SWEEP` - do a sweep from the first row of the matrix to the last 15672ef1f0ffSBarry Smith . `SOR_BACKWARD_SWEEP` - do a sweep from the last row to the first 15682ef1f0ffSBarry Smith . `SOR_SYMMETRIC_SWEEP` - do a sweep from the first row to the last and then back to the first 1569*af27ebaaSBarry Smith . `SOR_LOCAL_FORWARD_SWEEP` - each MPI process does its own forward sweep with no communication 1570*af27ebaaSBarry Smith . `SOR_LOCAL_BACKWARD_SWEEP` - each MPI process does its own backward sweep with no communication 1571*af27ebaaSBarry Smith . `SOR_LOCAL_SYMMETRIC_SWEEP` - each MPI process does its own symmetric sweep with no communication 15722ef1f0ffSBarry Smith . `SOR_ZERO_INITIAL_GUESS` - indicates the initial solution is zero so the sweep can avoid unneeded computation 15732ef1f0ffSBarry Smith . `SOR_EISENSTAT` - apply the Eisentat application of SOR, see `PCEISENSTAT` 15742ef1f0ffSBarry Smith . `SOR_APPLY_UPPER` - multiply by the upper triangular portion of the matrix 15752ef1f0ffSBarry Smith - `SOR_APPLY_LOWER` - multiply by the lower triangular portion of the matrix 15762ef1f0ffSBarry Smith 1577d91e6319SBarry Smith Level: beginner 1578d91e6319SBarry Smith 15792ef1f0ffSBarry Smith Note: 15802ef1f0ffSBarry Smith These may be bitwise ORd together 1581d9274352SBarry Smith 15822ef1f0ffSBarry Smith Developer Note: 15832ef1f0ffSBarry Smith Since `MatSORType` may be bitwise ORd together, so do not change the numerical values below 1584d91e6319SBarry Smith 15851cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSOR()` 1586d91e6319SBarry Smith E*/ 15879371c9d4SSatish Balay typedef enum { 15889371c9d4SSatish Balay SOR_FORWARD_SWEEP = 1, 15899371c9d4SSatish Balay SOR_BACKWARD_SWEEP = 2, 15909371c9d4SSatish Balay SOR_SYMMETRIC_SWEEP = 3, 15919371c9d4SSatish Balay SOR_LOCAL_FORWARD_SWEEP = 4, 15929371c9d4SSatish Balay SOR_LOCAL_BACKWARD_SWEEP = 8, 15939371c9d4SSatish Balay SOR_LOCAL_SYMMETRIC_SWEEP = 12, 15949371c9d4SSatish Balay SOR_ZERO_INITIAL_GUESS = 16, 15959371c9d4SSatish Balay SOR_EISENSTAT = 32, 15969371c9d4SSatish Balay SOR_APPLY_UPPER = 64, 15979371c9d4SSatish Balay SOR_APPLY_LOWER = 128 15989371c9d4SSatish Balay } MatSORType; 1599014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSOR(Mat, Vec, PetscReal, MatSORType, PetscReal, PetscInt, PetscInt, Vec); 16008ed539a5SBarry Smith 16017086a01eSPeter Brune /*S 16027086a01eSPeter Brune MatColoring - Object for managing the coloring of matrices. 16037086a01eSPeter Brune 16047086a01eSPeter Brune Level: beginner 16057086a01eSPeter Brune 1606ec5066bdSBarry Smith Notes: 160787497f52SBarry 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 160887497f52SBarry Smith matrix comes from via `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors). 1609ec5066bdSBarry Smith 161087497f52SBarry Smith Once a coloring is available `MatFDColoringCreate()` creates an object that can be used to efficiently compute Jacobians using that coloring. This 16112ef1f0ffSBarry Smith same object can also be used to efficiently convert data created by Automatic Differentiation tools to PETSc sparse matrices. 1612ec5066bdSBarry Smith 16131cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `MatFDColoringCreate()`, `MatColoringWeightType`, `ISColoring`, `MatFDColoring`, `DMCreateColoring()`, `MatColoringCreate()`, 16142ef1f0ffSBarry Smith `MatPartitioning`, `MatColoringType`, `MatPartitioningType`, `MatOrderingType`, `MatColoringSetWeightType()`, 16152ef1f0ffSBarry Smith `MatColoringSetWeights()`, `MatCoarsenType`, `MatCoarsen` 16167086a01eSPeter Brune S*/ 1617d4db15c4SBarry Smith typedef struct _p_MatColoring *MatColoring; 1618d4db15c4SBarry Smith 1619d4db15c4SBarry Smith /*J 1620d4db15c4SBarry Smith MatColoringType - String with the name of a PETSc matrix coloring 1621d9274352SBarry Smith 1622d9274352SBarry Smith Level: beginner 1623d9274352SBarry Smith 16241cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatFDColoringCreate()`, `MatColoringSetType()`, `MatColoring` 162576bdecfbSBarry Smith J*/ 162619fd82e9SBarry Smith typedef const char *MatColoringType; 16275567d71aSPeter Brune #define MATCOLORINGJP "jp" 1628b9acb617SPeter Brune #define MATCOLORINGPOWER "power" 16292692d6eeSBarry Smith #define MATCOLORINGNATURAL "natural" 16302692d6eeSBarry Smith #define MATCOLORINGSL "sl" 16312692d6eeSBarry Smith #define MATCOLORINGLF "lf" 16322692d6eeSBarry Smith #define MATCOLORINGID "id" 16338121bdceSPeter Brune #define MATCOLORINGGREEDY "greedy" 1634b12f92e5SBarry Smith 16358ac6da0aSPeter Brune /*E 16362ef1f0ffSBarry Smith MatColoringWeightType - Type of weight scheme used for the coloring algorithm 16378ac6da0aSPeter Brune 16382ef1f0ffSBarry Smith Values: 163987497f52SBarry Smith + `MAT_COLORING_RANDOM` - Random weights 164087497f52SBarry Smith . `MAT_COLORING_LEXICAL` - Lexical weighting based upon global numbering. 164187497f52SBarry Smith - `MAT_COLORING_LF` - Last-first weighting. 16428ac6da0aSPeter Brune 16438ac6da0aSPeter Brune Level: intermediate 16448ac6da0aSPeter Brune 16451cc06b55SBarry Smith .seealso: [](ch_matrices), `MatColoring`, `MatColoringCreate()`, `MatColoringSetWeightType()`, `MatColoringSetWeights()` 16468ac6da0aSPeter Brune E*/ 16479371c9d4SSatish Balay typedef enum { 16489371c9d4SSatish Balay MAT_COLORING_WEIGHT_RANDOM, 16499371c9d4SSatish Balay MAT_COLORING_WEIGHT_LEXICAL, 16509371c9d4SSatish Balay MAT_COLORING_WEIGHT_LF, 16519371c9d4SSatish Balay MAT_COLORING_WEIGHT_SL 16529371c9d4SSatish Balay } MatColoringWeightType; 16538ac6da0aSPeter Brune 1654335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat, MatColoring *); 1655d7f2a307SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat, PetscInt, PetscInt *); 1656335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring *); 1657335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring, PetscViewer); 1658335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring, MatColoringType); 1659335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring); 1660335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring, PetscInt); 1661335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring, PetscInt *); 1662335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring, PetscInt); 1663335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring, PetscInt *); 1664335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring, ISColoring *); 1665335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[], PetscErrorCode (*)(MatColoring)); 1666014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat, PetscInt, PetscInt, ISColoringValue[], ISColoring *); 16678ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring, MatColoringWeightType); 1668c29971fcSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring, PetscReal *, PetscInt *); 16698ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring, PetscReal **, PetscInt **lperm); 1670bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring, ISColoring); 1671edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 10, 0, "MatColoringTest()", ) static inline PetscErrorCode MatColoringTestValid(MatColoring matcoloring, ISColoring iscoloring) 1672d71ae5a4SJacob Faibussowitsch { 16739371c9d4SSatish Balay return MatColoringTest(matcoloring, iscoloring); 16749371c9d4SSatish Balay } 1675bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat, ISColoring); 1676639f9d9dSBarry Smith 1677d9274352SBarry Smith /*S 167887497f52SBarry Smith MatFDColoring - Object for computing a sparse Jacobian via finite differences with coloring 1679639f9d9dSBarry Smith 1680d9274352SBarry Smith Level: beginner 1681d9274352SBarry Smith 1682ec5066bdSBarry Smith Notes: 168387497f52SBarry Smith This object is creating utilizing a coloring provided by the `MatColoring` object or `DMCreateColoring()` 1684ec5066bdSBarry Smith 16852ef1f0ffSBarry Smith The `SNES` option `-snes_fd_coloring` will cause the Jacobian needed by `SNES` to be computed via a use of this object 16862ef1f0ffSBarry Smith 16871cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatFDColoringCreate()`, `MatFDColoringSetFunction()`, `MatColoring`, `DMCreateColoring()` 1688d9274352SBarry Smith S*/ 1689e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring; 1690639f9d9dSBarry Smith 1691014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat, ISColoring, MatFDColoring *); 1692014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring *); 1693014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring, PetscViewer); 1694014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring, PetscErrorCode (*)(void), void *); 1695014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring, PetscErrorCode (**)(void), void **); 1696014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring, PetscReal, PetscReal); 1697014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring); 1698d1e9a80fSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat, MatFDColoring, Vec, void *); 1699014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring, Vec); 1700edaa7c33SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring, PetscInt *, const PetscInt *[]); 1701f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat, ISColoring, MatFDColoring); 1702f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring, PetscInt, PetscInt); 1703bdaf1daeSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat, MatFDColoring, const PetscScalar *); 1704b1683b59SHong Zhang 1705b1683b59SHong Zhang /*S 1706*af27ebaaSBarry Smith MatTransposeColoring - Object for computing a sparse matrix product $C = A*B^T$ via coloring 1707b1683b59SHong Zhang 17082ef1f0ffSBarry Smith Level: developer 1709b1683b59SHong Zhang 17101cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatProductType`, `MatTransposeColoringCreate()` 1711b1683b59SHong Zhang S*/ 1712b9af6bddSHong Zhang typedef struct _p_MatTransposeColoring *MatTransposeColoring; 1713b1683b59SHong Zhang 1714014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat, ISColoring, MatTransposeColoring *); 1715014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring, Mat, Mat); 1716014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring, Mat, Mat); 1717014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring *); 1718b1683b59SHong Zhang 1719d9274352SBarry Smith /*S 1720d9274352SBarry Smith MatPartitioning - Object for managing the partitioning of a matrix or graph 1721d9274352SBarry Smith 1722d9274352SBarry Smith Level: beginner 1723d9274352SBarry Smith 172487497f52SBarry Smith Note: 172587497f52SBarry Smith There is also a `PetscPartitioner` object that provides the same functionality. It can utilize the `MatPartitioning` operations 172687497f52SBarry Smith via `PetscPartitionerSetType`(p,`PETSCPARTITIONERMATPARTITIONING`) 1727ec5066bdSBarry Smith 1728ec5066bdSBarry Smith Developers Note: 17292ef1f0ffSBarry Smith It is an extra maintenance and documentation cost to have two objects with the same functionality. `PetscPartitioner` should be removed 1730ec5066bdSBarry Smith 17311cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioningType`, `MatColoring`, `MatGetOrdering()`, `MatOrderingType`, 17322ef1f0ffSBarry Smith `MatCoarsenType`, `MatCoarsenType` 1733d9274352SBarry Smith S*/ 173491e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning; 1735d9274352SBarry Smith 173676bdecfbSBarry Smith /*J 17378f6c3df8SBarry Smith MatPartitioningType - String with the name of a PETSc matrix partitioning 1738d9274352SBarry Smith 1739d9274352SBarry Smith Level: beginner 17400d04baf8SBarry Smith dm 17411cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioning`, `MatPartitioningSetType()`, `MatColoringType`, `MatOrderingType`, 17422ef1f0ffSBarry Smith `MatCoarsenType`, `MatCoarsenType` 174376bdecfbSBarry Smith J*/ 174419fd82e9SBarry Smith typedef const char *MatPartitioningType; 17452692d6eeSBarry Smith #define MATPARTITIONINGCURRENT "current" 1746aa1e27eaSFande Kong #define MATPARTITIONINGAVERAGE "average" 17472692d6eeSBarry Smith #define MATPARTITIONINGSQUARE "square" 17482692d6eeSBarry Smith #define MATPARTITIONINGPARMETIS "parmetis" 17492692d6eeSBarry Smith #define MATPARTITIONINGCHACO "chaco" 17502692d6eeSBarry Smith #define MATPARTITIONINGPARTY "party" 175150d91057SBarry Smith #define MATPARTITIONINGPTSCOTCH "ptscotch" 175288d2ac2bSFande Kong #define MATPARTITIONINGHIERARCH "hierarch" 175371306c60Sjroman 1754014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm, MatPartitioning *); 175519fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning, MatPartitioningType); 1756014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning, PetscInt); 1757014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning, Mat); 1758252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetNumberVertexWeights(MatPartitioning, PetscInt); 1759014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning, const PetscInt[]); 1760014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning, const PetscReal[]); 1761ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningSetUseEdgeWeights(MatPartitioning, PetscBool); 1762ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningGetUseEdgeWeights(MatPartitioning, PetscBool *); 1763014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning, IS *); 1764fdd1c351SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning, IS *); 1765668144dbSFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning, IS); 1766f3ad2dabSStefano Zampini PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning, IS *); 1767014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning *); 1768bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[], PetscErrorCode (*)(MatPartitioning)); 1769014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning, PetscViewer); 1770fe2efc57SMark PETSC_EXTERN PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning, PetscObject, const char[]); 1771014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning); 177219fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning, MatPartitioningType *); 1773ca161407SBarry Smith 177427538973SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning part); 1775014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 1776014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *); 17770752156aSBarry Smith 17789371c9d4SSatish Balay typedef enum { 17799371c9d4SSatish Balay MP_CHACO_MULTILEVEL = 1, 17809371c9d4SSatish Balay MP_CHACO_SPECTRAL = 2, 17819371c9d4SSatish Balay MP_CHACO_LINEAR = 4, 17829371c9d4SSatish Balay MP_CHACO_RANDOM = 5, 17839371c9d4SSatish Balay MP_CHACO_SCATTERED = 6 17849371c9d4SSatish Balay } MPChacoGlobalType; 17856a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoGlobalTypes[]; 17869371c9d4SSatish Balay typedef enum { 17879371c9d4SSatish Balay MP_CHACO_KERNIGHAN = 1, 17889371c9d4SSatish Balay MP_CHACO_NONE = 2 17899371c9d4SSatish Balay } MPChacoLocalType; 17906a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoLocalTypes[]; 17919371c9d4SSatish Balay typedef enum { 17929371c9d4SSatish Balay MP_CHACO_LANCZOS = 0, 17939371c9d4SSatish Balay MP_CHACO_RQI = 1 17949371c9d4SSatish Balay } MPChacoEigenType; 17956a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoEigenTypes[]; 1796b6956c12SJose Roman 1797014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType); 1798014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning, MPChacoGlobalType *); 1799014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType); 1800014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning, MPChacoLocalType *); 1801014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning, PetscReal); 1802014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning, MPChacoEigenType); 1803014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning, MPChacoEigenType *); 1804014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal); 1805014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning, PetscReal *); 1806014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt); 1807014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning, PetscInt *); 180871306c60Sjroman 180971306c60Sjroman #define MP_PARTY_OPT "opt" 181071306c60Sjroman #define MP_PARTY_LIN "lin" 181171306c60Sjroman #define MP_PARTY_SCA "sca" 181271306c60Sjroman #define MP_PARTY_RAN "ran" 181371306c60Sjroman #define MP_PARTY_GBF "gbf" 181471306c60Sjroman #define MP_PARTY_GCF "gcf" 181571306c60Sjroman #define MP_PARTY_BUB "bub" 181671306c60Sjroman #define MP_PARTY_DEF "def" 1817014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char *); 181871306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs" 181971306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl" 182071306c60Sjroman #define MP_PARTY_NONE "no" 1821014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char *); 1822014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning, PetscReal); 1823014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning, PetscBool); 1824014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning, PetscBool); 182571306c60Sjroman 18269371c9d4SSatish Balay typedef enum { 18279371c9d4SSatish Balay MP_PTSCOTCH_DEFAULT, 18289371c9d4SSatish Balay MP_PTSCOTCH_QUALITY, 18299371c9d4SSatish Balay MP_PTSCOTCH_SPEED, 18309371c9d4SSatish Balay MP_PTSCOTCH_BALANCE, 18319371c9d4SSatish Balay MP_PTSCOTCH_SAFETY, 18329371c9d4SSatish Balay MP_PTSCOTCH_SCALABILITY 18339371c9d4SSatish Balay } MPPTScotchStrategyType; 18346a6fc655SJed Brown PETSC_EXTERN const char *const MPPTScotchStrategyTypes[]; 1835e0f1cffaSJose Roman 1836014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning, PetscReal); 1837014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning, PetscReal *); 1838014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning, MPPTScotchStrategyType); 1839014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning, MPPTScotchStrategyType *); 184071306c60Sjroman 1841b43b03e9SMark F. Adams /* 18426294fa2bSFande Kong * hierarchical partitioning 18436294fa2bSFande Kong */ 18444e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning, IS *); 18454e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning, IS *); 18464e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning, PetscInt); 18474e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt); 18486294fa2bSFande Kong 1849014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat, PetscInt, Mat *); 1850591294e4SBarry Smith 18510752156aSBarry Smith /* 1852c786d857SStefano Zampini If you add entries here you must also add them to src/mat/f90-mod/petscmat.h 1853c786d857SStefano Zampini If any of the enum values are changed, also update dMatOps dict at src/binding/petsc4py/src/libpetsc4py/libpetsc4py.pyx 1854d4fbbf0eSBarry Smith */ 18559371c9d4SSatish Balay typedef enum { 18569371c9d4SSatish Balay MATOP_SET_VALUES = 0, 18571c1c02c0SLois Curfman McInnes MATOP_GET_ROW = 1, 18581c1c02c0SLois Curfman McInnes MATOP_RESTORE_ROW = 2, 18591c1c02c0SLois Curfman McInnes MATOP_MULT = 3, 18601c1c02c0SLois Curfman McInnes MATOP_MULT_ADD = 4, 18617c922b88SBarry Smith MATOP_MULT_TRANSPOSE = 5, 18627c922b88SBarry Smith MATOP_MULT_TRANSPOSE_ADD = 6, 18631c1c02c0SLois Curfman McInnes MATOP_SOLVE = 7, 18641c1c02c0SLois Curfman McInnes MATOP_SOLVE_ADD = 8, 18657c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE = 9, 18667c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE_ADD = 10, 18671c1c02c0SLois Curfman McInnes MATOP_LUFACTOR = 11, 18681c1c02c0SLois Curfman McInnes MATOP_CHOLESKYFACTOR = 12, 1869a714c06dSBarry Smith MATOP_SOR = 13, 18701c1c02c0SLois Curfman McInnes MATOP_TRANSPOSE = 14, 18711c1c02c0SLois Curfman McInnes MATOP_GETINFO = 15, 18721c1c02c0SLois Curfman McInnes MATOP_EQUAL = 16, 18731c1c02c0SLois Curfman McInnes MATOP_GET_DIAGONAL = 17, 18741c1c02c0SLois Curfman McInnes MATOP_DIAGONAL_SCALE = 18, 18751c1c02c0SLois Curfman McInnes MATOP_NORM = 19, 18761c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_BEGIN = 20, 18771c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_END = 21, 1878d519adbfSMatthew Knepley MATOP_SET_OPTION = 22, 1879d519adbfSMatthew Knepley MATOP_ZERO_ENTRIES = 23, 1880d519adbfSMatthew Knepley MATOP_ZERO_ROWS = 24, 1881d519adbfSMatthew Knepley MATOP_LUFACTOR_SYMBOLIC = 25, 1882d519adbfSMatthew Knepley MATOP_LUFACTOR_NUMERIC = 26, 1883d519adbfSMatthew Knepley MATOP_CHOLESKY_FACTOR_SYMBOLIC = 27, 1884d519adbfSMatthew Knepley MATOP_CHOLESKY_FACTOR_NUMERIC = 28, 1885e5f2d425SStefano Zampini MATOP_SETUP = 29, 1886d519adbfSMatthew Knepley MATOP_ILUFACTOR_SYMBOLIC = 30, 1887d519adbfSMatthew Knepley MATOP_ICCFACTOR_SYMBOLIC = 31, 1888a5b7ff6bSBarry Smith MATOP_GET_DIAGONAL_BLOCK = 32, 1889e5f2d425SStefano Zampini MATOP_SET_INF = 33, 1890d519adbfSMatthew Knepley MATOP_DUPLICATE = 34, 1891d519adbfSMatthew Knepley MATOP_FORWARD_SOLVE = 35, 1892d519adbfSMatthew Knepley MATOP_BACKWARD_SOLVE = 36, 1893d519adbfSMatthew Knepley MATOP_ILUFACTOR = 37, 1894d519adbfSMatthew Knepley MATOP_ICCFACTOR = 38, 1895d519adbfSMatthew Knepley MATOP_AXPY = 39, 18967dae84e0SHong Zhang MATOP_CREATE_SUBMATRICES = 40, 1897d519adbfSMatthew Knepley MATOP_INCREASE_OVERLAP = 41, 1898d519adbfSMatthew Knepley MATOP_GET_VALUES = 42, 1899d519adbfSMatthew Knepley MATOP_COPY = 43, 1900d519adbfSMatthew Knepley MATOP_GET_ROW_MAX = 44, 1901d519adbfSMatthew Knepley MATOP_SCALE = 45, 1902d519adbfSMatthew Knepley MATOP_SHIFT = 46, 190335153367SBarry Smith MATOP_DIAGONAL_SET = 47, 19049d39f69dSJed Brown MATOP_ZERO_ROWS_COLUMNS = 48, 19059d39f69dSJed Brown MATOP_SET_RANDOM = 49, 1906d519adbfSMatthew Knepley MATOP_GET_ROW_IJ = 50, 1907d519adbfSMatthew Knepley MATOP_RESTORE_ROW_IJ = 51, 1908d519adbfSMatthew Knepley MATOP_GET_COLUMN_IJ = 52, 1909d519adbfSMatthew Knepley MATOP_RESTORE_COLUMN_IJ = 53, 1910d519adbfSMatthew Knepley MATOP_FDCOLORING_CREATE = 54, 1911d519adbfSMatthew Knepley MATOP_COLORING_PATCH = 55, 1912d519adbfSMatthew Knepley MATOP_SET_UNFACTORED = 56, 1913d519adbfSMatthew Knepley MATOP_PERMUTE = 57, 1914d519adbfSMatthew Knepley MATOP_SET_VALUES_BLOCKED = 58, 19157dae84e0SHong Zhang MATOP_CREATE_SUBMATRIX = 59, 1916d519adbfSMatthew Knepley MATOP_DESTROY = 60, 1917d519adbfSMatthew Knepley MATOP_VIEW = 61, 1918d519adbfSMatthew Knepley MATOP_CONVERT_FROM = 62, 1919e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_63=63 */ 19207bab7c10SHong Zhang MATOP_MATMAT_MULT_SYMBOLIC = 64, 19217bab7c10SHong Zhang MATOP_MATMAT_MULT_NUMERIC = 65, 1922d519adbfSMatthew Knepley MATOP_SET_LOCAL_TO_GLOBAL_MAP = 66, 1923d519adbfSMatthew Knepley MATOP_SET_VALUES_LOCAL = 67, 1924d519adbfSMatthew Knepley MATOP_ZERO_ROWS_LOCAL = 68, 1925d519adbfSMatthew Knepley MATOP_GET_ROW_MAX_ABS = 69, 1926d519adbfSMatthew Knepley MATOP_GET_ROW_MIN_ABS = 70, 1927d519adbfSMatthew Knepley MATOP_CONVERT = 71, 1928e5f2d425SStefano Zampini MATOP_HAS_OPERATION = 72, 19299d39f69dSJed Brown /* MATOP_PLACEHOLDER_73=73, */ 1930d519adbfSMatthew Knepley MATOP_SET_VALUES_ADIFOR = 74, 1931d519adbfSMatthew Knepley MATOP_FD_COLORING_APPLY = 75, 1932d519adbfSMatthew Knepley MATOP_SET_FROM_OPTIONS = 76, 1933e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_77=77, */ 1934e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_78=78, */ 19359d39f69dSJed Brown MATOP_FIND_ZERO_DIAGONALS = 79, 1936d519adbfSMatthew Knepley MATOP_MULT_MULTIPLE = 80, 1937d519adbfSMatthew Knepley MATOP_SOLVE_MULTIPLE = 81, 1938d519adbfSMatthew Knepley MATOP_GET_INERTIA = 82, 1939d519adbfSMatthew Knepley MATOP_LOAD = 83, 1940d519adbfSMatthew Knepley MATOP_IS_SYMMETRIC = 84, 1941d519adbfSMatthew Knepley MATOP_IS_HERMITIAN = 85, 1942d519adbfSMatthew Knepley MATOP_IS_STRUCTURALLY_SYMMETRIC = 86, 1943820469bcSHong Zhang MATOP_SET_VALUES_BLOCKEDLOCAL = 87, 1944b41ce5d5SBarry Smith MATOP_CREATE_VECS = 88, 1945e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_89=89, */ 1946d519adbfSMatthew Knepley MATOP_MAT_MULT_SYMBOLIC = 90, 1947d519adbfSMatthew Knepley MATOP_MAT_MULT_NUMERIC = 91, 1948e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_92=92, */ 1949d519adbfSMatthew Knepley MATOP_PTAP_SYMBOLIC = 93, 1950d519adbfSMatthew Knepley MATOP_PTAP_NUMERIC = 94, 1951e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_95=95, */ 1952bda6c4cbSBarry Smith MATOP_MAT_TRANSPOSE_MULT_SYMBO = 96, 1953bda6c4cbSBarry Smith MATOP_MAT_TRANSPOSE_MULT_NUMER = 97, 1954e5f2d425SStefano Zampini MATOP_BIND_TO_CPU = 98, 19557a3c3d58SStefano Zampini MATOP_PRODUCTSETFROMOPTIONS = 99, 19567a3c3d58SStefano Zampini MATOP_PRODUCTSYMBOLIC = 100, 19577a3c3d58SStefano Zampini MATOP_PRODUCTNUMERIC = 101, 1958d519adbfSMatthew Knepley MATOP_CONJUGATE = 102, 1959e5f2d425SStefano Zampini MATOP_VIEW_NATIVE = 103, 1960d519adbfSMatthew Knepley MATOP_SET_VALUES_ROW = 104, 1961d519adbfSMatthew Knepley MATOP_REAL_PART = 105, 1962bda6c4cbSBarry Smith MATOP_IMAGINARY_PART = 106, 1963bda6c4cbSBarry Smith MATOP_GET_ROW_UPPER_TRIANGULAR = 107, 1964bda6c4cbSBarry Smith MATOP_RESTORE_ROW_UPPER_TRIANG = 108, 1965bda6c4cbSBarry Smith MATOP_MAT_SOLVE = 109, 196629eadf9eSStefano Zampini MATOP_MAT_SOLVE_TRANSPOSE = 110, 1967d519adbfSMatthew Knepley MATOP_GET_ROW_MIN = 111, 19680e8d04f7SBarry Smith MATOP_GET_COLUMN_VECTOR = 112, 1969d519adbfSMatthew Knepley MATOP_MISSING_DIAGONAL = 113, 19700e8d04f7SBarry Smith MATOP_GET_SEQ_NONZERO_STRUCTUR = 114, 197189c6957cSBarry Smith MATOP_CREATE = 115, 197289c6957cSBarry Smith MATOP_GET_GHOSTS = 116, 19730e8d04f7SBarry Smith MATOP_GET_LOCAL_SUB_MATRIX = 117, 19740e8d04f7SBarry Smith MATOP_RESTORE_LOCALSUB_MATRIX = 118, 1975eeffb40dSHong Zhang MATOP_MULT_DIAGONAL_BLOCK = 119, 19760e8d04f7SBarry Smith MATOP_HERMITIAN_TRANSPOSE = 120, 19770e8d04f7SBarry Smith MATOP_MULT_HERMITIAN_TRANSPOSE = 121, 19780e8d04f7SBarry Smith MATOP_MULT_HERMITIAN_TRANS_ADD = 122, 19790e8d04f7SBarry Smith MATOP_GET_MULTI_PROC_BLOCK = 123, 19809d39f69dSJed Brown MATOP_FIND_NONZERO_ROWS = 124, 19810e8d04f7SBarry Smith MATOP_GET_COLUMN_NORMS = 125, 19829d39f69dSJed Brown MATOP_INVERT_BLOCK_DIAGONAL = 126, 1983e5f2d425SStefano Zampini MATOP_INVERT_VBLOCK_DIAGONAL = 127, 1984b41ce5d5SBarry Smith MATOP_CREATE_SUB_MATRICES_MPI = 128, 19852b8ad9a3SHong Zhang MATOP_SET_VALUES_BATCH = 129, 1986e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_130=130, */ 19870e8d04f7SBarry Smith MATOP_TRANSPOSE_MAT_MULT_SYMBO = 131, 1988e9b602ebSSatish Balay MATOP_TRANSPOSE_MAT_MULT_NUMER = 132, 19890e8d04f7SBarry Smith MATOP_TRANSPOSE_COLORING_CREAT = 133, 19900e8d04f7SBarry Smith MATOP_TRANS_COLORING_APPLY_SPT = 134, 19910e8d04f7SBarry Smith MATOP_TRANS_COLORING_APPLY_DEN = 135, 1992e5f2d425SStefano Zampini /* MATOP_PLACEHOLDER_136=136, */ 19930e8d04f7SBarry Smith MATOP_RART_SYMBOLIC = 137, 19940e8d04f7SBarry Smith MATOP_RART_NUMERIC = 138, 1995e09a3074SHong Zhang MATOP_SET_BLOCK_SIZES = 139, 1996f9426fe0SMark Adams MATOP_AYPX = 140, 19971919a2e2SJed Brown MATOP_RESIDUAL = 141, 19989c8f2541SHong Zhang MATOP_FDCOLORING_SETUP = 142, 1999e5f2d425SStefano Zampini MATOP_FIND_OFFBLOCK_ENTRIES = 143, 20002d033e1fSHong Zhang MATOP_MPICONCATENATESEQ = 144, 2001bb01b7b0SPatrick Sanan MATOP_DESTROYSUBMATRICES = 145, 2002e265f6d6SPatrick Sanan MATOP_TRANSPOSE_SOLVE = 146, 2003e265f6d6SPatrick Sanan MATOP_GET_VALUES_LOCAL = 147 2004fae171e0SBarry Smith } MatOperation; 20050c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOperation(Mat, MatOperation, void (*)(void)); 2006976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatGetOperation(Mat, MatOperation, void (**)(void)); 2007976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatHasOperation(Mat, MatOperation, PetscBool *); 200894342113SStefano Zampini PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat, PetscBool *); 2009edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatProductClear()", ) static inline PetscErrorCode MatFreeIntermediateDataStructures(Mat A) 2010d71ae5a4SJacob Faibussowitsch { 20119371c9d4SSatish Balay return MatProductClear(A); 20129371c9d4SSatish Balay } 2013014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat, MatOperation, void (*)(void)); 2014014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat, MatOperation, void (**)(void)); 2015014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat, void *); 2016800f99ffSJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetContextDestroy(Mat, PetscErrorCode (*)(void *)); 2017db77db73SJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetVecType(Mat, VecType); 2018f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *); 2019f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *); 20200c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat); 2021b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatShellSetMatProductOperation(Mat, MatProductType, PetscErrorCode (*)(Mat, Mat, Mat, void **), PetscErrorCode (*)(Mat, Mat, Mat, void *), PetscErrorCode (*)(void *), MatType, MatType); 2022b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatIsShell(Mat, PetscBool *); 2023112a2221SBarry Smith 202490ace30eSBarry Smith /* 202590ace30eSBarry Smith Codes for matrices stored on disk. By default they are 202690ace30eSBarry Smith stored in a universal format. By changing the format with 20276a9046bcSBarry Smith PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will 202890ace30eSBarry Smith be stored in a way natural for the matrix, for example dense matrices 202990ace30eSBarry Smith would be stored as dense. Matrices stored this way may only be 2030f4403165SShri Abhyankar read into matrices of the same type. 203190ace30eSBarry Smith */ 203290ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1 203390ace30eSBarry Smith 2034014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat, PetscReal); 203575d48cdbSStefano Zampini 20368546b261SStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat, MatType); 203775d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 203875d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat, PetscBool); 2039f03112d0SStefano Zampini PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat, PetscBool); 2040014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat, Mat *); 20413b3b1effSJed Brown PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat, Mat *); 2042014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat, Mat); 2043e432b41dSStefano Zampini PETSC_EXTERN PetscErrorCode MatISGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *); 2044edd03b47SJacob Faibussowitsch PETSC_EXTERN PETSC_DEPRECATED_FUNCTION(3, 10, 0, "MatConvert()", ) PetscErrorCode MatISGetMPIXAIJ(Mat, MatReuse, Mat *); 20451f4e1ec7SBarry Smith 2046d9274352SBarry Smith /*S 2047d9274352SBarry Smith MatNullSpace - Object that removes a null space from a vector, i.e. 2048cb6b9846SMatthew Knepley orthogonalizes the vector to a subspace 2049d9274352SBarry Smith 2050f7a9e4ceSBarry Smith Level: advanced 2051d9274352SBarry Smith 20521cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()` 2053d9274352SBarry Smith S*/ 205474637425SBarry Smith typedef struct _p_MatNullSpace *MatNullSpace; 2055d9274352SBarry Smith 2056014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm, PetscBool, PetscInt, const Vec[], MatNullSpace *); 2057014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace, PetscErrorCode (*)(MatNullSpace, Vec, void *), void *); 2058014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace *); 2059d0195637SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace, Vec); 2060014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *); 20615fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *); 20625fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat, MatNullSpace); 2063014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat, MatNullSpace); 2064014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat, MatNullSpace); 2065014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat, MatNullSpace *); 2066014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace, Mat, PetscBool *); 2067014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace, PetscViewer); 2068014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace, PetscBool *, PetscInt *, const Vec **); 2069014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec, MatNullSpace *); 207074637425SBarry Smith 2071014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat, IS); 2072014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat, PetscReal); 2073014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat, PetscInt *); 20743f1d51d7SBarry Smith 2075014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat, PetscInt, Mat *); 2076014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat, PetscInt, Mat *); 2077014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat, Mat *); 2078c4f061fbSSatish Balay 20790bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat, MatType, Mat *); 20800bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat, MatType, Mat *); 20810bacdadaSStefano Zampini 2082edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperator()", ) static inline PetscErrorCode MatComputeExplicitOperator(Mat A, Mat *B) 2083d71ae5a4SJacob Faibussowitsch { 2084f22e26b7SPierre Jolivet return MatComputeOperator(A, PETSC_NULLPTR, B); 20859371c9d4SSatish Balay } 2086edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperatorTranspose()", ) static inline PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A, Mat *B) 2087d71ae5a4SJacob Faibussowitsch { 2088f22e26b7SPierre Jolivet return MatComputeOperatorTranspose(A, PETSC_NULLPTR, B); 20899371c9d4SSatish Balay } 2090b0a32e0cSBarry Smith 209149bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat, PetscInt, PetscInt, const PetscScalar[], const PetscScalar[], Mat *); 209249bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat, Mat *); 2093a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat, PetscInt *, PetscInt *, PetscScalar **); 2094a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat, PetscInt *, PetscInt *, const PetscScalar **); 2095a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat, PetscScalar **); 2096a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat, const PetscScalar **); 2097a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat, PetscInt *, PetscInt *, PetscScalar **); 2098a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat, PetscInt *, PetscInt *, const PetscScalar **); 2099a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat, PetscScalar **); 2100a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat, const PetscScalar **); 2101dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat, Mat); 2102dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat, PetscInt, PetscInt, const PetscScalar[]); 2103dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat, PetscInt, PetscInt, const PetscScalar[]); 2104910cf402Sprj- PETSC_EXTERN PetscErrorCode MatKAIJGetScaledIdentity(Mat, PetscBool *); 210549bd79ccSDebojyoti Ghosh 2106014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat, Vec); 210704f1ad80SBarry Smith 21084bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMFFDInitializePackage(void); 21094bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMFFDFinalizePackage(void); 21104bf303faSJacob Faibussowitsch 2111014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 2112014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat, Vec, Vec); 2113014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat, PetscErrorCode (*)(void *, Vec, Vec), void *); 2114014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat, PetscErrorCode (*)(void *, PetscInt, Vec, PetscScalar *)); 2115014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat, PetscErrorCode (*)(void *, Vec)); 2116014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat, PetscScalar[], PetscInt); 2117014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat); 2118014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat, PetscReal); 2119014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat, PetscInt); 2120014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat, PetscScalar *); 2121014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat, const char[]); 2122014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void *, Vec, Vec, PetscScalar *); 2123014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat, PetscErrorCode (*)(void *, Vec, Vec, PetscScalar *), void *); 2124e884886fSBarry Smith 21256370053bSBarry Smith /*S 21266370053bSBarry Smith MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free 21276370053bSBarry Smith Jacobian vector products 2128e884886fSBarry Smith 21292ef1f0ffSBarry Smith Level: developer 21302ef1f0ffSBarry Smith 213195452b02SPatrick Sanan Notes: 213287497f52SBarry Smith `MATMFFD` is a specific `MatType` which uses the `MatMFFD` data structure 21336370053bSBarry Smith 21342ef1f0ffSBarry Smith MatMFFD*() methods actually take the `Mat` as their first argument. Not a `MatMFFD` data structure 21356370053bSBarry Smith 21362ef1f0ffSBarry Smith This functionality is often obtained using `MatCreateSNESMF()` or with `SNES` solvers using `-snes_mf` or `-snes_mf_operator` 21376370053bSBarry Smith 21381cc06b55SBarry Smith .seealso: [](ch_matrices), `MatMFFDType`, `MATMFFD`, `MatCreateMFFD()`, `MatMFFDSetFuction()`, `MatMFFDSetType()`, `MatMFFDRegister()`, 21392ef1f0ffSBarry Smith `MatCreateSNESMF()`, `SNES`, `-snes_mf`, `-snes_mf_operator` 21406370053bSBarry Smith S*/ 2141e884886fSBarry Smith typedef struct _p_MatMFFD *MatMFFD; 2142e884886fSBarry Smith 214376bdecfbSBarry Smith /*J 21442ef1f0ffSBarry Smith MatMFFDType - algorithm used to compute the `h` used in computing matrix-vector products via differencing of a function 2145e884886fSBarry Smith 214616a05f60SBarry Smith Values: 2147*af27ebaaSBarry Smith + `MATMFFD_DS` - an algorithm described by Dennis and Schnabel {cite}`dennis:83` 2148*af27ebaaSBarry Smith - `MATMFFD_WP` - the Walker-Pernice {cite}`pw98` strategy. 214916a05f60SBarry Smith 2150e884886fSBarry Smith Level: beginner 2151e884886fSBarry Smith 21521cc06b55SBarry Smith .seealso: [](ch_matrices), `MatMFFDSetType()`, `MatMFFDRegister()`, `MatMFFDSetFunction()`, `MatCreateMFFD()` 215376bdecfbSBarry Smith J*/ 215419fd82e9SBarry Smith typedef const char *MatMFFDType; 2155e884886fSBarry Smith #define MATMFFD_DS "ds" 2156e884886fSBarry Smith #define MATMFFD_WP "wp" 2157e884886fSBarry Smith 215819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat, MatMFFDType); 2159bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[], PetscErrorCode (*)(MatMFFD)); 2160e884886fSBarry Smith 2161014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat, PetscReal); 2162014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat, PetscBool); 2163e884886fSBarry Smith 216461ab5df0SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring, MatMFFDType); 216561ab5df0SBarry Smith 2166014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *); 2167014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *); 21687dbadf16SMatthew Knepley 216953022affSStefano Zampini #ifdef PETSC_HAVE_H2OPUS 217053022affSStefano Zampini PETSC_EXTERN_TYPEDEF typedef PetscScalar (*MatH2OpusKernel)(PetscInt, PetscReal[], PetscReal[], void *); 217153022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], PetscBool, MatH2OpusKernel, void *, PetscReal, PetscInt, PetscInt, Mat *); 217253022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromMat(Mat, PetscInt, const PetscReal[], PetscBool, PetscReal, PetscInt, PetscInt, PetscInt, PetscReal, Mat *); 217353022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetSamplingMat(Mat, Mat, PetscInt, PetscReal); 217453022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusOrthogonalize(Mat); 217553022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusCompress(Mat, PetscReal); 217653022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetNativeMult(Mat, PetscBool); 217753022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetNativeMult(Mat, PetscBool *); 217853022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetIndexMap(Mat, IS *); 217953022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusMapVec(Mat, PetscBool, Vec, Vec *); 2180300d917bSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusLowRankUpdate(Mat, Mat, Mat, PetscScalar); 2181a0d2e7d8SStefano Zampini #endif 2182a0d2e7d8SStefano Zampini 2183c7a4214aSPierre Jolivet #ifdef PETSC_HAVE_HTOOL 218498e73e17SPierre Jolivet PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatHtoolKernel)(PetscInt, PetscInt, PetscInt, const PetscInt *, const PetscInt *, PetscScalar *, void *); 2185c7a4214aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatCreateHtoolFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], const PetscReal[], MatHtoolKernel, void *, Mat *); 2186c7a4214aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolSetKernel(Mat, MatHtoolKernel, void *); 218798e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationSource(Mat, IS *); 218898e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationTarget(Mat, IS *); 218998e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolUsePermutation(Mat, PetscBool); 21902ef1f0ffSBarry Smith 2191c7a4214aSPierre Jolivet /*E 219287497f52SBarry Smith MatHtoolCompressorType - Indicates the type of compressor used by a `MATHTOOL` 2193c7a4214aSPierre Jolivet 2194c7a4214aSPierre Jolivet Values: 219587497f52SBarry Smith + `MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA` (default) - symmetric partial adaptive cross approximation 219687497f52SBarry Smith . `MAT_HTOOL_COMPRESSOR_FULL_ACA` - full adaptive cross approximation 219787497f52SBarry Smith - `MAT_HTOOL_COMPRESSOR_SVD` - singular value decomposition 2198c7a4214aSPierre Jolivet 219916a05f60SBarry Smith Level: intermediate 220016a05f60SBarry Smith 22011cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolClusteringType` 2202c7a4214aSPierre Jolivet E*/ 22039371c9d4SSatish Balay typedef enum { 22049371c9d4SSatish Balay MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA, 22059371c9d4SSatish Balay MAT_HTOOL_COMPRESSOR_FULL_ACA, 22069371c9d4SSatish Balay MAT_HTOOL_COMPRESSOR_SVD 22079371c9d4SSatish Balay } MatHtoolCompressorType; 22082ef1f0ffSBarry Smith 220998e73e17SPierre Jolivet /*E 221087497f52SBarry Smith MatHtoolClusteringType - Indicates the type of clustering used by a `MATHTOOL` 221198e73e17SPierre Jolivet 221298e73e17SPierre Jolivet Values: 221387497f52SBarry Smith + `MAT_HTOOL_CLUSTERING_PCA_REGULAR` (default) - axis computed via principle component analysis, split uniformly 221487497f52SBarry Smith . `MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC` - axis computed via principle component analysis, split barycentrically 221587497f52SBarry Smith . `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR` - axis along the largest extent of the bounding box, split uniformly 221687497f52SBarry Smith - `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC` - axis along the largest extent of the bounding box, split barycentrically 221798e73e17SPierre Jolivet 221816a05f60SBarry Smith Level: intermediate 221916a05f60SBarry Smith 22202ef1f0ffSBarry Smith Note: 22212ef1f0ffSBarry Smith Higher-dimensional clustering is not yet supported in Htool, but once it is, one should add BOUNDING_BOX_{2,3} types 222298e73e17SPierre Jolivet 22231cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolCompressorType` 222498e73e17SPierre Jolivet E*/ 22259371c9d4SSatish Balay typedef enum { 22269371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_PCA_REGULAR, 22279371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC, 22289371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR, 22299371c9d4SSatish Balay MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC 22309371c9d4SSatish Balay } MatHtoolClusteringType; 2231c7a4214aSPierre Jolivet #endif 2232c7a4214aSPierre Jolivet 223397969023SHong Zhang #ifdef PETSC_HAVE_MUMPS 2234014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat, PetscInt, PetscInt); 2235bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat, PetscInt, PetscInt *); 2236b9e9ea26SSatish Balay PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat, PetscInt, PetscReal); 2237bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat, PetscInt, PetscReal *); 2238bc6112feSHong Zhang 2239ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat, PetscInt, PetscInt *); 2240ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat, PetscInt, PetscInt *); 2241ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat, PetscInt, PetscReal *); 2242ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat, PetscInt, PetscReal *); 22435c0bae8cSAshish Patel PETSC_EXTERN PetscErrorCode MatMumpsGetNullPivots(Mat, PetscInt *, PetscInt **); 224489a9c03aSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat, Mat); 22450e6b8875SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat, Mat); 224697969023SHong Zhang #endif 224723a5497aSJed Brown 2248b500a6b7SJose David Bermeol #ifdef PETSC_HAVE_MKL_PARDISO 2249d615f992SSatish Balay PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat, PetscInt, PetscInt); 2250b500a6b7SJose David Bermeol #endif 2251b500a6b7SJose David Bermeol 2252d305a81bSVasiliy Kozyrev #ifdef PETSC_HAVE_MKL_CPARDISO 2253d305a81bSVasiliy Kozyrev PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat, PetscInt, PetscInt); 2254d305a81bSVasiliy Kozyrev #endif 2255d305a81bSVasiliy Kozyrev 2256d954db57SHong Zhang #ifdef PETSC_HAVE_SUPERLU 2257014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat, PetscReal); 2258d954db57SHong Zhang #endif 2259d954db57SHong Zhang 2260fb785984SHong Zhang #ifdef PETSC_HAVE_SUPERLU_DIST 2261fb785984SHong Zhang PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat, PetscScalar *); 2262fb785984SHong Zhang #endif 2263fb785984SHong Zhang 2264575704cbSPieter Ghysels #ifdef PETSC_HAVE_STRUMPACK 2265542aee0fSPieter Ghysels /*E 226629e0a805SPieter Ghysels MatSTRUMPACKReordering - sparsity reducing ordering to be used in `MATSOLVERSTRUMPACK` 2267542aee0fSPieter Ghysels 22682ef1f0ffSBarry Smith Values: 22692ef1f0ffSBarry Smith + `MAT_STRUMPACK_NATURAL` - use the current ordering 22702ef1f0ffSBarry Smith . `MAT_STRUMPACK_METIS` - use MeTis to compute an ordering 22712ef1f0ffSBarry Smith . `MAT_STRUMPACK_PARMETIS` - use ParMeTis to compute an ordering 22722ef1f0ffSBarry Smith . `MAT_STRUMPACK_SCOTCH` - use Scotch to compute an ordering 22732ef1f0ffSBarry Smith . `MAT_STRUMPACK_PTSCOTCH` - use parallel Scotch to compute an ordering 227429e0a805SPieter Ghysels . `MAT_STRUMPACK_RCM` - use an RCM ordering 227529e0a805SPieter Ghysels . `MAT_STRUMPACK_GEOMETRIC` - use a geometric ordering (needs mesh info from user) 227629e0a805SPieter Ghysels . `MAT_STRUMPACK_AMD` - approximate minimum degree 227729e0a805SPieter Ghysels . `MAT_STRUMPACK_MMD` - multiple minimum degree 227829e0a805SPieter Ghysels . `MAT_STRUMPACK_AND` - approximate nested dissection 227929e0a805SPieter Ghysels . `MAT_STRUMPACK_MLF` - minimum local fill 228029e0a805SPieter Ghysels - `MAT_STRUMPACK_SPECTRAL` - spectral nested dissection 22812ef1f0ffSBarry Smith 228216a05f60SBarry Smith Level: intermediate 228316a05f60SBarry Smith 22842ef1f0ffSBarry Smith Developer Note: 22852ef1f0ffSBarry Smith Should be called `MatSTRUMPACKReorderingType` 22862ef1f0ffSBarry Smith 228729e0a805SPieter Ghysels .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetReordering()` 2288542aee0fSPieter Ghysels E*/ 22899371c9d4SSatish Balay typedef enum { 229029e0a805SPieter Ghysels MAT_STRUMPACK_NATURAL, 229129e0a805SPieter Ghysels MAT_STRUMPACK_METIS, 229229e0a805SPieter Ghysels MAT_STRUMPACK_PARMETIS, 229329e0a805SPieter Ghysels MAT_STRUMPACK_SCOTCH, 229429e0a805SPieter Ghysels MAT_STRUMPACK_PTSCOTCH, 229529e0a805SPieter Ghysels MAT_STRUMPACK_RCM, 229629e0a805SPieter Ghysels MAT_STRUMPACK_GEOMETRIC, 229729e0a805SPieter Ghysels MAT_STRUMPACK_AMD, 229829e0a805SPieter Ghysels MAT_STRUMPACK_MMD, 229929e0a805SPieter Ghysels MAT_STRUMPACK_AND, 230029e0a805SPieter Ghysels MAT_STRUMPACK_MLF, 230129e0a805SPieter Ghysels MAT_STRUMPACK_SPECTRAL 23029371c9d4SSatish Balay } MatSTRUMPACKReordering; 23032ef1f0ffSBarry Smith 230434f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat, MatSTRUMPACKReordering); 230529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetReordering(Mat, MatSTRUMPACKReordering *); 230629e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricNxyz(Mat, PetscInt, PetscInt, PetscInt); 230729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricComponents(Mat, PetscInt); 230829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricWidth(Mat, PetscInt); 2309575704cbSPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat, PetscBool); 231029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetColPerm(Mat, PetscBool *); 231129e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGPU(Mat, PetscBool); 231229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetGPU(Mat, PetscBool *); 231329e0a805SPieter Ghysels 231429e0a805SPieter Ghysels /*E 231529e0a805SPieter Ghysels MatSTRUMPACKCompressionType - Compression used in the approximate sparse factorization solver `MATSOLVERSTRUMPACK` 231629e0a805SPieter Ghysels 231729e0a805SPieter Ghysels Values: 231829e0a805SPieter Ghysels + `MAT_STRUMPACK_COMPRESSION_TYPE_NONE` - no compression, direct solver 231929e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_HSS` - hierarchically semi-separable 232029e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_BLR` - block low rank 232129e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_HODLR` - hierarchically off-diagonal low rank (requires ButterfyPACK support, configure with --download-butterflypack) 232229e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR` - hybrid of BLR and HODLR (requires ButterfyPACK support, configure with --download-butterflypack) 232329e0a805SPieter 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) 232429e0a805SPieter Ghysels . `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS` - lossless compression (requires ZFP support, configure with --download-zfp) 232529e0a805SPieter Ghysels - `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY` - lossy compression (requires ZFP support, configure with --download-zfp) 232629e0a805SPieter Ghysels 232729e0a805SPieter Ghysels Level: intermediate 232829e0a805SPieter Ghysels 232929e0a805SPieter Ghysels .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetCompression()` 233029e0a805SPieter Ghysels E*/ 233129e0a805SPieter Ghysels typedef enum { 233229e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_NONE, 233329e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_HSS, 233429e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_BLR, 233529e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_HODLR, 233629e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR, 233729e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_ZFP_BLR_HODLR, 233829e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS, 233929e0a805SPieter Ghysels MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY 234029e0a805SPieter Ghysels } MatSTRUMPACKCompressionType; 234129e0a805SPieter Ghysels 234229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompression(Mat, MatSTRUMPACKCompressionType); 234329e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompression(Mat, MatSTRUMPACKCompressionType *); 234429e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompRelTol(Mat, PetscReal); 234529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompRelTol(Mat, PetscReal *); 234629e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompAbsTol(Mat, PetscReal); 234729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompAbsTol(Mat, PetscReal *); 234829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompMinSepSize(Mat, PetscInt); 234929e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompMinSepSize(Mat, PetscInt *); 235029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLeafSize(Mat, PetscInt); 235129e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLeafSize(Mat, PetscInt *); 235229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLossyPrecision(Mat, PetscInt); 235329e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLossyPrecision(Mat, PetscInt *); 235429e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompButterflyLevels(Mat, PetscInt); 235529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompButterflyLevels(Mat, PetscInt *); 2356575704cbSPieter Ghysels #endif 2357575704cbSPieter Ghysels 2358b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatBindToCPU(Mat, PetscBool); 23592216c58aSStefano Zampini PETSC_EXTERN PetscErrorCode MatBoundToCPU(Mat, PetscBool *); 2360edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 13, 0, "MatBindToCPU()", ) static inline PetscErrorCode MatPinToCPU(Mat A, PetscBool flg) 2361d71ae5a4SJacob Faibussowitsch { 23629371c9d4SSatish Balay return MatBindToCPU(A, flg); 23639371c9d4SSatish Balay } 236465a9ecf2SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatSetBindingPropagates(Mat, PetscBool); 2365e9c74fd6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetBindingPropagates(Mat, PetscBool *); 2366e7e92044SBarry Smith 2367aa372e3fSPaul Mullowney #ifdef PETSC_HAVE_CUDA 23683f9c0db1SPaul Mullowney /*E 23692ef1f0ffSBarry Smith MatCUSPARSEStorageFormat - indicates the storage format for `MATAIJCUSPARSE` (GPU) 23702692e278SPaul Mullowney matrices. 2371e057df02SPaul Mullowney 23722ef1f0ffSBarry Smith Values: 237387497f52SBarry Smith + `MAT_CUSPARSE_CSR` - Compressed Sparse Row 237487497f52SBarry Smith . `MAT_CUSPARSE_ELL` - Ellpack (requires CUDA 4.2 or later). 237587497f52SBarry Smith - `MAT_CUSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later). 2376e057df02SPaul Mullowney 2377e057df02SPaul Mullowney Level: intermediate 2378e057df02SPaul Mullowney 23791cc06b55SBarry Smith .seealso: [](ch_matrices), `MATAIJCUSPARSE`, `MatCUSPARSESetFormat()`, `MatCUSPARSEFormatOperation` 2380e057df02SPaul Mullowney E*/ 2381e057df02SPaul Mullowney 23829371c9d4SSatish Balay typedef enum { 23839371c9d4SSatish Balay MAT_CUSPARSE_CSR, 23849371c9d4SSatish Balay MAT_CUSPARSE_ELL, 23859371c9d4SSatish Balay MAT_CUSPARSE_HYB 23869371c9d4SSatish Balay } MatCUSPARSEStorageFormat; 2387e057df02SPaul Mullowney 2388e057df02SPaul Mullowney /* these will be strings associated with enumerated type defined above */ 2389e057df02SPaul Mullowney PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[]; 2390e057df02SPaul Mullowney 23913f9c0db1SPaul Mullowney /*E 23922ef1f0ffSBarry Smith MatCUSPARSEFormatOperation - indicates the operation of `MATAIJCUSPARSE` (GPU) 23932692e278SPaul Mullowney matrices whose operation should use a particular storage format. 2394e057df02SPaul Mullowney 23952ef1f0ffSBarry Smith Values: 23964cf0e950SBarry Smith + `MAT_CUSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()` 23974cf0e950SBarry Smith . `MAT_CUSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()` 23984cf0e950SBarry Smith . `MAT_CUSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()` 23992ef1f0ffSBarry Smith - `MAT_CUSPARSE_ALL` - sets the storage format for all `MATAIJCUSPARSE` (GPU) matrices 2400e057df02SPaul Mullowney 2401e057df02SPaul Mullowney Level: intermediate 2402e057df02SPaul Mullowney 24031cc06b55SBarry Smith .seealso: [](ch_matrices), `MatCUSPARSESetFormat()`, `MatCUSPARSEStorageFormat` 2404e057df02SPaul Mullowney E*/ 24059371c9d4SSatish Balay typedef enum { 24069371c9d4SSatish Balay MAT_CUSPARSE_MULT_DIAG, 24079371c9d4SSatish Balay MAT_CUSPARSE_MULT_OFFDIAG, 24089371c9d4SSatish Balay MAT_CUSPARSE_MULT, 24099371c9d4SSatish Balay MAT_CUSPARSE_ALL 24109371c9d4SSatish Balay } MatCUSPARSEFormatOperation; 2411e057df02SPaul Mullowney 241210e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 241310e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 2414e057df02SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat, MatCUSPARSEFormatOperation, MatCUSPARSEStorageFormat); 2415365b711fSMark Adams PETSC_EXTERN PetscErrorCode MatCUSPARSESetUseCPUSolve(Mat, PetscBool); 24165f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetIJ(Mat, PetscBool, const int **, const int **); 24175f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreIJ(Mat, PetscBool, const int **, const int **); 24185f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayRead(Mat, const PetscScalar **); 24195f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayRead(Mat, const PetscScalar **); 24205f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayWrite(Mat, PetscScalar **); 24215f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayWrite(Mat, PetscScalar **); 24225f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArray(Mat, PetscScalar **); 24235f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArray(Mat, PetscScalar **); 2424637a0070SStefano Zampini 2425637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 2426637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 2427637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayWrite(Mat, PetscScalar **); 2428637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayRead(Mat, const PetscScalar **); 2429637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArray(Mat, PetscScalar **); 2430637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayWrite(Mat, PetscScalar **); 2431637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayRead(Mat, const PetscScalar **); 2432637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArray(Mat, PetscScalar **); 2433637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAPlaceArray(Mat, const PetscScalar *); 2434d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAReplaceArray(Mat, const PetscScalar *); 2435637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAResetArray(Mat); 24363d9668e3SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatDenseCUDASetPreallocation(Mat, PetscScalar *); 24372d1451d4SHong Zhang 24382d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 24392d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 24409ae82921SPaul Mullowney #endif 24419ae82921SPaul Mullowney 244247d993e7Ssuyashtn #ifdef PETSC_HAVE_HIP 244347d993e7Ssuyashtn /*E 24442ef1f0ffSBarry Smith MatHIPSPARSEStorageFormat - indicates the storage format for `MATAIJHIPSPARSE` (GPU) 244547d993e7Ssuyashtn matrices. 244647d993e7Ssuyashtn 24472ef1f0ffSBarry Smith Values: 24482ef1f0ffSBarry Smith + `MAT_HIPSPARSE_CSR` - Compressed Sparse Row 24492ef1f0ffSBarry Smith . `MAT_HIPSPARSE_ELL` - Ellpack 24502ef1f0ffSBarry Smith - `MAT_HIPSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format 245147d993e7Ssuyashtn 245216a05f60SBarry Smith Level: intermediate 245316a05f60SBarry Smith 24541cc06b55SBarry Smith .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEFormatOperation` 245547d993e7Ssuyashtn E*/ 245647d993e7Ssuyashtn 245747d993e7Ssuyashtn typedef enum { 245847d993e7Ssuyashtn MAT_HIPSPARSE_CSR, 245947d993e7Ssuyashtn MAT_HIPSPARSE_ELL, 246047d993e7Ssuyashtn MAT_HIPSPARSE_HYB 246147d993e7Ssuyashtn } MatHIPSPARSEStorageFormat; 246247d993e7Ssuyashtn 246347d993e7Ssuyashtn /* these will be strings associated with enumerated type defined above */ 246447d993e7Ssuyashtn PETSC_EXTERN const char *const MatHIPSPARSEStorageFormats[]; 246547d993e7Ssuyashtn 246647d993e7Ssuyashtn /*E 24672ef1f0ffSBarry Smith MatHIPSPARSEFormatOperation - indicates the operation of `MATAIJHIPSPARSE` (GPU) 246847d993e7Ssuyashtn matrices whose operation should use a particular storage format. 246947d993e7Ssuyashtn 24702ef1f0ffSBarry Smith Values: 24712ef1f0ffSBarry Smith + `MAT_HIPSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()` 24724cf0e950SBarry Smith . `MAT_HIPSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()` 24732ef1f0ffSBarry Smith . `MAT_HIPSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()` 24742ef1f0ffSBarry Smith - `MAT_HIPSPARSE_ALL` - sets the storage format for all HIPSPARSE (GPU) matrices 24752ef1f0ffSBarry Smith 247616a05f60SBarry Smith Level: intermediate 247716a05f60SBarry Smith 24781cc06b55SBarry Smith .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEStorageFormat` 247947d993e7Ssuyashtn E*/ 248047d993e7Ssuyashtn typedef enum { 248147d993e7Ssuyashtn MAT_HIPSPARSE_MULT_DIAG, 248247d993e7Ssuyashtn MAT_HIPSPARSE_MULT_OFFDIAG, 248347d993e7Ssuyashtn MAT_HIPSPARSE_MULT, 248447d993e7Ssuyashtn MAT_HIPSPARSE_ALL 248547d993e7Ssuyashtn } MatHIPSPARSEFormatOperation; 248647d993e7Ssuyashtn 248747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 248847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 248947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetFormat(Mat, MatHIPSPARSEFormatOperation, MatHIPSPARSEStorageFormat); 249047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetUseCPUSolve(Mat, PetscBool); 249147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetIJ(Mat, PetscBool, const int **, const int **); 249247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreIJ(Mat, PetscBool, const int **, const int **); 249347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayRead(Mat, const PetscScalar **); 249447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayRead(Mat, const PetscScalar **); 249547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayWrite(Mat, PetscScalar **); 249647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayWrite(Mat, PetscScalar **); 249747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArray(Mat, PetscScalar **); 249847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArray(Mat, PetscScalar **); 249947d993e7Ssuyashtn 250047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 250147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 250247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayWrite(Mat, PetscScalar **); 250347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayRead(Mat, const PetscScalar **); 250447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArray(Mat, PetscScalar **); 250547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayWrite(Mat, PetscScalar **); 250647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayRead(Mat, const PetscScalar **); 250747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArray(Mat, PetscScalar **); 250847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPPlaceArray(Mat, const PetscScalar *); 250947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPReplaceArray(Mat, const PetscScalar *); 251047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPResetArray(Mat); 25113d9668e3SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatDenseHIPSetPreallocation(Mat, PetscScalar *); 251247d993e7Ssuyashtn #endif 251347d993e7Ssuyashtn 2514d67ff14aSKarl Rupp #if defined(PETSC_HAVE_VIENNACL) 2515d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 2516d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 2517d67ff14aSKarl Rupp #endif 2518d67ff14aSKarl Rupp 25194bf303faSJacob Faibussowitsch #if PetscDefined(HAVE_KOKKOS) 25204bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 25214bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 25224bf303faSJacob Faibussowitsch #endif 25234bf303faSJacob Faibussowitsch 252454efbe56SHong Zhang #if defined(PETSC_HAVE_FFTW) 2525014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat, Vec, Vec); 2526014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat, Vec, Vec); 25272a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat, Vec *, Vec *, Vec *); 252854efbe56SHong Zhang #endif 252954efbe56SHong Zhang 2530d24d4204SJose E. Roman #if defined(PETSC_HAVE_SCALAPACK) 2531d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateScaLAPACK(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 2532d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKSetBlockSizes(Mat, PetscInt, PetscInt); 2533d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKGetBlockSizes(Mat, PetscInt *, PetscInt *); 2534d24d4204SJose E. Roman #endif 2535d24d4204SJose E. Roman 2536014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm, PetscInt, const IS[], PetscInt, const IS[], const Mat[], Mat *); 2537014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat, PetscInt *, PetscInt *); 2538014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat, IS[], IS[]); 2539014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat, IS[], IS[]); 2540014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat, PetscInt *, PetscInt *, Mat ***); 2541014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat, PetscInt, PetscInt, Mat *); 254219fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat, VecType); 2543014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat, PetscInt, const IS[], PetscInt, const IS[], const Mat[]); 2544014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat, PetscInt, PetscInt, Mat); 2545d8588912SDave May 25462ce66baaSPierre Jolivet PETSC_EXTERN PetscErrorCode MatFilter(Mat, PetscReal, PetscBool, PetscBool); 25472ce66baaSPierre Jolivet PETSC_DEPRECATED_FUNCTION(3, 20, 0, "MatFilter()", ) static inline PetscErrorCode MatChop(Mat A, PetscReal tol) 25482ce66baaSPierre Jolivet { 25492ce66baaSPierre Jolivet return MatFilter(A, tol, PETSC_FALSE, PETSC_FALSE); 25502ce66baaSPierre Jolivet } 2551e0a58c10SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat, PetscReal, PetscInt *); 25524325cce7SMatthew G Knepley 2553b541e6a4SDmitry Karpeev PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat, PetscInt, PetscInt *, IS **); 255453dd7562SDmitry Karpeev 2555c094ef40SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat, PetscBool, Mat); 2556c094ef40SMatthew G. Knepley 255702218ef1SBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderMerge(Mat, Mat *); 2558539c167fSBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat, Mat *); 25591a2c6b5cSJunchao Zhang 25607ee59b9bSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetCSRAndMemType(Mat, const PetscInt **, const PetscInt **, PetscScalar **, PetscMemType *); 256172833a62Smarkadams4 25622d776b49SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateGraph(Mat, PetscBool, PetscBool, PetscReal, Mat *); 256358c11ad4SPierre Jolivet PETSC_EXTERN PetscErrorCode MatEliminateZeros(Mat, PetscBool); 2564ad6ad4e1SHansol Suh 2565d16ceb75SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseFromVecType(MPI_Comm, VecType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar *, Mat *); 2566