Skip to main content
`Ctrl`+`K`

# MatDenseReplaceArray

Allows one to replace the array in a dense matrix with an array provided by the user. This is useful to avoid copying an array into a matrix

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatDenseReplaceArray(Mat mat, const PetscScalar *array)

Not Collective

## Input Parameters

- mat - the matrix

- array - the array in column major order

## Note

Adding `const` to `array` was an oversight, see notes in `VecPlaceArray()`.

The memory passed in MUST be obtained with `PetscMalloc()` and CANNOT be freed by the user. It will be freed when the matrix is destroyed.

## See Also

Matrices, `Mat`, `MatDensePlaceArray()`, `MatDenseGetArray()`, `VecReplaceArray()`

## Level

developer

## Location

src/mat/impls/dense/mpi/mpidense.c

## Implementations

MatDenseReplaceArray_MPIDense() in src/mat/impls/dense/mpi/mpidense.c
MatDenseReplaceArray_SeqDense() in src/mat/impls/dense/seq/dense.c

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