1 2 #ifndef lint 3 static char vcid[] = "$Id: gcreate.c,v 1.101 1997/01/06 20:26:03 balay Exp bsmith $"; 4 #endif 5 6 #include "sys.h" 7 #include "mat.h" /*I "mat.h" I*/ 8 9 #undef __FUNC__ 10 #define __FUNC__ "MatCreate" 11 /*@C 12 MatCreate - Creates a matrix where the type is determined 13 from the options database. Generates a parallel MPI matrix if the 14 communicator has more than one processor. The default matrix type is 15 AIJ, using the routines MatCreateSeqAIJ() and MatCreateMPIAIJ(). 16 17 Input Parameters: 18 . m - number of global rows 19 . n - number of global columns 20 . comm - MPI communicator 21 22 Output Parameter: 23 . A - the matrix 24 25 Basic Options Database Keys: 26 These options use MatCreateSeqXXX or MatCreateMPIXXX, 27 depending on the communicator, comm. 28 $ -mat_aij : AIJ type 29 $ -mat_baij : block AIJ type 30 $ -mat_dense : dense type 31 $ -mat_bdiag : block diagonal type 32 33 More Options Database Keys: 34 $ -mat_seqaij : AIJ type, uses MatCreateSeqAIJ() 35 $ -mat_mpiaij : AIJ type, uses MatCreateMPIAIJ() 36 $ -mat_seqbdiag : block diagonal type, uses 37 $ MatCreateSeqBDiag() 38 $ -mat_mpibdiag : block diagonal type, uses 39 $ MatCreateMPIBDiag() 40 $ -mat_mpirowbs : rowbs type, uses MatCreateMPIRowbs() 41 $ -mat_seqdense : dense type, uses MatCreateSeqDense() 42 $ -mat_mpidense : dense type, uses MatCreateMPIDense() 43 $ -mat_seqbaij : block AIJ type, uses MatCreateSeqBAIJ() 44 $ -mat_mpibaij : block AIJ type, uses MatCreateMPIBAIJ() 45 46 Even More Options Database Keys: 47 See the manpages for particular formats (e.g., MatCreateSeqAIJ()) 48 for additional format-specific options. 49 50 Notes: 51 This routine calls MatGetTypeFromOptions() to determind the matrix type. 52 53 .keywords: matrix, create 54 55 .seealso: MatCreateSeqAIJ((), MatCreateMPIAIJ(), 56 MatCreateSeqBDiag(),MatCreateMPIBDiag(), 57 MatCreateSeqDense(), MatCreateMPIDense(), 58 MatCreateMPIRowbs(), MatCreateSeqBAIJ, 59 MatConvert(), MatGetTypeFromOptions() 60 @*/ 61 int MatCreate(MPI_Comm comm,int m,int n,Mat *A) 62 { 63 MatType type; 64 int set, 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