xref: /petsc/include/petscmat.h (revision b12f92e593fe1f4640a94465c95bdce45bd620eb)
1*b12f92e5SBarry Smith /* $Id: mat.h,v 1.176 1999/04/02 15:05:18 bsmith Exp bsmith $ */
22eac72dbSBarry Smith /*
32eac72dbSBarry Smith      Include file for the matrix component of PETSc
42eac72dbSBarry Smith */
5a009ddc3SBarry Smith #ifndef __MAT_H
6a009ddc3SBarry Smith #define __MAT_H
78ed539a5SBarry Smith #include "vec.h"
82eac72dbSBarry Smith 
99cd28387SBarry Smith #define MAT_COOKIE         PETSC_COOKIE+5
10f0479e8cSBarry Smith 
11e2a1c21fSSatish Balay typedef struct _p_Mat*           Mat;
122eac72dbSBarry Smith 
13f1d1b154SWilliam Gropp #define MAX_MATRIX_TYPES 14
14639f9d9dSBarry Smith /*
15639f9d9dSBarry Smith    The default matrix data storage formats and routines to create them.
16f1d1b154SWilliam Gropp 
17f1d1b154SWilliam Gropp    MATLASTTYPE is "end-of-list" marker that can be used to check that
18f1d1b154SWilliam Gropp    MAX_MATRIX_TYPES is large enough.  The rule is
19f1d1b154SWilliam Gropp    MAX_MATRIX_TYPES >= MATLASTTYPE .
20f1d1b154SWilliam Gropp 
21f1d1b154SWilliam Gropp    To do: add a test program that checks the consistency of these values.
22639f9d9dSBarry Smith */
234ac9ca07SLois Curfman McInnes typedef enum { MATSAME=-1,  MATSEQDENSE, MATSEQAIJ,   MATMPIAIJ,   MATSHELL,
2484cb2905SBarry Smith                MATMPIROWBS, MATSEQBDIAG, MATMPIBDIAG, MATMPIDENSE, MATSEQBAIJ,
25f1d1b154SWilliam Gropp                MATMPIBAIJ,  MATMPICSN,   MATSEQCSN,   MATSEQADJ,   MATMPIADJ,
26f1d1b154SWilliam Gropp                MATLASTTYPE } MatType;
2728988994SBarry Smith 
28*b12f92e5SBarry Smith extern int MatCreate(MPI_Comm,int,int,int,int,Mat*);
29df6e0191SLois Curfman McInnes extern int MatCreateSeqDense(MPI_Comm,int,int,Scalar*,Mat*);
30d5bc1036SLois Curfman McInnes extern int MatCreateMPIDense(MPI_Comm,int,int,int,int,Scalar*,Mat*);
31de7da479SBarry Smith extern int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*);
329717bf64SBarry Smith extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
33cfe223acSLois Curfman McInnes extern int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,void*,Mat*);
34f26ada1bSBarry Smith extern int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,Scalar**,Mat*);
35f26ada1bSBarry Smith extern int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,Scalar**,Mat*);
36df8a92d1SBarry Smith extern int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
37eba03b66SLois Curfman McInnes extern int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*);
3882c9921cSBarry Smith extern int MatCreateSeqAdj(MPI_Comm,int,int,int*,int*,Mat *);
390752156aSBarry Smith extern int MatCreateMPIAdj(MPI_Comm,int,int,int*,int*,Mat*);
409717bf64SBarry Smith 
417b80b807SBarry Smith extern int MatDestroy(Mat);
427b80b807SBarry Smith 
437ddc982cSLois Curfman McInnes extern int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*);
4417116c71SBarry Smith extern int MatShellGetContext(Mat,void **);
4521c89e3eSBarry Smith 
46ec0117caSBarry Smith extern int MatPrintHelp(Mat);
47cda55fadSBarry Smith extern int MatGetMaps(Mat,Map*,Map*);
48ec0117caSBarry Smith 
498ed539a5SBarry Smith /* ------------------------------------------------------------*/
50ee50ffe9SBarry Smith extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
5195e63191SSatish Balay extern int MatSetValuesBlocked(Mat,int,int*,int,int*,Scalar*,InsertMode);
5284cb2905SBarry Smith 
536d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
54ee50ffe9SBarry Smith extern int MatAssemblyBegin(Mat,MatAssemblyType);
55ee50ffe9SBarry Smith extern int MatAssemblyEnd(Mat,MatAssemblyType);
56b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \
57b951964fSBarry Smith {int _ierr,_row = i,_col = j; Scalar _va = va; \
58b951964fSBarry Smith   _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
59b951964fSBarry Smith }
60ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \
61ea06a074SBarry Smith {int _ierr,_row = i,_col = j; \
62ea06a074SBarry Smith   _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \
63ea06a074SBarry Smith }
646ca9ecd3SBarry Smith /*
656ca9ecd3SBarry Smith    Any additions/changes here MUST also be made in include/finclude/mat.h
666ca9ecd3SBarry Smith */
676d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
686d4a8577SBarry Smith               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
696d4a8577SBarry Smith               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
706ca9ecd3SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
716ca9ecd3SBarry Smith               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
726ca9ecd3SBarry Smith               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
736ca9ecd3SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
744787f768SSatish Balay               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
754787f768SSatish Balay               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78} MatOption;
76ee50ffe9SBarry Smith extern int MatSetOption(Mat,MatOption);
774b0e389bSBarry Smith extern int MatGetType(Mat,MatType*,char**);
7856cd22aeSBarry Smith extern int MatGetTypeFromOptions(MPI_Comm,char*,MatType*,PetscTruth*);
7984cb2905SBarry Smith 
80ee50ffe9SBarry Smith extern int MatGetValues(Mat,int,int*,int,int*,Scalar*);
818ed539a5SBarry Smith extern int MatGetRow(Mat,int,int *,int **,Scalar**);
828ed539a5SBarry Smith extern int MatRestoreRow(Mat,int,int *,int **,Scalar**);
8377c4ece6SBarry Smith extern int MatGetColumn(Mat,int,int *,int **,Scalar**);
8477c4ece6SBarry Smith extern int MatRestoreColumn(Mat,int,int *,int **,Scalar**);
855cd4b4e6SBarry Smith extern int MatGetColumnVector(Mat,Vec,int);
8664e87e97SBarry Smith extern int MatGetArray(Mat,Scalar **);
8709883261SBarry Smith extern int MatRestoreArray(Mat,Scalar **);
88870582ebSSatish Balay extern int MatGetBlockSize(Mat,int *);
897b80b807SBarry Smith 
908ed539a5SBarry Smith extern int MatMult(Mat,Vec,Vec);
918ed539a5SBarry Smith extern int MatMultAdd(Mat,Vec,Vec,Vec);
928ed539a5SBarry Smith extern int MatMultTrans(Mat,Vec,Vec);
938ed539a5SBarry Smith extern int MatMultTransAdd(Mat,Vec,Vec,Vec);
942eac72dbSBarry Smith 
952e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES, MAT_COPY_VALUES} MatDuplicateOption;
962e8a6d31SBarry Smith 
977b80b807SBarry Smith extern int MatConvert(Mat,MatType,Mat*);
982e8a6d31SBarry Smith extern int MatDuplicate(Mat,MatDuplicateOption,Mat*);
9994a9d846SBarry Smith extern int MatConvertRegister(MatType,MatType,int (*)(Mat,MatType,Mat*));
100cf256101SBarry Smith extern int MatConvertRegisterAll(void);
10194a9d846SBarry Smith 
102cb5b572fSBarry Smith typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER} MatStructure;
103cb5b572fSBarry Smith 
104cb5b572fSBarry Smith extern int MatCopy(Mat,Mat,MatStructure);
1057b80b807SBarry Smith extern int MatView(Mat,Viewer);
1067b80b807SBarry Smith extern int MatLoad(Viewer,MatType,Mat*);
10794a9d846SBarry Smith extern int MatLoadRegister(MatType,int (*)(Viewer,MatType,Mat*));
108cf256101SBarry Smith extern int MatLoadRegisterAll(void);
1097b80b807SBarry Smith 
110d4fbbf0eSBarry Smith extern int MatGetRowIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
111d4fbbf0eSBarry Smith extern int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
112d4fbbf0eSBarry Smith extern int MatGetColumnIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
113d4fbbf0eSBarry Smith extern int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
114d4fbbf0eSBarry Smith 
1151d607229SLois Curfman McInnes /*
1161d607229SLois Curfman McInnes    Context of matrix information, used with MatGetInfo()
1171d607229SLois Curfman McInnes    Note: If any entries are added to this context, be sure
11826cd32c0SSatish Balay          to adjust MAT_INFO_SIZE in finclude/mat.h
1191d607229SLois Curfman McInnes  */
1204e220ebcSLois Curfman McInnes typedef struct {
12137f753daSBarry Smith   PLogDouble rows_global, columns_global;         /* number of global rows and columns */
12237f753daSBarry Smith   PLogDouble rows_local, columns_local;           /* number of local rows and columns */
12337f753daSBarry Smith   PLogDouble block_size;                          /* block size */
12437f753daSBarry Smith   PLogDouble nz_allocated, nz_used, nz_unneeded;  /* number of nonzeros */
12537f753daSBarry Smith   PLogDouble memory;                              /* memory allocated */
12637f753daSBarry Smith   PLogDouble assemblies;                          /* number of matrix assemblies */
12737f753daSBarry Smith   PLogDouble mallocs;                             /* number of mallocs during MatSetValues() */
12837f753daSBarry Smith   PLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */
12937f753daSBarry Smith   PLogDouble factor_mallocs;                      /* number of mallocs during factorization */
1304e220ebcSLois Curfman McInnes } MatInfo;
1314e220ebcSLois Curfman McInnes 
1327b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
1334e220ebcSLois Curfman McInnes extern int MatGetInfo(Mat,MatInfoType,MatInfo*);
13477c4ece6SBarry Smith extern int MatValid(Mat,PetscTruth*);
1357b80b807SBarry Smith extern int MatGetDiagonal(Mat,Vec);
136cd8486b4SBarry Smith extern int MatTranspose(Mat,Mat*);
1370513a670SBarry Smith extern int MatPermute(Mat,IS,IS,Mat *);
138f4c33d5aSBarry Smith extern int MatDiagonalScale(Mat,Vec,Vec);
1398b3e568eSBarry Smith extern int MatDiagonalShift(Mat,Vec);
14077c4ece6SBarry Smith extern int MatEqual(Mat,Mat, PetscTruth*);
1417b80b807SBarry Smith 
1427b80b807SBarry Smith extern int MatNorm(Mat,NormType,double *);
1437b80b807SBarry Smith extern int MatZeroEntries(Mat);
1447b80b807SBarry Smith extern int MatZeroRows(Mat,IS,Scalar*);
1457b80b807SBarry Smith extern int MatZeroColumns(Mat,IS,Scalar*);
1467b80b807SBarry Smith 
1475ef9f2a5SBarry Smith extern int MatUseScaledForm(Mat,PetscTruth);
1485ef9f2a5SBarry Smith extern int MatScaleSystem(Mat,Vec,Vec);
1495ef9f2a5SBarry Smith extern int MatUnScaleSystem(Mat,Vec,Vec);
1505ef9f2a5SBarry Smith 
1517b80b807SBarry Smith extern int MatGetSize(Mat,int*,int*);
1527b80b807SBarry Smith extern int MatGetLocalSize(Mat,int*,int*);
1537b80b807SBarry Smith extern int MatGetOwnershipRange(Mat,int*,int*);
1547b80b807SBarry Smith 
1557b2a1423SBarry Smith typedef enum {MAT_INITIAL_MATRIX, MAT_REUSE_MATRIX} MatReuse;
1567b2a1423SBarry Smith extern int MatGetSubMatrices(Mat,int,IS *,IS *,MatReuse,Mat **);
157905e6a2fSBarry Smith extern int MatDestroyMatrices(int, Mat **);
1587b2a1423SBarry Smith extern int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *);
1598efafbd8SBarry Smith 
1607b80b807SBarry Smith extern int MatIncreaseOverlap(Mat,int,IS *,int);
1617b80b807SBarry Smith 
1627b80b807SBarry Smith extern int MatAXPY(Scalar *,Mat,Mat);
16386787d2cSSatish Balay extern int MatAYPX(Scalar *,Mat,Mat);
1647b80b807SBarry Smith extern int MatCompress(Mat);
1657b80b807SBarry Smith 
166052efed2SBarry Smith extern int MatScale(Scalar *,Mat);
167052efed2SBarry Smith extern int MatShift(Scalar *,Mat);
168052efed2SBarry Smith 
169d4bb536fSBarry Smith extern int MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping);
170d4bb536fSBarry Smith extern int MatSetLocalToGlobalMappingBlocked(Mat, ISLocalToGlobalMapping);
17190f02eecSBarry Smith extern int MatZeroRowsLocal(Mat,IS,Scalar*);
17290f02eecSBarry Smith extern int MatSetValuesLocal(Mat,int,int*,int,int*,Scalar*,InsertMode);
1734a387fc0SSatish Balay extern int MatSetValuesBlockedLocal(Mat,int,int*,int,int*,Scalar*,InsertMode);
17490f02eecSBarry Smith 
175649db694SBarry Smith extern int MatSetStashInitialSize(Mat,int, int);
176649db694SBarry Smith 
1777b80b807SBarry Smith /* Routines unique to particular data structures */
1787b80b807SBarry Smith extern int MatBDiagGetData(Mat,int*,int*,int**,int**,Scalar***);
1796f0482c6SBarry Smith extern int MatSeqAIJSetColumnIndices(Mat,int *);
1806f0482c6SBarry Smith extern int MatSeqBAIJSetColumnIndices(Mat,int *);
1817b80b807SBarry Smith 
1822e8a6d31SBarry Smith extern int MatStoreValues(Mat);
1832e8a6d31SBarry Smith extern int MatRetrieveValues(Mat);
1842e8a6d31SBarry Smith 
1857b80b807SBarry Smith /*
1867b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
1877b80b807SBarry Smith   done through the SLES, KSP and PC interfaces.
1887b80b807SBarry Smith */
1897b80b807SBarry Smith 
190*b12f92e5SBarry Smith typedef char* MatOrderingType;
191*b12f92e5SBarry Smith #define MATORDERING_NATURAL   "natural"
192*b12f92e5SBarry Smith #define MATORDERING_ND        "nd"
193*b12f92e5SBarry Smith #define MATORDERING_1WD       "1wd"
194*b12f92e5SBarry Smith #define MATORDERING_RCM       "rcm"
195*b12f92e5SBarry Smith #define MATORDERING_QMD       "qmd"
196*b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength"
197*b12f92e5SBarry Smith 
19891e9ee9fSBarry Smith extern int MatGetOrdering(Mat,MatOrderingType,IS*,IS*);
199*b12f92e5SBarry Smith extern int MatOrderingRegister_Private(char*,char*,char*,int(*)(Mat,MatOrderingType,IS*,IS*));
200*b12f92e5SBarry Smith #if defined(USE_DYNAMIC_LIBRARIES)
201*b12f92e5SBarry Smith #define MatOrderingRegister(a,b,c,d) MatOrderingRegister_Private(a,b,c,0)
202*b12f92e5SBarry Smith #else
203*b12f92e5SBarry Smith #define MatOrderingRegister(a,b,c,d) MatOrderingRegister_Private(a,b,c,d)
204*b12f92e5SBarry Smith #endif
20591e9ee9fSBarry Smith extern int MatOrderingRegisterDestroy(void);
206*b12f92e5SBarry Smith extern int MatOrderingRegisterAll(char*);
20791e9ee9fSBarry Smith extern int MatOrderingRegisterAllCalled;
208d4fbbf0eSBarry Smith 
209a2ce50c7SBarry Smith extern int MatReorderForNonzeroDiagonal(Mat,double,IS,IS);
210a2ce50c7SBarry Smith 
211a2ce50c7SBarry Smith extern int MatCholeskyFactor(Mat,IS,double);
212a2ce50c7SBarry Smith extern int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*);
213a2ce50c7SBarry Smith extern int MatCholeskyFactorNumeric(Mat,Mat*);
214a2ce50c7SBarry Smith 
2155ef9f2a5SBarry Smith /*
2165ef9f2a5SBarry Smith    Context of matrix information, used with MatILUFactor() and MatILUFactorSymbolic()
2175ef9f2a5SBarry Smith    Note: If any entries are added to this context, be sure
2185ef9f2a5SBarry Smith          to adjust MAT_ILUINFO_SIZE in finclude/mat.h
2195ef9f2a5SBarry Smith 
2205ef9f2a5SBarry Smith    Note: The integer values below are passed in double to allow easy use from
2215ef9f2a5SBarry Smith          Fortran
2225ef9f2a5SBarry Smith  */
2235ef9f2a5SBarry Smith typedef struct {
2245ef9f2a5SBarry Smith   double levels;  /* ILU(levels) */
2255ef9f2a5SBarry Smith   double fill;    /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
2265ef9f2a5SBarry Smith   double diagonal_fill;  /* force diagonal to fill in if initially not filled */
2275ef9f2a5SBarry Smith } MatILUInfo;
2285ef9f2a5SBarry Smith 
22949d8b64dSBarry Smith extern int MatLUFactor(Mat,IS,IS,double);
2305ef9f2a5SBarry Smith extern int MatILUFactor(Mat,IS,IS,MatILUInfo*);
23164051cb3SBarry Smith extern int MatLUFactorSymbolic(Mat,IS,IS,double,Mat*);
2325ef9f2a5SBarry Smith extern int MatILUFactorSymbolic(Mat,IS,IS,MatILUInfo*,Mat*);
23364051cb3SBarry Smith extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,double,int,Mat*);
23420563c6bSBarry Smith extern int MatLUFactorNumeric(Mat,Mat*);
235a2ce50c7SBarry Smith extern int MatILUDTFactor(Mat,double,int,IS,IS,Mat *);
236a2ce50c7SBarry Smith 
2378ed539a5SBarry Smith extern int MatSolve(Mat,Vec,Vec);
23822169318SLois Curfman McInnes extern int MatForwardSolve(Mat,Vec,Vec);
23922169318SLois Curfman McInnes extern int MatBackwardSolve(Mat,Vec,Vec);
2408ed539a5SBarry Smith extern int MatSolveAdd(Mat,Vec,Vec,Vec);
24128988994SBarry Smith extern int MatSolveTrans(Mat,Vec,Vec);
24228988994SBarry Smith extern int MatSolveTransAdd(Mat,Vec,Vec,Vec);
2438ed539a5SBarry Smith 
244bb5a7306SBarry Smith extern int MatSetUnfactored(Mat);
245bb5a7306SBarry Smith 
246bb1eb677SSatish Balay /*  MatSORType may be bitwise ORd together, so do not change the numbers */
247bb1eb677SSatish Balay 
248ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
249ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
250ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
25184cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
252ca9b4cbeSLois Curfman McInnes extern int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec);
2538ed539a5SBarry Smith 
254d4fbbf0eSBarry Smith /*
255639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
256639f9d9dSBarry Smith */
257*b12f92e5SBarry Smith 
258*b12f92e5SBarry Smith typedef char* MatColoringType;
259*b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural"
260*b12f92e5SBarry Smith #define MATCOLORING_SL      "sl"
261*b12f92e5SBarry Smith #define MATCOLORING_LF      "lf"
262*b12f92e5SBarry Smith #define MATCOLORING_ID      "id"
263*b12f92e5SBarry Smith 
264df8cb225SBarry Smith extern int MatGetColoring(Mat,MatColoringType,ISColoring*);
265*b12f92e5SBarry Smith extern int MatColoringRegister_Private(char*,char*,char*,int(*)(Mat,MatColoringType,ISColoring *));
266*b12f92e5SBarry Smith #if defined(USE_DYNAMIC_LIBRARIES)
267*b12f92e5SBarry Smith #define MatColoringRegister(a,b,c,d) MatColoringRegister_Private(a,b,c,0)
268*b12f92e5SBarry Smith #else
269*b12f92e5SBarry Smith #define MatColoringRegister(a,b,c,d) MatColoringRegister_Private(a,b,c,d)
270*b12f92e5SBarry Smith #endif
271*b12f92e5SBarry Smith extern int MatColoringRegisterAll(char *);
27284cb2905SBarry Smith extern int MatColoringRegisterAllCalled;
273cf256101SBarry Smith extern int MatColoringRegisterDestroy(void);
274639f9d9dSBarry Smith extern int MatColoringPatch(Mat,int,int *,ISColoring*);
275639f9d9dSBarry Smith 
27684cb2905SBarry Smith /*
27784cb2905SBarry Smith     Data structures used to compute Jacobian vector products
27884cb2905SBarry Smith   efficiently using finite differences.
27984cb2905SBarry Smith */
280639f9d9dSBarry Smith #define MAT_FDCOLORING_COOKIE PETSC_COOKIE + 22
281639f9d9dSBarry Smith 
282e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
283639f9d9dSBarry Smith 
284639f9d9dSBarry Smith extern int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
285639f9d9dSBarry Smith extern int MatFDColoringDestroy(MatFDColoring);
286639f9d9dSBarry Smith extern int MatFDColoringView(MatFDColoring,Viewer);
2876eb013d7SBarry Smith extern int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*);
288639f9d9dSBarry Smith extern int MatFDColoringSetParameters(MatFDColoring,double,double);
289005c665bSBarry Smith extern int MatFDColoringSetFrequency(MatFDColoring,int);
2908bba8e72SBarry Smith extern int MatFDColoringGetFrequency(MatFDColoring,int*);
291639f9d9dSBarry Smith extern int MatFDColoringSetFromOptions(MatFDColoring);
292639f9d9dSBarry Smith extern int MatFDColoringPrintHelp(MatFDColoring);
293005c665bSBarry Smith extern int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
2946eb013d7SBarry Smith extern int MatFDColoringApplyTS(Mat,MatFDColoring,double,Vec,MatStructure*,void *);
295639f9d9dSBarry Smith 
296639f9d9dSBarry Smith /*
2970752156aSBarry Smith     These routines are for partitioning matrices: currently used only
2980752156aSBarry Smith   for adjacency matrix, MatCreateSeqAdj() or MatCreateMPIAdj().
2990752156aSBarry Smith */
30091e9ee9fSBarry Smith #define MATPARTITIONING_COOKIE PETSC_COOKIE + 25
301ca161407SBarry Smith 
30291e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
3032aabb6bbSBarry Smith typedef char* MatPartitioningType;
3042aabb6bbSBarry Smith #define MATPARTITIONING_CURRENT  "current"
3052aabb6bbSBarry Smith #define MATPARTITIONING_PARMETIS "parmetis"
306ca161407SBarry Smith 
30791e9ee9fSBarry Smith extern int MatPartitioningCreate(MPI_Comm,MatPartitioning*);
30891e9ee9fSBarry Smith extern int MatPartitioningSetType(MatPartitioning,MatPartitioningType);
30991e9ee9fSBarry Smith extern int MatPartitioningSetAdjacency(MatPartitioning,Mat);
31091e9ee9fSBarry Smith extern int MatPartitioningSetVertexWeights(MatPartitioning,double*);
31191e9ee9fSBarry Smith extern int MatPartitioningApply(MatPartitioning,IS*);
31291e9ee9fSBarry Smith extern int MatPartitioningDestroy(MatPartitioning);
3132aabb6bbSBarry Smith 
3142aabb6bbSBarry Smith extern int MatPartitioningRegister_Private(char*,char*,char*,int(*)(MatPartitioning));
3152aabb6bbSBarry Smith #if defined(USE_DYNAMIC_LIBRARIES)
3162aabb6bbSBarry Smith #define MatPartitioningRegister(a,b,c,d) MatPartitioningRegister_Private(a,b,c,0)
3172aabb6bbSBarry Smith #else
3182aabb6bbSBarry Smith #define MatPartitioningRegister(a,b,c,d) MatPartitioningRegister_Private(a,b,c,d)
3192aabb6bbSBarry Smith #endif
3202aabb6bbSBarry Smith 
3212aabb6bbSBarry Smith extern int MatPartitioningRegisterAll(char *);
322ebb8b11fSBarry Smith extern int MatPartitioningRegisterAllCalled;
32391e9ee9fSBarry Smith extern int MatPartitioningRegisterDestroy(void);
32491e9ee9fSBarry Smith extern int MatPartitioningView(MatPartitioning,Viewer);
32591e9ee9fSBarry Smith extern int MatPartitioningSetFromOptions(MatPartitioning);
32691e9ee9fSBarry Smith extern int MatPartitioningPrintHelp(MatPartitioning);
327e905bf0dSBarry Smith extern int MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
328ca161407SBarry Smith 
32991e9ee9fSBarry Smith extern int MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
3300752156aSBarry Smith 
3310752156aSBarry Smith /*
33226cd32c0SSatish Balay     If you add entries here you must also add them to finclude/mat.h
333d4fbbf0eSBarry Smith */
3341c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
3351c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
3361c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
3371c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
3381c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
3391c1c02c0SLois Curfman McInnes                MATOP_MULT_TRANS=5,
3401c1c02c0SLois Curfman McInnes                MATOP_MULT_TRANS_ADD=6,
3411c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
3421c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
3431c1c02c0SLois Curfman McInnes                MATOP_SOLVE_TRANS=9,
3441c1c02c0SLois Curfman McInnes                MATOP_SOLVE_TRANS_ADD=10,
3451c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
3461c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
3471c1c02c0SLois Curfman McInnes                MATOP_RELAX=13,
3481c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
3491c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
3501c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
3511c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
3521c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
3531c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
3541c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
3551c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
3561c1c02c0SLois Curfman McInnes                MATOP_COMPRESS=22,
3571c1c02c0SLois Curfman McInnes                MATOP_SET_OPTION=23,
3581c1c02c0SLois Curfman McInnes                MATOP_ZERO_ENTRIES=24,
3591c1c02c0SLois Curfman McInnes                MATOP_ZERO_ROWS=25,
3601c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_SYMBOLIC=26,
3611c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_NUMERIC=27,
3621c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
3631c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
3641c1c02c0SLois Curfman McInnes                MATOP_GET_SIZE=30,
3651c1c02c0SLois Curfman McInnes                MATOP_GET_LOCAL_SIZE=31,
3661c1c02c0SLois Curfman McInnes                MATOP_GET_OWNERSHIP_RANGE=32,
3671c1c02c0SLois Curfman McInnes                MATOP_ILUFACTOR_SYMBOLIC=33,
3681c1c02c0SLois Curfman McInnes                MATOP_INCOMPLETECHOLESKYFACTOR_SYMBOLIC=34,
3691c1c02c0SLois Curfman McInnes                MATOP_GET_ARRAY=35,
3701c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ARRAY=36,
3717bf97ca4SSatish Balay 
372005c665bSBarry Smith                MATOP_CONVERT_SAME_TYPE=37,
373005c665bSBarry Smith                MATOP_FORWARD_SOLVE=38,
374005c665bSBarry Smith                MATOP_BACKWARD_SOLVE=39,
375005c665bSBarry Smith                MATOP_ILUFACTOR=40,
376005c665bSBarry Smith                MATOP_INCOMPLETECHOLESKYFACTOR=41,
377005c665bSBarry Smith                MATOP_AXPY=42,
378005c665bSBarry Smith                MATOP_GET_SUBMATRICES=43,
379005c665bSBarry Smith                MATOP_INCREASE_OVERLAP=44,
380005c665bSBarry Smith                MATOP_GET_VALUES=45,
381005c665bSBarry Smith                MATOP_COPY=46,
382005c665bSBarry Smith                MATOP_PRINT_HELP=47,
383005c665bSBarry Smith                MATOP_SCALE=48,
384005c665bSBarry Smith                MATOP_SHIFT=49,
385005c665bSBarry Smith                MATOP_DIAGONAL_SHIFT=50,
386005c665bSBarry Smith                MATOP_ILUDT_FACTOR=51,
387005c665bSBarry Smith                MATOP_GET_BLOCK_SIZE=52,
388005c665bSBarry Smith                MATOP_GET_ROW_IJ=53,
389005c665bSBarry Smith                MATOP_RESTORE_ROW_IJ=54,
390005c665bSBarry Smith                MATOP_GET_COLUMN_IJ=55,
391005c665bSBarry Smith                MATOP_RESTORE_COLUMN_IJ=56,
392005c665bSBarry Smith                MATOP_FDCOLORING_CREATE=57,
393005c665bSBarry Smith                MATOP_COLORING_PATCH=58,
394005c665bSBarry Smith                MATOP_SET_UNFACTORED=59,
395005c665bSBarry Smith                MATOP_PERMUTE=60,
396005c665bSBarry Smith                MATOP_SET_VALUES_BLOCKED=61,
3971c1c02c0SLois Curfman McInnes                MATOP_DESTROY=250,
3981c1c02c0SLois Curfman McInnes                MATOP_VIEW=251
399fae171e0SBarry Smith              } MatOperation;
400112a2221SBarry Smith extern int MatHasOperation(Mat,MatOperation,PetscTruth*);
401fae171e0SBarry Smith extern int MatShellSetOperation(Mat,MatOperation,void *);
402d4bb536fSBarry Smith extern int MatShellGetOperation(Mat,MatOperation,void **);
403112a2221SBarry Smith 
40490ace30eSBarry Smith /*
40590ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
40690ace30eSBarry Smith  stored in a universal format. By changing the format with
407639f9d9dSBarry Smith  ViewerSetFormat(viewer,VIEWER_FORMAT_BINARY_NATIVE); the matrices will
40890ace30eSBarry Smith  be stored in a way natural for the matrix, for example dense matrices
40990ace30eSBarry Smith  would be stored as dense. Matrices stored this way may only be
41090ace30eSBarry Smith  read into matrices of the same time.
41190ace30eSBarry Smith */
41290ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
41390ace30eSBarry Smith 
4143f1d51d7SBarry Smith /*
4153f1d51d7SBarry Smith      New matrix classes not yet distributed
4163f1d51d7SBarry Smith */
4173f1d51d7SBarry Smith /*
4183f1d51d7SBarry Smith     MatAIJIndices is a data structure for storing the nonzero location information
4193f1d51d7SBarry Smith   for sparse matrices. Several matrices with identical nonzero structure can share
4203f1d51d7SBarry Smith   the same MatAIJIndices.
4213f1d51d7SBarry Smith */
422e2a1c21fSSatish Balay typedef struct _p_MatAIJIndices* MatAIJIndices;
4233f1d51d7SBarry Smith 
4243f1d51d7SBarry Smith extern int MatCreateAIJIndices(int,int,int*,int*,PetscTruth,MatAIJIndices*);
4253f1d51d7SBarry Smith extern int MatCreateAIJIndicesEmpty(int,int,int*,PetscTruth,MatAIJIndices*);
4263f1d51d7SBarry Smith extern int MatAttachAIJIndices(MatAIJIndices,MatAIJIndices*);
4273f1d51d7SBarry Smith extern int MatDestroyAIJIndices(MatAIJIndices);
4283f1d51d7SBarry Smith extern int MatCopyAIJIndices(MatAIJIndices,MatAIJIndices*);
4293f1d51d7SBarry Smith extern int MatValidateAIJIndices(int,MatAIJIndices);
4303f1d51d7SBarry Smith extern int MatShiftAIJIndices(MatAIJIndices);
4313f1d51d7SBarry Smith extern int MatShrinkAIJIndices(MatAIJIndices);
4323f1d51d7SBarry Smith extern int MatTransposeAIJIndices(MatAIJIndices, MatAIJIndices*);
4333f1d51d7SBarry Smith 
4343f1d51d7SBarry Smith extern int MatCreateSeqCSN(MPI_Comm,int,int,int*,int,Mat*);
4353f1d51d7SBarry Smith extern int MatCreateSeqCSN_Single(MPI_Comm,int,int,int*,int,Mat*);
4363f1d51d7SBarry Smith extern int MatCreateSeqCSNWithPrecision(MPI_Comm,int,int,int*,int,ScalarPrecision,Mat*);
4373f1d51d7SBarry Smith 
4383f1d51d7SBarry Smith extern int MatCreateSeqCSNIndices(MPI_Comm,MatAIJIndices,int,Mat *);
4393f1d51d7SBarry Smith extern int MatCreateSeqCSNIndices_Single(MPI_Comm,MatAIJIndices,int,Mat *);
4403f1d51d7SBarry Smith extern int MatCreateSeqCSNIndicesWithPrecision(MPI_Comm,MatAIJIndices,int,ScalarPrecision,Mat *);
4413f1d51d7SBarry Smith 
442aa6d738dSSatish Balay extern int MatMPIBAIJSetHashTableFactor(Mat,double);
4432e8a6d31SBarry Smith extern int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *);
444860d1616SSatish Balay 
4453f1d51d7SBarry Smith 
4462eac72dbSBarry Smith #endif
4472eac72dbSBarry Smith 
4482eac72dbSBarry Smith 
4499d00d63dSBarry Smith 
450