VCTR
Loading...
Searching...
No Matches
Exp.h
1/*
2 ==============================================================================
3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
5 Copyright 2022- by sonible GmbH.
6
7 This file is part of VCTR - Versatile Container Templates Reconceptualized.
8
9 VCTR is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License version 3
11 only, as published by the Free Software Foundation.
12
13 VCTR is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License version 3 for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 version 3 along with VCTR. If not, see <https://www.gnu.org/licenses/>.
20 ==============================================================================
21*/
22
23namespace vctr::expressions
24{
25
26template <size_t extent, class SrcType>
27requires is::realNumber<ValueType<SrcType>>
29{
30 using SrcValueType = ValueType<SrcType>;
31
32public:
33 using value_type = std::conditional_t<is::intNumber<SrcValueType>, float, SrcValueType>;
34
35 VCTR_COMMON_UNARY_EXPRESSION_MEMBERS (Exp, src)
36
37 VCTR_FORCEDINLINE constexpr value_type operator[] (size_t i) const
38 {
39#if VCTR_USE_GCEM
40 if (std::is_constant_evaluated())
41 return value_type (gcem::exp (src[i]));
42#endif
43
44 return value_type (std::exp (src[i]));
45 }
46
47 //==============================================================================
48 // Platform Vector Operation Implementation
49 VCTR_FORCEDINLINE const value_type* evalNextVectorOpInExpressionChain (value_type* dst) const
51 {
52 Expression::Accelerate::exp (src.evalNextVectorOpInExpressionChain (dst), dst, sizeToInt (size()));
53 return dst;
54 }
55
56 VCTR_FORCEDINLINE const value_type* evalNextVectorOpInExpressionChain (value_type* dst) const
58 {
59 auto s = size();
60
61 Expression::Accelerate::intToFloat (src.evalNextVectorOpInExpressionChain (reinterpret_cast<SrcValueType*> (dst)), dst, s);
62 Expression::Accelerate::exp (dst, dst, sizeToInt (s));
63
64 return dst;
65 }
66
67 VCTR_FORCEDINLINE const value_type* evalNextVectorOpInExpressionChain (value_type* dst) const
69 {
70 Expression::IPP::exp (src.evalNextVectorOpInExpressionChain (dst), dst, sizeToInt (size()));
71 return dst;
72 }
73};
74
75} // namespace vctr::expressions
76
77namespace vctr
78{
79
85
86} // namespace vctr
Definition: Exp.h:29
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 real valued floating point...
Definition: ContainerAndExpressionConcepts.h:242
A combined concept to check if Apple Accelerate is a suitable option for a vector operation that tran...
Definition: ContainerAndExpressionConcepts.h:258
A combined concept to check if Intel IPP is a suitable option for a real or complex valued floating p...
Definition: ContainerAndExpressionConcepts.h:278
constexpr ExpressionChainBuilder< expressions::Exp > exp
Computes e (Euler's number, 2.7182818...) raised to the source vector elements power.
Definition: Exp.h:84
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
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