# MatCreateSeqSBAIJ

Creates a sparse symmetric matrix in block AIJ (block compressed row) format. For good matrix assembly performance the user should preallocate the matrix storage by setting the parameter nz (or the array nnz). By setting these parameters accurately, performance during matrix assembly can be increased by more than a factor of 50.

### Synopsis

    #include "petscmat.h"
    PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqSBAIJ(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,const PetscInt nnz[],Mat *A)

Collective on MPI_Comm

### Input Parameters

| comm | - MPI communicator, set to PETSC_COMM_SELF
| bs | - size of block
| m | - number of rows, or number of columns
| nz | - number of block nonzeros per block row (same for all rows)
| nnz | - array containing the number of block nonzeros in the upper triangular plus diagonal portion of each block (possibly different for each block row) or PETSC_NULL

### Output Parameter

A -the symmetric matrix

### Options Database Keys

-mat_no_unroll -uses code that does not unroll the loops in the block calculations (much slower)
-mat_block_size -size of the blocks to use

### C++ variants

| MatCreateSeqSBAIJ(PetscInt bs,PetscInt m,PetscInt n,Mat *A) |  | -> |  | MatCreateSeqSBAIJ(PETSC_COMM_SELF,bs,m,n,0,PETSC_NULL,A)
| MatCreateSeqSBAIJ(PetscInt bs,PetscInt m,PetscInt n,const PetscInt nnz[],Mat *A) |  | -> |  | MatCreateSeqSBAIJ(PETSC_COMM_SELF,bs,m,n,0,nnz,A)
| MatCreateSeqSBAIJ(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,Mat *A) |  | -> |  | MatCreateSeqSBAIJ(PETSC_COMM_SELF,bs,m,n,nz,PETSC_NULL,A)
| Mat MatCreateSeqSBAIJ(PetscInt bs,PetscInt m,PetscInt n) |  | -> |  | MatCreateSeqSBAIJ(PETSC_COMM_SELF,bs,m,n,0,PETSC_NULL,&A); return A;
| Mat MatCreateSeqSBAIJ(PetscInt bs,PetscInt m,PetscInt n,const PetscInt nnz[]) |  | -> |  | MatCreateSeqSBAIJ(PETSC_COMM_SELF,bs,m,n,0,nnz,&A); return A;
| Mat MatCreateSeqSBAIJ(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz) |  | -> |  | MatCreateSeqSBAIJ(PETSC_COMM_SELF,bs,m,n,nz,PETSC_NULL,&A); return A;
| Mat MatCreateSeqSBAIJ(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,const PetscInt nnz[]) |  | -> |  | MatCreateSeqSBAIJ(PETSC_COMM_SELF,bs,m,n,nz,nnz,&A); return A;

### Notes

The number of rows and columns must be divisible by blocksize. This matrix type does not support complex Hermitian operation.

Specify the preallocated storage with either nz or nnz (not both). Set nz=PETSC_DEFAULT and nnz=PETSC_NULL for PETSc to control dynamic memory allocation. For additional details, see the users manual chapter on matrices.

If the nnz parameter is given then the nz parameter is ignored

### See Also

MatCreate(), MatCreateSeqAIJ(), MatSetValues(), MatCreateMPISBAIJ()

Level:intermediate
Location: src/mat/impls/sbaij/seq/sbaij.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/mat/examples/tutorials/ex6.c.html