1 /* $Id: mat.h,v 1.186 2000/01/13 22:20:22 bsmith Exp bsmith $ */ 2 /* 3 Include file for the matrix component of PETSc 4 */ 5 #ifndef __MAT_H 6 #define __MAT_H 7 #include "vec.h" 8 9 #define MAT_COOKIE PETSC_COOKIE+5 10 11 typedef struct _p_Mat* Mat; 12 13 #define MAX_MATRIX_TYPES 14 14 /* 15 The default matrix data storage formats and routines to create them. 16 17 MATLASTTYPE is "end-of-list" marker that can be used to check that 18 MAX_MATRIX_TYPES is large enough. The rule is 19 MAX_MATRIX_TYPES >= MATLASTTYPE . 20 21 To do: add a test program that checks the consistency of these values. 22 */ 23 typedef enum { MATSAME=-1, MATSEQDENSE, MATSEQAIJ, MATMPIAIJ, MATSHELL, 24 MATMPIROWBS, MATSEQBDIAG, MATMPIBDIAG, MATMPIDENSE, MATSEQBAIJ, 25 MATMPIBAIJ, MATMPICSN, MATSEQCSN, MATMPICSR, MATSEQSBAIJ, 26 MATLASTTYPE } MatType; 27 28 extern int MatCreate(MPI_Comm,int,int,int,int,Mat*); 29 extern int MatCreateSeqDense(MPI_Comm,int,int,Scalar*,Mat*); 30 extern int MatCreateMPIDense(MPI_Comm,int,int,int,int,Scalar*,Mat*); 31 extern int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*); 32 extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*); 33 extern int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,void*,Mat*); 34 extern int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,Scalar**,Mat*); 35 extern int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,Scalar**,Mat*); 36 extern int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,int*,Mat*); 37 extern int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*); 38 extern int MatCreateMPICSR(MPI_Comm,int,int,int*,int*,int *,Mat*); 39 40 extern int MatDestroy(Mat); 41 42 extern int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*); 43 extern int MatShellGetContext(Mat,void **); 44 45 extern int MatPrintHelp(Mat); 46 extern int MatGetMaps(Mat,Map*,Map*); 47 48 /* ------------------------------------------------------------*/ 49 extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode); 50 extern int MatSetValuesBlocked(Mat,int,int*,int,int*,Scalar*,InsertMode); 51 52 typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType; 53 extern int MatAssemblyBegin(Mat,MatAssemblyType); 54 extern int MatAssemblyEnd(Mat,MatAssemblyType); 55 extern int MatAssembled(Mat,PetscTruth*); 56 57 #define MatSetValue(v,i,j,va,mode) \ 58 {int _ierr,_row = i,_col = j; Scalar _va = va; \ 59 _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \ 60 } 61 #define MatGetValue(v,i,j,va) \ 62 {int _ierr,_row = i,_col = j; \ 63 _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \ 64 } 65 /* 66 Any additions/changes here MUST also be made in include/finclude/mat.h 67 */ 68 typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4, 69 MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16, 70 MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64, 71 MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66, 72 MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69, 73 MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72, 74 MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74, 75 MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76, 76 MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78, 77 MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81, 78 MAT_DO_NOT_USE_INODES} MatOption; 79 extern int MatSetOption(Mat,MatOption); 80 extern int MatGetType(Mat,MatType*,char**); 81 extern int MatGetTypeFromOptions(MPI_Comm,char*,MatType*,PetscTruth*); 82 83 extern int MatGetValues(Mat,int,int*,int,int*,Scalar*); 84 extern int MatGetRow(Mat,int,int *,int **,Scalar**); 85 extern int MatRestoreRow(Mat,int,int *,int **,Scalar**); 86 extern int MatGetColumn(Mat,int,int *,int **,Scalar**); 87 extern int MatRestoreColumn(Mat,int,int *,int **,Scalar**); 88 extern int MatGetColumnVector(Mat,Vec,int); 89 extern int MatGetArray(Mat,Scalar **); 90 extern int MatRestoreArray(Mat,Scalar **); 91 extern int MatGetBlockSize(Mat,int *); 92 93 extern int MatMult(Mat,Vec,Vec); 94 extern int MatMultAdd(Mat,Vec,Vec,Vec); 95 extern int MatMultTranspose(Mat,Vec,Vec); 96 extern int MatMultTransposeAdd(Mat,Vec,Vec,Vec); 97 98 typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption; 99 100 extern int MatConvert(Mat,MatType,Mat*); 101 extern int MatDuplicate(Mat,MatDuplicateOption,Mat*); 102 extern int MatConvertRegister(MatType,MatType,int (*)(Mat,MatType,Mat*)); 103 extern int MatConvertRegisterAll(void); 104 105 typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER} MatStructure; 106 107 extern int MatCopy(Mat,Mat,MatStructure); 108 extern int MatView(Mat,Viewer); 109 extern int MatLoad(Viewer,MatType,Mat*); 110 extern int MatLoadRegister(MatType,int (*)(Viewer,MatType,Mat*)); 111 extern int MatLoadRegisterAll(void); 112 113 extern int MatGetRowIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *); 114 extern int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *); 115 extern int MatGetColumnIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *); 116 extern int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *); 117 118 /* 119 Context of matrix information, used with MatGetInfo() 120 Note: If any entries are added to this context, be sure 121 to adjust MAT_INFO_SIZE in finclude/mat.h 122 */ 123 typedef struct { 124 PLogDouble rows_global,columns_global; /* number of global rows and columns */ 125 PLogDouble rows_local,columns_local; /* number of local rows and columns */ 126 PLogDouble block_size; /* block size */ 127 PLogDouble nz_allocated,nz_used,nz_unneeded; /* number of nonzeros */ 128 PLogDouble memory; /* memory allocated */ 129 PLogDouble assemblies; /* number of matrix assemblies */ 130 PLogDouble mallocs; /* number of mallocs during MatSetValues() */ 131 PLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */ 132 PLogDouble factor_mallocs; /* number of mallocs during factorization */ 133 } MatInfo; 134 135 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 136 extern int MatGetInfo(Mat,MatInfoType,MatInfo*); 137 extern int MatValid(Mat,PetscTruth*); 138 extern int MatGetDiagonal(Mat,Vec); 139 extern int MatTranspose(Mat,Mat*); 140 extern int MatPermute(Mat,IS,IS,Mat *); 141 extern int MatDiagonalScale(Mat,Vec,Vec); 142 extern int MatDiagonalShift(Mat,Vec); 143 extern int MatEqual(Mat,Mat,PetscTruth*); 144 145 extern int MatNorm(Mat,NormType,double *); 146 extern int MatZeroEntries(Mat); 147 extern int MatZeroRows(Mat,IS,Scalar*); 148 extern int MatZeroColumns(Mat,IS,Scalar*); 149 150 extern int MatUseScaledForm(Mat,PetscTruth); 151 extern int MatScaleSystem(Mat,Vec,Vec); 152 extern int MatUnScaleSystem(Mat,Vec,Vec); 153 154 extern int MatGetSize(Mat,int*,int*); 155 extern int MatGetLocalSize(Mat,int*,int*); 156 extern int MatGetOwnershipRange(Mat,int*,int*); 157 158 typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse; 159 extern int MatGetSubMatrices(Mat,int,IS *,IS *,MatReuse,Mat **); 160 extern int MatDestroyMatrices(int,Mat **); 161 extern int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *); 162 163 extern int MatIncreaseOverlap(Mat,int,IS *,int); 164 165 extern int MatAXPY(Scalar *,Mat,Mat); 166 extern int MatAYPX(Scalar *,Mat,Mat); 167 extern int MatCompress(Mat); 168 169 extern int MatScale(Scalar *,Mat); 170 extern int MatShift(Scalar *,Mat); 171 172 extern int MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping); 173 extern int MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping); 174 extern int MatZeroRowsLocal(Mat,IS,Scalar*); 175 extern int MatSetValuesLocal(Mat,int,int*,int,int*,Scalar*,InsertMode); 176 extern int MatSetValuesBlockedLocal(Mat,int,int*,int,int*,Scalar*,InsertMode); 177 178 extern int MatSetStashInitialSize(Mat,int,int); 179 180 extern int MatInterpolateAdd(Mat,Vec,Vec,Vec); 181 extern int MatInterpolate(Mat,Vec,Vec); 182 extern int MatRestrict(Mat,Vec,Vec); 183 184 /* 185 These three macros MUST be used together. The third one closes the open { of the first one 186 */ 187 #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) \ 188 { \ 189 int __ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \ 190 dnz = (int*)PetscMalloc(2*__tmp*sizeof(int));CHKPTRQ(dnz);onz = dnz + __tmp;\ 191 __ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(__ierr);\ 192 __ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(__ierr); __start = __end - __ctmp;\ 193 __ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(__ierr); __rstart = __rstart - __tmp; 194 195 #define MatPreallocateSet(row,nc,cols,dnz,onz)\ 196 { int __i; \ 197 for (__i=0; __i<nc; __i++) {\ 198 if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \ 199 }\ 200 dnz[row - __rstart] = nc - onz[row - __rstart];\ 201 } 202 203 #define MatPreallocateFinalize(dnz,onz) __ierr = PetscFree(dnz);CHKERRQ(__ierr);} 204 205 /* Routines unique to particular data structures */ 206 extern int MatBDiagGetData(Mat,int*,int*,int**,int**,Scalar***); 207 extern int MatSeqAIJSetColumnIndices(Mat,int *); 208 extern int MatSeqBAIJSetColumnIndices(Mat,int *); 209 extern int MatCreateSeqAIJWithArrays(MPI_Comm,int,int,int*,int*,Scalar *,Mat*); 210 211 extern int MatStoreValues(Mat); 212 extern int MatRetrieveValues(Mat); 213 214 /* 215 These routines are not usually accessed directly, rather solving is 216 done through the SLES, KSP and PC interfaces. 217 */ 218 219 typedef char* MatOrderingType; 220 #define MATORDERING_NATURAL "natural" 221 #define MATORDERING_ND "nd" 222 #define MATORDERING_1WD "1wd" 223 #define MATORDERING_RCM "rcm" 224 #define MATORDERING_QMD "qmd" 225 #define MATORDERING_ROWLENGTH "rowlength" 226 227 extern int MatGetOrdering(Mat,MatOrderingType,IS*,IS*); 228 extern int MatOrderingRegister(char*,char*,char*,int(*)(Mat,MatOrderingType,IS*,IS*)); 229 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 230 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0) 231 #else 232 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d) 233 #endif 234 extern int MatOrderingRegisterDestroy(void); 235 extern int MatOrderingRegisterAll(char*); 236 extern PetscTruth MatOrderingRegisterAllCalled; 237 238 extern int MatReorderForNonzeroDiagonal(Mat,double,IS,IS); 239 240 extern int MatCholeskyFactor(Mat,IS,double); 241 extern int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*); 242 extern int MatCholeskyFactorNumeric(Mat,Mat*); 243 244 /* 245 Context of matrix information, used with MatILUFactor() and MatILUFactorSymbolic() 246 Note: If any entries are added to this context, be sure 247 to adjust MAT_ILUINFO_SIZE in finclude/mat.h 248 249 Note: The integer values below are passed in double to allow easy use from 250 Fortran 251 */ 252 typedef struct { 253 double levels; /* ILU(levels) */ 254 double fill; /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/ 255 double diagonal_fill; /* force diagonal to fill in if initially not filled */ 256 257 double dt; /* drop tolerance */ 258 double dtcol; /* tolerance for pivoting */ 259 double dtcount; /* maximum nonzeros to be allowed per row */ 260 } MatILUInfo; 261 262 extern int MatLUFactor(Mat,IS,IS,double); 263 extern int MatILUFactor(Mat,IS,IS,MatILUInfo*); 264 extern int MatLUFactorSymbolic(Mat,IS,IS,double,Mat*); 265 extern int MatILUFactorSymbolic(Mat,IS,IS,MatILUInfo*,Mat*); 266 extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,double,int,Mat*); 267 extern int MatLUFactorNumeric(Mat,Mat*); 268 extern int MatILUDTFactor(Mat,MatILUInfo*,IS,IS,Mat *); 269 270 extern int MatSolve(Mat,Vec,Vec); 271 extern int MatForwardSolve(Mat,Vec,Vec); 272 extern int MatBackwardSolve(Mat,Vec,Vec); 273 extern int MatSolveAdd(Mat,Vec,Vec,Vec); 274 extern int MatSolveTranspose(Mat,Vec,Vec); 275 extern int MatSolveTransposeAdd(Mat,Vec,Vec,Vec); 276 277 extern int MatSetUnfactored(Mat); 278 279 /* MatSORType may be bitwise ORd together, so do not change the numbers */ 280 281 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 282 SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 283 SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 284 SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType; 285 extern int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec); 286 287 /* 288 These routines are for efficiently computing Jacobians via finite differences. 289 */ 290 291 typedef char* MatColoringType; 292 #define MATCOLORING_NATURAL "natural" 293 #define MATCOLORING_SL "sl" 294 #define MATCOLORING_LF "lf" 295 #define MATCOLORING_ID "id" 296 297 extern int MatGetColoring(Mat,MatColoringType,ISColoring*); 298 extern int MatColoringRegister(char*,char*,char*,int(*)(Mat,MatColoringType,ISColoring *)); 299 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 300 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0) 301 #else 302 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d) 303 #endif 304 extern int MatColoringRegisterAll(char *); 305 extern PetscTruth MatColoringRegisterAllCalled; 306 extern int MatColoringRegisterDestroy(void); 307 extern int MatColoringPatch(Mat,int,int *,ISColoring*); 308 309 /* 310 Data structures used to compute Jacobian vector products 311 efficiently using finite differences. 312 */ 313 #define MAT_FDCOLORING_COOKIE PETSC_COOKIE + 23 314 315 typedef struct _p_MatFDColoring *MatFDColoring; 316 317 extern int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *); 318 extern int MatFDColoringDestroy(MatFDColoring); 319 extern int MatFDColoringView(MatFDColoring,Viewer); 320 extern int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*); 321 extern int MatFDColoringSetParameters(MatFDColoring,double,double); 322 extern int MatFDColoringSetFrequency(MatFDColoring,int); 323 extern int MatFDColoringGetFrequency(MatFDColoring,int*); 324 extern int MatFDColoringSetFromOptions(MatFDColoring); 325 extern int MatFDColoringPrintHelp(MatFDColoring); 326 extern int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *); 327 extern int MatFDColoringApplyTS(Mat,MatFDColoring,double,Vec,MatStructure*,void *); 328 329 /* 330 These routines are for partitioning matrices: currently used only 331 for adjacency matrix, MatCreateMPICSR(). 332 */ 333 #define MATPARTITIONING_COOKIE PETSC_COOKIE + 25 334 335 typedef struct _p_MatPartitioning *MatPartitioning; 336 typedef char* MatPartitioningType; 337 #define MATPARTITIONING_CURRENT "current" 338 #define MATPARTITIONING_PARMETIS "parmetis" 339 340 extern int MatPartitioningCreate(MPI_Comm,MatPartitioning*); 341 extern int MatPartitioningSetType(MatPartitioning,MatPartitioningType); 342 extern int MatPartitioningSetAdjacency(MatPartitioning,Mat); 343 extern int MatPartitioningSetVertexWeights(MatPartitioning,int*); 344 extern int MatPartitioningApply(MatPartitioning,IS*); 345 extern int MatPartitioningDestroy(MatPartitioning); 346 347 extern int MatPartitioningRegister(char*,char*,char*,int(*)(MatPartitioning)); 348 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 349 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0) 350 #else 351 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d) 352 #endif 353 354 extern int MatPartitioningRegisterAll(char *); 355 extern PetscTruth MatPartitioningRegisterAllCalled; 356 extern int MatPartitioningRegisterDestroy(void); 357 358 extern int MatPartitioningView(MatPartitioning,Viewer); 359 extern int MatPartitioningSetFromOptions(MatPartitioning); 360 extern int MatPartitioningPrintHelp(MatPartitioning); 361 extern int MatPartitioningGetType(MatPartitioning,MatPartitioningType*); 362 363 extern int MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 364 365 /* 366 If you add entries here you must also add them to finclude/mat.h 367 */ 368 typedef enum { MATOP_SET_VALUES=0, 369 MATOP_GET_ROW=1, 370 MATOP_RESTORE_ROW=2, 371 MATOP_MULT=3, 372 MATOP_MULT_ADD=4, 373 MATOP_MULT_TRANSPOSE=5, 374 MATOP_MULT_TRANSPOSE_ADD=6, 375 MATOP_SOLVE=7, 376 MATOP_SOLVE_ADD=8, 377 MATOP_SOLVE_TRANSPOSE=9, 378 MATOP_SOLVE_TRANSPOSE_ADD=10, 379 MATOP_LUFACTOR=11, 380 MATOP_CHOLESKYFACTOR=12, 381 MATOP_RELAX=13, 382 MATOP_TRANSPOSE=14, 383 MATOP_GETINFO=15, 384 MATOP_EQUAL=16, 385 MATOP_GET_DIAGONAL=17, 386 MATOP_DIAGONAL_SCALE=18, 387 MATOP_NORM=19, 388 MATOP_ASSEMBLY_BEGIN=20, 389 MATOP_ASSEMBLY_END=21, 390 MATOP_COMPRESS=22, 391 MATOP_SET_OPTION=23, 392 MATOP_ZERO_ENTRIES=24, 393 MATOP_ZERO_ROWS=25, 394 MATOP_LUFACTOR_SYMBOLIC=26, 395 MATOP_LUFACTOR_NUMERIC=27, 396 MATOP_CHOLESKY_FACTOR_SYMBOLIC=28, 397 MATOP_CHOLESKY_FACTOR_NUMERIC=29, 398 MATOP_GET_SIZE=30, 399 MATOP_GET_LOCAL_SIZE=31, 400 MATOP_GET_OWNERSHIP_RANGE=32, 401 MATOP_ILUFACTOR_SYMBOLIC=33, 402 MATOP_INCOMPLETECHOLESKYFACTOR_SYMBOLIC=34, 403 MATOP_GET_ARRAY=35, 404 MATOP_RESTORE_ARRAY=36, 405 406 MATOP_CONVERT_SAME_TYPE=37, 407 MATOP_FORWARD_SOLVE=38, 408 MATOP_BACKWARD_SOLVE=39, 409 MATOP_ILUFACTOR=40, 410 MATOP_INCOMPLETECHOLESKYFACTOR=41, 411 MATOP_AXPY=42, 412 MATOP_GET_SUBMATRICES=43, 413 MATOP_INCREASE_OVERLAP=44, 414 MATOP_GET_VALUES=45, 415 MATOP_COPY=46, 416 MATOP_PRINT_HELP=47, 417 MATOP_SCALE=48, 418 MATOP_SHIFT=49, 419 MATOP_DIAGONAL_SHIFT=50, 420 MATOP_ILUDT_FACTOR=51, 421 MATOP_GET_BLOCK_SIZE=52, 422 MATOP_GET_ROW_IJ=53, 423 MATOP_RESTORE_ROW_IJ=54, 424 MATOP_GET_COLUMN_IJ=55, 425 MATOP_RESTORE_COLUMN_IJ=56, 426 MATOP_FDCOLORING_CREATE=57, 427 MATOP_COLORING_PATCH=58, 428 MATOP_SET_UNFACTORED=59, 429 MATOP_PERMUTE=60, 430 MATOP_SET_VALUES_BLOCKED=61, 431 MATOP_DESTROY=250, 432 MATOP_VIEW=251 433 } MatOperation; 434 extern int MatHasOperation(Mat,MatOperation,PetscTruth*); 435 extern int MatShellSetOperation(Mat,MatOperation,void *); 436 extern int MatShellGetOperation(Mat,MatOperation,void **); 437 438 /* 439 Codes for matrices stored on disk. By default they are 440 stored in a universal format. By changing the format with 441 ViewerSetFormat(viewer,VIEWER_FORMAT_BINARY_NATIVE); the matrices will 442 be stored in a way natural for the matrix, for example dense matrices 443 would be stored as dense. Matrices stored this way may only be 444 read into matrices of the same time. 445 */ 446 #define MATRIX_BINARY_FORMAT_DENSE -1 447 448 /* 449 New matrix classes not yet distributed 450 */ 451 /* 452 MatAIJIndices is a data structure for storing the nonzero location information 453 for sparse matrices. Several matrices with identical nonzero structure can share 454 the same MatAIJIndices. 455 */ 456 typedef struct _p_MatAIJIndices* MatAIJIndices; 457 458 extern int MatCreateAIJIndices(int,int,int*,int*,PetscTruth,MatAIJIndices*); 459 extern int MatCreateAIJIndicesEmpty(int,int,int*,PetscTruth,MatAIJIndices*); 460 extern int MatAttachAIJIndices(MatAIJIndices,MatAIJIndices*); 461 extern int MatDestroyAIJIndices(MatAIJIndices); 462 extern int MatCopyAIJIndices(MatAIJIndices,MatAIJIndices*); 463 extern int MatValidateAIJIndices(int,MatAIJIndices); 464 extern int MatShiftAIJIndices(MatAIJIndices); 465 extern int MatShrinkAIJIndices(MatAIJIndices); 466 extern int MatTransposeAIJIndices(MatAIJIndices,MatAIJIndices*); 467 468 extern int MatCreateSeqCSN(MPI_Comm,int,int,int*,int,Mat*); 469 extern int MatCreateSeqCSN_Single(MPI_Comm,int,int,int*,int,Mat*); 470 extern int MatCreateSeqCSNWithPrecision(MPI_Comm,int,int,int*,int,ScalarPrecision,Mat*); 471 472 extern int MatCreateSeqCSNIndices(MPI_Comm,MatAIJIndices,int,Mat *); 473 extern int MatCreateSeqCSNIndices_Single(MPI_Comm,MatAIJIndices,int,Mat *); 474 extern int MatCreateSeqCSNIndicesWithPrecision(MPI_Comm,MatAIJIndices,int,ScalarPrecision,Mat *); 475 476 extern int MatMPIBAIJSetHashTableFactor(Mat,double); 477 extern int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *); 478 479 480 #endif 481 482 483 484