VecGetArrayReadAndMemType — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# VecGetArrayReadAndMemType

Like `VecGetArrayRead()`, but if the input vector is a device vector, it will return a read-only device pointer. The returned pointer is guaranteed to point to up-to-date data. For host vectors, it functions as `VecGetArrayRead()`.

## Synopsis

    #include "petscvec.h"
    PetscErrorCode VecGetArrayReadAndMemType(Vec x, const PetscScalar *a[], PetscMemType *mtype)

Not Collective; No Fortran Support

## Input Parameter

- x - the vector

## Output Parameters

- a - the array

- mtype - memory type of the array

## Notes

The array must be returned using a matching call to `VecRestoreArrayReadAndMemType()`.

## See Also

Vectors and Parallel Data, `Vec`, `VecRestoreArrayReadAndMemType()`, `VecGetArrayAndMemType()`, `VecGetArrayWriteAndMemType()`, `VecGetArray()`, `VecRestoreArray()`, `VecGetArrayPair()`, `VecRestoreArrayPair()`

## Level

beginner

## Location

src/vec/vec/interface/rvector.c

## Examples

src/mat/tutorials/ex19.c

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