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

Input Parameters#

  • x - the vector

  • alpha - the scalar

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.

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

See Also#

VecSetValues(), VecSetValuesBlocked(), VecSetRandom()

Level#

beginner

Location#

src/vec/vec/interface/rvector.c

Examples#

src/vec/vec/tutorials/ex11.c.html
src/vec/vec/tutorials/ex11f90.F90.html
src/vec/vec/tutorials/ex11f.F90.html
src/vec/vec/tutorials/ex12.c.html
src/vec/vec/tutorials/ex12f.F90.html
src/vec/vec/tutorials/ex13.c.html
src/vec/vec/tutorials/ex15.c.html
src/vec/vec/tutorials/ex18.c.html
src/vec/vec/tutorials/ex18f.F90.html
src/vec/vec/tutorials/ex1.c.html
src/vec/vec/tutorials/ex1f90.F90.html

Implementations#

VecSet_Nest in src/vec/vec/impls/nest/vecnest.c
{ VecSet_Seq in src/vec/vec/impls/seq/dvec2.c
{ VecSet_SeqKokkos in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx
{ VecSet_SeqCUDA in src/vec/vec/impls/seq/seqcuda/veccuda2.cu
{ VecSet_SeqHIP in src/vec/vec/impls/seq/seqhip/vechip2.hip.c
{ VecSet_SeqViennaCL in src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx
{


Edit on GitLab

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