# MatCreateSeqBDiag

Creates a sequential block diagonal matrix.

### Synopsis

    PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqBDiag(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt nd,PetscInt bs,const PetscInt diag[],PetscScalar *diagv[],Mat *A)

Collective on MPI_Comm

### Input Parameters

| comm | - MPI communicator, set to PETSC_COMM_SELF
| m | - number of rows
| n | - number of columns
| nd | - number of block diagonals (optional)
| bs | - each element of a diagonal is an bs x bs dense matrix
| diag | - optional array of block diagonal numbers (length nd). For a matrix element A[i,j], where i=row and j=column, the diagonal number is

        diag = i/bs - j/bs  (integer division)

Set diag=PETSC_NULL on input for PETSc to dynamically allocate memory as needed (expensive).
| diagv | - pointer to actual diagonals (in same order as diag array), if allocated by user. Otherwise, set diagv=PETSC_NULL on input for PETSc to control memory allocation.

### Output Parameters

A -the matrix

### Options Database Keys

-mat_block_size <bs> -Sets blocksize
-mat_bdiag_diags <s1,s2,s3,...> -Sets diagonal numbers

### Notes

See the users manual for further details regarding this storage format.

### Fortran Note

Fortran programmers cannot set diagv; this value is ignored.

### Keywords

matrix, block, diagonal, sparse

### See Also

MatCreate(), MatCreateMPIBDiag(), MatSetValues()

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