<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
scal.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2017-2021, University of Tennessee. All rights reserved.
5// Copyright (c) 2021-2023, University of Colorado Denver. All rights reserved.
6//
7// This file is part of <T>LAPACK.
8// <T>LAPACK is free software: you can redistribute it and/or modify it under
9// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
10
11#ifndef TLAPACK_BLAS_SCAL_HH
12#define TLAPACK_BLAS_SCAL_HH
13
15
16namespace tlapack {
17
26template <TLAPACK_VECTOR vector_t,
27 TLAPACK_SCALAR alpha_t,
28 class T = type_t<vector_t>,
29 disable_if_allow_optblas_t<pair<alpha_t, T>, pair<vector_t, T> > = 0>
30void scal(const alpha_t& alpha, vector_t& x)
31{
32 using idx_t = size_type<vector_t>;
33
34 // constants
35 const idx_t n = size(x);
36
37 for (idx_t i = 0; i < n; ++i)
38 x[i] *= alpha;
39}
40
41#ifdef TLAPACK_USE_LAPACKPP
42
43template <TLAPACK_LEGACY_VECTOR vector_t,
44 TLAPACK_SCALAR alpha_t,
45 class T = type_t<vector_t>,
46 enable_if_allow_optblas_t<pair<alpha_t, T>, pair<vector_t, T> > = 0>
47void scal(const alpha_t alpha, vector_t& x)
48{
49 // Legacy objects
50 auto x_ = legacy_vector(x);
51
52 // Constants to forward
53 const auto& n = x_.n;
54
55 return ::blas::scal(n, alpha, x_.ptr, x_.inc);
56}
57
58#endif
59
60} // namespace tlapack
61
62#endif // #ifndef TLAPACK_BLAS_SCAL_HH
#define TLAPACK_SCALAR
Macro for tlapack::concepts::Scalar compatible with C++17.
Definition concepts.hpp:915
#define TLAPACK_LEGACY_VECTOR
Macro for tlapack::concepts::LegacyVector compatible with C++17.
Definition concepts.hpp:954
#define TLAPACK_VECTOR
Macro for tlapack::concepts::Vector compatible with C++17.
Definition concepts.hpp:906
void scal(const alpha_t &alpha, vector_t &x)
Scale vector by constant, .
Definition scal.hpp:30
typename traits::real_type_traits< Types..., int >::type real_type
The common real type of the list of types.
Definition scalar_type_traits.hpp:113