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
6
#include <
etl/_linalg/concepts.hpp
>
7
#include <
etl/_utility/cmp_less.hpp
>
8
9
namespace
etl::linalg
{
10
12
template
<
typename
Scalar, inout_
object
InOutObj>
13
constexpr
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
concepts.hpp
cmp_less.hpp
etl::linalg::scale
constexpr auto scale(Scalar alpha, InOutObj x) -> void
Definition
blas1_scale.hpp:13
etl::cmp_less
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
etl::linalg
Definition
accessor_conjugate.hpp:12
include
etl
_linalg
blas1_scale.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0