:orphan:
# MatDenseGetColumn
gives access to a column of a dense matrix. This is only the local part of the column. You MUST call `MatDenseRestoreColumn()` to avoid memory bleeding.
## Synopsis
```
#include "petscmat.h"
PetscErrorCode MatDenseGetColumn(Mat A, PetscInt col, PetscScalar **vals)
```
Not Collective
## Input Parameters
- ***mat -*** a `MATSEQDENSE` or `MATMPIDENSE` matrix
- ***col -*** column index
## Output Parameter
- ***vals -*** pointer to the data
## Note
Use `MatDenseGetColumnVec()` to get access to a column of a `MATDENSE` treated as a `Vec`
## See Also
[](ch_matrices), `Mat`, `MATDENSE`, `MatDenseRestoreColumn()`, `MatDenseGetColumnVec()`
## Level
intermediate
## Location
src/mat/impls/dense/seq/dense.c
## Examples
src/ts/tutorials/ex20opt_ic.c
src/ts/tutorials/ex20opt_p.c
## Implementations
MatDenseGetColumn_MPIDense in src/mat/impls/dense/mpi/mpidense.c
MatDenseGetColumn_SeqDense in src/mat/impls/dense/seq/dense.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/impls/dense/seq/dense.c)
[Index of all Mat routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)