1 #ifdef PETSC_RCS_HEADER 2 static char vcid[] = "$Id: gcreate.c,v 1.103 1997/07/02 22:26:14 bsmith Exp balay $"; 3 #endif 4 5 #include "sys.h" 6 #include "mat.h" /*I "mat.h" I*/ 7 8 #undef __FUNC__ 9 #define __FUNC__ "MatCreate" 10 /*@C 11 MatCreate - Creates a matrix where the type is determined 12 from the options database. Generates a parallel MPI matrix if the 13 communicator has more than one processor. The default matrix type is 14 AIJ, using the routines MatCreateSeqAIJ() and MatCreateMPIAIJ(). 15 16 Input Parameters: 17 . m - number of global rows 18 . n - number of global columns 19 . comm - MPI communicator 20 21 Output Parameter: 22 . A - the matrix 23 24 Basic Options Database Keys: 25 These options use MatCreateSeqXXX or MatCreateMPIXXX, 26 depending on the communicator, comm. 27 $ -mat_aij : AIJ type 28 $ -mat_baij : block AIJ type 29 $ -mat_dense : dense type 30 $ -mat_bdiag : block diagonal type 31 32 More Options Database Keys: 33 $ -mat_seqaij : AIJ type, uses MatCreateSeqAIJ() 34 $ -mat_mpiaij : AIJ type, uses MatCreateMPIAIJ() 35 $ -mat_seqbdiag : block diagonal type, uses 36 $ MatCreateSeqBDiag() 37 $ -mat_mpibdiag : block diagonal type, uses 38 $ MatCreateMPIBDiag() 39 $ -mat_mpirowbs : rowbs type, uses MatCreateMPIRowbs() 40 $ -mat_seqdense : dense type, uses MatCreateSeqDense() 41 $ -mat_mpidense : dense type, uses MatCreateMPIDense() 42 $ -mat_seqbaij : block AIJ type, uses MatCreateSeqBAIJ() 43 $ -mat_mpibaij : block AIJ type, uses MatCreateMPIBAIJ() 44 45 Even More Options Database Keys: 46 See the manpages for particular formats (e.g., MatCreateSeqAIJ()) 47 for additional format-specific options. 48 49 Notes: 50 This routine calls MatGetTypeFromOptions() to determind the matrix type. 51 52 .keywords: matrix, create 53 54 .seealso: MatCreateSeqAIJ((), MatCreateMPIAIJ(), 55 MatCreateSeqBDiag(),MatCreateMPIBDiag(), 56 MatCreateSeqDense(), MatCreateMPIDense(), 57 MatCreateMPIRowbs(), MatCreateSeqBAIJ, 58 MatConvert(), MatGetTypeFromOptions() 59 @*/ 60 int MatCreate(MPI_Comm comm,int m,int n,Mat *A) 61 { 62 MatType type; 63 PetscTruth set; 64 int ierr, bs=1, flg; 65 66 ierr = MatGetTypeFromOptions(comm,0,&type,&set); CHKERRQ(ierr); 67 switch (type) { 68 case MATSEQDENSE: 69 ierr = MatCreateSeqDense(comm,m,n,PETSC_NULL,A); CHKERRQ(ierr); 70 break; 71 case MATMPIBDIAG: 72 ierr = MatCreateMPIBDiag(comm,PETSC_DECIDE,m,n,PETSC_DEFAULT,PETSC_DEFAULT, 73 PETSC_NULL,PETSC_NULL,A); CHKERRQ(ierr); 74 break; 75 case MATSEQBDIAG: 76 ierr = MatCreateSeqBDiag(comm,m,n,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_NULL, 77 PETSC_NULL,A); CHKERRQ(ierr); 78 break; 79 case MATMPIROWBS: 80 ierr = MatCreateMPIRowbs(comm,PETSC_DECIDE,m,PETSC_DEFAULT,PETSC_NULL, 81 PETSC_NULL,A); CHKERRQ(ierr); 82 break; 83 case MATMPIDENSE: 84 ierr = MatCreateMPIDense(comm,PETSC_DECIDE,PETSC_DECIDE,m,n,PETSC_NULL,A); CHKERRQ(ierr); 85 break; 86 case MATMPIAIJ: 87 ierr = MatCreateMPIAIJ(comm,PETSC_DECIDE,PETSC_DECIDE,m,n,PETSC_DEFAULT, 88 PETSC_NULL,PETSC_DEFAULT,PETSC_NULL,A); CHKERRQ(ierr); 89 break; 90 case MATSEQBAIJ: 91 ierr = OptionsGetInt(PETSC_NULL,"-mat_block_size",&bs,&flg); CHKERRQ(ierr); 92 ierr = MatCreateSeqBAIJ(comm,bs,m,n,PETSC_DEFAULT,PETSC_NULL,A); CHKERRQ(ierr); 93 break; 94 case MATMPIBAIJ: 95 ierr = OptionsGetInt(PETSC_NULL,"-mat_block_size",&bs,&flg); CHKERRQ(ierr); 96 ierr = MatCreateMPIBAIJ(comm,bs,PETSC_DECIDE,PETSC_DECIDE,m,n,PETSC_DEFAULT,PETSC_NULL,PETSC_DEFAULT,PETSC_NULL,A); CHKERRQ(ierr); 97 break; 98 default: 99 ierr = MatCreateSeqAIJ(comm,m,n,PETSC_DEFAULT,PETSC_NULL,A); CHKERRQ(ierr); 100 break; 101 } 102 return 0; 103 } 104 105 106 107 108 109