Skip to main content
`Ctrl`+`K`

# MatDuplicateOption

Indicates if a duplicated sparse matrix should have its numerical values copied over or just its nonzero structure.

## Synopsis

    typedef enum {
      MAT_DO_NOT_COPY_VALUES,
      MAT_COPY_VALUES,
      MAT_SHARE_NONZERO_PATTERN
    } MatDuplicateOption;

## Values

- `MAT_DO_NOT_COPY_VALUES` - Create a matrix using the same nonzero pattern as the original matrix, with zeros for the numerical values

- `MAT_COPY_VALUES` - Create a matrix with the same nonzero pattern as the original matrix and with the same numerical values.

- `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix and does not copy it, using zeros for the numerical values. The parent and child matrices will share their index (i and j) arrays, and you cannot insert new nonzero entries into either matrix

## Note

Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified.

## See Also

Matrices, `Mat`, `MatDuplicate()`

## Level

beginner

## Location

include/petscmat.h

## Examples

src/tao/tutorials/ex4.c
src/tao/pde_constrained/tutorials/parabolic.c
src/tao/pde_constrained/tutorials/elliptic.c
src/tao/pde_constrained/tutorials/hyperbolic.c

## Examples

src/ksp/pc/tutorials/ex4.c
src/ts/tutorials/ex20adj.c
src/mat/tutorials/ex20f.F90
src/ksp/ksp/tutorials/ex76.c
src/tao/tutorials/ex4.c
src/ts/tutorials/ex3.c
src/mat/tutorials/ex18.c

## Examples

src/tao/pde_constrained/tutorials/parabolic.c
src/mat/tutorials/ex20f.F90
src/tao/pde_constrained/tutorials/hyperbolic.c

## Examples

src/ksp/pc/tutorials/ex4.c
src/ksp/ksp/tutorials/ex81.c
src/ksp/ksp/tutorials/ex5.c
src/ksp/ksp/tutorials/ex87.c
src/ksp/ksp/tutorials/ex76.c
src/ksp/ksp/tutorials/ex42.c
src/tao/pde_constrained/tutorials/hyperbolic.c
src/ksp/ksp/tutorials/ex5f.F90
src/ksp/ksp/tutorials/ex81a.c
src/ksp/ksp/tutorials/ex76f.F90

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