Skip to main content
`Ctrl`+`K`

# MatCreateDenseFromVecType

Create a matrix that matches the type of a `Vec`.

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatCreateDenseFromVecType(MPI_Comm comm, VecType vtype, PetscInt m, PetscInt n, PetscInt M, PetscInt N, PetscInt lda, PetscScalar *data, Mat *A)

Collective

## Input Parameters

- comm - the communicator

- vtype - the vector type

- m - number of local rows (or `PETSC_DECIDE` to have calculated if `M` is given)

- n - number of local columns (or `PETSC_DECIDE` to have calculated if `N` is given)

- M - number of global rows (or `PETSC_DECIDE` to have calculated if `m` is given)

- N - number of global columns (or `PETSC_DECIDE` to have calculated if `n` is given)

- lda - leading dimension (or `PETSC_DECIDE` to use the default)

- data - optional location of matrix data, which should have the same memory type as the vector. Pass `NULL` to have PETSc take care of matrix memory allocation.

## Output Parameter

- A - the dense matrix

## See Also

Matrices, `Mat`, `MatCreateDense()`, `MatCreateDenseCUDA()`, `MatCreateDenseHIP()`, `MatCreateDenseWithMemType()`, `PetscMemType`

## Level

advanced

## Location

src/mat/utils/veccreatematdense.c

## Examples

src/ksp/ksp/tutorials/ex76.c
src/mat/tutorials/ex19.c

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