Actual source code: aijtype.c

  1: #define PETSCMAT_DLL

 3:  #include include/private/matimpl.h

  5: /*MC
  6:    MATAIJ - MATAIJ = "aij" - A matrix type to be used for sparse matrices.

  8:    This matrix type is identical to MATSEQAIJ when constructed with a single process communicator,
  9:    and MATMPIAIJ otherwise.  As a result, for single process communicators, 
 10:   MatSeqAIJSetPreallocation is supported, and similarly MatMPIAIJSetPreallocation is supported 
 11:   for communicators controlling multiple processes.  It is recommended that you call both of
 12:   the above preallocation routines for simplicity.

 14:    Options Database Keys:
 15: . -mat_type aij - sets the matrix type to "aij" during a call to MatSetFromOptions()

 17:   Level: beginner

 19: .seealso: MatCreateMPIAIJ,MATSEQAIJ,MATMPIAIJ
 20: M*/

 25: PetscErrorCode  MatCreate_AIJ(Mat A)
 26: {
 28:   PetscMPIInt    size;

 31:   MPI_Comm_size(A->comm,&size);
 32:   if (size == 1) {
 33:     MatSetType(A,MATSEQAIJ);
 34:   } else {
 35:     MatSetType(A,MATMPIAIJ);
 36:   }
 37:   return(0);
 38: }

 41: /*MC
 42:    MATCRL - MATCRL = "crl" - A matrix type to be used for sparse matrices.

 44:    This matrix type is identical to MATSEQCRL when constructed with a single process communicator,
 45:    and MATMPICRL otherwise.  As a result, for single process communicators, 
 46:   MatSeqAIJSetPreallocation is supported, and similarly MatMPIAIJSetPreallocation is supported 
 47:   for communicators controlling multiple processes.  It is recommended that you call both of
 48:   the above preallocation routines for simplicity.

 50:    Options Database Keys:
 51: . -mat_type crl - sets the matrix type to "crl" during a call to MatSetFromOptions()

 53:   Level: beginner

 55: .seealso: MatCreateMPICRL,MATSEQCRL,MATMPICRL, MATSEQCRL, MATMPICRL
 56: M*/

 61: PetscErrorCode  MatCreate_CRL(Mat A)
 62: {
 64:   PetscMPIInt    size;

 67:   MPI_Comm_size(A->comm,&size);
 68:   if (size == 1) {
 69:     MatSetType(A,MATSEQCRL);
 70:   } else {
 71:     MatSetType(A,MATMPICRL);
 72:   }
 73:   return(0);
 74: }