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// SPDX-FileCopyrightText: Copyright (C) 2023 Tobias Hienzsch
3
4#ifndef TETL_LINALG_BLAS1_SCALE_HPP
5#define TETL_LINALG_BLAS1_SCALE_HPP
6
7#include <etl/_linalg/exposition.hpp>
8
9namespace etl::linalg {
10
11/// \ingroup linalg
12template <typename Scalar, inout_object InOutObj>
13constexpr auto scale(Scalar alpha, InOutObj x) -> void
14{
15 using index_type = typename InOutObj::index_type;
16
17 if constexpr (InOutObj::rank() == 1) {
18 for (index_type i{0}; i < x.extent(0); ++i) {
19 x(i) = x(i) * alpha;
20 }
21 } else {
22 static_assert(InOutObj::rank() == 2);
23 for (index_type i{0}; i < x.extent(0); ++i) {
24 for (index_type j{0}; 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
Definition accessor_conjugate.hpp:13
Definition adjacent_find.hpp:9