Skip to main content
`Ctrl`+`K`

# MatCreateSeqSBAIJ

Creates a sparse symmetric matrix in (block compressed row) `MATSEQSBAIJ` format. For good matrix assembly performance the user should preallocate the matrix storage by setting the parameter `nz` (or the array `nnz`).

## Synopsis

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

Collective

## Input Parameters

- comm - MPI communicator, set to `PETSC_COMM_SELF`

- bs - size of block, the blocks are ALWAYS square. One can use `MatSetBlockSizes()` to set a different row and column blocksize but the row blocksize always defines the size of the blocks. The column blocksize sets the blocksize of the vectors obtained with MatCreateVecs()

- m - number of rows

- n - 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 `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

## Notes

It is recommended that one use `MatCreateFromOptions()` or the `MatCreate()`, `MatSetType()` and/or `MatSetFromOptions()`, MatXXXXSetPreallocation() paradigm instead of this routine directly. [MatXXXXSetPreallocation() is, for example, `MatSeqAIJSetPreallocation()`]

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` = `NULL` for PETSc to control dynamic memory allocation. See Sparse Matrices for details.

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

## See Also

Matrices, `Mat`, Sparse Matrices, `MATSEQSBAIJ`, `MatCreate()`, `MatCreateSeqAIJ()`, `MatSetValues()`, `MatCreateSBAIJ()`

## 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