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(),
sizeToInt (size()));
72 VCTR_FORWARD_PREPARE_SIMD_EVALUATION_UNARY_EXPRESSION_MEMBER_FUNCTIONS
77 result = Expression::Neon::add (result, src.getNeon (i));
80 VCTR_FORCEDINLINE VCTR_TARGET (
"fma")
void reduceAVXRegisterWise (
AVXRegister<value_type>& result,
size_t i)
const
83 result = Expression::AVX::add (result, src.getAVX (i));
86 VCTR_FORCEDINLINE VCTR_TARGET (
"avx2")
void reduceAVXRegisterWise (
AVXRegister<value_type>& result,
size_t i)
const
89 result = Expression::AVX::add (result, src.getAVX (i));
92 VCTR_FORCEDINLINE VCTR_TARGET (
"sse4.1")
void reduceSSERegisterWise (
SSERegister<value_type>& result,
size_t i)
const
95 result = Expression::SSE::add (result, src.getSSE (i));
100 VCTR_FORCEDINLINE
static constexpr value_type finalizeReduction (
const std::array<value_type, n>& sums)
102 if constexpr (n == 1)
105 return std::reduce (sums.begin(), sums.end());
Constrains a type to have a member function getAVX (size_t) const.
Definition: ContainerAndExpressionConcepts.h:92
Constrains a type to have a member function getNeon (size_t) const.
Definition: ContainerAndExpressionConcepts.h:84
Constrains a type to have a member function getSSE (size_t) const.
Definition: ContainerAndExpressionConcepts.h:100
Constrains a type to represent a real valued 32 bit integer number.
Definition: NumericTypeConcepts.h:57
Constrains a type to represent a real valued floating point number.
Definition: NumericTypeConcepts.h:83
A combined concept to check if Apple Accelerate is a suitable option for a floating point vector redu...
Definition: ContainerAndExpressionConcepts.h:280
A combined concept to check if Intel IPP is a suitable option for a real or complex floating point ve...
Definition: ContainerAndExpressionConcepts.h:308
constexpr ExpressionChainBuilder< expressions::Sum > sum
Computes the sum of the source values.
Definition: Sum.h:118
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
int sizeToInt(size_t size)
Casts the size_t argument to an int.
Definition: PlatformVectorOpsHelpers.h:27
Definition: AVXRegister.h:28
An expression chain builder is an object which supplies various operator<< overloads which build chai...
Definition: ExpressionChainBuilder.h:157
The base class to every expression template.
Definition: ExpressionTemplate.h:37
Definition: NeonRegister.h:28
Definition: SSERegister.h:28