xref: /petsc/include/petscmat.h (revision 6284ec503f7d48a443257752306f1a524cdcb213)
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 */
76c06d978dSMatthew Knepley extern int MAT_COOKIE;
7771d41ebeSBarry Smith extern int MATSNESMFCTX_COOKIE;
78c06d978dSMatthew Knepley extern int MAT_FDCOLORING_COOKIE;
798ba1e511SMatthew Knepley extern int MAT_PARTITIONING_COOKIE;
808ba1e511SMatthew Knepley extern int MAT_NULLSPACE_COOKIE;
81d59c15a7SBarry Smith extern int MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose;
82d59c15a7SBarry Smith extern int MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose;
83d5ba7fb7SMatthew Knepley extern int MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic;
84d5ba7fb7SMatthew Knepley extern int MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor;
85d5ba7fb7SMatthew Knepley extern int MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin;
86d5ba7fb7SMatthew Knepley extern int MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering;
87d5ba7fb7SMatthew Knepley extern int MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate;
8866f9b7ceSBarry Smith extern int MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction;
89*6284ec50SHong Zhang extern int MAT_MatMult;
90c06d978dSMatthew Knepley 
918ba1e511SMatthew Knepley EXTERN int MatInitializePackage(char *);
92c06d978dSMatthew Knepley 
93273d9f13SBarry Smith EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*);
940e33f6ddSBarry Smith EXTERN int MatSetType(Mat,const MatType);
95273d9f13SBarry Smith EXTERN int MatSetFromOptions(Mat);
96273d9f13SBarry Smith EXTERN int MatSetUpPreallocation(Mat);
970e33f6ddSBarry Smith EXTERN int MatRegisterAll(const char[]);
980e33f6ddSBarry Smith EXTERN int MatRegister(const char[],const char[],const char[],int(*)(Mat));
9930de9b25SBarry Smith 
10030de9b25SBarry Smith /*MC
10130de9b25SBarry Smith    MatRegisterDynamic - Adds a new matrix type
10230de9b25SBarry Smith 
10330de9b25SBarry Smith    Synopsis:
10430de9b25SBarry Smith    int MatRegisterDynamic(char *name,char *path,char *name_create,int (*routine_create)(Mat))
10530de9b25SBarry Smith 
10630de9b25SBarry Smith    Not Collective
10730de9b25SBarry Smith 
10830de9b25SBarry Smith    Input Parameters:
10930de9b25SBarry Smith +  name - name of a new user-defined matrix type
11030de9b25SBarry Smith .  path - path (either absolute or relative) the library containing this solver
11130de9b25SBarry Smith .  name_create - name of routine to create method context
11230de9b25SBarry Smith -  routine_create - routine to create method context
11330de9b25SBarry Smith 
11430de9b25SBarry Smith    Notes:
11530de9b25SBarry Smith    MatRegisterDynamic() may be called multiple times to add several user-defined solvers.
11630de9b25SBarry Smith 
11730de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (routine_create)
11830de9b25SBarry Smith    is ignored.
11930de9b25SBarry Smith 
12030de9b25SBarry Smith    Sample usage:
12130de9b25SBarry Smith .vb
12230de9b25SBarry Smith    MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a,
12330de9b25SBarry Smith                "MyMatCreate",MyMatCreate);
12430de9b25SBarry Smith .ve
12530de9b25SBarry Smith 
12630de9b25SBarry Smith    Then, your solver can be chosen with the procedural interface via
12730de9b25SBarry Smith $     MatSetType(Mat,"my_mat")
12830de9b25SBarry Smith    or at runtime via the option
12930de9b25SBarry Smith $     -mat_type my_mat
13030de9b25SBarry Smith 
13130de9b25SBarry Smith    Level: advanced
13230de9b25SBarry Smith 
13330de9b25SBarry Smith    Notes: ${PETSC_ARCH} and ${BOPT} occuring in pathname will be replaced with appropriate values.
13430de9b25SBarry Smith          If your function is not being put into a shared library then use VecRegister() instead
13530de9b25SBarry Smith 
13630de9b25SBarry Smith .keywords: Mat, register
13730de9b25SBarry Smith 
13830de9b25SBarry Smith .seealso: MatRegisterAll(), MatRegisterDestroy()
13930de9b25SBarry Smith 
14030de9b25SBarry Smith M*/
141273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
142273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0)
143273d9f13SBarry Smith #else
144273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d)
14530de9b25SBarry Smith #endif
14630de9b25SBarry Smith 
147273d9f13SBarry Smith extern PetscTruth MatRegisterAllCalled;
148b0a32e0cSBarry Smith extern PetscFList MatList;
14928988994SBarry Smith 
150ca01db9bSBarry Smith EXTERN int MatCreateSeqDense(MPI_Comm,int,int,PetscScalar[],Mat*);
151ca01db9bSBarry Smith EXTERN int MatCreateMPIDense(MPI_Comm,int,int,int,int,PetscScalar[],Mat*);
152ca01db9bSBarry Smith EXTERN int MatCreateSeqAIJ(MPI_Comm,int,int,int,const int[],Mat*);
153ca01db9bSBarry Smith EXTERN int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,const int[],int,const int[],Mat*);
154ca01db9bSBarry Smith EXTERN int MatCreateMPIRowbs(MPI_Comm,int,int,int,const int[],Mat*);
155ca01db9bSBarry Smith EXTERN int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,const int[],PetscScalar*[],Mat*);
156ca01db9bSBarry Smith EXTERN int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,const int[],PetscScalar*[],Mat*);
157ca01db9bSBarry Smith EXTERN int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,const int[],Mat*);
158ca01db9bSBarry Smith EXTERN int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,const int[],int,const int[],Mat*);
159ca01db9bSBarry Smith EXTERN int MatCreateMPIAdj(MPI_Comm,int,int,int[],int[],int[],Mat*);
160ca01db9bSBarry Smith EXTERN int MatCreateSeqSBAIJ(MPI_Comm,int,int,int,int,const int[],Mat*);
161ca01db9bSBarry Smith EXTERN int MatCreateMPISBAIJ(MPI_Comm,int,int,int,int,int,int,const int[],int,const int[],Mat*);
162ca44d042SBarry Smith EXTERN int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*);
1633a7fca6bSBarry Smith EXTERN int MatCreateAdic(MPI_Comm,int,int,int,int,int,void (*)(void),Mat*);
164c8a8475eSBarry Smith EXTERN int MatCreateNormal(Mat,Mat*);
165435da068SBarry Smith EXTERN int MatDestroy(Mat);
16621c89e3eSBarry Smith 
167ca44d042SBarry Smith EXTERN int MatPrintHelp(Mat);
1688a124369SBarry Smith EXTERN int MatGetPetscMaps(Mat,PetscMap*,PetscMap*);
169ec0117caSBarry Smith 
1708ed539a5SBarry Smith /* ------------------------------------------------------------*/
171f15d580aSBarry Smith EXTERN int MatSetValues(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode);
172f15d580aSBarry Smith EXTERN int MatSetValuesBlocked(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode);
17384cb2905SBarry Smith 
1742ef4de8bSBarry Smith /*S
1752ef4de8bSBarry Smith      MatStencil - Data structure (C struct) for storing information about a single row or
1762ef4de8bSBarry Smith         column of a matrix as index on an associated grid.
1772ef4de8bSBarry Smith 
1782ef4de8bSBarry Smith    Level: beginner
1792ef4de8bSBarry Smith 
1802ef4de8bSBarry Smith   Concepts: matrix; linear operator
1812ef4de8bSBarry Smith 
182d7bd93baSBarry Smith .seealso:  MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockStencil()
1832ef4de8bSBarry Smith S*/
184435da068SBarry Smith typedef struct {
185435da068SBarry Smith   int k,j,i,c;
186435da068SBarry Smith } MatStencil;
1872ef4de8bSBarry Smith 
188f15d580aSBarry Smith EXTERN int MatSetValuesStencil(Mat,int,const MatStencil[],int,const MatStencil[],const PetscScalar[],InsertMode);
189f15d580aSBarry Smith EXTERN int MatSetValuesBlockedStencil(Mat,int,const MatStencil[],int,const MatStencil[],const PetscScalar[],InsertMode);
190f15d580aSBarry Smith EXTERN int MatSetStencil(Mat,int,const int[],const int[],int);
191435da068SBarry Smith 
1923a7fca6bSBarry Smith EXTERN int MatSetColoring(Mat,ISColoring);
1933a7fca6bSBarry Smith EXTERN int MatSetValuesAdic(Mat,void*);
1943a7fca6bSBarry Smith EXTERN int MatSetValuesAdifor(Mat,int,void*);
1953a7fca6bSBarry Smith 
196d91e6319SBarry Smith /*E
197d91e6319SBarry Smith     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
198d91e6319SBarry Smith      to continue to add values to it
199d91e6319SBarry Smith 
200d91e6319SBarry Smith     Level: beginner
201d91e6319SBarry Smith 
202d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd()
203d91e6319SBarry Smith E*/
2046d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
205ca44d042SBarry Smith EXTERN int MatAssemblyBegin(Mat,MatAssemblyType);
206ca44d042SBarry Smith EXTERN int MatAssemblyEnd(Mat,MatAssemblyType);
207ca44d042SBarry Smith EXTERN int MatAssembled(Mat,PetscTruth*);
2084f9c727eSBarry Smith 
2091d73ed98SBarry Smith extern int         MatSetValue_Row, MatSetValue_Column;
2101d73ed98SBarry Smith extern PetscScalar MatSetValue_Value;
2111d73ed98SBarry Smith 
21230de9b25SBarry Smith /*MC
21330de9b25SBarry Smith    MatSetValue - Set a single entry into a matrix.
21430de9b25SBarry Smith 
21530de9b25SBarry Smith    Synopsis:
21630de9b25SBarry Smith    int MatSetValue(Mat m,int row,int col,PetscScalar value,InsertMode mode);
21730de9b25SBarry Smith 
21830de9b25SBarry Smith    Not collective
21930de9b25SBarry Smith 
22030de9b25SBarry Smith    Input Parameters:
22130de9b25SBarry Smith +  m - the matrix
22230de9b25SBarry Smith .  row - the row location of the entry
22330de9b25SBarry Smith .  col - the column location of the entry
22430de9b25SBarry Smith .  value - the value to insert
22530de9b25SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
22630de9b25SBarry Smith 
22730de9b25SBarry Smith    Notes:
22830de9b25SBarry Smith    For efficiency one should use MatSetValues() and set several or many
22930de9b25SBarry Smith    values simultaneously if possible.
23030de9b25SBarry Smith 
23130de9b25SBarry Smith    Level: beginner
23230de9b25SBarry Smith 
23330de9b25SBarry Smith .seealso: MatSetValues(), MatSetValueLocal()
23430de9b25SBarry Smith M*/
235b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \
2361d73ed98SBarry Smith   (MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va, \
2371d73ed98SBarry Smith    MatSetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))
23830de9b25SBarry Smith 
239ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \
2401d73ed98SBarry Smith   (MatSetValue_Row = i,MatSetValue_Column = j,\
2411d73ed98SBarry Smith    MatGetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&va))
24230de9b25SBarry Smith 
243d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \
2441d73ed98SBarry Smith   (MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va, \
2451d73ed98SBarry Smith    MatSetValuesLocal(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))
24630de9b25SBarry Smith 
247d91e6319SBarry Smith /*E
248d91e6319SBarry Smith     MatOption - Options that may be set for a matrix and its behavior or storage
249d91e6319SBarry Smith 
250d91e6319SBarry Smith     Level: beginner
251d91e6319SBarry Smith 
2520a835dfdSSatish Balay    Any additions/changes here MUST also be made in include/finclude/petscmat.h
253d91e6319SBarry Smith 
254d91e6319SBarry Smith .seealso: MatSetOption()
255d91e6319SBarry Smith E*/
2566d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
2576d4a8577SBarry Smith               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
2586d4a8577SBarry Smith               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
2596ca9ecd3SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
2606ca9ecd3SBarry Smith               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
2616ca9ecd3SBarry Smith               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
2626ca9ecd3SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
2634787f768SSatish Balay               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
2647c922b88SBarry Smith               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78,
2652bad1931SBarry Smith               MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81,
266efcf0fc3SBarry Smith               MAT_DO_NOT_USE_INODES=82,MAT_NOT_SYMMETRIC=83,MAT_HERMITIAN=84,
2679a4540c5SBarry Smith               MAT_NOT_STRUCTURALLY_SYMMETRIC=85,MAT_NOT_HERMITIAN=86,
2689a4540c5SBarry Smith               MAT_SYMMETRY_ETERNAL=87,MAT_NOT_SYMMETRY_ETERNAL=88} MatOption;
269ca44d042SBarry Smith EXTERN int MatSetOption(Mat,MatOption);
270273d9f13SBarry Smith EXTERN int MatGetType(Mat,MatType*);
27184cb2905SBarry Smith 
272f15d580aSBarry Smith EXTERN int MatGetValues(Mat,int,const int[],int,const int[],PetscScalar[]);
273b3cc6726SBarry Smith EXTERN int MatGetRow(Mat,int,int *,const int *[],const PetscScalar*[]);
274b3cc6726SBarry Smith EXTERN int MatRestoreRow(Mat,int,int *,const int *[],const PetscScalar*[]);
2754e7234bfSBarry Smith EXTERN int MatGetColumn(Mat,int,int *,int *[],PetscScalar*[]);
2764e7234bfSBarry Smith EXTERN int MatRestoreColumn(Mat,int,int *,int *[],PetscScalar*[]);
277ca44d042SBarry Smith EXTERN int MatGetColumnVector(Mat,Vec,int);
2784e7234bfSBarry Smith EXTERN int MatGetArray(Mat,PetscScalar *[]);
2794e7234bfSBarry Smith EXTERN int MatRestoreArray(Mat,PetscScalar *[]);
280ca44d042SBarry Smith EXTERN int MatGetBlockSize(Mat,int *);
2817b80b807SBarry Smith 
282ca44d042SBarry Smith EXTERN int MatMult(Mat,Vec,Vec);
283ca44d042SBarry Smith EXTERN int MatMultAdd(Mat,Vec,Vec,Vec);
284ca44d042SBarry Smith EXTERN int MatMultTranspose(Mat,Vec,Vec);
2855485867bSBarry Smith EXTERN int MatIsTranspose(Mat,Mat,PetscReal,PetscTruth*);
286ca44d042SBarry Smith EXTERN int MatMultTransposeAdd(Mat,Vec,Vec,Vec);
287c06d978dSMatthew Knepley EXTERN int MatMultConstrained(Mat,Vec,Vec);
2886d0dc95fSMatthew Knepley EXTERN int MatMultTransposeConstrained(Mat,Vec,Vec);
2892eac72dbSBarry Smith 
290d91e6319SBarry Smith /*E
291d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
292d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
293d91e6319SBarry Smith 
294d91e6319SBarry Smith     Level: beginner
295d91e6319SBarry Smith 
296d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
297d91e6319SBarry Smith 
298d91e6319SBarry Smith .seealso: MatDuplicate()
299d91e6319SBarry Smith E*/
3002e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;
3012e8a6d31SBarry Smith 
3020e33f6ddSBarry Smith EXTERN int MatConvertRegister(const char[],const char[],const char[],int (*)(Mat,MatType,Mat*));
303273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
304273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0)
305273d9f13SBarry Smith #else
306273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d)
307273d9f13SBarry Smith #endif
3080e33f6ddSBarry Smith EXTERN int        MatConvertRegisterAll(const char[]);
309273d9f13SBarry Smith EXTERN int        MatConvertRegisterDestroy(void);
310273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled;
311b0a32e0cSBarry Smith extern PetscFList MatConvertList;
3128e9aea5cSBarry Smith EXTERN int        MatConvert(Mat,const MatType,Mat*);
313ca44d042SBarry Smith EXTERN int        MatDuplicate(Mat,MatDuplicateOption,Mat*);
31494a9d846SBarry Smith 
315d91e6319SBarry Smith /*E
316d91e6319SBarry Smith     MatStructure - Indicates if the matrix has the same nonzero structure
317d91e6319SBarry Smith 
318d91e6319SBarry Smith     Level: beginner
319d91e6319SBarry Smith 
320d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
321d91e6319SBarry Smith 
32294b7f48cSBarry Smith .seealso: MatCopy(), KSPSetOperators(), PCSetOperators()
323d91e6319SBarry Smith E*/
324c537a176SHong Zhang typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure;
325cb5b572fSBarry Smith 
326ca44d042SBarry Smith EXTERN int MatCopy(Mat,Mat,MatStructure);
327b0a32e0cSBarry Smith EXTERN int MatView(Mat,PetscViewer);
3285485867bSBarry Smith EXTERN int MatIsSymmetric(Mat,PetscReal,PetscTruth*);
329ba8a7149SBarry Smith EXTERN int MatIsSymmetricKnown(Mat,PetscTruth*,PetscTruth*);
3308e9aea5cSBarry Smith EXTERN int MatLoad(PetscViewer,const MatType,Mat*);
33151dd7536SBarry Smith EXTERN int MatMerge(MPI_Comm,Mat,Mat*);
3327b80b807SBarry Smith 
3334e7234bfSBarry Smith EXTERN int MatGetRowIJ(Mat,int,PetscTruth,int*,int *[],int *[],PetscTruth *);
3344e7234bfSBarry Smith EXTERN int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int *[],int *[],PetscTruth *);
3354e7234bfSBarry Smith EXTERN int MatGetColumnIJ(Mat,int,PetscTruth,int*,int *[],int *[],PetscTruth *);
3364e7234bfSBarry Smith EXTERN int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int *[],int *[],PetscTruth *);
337d4fbbf0eSBarry Smith 
338d91e6319SBarry Smith /*S
339d91e6319SBarry Smith      MatInfo - Context of matrix information, used with MatGetInfo()
340d91e6319SBarry Smith 
341d91e6319SBarry Smith    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
342d91e6319SBarry Smith 
343d91e6319SBarry Smith    Level: intermediate
344d91e6319SBarry Smith 
345d91e6319SBarry Smith   Concepts: matrix^nonzero information
346d91e6319SBarry Smith 
347d9274352SBarry Smith .seealso:  MatGetInfo(), MatInfoType
348d91e6319SBarry Smith S*/
3494e220ebcSLois Curfman McInnes typedef struct {
350b0a32e0cSBarry Smith   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
351b0a32e0cSBarry Smith   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
352b0a32e0cSBarry Smith   PetscLogDouble block_size;                         /* block size */
353b0a32e0cSBarry Smith   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
354b0a32e0cSBarry Smith   PetscLogDouble memory;                             /* memory allocated */
355b0a32e0cSBarry Smith   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
356b0a32e0cSBarry Smith   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
357b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
358b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
3594e220ebcSLois Curfman McInnes } MatInfo;
3604e220ebcSLois Curfman McInnes 
361d9274352SBarry Smith /*E
362d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
363d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
364d9274352SBarry Smith 
365d9274352SBarry Smith     Level: beginner
366d9274352SBarry Smith 
367d9274352SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
368d9274352SBarry Smith 
369d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo
370d9274352SBarry Smith E*/
3717b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
372ca44d042SBarry Smith EXTERN int MatGetInfo(Mat,MatInfoType,MatInfo*);
373ca44d042SBarry Smith EXTERN int MatValid(Mat,PetscTruth*);
374ca44d042SBarry Smith EXTERN int MatGetDiagonal(Mat,Vec);
375273d9f13SBarry Smith EXTERN int MatGetRowMax(Mat,Vec);
376ca44d042SBarry Smith EXTERN int MatTranspose(Mat,Mat*);
377ca44d042SBarry Smith EXTERN int MatPermute(Mat,IS,IS,Mat *);
378bf1d55d4SSatish Balay EXTERN int MatPermuteSparsify(Mat,int,PetscReal,PetscReal,IS,IS,Mat *);
379ca44d042SBarry Smith EXTERN int MatDiagonalScale(Mat,Vec,Vec);
38006ef90c2SBarry Smith EXTERN int MatDiagonalSet(Mat,Vec,InsertMode);
381ca44d042SBarry Smith EXTERN int MatEqual(Mat,Mat,PetscTruth*);
3827b80b807SBarry Smith 
38387828ca2SBarry Smith EXTERN int MatNorm(Mat,NormType,PetscReal *);
384ca44d042SBarry Smith EXTERN int MatZeroEntries(Mat);
385268466fbSBarry Smith EXTERN int MatZeroRows(Mat,IS,const PetscScalar*);
386268466fbSBarry Smith EXTERN int MatZeroColumns(Mat,IS,const PetscScalar*);
3877b80b807SBarry Smith 
388ca44d042SBarry Smith EXTERN int MatUseScaledForm(Mat,PetscTruth);
389ca44d042SBarry Smith EXTERN int MatScaleSystem(Mat,Vec,Vec);
390ca44d042SBarry Smith EXTERN int MatUnScaleSystem(Mat,Vec,Vec);
3915ef9f2a5SBarry Smith 
392ca44d042SBarry Smith EXTERN int MatGetSize(Mat,int*,int*);
393ca44d042SBarry Smith EXTERN int MatGetLocalSize(Mat,int*,int*);
394ca44d042SBarry Smith EXTERN int MatGetOwnershipRange(Mat,int*,int*);
3957b80b807SBarry Smith 
396d91e6319SBarry Smith /*E
397d91e6319SBarry Smith     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
398d91e6319SBarry Smith      or MatGetSubMatrix() are to be reused to store the new matrix values.
399d91e6319SBarry Smith 
400d91e6319SBarry Smith     Level: beginner
401d91e6319SBarry Smith 
402d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
403d91e6319SBarry Smith 
404d91e6319SBarry Smith .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices()
405d91e6319SBarry Smith E*/
4067b2a1423SBarry Smith typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;
407268466fbSBarry Smith EXTERN int MatGetSubMatrices(Mat,int,const IS[],const IS[],MatReuse,Mat *[]);
408268466fbSBarry Smith EXTERN int MatDestroyMatrices(int,Mat *[]);
409ca44d042SBarry Smith EXTERN int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *);
4108efafbd8SBarry Smith 
411268466fbSBarry Smith EXTERN int MatIncreaseOverlap(Mat,int,IS[],int);
4127b80b807SBarry Smith 
413268466fbSBarry Smith EXTERN int MatAXPY(const PetscScalar *,Mat,Mat,MatStructure);
414268466fbSBarry Smith EXTERN int MatAYPX(const PetscScalar *,Mat,Mat);
415ca44d042SBarry Smith EXTERN int MatCompress(Mat);
4167b80b807SBarry Smith 
417268466fbSBarry Smith EXTERN int MatScale(const PetscScalar *,Mat);
418268466fbSBarry Smith EXTERN int MatShift(const PetscScalar *,Mat);
419052efed2SBarry Smith 
420ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
421ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
422268466fbSBarry Smith EXTERN int MatZeroRowsLocal(Mat,IS,const PetscScalar*);
423f15d580aSBarry Smith EXTERN int MatSetValuesLocal(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode);
424f15d580aSBarry Smith EXTERN int MatSetValuesBlockedLocal(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode);
42590f02eecSBarry Smith 
4261ecfd215SBarry Smith EXTERN int MatStashSetInitialSize(Mat,int,int);
4271ecfd215SBarry Smith EXTERN int MatStashGetInfo(Mat,int*,int*,int*,int*);
428649db694SBarry Smith 
429ca44d042SBarry Smith EXTERN int MatInterpolateAdd(Mat,Vec,Vec,Vec);
430ca44d042SBarry Smith EXTERN int MatInterpolate(Mat,Vec,Vec);
431ca44d042SBarry Smith EXTERN int MatRestrict(Mat,Vec,Vec);
43223ce1328SBarry Smith EXTERN int MatGetVecs(Mat,Vec*,Vec*);
433bd481603SBarry Smith 
434bd481603SBarry Smith /*MC
435bd481603SBarry Smith    MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per
436bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
437bd481603SBarry Smith 
438bd481603SBarry Smith    Synopsis:
439bd481603SBarry Smith    int MatPreallocateInitialize(MPI_Comm comm, int nrows, int ncols, int *dnz, int *onz)
440bd481603SBarry Smith 
441bd481603SBarry Smith    Collective on MPI_Comm
442bd481603SBarry Smith 
443bd481603SBarry Smith    Input Parameters:
444bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
445bd481603SBarry Smith .  nrows - the number of rows in the matrix
446bd481603SBarry Smith -  ncols - the number of columns in the matrix
447bd481603SBarry Smith 
448bd481603SBarry Smith    Output Parameters:
449bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
450bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
451bd481603SBarry Smith 
452bd481603SBarry Smith 
453bd481603SBarry Smith    Level: intermediate
454bd481603SBarry Smith 
455bd481603SBarry Smith    Notes:
456bd481603SBarry Smith    See the chapter in the users manual on performance for more details
457bd481603SBarry Smith 
4581d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
459bd481603SBarry Smith 
460bd481603SBarry Smith    Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices)
461bd481603SBarry Smith 
462bd481603SBarry Smith   Concepts: preallocation^Matrix
463bd481603SBarry Smith 
464bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
465bd481603SBarry Smith           MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal()
466bd481603SBarry Smith M*/
467c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
4687c922b88SBarry Smith { \
469ef66eb69SBarry Smith   int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
470ef66eb69SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
471ef66eb69SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\
472ef66eb69SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\
473ef66eb69SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
4747c922b88SBarry Smith 
475bd481603SBarry Smith /*MC
476bd481603SBarry Smith    MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per
477bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
478bd481603SBarry Smith 
479bd481603SBarry Smith    Synopsis:
480bd481603SBarry Smith    int MatPreallocateSymmetricInitialize(MPI_Comm comm, int nrows, int ncols, int *dnz, int *onz)
481bd481603SBarry Smith 
482bd481603SBarry Smith    Collective on MPI_Comm
483bd481603SBarry Smith 
484bd481603SBarry Smith    Input Parameters:
485bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
486bd481603SBarry Smith .  nrows - the number of rows in the matrix
487bd481603SBarry Smith -  ncols - the number of columns in the matrix
488bd481603SBarry Smith 
489bd481603SBarry Smith    Output Parameters:
490bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
491bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
492bd481603SBarry Smith 
493bd481603SBarry Smith 
494bd481603SBarry Smith    Level: intermediate
495bd481603SBarry Smith 
496bd481603SBarry Smith    Notes:
497bd481603SBarry Smith    See the chapter in the users manual on performance for more details
498bd481603SBarry Smith 
4991d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
500bd481603SBarry Smith 
501bd481603SBarry Smith   Concepts: preallocation^Matrix
502bd481603SBarry Smith 
503bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
504bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
505bd481603SBarry Smith M*/
506222b16d4SBarry Smith #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \
507222b16d4SBarry Smith { \
508222b16d4SBarry Smith   int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__end; \
509222b16d4SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
510222b16d4SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\
511222b16d4SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\
512222b16d4SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
513222b16d4SBarry Smith 
514bd481603SBarry Smith /*MC
515bd481603SBarry Smith    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
516bd481603SBarry Smith        inserted using a local number of the rows and columns
517bd481603SBarry Smith 
518bd481603SBarry Smith    Synopsis:
519bd481603SBarry Smith    int MatPreallocateSetLocal(ISLocalToGlobalMappping map,int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
520bd481603SBarry Smith 
521bd481603SBarry Smith    Not Collective
522bd481603SBarry Smith 
523bd481603SBarry Smith    Input Parameters:
524bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
525bd481603SBarry Smith .  nrows - the number of rows indicated
5261d73ed98SBarry Smith .  rows - the indices of the rows
527bd481603SBarry Smith .  ncols - the number of columns in the matrix
528bd481603SBarry Smith .  cols - the columns indicated
529bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
530bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
531bd481603SBarry Smith 
532bd481603SBarry Smith 
533bd481603SBarry Smith    Level: intermediate
534bd481603SBarry Smith 
535bd481603SBarry Smith    Notes:
536bd481603SBarry Smith    See the chapter in the users manual on performance for more details
537bd481603SBarry Smith 
5381d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
539bd481603SBarry Smith 
540bd481603SBarry Smith   Concepts: preallocation^Matrix
541bd481603SBarry Smith 
542bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
543bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
544bd481603SBarry Smith M*/
545c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
546c4f061fbSSatish Balay {\
547c4f061fbSSatish Balay   int __l;\
548ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
549ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
550c4f061fbSSatish Balay   for (__l=0;__l<nrows;__l++) {\
551ef66eb69SBarry Smith     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
552c4f061fbSSatish Balay   }\
553c4f061fbSSatish Balay }
554c4f061fbSSatish Balay 
555bd481603SBarry Smith /*MC
556bd481603SBarry Smith    MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
557bd481603SBarry Smith        inserted using a local number of the rows and columns
558bd481603SBarry Smith 
559bd481603SBarry Smith    Synopsis:
560bd481603SBarry Smith    int MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
561bd481603SBarry Smith 
562bd481603SBarry Smith    Not Collective
563bd481603SBarry Smith 
564bd481603SBarry Smith    Input Parameters:
565bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
566bd481603SBarry Smith .  nrows - the number of rows indicated
5671d73ed98SBarry Smith .  rows - the indices of the rows
568bd481603SBarry Smith .  ncols - the number of columns in the matrix
569bd481603SBarry Smith .  cols - the columns indicated
570bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
571bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
572bd481603SBarry Smith 
573bd481603SBarry Smith 
574bd481603SBarry Smith    Level: intermediate
575bd481603SBarry Smith 
576bd481603SBarry Smith    Notes:
577bd481603SBarry Smith    See the chapter in the users manual on performance for more details
578bd481603SBarry Smith 
579bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
580bd481603SBarry Smith 
581bd481603SBarry Smith   Concepts: preallocation^Matrix
582bd481603SBarry Smith 
583bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
584bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
585bd481603SBarry Smith M*/
586d3d32019SBarry Smith #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
587d3d32019SBarry Smith {\
588d3d32019SBarry Smith   int __l;\
589d3d32019SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
590d3d32019SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
591d3d32019SBarry Smith   for (__l=0;__l<nrows;__l++) {\
592d3d32019SBarry Smith     _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
593d3d32019SBarry Smith   }\
594d3d32019SBarry Smith }
595d3d32019SBarry Smith 
596bd481603SBarry Smith /*MC
597bd481603SBarry Smith    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
598bd481603SBarry Smith        inserted using a local number of the rows and columns
599bd481603SBarry Smith 
600bd481603SBarry Smith    Synopsis:
601bd481603SBarry Smith    int MatPreallocateSet(int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
602bd481603SBarry Smith 
603bd481603SBarry Smith    Not Collective
604bd481603SBarry Smith 
605bd481603SBarry Smith    Input Parameters:
606bd481603SBarry Smith +  nrows - the number of rows indicated
6071d73ed98SBarry Smith .  rows - the indices of the rows
608bd481603SBarry Smith .  ncols - the number of columns in the matrix
609bd481603SBarry Smith .  cols - the columns indicated
610bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
611bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
612bd481603SBarry Smith 
613bd481603SBarry Smith 
614bd481603SBarry Smith    Level: intermediate
615bd481603SBarry Smith 
616bd481603SBarry Smith    Notes:
617bd481603SBarry Smith    See the chapter in the users manual on performance for more details
618bd481603SBarry Smith 
619bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
620bd481603SBarry Smith 
621bd481603SBarry Smith   Concepts: preallocation^Matrix
622bd481603SBarry Smith 
623bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
624bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
625bd481603SBarry Smith M*/
626c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
6277c922b88SBarry Smith { int __i; \
6287c922b88SBarry Smith   for (__i=0; __i<nc; __i++) {\
6297c922b88SBarry Smith     if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \
6307c922b88SBarry Smith   }\
6317c922b88SBarry Smith   dnz[row - __rstart] = nc - onz[row - __rstart];\
6327c922b88SBarry Smith }
6337c922b88SBarry Smith 
634bd481603SBarry Smith /*MC
635bd481603SBarry Smith    MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
636bd481603SBarry Smith        inserted using a local number of the rows and columns
637bd481603SBarry Smith 
638bd481603SBarry Smith    Synopsis:
639bd481603SBarry Smith    int MatPreallocateSymmetricSet(int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
640bd481603SBarry Smith 
641bd481603SBarry Smith    Not Collective
642bd481603SBarry Smith 
643bd481603SBarry Smith    Input Parameters:
644bd481603SBarry Smith +  nrows - the number of rows indicated
6451d73ed98SBarry Smith .  rows - the indices of the rows
646bd481603SBarry Smith .  ncols - the number of columns in the matrix
647bd481603SBarry Smith .  cols - the columns indicated
648bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
649bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
650bd481603SBarry Smith 
651bd481603SBarry Smith 
652bd481603SBarry Smith    Level: intermediate
653bd481603SBarry Smith 
654bd481603SBarry Smith    Notes:
655bd481603SBarry Smith    See the chapter in the users manual on performance for more details
656bd481603SBarry Smith 
657bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
658bd481603SBarry Smith 
659bd481603SBarry Smith   Concepts: preallocation^Matrix
660bd481603SBarry Smith 
661bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
662bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
663bd481603SBarry Smith M*/
664d3d32019SBarry Smith #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\
665d3d32019SBarry Smith { int __i; \
666d3d32019SBarry Smith   for (__i=0; __i<nc; __i++) {\
667d3d32019SBarry Smith     if (cols[__i] >= __end) onz[row - __rstart]++; \
668d3d32019SBarry Smith     else if (cols[__i] >= row) dnz[row - __rstart]++;\
669d3d32019SBarry Smith   }\
670d3d32019SBarry Smith }
671d3d32019SBarry Smith 
672bd481603SBarry Smith /*MC
673bd481603SBarry Smith    MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per
674bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
675bd481603SBarry Smith 
676bd481603SBarry Smith    Synopsis:
677bd481603SBarry Smith    int MatPreallocateFinalize(int *dnz, int *onz)
678bd481603SBarry Smith 
679bd481603SBarry Smith    Collective on MPI_Comm
680bd481603SBarry Smith 
681bd481603SBarry Smith    Input Parameters:
682bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
683bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
684bd481603SBarry Smith 
685bd481603SBarry Smith 
686bd481603SBarry Smith    Level: intermediate
687bd481603SBarry Smith 
688bd481603SBarry Smith    Notes:
689bd481603SBarry Smith    See the chapter in the users manual on performance for more details
690bd481603SBarry Smith 
691bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
692bd481603SBarry Smith 
693bd481603SBarry Smith   Concepts: preallocation^Matrix
694bd481603SBarry Smith 
695bd481603SBarry Smith .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
696bd481603SBarry Smith           MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal()
697bd481603SBarry Smith M*/
698ef66eb69SBarry Smith #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);}
6997c922b88SBarry Smith 
700bd481603SBarry Smith 
701bd481603SBarry Smith 
7027b80b807SBarry Smith /* Routines unique to particular data structures */
703435da068SBarry Smith EXTERN int MatShellGetContext(Mat,void **);
704435da068SBarry Smith 
705268466fbSBarry Smith EXTERN int MatBDiagGetData(Mat,int*,int*,int*[],int*[],PetscScalar***);
706ca01db9bSBarry Smith EXTERN int MatSeqAIJSetColumnIndices(Mat,int[]);
707ca01db9bSBarry Smith EXTERN int MatSeqBAIJSetColumnIndices(Mat,int[]);
708ca01db9bSBarry Smith EXTERN int MatCreateSeqAIJWithArrays(MPI_Comm,int,int,int[],int[],PetscScalar[],Mat*);
7097b80b807SBarry Smith 
710ca01db9bSBarry Smith EXTERN int MatSeqBAIJSetPreallocation(Mat,int,int,const int[]);
711ca01db9bSBarry Smith EXTERN int MatSeqSBAIJSetPreallocation(Mat,int,int,const int[]);
712ca01db9bSBarry Smith EXTERN int MatSeqAIJSetPreallocation(Mat,int,const int[]);
713ca01db9bSBarry Smith EXTERN int MatSeqDensePreallocation(Mat,PetscScalar[]);
714ca01db9bSBarry Smith EXTERN int MatSeqBDiagSetPreallocation(Mat,int,int,const int[],PetscScalar*[]);
715ca01db9bSBarry Smith EXTERN int MatSeqDenseSetPreallocation(Mat,PetscScalar[]);
716273d9f13SBarry Smith 
717ca01db9bSBarry Smith EXTERN int MatMPIBAIJSetPreallocation(Mat,int,int,const int[],int,const int[]);
718ca01db9bSBarry Smith EXTERN int MatMPISBAIJSetPreallocation(Mat,int,int,const int[],int,const int[]);
719ca01db9bSBarry Smith EXTERN int MatMPIAIJSetPreallocation(Mat,int,const int[],int,const int[]);
720ca01db9bSBarry Smith EXTERN int MatMPIDensePreallocation(Mat,PetscScalar[]);
721ca01db9bSBarry Smith EXTERN int MatMPIBDiagSetPreallocation(Mat,int,int,const int[],PetscScalar*[]);
722ca01db9bSBarry Smith EXTERN int MatMPIAdjSetPreallocation(Mat,int[],int[],int[]);
723ca01db9bSBarry Smith EXTERN int MatMPIDenseSetPreallocation(Mat,PetscScalar[]);
724ca01db9bSBarry Smith EXTERN int MatMPIRowbsSetPreallocation(Mat,int,const int[]);
725268466fbSBarry Smith EXTERN int MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,int*[]);
726268466fbSBarry Smith EXTERN int MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,int*[]);
7273a7fca6bSBarry Smith EXTERN int MatAdicSetLocalFunction(Mat,void (*)(void));
728273d9f13SBarry Smith 
7291b807ce4Svictorle EXTERN int MatSeqDenseSetLDA(Mat,int);
7301b807ce4Svictorle 
731ca44d042SBarry Smith EXTERN int MatStoreValues(Mat);
732ca44d042SBarry Smith EXTERN int MatRetrieveValues(Mat);
7332e8a6d31SBarry Smith 
7343a7fca6bSBarry Smith EXTERN int MatDAADSetCtx(Mat,void*);
7353a7fca6bSBarry Smith 
7367b80b807SBarry Smith /*
7377b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
73894b7f48cSBarry Smith   done through the KSP and PC interfaces.
7397b80b807SBarry Smith */
7407b80b807SBarry Smith 
741d9274352SBarry Smith /*E
742d9274352SBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
743d9274352SBarry Smith        with an optional dynamic library name, for example
744d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()
745d9274352SBarry Smith 
746d9274352SBarry Smith    Level: beginner
747d9274352SBarry Smith 
748d9274352SBarry Smith .seealso: MatGetOrdering()
749d9274352SBarry Smith E*/
75049773a63SBarry Smith #define MatOrderingType char*
751b12f92e5SBarry Smith #define MATORDERING_NATURAL   "natural"
752b12f92e5SBarry Smith #define MATORDERING_ND        "nd"
753b12f92e5SBarry Smith #define MATORDERING_1WD       "1wd"
754b12f92e5SBarry Smith #define MATORDERING_RCM       "rcm"
755b12f92e5SBarry Smith #define MATORDERING_QMD       "qmd"
756b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength"
75762152c8bSBarry Smith #define MATORDERING_DSC_ND    "dsc_nd"
75862152c8bSBarry Smith #define MATORDERING_DSC_MMD   "dsc_mmd"
75962152c8bSBarry Smith #define MATORDERING_DSC_MDF   "dsc_mdf"
760c06d978dSMatthew Knepley #define MATORDERING_CONSTRAINED "constrained"
761c06d978dSMatthew Knepley #define MATORDERING_IDENTITY  "identity"
762c06d978dSMatthew Knepley #define MATORDERING_REVERSE   "reverse"
763b12f92e5SBarry Smith 
764beff0ce9SBarry Smith EXTERN int MatGetOrdering(Mat,const MatOrderingType,IS*,IS*);
765234db7c0SBarry Smith EXTERN int MatOrderingRegister(const char[],const char[],const char[],int(*)(Mat,const MatOrderingType,IS*,IS*));
76630de9b25SBarry Smith 
76730de9b25SBarry Smith /*MC
76830de9b25SBarry Smith    MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the
76930de9b25SBarry Smith                                matrix package.
77030de9b25SBarry Smith 
77130de9b25SBarry Smith    Synopsis:
77230de9b25SBarry Smith    int MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,int (*routine_create)(MatOrdering))
77330de9b25SBarry Smith 
77430de9b25SBarry Smith    Not Collective
77530de9b25SBarry Smith 
77630de9b25SBarry Smith    Input Parameters:
77730de9b25SBarry Smith +  sname - name of ordering (for example MATORDERING_ND)
77830de9b25SBarry Smith .  path - location of library where creation routine is
77930de9b25SBarry Smith .  name - name of function that creates the ordering type,a string
78030de9b25SBarry Smith -  function - function pointer that creates the ordering
78130de9b25SBarry Smith 
78230de9b25SBarry Smith    Level: developer
78330de9b25SBarry Smith 
78430de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
78530de9b25SBarry Smith    is ignored.
78630de9b25SBarry Smith 
78730de9b25SBarry Smith    Sample usage:
78830de9b25SBarry Smith .vb
78930de9b25SBarry Smith    MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a,
79030de9b25SBarry Smith                "MyOrder",MyOrder);
79130de9b25SBarry Smith .ve
79230de9b25SBarry Smith 
79330de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
79430de9b25SBarry Smith $     MatOrderingSetType(part,"my_order)
79530de9b25SBarry Smith    or at runtime via the option
79630de9b25SBarry Smith $     -pc_ilu_mat_ordering_type my_order
79730de9b25SBarry Smith $     -pc_lu_mat_ordering_type my_order
79830de9b25SBarry Smith 
79930de9b25SBarry Smith    ${PETSC_ARCH} and ${BOPT} occuring in pathname will be replaced with appropriate values.
80030de9b25SBarry Smith 
80130de9b25SBarry Smith .keywords: matrix, ordering, register
80230de9b25SBarry Smith 
80330de9b25SBarry Smith .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll()
80430de9b25SBarry Smith M*/
805aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
806f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
807b12f92e5SBarry Smith #else
808f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
809b12f92e5SBarry Smith #endif
81030de9b25SBarry Smith 
811ca44d042SBarry Smith EXTERN int        MatOrderingRegisterDestroy(void);
8120e33f6ddSBarry Smith EXTERN int        MatOrderingRegisterAll(const char[]);
8132bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled;
814b0a32e0cSBarry Smith extern PetscFList MatOrderingList;
815d4fbbf0eSBarry Smith 
81687828ca2SBarry Smith EXTERN int MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);
817a2ce50c7SBarry Smith 
818d91e6319SBarry Smith /*S
81915e8a5b3SHong Zhang    MatFactorInfo - Data based into the matrix factorization routines
820b00f7748SHong Zhang 
82115e8a5b3SHong Zhang    In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE
822b00f7748SHong Zhang 
82315e8a5b3SHong Zhang    Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC.
824b00f7748SHong Zhang 
825b00f7748SHong Zhang    Level: developer
826b00f7748SHong Zhang 
827b380c88cSHong Zhang .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor()
828b00f7748SHong Zhang 
829b00f7748SHong Zhang S*/
830b00f7748SHong Zhang typedef struct {
83115e8a5b3SHong Zhang   PetscReal     damping;        /* scaling of identity added to matrix to prevent zero pivots */
8322cea7109SBarry Smith   PetscReal     shift;          /* if true, shift until positive pivots */
8332cea7109SBarry Smith   PetscReal     shift_fraction; /* record shift fraction taken */
83415e8a5b3SHong Zhang   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
83515e8a5b3SHong Zhang   PetscReal     dt;             /* drop tolerance */
836b00f7748SHong Zhang   PetscReal     dtcol;          /* tolerance for pivoting */
83715e8a5b3SHong Zhang   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
838f6275e2eSBarry Smith   PetscReal     fill;           /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
839348344bbSBarry Smith   PetscReal     levels;         /* ICC/ILU(levels) */
840bcd9e38bSBarry Smith   PetscReal     pivotinblocks;  /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
841bcd9e38bSBarry Smith                                    factorization may be faster if do not pivot */
84215e8a5b3SHong Zhang   PetscReal     zeropivot;      /* pivot is called zero if less than this */
84315e8a5b3SHong Zhang } MatFactorInfo;
844ffa6d0a5SLois Curfman McInnes 
84515e8a5b3SHong Zhang EXTERN int MatCholeskyFactor(Mat,IS,MatFactorInfo*);
84615e8a5b3SHong Zhang EXTERN int MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
84715e8a5b3SHong Zhang EXTERN int MatCholeskyFactorNumeric(Mat,Mat*);
848b380c88cSHong Zhang EXTERN int MatLUFactor(Mat,IS,IS,MatFactorInfo*);
849b380c88cSHong Zhang EXTERN int MatILUFactor(Mat,IS,IS,MatFactorInfo*);
850b380c88cSHong Zhang EXTERN int MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
851b380c88cSHong Zhang EXTERN int MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
85215e8a5b3SHong Zhang EXTERN int MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
85315e8a5b3SHong Zhang EXTERN int MatICCFactor(Mat,IS,MatFactorInfo*);
854ca44d042SBarry Smith EXTERN int MatLUFactorNumeric(Mat,Mat*);
855b380c88cSHong Zhang EXTERN int MatILUDTFactor(Mat,MatFactorInfo*,IS,IS,Mat *);
8563e0d88b5SBarry Smith EXTERN int MatGetInertia(Mat,int*,int*,int*);
857ca44d042SBarry Smith EXTERN int MatSolve(Mat,Vec,Vec);
858ca44d042SBarry Smith EXTERN int MatForwardSolve(Mat,Vec,Vec);
859ca44d042SBarry Smith EXTERN int MatBackwardSolve(Mat,Vec,Vec);
860ca44d042SBarry Smith EXTERN int MatSolveAdd(Mat,Vec,Vec,Vec);
861ca44d042SBarry Smith EXTERN int MatSolveTranspose(Mat,Vec,Vec);
862ca44d042SBarry Smith EXTERN int MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
863d59c15a7SBarry Smith EXTERN int MatSolves(Mat,Vecs,Vecs);
8648ed539a5SBarry Smith 
865ca44d042SBarry Smith EXTERN int MatSetUnfactored(Mat);
866bb5a7306SBarry Smith 
867d91e6319SBarry Smith /*E
868d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
869bb1eb677SSatish Balay 
870d91e6319SBarry Smith     Level: beginner
871d91e6319SBarry Smith 
872d9274352SBarry Smith    May be bitwise ORd together
873d9274352SBarry Smith 
874d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
875d91e6319SBarry Smith 
8764e7234bfSBarry Smith    MatSORType may be bitwise ORd together, so do not change the numbers
8774e7234bfSBarry Smith 
878a1d92eedSBarry Smith .seealso: MatRelax(), MatPBRelax()
879d91e6319SBarry Smith E*/
880ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
881ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
882ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
88384cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
884c14dc6b6SHong Zhang EXTERN int MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,int,int,Vec);
885a1d92eedSBarry Smith EXTERN int MatPBRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,int,int,Vec);
8868ed539a5SBarry Smith 
887d4fbbf0eSBarry Smith /*
888639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
889639f9d9dSBarry Smith */
890b12f92e5SBarry Smith 
891d9274352SBarry Smith /*E
892d9274352SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
893d9274352SBarry Smith        with an optional dynamic library name, for example
894d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()
895d9274352SBarry Smith 
896d9274352SBarry Smith    Level: beginner
897d9274352SBarry Smith 
898d9274352SBarry Smith .seealso: MatGetColoring()
899d9274352SBarry Smith E*/
90049773a63SBarry Smith #define MatColoringType char*
901b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural"
902b12f92e5SBarry Smith #define MATCOLORING_SL      "sl"
903b12f92e5SBarry Smith #define MATCOLORING_LF      "lf"
904b12f92e5SBarry Smith #define MATCOLORING_ID      "id"
905b12f92e5SBarry Smith 
906234db7c0SBarry Smith EXTERN int MatGetColoring(Mat,const MatColoringType,ISColoring*);
907234db7c0SBarry Smith EXTERN int MatColoringRegister(const char[],const char[],const char[],int(*)(Mat,const MatColoringType,ISColoring *));
90830de9b25SBarry Smith 
90930de9b25SBarry Smith /*MC
91030de9b25SBarry Smith    MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the
91130de9b25SBarry Smith                                matrix package.
91230de9b25SBarry Smith 
91330de9b25SBarry Smith    Synopsis:
91430de9b25SBarry Smith    int MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,int (*routine_create)(MatColoring))
91530de9b25SBarry Smith 
91630de9b25SBarry Smith    Not Collective
91730de9b25SBarry Smith 
91830de9b25SBarry Smith    Input Parameters:
91930de9b25SBarry Smith +  sname - name of Coloring (for example MATCOLORING_SL)
92030de9b25SBarry Smith .  path - location of library where creation routine is
92130de9b25SBarry Smith .  name - name of function that creates the Coloring type, a string
92230de9b25SBarry Smith -  function - function pointer that creates the coloring
92330de9b25SBarry Smith 
92430de9b25SBarry Smith    Level: developer
92530de9b25SBarry Smith 
92630de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
92730de9b25SBarry Smith    is ignored.
92830de9b25SBarry Smith 
92930de9b25SBarry Smith    Sample usage:
93030de9b25SBarry Smith .vb
93130de9b25SBarry Smith    MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a,
93230de9b25SBarry Smith                "MyColor",MyColor);
93330de9b25SBarry Smith .ve
93430de9b25SBarry Smith 
93530de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
93630de9b25SBarry Smith $     MatColoringSetType(part,"my_color")
93730de9b25SBarry Smith    or at runtime via the option
93830de9b25SBarry Smith $     -mat_coloring_type my_color
93930de9b25SBarry Smith 
94030de9b25SBarry Smith    $PETSC_ARCH and $BOPT occuring in pathname will be replaced with appropriate values.
94130de9b25SBarry Smith 
94230de9b25SBarry Smith .keywords: matrix, Coloring, register
94330de9b25SBarry Smith 
94430de9b25SBarry Smith .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll()
94530de9b25SBarry Smith M*/
946aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
947f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
948b12f92e5SBarry Smith #else
949f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
950b12f92e5SBarry Smith #endif
95130de9b25SBarry Smith 
9520e33f6ddSBarry Smith EXTERN int        MatColoringRegisterAll(const char[]);
9532bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled;
954ca44d042SBarry Smith EXTERN int        MatColoringRegisterDestroy(void);
9554e7234bfSBarry Smith EXTERN int        MatColoringPatch(Mat,int,int,const ISColoringValue[],ISColoring*);
956639f9d9dSBarry Smith 
957d9274352SBarry Smith /*S
958d9274352SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences
959d9274352SBarry Smith         and coloring
960639f9d9dSBarry Smith 
961d9274352SBarry Smith    Level: beginner
962d9274352SBarry Smith 
963d9274352SBarry Smith   Concepts: coloring, sparse Jacobian, finite differences
964d9274352SBarry Smith 
965d9274352SBarry Smith .seealso:  MatFDColoringCreate()
966d9274352SBarry Smith S*/
967e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
968639f9d9dSBarry Smith 
969ca44d042SBarry Smith EXTERN int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
970ca44d042SBarry Smith EXTERN int MatFDColoringDestroy(MatFDColoring);
971b0a32e0cSBarry Smith EXTERN int MatFDColoringView(MatFDColoring,PetscViewer);
972ca44d042SBarry Smith EXTERN int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*);
97387828ca2SBarry Smith EXTERN int MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
974ca44d042SBarry Smith EXTERN int MatFDColoringSetFrequency(MatFDColoring,int);
975ca44d042SBarry Smith EXTERN int MatFDColoringGetFrequency(MatFDColoring,int*);
976ca44d042SBarry Smith EXTERN int MatFDColoringSetFromOptions(MatFDColoring);
977ca44d042SBarry Smith EXTERN int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
97887828ca2SBarry Smith EXTERN int MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *);
97962152c8bSBarry Smith EXTERN int MatFDColoringSetRecompute(MatFDColoring);
9803a7fca6bSBarry Smith EXTERN int MatFDColoringSetF(MatFDColoring,Vec);
9814e7234bfSBarry Smith EXTERN int MatFDColoringGetPerturbedColumns(MatFDColoring,int*,int*[]);
982639f9d9dSBarry Smith /*
9830752156aSBarry Smith     These routines are for partitioning matrices: currently used only
9843eda8832SBarry Smith   for adjacency matrix, MatCreateMPIAdj().
9850752156aSBarry Smith */
986ca161407SBarry Smith 
987d9274352SBarry Smith /*S
988d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
989d9274352SBarry Smith 
990d9274352SBarry Smith    Level: beginner
991d9274352SBarry Smith 
992d9274352SBarry Smith   Concepts: partitioning
993d9274352SBarry Smith 
994743a1026Svictorle .seealso:  MatPartitioningCreate(), MatPartitioningType
995d9274352SBarry Smith S*/
99691e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
997d9274352SBarry Smith 
998d9274352SBarry Smith /*E
9995bc6e7ccSvictorle     MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function
1000d9274352SBarry Smith        with an optional dynamic library name, for example
1001d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()
1002d9274352SBarry Smith 
1003d9274352SBarry Smith    Level: beginner
1004d9274352SBarry Smith 
1005b547a13bSvictorle .seealso: MatPartitioningCreate(), MatPartitioning
1006d9274352SBarry Smith E*/
100749773a63SBarry Smith #define MatPartitioningType char*
10088ba1e511SMatthew Knepley #define MAT_PARTITIONING_CURRENT  "current"
10098ba1e511SMatthew Knepley #define MAT_PARTITIONING_PARMETIS "parmetis"
101071306c60Sjroman #define MAT_PARTITIONING_CHACO    "chaco"
101171306c60Sjroman #define MAT_PARTITIONING_JOSTLE   "jostle"
101271306c60Sjroman #define MAT_PARTITIONING_PARTY    "party"
101371306c60Sjroman #define MAT_PARTITIONING_SCOTCH   "scotch"
101471306c60Sjroman 
1015ca161407SBarry Smith 
1016ca44d042SBarry Smith EXTERN int MatPartitioningCreate(MPI_Comm,MatPartitioning*);
10170e33f6ddSBarry Smith EXTERN int MatPartitioningSetType(MatPartitioning,const MatPartitioningType);
10185bc6e7ccSvictorle EXTERN int MatPartitioningSetNParts(MatPartitioning,int);
1019ca44d042SBarry Smith EXTERN int MatPartitioningSetAdjacency(MatPartitioning,Mat);
10204e7234bfSBarry Smith EXTERN int MatPartitioningSetVertexWeights(MatPartitioning,const int[]);
10214e7234bfSBarry Smith EXTERN int MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []);
1022ca44d042SBarry Smith EXTERN int MatPartitioningApply(MatPartitioning,IS*);
1023ca44d042SBarry Smith EXTERN int MatPartitioningDestroy(MatPartitioning);
10242aabb6bbSBarry Smith 
10250e33f6ddSBarry Smith EXTERN int MatPartitioningRegister(const char[],const char[],const char[],int(*)(MatPartitioning));
102630de9b25SBarry Smith 
102730de9b25SBarry Smith /*MC
102830de9b25SBarry Smith    MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the
102930de9b25SBarry Smith    matrix package.
103030de9b25SBarry Smith 
103130de9b25SBarry Smith    Synopsis:
103230de9b25SBarry Smith    int MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,int (*routine_create)(MatPartitioning))
103330de9b25SBarry Smith 
103430de9b25SBarry Smith    Not Collective
103530de9b25SBarry Smith 
103630de9b25SBarry Smith    Input Parameters:
103730de9b25SBarry Smith +  sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis
103830de9b25SBarry Smith .  path - location of library where creation routine is
103930de9b25SBarry Smith .  name - name of function that creates the partitioning type, a string
104030de9b25SBarry Smith -  function - function pointer that creates the partitioning type
104130de9b25SBarry Smith 
104230de9b25SBarry Smith    Level: developer
104330de9b25SBarry Smith 
104430de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
104530de9b25SBarry Smith    is ignored.
104630de9b25SBarry Smith 
104730de9b25SBarry Smith    Sample usage:
104830de9b25SBarry Smith .vb
104930de9b25SBarry Smith    MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a,
105030de9b25SBarry Smith                "MyPartCreate",MyPartCreate);
105130de9b25SBarry Smith .ve
105230de9b25SBarry Smith 
105330de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
105430de9b25SBarry Smith $     MatPartitioningSetType(part,"my_part")
105530de9b25SBarry Smith    or at runtime via the option
105630de9b25SBarry Smith $     -mat_partitioning_type my_part
105730de9b25SBarry Smith 
105830de9b25SBarry Smith    $PETSC_ARCH and $BOPT occuring in pathname will be replaced with appropriate values.
105930de9b25SBarry Smith 
106030de9b25SBarry Smith .keywords: matrix, partitioning, register
106130de9b25SBarry Smith 
106230de9b25SBarry Smith .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll()
106330de9b25SBarry Smith M*/
1064aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1065f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
10662aabb6bbSBarry Smith #else
1067f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
10682aabb6bbSBarry Smith #endif
10692aabb6bbSBarry Smith 
10700e33f6ddSBarry Smith EXTERN int        MatPartitioningRegisterAll(const char[]);
10712bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled;
1072ca44d042SBarry Smith EXTERN int        MatPartitioningRegisterDestroy(void);
10732bad1931SBarry Smith 
1074b0a32e0cSBarry Smith EXTERN int MatPartitioningView(MatPartitioning,PetscViewer);
1075ca44d042SBarry Smith EXTERN int MatPartitioningSetFromOptions(MatPartitioning);
1076ca44d042SBarry Smith EXTERN int MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
1077ca161407SBarry Smith 
1078ca44d042SBarry Smith EXTERN int MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
10790752156aSBarry Smith 
108071306c60Sjroman EXTERN int MatPartitioningJostleSetCoarseLevel(MatPartitioning,PetscReal);
108171306c60Sjroman EXTERN int MatPartitioningJostleSetCoarseSequential(MatPartitioning);
108271306c60Sjroman 
108371306c60Sjroman typedef enum { MP_CHACO_MULTILEVEL_KL, MP_CHACO_SPECTRAL, MP_CHACO_LINEAR,
108471306c60Sjroman     MP_CHACO_RANDOM, MP_CHACO_SCATTERED } MPChacoGlobalType;
108571306c60Sjroman EXTERN int MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
108671306c60Sjroman typedef enum { MP_CHACO_KERNIGHAN_LIN, MP_CHACO_NONE } MPChacoLocalType;
108771306c60Sjroman EXTERN int MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
108871306c60Sjroman EXTERN int MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal);
108971306c60Sjroman typedef enum { MP_CHACO_LANCZOS, MP_CHACO_RQI_SYMMLQ } MPChacoEigenType;
109071306c60Sjroman EXTERN int MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType);
109171306c60Sjroman EXTERN int MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
109271306c60Sjroman EXTERN int MatPartitioningChacoSetEigenNumber(MatPartitioning, int);
109371306c60Sjroman 
109471306c60Sjroman #define MP_PARTY_OPT "opt"
109571306c60Sjroman #define MP_PARTY_LIN "lin"
109671306c60Sjroman #define MP_PARTY_SCA "sca"
109771306c60Sjroman #define MP_PARTY_RAN "ran"
109871306c60Sjroman #define MP_PARTY_GBF "gbf"
109971306c60Sjroman #define MP_PARTY_GCF "gcf"
110071306c60Sjroman #define MP_PARTY_BUB "bub"
110171306c60Sjroman #define MP_PARTY_DEF "def"
110271306c60Sjroman EXTERN int MatPartitioningPartySetGlobal(MatPartitioning, const char*);
110371306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs"
110471306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl"
110571306c60Sjroman #define MP_PARTY_NONE "no"
110671306c60Sjroman EXTERN int MatPartitioningPartySetLocal(MatPartitioning, const char*);
110771306c60Sjroman EXTERN int MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal);
110871306c60Sjroman EXTERN int MatPartitioningPartySetBipart(MatPartitioning,PetscTruth);
110971306c60Sjroman EXTERN int MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscTruth);
111071306c60Sjroman 
111171306c60Sjroman typedef enum { MP_SCOTCH_GREEDY, MP_SCOTCH_GPS, MP_SCOTCH_GR_GPS } MPScotchGlobalType;
111271306c60Sjroman EXTERN int MatPartitioningScotchSetArch(MatPartitioning,const char*);
111371306c60Sjroman EXTERN int MatPartitioningScotchSetMultilevel(MatPartitioning);
111471306c60Sjroman EXTERN int MatPartitioningScotchSetGlobal(MatPartitioning,MPScotchGlobalType);
111571306c60Sjroman EXTERN int MatPartitioningScotchSetCoarseLevel(MatPartitioning,PetscReal);
111671306c60Sjroman EXTERN int MatPartitioningScotchSetHostList(MatPartitioning,const char*);
111771306c60Sjroman typedef enum { MP_SCOTCH_KERNIGHAN_LIN, MP_SCOTCH_NONE } MPScotchLocalType;
111871306c60Sjroman EXTERN int MatPartitioningScotchSetLocal(MatPartitioning,MPScotchLocalType);
111971306c60Sjroman EXTERN int MatPartitioningScotchSetMapping(MatPartitioning);
112071306c60Sjroman EXTERN int MatPartitioningScotchSetStrategy(MatPartitioning,char*);
112171306c60Sjroman 
11220752156aSBarry Smith /*
11230a835dfdSSatish Balay     If you add entries here you must also add them to finclude/petscmat.h
1124d4fbbf0eSBarry Smith */
11251c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
11261c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
11271c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
11281c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
11291c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
11307c922b88SBarry Smith                MATOP_MULT_TRANSPOSE=5,
11317c922b88SBarry Smith                MATOP_MULT_TRANSPOSE_ADD=6,
11321c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
11331c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
11347c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE=9,
11357c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE_ADD=10,
11361c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
11371c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
11381c1c02c0SLois Curfman McInnes                MATOP_RELAX=13,
11391c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
11401c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
11411c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
11421c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
11431c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
11441c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
11451c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
11461c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
11471c1c02c0SLois Curfman McInnes                MATOP_COMPRESS=22,
11481c1c02c0SLois Curfman McInnes                MATOP_SET_OPTION=23,
11491c1c02c0SLois Curfman McInnes                MATOP_ZERO_ENTRIES=24,
11501c1c02c0SLois Curfman McInnes                MATOP_ZERO_ROWS=25,
11511c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_SYMBOLIC=26,
11521c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_NUMERIC=27,
11531c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
11541c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
1155d643ce63SMatthew Knepley                MATOP_SETUP_PREALLOCATION=30,
1156d643ce63SMatthew Knepley                MATOP_ILUFACTOR_SYMBOLIC=31,
1157d643ce63SMatthew Knepley                MATOP_ICCFACTOR_SYMBOLIC=32,
1158d643ce63SMatthew Knepley                MATOP_GET_ARRAY=33,
1159d643ce63SMatthew Knepley                MATOP_RESTORE_ARRAY=34,
1160d643ce63SMatthew Knepley                MATOP_DUPLCIATE=35,
1161d643ce63SMatthew Knepley                MATOP_FORWARD_SOLVE=36,
1162d643ce63SMatthew Knepley                MATOP_BACKWARD_SOLVE=37,
1163d643ce63SMatthew Knepley                MATOP_ILUFACTOR=38,
1164d643ce63SMatthew Knepley                MATOP_ICCFACTOR=39,
1165d643ce63SMatthew Knepley                MATOP_AXPY=40,
1166d643ce63SMatthew Knepley                MATOP_GET_SUBMATRICES=41,
1167d643ce63SMatthew Knepley                MATOP_INCREASE_OVERLAP=42,
1168d643ce63SMatthew Knepley                MATOP_GET_VALUES=43,
1169d643ce63SMatthew Knepley                MATOP_COPY=44,
1170d643ce63SMatthew Knepley                MATOP_PRINT_HELP=45,
1171d643ce63SMatthew Knepley                MATOP_SCALE=46,
1172d643ce63SMatthew Knepley                MATOP_SHIFT=47,
1173d643ce63SMatthew Knepley                MATOP_DIAGONAL_SHIFT=48,
1174d643ce63SMatthew Knepley                MATOP_ILUDT_FACTOR=49,
1175d643ce63SMatthew Knepley                MATOP_GET_BLOCK_SIZE=50,
1176d643ce63SMatthew Knepley                MATOP_GET_ROW_IJ=51,
1177d643ce63SMatthew Knepley                MATOP_RESTORE_ROW_IJ=52,
1178d643ce63SMatthew Knepley                MATOP_GET_COLUMN_IJ=53,
1179d643ce63SMatthew Knepley                MATOP_RESTORE_COLUMN_IJ=54,
1180d643ce63SMatthew Knepley                MATOP_FDCOLORING_CREATE=55,
1181d643ce63SMatthew Knepley                MATOP_COLORING_PATCH=56,
1182d643ce63SMatthew Knepley                MATOP_SET_UNFACTORED=57,
1183d643ce63SMatthew Knepley                MATOP_PERMUTE=58,
1184d643ce63SMatthew Knepley                MATOP_SET_VALUES_BLOCKED=59,
1185d643ce63SMatthew Knepley                MATOP_GET_SUBMATRIX=60,
1186d643ce63SMatthew Knepley                MATOP_DESTROY=61,
1187d643ce63SMatthew Knepley                MATOP_VIEW=62,
1188d643ce63SMatthew Knepley                MATOP_GET_MAPS=63,
1189d643ce63SMatthew Knepley                MATOP_USE_SCALED_FORM=64,
1190d643ce63SMatthew Knepley                MATOP_SCALE_SYSTEM=65,
1191d643ce63SMatthew Knepley                MATOP_UNSCALE_SYSTEM=66,
1192d643ce63SMatthew Knepley                MATOP_SET_LOCAL_TO_GLOBAL_MAPPING=67,
1193d643ce63SMatthew Knepley                MATOP_SET_VALUES_LOCAL=68,
1194d643ce63SMatthew Knepley                MATOP_ZERO_ROWS_LOCAL=69,
1195d643ce63SMatthew Knepley                MATOP_GET_ROW_MAX=70,
1196d643ce63SMatthew Knepley                MATOP_CONVERT=71,
1197d643ce63SMatthew Knepley                MATOP_SET_COLORING=72,
1198d643ce63SMatthew Knepley                MATOP_SET_VALUES_ADIC=73,
1199d643ce63SMatthew Knepley                MATOP_SET_VALUES_ADIFOR=74,
1200d643ce63SMatthew Knepley                MATOP_FD_COLORING_APPLY=75,
1201d643ce63SMatthew Knepley                MATOP_SET_FROM_OPTIONS=76,
1202d643ce63SMatthew Knepley                MATOP_MULT_CONSTRAINED=77,
1203d643ce63SMatthew Knepley                MATOP_MULT_TRANSPOSE_CONSTRAINED=78,
1204d643ce63SMatthew Knepley                MATOP_ILU_FACTOR_SYMBOLIC_CONSTRAINED=79,
1205d643ce63SMatthew Knepley                MATOP_PERMUTE_SPARSIFY=80,
1206d643ce63SMatthew Knepley                MATOP_MULT_MULTIPLE=81,
1207d643ce63SMatthew Knepley                MATOP_SOLVE_MULTIPLE=82
1208fae171e0SBarry Smith              } MatOperation;
1209ca44d042SBarry Smith EXTERN int MatHasOperation(Mat,MatOperation,PetscTruth*);
1210ff8b7a98SSatish Balay EXTERN int MatShellSetOperation(Mat,MatOperation,void(*)(void));
1211ff8b7a98SSatish Balay EXTERN int MatShellGetOperation(Mat,MatOperation,void(**)(void));
1212273d9f13SBarry Smith EXTERN int MatShellSetContext(Mat,void*);
1213112a2221SBarry Smith 
121490ace30eSBarry Smith /*
121590ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
121690ace30eSBarry Smith  stored in a universal format. By changing the format with
1217fb9695e5SSatish Balay  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
121890ace30eSBarry Smith  be stored in a way natural for the matrix, for example dense matrices
121990ace30eSBarry Smith  would be stored as dense. Matrices stored this way may only be
122090ace30eSBarry Smith  read into matrices of the same time.
122190ace30eSBarry Smith */
122290ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
122390ace30eSBarry Smith 
12246d053be9SSatish Balay EXTERN int MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
1225ca44d042SBarry Smith EXTERN int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *);
122608918a0eSSatish Balay EXTERN int MatMPIRowbsGetColor(Mat,ISColoring *);
1227860d1616SSatish Balay 
12281f4e1ec7SBarry Smith EXTERN int MatISGetLocalMat(Mat,Mat*);
12291f4e1ec7SBarry Smith 
1230d9274352SBarry Smith /*S
1231d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
1232d9274352SBarry Smith          orthogonalizes the vector to a subsapce
1233d9274352SBarry Smith 
1234f7a9e4ceSBarry Smith    Level: advanced
1235d9274352SBarry Smith 
1236d9274352SBarry Smith   Concepts: matrix; linear operator, null space
1237d9274352SBarry Smith 
12386e1639daSBarry Smith   Users manual sections:
12396e1639daSBarry Smith .   sec_singular
12406e1639daSBarry Smith 
1241d9274352SBarry Smith .seealso:  MatNullSpaceCreate()
1242d9274352SBarry Smith S*/
124374637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace;
1244d9274352SBarry Smith 
12454e7234bfSBarry Smith EXTERN int MatNullSpaceCreate(MPI_Comm,int,int,const Vec[],MatNullSpace*);
124674637425SBarry Smith EXTERN int MatNullSpaceDestroy(MatNullSpace);
124774637425SBarry Smith EXTERN int MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
124874637425SBarry Smith EXTERN int MatNullSpaceAttach(Mat,MatNullSpace);
124974637425SBarry Smith EXTERN int MatNullSpaceTest(MatNullSpace,Mat);
125074637425SBarry Smith 
1251273d9f13SBarry Smith EXTERN int MatReorderingSeqSBAIJ(Mat A,IS isp);
1252273d9f13SBarry Smith EXTERN int MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
1253273d9f13SBarry Smith EXTERN int MatSeqSBAIJSetColumnIndices(Mat,int *);
1254273d9f13SBarry Smith 
12555c66b693SKris Buschelman EXTERN int MatMatMult(Mat A,Mat B, Mat *C);
12565c66b693SKris Buschelman EXTERN int MatMatMultSymbolic(Mat A,Mat B,Mat *C);
12575c66b693SKris Buschelman EXTERN int MatMatMultNumeric(Mat A,Mat B,Mat C);
12583f1d51d7SBarry Smith 
1259f069c275SSatish Balay EXTERN int MatCreateMAIJ(Mat,int,Mat*);
1260c4f061fbSSatish Balay EXTERN int MatMAIJRedimension(Mat,int,Mat*);
1261c4f061fbSSatish Balay EXTERN int MatMAIJGetAIJ(Mat,Mat*);
1262c4f061fbSSatish Balay 
1263b0a32e0cSBarry Smith EXTERN int MatComputeExplicitOperator(Mat,Mat*);
1264b0a32e0cSBarry Smith 
12650e33f6ddSBarry Smith EXTERN int MatESISetType(Mat,const char*);
126624a595ddSBarry Smith EXTERN int MatESISetFromOptions(Mat);
126724a595ddSBarry Smith 
12682cd6534aSBarry Smith EXTERN int MatDiagonalScaleLocal(Mat,Vec);
126904f1ad80SBarry Smith 
12707dbadf16SMatthew Knepley EXTERN int PetscViewerMathematicaPutMatrix(PetscViewer, int, int, PetscReal *);
12717dbadf16SMatthew Knepley EXTERN int PetscViewerMathematicaPutCSRMatrix(PetscViewer, int, int, int *, int *, PetscReal *);
12727dbadf16SMatthew Knepley 
12731f4e1ec7SBarry Smith EXTERN int MatSeqAIJPtAP(Mat,Mat,Mat*);
1274231952e2SKris Buschelman EXTERN int MatSeqAIJPtAPSymbolic(Mat,Mat,Mat*);
1275231952e2SKris Buschelman EXTERN int MatSeqAIJPtAPNumeric(Mat,Mat,Mat);
1276e82a3eeeSBarry Smith 
1277e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END
12782eac72dbSBarry Smith #endif
1279