xref: /petsc/include/petscmat.h (revision 5bc6e7ccb8611ef2bf8e0c2cd29b0b9d7dfdb253)
173f4d377SMatthew Knepley /* $Id: petscmat.h,v 1.228 2001/09/07 20:09:08 bsmith Exp $ */
22eac72dbSBarry Smith /*
32eac72dbSBarry Smith      Include file for the matrix component of PETSc
42eac72dbSBarry Smith */
50a835dfdSSatish Balay #ifndef __PETSCMAT_H
60a835dfdSSatish Balay #define __PETSCMAT_H
70a835dfdSSatish Balay #include "petscvec.h"
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"
32273d9f13SBarry Smith #define MATIS       "is"
33273d9f13SBarry Smith #define MATMPIROWBS "mpirowbs"
34273d9f13SBarry Smith #define MATSEQDENSE "seqdense"
35273d9f13SBarry Smith #define MATSEQAIJ   "seqaij"
36273d9f13SBarry Smith #define MATMPIAIJ   "mpiaij"
37273d9f13SBarry Smith #define MATSHELL    "shell"
38273d9f13SBarry Smith #define MATSEQBDIAG "seqbdiag"
39273d9f13SBarry Smith #define MATMPIBDIAG "mpibdiag"
40273d9f13SBarry Smith #define MATMPIDENSE "mpidense"
41273d9f13SBarry Smith #define MATSEQBAIJ  "seqbaij"
42273d9f13SBarry Smith #define MATMPIBAIJ  "mpibaij"
43273d9f13SBarry Smith #define MATMPIADJ   "mpiadj"
44273d9f13SBarry Smith #define MATSEQSBAIJ "seqsbaij"
45273d9f13SBarry Smith #define MATMPISBAIJ "mpisbaij"
46cebc7f6cSBarry Smith #define MATDAAD     "daad"
47cebc7f6cSBarry Smith #define MATMFFD     "mffd"
486d88219bSBarry Smith #define MATESI      "esi"
496d88219bSBarry Smith #define MATPETSCESI "petscesi"
50c8a8475eSBarry Smith #define MATNORMAL   "normal"
51273d9f13SBarry Smith typedef char* MatType;
52d91e6319SBarry Smith 
53c06d978dSMatthew Knepley #define MAT_SER_SEQAIJ_BINARY "seqaij_binary"
54c06d978dSMatthew Knepley #define MAT_SER_MPIAIJ_BINARY "mpiaij_binary"
55c06d978dSMatthew Knepley typedef char *MatSerializeType;
56c06d978dSMatthew Knepley 
57c06d978dSMatthew Knepley /* Logging support */
58552e946dSBarry Smith #define    MAT_FILE_COOKIE 1211216    /* used to indicate matrices in binary files */
59c06d978dSMatthew Knepley extern int MAT_COOKIE;
6071d41ebeSBarry Smith extern int MATSNESMFCTX_COOKIE;
61c06d978dSMatthew Knepley extern int MAT_FDCOLORING_COOKIE;
628ba1e511SMatthew Knepley extern int MAT_PARTITIONING_COOKIE;
638ba1e511SMatthew Knepley extern int MAT_NULLSPACE_COOKIE;
64d59c15a7SBarry Smith extern int MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose;
65d59c15a7SBarry Smith extern int MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose;
66d5ba7fb7SMatthew Knepley extern int MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic;
67d5ba7fb7SMatthew Knepley extern int MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor;
68d5ba7fb7SMatthew Knepley extern int MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin;
69d5ba7fb7SMatthew Knepley extern int MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering;
70d5ba7fb7SMatthew Knepley extern int MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate;
7166f9b7ceSBarry Smith extern int MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction;
72c06d978dSMatthew Knepley 
738ba1e511SMatthew Knepley EXTERN int MatInitializePackage(char *);
74c06d978dSMatthew Knepley 
75273d9f13SBarry Smith EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*);
76273d9f13SBarry Smith EXTERN int MatSetType(Mat,MatType);
77273d9f13SBarry Smith EXTERN int MatSetFromOptions(Mat);
78273d9f13SBarry Smith EXTERN int MatSetUpPreallocation(Mat);
79273d9f13SBarry Smith EXTERN int MatRegisterAll(char*);
80273d9f13SBarry Smith EXTERN int MatRegister(char*,char*,char*,int(*)(Mat));
81c06d978dSMatthew Knepley EXTERN int MatSerializeRegister(const char [], const char [], const char [], int (*)(MPI_Comm, Mat *, PetscViewer, PetscTruth));
82273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
83273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0)
84c06d978dSMatthew Knepley #define MatSerializeRegisterDynamic(a,b,c,d) MatSerializeRegister(a,b,c,0)
85273d9f13SBarry Smith #else
86273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d)
87c06d978dSMatthew Knepley #define MatSerializeRegisterDynamic(a,b,c,d) MatSerializeRegister(a,b,c,d)
88273d9f13SBarry Smith #endif
89273d9f13SBarry Smith extern PetscTruth MatRegisterAllCalled;
90b0a32e0cSBarry Smith extern PetscFList MatList;
9128988994SBarry Smith 
92c06d978dSMatthew Knepley EXTERN PetscFList MatSerializeList;
93c06d978dSMatthew Knepley EXTERN int MatSerializeRegisterAll(const char []);
9465804fbbSSatish Balay EXTERN int MatSerializeRegisterDestroy(void);
95c06d978dSMatthew Knepley EXTERN int MatSerializeRegisterAllCalled;
96c06d978dSMatthew Knepley EXTERN int MatSerialize(MPI_Comm, Mat *, PetscViewer, PetscTruth);
97c06d978dSMatthew Knepley EXTERN int MatSetSerializeType(Mat, MatSerializeType);
98c06d978dSMatthew Knepley 
9987828ca2SBarry Smith EXTERN int MatCreateSeqDense(MPI_Comm,int,int,PetscScalar*,Mat*);
10087828ca2SBarry Smith EXTERN int MatCreateMPIDense(MPI_Comm,int,int,int,int,PetscScalar*,Mat*);
101ca44d042SBarry Smith EXTERN int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*);
102ca44d042SBarry Smith EXTERN int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
103c4f061fbSSatish Balay EXTERN int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,Mat*);
10487828ca2SBarry Smith EXTERN int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,PetscScalar**,Mat*);
10587828ca2SBarry Smith EXTERN int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,PetscScalar**,Mat*);
106ca44d042SBarry Smith EXTERN int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
107ca44d042SBarry Smith EXTERN int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*);
108ca44d042SBarry Smith EXTERN int MatCreateMPIAdj(MPI_Comm,int,int,int*,int*,int *,Mat*);
109ca44d042SBarry Smith EXTERN int MatCreateSeqSBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
110ca44d042SBarry Smith EXTERN int MatCreateMPISBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*);
111ca44d042SBarry Smith EXTERN int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*);
1123a7fca6bSBarry Smith EXTERN int MatCreateAdic(MPI_Comm,int,int,int,int,int,void (*)(void),Mat*);
113c8a8475eSBarry Smith EXTERN int MatCreateNormal(Mat,Mat*);
114435da068SBarry Smith EXTERN int MatDestroy(Mat);
11521c89e3eSBarry Smith 
116ca44d042SBarry Smith EXTERN int MatPrintHelp(Mat);
1178a124369SBarry Smith EXTERN int MatGetPetscMaps(Mat,PetscMap*,PetscMap*);
118ec0117caSBarry Smith 
1198ed539a5SBarry Smith /* ------------------------------------------------------------*/
12087828ca2SBarry Smith EXTERN int MatSetValues(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
12187828ca2SBarry Smith EXTERN int MatSetValuesBlocked(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
12284cb2905SBarry Smith 
1232ef4de8bSBarry Smith /*S
1242ef4de8bSBarry Smith      MatStencil - Data structure (C struct) for storing information about a single row or
1252ef4de8bSBarry Smith         column of a matrix as index on an associated grid.
1262ef4de8bSBarry Smith 
1272ef4de8bSBarry Smith    Level: beginner
1282ef4de8bSBarry Smith 
1292ef4de8bSBarry Smith   Concepts: matrix; linear operator
1302ef4de8bSBarry Smith 
1312ef4de8bSBarry Smith .seealso:  MatSetValuesStencil(), MatSetStencil()
1322ef4de8bSBarry Smith S*/
133435da068SBarry Smith typedef struct {
134435da068SBarry Smith   int k,j,i,c;
135435da068SBarry Smith } MatStencil;
1362ef4de8bSBarry Smith 
13787828ca2SBarry Smith EXTERN int MatSetValuesStencil(Mat,int,MatStencil*,int,MatStencil*,PetscScalar*,InsertMode);
13887828ca2SBarry Smith EXTERN int MatSetValuesBlockedStencil(Mat,int,MatStencil*,int,MatStencil*,PetscScalar*,InsertMode);
139435da068SBarry Smith EXTERN int MatSetStencil(Mat,int,int*,int*,int);
140435da068SBarry Smith 
1413a7fca6bSBarry Smith EXTERN int MatSetColoring(Mat,ISColoring);
1423a7fca6bSBarry Smith EXTERN int MatSetValuesAdic(Mat,void*);
1433a7fca6bSBarry Smith EXTERN int MatSetValuesAdifor(Mat,int,void*);
1443a7fca6bSBarry Smith 
145d91e6319SBarry Smith /*E
146d91e6319SBarry Smith     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
147d91e6319SBarry Smith      to continue to add values to it
148d91e6319SBarry Smith 
149d91e6319SBarry Smith     Level: beginner
150d91e6319SBarry Smith 
151d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd()
152d91e6319SBarry Smith E*/
1536d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
154ca44d042SBarry Smith EXTERN int MatAssemblyBegin(Mat,MatAssemblyType);
155ca44d042SBarry Smith EXTERN int MatAssemblyEnd(Mat,MatAssemblyType);
156ca44d042SBarry Smith EXTERN int MatAssembled(Mat,PetscTruth*);
1574f9c727eSBarry Smith 
158b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \
159ea709b57SSatish Balay 0; {int _ierr,_row = i,_col = j; PetscScalar _va = va; \
160b951964fSBarry Smith   _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
161b951964fSBarry Smith }
162ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \
163d91e6319SBarry Smith 0; {int _ierr,_row = i,_col = j; \
164ea06a074SBarry Smith   _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \
165ea06a074SBarry Smith }
166d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \
167ea709b57SSatish Balay 0; {int _ierr,_row = i,_col = j; PetscScalar _va = va; \
168d91e6319SBarry Smith   _ierr = MatSetValuesLocal(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
169d91e6319SBarry Smith }
170d91e6319SBarry Smith /*E
171d91e6319SBarry Smith     MatOption - Options that may be set for a matrix and its behavior or storage
172d91e6319SBarry Smith 
173d91e6319SBarry Smith     Level: beginner
174d91e6319SBarry Smith 
1750a835dfdSSatish Balay    Any additions/changes here MUST also be made in include/finclude/petscmat.h
176d91e6319SBarry Smith 
177d91e6319SBarry Smith .seealso: MatSetOption()
178d91e6319SBarry Smith E*/
1796d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
1806d4a8577SBarry Smith               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
1816d4a8577SBarry Smith               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
1826ca9ecd3SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
1836ca9ecd3SBarry Smith               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
1846ca9ecd3SBarry Smith               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
1856ca9ecd3SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
1864787f768SSatish Balay               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
1877c922b88SBarry Smith               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78,
1882bad1931SBarry Smith               MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81,
189123145dfSKris Buschelman               MAT_DO_NOT_USE_INODES=82} MatOption;
190ca44d042SBarry Smith EXTERN int MatSetOption(Mat,MatOption);
191273d9f13SBarry Smith EXTERN int MatGetType(Mat,MatType*);
19284cb2905SBarry Smith 
19387828ca2SBarry Smith EXTERN int MatGetValues(Mat,int,int*,int,int*,PetscScalar*);
19487828ca2SBarry Smith EXTERN int MatGetRow(Mat,int,int *,int **,PetscScalar**);
19587828ca2SBarry Smith EXTERN int MatRestoreRow(Mat,int,int *,int **,PetscScalar**);
19687828ca2SBarry Smith EXTERN int MatGetColumn(Mat,int,int *,int **,PetscScalar**);
19787828ca2SBarry Smith EXTERN int MatRestoreColumn(Mat,int,int *,int **,PetscScalar**);
198ca44d042SBarry Smith EXTERN int MatGetColumnVector(Mat,Vec,int);
19987828ca2SBarry Smith EXTERN int MatGetArray(Mat,PetscScalar **);
20087828ca2SBarry Smith EXTERN int MatRestoreArray(Mat,PetscScalar **);
201ca44d042SBarry Smith EXTERN int MatGetBlockSize(Mat,int *);
2027b80b807SBarry Smith 
203ca44d042SBarry Smith EXTERN int MatMult(Mat,Vec,Vec);
204ca44d042SBarry Smith EXTERN int MatMultAdd(Mat,Vec,Vec,Vec);
205ca44d042SBarry Smith EXTERN int MatMultTranspose(Mat,Vec,Vec);
206cd0d46ebSvictorle EXTERN int MatIsSymmetric(Mat,Mat,PetscTruth*);
207ca44d042SBarry Smith EXTERN int MatMultTransposeAdd(Mat,Vec,Vec,Vec);
208c06d978dSMatthew Knepley EXTERN int MatMultConstrained(Mat,Vec,Vec);
2096d0dc95fSMatthew Knepley EXTERN int MatMultTransposeConstrained(Mat,Vec,Vec);
2102eac72dbSBarry Smith 
211d91e6319SBarry Smith /*E
212d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
213d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
214d91e6319SBarry Smith 
215d91e6319SBarry Smith     Level: beginner
216d91e6319SBarry Smith 
217d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
218d91e6319SBarry Smith 
219d91e6319SBarry Smith .seealso: MatDuplicate()
220d91e6319SBarry Smith E*/
2212e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;
2222e8a6d31SBarry Smith 
223273d9f13SBarry Smith EXTERN int MatConvertRegister(char*,char*,char*,int (*)(Mat,MatType,Mat*));
224273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
225273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0)
226273d9f13SBarry Smith #else
227273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d)
228273d9f13SBarry Smith #endif
229273d9f13SBarry Smith EXTERN int        MatConvertRegisterAll(char*);
230273d9f13SBarry Smith EXTERN int        MatConvertRegisterDestroy(void);
231273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled;
232b0a32e0cSBarry Smith extern PetscFList MatConvertList;
233ca44d042SBarry Smith EXTERN int        MatConvert(Mat,MatType,Mat*);
234ca44d042SBarry Smith EXTERN int        MatDuplicate(Mat,MatDuplicateOption,Mat*);
23594a9d846SBarry Smith 
236d91e6319SBarry Smith /*E
237d91e6319SBarry Smith     MatStructure - Indicates if the matrix has the same nonzero structure
238d91e6319SBarry Smith 
239d91e6319SBarry Smith     Level: beginner
240d91e6319SBarry Smith 
241d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
242d91e6319SBarry Smith 
243d91e6319SBarry Smith .seealso: MatCopy(), SLESSetOperators(), PCSetOperators()
244d91e6319SBarry Smith E*/
245c537a176SHong Zhang typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure;
246cb5b572fSBarry Smith 
247ca44d042SBarry Smith EXTERN int MatCopy(Mat,Mat,MatStructure);
248b0a32e0cSBarry Smith EXTERN int MatView(Mat,PetscViewer);
249273d9f13SBarry Smith 
250b0a32e0cSBarry Smith EXTERN int MatLoadRegister(char*,char*,char*,int (*)(PetscViewer,MatType,Mat*));
251273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
252273d9f13SBarry Smith #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,0)
253273d9f13SBarry Smith #else
254273d9f13SBarry Smith #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,d)
255273d9f13SBarry Smith #endif
256273d9f13SBarry Smith EXTERN int        MatLoadRegisterAll(char*);
257273d9f13SBarry Smith EXTERN int        MatLoadRegisterDestroy(void);
258273d9f13SBarry Smith extern PetscTruth MatLoadRegisterAllCalled;
259b0a32e0cSBarry Smith extern PetscFList MatLoadList;
260b0a32e0cSBarry Smith EXTERN int        MatLoad(PetscViewer,MatType,Mat*);
26151dd7536SBarry Smith EXTERN int        MatMerge(MPI_Comm,Mat,Mat*);
2627b80b807SBarry Smith 
263ca44d042SBarry Smith EXTERN int MatGetRowIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
264ca44d042SBarry Smith EXTERN int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
265ca44d042SBarry Smith EXTERN int MatGetColumnIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
266ca44d042SBarry Smith EXTERN int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
267d4fbbf0eSBarry Smith 
268d91e6319SBarry Smith /*S
269d91e6319SBarry Smith      MatInfo - Context of matrix information, used with MatGetInfo()
270d91e6319SBarry Smith 
271d91e6319SBarry Smith    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
272d91e6319SBarry Smith 
273d91e6319SBarry Smith    Level: intermediate
274d91e6319SBarry Smith 
275d91e6319SBarry Smith   Concepts: matrix^nonzero information
276d91e6319SBarry Smith 
277d9274352SBarry Smith .seealso:  MatGetInfo(), MatInfoType
278d91e6319SBarry Smith S*/
2794e220ebcSLois Curfman McInnes typedef struct {
280b0a32e0cSBarry Smith   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
281b0a32e0cSBarry Smith   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
282b0a32e0cSBarry Smith   PetscLogDouble block_size;                         /* block size */
283b0a32e0cSBarry Smith   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
284b0a32e0cSBarry Smith   PetscLogDouble memory;                             /* memory allocated */
285b0a32e0cSBarry Smith   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
286b0a32e0cSBarry Smith   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
287b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
288b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
2894e220ebcSLois Curfman McInnes } MatInfo;
2904e220ebcSLois Curfman McInnes 
291d9274352SBarry Smith /*E
292d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
293d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
294d9274352SBarry Smith 
295d9274352SBarry Smith     Level: beginner
296d9274352SBarry Smith 
297d9274352SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
298d9274352SBarry Smith 
299d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo
300d9274352SBarry Smith E*/
3017b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
302ca44d042SBarry Smith EXTERN int MatGetInfo(Mat,MatInfoType,MatInfo*);
303ca44d042SBarry Smith EXTERN int MatValid(Mat,PetscTruth*);
304ca44d042SBarry Smith EXTERN int MatGetDiagonal(Mat,Vec);
305273d9f13SBarry Smith EXTERN int MatGetRowMax(Mat,Vec);
306ca44d042SBarry Smith EXTERN int MatTranspose(Mat,Mat*);
307ca44d042SBarry Smith EXTERN int MatPermute(Mat,IS,IS,Mat *);
308bf1d55d4SSatish Balay EXTERN int MatPermuteSparsify(Mat,int,PetscReal,PetscReal,IS,IS,Mat *);
309ca44d042SBarry Smith EXTERN int MatDiagonalScale(Mat,Vec,Vec);
31006ef90c2SBarry Smith EXTERN int MatDiagonalSet(Mat,Vec,InsertMode);
311ca44d042SBarry Smith EXTERN int MatEqual(Mat,Mat,PetscTruth*);
3127b80b807SBarry Smith 
31387828ca2SBarry Smith EXTERN int MatNorm(Mat,NormType,PetscReal *);
314ca44d042SBarry Smith EXTERN int MatZeroEntries(Mat);
31587828ca2SBarry Smith EXTERN int MatZeroRows(Mat,IS,PetscScalar*);
31687828ca2SBarry Smith EXTERN int MatZeroColumns(Mat,IS,PetscScalar*);
3177b80b807SBarry Smith 
318ca44d042SBarry Smith EXTERN int MatUseScaledForm(Mat,PetscTruth);
319ca44d042SBarry Smith EXTERN int MatScaleSystem(Mat,Vec,Vec);
320ca44d042SBarry Smith EXTERN int MatUnScaleSystem(Mat,Vec,Vec);
3215ef9f2a5SBarry Smith 
322ca44d042SBarry Smith EXTERN int MatGetSize(Mat,int*,int*);
323ca44d042SBarry Smith EXTERN int MatGetLocalSize(Mat,int*,int*);
324ca44d042SBarry Smith EXTERN int MatGetOwnershipRange(Mat,int*,int*);
3257b80b807SBarry Smith 
326d91e6319SBarry Smith /*E
327d91e6319SBarry Smith     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
328d91e6319SBarry Smith      or MatGetSubMatrix() are to be reused to store the new matrix values.
329d91e6319SBarry Smith 
330d91e6319SBarry Smith     Level: beginner
331d91e6319SBarry Smith 
332d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
333d91e6319SBarry Smith 
334d91e6319SBarry Smith .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices()
335d91e6319SBarry Smith E*/
3367b2a1423SBarry Smith typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;
337ca44d042SBarry Smith EXTERN int MatGetSubMatrices(Mat,int,IS *,IS *,MatReuse,Mat **);
338ca44d042SBarry Smith EXTERN int MatDestroyMatrices(int,Mat **);
339ca44d042SBarry Smith EXTERN int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *);
3408efafbd8SBarry Smith 
341ca44d042SBarry Smith EXTERN int MatIncreaseOverlap(Mat,int,IS *,int);
3427b80b807SBarry Smith 
343607cd303SBarry Smith EXTERN int MatAXPY(PetscScalar *,Mat,Mat,MatStructure);
34487828ca2SBarry Smith EXTERN int MatAYPX(PetscScalar *,Mat,Mat);
345ca44d042SBarry Smith EXTERN int MatCompress(Mat);
3467b80b807SBarry Smith 
34787828ca2SBarry Smith EXTERN int MatScale(PetscScalar *,Mat);
34887828ca2SBarry Smith EXTERN int MatShift(PetscScalar *,Mat);
349052efed2SBarry Smith 
350ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
351ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
35287828ca2SBarry Smith EXTERN int MatZeroRowsLocal(Mat,IS,PetscScalar*);
35387828ca2SBarry Smith EXTERN int MatSetValuesLocal(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
35487828ca2SBarry Smith EXTERN int MatSetValuesBlockedLocal(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
35590f02eecSBarry Smith 
356ca44d042SBarry Smith EXTERN int MatSetStashInitialSize(Mat,int,int);
357649db694SBarry Smith 
358ca44d042SBarry Smith EXTERN int MatInterpolateAdd(Mat,Vec,Vec,Vec);
359ca44d042SBarry Smith EXTERN int MatInterpolate(Mat,Vec,Vec);
360ca44d042SBarry Smith EXTERN int MatRestrict(Mat,Vec,Vec);
3617c922b88SBarry Smith 
362bd481603SBarry Smith 
363bd481603SBarry Smith /*MC
364bd481603SBarry Smith    MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per
365bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
366bd481603SBarry Smith 
367bd481603SBarry Smith    Synopsis:
368bd481603SBarry Smith    int MatPreallocateInitialize(MPI_Comm comm, int nrows, int ncols, int *dnz, int *onz)
369bd481603SBarry Smith 
370bd481603SBarry Smith    Collective on MPI_Comm
371bd481603SBarry Smith 
372bd481603SBarry Smith    Input Parameters:
373bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
374bd481603SBarry Smith .  nrows - the number of rows in the matrix
375bd481603SBarry Smith -  ncols - the number of columns in the matrix
376bd481603SBarry Smith 
377bd481603SBarry Smith    Output Parameters:
378bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
379bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
380bd481603SBarry Smith 
381bd481603SBarry Smith 
382bd481603SBarry Smith    Level: intermediate
383bd481603SBarry Smith 
384bd481603SBarry Smith    Notes:
385bd481603SBarry Smith    See the chapter in the users manual on performance for more details
386bd481603SBarry Smith 
387bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
388bd481603SBarry Smith 
389bd481603SBarry Smith    Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices)
390bd481603SBarry Smith 
391bd481603SBarry Smith   Concepts: preallocation^Matrix
392bd481603SBarry Smith 
393bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
394bd481603SBarry Smith           MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal()
395bd481603SBarry Smith M*/
396c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
3977c922b88SBarry Smith { \
398ef66eb69SBarry Smith   int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
399ef66eb69SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
400ef66eb69SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\
401ef66eb69SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\
402ef66eb69SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
4037c922b88SBarry Smith 
404bd481603SBarry Smith /*MC
405bd481603SBarry Smith    MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per
406bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
407bd481603SBarry Smith 
408bd481603SBarry Smith    Synopsis:
409bd481603SBarry Smith    int MatPreallocateSymmetricInitialize(MPI_Comm comm, int nrows, int ncols, int *dnz, int *onz)
410bd481603SBarry Smith 
411bd481603SBarry Smith    Collective on MPI_Comm
412bd481603SBarry Smith 
413bd481603SBarry Smith    Input Parameters:
414bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
415bd481603SBarry Smith .  nrows - the number of rows in the matrix
416bd481603SBarry Smith -  ncols - the number of columns in the matrix
417bd481603SBarry Smith 
418bd481603SBarry Smith    Output Parameters:
419bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
420bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
421bd481603SBarry Smith 
422bd481603SBarry Smith 
423bd481603SBarry Smith    Level: intermediate
424bd481603SBarry Smith 
425bd481603SBarry Smith    Notes:
426bd481603SBarry Smith    See the chapter in the users manual on performance for more details
427bd481603SBarry Smith 
428bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
429bd481603SBarry Smith 
430bd481603SBarry Smith   Concepts: preallocation^Matrix
431bd481603SBarry Smith 
432bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
433bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
434bd481603SBarry Smith M*/
435222b16d4SBarry Smith #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \
436222b16d4SBarry Smith { \
437222b16d4SBarry Smith   int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__end; \
438222b16d4SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
439222b16d4SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\
440222b16d4SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\
441222b16d4SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
442222b16d4SBarry Smith 
443bd481603SBarry Smith /*MC
444bd481603SBarry Smith    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
445bd481603SBarry Smith        inserted using a local number of the rows and columns
446bd481603SBarry Smith 
447bd481603SBarry Smith    Synopsis:
448bd481603SBarry Smith    int MatPreallocateSetLocal(ISLocalToGlobalMappping map,int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
449bd481603SBarry Smith 
450bd481603SBarry Smith    Not Collective
451bd481603SBarry Smith 
452bd481603SBarry Smith    Input Parameters:
453bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
454bd481603SBarry Smith .  nrows - the number of rows indicated
455bd481603SBarry Smith .  rows - the indices of the rows (these will be mapped in the
456bd481603SBarry Smith .  ncols - the number of columns in the matrix
457bd481603SBarry Smith .  cols - the columns indicated
458bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
459bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
460bd481603SBarry Smith 
461bd481603SBarry Smith 
462bd481603SBarry Smith    Level: intermediate
463bd481603SBarry Smith 
464bd481603SBarry Smith    Notes:
465bd481603SBarry Smith    See the chapter in the users manual on performance for more details
466bd481603SBarry Smith 
467bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
468bd481603SBarry Smith 
469bd481603SBarry Smith   Concepts: preallocation^Matrix
470bd481603SBarry Smith 
471bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
472bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
473bd481603SBarry Smith M*/
474c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
475c4f061fbSSatish Balay {\
476c4f061fbSSatish Balay   int __l;\
477ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
478ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
479c4f061fbSSatish Balay   for (__l=0;__l<nrows;__l++) {\
480ef66eb69SBarry Smith     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
481c4f061fbSSatish Balay   }\
482c4f061fbSSatish Balay }
483c4f061fbSSatish Balay 
484bd481603SBarry Smith /*MC
485bd481603SBarry Smith    MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
486bd481603SBarry Smith        inserted using a local number of the rows and columns
487bd481603SBarry Smith 
488bd481603SBarry Smith    Synopsis:
489bd481603SBarry Smith    int MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
490bd481603SBarry Smith 
491bd481603SBarry Smith    Not Collective
492bd481603SBarry Smith 
493bd481603SBarry Smith    Input Parameters:
494bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
495bd481603SBarry Smith .  nrows - the number of rows indicated
496bd481603SBarry Smith .  rows - the indices of the rows (these will be mapped in the
497bd481603SBarry Smith .  ncols - the number of columns in the matrix
498bd481603SBarry Smith .  cols - the columns indicated
499bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
500bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
501bd481603SBarry Smith 
502bd481603SBarry Smith 
503bd481603SBarry Smith    Level: intermediate
504bd481603SBarry Smith 
505bd481603SBarry Smith    Notes:
506bd481603SBarry Smith    See the chapter in the users manual on performance for more details
507bd481603SBarry Smith 
508bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
509bd481603SBarry Smith 
510bd481603SBarry Smith   Concepts: preallocation^Matrix
511bd481603SBarry Smith 
512bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
513bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
514bd481603SBarry Smith M*/
515d3d32019SBarry Smith #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
516d3d32019SBarry Smith {\
517d3d32019SBarry Smith   int __l;\
518d3d32019SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
519d3d32019SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
520d3d32019SBarry Smith   for (__l=0;__l<nrows;__l++) {\
521d3d32019SBarry Smith     _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
522d3d32019SBarry Smith   }\
523d3d32019SBarry Smith }
524d3d32019SBarry Smith 
525bd481603SBarry Smith /*MC
526bd481603SBarry Smith    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
527bd481603SBarry Smith        inserted using a local number of the rows and columns
528bd481603SBarry Smith 
529bd481603SBarry Smith    Synopsis:
530bd481603SBarry Smith    int MatPreallocateSet(int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
531bd481603SBarry Smith 
532bd481603SBarry Smith    Not Collective
533bd481603SBarry Smith 
534bd481603SBarry Smith    Input Parameters:
535bd481603SBarry Smith +  nrows - the number of rows indicated
536bd481603SBarry Smith .  rows - the indices of the rows (these will be mapped in the
537bd481603SBarry Smith .  ncols - the number of columns in the matrix
538bd481603SBarry Smith .  cols - the columns indicated
539bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
540bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
541bd481603SBarry Smith 
542bd481603SBarry Smith 
543bd481603SBarry Smith    Level: intermediate
544bd481603SBarry Smith 
545bd481603SBarry Smith    Notes:
546bd481603SBarry Smith    See the chapter in the users manual on performance for more details
547bd481603SBarry Smith 
548bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
549bd481603SBarry Smith 
550bd481603SBarry Smith   Concepts: preallocation^Matrix
551bd481603SBarry Smith 
552bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
553bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
554bd481603SBarry Smith M*/
555c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
5567c922b88SBarry Smith { int __i; \
5577c922b88SBarry Smith   for (__i=0; __i<nc; __i++) {\
5587c922b88SBarry Smith     if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \
5597c922b88SBarry Smith   }\
5607c922b88SBarry Smith   dnz[row - __rstart] = nc - onz[row - __rstart];\
5617c922b88SBarry Smith }
5627c922b88SBarry Smith 
563bd481603SBarry Smith /*MC
564bd481603SBarry Smith    MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
565bd481603SBarry Smith        inserted using a local number of the rows and columns
566bd481603SBarry Smith 
567bd481603SBarry Smith    Synopsis:
568bd481603SBarry Smith    int MatPreallocateSymmetricSet(int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
569bd481603SBarry Smith 
570bd481603SBarry Smith    Not Collective
571bd481603SBarry Smith 
572bd481603SBarry Smith    Input Parameters:
573bd481603SBarry Smith +  nrows - the number of rows indicated
574bd481603SBarry Smith .  rows - the indices of the rows (these will be mapped in the
575bd481603SBarry Smith .  ncols - the number of columns in the matrix
576bd481603SBarry Smith .  cols - the columns indicated
577bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
578bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
579bd481603SBarry Smith 
580bd481603SBarry Smith 
581bd481603SBarry Smith    Level: intermediate
582bd481603SBarry Smith 
583bd481603SBarry Smith    Notes:
584bd481603SBarry Smith    See the chapter in the users manual on performance for more details
585bd481603SBarry Smith 
586bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
587bd481603SBarry Smith 
588bd481603SBarry Smith   Concepts: preallocation^Matrix
589bd481603SBarry Smith 
590bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
591bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
592bd481603SBarry Smith M*/
593d3d32019SBarry Smith #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\
594d3d32019SBarry Smith { int __i; \
595d3d32019SBarry Smith   for (__i=0; __i<nc; __i++) {\
596d3d32019SBarry Smith     if (cols[__i] >= __end) onz[row - __rstart]++; \
597d3d32019SBarry Smith     else if (cols[__i] >= row) dnz[row - __rstart]++;\
598d3d32019SBarry Smith   }\
599d3d32019SBarry Smith }
600d3d32019SBarry Smith 
601bd481603SBarry Smith /*MC
602bd481603SBarry Smith    MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per
603bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
604bd481603SBarry Smith 
605bd481603SBarry Smith    Synopsis:
606bd481603SBarry Smith    int MatPreallocateFinalize(int *dnz, int *onz)
607bd481603SBarry Smith 
608bd481603SBarry Smith    Collective on MPI_Comm
609bd481603SBarry Smith 
610bd481603SBarry Smith    Input Parameters:
611bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
612bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
613bd481603SBarry Smith 
614bd481603SBarry Smith 
615bd481603SBarry Smith    Level: intermediate
616bd481603SBarry Smith 
617bd481603SBarry Smith    Notes:
618bd481603SBarry Smith    See the chapter in the users manual on performance for more details
619bd481603SBarry Smith 
620bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
621bd481603SBarry Smith 
622bd481603SBarry Smith   Concepts: preallocation^Matrix
623bd481603SBarry Smith 
624bd481603SBarry Smith .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
625bd481603SBarry Smith           MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal()
626bd481603SBarry Smith M*/
627ef66eb69SBarry Smith #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);}
6287c922b88SBarry Smith 
629bd481603SBarry Smith 
630bd481603SBarry Smith 
6317b80b807SBarry Smith /* Routines unique to particular data structures */
632435da068SBarry Smith EXTERN int MatShellGetContext(Mat,void **);
633435da068SBarry Smith 
63487828ca2SBarry Smith EXTERN int MatBDiagGetData(Mat,int*,int*,int**,int**,PetscScalar***);
635ca44d042SBarry Smith EXTERN int MatSeqAIJSetColumnIndices(Mat,int *);
636ca44d042SBarry Smith EXTERN int MatSeqBAIJSetColumnIndices(Mat,int *);
63787828ca2SBarry Smith EXTERN int MatCreateSeqAIJWithArrays(MPI_Comm,int,int,int*,int*,PetscScalar *,Mat*);
6387b80b807SBarry Smith 
639273d9f13SBarry Smith EXTERN int MatSeqBAIJSetPreallocation(Mat,int,int,int*);
640273d9f13SBarry Smith EXTERN int MatSeqSBAIJSetPreallocation(Mat,int,int,int*);
641273d9f13SBarry Smith EXTERN int MatSeqAIJSetPreallocation(Mat,int,int*);
64287828ca2SBarry Smith EXTERN int MatSeqDensePreallocation(Mat,PetscScalar*);
64387828ca2SBarry Smith EXTERN int MatSeqBDiagSetPreallocation(Mat,int,int,int*,PetscScalar**);
64487828ca2SBarry Smith EXTERN int MatSeqDenseSetPreallocation(Mat,PetscScalar*);
645273d9f13SBarry Smith 
646273d9f13SBarry Smith EXTERN int MatMPIBAIJSetPreallocation(Mat,int,int,int*,int,int*);
647273d9f13SBarry Smith EXTERN int MatMPISBAIJSetPreallocation(Mat,int,int,int*,int,int*);
648273d9f13SBarry Smith EXTERN int MatMPIAIJSetPreallocation(Mat,int,int*,int,int*);
64987828ca2SBarry Smith EXTERN int MatMPIDensePreallocation(Mat,PetscScalar*);
65087828ca2SBarry Smith EXTERN int MatMPIBDiagSetPreallocation(Mat,int,int,int*,PetscScalar**);
651273d9f13SBarry Smith EXTERN int MatMPIAdjSetPreallocation(Mat,int*,int*,int*);
65287828ca2SBarry Smith EXTERN int MatMPIDenseSetPreallocation(Mat,PetscScalar*);
653273d9f13SBarry Smith EXTERN int MatMPIRowbsSetPreallocation(Mat,int,int*);
654435da068SBarry Smith EXTERN int MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,int**);
655435da068SBarry Smith EXTERN int MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,int**);
6563a7fca6bSBarry Smith EXTERN int MatAdicSetLocalFunction(Mat,void (*)(void));
657273d9f13SBarry Smith 
6581b807ce4Svictorle EXTERN int MatSeqDenseSetLDA(Mat,int);
6591b807ce4Svictorle 
660ca44d042SBarry Smith EXTERN int MatStoreValues(Mat);
661ca44d042SBarry Smith EXTERN int MatRetrieveValues(Mat);
6622e8a6d31SBarry Smith 
6633a7fca6bSBarry Smith EXTERN int MatDAADSetCtx(Mat,void*);
6643a7fca6bSBarry Smith 
6657b80b807SBarry Smith /*
6667b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
6677b80b807SBarry Smith   done through the SLES, KSP and PC interfaces.
6687b80b807SBarry Smith */
6697b80b807SBarry Smith 
670d9274352SBarry Smith /*E
671d9274352SBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
672d9274352SBarry Smith        with an optional dynamic library name, for example
673d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()
674d9274352SBarry Smith 
675d9274352SBarry Smith    Level: beginner
676d9274352SBarry Smith 
677d9274352SBarry Smith .seealso: MatGetOrdering()
678d9274352SBarry Smith E*/
679b12f92e5SBarry Smith typedef char* MatOrderingType;
680b12f92e5SBarry Smith #define MATORDERING_NATURAL   "natural"
681b12f92e5SBarry Smith #define MATORDERING_ND        "nd"
682b12f92e5SBarry Smith #define MATORDERING_1WD       "1wd"
683b12f92e5SBarry Smith #define MATORDERING_RCM       "rcm"
684b12f92e5SBarry Smith #define MATORDERING_QMD       "qmd"
685b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength"
68662152c8bSBarry Smith #define MATORDERING_DSC_ND    "dsc_nd"
68762152c8bSBarry Smith #define MATORDERING_DSC_MMD   "dsc_mmd"
68862152c8bSBarry Smith #define MATORDERING_DSC_MDF   "dsc_mdf"
689c06d978dSMatthew Knepley #define MATORDERING_CONSTRAINED "constrained"
690c06d978dSMatthew Knepley #define MATORDERING_IDENTITY  "identity"
691c06d978dSMatthew Knepley #define MATORDERING_REVERSE   "reverse"
692b12f92e5SBarry Smith 
693ca44d042SBarry Smith EXTERN int MatGetOrdering(Mat,MatOrderingType,IS*,IS*);
694ca44d042SBarry Smith EXTERN int MatOrderingRegister(char*,char*,char*,int(*)(Mat,MatOrderingType,IS*,IS*));
695aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
696f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
697b12f92e5SBarry Smith #else
698f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
699b12f92e5SBarry Smith #endif
700ca44d042SBarry Smith EXTERN int        MatOrderingRegisterDestroy(void);
701ca44d042SBarry Smith EXTERN int        MatOrderingRegisterAll(char*);
7022bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled;
703b0a32e0cSBarry Smith extern PetscFList      MatOrderingList;
704d4fbbf0eSBarry Smith 
70587828ca2SBarry Smith EXTERN int MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);
706a2ce50c7SBarry Smith 
707d91e6319SBarry Smith /*S
70815e8a5b3SHong Zhang    MatFactorInfo - Data based into the matrix factorization routines
709b00f7748SHong Zhang 
71015e8a5b3SHong Zhang    In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE
711b00f7748SHong Zhang 
71215e8a5b3SHong Zhang    Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC.
713b00f7748SHong Zhang 
714b00f7748SHong Zhang    Level: developer
715b00f7748SHong Zhang 
716b380c88cSHong Zhang .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor()
717b00f7748SHong Zhang 
718b00f7748SHong Zhang S*/
719b00f7748SHong Zhang typedef struct {
72015e8a5b3SHong Zhang   PetscReal     damping;        /* scaling of identity added to matrix to prevent zero pivots */
7212cea7109SBarry Smith   PetscReal     shift;          /* if true, shift until positive pivots */
7222cea7109SBarry Smith   PetscReal     shift_fraction; /* record shift fraction taken */
72315e8a5b3SHong Zhang   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
72415e8a5b3SHong Zhang   PetscReal     dt;             /* drop tolerance */
725b00f7748SHong Zhang   PetscReal     dtcol;          /* tolerance for pivoting */
72615e8a5b3SHong Zhang   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
727f6275e2eSBarry Smith   PetscReal     fill;           /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
728348344bbSBarry Smith   PetscReal     levels;         /* ICC/ILU(levels) */
729bcd9e38bSBarry Smith   PetscReal     pivotinblocks;  /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
730bcd9e38bSBarry Smith                                    factorization may be faster if do not pivot */
73115e8a5b3SHong Zhang   PetscReal     zeropivot;      /* pivot is called zero if less than this */
73215e8a5b3SHong Zhang } MatFactorInfo;
733ffa6d0a5SLois Curfman McInnes 
73415e8a5b3SHong Zhang EXTERN int MatCholeskyFactor(Mat,IS,MatFactorInfo*);
73515e8a5b3SHong Zhang EXTERN int MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
73615e8a5b3SHong Zhang EXTERN int MatCholeskyFactorNumeric(Mat,Mat*);
737b380c88cSHong Zhang EXTERN int MatLUFactor(Mat,IS,IS,MatFactorInfo*);
738b380c88cSHong Zhang EXTERN int MatILUFactor(Mat,IS,IS,MatFactorInfo*);
739b380c88cSHong Zhang EXTERN int MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
740b380c88cSHong Zhang EXTERN int MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
74115e8a5b3SHong Zhang EXTERN int MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
74215e8a5b3SHong Zhang EXTERN int MatICCFactor(Mat,IS,MatFactorInfo*);
743ca44d042SBarry Smith EXTERN int MatLUFactorNumeric(Mat,Mat*);
744b380c88cSHong Zhang EXTERN int MatILUDTFactor(Mat,MatFactorInfo*,IS,IS,Mat *);
7453e0d88b5SBarry Smith EXTERN int MatGetInertia(Mat,int*,int*,int*);
746ca44d042SBarry Smith EXTERN int MatSolve(Mat,Vec,Vec);
747ca44d042SBarry Smith EXTERN int MatForwardSolve(Mat,Vec,Vec);
748ca44d042SBarry Smith EXTERN int MatBackwardSolve(Mat,Vec,Vec);
749ca44d042SBarry Smith EXTERN int MatSolveAdd(Mat,Vec,Vec,Vec);
750ca44d042SBarry Smith EXTERN int MatSolveTranspose(Mat,Vec,Vec);
751ca44d042SBarry Smith EXTERN int MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
752d59c15a7SBarry Smith EXTERN int MatSolves(Mat,Vecs,Vecs);
7538ed539a5SBarry Smith 
754ca44d042SBarry Smith EXTERN int MatSetUnfactored(Mat);
755bb5a7306SBarry Smith 
756bb1eb677SSatish Balay /*  MatSORType may be bitwise ORd together, so do not change the numbers */
757d91e6319SBarry Smith /*E
758d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
759bb1eb677SSatish Balay 
760d91e6319SBarry Smith     Level: beginner
761d91e6319SBarry Smith 
762d9274352SBarry Smith    May be bitwise ORd together
763d9274352SBarry Smith 
764d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
765d91e6319SBarry Smith 
766d91e6319SBarry Smith .seealso: MatRelax()
767d91e6319SBarry Smith E*/
768ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
769ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
770ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
77184cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
772c14dc6b6SHong Zhang EXTERN int MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,int,int,Vec);
7738ed539a5SBarry Smith 
774d4fbbf0eSBarry Smith /*
775639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
776639f9d9dSBarry Smith */
777b12f92e5SBarry Smith 
778d9274352SBarry Smith /*E
779d9274352SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
780d9274352SBarry Smith        with an optional dynamic library name, for example
781d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()
782d9274352SBarry Smith 
783d9274352SBarry Smith    Level: beginner
784d9274352SBarry Smith 
785d9274352SBarry Smith .seealso: MatGetColoring()
786d9274352SBarry Smith E*/
787b12f92e5SBarry Smith typedef char* MatColoringType;
788b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural"
789b12f92e5SBarry Smith #define MATCOLORING_SL      "sl"
790b12f92e5SBarry Smith #define MATCOLORING_LF      "lf"
791b12f92e5SBarry Smith #define MATCOLORING_ID      "id"
792b12f92e5SBarry Smith 
793ca44d042SBarry Smith EXTERN int MatGetColoring(Mat,MatColoringType,ISColoring*);
794ca44d042SBarry Smith EXTERN int MatColoringRegister(char*,char*,char*,int(*)(Mat,MatColoringType,ISColoring *));
795aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
796f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
797b12f92e5SBarry Smith #else
798f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
799b12f92e5SBarry Smith #endif
800ca44d042SBarry Smith EXTERN int        MatColoringRegisterAll(char *);
8012bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled;
802ca44d042SBarry Smith EXTERN int        MatColoringRegisterDestroy(void);
80308b6dcc0SBarry Smith EXTERN int        MatColoringPatch(Mat,int,int,ISColoringValue *,ISColoring*);
804639f9d9dSBarry Smith 
805d9274352SBarry Smith /*S
806d9274352SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences
807d9274352SBarry Smith         and coloring
808639f9d9dSBarry Smith 
809d9274352SBarry Smith    Level: beginner
810d9274352SBarry Smith 
811d9274352SBarry Smith   Concepts: coloring, sparse Jacobian, finite differences
812d9274352SBarry Smith 
813d9274352SBarry Smith .seealso:  MatFDColoringCreate()
814d9274352SBarry Smith S*/
815e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
816639f9d9dSBarry Smith 
817ca44d042SBarry Smith EXTERN int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
818ca44d042SBarry Smith EXTERN int MatFDColoringDestroy(MatFDColoring);
819b0a32e0cSBarry Smith EXTERN int MatFDColoringView(MatFDColoring,PetscViewer);
820ca44d042SBarry Smith EXTERN int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*);
82187828ca2SBarry Smith EXTERN int MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
822ca44d042SBarry Smith EXTERN int MatFDColoringSetFrequency(MatFDColoring,int);
823ca44d042SBarry Smith EXTERN int MatFDColoringGetFrequency(MatFDColoring,int*);
824ca44d042SBarry Smith EXTERN int MatFDColoringSetFromOptions(MatFDColoring);
825ca44d042SBarry Smith EXTERN int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
82687828ca2SBarry Smith EXTERN int MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *);
82762152c8bSBarry Smith EXTERN int MatFDColoringSetRecompute(MatFDColoring);
8283a7fca6bSBarry Smith EXTERN int MatFDColoringSetF(MatFDColoring,Vec);
82949b058dcSBarry Smith EXTERN int MatFDColoringGetPerturbedColumns(MatFDColoring,int*,int**);
830639f9d9dSBarry Smith /*
8310752156aSBarry Smith     These routines are for partitioning matrices: currently used only
8323eda8832SBarry Smith   for adjacency matrix, MatCreateMPIAdj().
8330752156aSBarry Smith */
834ca161407SBarry Smith 
835d9274352SBarry Smith /*S
836d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
837d9274352SBarry Smith 
838d9274352SBarry Smith    Level: beginner
839d9274352SBarry Smith 
840d9274352SBarry Smith   Concepts: partitioning
841d9274352SBarry Smith 
842743a1026Svictorle .seealso:  MatPartitioningCreate(), MatPartitioningType
843d9274352SBarry Smith S*/
84491e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
845d9274352SBarry Smith 
846d9274352SBarry Smith /*E
847*5bc6e7ccSvictorle     MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function
848d9274352SBarry Smith        with an optional dynamic library name, for example
849d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()
850d9274352SBarry Smith 
851d9274352SBarry Smith    Level: beginner
852d9274352SBarry Smith 
853b547a13bSvictorle .seealso: MatPartitioningCreate(), MatPartitioning
854d9274352SBarry Smith E*/
8552aabb6bbSBarry Smith typedef char* MatPartitioningType;
8568ba1e511SMatthew Knepley #define MAT_PARTITIONING_CURRENT  "current"
8578ba1e511SMatthew Knepley #define MAT_PARTITIONING_PARMETIS "parmetis"
858ca161407SBarry Smith 
859ca44d042SBarry Smith EXTERN int MatPartitioningCreate(MPI_Comm,MatPartitioning*);
860ca44d042SBarry Smith EXTERN int MatPartitioningSetType(MatPartitioning,MatPartitioningType);
861*5bc6e7ccSvictorle EXTERN int MatPartitioningSetNParts(MatPartitioning,int);
862ca44d042SBarry Smith EXTERN int MatPartitioningSetAdjacency(MatPartitioning,Mat);
863ca44d042SBarry Smith EXTERN int MatPartitioningSetVertexWeights(MatPartitioning,int*);
864ca44d042SBarry Smith EXTERN int MatPartitioningApply(MatPartitioning,IS*);
865ca44d042SBarry Smith EXTERN int MatPartitioningDestroy(MatPartitioning);
8662aabb6bbSBarry Smith 
867ca44d042SBarry Smith EXTERN int MatPartitioningRegister(char*,char*,char*,int(*)(MatPartitioning));
868aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
869f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
8702aabb6bbSBarry Smith #else
871f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
8722aabb6bbSBarry Smith #endif
8732aabb6bbSBarry Smith 
874ca44d042SBarry Smith EXTERN int        MatPartitioningRegisterAll(char *);
8752bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled;
876ca44d042SBarry Smith EXTERN int        MatPartitioningRegisterDestroy(void);
8772bad1931SBarry Smith 
878b0a32e0cSBarry Smith EXTERN int MatPartitioningView(MatPartitioning,PetscViewer);
879ca44d042SBarry Smith EXTERN int MatPartitioningSetFromOptions(MatPartitioning);
880ca44d042SBarry Smith EXTERN int MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
881ca161407SBarry Smith 
882ca44d042SBarry Smith EXTERN int MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
8830752156aSBarry Smith 
8840752156aSBarry Smith /*
8850a835dfdSSatish Balay     If you add entries here you must also add them to finclude/petscmat.h
886d4fbbf0eSBarry Smith */
8871c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
8881c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
8891c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
8901c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
8911c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
8927c922b88SBarry Smith                MATOP_MULT_TRANSPOSE=5,
8937c922b88SBarry Smith                MATOP_MULT_TRANSPOSE_ADD=6,
8941c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
8951c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
8967c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE=9,
8977c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE_ADD=10,
8981c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
8991c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
9001c1c02c0SLois Curfman McInnes                MATOP_RELAX=13,
9011c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
9021c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
9031c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
9041c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
9051c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
9061c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
9071c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
9081c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
9091c1c02c0SLois Curfman McInnes                MATOP_COMPRESS=22,
9101c1c02c0SLois Curfman McInnes                MATOP_SET_OPTION=23,
9111c1c02c0SLois Curfman McInnes                MATOP_ZERO_ENTRIES=24,
9121c1c02c0SLois Curfman McInnes                MATOP_ZERO_ROWS=25,
9131c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_SYMBOLIC=26,
9141c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_NUMERIC=27,
9151c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
9161c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
917d643ce63SMatthew Knepley                MATOP_SETUP_PREALLOCATION=30,
918d643ce63SMatthew Knepley                MATOP_ILUFACTOR_SYMBOLIC=31,
919d643ce63SMatthew Knepley                MATOP_ICCFACTOR_SYMBOLIC=32,
920d643ce63SMatthew Knepley                MATOP_GET_ARRAY=33,
921d643ce63SMatthew Knepley                MATOP_RESTORE_ARRAY=34,
922d643ce63SMatthew Knepley                MATOP_DUPLCIATE=35,
923d643ce63SMatthew Knepley                MATOP_FORWARD_SOLVE=36,
924d643ce63SMatthew Knepley                MATOP_BACKWARD_SOLVE=37,
925d643ce63SMatthew Knepley                MATOP_ILUFACTOR=38,
926d643ce63SMatthew Knepley                MATOP_ICCFACTOR=39,
927d643ce63SMatthew Knepley                MATOP_AXPY=40,
928d643ce63SMatthew Knepley                MATOP_GET_SUBMATRICES=41,
929d643ce63SMatthew Knepley                MATOP_INCREASE_OVERLAP=42,
930d643ce63SMatthew Knepley                MATOP_GET_VALUES=43,
931d643ce63SMatthew Knepley                MATOP_COPY=44,
932d643ce63SMatthew Knepley                MATOP_PRINT_HELP=45,
933d643ce63SMatthew Knepley                MATOP_SCALE=46,
934d643ce63SMatthew Knepley                MATOP_SHIFT=47,
935d643ce63SMatthew Knepley                MATOP_DIAGONAL_SHIFT=48,
936d643ce63SMatthew Knepley                MATOP_ILUDT_FACTOR=49,
937d643ce63SMatthew Knepley                MATOP_GET_BLOCK_SIZE=50,
938d643ce63SMatthew Knepley                MATOP_GET_ROW_IJ=51,
939d643ce63SMatthew Knepley                MATOP_RESTORE_ROW_IJ=52,
940d643ce63SMatthew Knepley                MATOP_GET_COLUMN_IJ=53,
941d643ce63SMatthew Knepley                MATOP_RESTORE_COLUMN_IJ=54,
942d643ce63SMatthew Knepley                MATOP_FDCOLORING_CREATE=55,
943d643ce63SMatthew Knepley                MATOP_COLORING_PATCH=56,
944d643ce63SMatthew Knepley                MATOP_SET_UNFACTORED=57,
945d643ce63SMatthew Knepley                MATOP_PERMUTE=58,
946d643ce63SMatthew Knepley                MATOP_SET_VALUES_BLOCKED=59,
947d643ce63SMatthew Knepley                MATOP_GET_SUBMATRIX=60,
948d643ce63SMatthew Knepley                MATOP_DESTROY=61,
949d643ce63SMatthew Knepley                MATOP_VIEW=62,
950d643ce63SMatthew Knepley                MATOP_GET_MAPS=63,
951d643ce63SMatthew Knepley                MATOP_USE_SCALED_FORM=64,
952d643ce63SMatthew Knepley                MATOP_SCALE_SYSTEM=65,
953d643ce63SMatthew Knepley                MATOP_UNSCALE_SYSTEM=66,
954d643ce63SMatthew Knepley                MATOP_SET_LOCAL_TO_GLOBAL_MAPPING=67,
955d643ce63SMatthew Knepley                MATOP_SET_VALUES_LOCAL=68,
956d643ce63SMatthew Knepley                MATOP_ZERO_ROWS_LOCAL=69,
957d643ce63SMatthew Knepley                MATOP_GET_ROW_MAX=70,
958d643ce63SMatthew Knepley                MATOP_CONVERT=71,
959d643ce63SMatthew Knepley                MATOP_SET_COLORING=72,
960d643ce63SMatthew Knepley                MATOP_SET_VALUES_ADIC=73,
961d643ce63SMatthew Knepley                MATOP_SET_VALUES_ADIFOR=74,
962d643ce63SMatthew Knepley                MATOP_FD_COLORING_APPLY=75,
963d643ce63SMatthew Knepley                MATOP_SET_FROM_OPTIONS=76,
964d643ce63SMatthew Knepley                MATOP_MULT_CONSTRAINED=77,
965d643ce63SMatthew Knepley                MATOP_MULT_TRANSPOSE_CONSTRAINED=78,
966d643ce63SMatthew Knepley                MATOP_ILU_FACTOR_SYMBOLIC_CONSTRAINED=79,
967d643ce63SMatthew Knepley                MATOP_PERMUTE_SPARSIFY=80,
968d643ce63SMatthew Knepley                MATOP_MULT_MULTIPLE=81,
969d643ce63SMatthew Knepley                MATOP_SOLVE_MULTIPLE=82
970fae171e0SBarry Smith              } MatOperation;
971ca44d042SBarry Smith EXTERN int MatHasOperation(Mat,MatOperation,PetscTruth*);
972ff8b7a98SSatish Balay EXTERN int MatShellSetOperation(Mat,MatOperation,void(*)(void));
973ff8b7a98SSatish Balay EXTERN int MatShellGetOperation(Mat,MatOperation,void(**)(void));
974273d9f13SBarry Smith EXTERN int MatShellSetContext(Mat,void*);
975112a2221SBarry Smith 
97690ace30eSBarry Smith /*
97790ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
97890ace30eSBarry Smith  stored in a universal format. By changing the format with
979fb9695e5SSatish Balay  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
98090ace30eSBarry Smith  be stored in a way natural for the matrix, for example dense matrices
98190ace30eSBarry Smith  would be stored as dense. Matrices stored this way may only be
98290ace30eSBarry Smith  read into matrices of the same time.
98390ace30eSBarry Smith */
98490ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
98590ace30eSBarry Smith 
9863f1d51d7SBarry Smith /*
9873f1d51d7SBarry Smith      New matrix classes not yet distributed
9883f1d51d7SBarry Smith */
9893f1d51d7SBarry Smith /*
9903f1d51d7SBarry Smith     MatAIJIndices is a data structure for storing the nonzero location information
9913f1d51d7SBarry Smith   for sparse matrices. Several matrices with identical nonzero structure can share
9923f1d51d7SBarry Smith   the same MatAIJIndices.
9933f1d51d7SBarry Smith */
994e2a1c21fSSatish Balay typedef struct _p_MatAIJIndices* MatAIJIndices;
9953f1d51d7SBarry Smith 
996ca44d042SBarry Smith EXTERN int MatCreateAIJIndices(int,int,int*,int*,PetscTruth,MatAIJIndices*);
997ca44d042SBarry Smith EXTERN int MatCreateAIJIndicesEmpty(int,int,int*,PetscTruth,MatAIJIndices*);
998ca44d042SBarry Smith EXTERN int MatAttachAIJIndices(MatAIJIndices,MatAIJIndices*);
999ca44d042SBarry Smith EXTERN int MatDestroyAIJIndices(MatAIJIndices);
1000ca44d042SBarry Smith EXTERN int MatCopyAIJIndices(MatAIJIndices,MatAIJIndices*);
1001ca44d042SBarry Smith EXTERN int MatValidateAIJIndices(int,MatAIJIndices);
1002ca44d042SBarry Smith EXTERN int MatShiftAIJIndices(MatAIJIndices);
1003ca44d042SBarry Smith EXTERN int MatShrinkAIJIndices(MatAIJIndices);
1004ca44d042SBarry Smith EXTERN int MatTransposeAIJIndices(MatAIJIndices,MatAIJIndices*);
10053f1d51d7SBarry Smith 
1006ca44d042SBarry Smith EXTERN int MatCreateSeqCSN(MPI_Comm,int,int,int*,int,Mat*);
1007ca44d042SBarry Smith EXTERN int MatCreateSeqCSN_Single(MPI_Comm,int,int,int*,int,Mat*);
100887828ca2SBarry Smith EXTERN int MatCreateSeqCSNWithPrecision(MPI_Comm,int,int,int*,int,PetscScalarPrecision,Mat*);
10093f1d51d7SBarry Smith 
1010ca44d042SBarry Smith EXTERN int MatCreateSeqCSNIndices(MPI_Comm,MatAIJIndices,int,Mat *);
1011ca44d042SBarry Smith EXTERN int MatCreateSeqCSNIndices_Single(MPI_Comm,MatAIJIndices,int,Mat *);
101287828ca2SBarry Smith EXTERN int MatCreateSeqCSNIndicesWithPrecision(MPI_Comm,MatAIJIndices,int,PetscScalarPrecision,Mat *);
10133f1d51d7SBarry Smith 
10146d053be9SSatish Balay EXTERN int MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
1015ca44d042SBarry Smith EXTERN int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *);
101608918a0eSSatish Balay EXTERN int MatMPIRowbsGetColor(Mat,ISColoring *);
1017860d1616SSatish Balay 
1018d9274352SBarry Smith /*S
1019d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
1020d9274352SBarry Smith          orthogonalizes the vector to a subsapce
1021d9274352SBarry Smith 
1022f7a9e4ceSBarry Smith    Level: advanced
1023d9274352SBarry Smith 
1024d9274352SBarry Smith   Concepts: matrix; linear operator, null space
1025d9274352SBarry Smith 
10266e1639daSBarry Smith   Users manual sections:
10276e1639daSBarry Smith .   sec_singular
10286e1639daSBarry Smith 
1029d9274352SBarry Smith .seealso:  MatNullSpaceCreate()
1030d9274352SBarry Smith S*/
103174637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace;
1032d9274352SBarry Smith 
103374637425SBarry Smith EXTERN int MatNullSpaceCreate(MPI_Comm,int,int,Vec *,MatNullSpace*);
103474637425SBarry Smith EXTERN int MatNullSpaceDestroy(MatNullSpace);
103574637425SBarry Smith EXTERN int MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
103674637425SBarry Smith EXTERN int MatNullSpaceAttach(Mat,MatNullSpace);
103774637425SBarry Smith EXTERN int MatNullSpaceTest(MatNullSpace,Mat);
103874637425SBarry Smith 
1039273d9f13SBarry Smith EXTERN int MatReorderingSeqSBAIJ(Mat A,IS isp);
1040273d9f13SBarry Smith EXTERN int MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
1041273d9f13SBarry Smith EXTERN int MatSeqSBAIJSetColumnIndices(Mat,int *);
1042273d9f13SBarry Smith 
10433f1d51d7SBarry Smith 
1044f069c275SSatish Balay EXTERN int MatCreateMAIJ(Mat,int,Mat*);
1045c4f061fbSSatish Balay EXTERN int MatMAIJRedimension(Mat,int,Mat*);
1046c4f061fbSSatish Balay EXTERN int MatMAIJGetAIJ(Mat,Mat*);
1047c4f061fbSSatish Balay 
1048273d9f13SBarry Smith EXTERN int MatMPIAdjSetValues(Mat,int*,int*,int*);
1049f069c275SSatish Balay 
1050b0a32e0cSBarry Smith EXTERN int MatComputeExplicitOperator(Mat,Mat*);
1051b0a32e0cSBarry Smith 
105224a595ddSBarry Smith EXTERN int MatESISetType(Mat,char*);
105324a595ddSBarry Smith EXTERN int MatESISetFromOptions(Mat);
105424a595ddSBarry Smith 
10552cd6534aSBarry Smith EXTERN int MatDiagonalScaleLocal(Mat,Vec);
105604f1ad80SBarry Smith 
10577dbadf16SMatthew Knepley EXTERN int PetscViewerMathematicaPutMatrix(PetscViewer, int, int, PetscReal *);
10587dbadf16SMatthew Knepley EXTERN int PetscViewerMathematicaPutCSRMatrix(PetscViewer, int, int, int *, int *, PetscReal *);
10597dbadf16SMatthew Knepley 
1060e82a3eeeSBarry Smith EXTERN int MatUseSpooles_SeqAIJ(Mat);
1061e82a3eeeSBarry Smith EXTERN int MatUseUMFPACK_SeqAIJ(Mat);
1062e82a3eeeSBarry Smith EXTERN int MatUseSuperLU_SeqAIJ(Mat);
1063e82a3eeeSBarry Smith EXTERN int MatUseEssl_SeqAIJ(Mat);
1064e82a3eeeSBarry Smith EXTERN int MatUseLUSOL_SeqAIJ(Mat);
1065e82a3eeeSBarry Smith EXTERN int MatUseMatlab_SeqAIJ(Mat);
1066e82a3eeeSBarry Smith EXTERN int MatUseDXML_SeqAIJ(Mat);
1067e82a3eeeSBarry Smith EXTERN int MatUseSuperLU_DIST_MPIAIJ(Mat);
1068e82a3eeeSBarry Smith EXTERN int MatUseSpooles_MPIAIJ(Mat);
1069e82a3eeeSBarry Smith EXTERN int MatUseSpooles_SeqSBAIJ(Mat);
1070eee76cafSHong Zhang EXTERN int MatUseSpooles_MPISBAIJ(Mat);
1071eee76cafSHong Zhang EXTERN int MatUseMUMPS_MPIAIJ(Mat);
1072e82a3eeeSBarry Smith 
10732eac72dbSBarry Smith #endif
10742eac72dbSBarry Smith 
10752eac72dbSBarry Smith 
10769d00d63dSBarry Smith 
1077