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>> {
322 using Real =
typename GradientTraits::Real<Type>;
325 for (
size_t i = 0; i < GradientTraits::dim<Type>(); ++i) {
334 template<
typename T_Type>
335 struct RealTraits::IsTotalFinite<T_Type, GradientTraits::
EnableIfDirection<T_Type>> {
341 for (
size_t i = 0; i < GradientTraits::dim<Type>(); ++i) {
350 namespace GradientTraits {
352 template<
typename T_Gradient>
356 using Gradient =
CODI_DD(T_Gradient,
CODI_T(Direction<double, 1>));
357 using Real =
typename Gradient::Real;
359 static size_t constexpr dim = Gradient::dim;
362 return gradient[
dim];
366 return gradient[
dim];
369 CODI_INLINE static std::array<AtomicTraits::RemoveAtomic<Real>,
dim>
toArray(Gradient
const& gradient) {
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:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:111
typename RemoveAtomicImpl< Type >::Type RemoveAtomic
Wrapper for removing atomic from a type.
Definition atomicTraits.hpp:83
typename std::enable_if< IsDirection< Gradient >::value >::type EnableIfDirection
Enable if wrapper for EnableIfDirection.
Definition gradientTraits.hpp:144
bool isTotalFinite(Type const &v)
Function for checking if all values of the type are finite.
Definition realTraits.hpp:133
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition realTraits.hpp:117
bool isTotalZero(Type const &v)
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:139
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
bool operator==(Enum a, EnumBitset< Enum > const &b)
Equal comparison for an enum and a bitset.
Definition enumBitset.hpp:247
Direction< Real, dim > operator-(Direction< Real, dim > const &v1, Direction< Real, dim > const &v2)
Subtraction of two vectors.
Definition direction.hpp:233
ExpressionTraits::EnableIfExpression< Expr, std::ostream > & operator<<(std::ostream &out, Expr const &v)
Write the primal value to the stream.
Definition expressionInterface.hpp:129
Direction< Real, dim > operator/(Direction< Real, dim > const &v, Real const &s)
Division by a scalar.
Definition direction.hpp:189
bool operator!=(Enum a, EnumBitset< Enum > const &b)
Not equal comparison for an enum and a bitset.
Definition enumBitset.hpp:241
ExpressionInterface< Real, Arg > const & operator+(ExpressionInterface< Real, Arg > const &arg)
Function overload for operator +.
Definition unaryOperators.hpp:79
Direction< Real, dim > operator*(Real const &s, Direction< Real, dim > const &v)
Multiplication with a scalar.
Definition direction.hpp:138
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52
Fixed size vector mode implementation.
Definition direction.hpp:57
Direction(Real const &s)
Constructor.
Definition direction.hpp:73
Direction()
Constructor.
Definition direction.hpp:70
T_Real Real
See Direction.
Definition direction.hpp:60
Direction & operator-=(Direction const &v)
Update operator.
Definition direction.hpp:124
Real & operator[](size_t const &i)
Per reference element access.
Definition direction.hpp:96
Real const & operator[](size_t const &i) const
Per value element access.
Definition direction.hpp:101
Direction(std::initializer_list< Real > l)
Constructor.
Definition direction.hpp:87
Direction & operator+=(Direction const &v)
Update operator.
Definition direction.hpp:115
static size_t constexpr dim
See Direction.
Definition direction.hpp:62
Direction(Direction const &v)
Constructor.
Definition direction.hpp:80
Direction & operator=(Direction const &v)
Assignment operator.
Definition direction.hpp:106
static size_t constexpr dim
Number of dimensions this gradient value has.
Definition gradientTraits.hpp:70
static Real & at(Gradient &gradient, size_t dim)
Get the entry at the given index.
Definition gradientTraits.hpp:73
static 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_Type Type
See IsTotalFinite.
Definition realTraits.hpp:85
static bool isTotalFinite(Type const &v)
Checks if the values are all finite.
Definition realTraits.hpp:88
T_Type Type
See IsTotalZero.
Definition realTraits.hpp:103
static bool isTotalZero(Type const &v)
Checks if the values are completely zero.
Definition realTraits.hpp:106