# VecCreate

Creates an empty vector object. The type can then be set with VecSetType(), or VecSetFromOptions().

### Synopsis

    #include "petscvec.h"
    PetscErrorCode PETSCVEC_DLLEXPORT VecCreate(MPI_Comm comm, Vec *vec)

If you never call VecSetType() or VecSetFromOptions() it will generate an error when you try to use the vector.

Collective on MPI_Comm

### Input Parameter

comm -The communicator for the vector object

### Output Parameter

vec -The vector object

### Keywords

vector, create

### C++ variants

| VecCreate(Vec *x) |  | -> |  | VecCreate(PETSC_COMM_SELF,x)

### See Also

VecSetType(), VecSetSizes(), VecCreateMPIWithArray(), VecCreateMPI(), VecDuplicate(),
VecDuplicateVecs(), VecCreateGhost(), VecCreateSeq(), VecPlaceArray()

Level:beginner
Location:src/vec/interface/veccreate.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/vec/examples/tutorials/ex1.c.html
src/vec/examples/tutorials/ex1e.c.html
src/vec/examples/tutorials/ex2.c.html
src/vec/examples/tutorials/ex3.c.html
src/vec/examples/tutorials/ex5.c.html
src/vec/examples/tutorials/ex6.c.html
src/vec/examples/tutorials/ex7.c.html
src/vec/examples/tutorials/ex8.c.html
src/vec/examples/tutorials/ex10.c.html
src/vec/examples/tutorials/ex11.c.html
src/vec/examples/tutorials/ex12.c.html