CoDiPack  3.1.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
staticContextAggregatedActiveType.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2026 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://scicomp.rptu.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of CoDiPack (http://scicomp.rptu.de/software/codi).
11 *
12 * CoDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * CoDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty
19 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU General Public License for more details.
22 * You should have received a copy of the GNU
23 * General Public License along with CoDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * For other licensing options please contact us.
27 *
28 * Authors:
29 * - SciComp, University of Kaiserslautern-Landau:
30 * - Max Sagebaum
31 * - Johannes Blühdorn
32 * - Former members:
33 * - Tim Albring
34 */
35#pragma once
36
37#include "../../config.h"
38#include "../../misc/compileTimeLoop.hpp"
39#include "../../misc/macros.hpp"
40#include "../../traits/realTraits.hpp"
41#include "../aggregate/aggregatedActiveType.hpp"
42#include "../logic/constructStaticContext.hpp"
43
45namespace codi {
46
55 template<typename T_Real, typename T_InnerActiveType>
57 : public AggregatedActiveTypeBase<T_Real, T_InnerActiveType,
58 StaticAggregatedActiveType<T_Real, T_InnerActiveType>, true> {
59 using Real = T_Real;
60 using InnerActiveType = CODI_DD(T_InnerActiveType,
62
63 using InnerReal = typename InnerActiveType::Real;
64 using InnerIdentifier = typename InnerActiveType::Identifier;
65
66 using Base =
69
71
73 };
74
75#ifndef DOXYGEN_DISABLE
76
77 template<typename T_Rhs, typename T_Tape, size_t T_primalValueOffset, size_t T_constantValueOffset>
78 struct ConstructStaticContextLogic<T_Rhs, T_Tape, T_primalValueOffset, T_constantValueOffset,
79 RealTraits::EnableIfAggregatedActiveType<T_Rhs>> {
80 public:
81
83 using Tape = T_Tape;
84 static constexpr size_t primalValueOffset = T_primalValueOffset;
85 static constexpr size_t constantValueOffset = T_constantValueOffset;
86
87 using Real = typename Rhs::Real;
88 using InnerActiveType = typename Rhs::InnerActiveType;
89 static int constexpr Elements = Rhs::Elements;
90
92 using StaticInnerType = typename InnerConstructor::ResultType;
93
94 using InnerReal = typename Tape::Real;
95 using InnerIdentifier = typename Tape::Identifier;
96 using PasiverInnerReal = typename Tape::PassiveReal;
97
99
101 CODI_INLINE static ResultType construct(InnerReal* primalVector, InnerIdentifier const* const identifiers,
102 PasiverInnerReal const* const constantData) {
103 CODI_UNUSED(constantData);
104
105 ResultType value;
106
108 new (&value.values[i.value]) StaticInnerType(InnerConstructor::construct(
109 primalVector, &identifiers[primalValueOffset + i.value], &constantData[constantValueOffset + i.value]));
110 });
111
112 return value;
113 }
114 };
115
116#endif
117}
#define CODI_LAMBDA_INLINE
See codi::Config::ForcedInlines.
Definition config.h:473
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:97
#define CODI_ANY
Used in default declarations of expression templates.
Definition macros.hpp:101
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:117
Traits for values that can be used as real values, e.g. double, float, codi::RealReverse etc....
Definition stdComplex.hpp:242
CoDiPack - Code Differentiation Package.
Definition codi.hpp:97
inlinevoid static_for(F func, Args &&... args)
Static for with i = 0 .. (N - 1). See CompileTimeLoop for details.
Definition compileTimeLoop.hpp:110
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:55
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52
Defines an aggregated type via an array and implements the ExpressionInterface.
Definition aggregatedActiveType.hpp:59
Represents a concrete aggregated lvalue int the CoDiPack expression tree.
Definition aggregatedActiveType.hpp:164
Helper class for the construction of an expression in a different context.
Definition constructStaticContext.hpp:70
T_Rhs ResultType
The resulting expression type after all nodes are replaced.
Definition constructStaticContext.hpp:86
static ResultType construct(Real *primalVector, Identifier const *const identifiers, PassiveReal const *const constantData)
Perform the construction.
T_Rhs Rhs
See ConstructStaticContextLogic.
Definition constructStaticContext.hpp:73
static constexpr size_t constantValueOffset
See ConstructStaticContextLogic.
Definition constructStaticContext.hpp:78
static constexpr size_t primalValueOffset
See ConstructStaticContextLogic.
Definition constructStaticContext.hpp:76
Static context implementation of the aggregated active type.
Definition staticContextAggregatedActiveType.hpp:58
typename InnerActiveType::Real InnerReal
Inner real type of the active type.
Definition staticContextAggregatedActiveType.hpp:63
typename InnerActiveType::Identifier InnerIdentifier
Inner real type of the active type.
Definition staticContextAggregatedActiveType.hpp:64
AggregatedActiveTypeBase< Real, InnerActiveType, StaticAggregatedActiveType, true > Base
Definition staticContextAggregatedActiveType.hpp:66
T_Real Real
See StaticAggregatedActiveType.
Definition staticContextAggregatedActiveType.hpp:59
T_InnerActiveType InnerActiveType
See StaticAggregatedActiveType.
Definition staticContextAggregatedActiveType.hpp:60