:orphan: # VecScale Scales a vector. ## Synopsis ``` #include "petscvec.h" PetscErrorCode VecScale(Vec x, PetscScalar alpha) ``` Not Collective ## Input Parameters - ***x -*** the vector - ***alpha -*** the scalar ## Note For a vector with n components, `VecScale()` computes x[i] = alpha * x[i], for i=1,...,n. ## See Also [](ch_vectors), `Vec`, `VecSet()` ## Level intermediate ## Location src/vec/vec/interface/rvector.c ## Examples src/dm/impls/stag/tutorials/ex2.c
src/dm/impls/stag/tutorials/ex3.c
src/dm/impls/stag/tutorials/ex4.c
src/dm/tutorials/ex1.c
src/dm/tutorials/ex7.c
src/dm/tutorials/ex9.c
src/ksp/ksp/tutorials/ex28.c
src/ksp/ksp/tutorials/ex49.c
src/ksp/ksp/tutorials/ex59.c
src/ksp/ksp/tutorials/ex60.c
src/mat/tutorials/ex9.c
## Implementations VecScale_Nest in src/vec/vec/impls/nest/vecnest.c
VecScale_Seq in src/vec/vec/impls/seq/bvec1.c
VecScale_SeqKokkos in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx
VecScale_SeqViennaCL in src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx
--- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/interface/rvector.c) [Index of all Vec routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)