# VecSet

Sets all components of a vector to a single scalar value.

### Synopsis

    #include "petscvec.h"
    int VecSet(const PetscScalar *alpha,Vec x)

Collective on Vec

### Input Parameters

| alpha | - the scalar
| x | - the vector

### Output Parameter

x -the vector

### Note

For a vector of dimension n, VecSet() computes

        x[i] = alpha, for i=1,...,n,

so that all vector entries then equal the identical scalar value, alpha. Use the more general routine VecSetValues() to set different vector entries.

### See Also

VecSetValues(), VecSetValuesBlocked(), VecSetRandom()

Level:beginner
Location: src/vec/interface/vector.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/ex8.c.html
src/vec/examples/tutorials/ex11.c.html
src/vec/examples/tutorials/ex12.c.html
src/vec/examples/tutorials/ex13.c.html
src/vec/examples/tutorials/ex1f.F.html
src/vec/examples/tutorials/ex2f.F.html
src/vec/examples/tutorials/ex7f.F.html
src/vec/examples/tutorials/ex1f90.F.html