tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
blas1_scale.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_LINALG_BLAS1_SCALE_HPP
4#define TETL_LINALG_BLAS1_SCALE_HPP
5
8
9namespace etl::linalg {
10
12template <typename Scalar, inout_object InOutObj>
13constexpr auto scale(Scalar alpha, InOutObj x) -> void
14{
15 using size_type = typename InOutObj::size_type;
16
17 if constexpr (InOutObj::rank() == 1) {
18 for (size_type i{0}; etl::cmp_less(i, x.extent(0)); ++i) {
19 x(i) = x(i) * alpha;
20 }
21 } else {
22 static_assert(InOutObj::rank() == 2);
23 for (size_type i{0}; etl::cmp_less(i, x.extent(0)); ++i) {
24 for (size_type j{0}; etl::cmp_less(j, x.extent(1)); ++j) {
25 x(i, j) = x(i, j) * alpha;
26 }
27 }
28 }
29}
30
31} // namespace etl::linalg
32
33#endif // TETL_LINALG_BLAS1_SCALE_HPP
constexpr auto scale(Scalar alpha, InOutObj x) -> void
Definition blas1_scale.hpp:13
constexpr auto cmp_less(T t, U u) noexcept -> bool
Compare the values of two integers t and u. Unlike builtin comparison operators, negative signed inte...
Definition cmp_less.hpp:21
Definition accessor_conjugate.hpp:12