12eac72dbSBarry Smith /* 22eac72dbSBarry Smith Include file for the matrix component of PETSc 32eac72dbSBarry Smith */ 40a835dfdSSatish Balay #ifndef __PETSCMAT_H 50a835dfdSSatish Balay #define __PETSCMAT_H 60a835dfdSSatish Balay #include "petscvec.h" 7e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN 82eac72dbSBarry Smith 9d9274352SBarry Smith /*S 10d9274352SBarry Smith Mat - Abstract PETSc matrix object 112eac72dbSBarry Smith 12d91e6319SBarry Smith Level: beginner 13d91e6319SBarry Smith 14d9274352SBarry Smith Concepts: matrix; linear operator 15d9274352SBarry Smith 16d9274352SBarry Smith .seealso: MatCreate(), MatType, MatSetType() 17d9274352SBarry Smith S*/ 18d9274352SBarry Smith typedef struct _p_Mat* Mat; 19d9274352SBarry Smith 20d9274352SBarry Smith /*E 21d9274352SBarry Smith MatType - String with the name of a PETSc matrix or the creation function 22d9274352SBarry Smith with an optional dynamic library name, for example 23d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:mymatcreate() 24d9274352SBarry Smith 25d9274352SBarry Smith Level: beginner 26d9274352SBarry Smith 27d9274352SBarry Smith .seealso: MatSetType(), Mat 28d91e6319SBarry Smith E*/ 29273d9f13SBarry Smith #define MATSAME "same" 30273d9f13SBarry Smith #define MATSEQMAIJ "seqmaij" 31273d9f13SBarry Smith #define MATMPIMAIJ "mpimaij" 32209238afSKris Buschelman #define MATMAIJ "maij" 33273d9f13SBarry Smith #define MATIS "is" 34273d9f13SBarry Smith #define MATMPIROWBS "mpirowbs" 35273d9f13SBarry Smith #define MATSEQAIJ "seqaij" 36273d9f13SBarry Smith #define MATMPIAIJ "mpiaij" 37209238afSKris Buschelman #define MATAIJ "aij" 38273d9f13SBarry Smith #define MATSHELL "shell" 39273d9f13SBarry Smith #define MATSEQBDIAG "seqbdiag" 40273d9f13SBarry Smith #define MATMPIBDIAG "mpibdiag" 41209238afSKris Buschelman #define MATBDIAG "bdiag" 42209238afSKris Buschelman #define MATSEQDENSE "seqdense" 43273d9f13SBarry Smith #define MATMPIDENSE "mpidense" 44209238afSKris Buschelman #define MATDENSE "dense" 45273d9f13SBarry Smith #define MATSEQBAIJ "seqbaij" 46273d9f13SBarry Smith #define MATMPIBAIJ "mpibaij" 47209238afSKris Buschelman #define MATBAIJ "baij" 48273d9f13SBarry Smith #define MATMPIADJ "mpiadj" 49273d9f13SBarry Smith #define MATSEQSBAIJ "seqsbaij" 50273d9f13SBarry Smith #define MATMPISBAIJ "mpisbaij" 51209238afSKris Buschelman #define MATSBAIJ "sbaij" 52cebc7f6cSBarry Smith #define MATDAAD "daad" 53cebc7f6cSBarry Smith #define MATMFFD "mffd" 546d88219bSBarry Smith #define MATESI "esi" 556d88219bSBarry Smith #define MATPETSCESI "petscesi" 56c8a8475eSBarry Smith #define MATNORMAL "normal" 57b3a1e11cSKris Buschelman #define MATSEQAIJSPOOLES "seqaijspooles" 58d10c748bSKris Buschelman #define MATMPIAIJSPOOLES "mpiaijspooles" 599abb65ffSKris Buschelman #define MATSEQSBAIJSPOOLES "seqsbaijspooles" 6022191285SKris Buschelman #define MATMPISBAIJSPOOLES "mpisbaijspooles" 61bb4d4166SHong Zhang #define MATAIJSPOOLES "aijspooles" 62bb4d4166SHong Zhang #define MATSBAIJSPOOLES "sbaijspooles" 6314b396bbSKris Buschelman #define MATSUPERLU "superlu" 641d96aa28SKris Buschelman #define MATSUPERLU_DIST "superlu_dist" 651677d0b8SKris Buschelman #define MATUMFPACK "umfpack" 66e8aa55a4SKris Buschelman #define MATESSL "essl" 674eb8e494SKris Buschelman #define MATLUSOL "lusol" 68397b6df1SKris Buschelman #define MATAIJMUMPS "aijmumps" 69397b6df1SKris Buschelman #define MATSBAIJMUMPS "sbaijmumps" 708da957c5SKris Buschelman #define MATDSCPACK "dscpack" 717065e2aaSKris Buschelman #define MATMATLAB "matlab" 7249773a63SBarry Smith #define MatType char* 73d91e6319SBarry Smith 74c06d978dSMatthew Knepley /* Logging support */ 75552e946dSBarry Smith #define MAT_FILE_COOKIE 1211216 /* used to indicate matrices in binary files */ 766849ba73SBarry Smith extern PetscCookie MAT_COOKIE, MATSNESMFCTX_COOKIE, MAT_FDCOLORING_COOKIE, MAT_PARTITIONING_COOKIE, MAT_NULLSPACE_COOKIE; 776849ba73SBarry Smith extern PetscEvent MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose; 786849ba73SBarry Smith extern PetscEvent MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose; 796849ba73SBarry Smith extern PetscEvent MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic; 806849ba73SBarry Smith extern PetscEvent MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor; 816849ba73SBarry Smith extern PetscEvent MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin; 826849ba73SBarry Smith extern PetscEvent MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering; 836849ba73SBarry Smith extern PetscEvent MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate; 846849ba73SBarry Smith extern PetscEvent MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction; 85cb00f407SKris Buschelman extern PetscEvent MAT_MatMult, MAT_MatMultSymbolic, MAT_MatMultNumeric; 86534c1384SKris Buschelman extern PetscEvent MAT_PtAP, MAT_PtAPSymbolic, MAT_PtAPNumeric; 87bc011b1eSHong Zhang extern PetscEvent MAT_MatMultTranspose, MAT_MatMultTransposeSymbolic, MAT_MatMultTransposeNumeric; 88c06d978dSMatthew Knepley 89dfbe8321SBarry Smith EXTERN PetscErrorCode MatInitializePackage(char *); 90c06d978dSMatthew Knepley 91*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreate(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*); 92dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetType(Mat,const MatType); 93dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetFromOptions(Mat); 94dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetUpPreallocation(Mat); 95dfbe8321SBarry Smith EXTERN PetscErrorCode MatRegisterAll(const char[]); 966849ba73SBarry Smith EXTERN PetscErrorCode MatRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat)); 9730de9b25SBarry Smith 9830de9b25SBarry Smith /*MC 9930de9b25SBarry Smith MatRegisterDynamic - Adds a new matrix type 10030de9b25SBarry Smith 10130de9b25SBarry Smith Synopsis: 102*c1ac3661SBarry Smith PetscErrorCode MatRegisterDynamic(char *name,char *path,char *name_create,PetscErrorCode (*routine_create)(Mat)) 10330de9b25SBarry Smith 10430de9b25SBarry Smith Not Collective 10530de9b25SBarry Smith 10630de9b25SBarry Smith Input Parameters: 10730de9b25SBarry Smith + name - name of a new user-defined matrix type 10830de9b25SBarry Smith . path - path (either absolute or relative) the library containing this solver 10930de9b25SBarry Smith . name_create - name of routine to create method context 11030de9b25SBarry Smith - routine_create - routine to create method context 11130de9b25SBarry Smith 11230de9b25SBarry Smith Notes: 11330de9b25SBarry Smith MatRegisterDynamic() may be called multiple times to add several user-defined solvers. 11430de9b25SBarry Smith 11530de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (routine_create) 11630de9b25SBarry Smith is ignored. 11730de9b25SBarry Smith 11830de9b25SBarry Smith Sample usage: 11930de9b25SBarry Smith .vb 12030de9b25SBarry Smith MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a, 12130de9b25SBarry Smith "MyMatCreate",MyMatCreate); 12230de9b25SBarry Smith .ve 12330de9b25SBarry Smith 12430de9b25SBarry Smith Then, your solver can be chosen with the procedural interface via 12530de9b25SBarry Smith $ MatSetType(Mat,"my_mat") 12630de9b25SBarry Smith or at runtime via the option 12730de9b25SBarry Smith $ -mat_type my_mat 12830de9b25SBarry Smith 12930de9b25SBarry Smith Level: advanced 13030de9b25SBarry Smith 13130de9b25SBarry Smith Notes: ${PETSC_ARCH} and ${BOPT} occuring in pathname will be replaced with appropriate values. 13230de9b25SBarry Smith If your function is not being put into a shared library then use VecRegister() instead 13330de9b25SBarry Smith 13430de9b25SBarry Smith .keywords: Mat, register 13530de9b25SBarry Smith 13630de9b25SBarry Smith .seealso: MatRegisterAll(), MatRegisterDestroy() 13730de9b25SBarry Smith 13830de9b25SBarry Smith M*/ 139273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 140273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0) 141273d9f13SBarry Smith #else 142273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d) 14330de9b25SBarry Smith #endif 14430de9b25SBarry Smith 145273d9f13SBarry Smith extern PetscTruth MatRegisterAllCalled; 146b0a32e0cSBarry Smith extern PetscFList MatList; 14728988994SBarry Smith 148*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*); 149*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*); 150*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 151*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 152*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIRowbs(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 153*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*); 154*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*); 155*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 156*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 157*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*); 158*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 159*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPISBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 160*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*); 161*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateAdic(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,void (*)(void),Mat*); 162dfbe8321SBarry Smith EXTERN PetscErrorCode MatCreateNormal(Mat,Mat*); 163dfbe8321SBarry Smith EXTERN PetscErrorCode MatDestroy(Mat); 16421c89e3eSBarry Smith 165dfbe8321SBarry Smith EXTERN PetscErrorCode MatPrintHelp(Mat); 166dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetPetscMaps(Mat,PetscMap*,PetscMap*); 167ec0117caSBarry Smith 1688ed539a5SBarry Smith /* ------------------------------------------------------------*/ 169*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 170*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 17184cb2905SBarry Smith 1722ef4de8bSBarry Smith /*S 1732ef4de8bSBarry Smith MatStencil - Data structure (C struct) for storing information about a single row or 1742ef4de8bSBarry Smith column of a matrix as index on an associated grid. 1752ef4de8bSBarry Smith 1762ef4de8bSBarry Smith Level: beginner 1772ef4de8bSBarry Smith 1782ef4de8bSBarry Smith Concepts: matrix; linear operator 1792ef4de8bSBarry Smith 180d7bd93baSBarry Smith .seealso: MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockStencil() 1812ef4de8bSBarry Smith S*/ 182435da068SBarry Smith typedef struct { 183*c1ac3661SBarry Smith PetscInt k,j,i,c; 184435da068SBarry Smith } MatStencil; 1852ef4de8bSBarry Smith 186*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode); 187*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode); 188*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt); 189435da068SBarry Smith 190dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetColoring(Mat,ISColoring); 191dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetValuesAdic(Mat,void*); 192*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesAdifor(Mat,PetscInt,void*); 1933a7fca6bSBarry Smith 194d91e6319SBarry Smith /*E 195d91e6319SBarry Smith MatAssemblyType - Indicates if the matrix is now to be used, or if you plan 196d91e6319SBarry Smith to continue to add values to it 197d91e6319SBarry Smith 198d91e6319SBarry Smith Level: beginner 199d91e6319SBarry Smith 200d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd() 201d91e6319SBarry Smith E*/ 2026d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType; 203dfbe8321SBarry Smith EXTERN PetscErrorCode MatAssemblyBegin(Mat,MatAssemblyType); 204dfbe8321SBarry Smith EXTERN PetscErrorCode MatAssemblyEnd(Mat,MatAssemblyType); 205dfbe8321SBarry Smith EXTERN PetscErrorCode MatAssembled(Mat,PetscTruth*); 2064f9c727eSBarry Smith 207*c1ac3661SBarry Smith extern PetscInt MatSetValue_Row, MatSetValue_Column; 2081d73ed98SBarry Smith extern PetscScalar MatSetValue_Value; 2091d73ed98SBarry Smith 21030de9b25SBarry Smith /*MC 21130de9b25SBarry Smith MatSetValue - Set a single entry into a matrix. 21230de9b25SBarry Smith 21330de9b25SBarry Smith Synopsis: 214*c1ac3661SBarry Smith PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode); 21530de9b25SBarry Smith 21630de9b25SBarry Smith Not collective 21730de9b25SBarry Smith 21830de9b25SBarry Smith Input Parameters: 21930de9b25SBarry Smith + m - the matrix 22030de9b25SBarry Smith . row - the row location of the entry 22130de9b25SBarry Smith . col - the column location of the entry 22230de9b25SBarry Smith . value - the value to insert 22330de9b25SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 22430de9b25SBarry Smith 22530de9b25SBarry Smith Notes: 22630de9b25SBarry Smith For efficiency one should use MatSetValues() and set several or many 22730de9b25SBarry Smith values simultaneously if possible. 22830de9b25SBarry Smith 22930de9b25SBarry Smith Level: beginner 23030de9b25SBarry Smith 23130de9b25SBarry Smith .seealso: MatSetValues(), MatSetValueLocal() 23230de9b25SBarry Smith M*/ 233b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \ 2341d73ed98SBarry Smith (MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va, \ 2351d73ed98SBarry Smith MatSetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode)) 23630de9b25SBarry Smith 237ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \ 2381d73ed98SBarry Smith (MatSetValue_Row = i,MatSetValue_Column = j,\ 2391d73ed98SBarry Smith MatGetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&va)) 24030de9b25SBarry Smith 241d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \ 2421d73ed98SBarry Smith (MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va, \ 2431d73ed98SBarry Smith MatSetValuesLocal(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode)) 24430de9b25SBarry Smith 245d91e6319SBarry Smith /*E 246d91e6319SBarry Smith MatOption - Options that may be set for a matrix and its behavior or storage 247d91e6319SBarry Smith 248d91e6319SBarry Smith Level: beginner 249d91e6319SBarry Smith 2500a835dfdSSatish Balay Any additions/changes here MUST also be made in include/finclude/petscmat.h 251d91e6319SBarry Smith 252d91e6319SBarry Smith .seealso: MatSetOption() 253d91e6319SBarry Smith E*/ 2546d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4, 2556d4a8577SBarry Smith MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16, 2566d4a8577SBarry Smith MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64, 2576ca9ecd3SBarry Smith MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66, 2586ca9ecd3SBarry Smith MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69, 2596ca9ecd3SBarry Smith MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72, 2606ca9ecd3SBarry Smith MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74, 2614787f768SSatish Balay MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76, 2627c922b88SBarry Smith MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78, 2632bad1931SBarry Smith MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81, 264efcf0fc3SBarry Smith MAT_DO_NOT_USE_INODES=82,MAT_NOT_SYMMETRIC=83,MAT_HERMITIAN=84, 2659a4540c5SBarry Smith MAT_NOT_STRUCTURALLY_SYMMETRIC=85,MAT_NOT_HERMITIAN=86, 2669a4540c5SBarry Smith MAT_SYMMETRY_ETERNAL=87,MAT_NOT_SYMMETRY_ETERNAL=88} MatOption; 267dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetOption(Mat,MatOption); 268dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetType(Mat,MatType*); 26984cb2905SBarry Smith 270*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]); 271*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 272*c1ac3661SBarry Smith EXTERN PetscErrorCode MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 273*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetColumn(Mat,PetscInt,PetscInt *,PetscInt *[],PetscScalar*[]); 274*c1ac3661SBarry Smith EXTERN PetscErrorCode MatRestoreColumn(Mat,PetscInt,PetscInt *,PetscInt *[],PetscScalar*[]); 275*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetColumnVector(Mat,Vec,PetscInt); 276dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetArray(Mat,PetscScalar *[]); 277dfbe8321SBarry Smith EXTERN PetscErrorCode MatRestoreArray(Mat,PetscScalar *[]); 278*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetBlockSize(Mat,PetscInt *); 2797b80b807SBarry Smith 280dfbe8321SBarry Smith EXTERN PetscErrorCode MatMult(Mat,Vec,Vec); 281dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultAdd(Mat,Vec,Vec,Vec); 282dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultTranspose(Mat,Vec,Vec); 283dfbe8321SBarry Smith EXTERN PetscErrorCode MatIsTranspose(Mat,Mat,PetscReal,PetscTruth*); 284dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultTransposeAdd(Mat,Vec,Vec,Vec); 285dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultConstrained(Mat,Vec,Vec); 286dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultTransposeConstrained(Mat,Vec,Vec); 2872eac72dbSBarry Smith 288d91e6319SBarry Smith /*E 289d91e6319SBarry Smith MatDuplicateOption - Indicates if a duplicated sparse matrix should have 290d91e6319SBarry Smith its numerical values copied over or just its nonzero structure. 291d91e6319SBarry Smith 292d91e6319SBarry Smith Level: beginner 293d91e6319SBarry Smith 294d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 295d91e6319SBarry Smith 296d91e6319SBarry Smith .seealso: MatDuplicate() 297d91e6319SBarry Smith E*/ 2982e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption; 2992e8a6d31SBarry Smith 3006849ba73SBarry Smith EXTERN PetscErrorCode MatConvertRegister(const char[],const char[],const char[],PetscErrorCode (*)(Mat,MatType,Mat*)); 301273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 302273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0) 303273d9f13SBarry Smith #else 304273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d) 305273d9f13SBarry Smith #endif 306dfbe8321SBarry Smith EXTERN PetscErrorCode MatConvertRegisterAll(const char[]); 307dfbe8321SBarry Smith EXTERN PetscErrorCode MatConvertRegisterDestroy(void); 308273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled; 309b0a32e0cSBarry Smith extern PetscFList MatConvertList; 310dfbe8321SBarry Smith EXTERN PetscErrorCode MatConvert(Mat,const MatType,Mat*); 311dfbe8321SBarry Smith EXTERN PetscErrorCode MatDuplicate(Mat,MatDuplicateOption,Mat*); 31294a9d846SBarry Smith 313d91e6319SBarry Smith /*E 314d91e6319SBarry Smith MatStructure - Indicates if the matrix has the same nonzero structure 315d91e6319SBarry Smith 316d91e6319SBarry Smith Level: beginner 317d91e6319SBarry Smith 318d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 319d91e6319SBarry Smith 32094b7f48cSBarry Smith .seealso: MatCopy(), KSPSetOperators(), PCSetOperators() 321d91e6319SBarry Smith E*/ 322c537a176SHong Zhang typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure; 323cb5b572fSBarry Smith 324dfbe8321SBarry Smith EXTERN PetscErrorCode MatCopy(Mat,Mat,MatStructure); 325dfbe8321SBarry Smith EXTERN PetscErrorCode MatView(Mat,PetscViewer); 326dfbe8321SBarry Smith EXTERN PetscErrorCode MatIsSymmetric(Mat,PetscReal,PetscTruth*); 327dfbe8321SBarry Smith EXTERN PetscErrorCode MatIsSymmetricKnown(Mat,PetscTruth*,PetscTruth*); 328dfbe8321SBarry Smith EXTERN PetscErrorCode MatLoad(PetscViewer,const MatType,Mat*); 3297b80b807SBarry Smith 330*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetRowIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *); 331*c1ac3661SBarry Smith EXTERN PetscErrorCode MatRestoreRowIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *); 332*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetColumnIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *); 333*c1ac3661SBarry Smith EXTERN PetscErrorCode MatRestoreColumnIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *); 334d4fbbf0eSBarry Smith 335d91e6319SBarry Smith /*S 336d91e6319SBarry Smith MatInfo - Context of matrix information, used with MatGetInfo() 337d91e6319SBarry Smith 338d91e6319SBarry Smith In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE 339d91e6319SBarry Smith 340d91e6319SBarry Smith Level: intermediate 341d91e6319SBarry Smith 342d91e6319SBarry Smith Concepts: matrix^nonzero information 343d91e6319SBarry Smith 344d9274352SBarry Smith .seealso: MatGetInfo(), MatInfoType 345d91e6319SBarry Smith S*/ 3464e220ebcSLois Curfman McInnes typedef struct { 347b0a32e0cSBarry Smith PetscLogDouble rows_global,columns_global; /* number of global rows and columns */ 348b0a32e0cSBarry Smith PetscLogDouble rows_local,columns_local; /* number of local rows and columns */ 349b0a32e0cSBarry Smith PetscLogDouble block_size; /* block size */ 350b0a32e0cSBarry Smith PetscLogDouble nz_allocated,nz_used,nz_unneeded; /* number of nonzeros */ 351b0a32e0cSBarry Smith PetscLogDouble memory; /* memory allocated */ 352b0a32e0cSBarry Smith PetscLogDouble assemblies; /* number of matrix assemblies called */ 353b0a32e0cSBarry Smith PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 354b0a32e0cSBarry Smith PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */ 355b0a32e0cSBarry Smith PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 3564e220ebcSLois Curfman McInnes } MatInfo; 3574e220ebcSLois Curfman McInnes 358d9274352SBarry Smith /*E 359d9274352SBarry Smith MatInfoType - Indicates if you want information about the local part of the matrix, 360d9274352SBarry Smith the entire parallel matrix or the maximum over all the local parts. 361d9274352SBarry Smith 362d9274352SBarry Smith Level: beginner 363d9274352SBarry Smith 364d9274352SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 365d9274352SBarry Smith 366d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo 367d9274352SBarry Smith E*/ 3687b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 369dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetInfo(Mat,MatInfoType,MatInfo*); 370dfbe8321SBarry Smith EXTERN PetscErrorCode MatValid(Mat,PetscTruth*); 371dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetDiagonal(Mat,Vec); 372dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetRowMax(Mat,Vec); 373dfbe8321SBarry Smith EXTERN PetscErrorCode MatTranspose(Mat,Mat*); 374dfbe8321SBarry Smith EXTERN PetscErrorCode MatPermute(Mat,IS,IS,Mat *); 375*c1ac3661SBarry Smith EXTERN PetscErrorCode MatPermuteSparsify(Mat,PetscInt,PetscReal,PetscReal,IS,IS,Mat *); 376dfbe8321SBarry Smith EXTERN PetscErrorCode MatDiagonalScale(Mat,Vec,Vec); 377dfbe8321SBarry Smith EXTERN PetscErrorCode MatDiagonalSet(Mat,Vec,InsertMode); 378dfbe8321SBarry Smith EXTERN PetscErrorCode MatEqual(Mat,Mat,PetscTruth*); 3797b80b807SBarry Smith 380dfbe8321SBarry Smith EXTERN PetscErrorCode MatNorm(Mat,NormType,PetscReal *); 381dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroEntries(Mat); 382dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroRows(Mat,IS,const PetscScalar*); 383dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroColumns(Mat,IS,const PetscScalar*); 3847b80b807SBarry Smith 385dfbe8321SBarry Smith EXTERN PetscErrorCode MatUseScaledForm(Mat,PetscTruth); 386dfbe8321SBarry Smith EXTERN PetscErrorCode MatScaleSystem(Mat,Vec,Vec); 387dfbe8321SBarry Smith EXTERN PetscErrorCode MatUnScaleSystem(Mat,Vec,Vec); 3885ef9f2a5SBarry Smith 389*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetSize(Mat,PetscInt*,PetscInt*); 390*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetLocalSize(Mat,PetscInt*,PetscInt*); 391*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetOwnershipRange(Mat,PetscInt*,PetscInt*); 3927b80b807SBarry Smith 393d91e6319SBarry Smith /*E 394d91e6319SBarry Smith MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices() 395d91e6319SBarry Smith or MatGetSubMatrix() are to be reused to store the new matrix values. 396d91e6319SBarry Smith 397d91e6319SBarry Smith Level: beginner 398d91e6319SBarry Smith 399d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 400d91e6319SBarry Smith 401d91e6319SBarry Smith .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices() 402d91e6319SBarry Smith E*/ 4037b2a1423SBarry Smith typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse; 404*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 405*c1ac3661SBarry Smith EXTERN PetscErrorCode MatDestroyMatrices(PetscInt,Mat *[]); 406*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetSubMatrix(Mat,IS,IS,PetscInt,MatReuse,Mat *); 4070e36024fSHong Zhang EXTERN PetscErrorCode MatMerge(MPI_Comm,Mat,PetscInt,MatReuse,Mat*); 4080e36024fSHong Zhang EXTERN PetscErrorCode MatMerge_SeqsToMPI(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*); 40925616d81SHong Zhang EXTERN PetscErrorCode MatGetLocalMat(Mat,MatReuse,IS*,IS*,Mat*); 41025616d81SHong Zhang EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,PetscInt*,Mat*); 4118efafbd8SBarry Smith 412*c1ac3661SBarry Smith EXTERN PetscErrorCode MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt); 4137b80b807SBarry Smith 414dfbe8321SBarry Smith EXTERN PetscErrorCode MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*); 415dfbe8321SBarry Smith EXTERN PetscErrorCode MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*); 416dfbe8321SBarry Smith EXTERN PetscErrorCode MatMatMultNumeric(Mat,Mat,Mat); 41722440eb1SKris Buschelman 418dfbe8321SBarry Smith EXTERN PetscErrorCode MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*); 41922440eb1SKris Buschelman EXTERN PetscErrorCode MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*); 42022440eb1SKris Buschelman EXTERN PetscErrorCode MatPtAPNumeric(Mat,Mat,Mat); 42122440eb1SKris Buschelman 422bc011b1eSHong Zhang EXTERN PetscErrorCode MatMatMultTranspose(Mat,Mat,MatReuse,PetscReal,Mat*); 423bc011b1eSHong Zhang EXTERN PetscErrorCode MatMatMultTransposeSymbolic(Mat,Mat,PetscReal,Mat*); 424bc011b1eSHong Zhang EXTERN PetscErrorCode MatMatMultTransposeNumeric(Mat,Mat,Mat); 425bc011b1eSHong Zhang 426dfbe8321SBarry Smith EXTERN PetscErrorCode MatAXPY(const PetscScalar *,Mat,Mat,MatStructure); 427dfbe8321SBarry Smith EXTERN PetscErrorCode MatAYPX(const PetscScalar *,Mat,Mat); 428dfbe8321SBarry Smith EXTERN PetscErrorCode MatCompress(Mat); 4291c741599SHong Zhang 430dfbe8321SBarry Smith EXTERN PetscErrorCode MatScale(const PetscScalar *,Mat); 431dfbe8321SBarry Smith EXTERN PetscErrorCode MatShift(const PetscScalar *,Mat); 4327b80b807SBarry Smith 433dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping); 434dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping); 435dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroRowsLocal(Mat,IS,const PetscScalar*); 436*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 437*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 438052efed2SBarry Smith 439*c1ac3661SBarry Smith EXTERN PetscErrorCode MatStashSetInitialSize(Mat,PetscInt,PetscInt); 440*c1ac3661SBarry Smith EXTERN PetscErrorCode MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 44190f02eecSBarry Smith 442dfbe8321SBarry Smith EXTERN PetscErrorCode MatInterpolateAdd(Mat,Vec,Vec,Vec); 443dfbe8321SBarry Smith EXTERN PetscErrorCode MatInterpolate(Mat,Vec,Vec); 444dfbe8321SBarry Smith EXTERN PetscErrorCode MatRestrict(Mat,Vec,Vec); 445dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetVecs(Mat,Vec*,Vec*); 446bd481603SBarry Smith 447bd481603SBarry Smith /*MC 448bd481603SBarry Smith MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per 449bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 450bd481603SBarry Smith 451bd481603SBarry Smith Synopsis: 452*c1ac3661SBarry Smith PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 453bd481603SBarry Smith 454bd481603SBarry Smith Collective on MPI_Comm 455bd481603SBarry Smith 456bd481603SBarry Smith Input Parameters: 457bd481603SBarry Smith + comm - the communicator that will share the eventually allocated matrix 458bd481603SBarry Smith . nrows - the number of rows in the matrix 459bd481603SBarry Smith - ncols - the number of columns in the matrix 460bd481603SBarry Smith 461bd481603SBarry Smith Output Parameters: 462bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 463bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 464bd481603SBarry Smith 465bd481603SBarry Smith 466bd481603SBarry Smith Level: intermediate 467bd481603SBarry Smith 468bd481603SBarry Smith Notes: 469bd481603SBarry Smith See the chapter in the users manual on performance for more details 470bd481603SBarry Smith 4711d73ed98SBarry Smith Do not malloc or free dnz and onz, that is handled internally by these routines 472bd481603SBarry Smith 473bd481603SBarry Smith Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices) 474bd481603SBarry Smith 475bd481603SBarry Smith Concepts: preallocation^Matrix 476bd481603SBarry Smith 477bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 478bd481603SBarry Smith MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal() 479bd481603SBarry Smith M*/ 480c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \ 4817c922b88SBarry Smith { \ 482*c1ac3661SBarry Smith PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \ 483*c1ac3661SBarry Smith _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 484*c1ac3661SBarry Smith _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\ 485*c1ac3661SBarry Smith _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\ 486*c1ac3661SBarry Smith _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 4877c922b88SBarry Smith 488bd481603SBarry Smith /*MC 489bd481603SBarry Smith MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per 490bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 491bd481603SBarry Smith 492bd481603SBarry Smith Synopsis: 493*c1ac3661SBarry Smith PetscErrorCode MatPreallocateSymmetricInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 494bd481603SBarry Smith 495bd481603SBarry Smith Collective on MPI_Comm 496bd481603SBarry Smith 497bd481603SBarry Smith Input Parameters: 498bd481603SBarry Smith + comm - the communicator that will share the eventually allocated matrix 499bd481603SBarry Smith . nrows - the number of rows in the matrix 500bd481603SBarry Smith - ncols - the number of columns in the matrix 501bd481603SBarry Smith 502bd481603SBarry Smith Output Parameters: 503bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 504bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 505bd481603SBarry Smith 506bd481603SBarry Smith 507bd481603SBarry Smith Level: intermediate 508bd481603SBarry Smith 509bd481603SBarry Smith Notes: 510bd481603SBarry Smith See the chapter in the users manual on performance for more details 511bd481603SBarry Smith 5121d73ed98SBarry Smith Do not malloc or free dnz and onz, that is handled internally by these routines 513bd481603SBarry Smith 514bd481603SBarry Smith Concepts: preallocation^Matrix 515bd481603SBarry Smith 516bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 517bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 518bd481603SBarry Smith M*/ 519222b16d4SBarry Smith #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \ 520222b16d4SBarry Smith { \ 521*c1ac3661SBarry Smith PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__end; \ 522*c1ac3661SBarry Smith _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 523*c1ac3661SBarry Smith _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\ 524*c1ac3661SBarry Smith _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\ 525*c1ac3661SBarry Smith _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 526222b16d4SBarry Smith 527bd481603SBarry Smith /*MC 528bd481603SBarry Smith MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 529bd481603SBarry Smith inserted using a local number of the rows and columns 530bd481603SBarry Smith 531bd481603SBarry Smith Synopsis: 532*c1ac3661SBarry Smith PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 533bd481603SBarry Smith 534bd481603SBarry Smith Not Collective 535bd481603SBarry Smith 536bd481603SBarry Smith Input Parameters: 537bd481603SBarry Smith + map - the mapping between local numbering and global numbering 538bd481603SBarry Smith . nrows - the number of rows indicated 5391d73ed98SBarry Smith . rows - the indices of the rows 540bd481603SBarry Smith . ncols - the number of columns in the matrix 541bd481603SBarry Smith . cols - the columns indicated 542bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 543bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 544bd481603SBarry Smith 545bd481603SBarry Smith 546bd481603SBarry Smith Level: intermediate 547bd481603SBarry Smith 548bd481603SBarry Smith Notes: 549bd481603SBarry Smith See the chapter in the users manual on performance for more details 550bd481603SBarry Smith 5511d73ed98SBarry Smith Do not malloc or free dnz and onz, that is handled internally by these routines 552bd481603SBarry Smith 553bd481603SBarry Smith Concepts: preallocation^Matrix 554bd481603SBarry Smith 555bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 556bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 557bd481603SBarry Smith M*/ 558c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 559c4f061fbSSatish Balay {\ 560*c1ac3661SBarry Smith PetscInt __l;\ 561ef66eb69SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 562ef66eb69SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 563c4f061fbSSatish Balay for (__l=0;__l<nrows;__l++) {\ 564ef66eb69SBarry Smith _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 565c4f061fbSSatish Balay }\ 566c4f061fbSSatish Balay } 567c4f061fbSSatish Balay 568bd481603SBarry Smith /*MC 569bd481603SBarry Smith MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 570bd481603SBarry Smith inserted using a local number of the rows and columns 571bd481603SBarry Smith 572bd481603SBarry Smith Synopsis: 573*c1ac3661SBarry Smith PetscErrorCode MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 574bd481603SBarry Smith 575bd481603SBarry Smith Not Collective 576bd481603SBarry Smith 577bd481603SBarry Smith Input Parameters: 578bd481603SBarry Smith + map - the mapping between local numbering and global numbering 579bd481603SBarry Smith . nrows - the number of rows indicated 5801d73ed98SBarry Smith . rows - the indices of the rows 581bd481603SBarry Smith . ncols - the number of columns in the matrix 582bd481603SBarry Smith . cols - the columns indicated 583bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 584bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 585bd481603SBarry Smith 586bd481603SBarry Smith 587bd481603SBarry Smith Level: intermediate 588bd481603SBarry Smith 589bd481603SBarry Smith Notes: 590bd481603SBarry Smith See the chapter in the users manual on performance for more details 591bd481603SBarry Smith 592bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 593bd481603SBarry Smith 594bd481603SBarry Smith Concepts: preallocation^Matrix 595bd481603SBarry Smith 596bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 597bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 598bd481603SBarry Smith M*/ 599d3d32019SBarry Smith #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 600d3d32019SBarry Smith {\ 601*c1ac3661SBarry Smith PetscInt __l;\ 602d3d32019SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 603d3d32019SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 604d3d32019SBarry Smith for (__l=0;__l<nrows;__l++) {\ 605d3d32019SBarry Smith _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 606d3d32019SBarry Smith }\ 607d3d32019SBarry Smith } 608d3d32019SBarry Smith 609bd481603SBarry Smith /*MC 610bd481603SBarry Smith MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 611bd481603SBarry Smith inserted using a local number of the rows and columns 612bd481603SBarry Smith 613bd481603SBarry Smith Synopsis: 614*c1ac3661SBarry Smith PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 615bd481603SBarry Smith 616bd481603SBarry Smith Not Collective 617bd481603SBarry Smith 618bd481603SBarry Smith Input Parameters: 619bd481603SBarry Smith + nrows - the number of rows indicated 6201d73ed98SBarry Smith . rows - the indices of the rows 621bd481603SBarry Smith . ncols - the number of columns in the matrix 622a50f8bf6SHong Zhang - cols - the columns indicated 623a50f8bf6SHong Zhang 624a50f8bf6SHong Zhang Output Parameters: 625a50f8bf6SHong Zhang + dnz - the array that will be passed to the matrix preallocation routines 626bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 627bd481603SBarry Smith 628bd481603SBarry Smith 629bd481603SBarry Smith Level: intermediate 630bd481603SBarry Smith 631bd481603SBarry Smith Notes: 632bd481603SBarry Smith See the chapter in the users manual on performance for more details 633bd481603SBarry Smith 634bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 635bd481603SBarry Smith 636bd481603SBarry Smith Concepts: preallocation^Matrix 637bd481603SBarry Smith 638bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 639bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 640bd481603SBarry Smith M*/ 641c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\ 642*c1ac3661SBarry Smith { PetscInt __i; \ 6437c922b88SBarry Smith for (__i=0; __i<nc; __i++) {\ 6447c922b88SBarry Smith if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \ 6457c922b88SBarry Smith }\ 6467c922b88SBarry Smith dnz[row - __rstart] = nc - onz[row - __rstart];\ 6477c922b88SBarry Smith } 6487c922b88SBarry Smith 649bd481603SBarry Smith /*MC 650bd481603SBarry Smith MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 651bd481603SBarry Smith inserted using a local number of the rows and columns 652bd481603SBarry Smith 653bd481603SBarry Smith Synopsis: 654*c1ac3661SBarry Smith PetscErrorCode MatPreallocateSymmetricSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 655bd481603SBarry Smith 656bd481603SBarry Smith Not Collective 657bd481603SBarry Smith 658bd481603SBarry Smith Input Parameters: 659bd481603SBarry Smith + nrows - the number of rows indicated 6601d73ed98SBarry Smith . rows - the indices of the rows 661bd481603SBarry Smith . ncols - the number of columns in the matrix 662bd481603SBarry Smith . cols - the columns indicated 663bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 664bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 665bd481603SBarry Smith 666bd481603SBarry Smith 667bd481603SBarry Smith Level: intermediate 668bd481603SBarry Smith 669bd481603SBarry Smith Notes: 670bd481603SBarry Smith See the chapter in the users manual on performance for more details 671bd481603SBarry Smith 672bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 673bd481603SBarry Smith 674bd481603SBarry Smith Concepts: preallocation^Matrix 675bd481603SBarry Smith 676bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 677bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 678bd481603SBarry Smith M*/ 679d3d32019SBarry Smith #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\ 680*c1ac3661SBarry Smith { PetscInt __i; \ 681d3d32019SBarry Smith for (__i=0; __i<nc; __i++) {\ 682d3d32019SBarry Smith if (cols[__i] >= __end) onz[row - __rstart]++; \ 683d3d32019SBarry Smith else if (cols[__i] >= row) dnz[row - __rstart]++;\ 684d3d32019SBarry Smith }\ 685d3d32019SBarry Smith } 686d3d32019SBarry Smith 687bd481603SBarry Smith /*MC 688bd481603SBarry Smith MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per 689bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 690bd481603SBarry Smith 691bd481603SBarry Smith Synopsis: 692*c1ac3661SBarry Smith PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz) 693bd481603SBarry Smith 694bd481603SBarry Smith Collective on MPI_Comm 695bd481603SBarry Smith 696bd481603SBarry Smith Input Parameters: 697bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 698bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 699bd481603SBarry Smith 700bd481603SBarry Smith 701bd481603SBarry Smith Level: intermediate 702bd481603SBarry Smith 703bd481603SBarry Smith Notes: 704bd481603SBarry Smith See the chapter in the users manual on performance for more details 705bd481603SBarry Smith 706bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 707bd481603SBarry Smith 708bd481603SBarry Smith Concepts: preallocation^Matrix 709bd481603SBarry Smith 710bd481603SBarry Smith .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 711bd481603SBarry Smith MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal() 712bd481603SBarry Smith M*/ 713ef66eb69SBarry Smith #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);} 7147c922b88SBarry Smith 715bd481603SBarry Smith 716bd481603SBarry Smith 7177b80b807SBarry Smith /* Routines unique to particular data structures */ 718dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellGetContext(Mat,void **); 719435da068SBarry Smith 720*c1ac3661SBarry Smith EXTERN PetscErrorCode MatBDiagGetData(Mat,PetscInt*,PetscInt*,PetscInt*[],PetscInt*[],PetscScalar***); 721*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat,PetscInt[]); 722*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat,PetscInt[]); 723*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*); 7247b80b807SBarry Smith 725*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]); 726*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]); 727*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]); 728dfbe8321SBarry Smith EXTERN PetscErrorCode MatSeqDensePreallocation(Mat,PetscScalar[]); 729*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]); 730dfbe8321SBarry Smith EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat,PetscScalar[]); 731273d9f13SBarry Smith 732*c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 733*c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 734*c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 735dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIDensePreallocation(Mat,PetscScalar[]); 736*c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]); 737*c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]); 738dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat,PetscScalar[]); 739*c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIRowbsSetPreallocation(Mat,PetscInt,const PetscInt[]); 740*c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,PetscInt*[]); 741*c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,PetscInt*[]); 742dfbe8321SBarry Smith EXTERN PetscErrorCode MatAdicSetLocalFunction(Mat,void (*)(void)); 743273d9f13SBarry Smith 744*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqDenseSetLDA(Mat,PetscInt); 7451b807ce4Svictorle 746dfbe8321SBarry Smith EXTERN PetscErrorCode MatStoreValues(Mat); 747dfbe8321SBarry Smith EXTERN PetscErrorCode MatRetrieveValues(Mat); 7482e8a6d31SBarry Smith 749dfbe8321SBarry Smith EXTERN PetscErrorCode MatDAADSetCtx(Mat,void*); 7503a7fca6bSBarry Smith 7517b80b807SBarry Smith /* 7527b80b807SBarry Smith These routines are not usually accessed directly, rather solving is 75394b7f48cSBarry Smith done through the KSP and PC interfaces. 7547b80b807SBarry Smith */ 7557b80b807SBarry Smith 756d9274352SBarry Smith /*E 757d9274352SBarry Smith MatOrderingType - String with the name of a PETSc matrix ordering or the creation function 758d9274352SBarry Smith with an optional dynamic library name, for example 759d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:orderingcreate() 760d9274352SBarry Smith 761d9274352SBarry Smith Level: beginner 762d9274352SBarry Smith 763d9274352SBarry Smith .seealso: MatGetOrdering() 764d9274352SBarry Smith E*/ 76549773a63SBarry Smith #define MatOrderingType char* 766b12f92e5SBarry Smith #define MATORDERING_NATURAL "natural" 767b12f92e5SBarry Smith #define MATORDERING_ND "nd" 768b12f92e5SBarry Smith #define MATORDERING_1WD "1wd" 769b12f92e5SBarry Smith #define MATORDERING_RCM "rcm" 770b12f92e5SBarry Smith #define MATORDERING_QMD "qmd" 771b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength" 77262152c8bSBarry Smith #define MATORDERING_DSC_ND "dsc_nd" 77362152c8bSBarry Smith #define MATORDERING_DSC_MMD "dsc_mmd" 77462152c8bSBarry Smith #define MATORDERING_DSC_MDF "dsc_mdf" 775c06d978dSMatthew Knepley #define MATORDERING_CONSTRAINED "constrained" 776c06d978dSMatthew Knepley #define MATORDERING_IDENTITY "identity" 777c06d978dSMatthew Knepley #define MATORDERING_REVERSE "reverse" 778b12f92e5SBarry Smith 779dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetOrdering(Mat,const MatOrderingType,IS*,IS*); 7806849ba73SBarry Smith EXTERN PetscErrorCode MatOrderingRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatOrderingType,IS*,IS*)); 78130de9b25SBarry Smith 78230de9b25SBarry Smith /*MC 78330de9b25SBarry Smith MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the 78430de9b25SBarry Smith matrix package. 78530de9b25SBarry Smith 78630de9b25SBarry Smith Synopsis: 787*c1ac3661SBarry Smith PetscErrorCode MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,PetscErrorCode (*routine_create)(MatOrdering)) 78830de9b25SBarry Smith 78930de9b25SBarry Smith Not Collective 79030de9b25SBarry Smith 79130de9b25SBarry Smith Input Parameters: 79230de9b25SBarry Smith + sname - name of ordering (for example MATORDERING_ND) 79330de9b25SBarry Smith . path - location of library where creation routine is 79430de9b25SBarry Smith . name - name of function that creates the ordering type,a string 79530de9b25SBarry Smith - function - function pointer that creates the ordering 79630de9b25SBarry Smith 79730de9b25SBarry Smith Level: developer 79830de9b25SBarry Smith 79930de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (function) 80030de9b25SBarry Smith is ignored. 80130de9b25SBarry Smith 80230de9b25SBarry Smith Sample usage: 80330de9b25SBarry Smith .vb 80430de9b25SBarry Smith MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a, 80530de9b25SBarry Smith "MyOrder",MyOrder); 80630de9b25SBarry Smith .ve 80730de9b25SBarry Smith 80830de9b25SBarry Smith Then, your partitioner can be chosen with the procedural interface via 80930de9b25SBarry Smith $ MatOrderingSetType(part,"my_order) 81030de9b25SBarry Smith or at runtime via the option 81130de9b25SBarry Smith $ -pc_ilu_mat_ordering_type my_order 81230de9b25SBarry Smith $ -pc_lu_mat_ordering_type my_order 81330de9b25SBarry Smith 81430de9b25SBarry Smith ${PETSC_ARCH} and ${BOPT} occuring in pathname will be replaced with appropriate values. 81530de9b25SBarry Smith 81630de9b25SBarry Smith .keywords: matrix, ordering, register 81730de9b25SBarry Smith 81830de9b25SBarry Smith .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll() 81930de9b25SBarry Smith M*/ 820aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 821f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0) 822b12f92e5SBarry Smith #else 823f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d) 824b12f92e5SBarry Smith #endif 82530de9b25SBarry Smith 826dfbe8321SBarry Smith EXTERN PetscErrorCode MatOrderingRegisterDestroy(void); 827dfbe8321SBarry Smith EXTERN PetscErrorCode MatOrderingRegisterAll(const char[]); 8282bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled; 829b0a32e0cSBarry Smith extern PetscFList MatOrderingList; 830d4fbbf0eSBarry Smith 831dfbe8321SBarry Smith EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS); 832a2ce50c7SBarry Smith 833d91e6319SBarry Smith /*S 83415e8a5b3SHong Zhang MatFactorInfo - Data based into the matrix factorization routines 835b00f7748SHong Zhang 83615e8a5b3SHong Zhang In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE 837b00f7748SHong Zhang 83815e8a5b3SHong Zhang Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC. 839b00f7748SHong Zhang 840b00f7748SHong Zhang Level: developer 841b00f7748SHong Zhang 842b380c88cSHong Zhang .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor() 843b00f7748SHong Zhang 844b00f7748SHong Zhang S*/ 845b00f7748SHong Zhang typedef struct { 84615e8a5b3SHong Zhang PetscReal damping; /* scaling of identity added to matrix to prevent zero pivots */ 8472cea7109SBarry Smith PetscReal shift; /* if true, shift until positive pivots */ 8482cea7109SBarry Smith PetscReal shift_fraction; /* record shift fraction taken */ 84915e8a5b3SHong Zhang PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 85015e8a5b3SHong Zhang PetscReal dt; /* drop tolerance */ 851b00f7748SHong Zhang PetscReal dtcol; /* tolerance for pivoting */ 85215e8a5b3SHong Zhang PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 853f6275e2eSBarry Smith PetscReal fill; /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/ 854348344bbSBarry Smith PetscReal levels; /* ICC/ILU(levels) */ 855bcd9e38bSBarry Smith PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 856bcd9e38bSBarry Smith factorization may be faster if do not pivot */ 85715e8a5b3SHong Zhang PetscReal zeropivot; /* pivot is called zero if less than this */ 85815e8a5b3SHong Zhang } MatFactorInfo; 859ffa6d0a5SLois Curfman McInnes 860dfbe8321SBarry Smith EXTERN PetscErrorCode MatCholeskyFactor(Mat,IS,MatFactorInfo*); 861dfbe8321SBarry Smith EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 862dfbe8321SBarry Smith EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat,Mat*); 863dfbe8321SBarry Smith EXTERN PetscErrorCode MatLUFactor(Mat,IS,IS,MatFactorInfo*); 864dfbe8321SBarry Smith EXTERN PetscErrorCode MatILUFactor(Mat,IS,IS,MatFactorInfo*); 865dfbe8321SBarry Smith EXTERN PetscErrorCode MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 866dfbe8321SBarry Smith EXTERN PetscErrorCode MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 867dfbe8321SBarry Smith EXTERN PetscErrorCode MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 868dfbe8321SBarry Smith EXTERN PetscErrorCode MatICCFactor(Mat,IS,MatFactorInfo*); 869dfbe8321SBarry Smith EXTERN PetscErrorCode MatLUFactorNumeric(Mat,Mat*); 870dfbe8321SBarry Smith EXTERN PetscErrorCode MatILUDTFactor(Mat,MatFactorInfo*,IS,IS,Mat *); 871*c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*); 872dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolve(Mat,Vec,Vec); 873dfbe8321SBarry Smith EXTERN PetscErrorCode MatForwardSolve(Mat,Vec,Vec); 874dfbe8321SBarry Smith EXTERN PetscErrorCode MatBackwardSolve(Mat,Vec,Vec); 875dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolveAdd(Mat,Vec,Vec,Vec); 876dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolveTranspose(Mat,Vec,Vec); 877dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolveTransposeAdd(Mat,Vec,Vec,Vec); 878dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolves(Mat,Vecs,Vecs); 8798ed539a5SBarry Smith 880dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetUnfactored(Mat); 881bb5a7306SBarry Smith 882d91e6319SBarry Smith /*E 883d91e6319SBarry Smith MatSORType - What type of (S)SOR to perform 884bb1eb677SSatish Balay 885d91e6319SBarry Smith Level: beginner 886d91e6319SBarry Smith 887d9274352SBarry Smith May be bitwise ORd together 888d9274352SBarry Smith 889d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 890d91e6319SBarry Smith 8914e7234bfSBarry Smith MatSORType may be bitwise ORd together, so do not change the numbers 8924e7234bfSBarry Smith 893a1d92eedSBarry Smith .seealso: MatRelax(), MatPBRelax() 894d91e6319SBarry Smith E*/ 895ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 896ee50ffe9SBarry Smith SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 897ee50ffe9SBarry Smith SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 89884cb2905SBarry Smith SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType; 899*c1ac3661SBarry Smith EXTERN PetscErrorCode MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec); 900*c1ac3661SBarry Smith EXTERN PetscErrorCode MatPBRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec); 9018ed539a5SBarry Smith 902d4fbbf0eSBarry Smith /* 903639f9d9dSBarry Smith These routines are for efficiently computing Jacobians via finite differences. 904639f9d9dSBarry Smith */ 905b12f92e5SBarry Smith 906d9274352SBarry Smith /*E 907d9274352SBarry Smith MatColoringType - String with the name of a PETSc matrix coloring or the creation function 908d9274352SBarry Smith with an optional dynamic library name, for example 909d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:coloringcreate() 910d9274352SBarry Smith 911d9274352SBarry Smith Level: beginner 912d9274352SBarry Smith 913d9274352SBarry Smith .seealso: MatGetColoring() 914d9274352SBarry Smith E*/ 91549773a63SBarry Smith #define MatColoringType char* 916b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural" 917b12f92e5SBarry Smith #define MATCOLORING_SL "sl" 918b12f92e5SBarry Smith #define MATCOLORING_LF "lf" 919b12f92e5SBarry Smith #define MATCOLORING_ID "id" 920b12f92e5SBarry Smith 921dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetColoring(Mat,const MatColoringType,ISColoring*); 9226849ba73SBarry Smith EXTERN PetscErrorCode MatColoringRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatColoringType,ISColoring *)); 92330de9b25SBarry Smith 92430de9b25SBarry Smith /*MC 92530de9b25SBarry Smith MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the 92630de9b25SBarry Smith matrix package. 92730de9b25SBarry Smith 92830de9b25SBarry Smith Synopsis: 929*c1ac3661SBarry Smith PetscErrorCode MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,PetscErrorCode (*routine_create)(MatColoring)) 93030de9b25SBarry Smith 93130de9b25SBarry Smith Not Collective 93230de9b25SBarry Smith 93330de9b25SBarry Smith Input Parameters: 93430de9b25SBarry Smith + sname - name of Coloring (for example MATCOLORING_SL) 93530de9b25SBarry Smith . path - location of library where creation routine is 93630de9b25SBarry Smith . name - name of function that creates the Coloring type, a string 93730de9b25SBarry Smith - function - function pointer that creates the coloring 93830de9b25SBarry Smith 93930de9b25SBarry Smith Level: developer 94030de9b25SBarry Smith 94130de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (function) 94230de9b25SBarry Smith is ignored. 94330de9b25SBarry Smith 94430de9b25SBarry Smith Sample usage: 94530de9b25SBarry Smith .vb 94630de9b25SBarry Smith MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a, 94730de9b25SBarry Smith "MyColor",MyColor); 94830de9b25SBarry Smith .ve 94930de9b25SBarry Smith 95030de9b25SBarry Smith Then, your partitioner can be chosen with the procedural interface via 95130de9b25SBarry Smith $ MatColoringSetType(part,"my_color") 95230de9b25SBarry Smith or at runtime via the option 95330de9b25SBarry Smith $ -mat_coloring_type my_color 95430de9b25SBarry Smith 95530de9b25SBarry Smith $PETSC_ARCH and $BOPT occuring in pathname will be replaced with appropriate values. 95630de9b25SBarry Smith 95730de9b25SBarry Smith .keywords: matrix, Coloring, register 95830de9b25SBarry Smith 95930de9b25SBarry Smith .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll() 96030de9b25SBarry Smith M*/ 961aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 962f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0) 963b12f92e5SBarry Smith #else 964f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d) 965b12f92e5SBarry Smith #endif 96630de9b25SBarry Smith 967dfbe8321SBarry Smith EXTERN PetscErrorCode MatColoringRegisterAll(const char[]); 9682bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled; 969dfbe8321SBarry Smith EXTERN PetscErrorCode MatColoringRegisterDestroy(void); 970*c1ac3661SBarry Smith EXTERN PetscErrorCode MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*); 971639f9d9dSBarry Smith 972d9274352SBarry Smith /*S 973d9274352SBarry Smith MatFDColoring - Object for computing a sparse Jacobian via finite differences 974d9274352SBarry Smith and coloring 975639f9d9dSBarry Smith 976d9274352SBarry Smith Level: beginner 977d9274352SBarry Smith 978d9274352SBarry Smith Concepts: coloring, sparse Jacobian, finite differences 979d9274352SBarry Smith 980d9274352SBarry Smith .seealso: MatFDColoringCreate() 981d9274352SBarry Smith S*/ 982e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring; 983639f9d9dSBarry Smith 984dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringCreate(Mat,ISColoring,MatFDColoring *); 985dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring); 986dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringView(MatFDColoring,PetscViewer); 9876849ba73SBarry Smith EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*); 988dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal); 989*c1ac3661SBarry Smith EXTERN PetscErrorCode MatFDColoringSetFrequency(MatFDColoring,PetscInt); 990*c1ac3661SBarry Smith EXTERN PetscErrorCode MatFDColoringGetFrequency(MatFDColoring,PetscInt*); 991dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring); 992dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *); 993dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *); 994dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetRecompute(MatFDColoring); 995dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring,Vec); 996*c1ac3661SBarry Smith EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,PetscInt*[]); 997639f9d9dSBarry Smith /* 9980752156aSBarry Smith These routines are for partitioning matrices: currently used only 9993eda8832SBarry Smith for adjacency matrix, MatCreateMPIAdj(). 10000752156aSBarry Smith */ 1001ca161407SBarry Smith 1002d9274352SBarry Smith /*S 1003d9274352SBarry Smith MatPartitioning - Object for managing the partitioning of a matrix or graph 1004d9274352SBarry Smith 1005d9274352SBarry Smith Level: beginner 1006d9274352SBarry Smith 1007d9274352SBarry Smith Concepts: partitioning 1008d9274352SBarry Smith 1009743a1026Svictorle .seealso: MatPartitioningCreate(), MatPartitioningType 1010d9274352SBarry Smith S*/ 101191e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning; 1012d9274352SBarry Smith 1013d9274352SBarry Smith /*E 10145bc6e7ccSvictorle MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function 1015d9274352SBarry Smith with an optional dynamic library name, for example 1016d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate() 1017d9274352SBarry Smith 1018d9274352SBarry Smith Level: beginner 1019d9274352SBarry Smith 1020b547a13bSvictorle .seealso: MatPartitioningCreate(), MatPartitioning 1021d9274352SBarry Smith E*/ 102249773a63SBarry Smith #define MatPartitioningType char* 10238ba1e511SMatthew Knepley #define MAT_PARTITIONING_CURRENT "current" 10248ba1e511SMatthew Knepley #define MAT_PARTITIONING_PARMETIS "parmetis" 102571306c60Sjroman #define MAT_PARTITIONING_CHACO "chaco" 102671306c60Sjroman #define MAT_PARTITIONING_JOSTLE "jostle" 102771306c60Sjroman #define MAT_PARTITIONING_PARTY "party" 102871306c60Sjroman #define MAT_PARTITIONING_SCOTCH "scotch" 102971306c60Sjroman 1030ca161407SBarry Smith 1031dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm,MatPartitioning*); 1032dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning,const MatPartitioningType); 1033*c1ac3661SBarry Smith EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning,PetscInt); 1034dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning,Mat); 1035*c1ac3661SBarry Smith EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]); 1036dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []); 1037dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning,IS*); 1038dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning); 10392aabb6bbSBarry Smith 10406849ba73SBarry Smith EXTERN PetscErrorCode MatPartitioningRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatPartitioning)); 104130de9b25SBarry Smith 104230de9b25SBarry Smith /*MC 104330de9b25SBarry Smith MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the 104430de9b25SBarry Smith matrix package. 104530de9b25SBarry Smith 104630de9b25SBarry Smith Synopsis: 1047*c1ac3661SBarry Smith PetscErrorCode MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,PetscErrorCode (*routine_create)(MatPartitioning)) 104830de9b25SBarry Smith 104930de9b25SBarry Smith Not Collective 105030de9b25SBarry Smith 105130de9b25SBarry Smith Input Parameters: 105230de9b25SBarry Smith + sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis 105330de9b25SBarry Smith . path - location of library where creation routine is 105430de9b25SBarry Smith . name - name of function that creates the partitioning type, a string 105530de9b25SBarry Smith - function - function pointer that creates the partitioning type 105630de9b25SBarry Smith 105730de9b25SBarry Smith Level: developer 105830de9b25SBarry Smith 105930de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (function) 106030de9b25SBarry Smith is ignored. 106130de9b25SBarry Smith 106230de9b25SBarry Smith Sample usage: 106330de9b25SBarry Smith .vb 106430de9b25SBarry Smith MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a, 106530de9b25SBarry Smith "MyPartCreate",MyPartCreate); 106630de9b25SBarry Smith .ve 106730de9b25SBarry Smith 106830de9b25SBarry Smith Then, your partitioner can be chosen with the procedural interface via 106930de9b25SBarry Smith $ MatPartitioningSetType(part,"my_part") 107030de9b25SBarry Smith or at runtime via the option 107130de9b25SBarry Smith $ -mat_partitioning_type my_part 107230de9b25SBarry Smith 107330de9b25SBarry Smith $PETSC_ARCH and $BOPT occuring in pathname will be replaced with appropriate values. 107430de9b25SBarry Smith 107530de9b25SBarry Smith .keywords: matrix, partitioning, register 107630de9b25SBarry Smith 107730de9b25SBarry Smith .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll() 107830de9b25SBarry Smith M*/ 1079aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1080f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0) 10812aabb6bbSBarry Smith #else 1082f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d) 10832aabb6bbSBarry Smith #endif 10842aabb6bbSBarry Smith 1085dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningRegisterAll(const char[]); 10862bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled; 1087dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningRegisterDestroy(void); 10882bad1931SBarry Smith 1089dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningView(MatPartitioning,PetscViewer); 1090dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning); 1091dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning,MatPartitioningType*); 1092ca161407SBarry Smith 1093dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 10940752156aSBarry Smith 1095dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningJostleSetCoarseLevel(MatPartitioning,PetscReal); 1096dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningJostleSetCoarseSequential(MatPartitioning); 109771306c60Sjroman 109871306c60Sjroman typedef enum { MP_CHACO_MULTILEVEL_KL, MP_CHACO_SPECTRAL, MP_CHACO_LINEAR, 109971306c60Sjroman MP_CHACO_RANDOM, MP_CHACO_SCATTERED } MPChacoGlobalType; 1100dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType); 110171306c60Sjroman typedef enum { MP_CHACO_KERNIGHAN_LIN, MP_CHACO_NONE } MPChacoLocalType; 1102dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType); 1103dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal); 110471306c60Sjroman typedef enum { MP_CHACO_LANCZOS, MP_CHACO_RQI_SYMMLQ } MPChacoEigenType; 1105dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType); 1106dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal); 1107*c1ac3661SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt); 110871306c60Sjroman 110971306c60Sjroman #define MP_PARTY_OPT "opt" 111071306c60Sjroman #define MP_PARTY_LIN "lin" 111171306c60Sjroman #define MP_PARTY_SCA "sca" 111271306c60Sjroman #define MP_PARTY_RAN "ran" 111371306c60Sjroman #define MP_PARTY_GBF "gbf" 111471306c60Sjroman #define MP_PARTY_GCF "gcf" 111571306c60Sjroman #define MP_PARTY_BUB "bub" 111671306c60Sjroman #define MP_PARTY_DEF "def" 1117dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char*); 111871306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs" 111971306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl" 112071306c60Sjroman #define MP_PARTY_NONE "no" 1121dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char*); 1122dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal); 1123dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning,PetscTruth); 1124dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscTruth); 112571306c60Sjroman 112671306c60Sjroman typedef enum { MP_SCOTCH_GREEDY, MP_SCOTCH_GPS, MP_SCOTCH_GR_GPS } MPScotchGlobalType; 1127dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetArch(MatPartitioning,const char*); 1128dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetMultilevel(MatPartitioning); 1129dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetGlobal(MatPartitioning,MPScotchGlobalType); 1130dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetCoarseLevel(MatPartitioning,PetscReal); 1131dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetHostList(MatPartitioning,const char*); 113271306c60Sjroman typedef enum { MP_SCOTCH_KERNIGHAN_LIN, MP_SCOTCH_NONE } MPScotchLocalType; 1133dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetLocal(MatPartitioning,MPScotchLocalType); 1134dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetMapping(MatPartitioning); 1135dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetStrategy(MatPartitioning,char*); 113671306c60Sjroman 11370752156aSBarry Smith /* 11380a835dfdSSatish Balay If you add entries here you must also add them to finclude/petscmat.h 1139d4fbbf0eSBarry Smith */ 11401c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0, 11411c1c02c0SLois Curfman McInnes MATOP_GET_ROW=1, 11421c1c02c0SLois Curfman McInnes MATOP_RESTORE_ROW=2, 11431c1c02c0SLois Curfman McInnes MATOP_MULT=3, 11441c1c02c0SLois Curfman McInnes MATOP_MULT_ADD=4, 11457c922b88SBarry Smith MATOP_MULT_TRANSPOSE=5, 11467c922b88SBarry Smith MATOP_MULT_TRANSPOSE_ADD=6, 11471c1c02c0SLois Curfman McInnes MATOP_SOLVE=7, 11481c1c02c0SLois Curfman McInnes MATOP_SOLVE_ADD=8, 11497c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE=9, 11507c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE_ADD=10, 11511c1c02c0SLois Curfman McInnes MATOP_LUFACTOR=11, 11521c1c02c0SLois Curfman McInnes MATOP_CHOLESKYFACTOR=12, 11531c1c02c0SLois Curfman McInnes MATOP_RELAX=13, 11541c1c02c0SLois Curfman McInnes MATOP_TRANSPOSE=14, 11551c1c02c0SLois Curfman McInnes MATOP_GETINFO=15, 11561c1c02c0SLois Curfman McInnes MATOP_EQUAL=16, 11571c1c02c0SLois Curfman McInnes MATOP_GET_DIAGONAL=17, 11581c1c02c0SLois Curfman McInnes MATOP_DIAGONAL_SCALE=18, 11591c1c02c0SLois Curfman McInnes MATOP_NORM=19, 11601c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_BEGIN=20, 11611c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_END=21, 11621c1c02c0SLois Curfman McInnes MATOP_COMPRESS=22, 11631c1c02c0SLois Curfman McInnes MATOP_SET_OPTION=23, 11641c1c02c0SLois Curfman McInnes MATOP_ZERO_ENTRIES=24, 11651c1c02c0SLois Curfman McInnes MATOP_ZERO_ROWS=25, 11661c1c02c0SLois Curfman McInnes MATOP_LUFACTOR_SYMBOLIC=26, 11671c1c02c0SLois Curfman McInnes MATOP_LUFACTOR_NUMERIC=27, 11681c1c02c0SLois Curfman McInnes MATOP_CHOLESKY_FACTOR_SYMBOLIC=28, 11691c1c02c0SLois Curfman McInnes MATOP_CHOLESKY_FACTOR_NUMERIC=29, 1170d643ce63SMatthew Knepley MATOP_SETUP_PREALLOCATION=30, 1171d643ce63SMatthew Knepley MATOP_ILUFACTOR_SYMBOLIC=31, 1172d643ce63SMatthew Knepley MATOP_ICCFACTOR_SYMBOLIC=32, 1173d643ce63SMatthew Knepley MATOP_GET_ARRAY=33, 1174d643ce63SMatthew Knepley MATOP_RESTORE_ARRAY=34, 1175d643ce63SMatthew Knepley MATOP_DUPLCIATE=35, 1176d643ce63SMatthew Knepley MATOP_FORWARD_SOLVE=36, 1177d643ce63SMatthew Knepley MATOP_BACKWARD_SOLVE=37, 1178d643ce63SMatthew Knepley MATOP_ILUFACTOR=38, 1179d643ce63SMatthew Knepley MATOP_ICCFACTOR=39, 1180d643ce63SMatthew Knepley MATOP_AXPY=40, 1181d643ce63SMatthew Knepley MATOP_GET_SUBMATRICES=41, 1182d643ce63SMatthew Knepley MATOP_INCREASE_OVERLAP=42, 1183d643ce63SMatthew Knepley MATOP_GET_VALUES=43, 1184d643ce63SMatthew Knepley MATOP_COPY=44, 1185d643ce63SMatthew Knepley MATOP_PRINT_HELP=45, 1186d643ce63SMatthew Knepley MATOP_SCALE=46, 1187d643ce63SMatthew Knepley MATOP_SHIFT=47, 1188d643ce63SMatthew Knepley MATOP_DIAGONAL_SHIFT=48, 1189d643ce63SMatthew Knepley MATOP_ILUDT_FACTOR=49, 1190d643ce63SMatthew Knepley MATOP_GET_BLOCK_SIZE=50, 1191d643ce63SMatthew Knepley MATOP_GET_ROW_IJ=51, 1192d643ce63SMatthew Knepley MATOP_RESTORE_ROW_IJ=52, 1193d643ce63SMatthew Knepley MATOP_GET_COLUMN_IJ=53, 1194d643ce63SMatthew Knepley MATOP_RESTORE_COLUMN_IJ=54, 1195d643ce63SMatthew Knepley MATOP_FDCOLORING_CREATE=55, 1196d643ce63SMatthew Knepley MATOP_COLORING_PATCH=56, 1197d643ce63SMatthew Knepley MATOP_SET_UNFACTORED=57, 1198d643ce63SMatthew Knepley MATOP_PERMUTE=58, 1199d643ce63SMatthew Knepley MATOP_SET_VALUES_BLOCKED=59, 1200d643ce63SMatthew Knepley MATOP_GET_SUBMATRIX=60, 1201d643ce63SMatthew Knepley MATOP_DESTROY=61, 1202d643ce63SMatthew Knepley MATOP_VIEW=62, 1203d643ce63SMatthew Knepley MATOP_GET_MAPS=63, 1204d643ce63SMatthew Knepley MATOP_USE_SCALED_FORM=64, 1205d643ce63SMatthew Knepley MATOP_SCALE_SYSTEM=65, 1206d643ce63SMatthew Knepley MATOP_UNSCALE_SYSTEM=66, 1207ba16a8cbSKris Buschelman MATOP_SET_LOCAL_TO_GLOBAL_MAP=67, 1208d643ce63SMatthew Knepley MATOP_SET_VALUES_LOCAL=68, 1209d643ce63SMatthew Knepley MATOP_ZERO_ROWS_LOCAL=69, 1210d643ce63SMatthew Knepley MATOP_GET_ROW_MAX=70, 1211d643ce63SMatthew Knepley MATOP_CONVERT=71, 1212d643ce63SMatthew Knepley MATOP_SET_COLORING=72, 1213d643ce63SMatthew Knepley MATOP_SET_VALUES_ADIC=73, 1214d643ce63SMatthew Knepley MATOP_SET_VALUES_ADIFOR=74, 1215d643ce63SMatthew Knepley MATOP_FD_COLORING_APPLY=75, 1216d643ce63SMatthew Knepley MATOP_SET_FROM_OPTIONS=76, 1217ba16a8cbSKris Buschelman MATOP_MULT_CON=77, 1218ba16a8cbSKris Buschelman MATOP_MULT_TRANSPOSE_CON=78, 1219ba16a8cbSKris Buschelman MATOP_ILU_FACTOR_SYMBOLIC_CON=79, 1220d643ce63SMatthew Knepley MATOP_PERMUTE_SPARSIFY=80, 1221d643ce63SMatthew Knepley MATOP_MULT_MULTIPLE=81, 122241acf15aSKris Buschelman MATOP_SOLVE_MULTIPLE=82, 122341acf15aSKris Buschelman MATOP_GET_INERTIA=83, 122441acf15aSKris Buschelman MATOP_LOAD=84, 122541acf15aSKris Buschelman MATOP_IS_SYMMETRIC=85, 122641acf15aSKris Buschelman MATOP_IS_HERMITIAN=86, 122741acf15aSKris Buschelman MATOP_IS_STRUCTURALLY_SYMMETRIC=87, 122841acf15aSKris Buschelman MATOP_PB_RELAX=88, 122941acf15aSKris Buschelman MATOP_GET_VECS=89, 123041acf15aSKris Buschelman MATOP_MAT_MULT=90, 123141acf15aSKris Buschelman MATOP_MAT_MULT_SYMBOLIC=91, 123241acf15aSKris Buschelman MATOP_MAT_MULT_NUMERIC=92, 123341acf15aSKris Buschelman MATOP_PTAP=93, 123441acf15aSKris Buschelman MATOP_PTAP_SYMBOLIC=94, 1235bc011b1eSHong Zhang MATOP_PTAP_NUMERIC=95, 1236bc011b1eSHong Zhang MATOP_MAT_MULTTRANSPOSE=96, 1237bc011b1eSHong Zhang MATOP_MAT_MULTTRANSPOSE_SYMBOLIC=97, 12388aeee837SMatthew Knepley MATOP_MAT_MULTTRANSPOSE_NUMERIC=98 1239fae171e0SBarry Smith } MatOperation; 1240dfbe8321SBarry Smith EXTERN PetscErrorCode MatHasOperation(Mat,MatOperation,PetscTruth*); 1241dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellSetOperation(Mat,MatOperation,void(*)(void)); 1242dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellGetOperation(Mat,MatOperation,void(**)(void)); 1243dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellSetContext(Mat,void*); 1244112a2221SBarry Smith 124590ace30eSBarry Smith /* 124690ace30eSBarry Smith Codes for matrices stored on disk. By default they are 124790ace30eSBarry Smith stored in a universal format. By changing the format with 1248fb9695e5SSatish Balay PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will 124990ace30eSBarry Smith be stored in a way natural for the matrix, for example dense matrices 125090ace30eSBarry Smith would be stored as dense. Matrices stored this way may only be 125190ace30eSBarry Smith read into matrices of the same time. 125290ace30eSBarry Smith */ 125390ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1 125490ace30eSBarry Smith 1255dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat,PetscReal); 1256*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqAIJGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *); 1257dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIRowbsGetColor(Mat,ISColoring *); 1258860d1616SSatish Balay 1259dfbe8321SBarry Smith EXTERN PetscErrorCode MatISGetLocalMat(Mat,Mat*); 12601f4e1ec7SBarry Smith 1261d9274352SBarry Smith /*S 1262d9274352SBarry Smith MatNullSpace - Object that removes a null space from a vector, i.e. 1263d9274352SBarry Smith orthogonalizes the vector to a subsapce 1264d9274352SBarry Smith 1265f7a9e4ceSBarry Smith Level: advanced 1266d9274352SBarry Smith 1267d9274352SBarry Smith Concepts: matrix; linear operator, null space 1268d9274352SBarry Smith 12696e1639daSBarry Smith Users manual sections: 12706e1639daSBarry Smith . sec_singular 12716e1639daSBarry Smith 1272d9274352SBarry Smith .seealso: MatNullSpaceCreate() 1273d9274352SBarry Smith S*/ 127474637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace; 1275d9274352SBarry Smith 1276*c1ac3661SBarry Smith EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm,PetscTruth,PetscInt,const Vec[],MatNullSpace*); 1277dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace); 1278dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace,Vec,Vec*); 1279dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceAttach(Mat,MatNullSpace); 1280dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace,Mat); 128174637425SBarry Smith 1282dfbe8321SBarry Smith EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat,IS); 1283dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat,PetscReal); 1284*c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat,PetscInt *); 1285273d9f13SBarry Smith 12863f1d51d7SBarry Smith 1287*c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMAIJ(Mat,PetscInt,Mat*); 1288*c1ac3661SBarry Smith EXTERN PetscErrorCode MatMAIJRedimension(Mat,PetscInt,Mat*); 1289dfbe8321SBarry Smith EXTERN PetscErrorCode MatMAIJGetAIJ(Mat,Mat*); 1290c4f061fbSSatish Balay 1291dfbe8321SBarry Smith EXTERN PetscErrorCode MatComputeExplicitOperator(Mat,Mat*); 1292b0a32e0cSBarry Smith 1293dfbe8321SBarry Smith EXTERN PetscErrorCode MatESISetType(Mat,const char*); 1294dfbe8321SBarry Smith EXTERN PetscErrorCode MatESISetFromOptions(Mat); 129524a595ddSBarry Smith 1296dfbe8321SBarry Smith EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat,Vec); 129704f1ad80SBarry Smith 1298*c1ac3661SBarry Smith EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *); 1299*c1ac3661SBarry Smith EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *); 13007dbadf16SMatthew Knepley 1301e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 13022eac72dbSBarry Smith #endif 1303