petsc-3.7.1 2016-05-15
Report Typos and Errors

# VecSet

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

### Synopsis

    #include "petscvec.h"
    PetscErrorCode  VecSet(Vec x,PetscScalar alpha)

Logically Collective on Vec Many br

### Input Parameters

| x | - the vector Many br
| alpha | - the scalar Many br

### Output Parameter

x -the vector Many br

### Note

For a vector of dimension n, VecSet() computes Many br

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

so that all vector entries then equal the identical Many brscalar value, alpha. Use the more general routine Many brVecSetValues() to set different vector entries. Many br

You CANNOT call this after you have called VecSetValues() but before you call Many brVecAssemblyBegin/End(). Many br

Many br

### See Also

VecSetValues(), VecSetValuesBlocked(), VecSetRandom()

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

### Examples

src/vec/vec/examples/tutorials/ex1.c.html
src/vec/vec/examples/tutorials/ex2.c.html
src/vec/vec/examples/tutorials/ex8.c.html
src/vec/vec/examples/tutorials/ex11.c.html
src/vec/vec/examples/tutorials/ex12.c.html
src/vec/vec/examples/tutorials/ex15.c.html
src/vec/vec/examples/tutorials/ex18.c.html
src/vec/vec/examples/tutorials/ex1f.F.html
src/vec/vec/examples/tutorials/ex1f90.F.html
src/vec/vec/examples/tutorials/ex2f.F.html
src/vec/vec/examples/tutorials/ex7f.F.html