MatPreallocatorPreallocate#
Preallocates the A matrix, using information from a MATPREALLOCATOR
mat, optionally filling A with zeros
Synopsis#
#include "petscmat.h"
PetscErrorCode MatPreallocatorPreallocate(Mat mat, PetscBool fill, Mat A)
Input Parameters#
mat - the
MATPREALLOCATOR
preallocator matrixfill - fill the matrix with zeros
A - the matrix to be preallocated
Notes#
This MatType
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 entries 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
);
This function may only be called once for a given MATPREALLOCATOR
object. If
multiple Mat
s need to be preallocated, consider using MatDuplicate()
after
this function.
See Also#
Level#
advanced
Location#
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