tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
blas1_vector_abs_sum.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_LINALG_BLAS1_VECTOR_ABS_SUM
4
#define TETL_LINALG_BLAS1_VECTOR_ABS_SUM
5
6
#include <
etl/_linalg/concepts.hpp
>
7
#include <
etl/_type_traits/is_arithmetic.hpp
>
8
#include <
etl/_utility/cmp_less.hpp
>
9
10
namespace
etl::linalg
{
11
13
template
<in_vector InVec,
typename
Scalar>
14
constexpr
auto
vector_abs_sum
(InVec v, Scalar init)
noexcept
-> Scalar
15
{
16
auto
sum = init;
17
for
(
typename
InVec::size_type i{0};
etl::cmp_less
(i, v.extent(0)); ++i) {
18
if
constexpr
(
is_arithmetic_v<typename InVec::value_type>
) {
19
sum += detail::abs_if_needed(v(i));
20
}
else
{
21
sum += detail::abs_if_needed(detail::real_if_needed(v(i)));
22
sum += detail::abs_if_needed(detail::imag_if_needed(v(i)));
23
}
24
}
25
return
sum;
26
}
27
29
template
<in_vector InVec>
30
constexpr
auto
vector_abs_sum
(InVec v)
noexcept
->
typename
InVec::value_type
31
{
32
return
vector_abs_sum
(v,
typename
InVec::value_type{});
33
}
34
35
}
// namespace etl::linalg
36
37
#endif
// TETL_LINALG_BLAS1_VECTOR_ABS_SUM
concepts.hpp
cmp_less.hpp
etl::linalg::vector_abs_sum
constexpr auto vector_abs_sum(InVec v, Scalar init) noexcept -> Scalar
Definition
blas1_vector_abs_sum.hpp:14
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
is_arithmetic.hpp
etl::linalg
Definition
accessor_conjugate.hpp:12
etl::is_arithmetic_v
constexpr bool is_arithmetic_v
Definition
is_arithmetic.hpp:21
include
etl
_linalg
blas1_vector_abs_sum.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0