25template <
class ValueType>
31template <
class StringType>
32requires std::convertible_to<const char*, StringType>
33struct SumInit<StringType>
35 static constexpr const char* value =
"";
39namespace vctr::expressions
42template <
size_t extent,
class SrcType>
43requires has::operatorPlusEquals<ValueType<SrcType>>
49 VCTR_COMMON_UNARY_EXPRESSION_MEMBERS (
Sum, src)
51 static constexpr auto reductionResultInitValue = detail::SumInit<value_type>::value;
53 VCTR_FORCEDINLINE
constexpr void reduceElementWise (value_type& result,
size_t i)
const
59 VCTR_FORCEDINLINE value_type reduceVectorOp()
const
62 return Expression::Accelerate::sum (src.data(), size());
65 VCTR_FORCEDINLINE value_type reduceVectorOp()
const
68 return Expression::IPP::sum (src.data(), size());
75 result = Expression::Neon::add (result, src.getNeon (i));
78 VCTR_FORCEDINLINE VCTR_TARGET (
"avx")
void reduceAVXRegisterWise (
AVXRegister<value_type>& result,
size_t i)
const
81 result = Expression::AVX::add (result, src.getAVX (i));
84 VCTR_FORCEDINLINE VCTR_TARGET (
"avx2")
void reduceAVXRegisterWise (
AVXRegister<value_type>& result,
size_t i)
const
87 result = Expression::AVX::add (result, src.getAVX (i));
90 VCTR_FORCEDINLINE VCTR_TARGET (
"sse4.1")
void reduceSSERegisterWise (
SSERegister<value_type>& result,
size_t i)
const
93 result = Expression::SSE::add (result, src.getSSE (i));
98 VCTR_FORCEDINLINE
static constexpr value_type finalizeReduction (
const std::array<value_type, n>& sums)
100 if constexpr (n == 1)
103 return std::reduce (sums.begin(), sums.end());
Constrains a type to have a member function getAVX (size_t) const.
Definition: ContainerAndExpressionConcepts.h:78
Constrains a type to have a member function getNeon (size_t) const.
Definition: ContainerAndExpressionConcepts.h:74
Constrains a type to have a member function getSSE (size_t) const.
Definition: ContainerAndExpressionConcepts.h:82
Constrains a type to represent a real valued 32 bit integer number.
Definition: NumericTypeConcepts.h:53
Constrains a type to represent a real valued floating point number.
Definition: NumericTypeConcepts.h:79
A combined concept to check if Apple Accelerate is a suitable option for a floating point vector redu...
Definition: ContainerAndExpressionConcepts.h:262
A combined concept to check if Intel IPP is a suitable option for a real or complex floating point ve...
Definition: ContainerAndExpressionConcepts.h:290
constexpr ExpressionChainBuilder< expressions::Sum > sum
Computes the sum of the source values.
Definition: Sum.h:116
The main namespace of the VCTR project.
Definition: Array.h:24
typename detail::ValueType< std::remove_cvref_t< T > >::Type ValueType
If T is an expression template, it equals its return type, if it's a type that defines value_type as ...
Definition: Traits.h:201
Definition: AVXRegister.h:28
An expression chain builder is an object which supplies various operator<< overloads which build chai...
Definition: ExpressionChainBuilder.h:136
The base class to every expression template.
Definition: ExpressionTemplate.h:37
Definition: NeonRegister.h:28
Definition: SSERegister.h:28