MatHeaderReplace#
Replaces the internal data of matrix A by the internal data of matrix C while deleting the outer wrapper of C
Synopsis#
#include "petscmat.h"
PetscErrorCode MatHeaderReplace(Mat A, Mat *C)
Input Parameters#
Example Usage:
Mat C;
MatCreateSeqAIJWithArrays(..., &C);
MatHeaderReplace(A, &C);
// C has been destroyed and A contains the matrix entries of C
Note#
This can be used inside a function provided to SNESSetJacobian(), TSSetRHSJacobian(), or TSSetIJacobian() in cases where the user code computes an entirely new sparse matrix
(generally with a different nonzero pattern) for each Newton update. It is usually better to reuse the matrix structure of A instead of constructing an entirely new one.
Developer Note#
This is somewhat different from MatHeaderMerge() it would be nice to merge the code
See Also#
Level#
advanced
Location#
Examples#
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages