# MatCopy#

Copies a matrix to another matrix.

## Synopsis#

#include "petscmat.h"
PetscErrorCode MatCopy(Mat A, Mat B, MatStructure str)


Collective on A

## Input Parameters#

• A - the matrix

• str - SAME_NONZERO_PATTERN or DIFFERENT_NONZERO_PATTERN

## Output Parameter#

• B - where the copy is put

## Notes#

If you use SAME_NONZERO_PATTERN then the two matrices must have the same nonzero pattern or the routine will crash.

MatCopy() copies the matrix entries of a matrix to another existing matrix (after first zeroing the second matrix). A related routine is MatConvert(), which first creates a new matrix and then copies the data.

Mat, MatConvert(), MatDuplicate()

intermediate

## Location#

src/mat/interface/matrix.c

Edit on GitLab