xref: /petsc/include/petscmat.h (revision 4787f7683dc5ea85e35b4269f7afceca0dae908f)
1*4787f768SSatish Balay /* $Id: mat.h,v 1.167 1999/02/09 15:12:55 bsmith Exp balay $ */
22eac72dbSBarry Smith /*
32eac72dbSBarry Smith      Include file for the matrix component of PETSc
4f1d1b154SWilliam Gropp 
526cd32c0SSatish Balay      Any change to this file must also be made to finclude/mat.h
62eac72dbSBarry Smith */
7a009ddc3SBarry Smith #ifndef __MAT_H
8a009ddc3SBarry Smith #define __MAT_H
98ed539a5SBarry Smith #include "vec.h"
102eac72dbSBarry Smith 
119cd28387SBarry Smith #define MAT_COOKIE         PETSC_COOKIE+5
12f0479e8cSBarry Smith 
13e2a1c21fSSatish Balay typedef struct _p_Mat*           Mat;
142eac72dbSBarry Smith 
15f1d1b154SWilliam Gropp #define MAX_MATRIX_TYPES 14
16639f9d9dSBarry Smith /*
17639f9d9dSBarry Smith    The default matrix data storage formats and routines to create them.
18f1d1b154SWilliam Gropp 
19f1d1b154SWilliam Gropp    MATLASTTYPE is "end-of-list" marker that can be used to check that
20f1d1b154SWilliam Gropp    MAX_MATRIX_TYPES is large enough.  The rule is
21f1d1b154SWilliam Gropp    MAX_MATRIX_TYPES >= MATLASTTYPE .
22f1d1b154SWilliam Gropp 
23f1d1b154SWilliam Gropp    To do: add a test program that checks the consistency of these values.
24639f9d9dSBarry Smith */
254ac9ca07SLois Curfman McInnes typedef enum { MATSAME=-1,  MATSEQDENSE, MATSEQAIJ,   MATMPIAIJ,   MATSHELL,
2684cb2905SBarry Smith                MATMPIROWBS, MATSEQBDIAG, MATMPIBDIAG, MATMPIDENSE, MATSEQBAIJ,
27f1d1b154SWilliam Gropp                MATMPIBAIJ,  MATMPICSN,   MATSEQCSN,   MATSEQADJ,   MATMPIADJ,
28f1d1b154SWilliam Gropp                MATLASTTYPE } MatType;
2928988994SBarry Smith 
300e998a85SBarry Smith extern int MatCreate(MPI_Comm,int,int,Mat*);
31df6e0191SLois Curfman McInnes extern int MatCreateSeqDense(MPI_Comm,int,int,Scalar*,Mat*);
32d5bc1036SLois Curfman McInnes extern int MatCreateMPIDense(MPI_Comm,int,int,int,int,Scalar*,Mat*);
33de7da479SBarry Smith extern int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*);
349717bf64SBarry Smith extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
35cfe223acSLois Curfman McInnes extern int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,void*,Mat*);
36f26ada1bSBarry Smith extern int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,Scalar**,Mat*);
37f26ada1bSBarry Smith extern int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,Scalar**,Mat*);
38df8a92d1SBarry Smith extern int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
39eba03b66SLois Curfman McInnes extern int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*);
4082c9921cSBarry Smith extern int MatCreateSeqAdj(MPI_Comm,int,int,int*,int*,Mat *);
410752156aSBarry Smith extern int MatCreateMPIAdj(MPI_Comm,int,int,int*,int*,Mat*);
429717bf64SBarry Smith 
437b80b807SBarry Smith extern int MatDestroy(Mat);
447b80b807SBarry Smith 
457ddc982cSLois Curfman McInnes extern int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*);
4617116c71SBarry Smith extern int MatShellGetContext(Mat,void **);
4721c89e3eSBarry Smith 
48ec0117caSBarry Smith extern int MatPrintHelp(Mat);
49cda55fadSBarry Smith extern int MatGetMaps(Mat,Map*,Map*);
50ec0117caSBarry Smith 
518ed539a5SBarry Smith /* ------------------------------------------------------------*/
52ee50ffe9SBarry Smith extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
5395e63191SSatish Balay extern int MatSetValuesBlocked(Mat,int,int*,int,int*,Scalar*,InsertMode);
5484cb2905SBarry Smith 
556d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
56ee50ffe9SBarry Smith extern int MatAssemblyBegin(Mat,MatAssemblyType);
57ee50ffe9SBarry Smith extern int MatAssemblyEnd(Mat,MatAssemblyType);
58b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \
59b951964fSBarry Smith {int _ierr,_row = i,_col = j; Scalar _va = va; \
60b951964fSBarry Smith   _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
61b951964fSBarry Smith }
62ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \
63ea06a074SBarry Smith {int _ierr,_row = i,_col = j; \
64ea06a074SBarry Smith   _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \
65ea06a074SBarry Smith }
666ca9ecd3SBarry Smith /*
676ca9ecd3SBarry Smith    Any additions/changes here MUST also be made in include/finclude/mat.h
686ca9ecd3SBarry Smith */
696d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
706d4a8577SBarry Smith               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
716d4a8577SBarry Smith               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
726ca9ecd3SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
736ca9ecd3SBarry Smith               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
746ca9ecd3SBarry Smith               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
756ca9ecd3SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
76*4787f768SSatish Balay               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
77*4787f768SSatish Balay               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78} MatOption;
78ee50ffe9SBarry Smith extern int MatSetOption(Mat,MatOption);
794b0e389bSBarry Smith extern int MatGetType(Mat,MatType*,char**);
8056cd22aeSBarry Smith extern int MatGetTypeFromOptions(MPI_Comm,char*,MatType*,PetscTruth*);
8184cb2905SBarry Smith 
82ee50ffe9SBarry Smith extern int MatGetValues(Mat,int,int*,int,int*,Scalar*);
838ed539a5SBarry Smith extern int MatGetRow(Mat,int,int *,int **,Scalar**);
848ed539a5SBarry Smith extern int MatRestoreRow(Mat,int,int *,int **,Scalar**);
8577c4ece6SBarry Smith extern int MatGetColumn(Mat,int,int *,int **,Scalar**);
8677c4ece6SBarry Smith extern int MatRestoreColumn(Mat,int,int *,int **,Scalar**);
875cd4b4e6SBarry Smith extern int MatGetColumnVector(Mat,Vec,int);
8864e87e97SBarry Smith extern int MatGetArray(Mat,Scalar **);
8909883261SBarry Smith extern int MatRestoreArray(Mat,Scalar **);
90870582ebSSatish Balay extern int MatGetBlockSize(Mat,int *);
917b80b807SBarry Smith 
928ed539a5SBarry Smith extern int MatMult(Mat,Vec,Vec);
938ed539a5SBarry Smith extern int MatMultAdd(Mat,Vec,Vec,Vec);
948ed539a5SBarry Smith extern int MatMultTrans(Mat,Vec,Vec);
958ed539a5SBarry Smith extern int MatMultTransAdd(Mat,Vec,Vec,Vec);
962eac72dbSBarry Smith 
972e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES, MAT_COPY_VALUES} MatDuplicateOption;
982e8a6d31SBarry Smith 
997b80b807SBarry Smith extern int MatConvert(Mat,MatType,Mat*);
1002e8a6d31SBarry Smith extern int MatDuplicate(Mat,MatDuplicateOption,Mat*);
10194a9d846SBarry Smith extern int MatConvertRegister(MatType,MatType,int (*)(Mat,MatType,Mat*));
102cf256101SBarry Smith extern int MatConvertRegisterAll(void);
10394a9d846SBarry Smith 
104cb5b572fSBarry Smith typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER} MatStructure;
105cb5b572fSBarry Smith 
106cb5b572fSBarry Smith extern int MatCopy(Mat,Mat,MatStructure);
1077b80b807SBarry Smith extern int MatView(Mat,Viewer);
1087b80b807SBarry Smith extern int MatLoad(Viewer,MatType,Mat*);
10994a9d846SBarry Smith extern int MatLoadRegister(MatType,int (*)(Viewer,MatType,Mat*));
110cf256101SBarry Smith extern int MatLoadRegisterAll(void);
1117b80b807SBarry Smith 
112d4fbbf0eSBarry Smith extern int MatGetRowIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
113d4fbbf0eSBarry Smith extern int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
114d4fbbf0eSBarry Smith extern int MatGetColumnIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
115d4fbbf0eSBarry Smith extern int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
116d4fbbf0eSBarry Smith 
1171d607229SLois Curfman McInnes /*
1181d607229SLois Curfman McInnes    Context of matrix information, used with MatGetInfo()
1191d607229SLois Curfman McInnes    Note: If any entries are added to this context, be sure
12026cd32c0SSatish Balay          to adjust MAT_INFO_SIZE in finclude/mat.h
1211d607229SLois Curfman McInnes  */
1224e220ebcSLois Curfman McInnes typedef struct {
12337f753daSBarry Smith   PLogDouble rows_global, columns_global;         /* number of global rows and columns */
12437f753daSBarry Smith   PLogDouble rows_local, columns_local;           /* number of local rows and columns */
12537f753daSBarry Smith   PLogDouble block_size;                          /* block size */
12637f753daSBarry Smith   PLogDouble nz_allocated, nz_used, nz_unneeded;  /* number of nonzeros */
12737f753daSBarry Smith   PLogDouble memory;                              /* memory allocated */
12837f753daSBarry Smith   PLogDouble assemblies;                          /* number of matrix assemblies */
12937f753daSBarry Smith   PLogDouble mallocs;                             /* number of mallocs during MatSetValues() */
13037f753daSBarry Smith   PLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */
13137f753daSBarry Smith   PLogDouble factor_mallocs;                      /* number of mallocs during factorization */
1324e220ebcSLois Curfman McInnes } MatInfo;
1334e220ebcSLois Curfman McInnes 
1347b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
1354e220ebcSLois Curfman McInnes extern int MatGetInfo(Mat,MatInfoType,MatInfo*);
13677c4ece6SBarry Smith extern int MatValid(Mat,PetscTruth*);
1377b80b807SBarry Smith extern int MatGetDiagonal(Mat,Vec);
138cd8486b4SBarry Smith extern int MatTranspose(Mat,Mat*);
1390513a670SBarry Smith extern int MatPermute(Mat,IS,IS,Mat *);
140f4c33d5aSBarry Smith extern int MatDiagonalScale(Mat,Vec,Vec);
1418b3e568eSBarry Smith extern int MatDiagonalShift(Mat,Vec);
14277c4ece6SBarry Smith extern int MatEqual(Mat,Mat, PetscTruth*);
1437b80b807SBarry Smith 
1447b80b807SBarry Smith extern int MatNorm(Mat,NormType,double *);
1457b80b807SBarry Smith extern int MatZeroEntries(Mat);
1467b80b807SBarry Smith extern int MatZeroRows(Mat,IS,Scalar*);
1477b80b807SBarry Smith extern int MatZeroColumns(Mat,IS,Scalar*);
1487b80b807SBarry Smith 
1495ef9f2a5SBarry Smith extern int MatUseScaledForm(Mat,PetscTruth);
1505ef9f2a5SBarry Smith extern int MatScaleSystem(Mat,Vec,Vec);
1515ef9f2a5SBarry Smith extern int MatUnScaleSystem(Mat,Vec,Vec);
1525ef9f2a5SBarry Smith 
1537b80b807SBarry Smith extern int MatGetSize(Mat,int*,int*);
1547b80b807SBarry Smith extern int MatGetLocalSize(Mat,int*,int*);
1557b80b807SBarry Smith extern int MatGetOwnershipRange(Mat,int*,int*);
1567b80b807SBarry Smith 
1577b2a1423SBarry Smith typedef enum {MAT_INITIAL_MATRIX, MAT_REUSE_MATRIX} MatReuse;
1587b2a1423SBarry Smith extern int MatGetSubMatrices(Mat,int,IS *,IS *,MatReuse,Mat **);
159905e6a2fSBarry Smith extern int MatDestroyMatrices(int, Mat **);
1607b2a1423SBarry Smith extern int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *);
1618efafbd8SBarry Smith 
1627b80b807SBarry Smith extern int MatIncreaseOverlap(Mat,int,IS *,int);
1637b80b807SBarry Smith 
1647b80b807SBarry Smith extern int MatAXPY(Scalar *,Mat,Mat);
16586787d2cSSatish Balay extern int MatAYPX(Scalar *,Mat,Mat);
1667b80b807SBarry Smith extern int MatCompress(Mat);
1677b80b807SBarry Smith 
168052efed2SBarry Smith extern int MatScale(Scalar *,Mat);
169052efed2SBarry Smith extern int MatShift(Scalar *,Mat);
170052efed2SBarry Smith 
171d4bb536fSBarry Smith extern int MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping);
172d4bb536fSBarry Smith extern int MatSetLocalToGlobalMappingBlocked(Mat, ISLocalToGlobalMapping);
17390f02eecSBarry Smith extern int MatZeroRowsLocal(Mat,IS,Scalar*);
17490f02eecSBarry Smith extern int MatSetValuesLocal(Mat,int,int*,int,int*,Scalar*,InsertMode);
1754a387fc0SSatish Balay extern int MatSetValuesBlockedLocal(Mat,int,int*,int,int*,Scalar*,InsertMode);
17690f02eecSBarry 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 
19084cb2905SBarry Smith typedef enum {ORDER_NATURAL=0,ORDER_ND=1,ORDER_1WD=2,ORDER_RCM=3,
191ca161407SBarry Smith               ORDER_QMD=4,ORDER_ROWLENGTH=5,ORDER_FLOW,ORDER_NEW} MatReorderingType;
192ca161407SBarry Smith extern int MatGetReordering(Mat,MatReorderingType,IS*,IS*);
193ca161407SBarry Smith extern int MatGetReorderingTypeFromOptions(char *,MatReorderingType*);
194ca161407SBarry Smith extern int MatReorderingRegister(MatReorderingType,MatReorderingType*,char*,
195ca161407SBarry Smith                                  int(*)(Mat,MatReorderingType,IS*,IS*));
196ca161407SBarry Smith extern int MatReorderingGetName(MatReorderingType,char **);
197cf256101SBarry Smith extern int MatReorderingRegisterDestroy(void);
198cf256101SBarry Smith extern int MatReorderingRegisterAll(void);
19984cb2905SBarry Smith extern int MatReorderingRegisterAllCalled;
200d4fbbf0eSBarry Smith 
201a2ce50c7SBarry Smith extern int MatReorderForNonzeroDiagonal(Mat,double,IS,IS);
202a2ce50c7SBarry Smith 
203a2ce50c7SBarry Smith extern int MatCholeskyFactor(Mat,IS,double);
204a2ce50c7SBarry Smith extern int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*);
205a2ce50c7SBarry Smith extern int MatCholeskyFactorNumeric(Mat,Mat*);
206a2ce50c7SBarry Smith 
2075ef9f2a5SBarry Smith /*
2085ef9f2a5SBarry Smith    Context of matrix information, used with MatILUFactor() and MatILUFactorSymbolic()
2095ef9f2a5SBarry Smith    Note: If any entries are added to this context, be sure
2105ef9f2a5SBarry Smith          to adjust MAT_ILUINFO_SIZE in finclude/mat.h
2115ef9f2a5SBarry Smith 
2125ef9f2a5SBarry Smith    Note: The integer values below are passed in double to allow easy use from
2135ef9f2a5SBarry Smith          Fortran
2145ef9f2a5SBarry Smith  */
2155ef9f2a5SBarry Smith typedef struct {
2165ef9f2a5SBarry Smith   double levels;  /* ILU(levels) */
2175ef9f2a5SBarry Smith   double fill;    /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
2185ef9f2a5SBarry Smith   double diagonal_fill;  /* force diagonal to fill in if initially not filled */
2195ef9f2a5SBarry Smith } MatILUInfo;
2205ef9f2a5SBarry Smith 
22149d8b64dSBarry Smith extern int MatLUFactor(Mat,IS,IS,double);
2225ef9f2a5SBarry Smith extern int MatILUFactor(Mat,IS,IS,MatILUInfo*);
22364051cb3SBarry Smith extern int MatLUFactorSymbolic(Mat,IS,IS,double,Mat*);
2245ef9f2a5SBarry Smith extern int MatILUFactorSymbolic(Mat,IS,IS,MatILUInfo*,Mat*);
22564051cb3SBarry Smith extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,double,int,Mat*);
22620563c6bSBarry Smith extern int MatLUFactorNumeric(Mat,Mat*);
227a2ce50c7SBarry Smith extern int MatILUDTFactor(Mat,double,int,IS,IS,Mat *);
228a2ce50c7SBarry Smith 
2298ed539a5SBarry Smith extern int MatSolve(Mat,Vec,Vec);
23022169318SLois Curfman McInnes extern int MatForwardSolve(Mat,Vec,Vec);
23122169318SLois Curfman McInnes extern int MatBackwardSolve(Mat,Vec,Vec);
2328ed539a5SBarry Smith extern int MatSolveAdd(Mat,Vec,Vec,Vec);
23328988994SBarry Smith extern int MatSolveTrans(Mat,Vec,Vec);
23428988994SBarry Smith extern int MatSolveTransAdd(Mat,Vec,Vec,Vec);
2358ed539a5SBarry Smith 
236bb5a7306SBarry Smith extern int MatSetUnfactored(Mat);
237bb5a7306SBarry Smith 
238ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
239ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
240ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
24184cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
242ca9b4cbeSLois Curfman McInnes extern int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec);
2438ed539a5SBarry Smith 
244005c665bSBarry Smith 
245d4fbbf0eSBarry Smith /*
246639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
247639f9d9dSBarry Smith */
248639f9d9dSBarry Smith typedef enum {COLORING_NATURAL, COLORING_SL, COLORING_LF, COLORING_ID,
249df8cb225SBarry Smith               COLORING_NEW} MatColoringType;
250df8cb225SBarry Smith extern int MatGetColoring(Mat,MatColoringType,ISColoring*);
251df8cb225SBarry Smith extern int MatGetColoringTypeFromOptions(char *,MatColoringType*);
252df8cb225SBarry Smith extern int MatColoringRegister(MatColoringType,MatColoringType*,char*,int(*)(Mat,MatColoringType,ISColoring *));
253cf256101SBarry Smith extern int MatColoringRegisterAll(void);
25484cb2905SBarry Smith extern int MatColoringRegisterAllCalled;
255cf256101SBarry Smith extern int MatColoringRegisterDestroy(void);
256639f9d9dSBarry Smith extern int MatColoringPatch(Mat,int,int *,ISColoring*);
257639f9d9dSBarry Smith 
25884cb2905SBarry Smith /*
25984cb2905SBarry Smith     Data structures used to compute Jacobian vector products
26084cb2905SBarry Smith   efficiently using finite differences.
26184cb2905SBarry Smith */
262639f9d9dSBarry Smith #define MAT_FDCOLORING_COOKIE PETSC_COOKIE + 22
263639f9d9dSBarry Smith 
264e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
265639f9d9dSBarry Smith 
266639f9d9dSBarry Smith extern int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
267639f9d9dSBarry Smith extern int MatFDColoringDestroy(MatFDColoring);
268639f9d9dSBarry Smith extern int MatFDColoringView(MatFDColoring,Viewer);
2696eb013d7SBarry Smith extern int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*);
270639f9d9dSBarry Smith extern int MatFDColoringSetParameters(MatFDColoring,double,double);
271005c665bSBarry Smith extern int MatFDColoringSetFrequency(MatFDColoring,int);
2728bba8e72SBarry Smith extern int MatFDColoringGetFrequency(MatFDColoring,int*);
273639f9d9dSBarry Smith extern int MatFDColoringSetFromOptions(MatFDColoring);
274639f9d9dSBarry Smith extern int MatFDColoringPrintHelp(MatFDColoring);
275005c665bSBarry Smith extern int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
2766eb013d7SBarry Smith extern int MatFDColoringApplyTS(Mat,MatFDColoring,double,Vec,MatStructure*,void *);
277639f9d9dSBarry Smith 
278639f9d9dSBarry Smith /*
2790752156aSBarry Smith     These routines are for partitioning matrices: currently used only
2800752156aSBarry Smith   for adjacency matrix, MatCreateSeqAdj() or MatCreateMPIAdj().
2810752156aSBarry Smith */
282ca161407SBarry Smith #define PARTITIONING_COOKIE PETSC_COOKIE + 25
283ca161407SBarry Smith 
284ca161407SBarry Smith typedef struct _p_Partitioning *Partitioning;
285ca161407SBarry Smith 
286ca161407SBarry Smith typedef enum {PARTITIONING_CURRENT,PARTITIONING_PARMETIS,PARTITIONING_NEW} PartitioningType;
287ca161407SBarry Smith 
288ca161407SBarry Smith extern int PartitioningCreate(MPI_Comm,Partitioning*);
289ca161407SBarry Smith extern int PartitioningSetType(Partitioning,PartitioningType);
290ca161407SBarry Smith extern int PartitioningSetAdjacency(Partitioning,Mat);
291ca161407SBarry Smith extern int PartitioningSetVertexWeights(Partitioning,double*);
292ca161407SBarry Smith extern int PartitioningApply(Partitioning,IS*);
293ca161407SBarry Smith extern int PartitioningDestroy(Partitioning);
294ca161407SBarry Smith extern int PartitioningRegister(PartitioningType,PartitioningType *,char*,int(*)(Partitioning));
295cf256101SBarry Smith extern int PartitioningRegisterAll(void);
296ca161407SBarry Smith extern int PartitioningRegisterAllCalled;
297cf256101SBarry Smith extern int PartitioningRegisterDestroy(void);
298ca161407SBarry Smith extern int PartitioningView(Partitioning,Viewer);
299ca161407SBarry Smith extern int PartitioningSetFromOptions(Partitioning);
300ca161407SBarry Smith extern int PartitioningPrintHelp(Partitioning);
301ca161407SBarry Smith extern int PartitioningGetType(Partitioning,PartitioningType*,char**);
302ca161407SBarry Smith 
303ca161407SBarry Smith extern int PartitioningParmetisSetCoarseSequential(Partitioning);
3040752156aSBarry Smith 
3050752156aSBarry Smith /*
30626cd32c0SSatish Balay     If you add entries here you must also add them to finclude/mat.h
307d4fbbf0eSBarry Smith */
3081c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
3091c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
3101c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
3111c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
3121c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
3131c1c02c0SLois Curfman McInnes                MATOP_MULT_TRANS=5,
3141c1c02c0SLois Curfman McInnes                MATOP_MULT_TRANS_ADD=6,
3151c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
3161c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
3171c1c02c0SLois Curfman McInnes                MATOP_SOLVE_TRANS=9,
3181c1c02c0SLois Curfman McInnes                MATOP_SOLVE_TRANS_ADD=10,
3191c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
3201c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
3211c1c02c0SLois Curfman McInnes                MATOP_RELAX=13,
3221c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
3231c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
3241c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
3251c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
3261c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
3271c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
3281c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
3291c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
3301c1c02c0SLois Curfman McInnes                MATOP_COMPRESS=22,
3311c1c02c0SLois Curfman McInnes                MATOP_SET_OPTION=23,
3321c1c02c0SLois Curfman McInnes                MATOP_ZERO_ENTRIES=24,
3331c1c02c0SLois Curfman McInnes                MATOP_ZERO_ROWS=25,
3341c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_SYMBOLIC=26,
3351c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_NUMERIC=27,
3361c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
3371c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
3381c1c02c0SLois Curfman McInnes                MATOP_GET_SIZE=30,
3391c1c02c0SLois Curfman McInnes                MATOP_GET_LOCAL_SIZE=31,
3401c1c02c0SLois Curfman McInnes                MATOP_GET_OWNERSHIP_RANGE=32,
3411c1c02c0SLois Curfman McInnes                MATOP_ILUFACTOR_SYMBOLIC=33,
3421c1c02c0SLois Curfman McInnes                MATOP_INCOMPLETECHOLESKYFACTOR_SYMBOLIC=34,
3431c1c02c0SLois Curfman McInnes                MATOP_GET_ARRAY=35,
3441c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ARRAY=36,
3457bf97ca4SSatish Balay 
346005c665bSBarry Smith                MATOP_CONVERT_SAME_TYPE=37,
347005c665bSBarry Smith                MATOP_FORWARD_SOLVE=38,
348005c665bSBarry Smith                MATOP_BACKWARD_SOLVE=39,
349005c665bSBarry Smith                MATOP_ILUFACTOR=40,
350005c665bSBarry Smith                MATOP_INCOMPLETECHOLESKYFACTOR=41,
351005c665bSBarry Smith                MATOP_AXPY=42,
352005c665bSBarry Smith                MATOP_GET_SUBMATRICES=43,
353005c665bSBarry Smith                MATOP_INCREASE_OVERLAP=44,
354005c665bSBarry Smith                MATOP_GET_VALUES=45,
355005c665bSBarry Smith                MATOP_COPY=46,
356005c665bSBarry Smith                MATOP_PRINT_HELP=47,
357005c665bSBarry Smith                MATOP_SCALE=48,
358005c665bSBarry Smith                MATOP_SHIFT=49,
359005c665bSBarry Smith                MATOP_DIAGONAL_SHIFT=50,
360005c665bSBarry Smith                MATOP_ILUDT_FACTOR=51,
361005c665bSBarry Smith                MATOP_GET_BLOCK_SIZE=52,
362005c665bSBarry Smith                MATOP_GET_ROW_IJ=53,
363005c665bSBarry Smith                MATOP_RESTORE_ROW_IJ=54,
364005c665bSBarry Smith                MATOP_GET_COLUMN_IJ=55,
365005c665bSBarry Smith                MATOP_RESTORE_COLUMN_IJ=56,
366005c665bSBarry Smith                MATOP_FDCOLORING_CREATE=57,
367005c665bSBarry Smith                MATOP_COLORING_PATCH=58,
368005c665bSBarry Smith                MATOP_SET_UNFACTORED=59,
369005c665bSBarry Smith                MATOP_PERMUTE=60,
370005c665bSBarry Smith                MATOP_SET_VALUES_BLOCKED=61,
3711c1c02c0SLois Curfman McInnes                MATOP_DESTROY=250,
3721c1c02c0SLois Curfman McInnes                MATOP_VIEW=251
373fae171e0SBarry Smith              } MatOperation;
374112a2221SBarry Smith extern int MatHasOperation(Mat,MatOperation,PetscTruth*);
375fae171e0SBarry Smith extern int MatShellSetOperation(Mat,MatOperation,void *);
376d4bb536fSBarry Smith extern int MatShellGetOperation(Mat,MatOperation,void **);
377112a2221SBarry Smith 
37890ace30eSBarry Smith /*
37990ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
38090ace30eSBarry Smith  stored in a universal format. By changing the format with
381639f9d9dSBarry Smith  ViewerSetFormat(viewer,VIEWER_FORMAT_BINARY_NATIVE); the matrices will
38290ace30eSBarry Smith  be stored in a way natural for the matrix, for example dense matrices
38390ace30eSBarry Smith  would be stored as dense. Matrices stored this way may only be
38490ace30eSBarry Smith  read into matrices of the same time.
38590ace30eSBarry Smith */
38690ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
38790ace30eSBarry Smith 
3883f1d51d7SBarry Smith /*
3893f1d51d7SBarry Smith      New matrix classes not yet distributed
3903f1d51d7SBarry Smith */
3913f1d51d7SBarry Smith /*
3923f1d51d7SBarry Smith     MatAIJIndices is a data structure for storing the nonzero location information
3933f1d51d7SBarry Smith   for sparse matrices. Several matrices with identical nonzero structure can share
3943f1d51d7SBarry Smith   the same MatAIJIndices.
3953f1d51d7SBarry Smith */
396e2a1c21fSSatish Balay typedef struct _p_MatAIJIndices* MatAIJIndices;
3973f1d51d7SBarry Smith 
3983f1d51d7SBarry Smith extern int MatCreateAIJIndices(int,int,int*,int*,PetscTruth,MatAIJIndices*);
3993f1d51d7SBarry Smith extern int MatCreateAIJIndicesEmpty(int,int,int*,PetscTruth,MatAIJIndices*);
4003f1d51d7SBarry Smith extern int MatAttachAIJIndices(MatAIJIndices,MatAIJIndices*);
4013f1d51d7SBarry Smith extern int MatDestroyAIJIndices(MatAIJIndices);
4023f1d51d7SBarry Smith extern int MatCopyAIJIndices(MatAIJIndices,MatAIJIndices*);
4033f1d51d7SBarry Smith extern int MatValidateAIJIndices(int,MatAIJIndices);
4043f1d51d7SBarry Smith extern int MatShiftAIJIndices(MatAIJIndices);
4053f1d51d7SBarry Smith extern int MatShrinkAIJIndices(MatAIJIndices);
4063f1d51d7SBarry Smith extern int MatTransposeAIJIndices(MatAIJIndices, MatAIJIndices*);
4073f1d51d7SBarry Smith 
4083f1d51d7SBarry Smith extern int MatCreateSeqCSN(MPI_Comm,int,int,int*,int,Mat*);
4093f1d51d7SBarry Smith extern int MatCreateSeqCSN_Single(MPI_Comm,int,int,int*,int,Mat*);
4103f1d51d7SBarry Smith extern int MatCreateSeqCSNWithPrecision(MPI_Comm,int,int,int*,int,ScalarPrecision,Mat*);
4113f1d51d7SBarry Smith 
4123f1d51d7SBarry Smith extern int MatCreateSeqCSNIndices(MPI_Comm,MatAIJIndices,int,Mat *);
4133f1d51d7SBarry Smith extern int MatCreateSeqCSNIndices_Single(MPI_Comm,MatAIJIndices,int,Mat *);
4143f1d51d7SBarry Smith extern int MatCreateSeqCSNIndicesWithPrecision(MPI_Comm,MatAIJIndices,int,ScalarPrecision,Mat *);
4153f1d51d7SBarry Smith 
416aa6d738dSSatish Balay extern int MatMPIBAIJSetHashTableFactor(Mat,double);
4172e8a6d31SBarry Smith extern int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *);
418860d1616SSatish Balay 
4193f1d51d7SBarry Smith 
4202eac72dbSBarry Smith #endif
4212eac72dbSBarry Smith 
4222eac72dbSBarry Smith 
4239d00d63dSBarry Smith 
424