petsc-3.7.1 2016-05-15
Report Typos and Errors

# MatBlockMatSetPreallocation

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  MatBlockMatSetPreallocation(Mat B,PetscInt bs,PetscInt nz,const PetscInt nnz[])

Collective on MPI_Comm Many br

### Input Parameters

| B | - The matrix Many br
| bs | - size of each block in matrix Many br
| nz | - number of nonzeros per block row (same for all rows) Many br
| nnz | - array containing the number of nonzeros in the various block rows Many br(possibly different for each row) or NULL Many br

### Notes

If nnz is given then nz is ignored Many br

Specify the preallocated storage with either nz or nnz (not both). Many brSet nz=PETSC_DEFAULT and nnz=NULL for PETSc to control dynamic memory Many brallocation. For large problems you MUST preallocate memory or you Many brwill get TERRIBLE performance, see the users' manual chapter on matrices. Many br

Many br

### See Also

MatCreate(), MatCreateBlockMat(), MatSetValues()

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