petsc-3.11.4 2019-09-28
Report Typos and Errors

MatPreallocatorPreallocate

Preallocates the A matrix, using information from mat, optionally filling A with zeros

Synopsis

#include "petscmat.h" 
PetscErrorCode MatPreallocatorPreallocate(Mat mat, PetscBool fill, Mat A)

Input Parameter

mat - the preallocator
fill - fill the matrix with zeros
A - the matrix to be preallocated

Notes

This Mat implementation provides a helper utility to define the correct preallocation data for a given nonzero structure. Use this object like a regular matrix, e.g. loop over the nonzero structure of the matrix and call MatSetValues() or MatSetValuesBlocked() to indicate the nonzero locations. The matrix entires provided to MatSetValues() will be ignored, it only uses the row / col indices provided to determine the information required to be passed to MatXAIJSetPreallocation(). Once you have looped over the nonzero structure, you must call MatAssemblyBegin(), MatAssemblyEnd() on mat.

After you have assembled the preallocator matrix (mat), call MatPreallocatorPreallocate() to define the preallocation information on the matrix (A). Setting the parameter fill = PETSC_TRUE will insert zeros into the matrix A. Internally MatPreallocatorPreallocate() will call MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_TRUE);

See Also

MATPREALLOCATOR

Level

advanced

Location

src/mat/impls/preallocator/matpreallocator.c

Implementations

MatPreallocatorPreallocate_Preallocator in src/mat/impls/preallocator/matpreallocator.c

Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages