# MatDenseCUDAReplaceArray
Allows one to replace the GPU array in a `MATDENSECUDA` matrix with an array provided by the user. This is useful to avoid copying an array into a matrix 
## Synopsis
```
#include "petscmat.h"  
PetscErrorCode MatDenseCUDAReplaceArray(Mat mat, const PetscScalar *array)
```
Not Collective


## Input Parameters

- ***mat -*** the matrix
- ***array -*** the array in column major order



## Note
This permanently replaces the GPU array and frees the memory associated with the old GPU array.
The memory passed in CANNOT be freed by the user. It will be freed
when the matrix is destroyed. The array should respect the matrix leading dimension.




## See Also
 `MatDenseCUDAGetArray()`, `MatDenseCUDAPlaceArray()`, `MatDenseCUDAResetArray()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/dense/mpi/mpidense.c.html#MatDenseCUDAReplaceArray">src/mat/impls/dense/mpi/mpidense.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/dense/mpi/mpidense.c.html#MatDenseCUDAReplaceArray_MPIDenseCUDA">MatDenseCUDAReplaceArray_MPIDenseCUDA in src/mat/impls/dense/mpi/mpidense.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/dense/seq/cuda/densecuda.cu.html#MatDenseCUDAReplaceArray_SeqDenseCUDA">MatDenseCUDAReplaceArray_SeqDenseCUDA in src/mat/impls/dense/seq/cuda/densecuda.cu</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/impls/dense/mpi/mpidense.c)


[Index of all Mat routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
