37#include <initializer_list>
41#include "../../traits/atomicTraits.hpp"
42#include "../../traits/gradientTraits.hpp"
43#include "../../traits/realTraits.hpp"
56 template<
typename T_Real,
size_t T_dim>
62 static size_t constexpr dim = T_dim;
74 for (
size_t i = 0; i <
dim; ++i) {
81 for (
size_t i = 0; i <
dim; ++i) {
82 vector[i] = v.vector[i];
88 size_t size = std::min(
dim, l.size());
89 Real const* array = l.begin();
90 for (
size_t i = 0; i < size; ++i) {
107 for (
size_t i = 0; i <
dim; ++i) {
108 this->vector[i] = v.vector[i];
116 for (
size_t i = 0; i <
dim; ++i) {
117 this->vector[i] += v.vector[i];
125 for (
size_t i = 0; i <
dim; ++i) {
126 this->vector[i] -= v.vector[i];
133 template<
typename Real,
size_t dim>
137 template<
typename Real,
size_t dim>
140 for (
size_t i = 0; i < dim; ++i) {
148 template<
typename Real,
size_t dim,
typename = RealTraits::EnableIfNotPassiveReal<Real>>
151 for (
size_t i = 0; i < dim; ++i) {
159 template<
typename Real,
size_t dim,
typename = AtomicTraits::EnableIfAtomic<Real>>
162 for (
size_t i = 0; i < dim; ++i) {
170 template<
typename Real,
size_t dim>
176 template<
typename Real,
size_t dim,
typename = RealTraits::EnableIfNotPassiveReal<Real>>
182 template<
typename Real,
size_t dim,
typename = AtomicTraits::EnableIfAtomic<Real>>
188 template<
typename Real,
size_t dim>
191 for (
size_t i = 0; i < dim; ++i) {
199 template<
typename Real,
size_t dim,
typename = RealTraits::EnableIfNotPassiveReal<Real>>
202 for (
size_t i = 0; i < dim; ++i) {
210 template<
typename Real,
size_t dim,
typename = AtomicTraits::EnableIfAtomic<Real>>
213 for (
size_t i = 0; i < dim; ++i) {
221 template<
typename Real,
size_t dim>
224 for (
size_t i = 0; i < dim; ++i) {
225 r[i] = v1[i] + v2[i];
232 template<
typename Real,
size_t dim>
235 for (
size_t i = 0; i < dim; ++i) {
236 r[i] = v1[i] - v2[i];
243 template<
typename Real,
size_t dim>
246 for (
size_t i = 0; i < dim; ++i) {
254 template<
typename Real,
size_t dim>
260 template<
typename A,
typename Real,
size_t dim>
266 template<
typename A,
typename Real,
size_t dim>
272 template<
typename Real,
size_t dim>
274 for (
size_t i = 0; i < dim; ++i) {
275 if (v1[i] != v2[i]) {
284 template<
typename A,
typename Real,
size_t dim>
286 for (
size_t i = 0; i < dim; ++i) {
296 template<
typename A,
typename Real,
size_t dim>
302 template<
typename Real,
size_t dim>
305 for (
size_t i = 0; i < dim; ++i) {
316#ifndef DOXYGEN_DISABLE
317 template<
typename T_Type>
318 struct RealTraits::IsTotalZero<T_Type, GradientTraits::EnableIfDirection<T_Type>> {
325 for (
size_t i = 0; i < GradientTraits::dim<Type>(); ++i) {
334 template<
typename T_Type>
341 for (
size_t i = 0; i < GradientTraits::dim<Type>(); ++i) {
352 template<
typename T_Gradient>
357 using Real =
typename Gradient::Real;
359 static size_t constexpr dim = Gradient::dim;
362 return gradient[
dim];
366 return gradient[
dim];
370 std::array<AtomicTraits::RemoveAtomic<Real>,
dim> result;
371 for (
size_t i = 0; i <
dim; ++i) {
372 result[i] =
at(gradient, i);
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:96
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:116
typename RemoveAtomicImpl< Type >::Type RemoveAtomic
Wrapper for removing atomic from a type.
Definition atomicTraits.hpp:83
Definition gradientTraits.hpp:52
typename TraitsImplementation< Gradient >::Real Real
The base value used in the gradient entries.
Definition gradientTraits.hpp:92
typename std::enable_if< IsDirection< Gradient >::value >::type EnableIfDirection
Enable if wrapper for EnableIfDirection.
Definition gradientTraits.hpp:142
inlinebool isTotalFinite(Type const &v)
Function for checking if all values of the type are finite.
Definition realTraits.hpp:139
inlinebool isTotalZero(Type const &v)
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:145
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type that was used in the application.
Definition realTraits.hpp:123
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
ExpressionTraits::EnableIfExpression< Expr, std::ostream > & operator<<(std::ostream &out, Expr const &v)
Write the primal value to the stream.
Definition expressionInterface.hpp:154
inlineauto operator+(ExpressionInterface< std::complex< Real >, ArgA > const &argA, ExpressionInterface< Real, ArgB > const &argB)
Function overload for FUNCTION(complex, real).
Definition allOperators.hpp:92
inlinebool operator!=(ExpressionInterface< std::complex< Real >, ArgA > const &argA, RealTraits::PassiveReal< Real > const &argB)
Function overload for OPERATOR(complex, passive real).
Definition allOperators.hpp:78
inlineauto operator*(ExpressionInterface< std::complex< Real >, ArgA > const &argA, ExpressionInterface< Real, ArgB > const &argB)
Function overload for FUNCTION(complex, real).
Definition allOperators.hpp:92
inlineauto operator-(ExpressionInterface< std::complex< Real >, ArgA > const &argA, ExpressionInterface< Real, ArgB > const &argB)
Function overload for FUNCTION(complex, real).
Definition allOperators.hpp:92
inlineauto operator/(ExpressionInterface< std::complex< Real >, ArgA > const &argA, ExpressionInterface< Real, ArgB > const &argB)
Function overload for FUNCTION(complex, real).
Definition allOperators.hpp:92
inlinebool operator==(ExpressionInterface< std::complex< Real >, ArgA > const &argA, RealTraits::PassiveReal< Real > const &argB)
Function overload for OPERATOR(complex, passive real).
Definition allOperators.hpp:78
Fixed size vector mode implementation.
Definition direction.hpp:57
inlineDirection & operator-=(Direction const &v)
Update operator.
Definition direction.hpp:124
T_Real Real
See Direction.
Definition direction.hpp:60
inlineDirection & operator=(Direction const &v)
Assignment operator.
Definition direction.hpp:106
static size_t constexpr dim
See Direction.
Definition direction.hpp:62
inlineDirection & operator+=(Direction const &v)
Update operator.
Definition direction.hpp:115
inlineReal const & operator[](size_t const &i) const
Per value element access.
Definition direction.hpp:101
inlineReal & operator[](size_t const &i)
Per reference element access.
Definition direction.hpp:96
Common traits for all types used as gradients.
Definition gradientTraits.hpp:64
static size_t constexpr dim
Number of dimensions this gradient value has.
Definition gradientTraits.hpp:70
inlinestatic Real & at(Gradient &gradient, size_t dim)
Get the entry at the given index.
Definition gradientTraits.hpp:73
inlinestatic std::array< AtomicTraits::RemoveAtomic< Real >, dim > toArray(Gradient const &gradient)
Converts the (possibly multi-component) gradient to an array of Reals.
Definition gradientTraits.hpp:85
T_Gradient Gradient
See TraitsImplementation.
Definition gradientTraits.hpp:67
Gradient Real
The base value used in the gradient entries.
Definition gradientTraits.hpp:68
Function for checking if all values of the type are finite.
Definition realTraits.hpp:88
T_Type Type
See IsTotalFinite.
Definition realTraits.hpp:91
static inlinebool isTotalFinite(Type const &v)
Checks if the values are all finite.
Definition realTraits.hpp:94
T_Type Type
See IsTotalZero.
Definition realTraits.hpp:109
static inlinebool isTotalZero(Type const &v)
Checks if the values are completely zero.
Definition realTraits.hpp:112