42#include "expressionTraits.hpp"
47 namespace ComputationTraits {
60 template<
typename T_Outer,
typename T_Inner,
typename =
void>
63 CODI_STATIC_ASSERT(
false && std::is_void<T_Outer>::value,
"Instantiation of unspecialized adjoint conversion.");
78 template<
typename Outer,
typename Inner>
90 template<
typename T_Jacobian,
typename =
void>
94 "Instantiation of unspecialized Jacobian transpose.");
105 template<
typename Jacobian>
118 template<
typename T_Lhs,
typename T_Rhs,
typename =
void>
133 template<
typename Lhs,
typename Rhs>
142#define CODI_CREATE_ADJOINT_CONVERSION(OuterType, InnerType, RType, conversion) \
144 struct ComputationTraits::AdjointConversionImpl<OuterType, InnerType> { \
146 using Outer = OuteType; \
147 using Inner = InnerType; \
148 using Return = RType; \
149 static Return adjointConversion(Inner const& jacobian) { \
157#define CODI_CREATE_TRANSPOSE(Type, RType, trans) \
159 struct ComputationTraits::Transpose<Type> { \
161 using Jacobian = Type; \
162 using Return = RType; \
163 static Return transpose(Type const& jacobian) { \
171#define CODI_CREATE_UPDATE(LhsType, RhsType, up) \
173 struct ComputationTraits::UpdateImpl<LhsType, RhsType> { \
175 using Lhs = LhsType; \
176 using Rhs = RhsType; \
177 using Return = LhsType&; \
178 static Return update(Lhs& lhs, Rhs const& rhs) { \
183#ifndef DOXYGEN_DISABLE
186 template<
typename Type>
187 struct ComputationTraits::AdjointConversionImpl<Type, Type> {
200 template<
typename T_Outer,
typename T_Inner>
201 struct ComputationTraits::AdjointConversionImpl<
203 typename std::enable_if<!std::is_same<T_Outer, T_Inner>::value &
204 ExpressionTraits::IsExpression<T_Inner>::value>::type> {
207 using Outer = T_Outer;
208 using Inner = T_Inner;
210 using InnerActive =
typename Inner::ActiveResult;
211 using InnerActiveConversion = ComputationTraits::AdjointConversionImpl<Outer, InnerActive>;
213 using Return =
typename InnerActiveConversion::Return;
216 return InnerActiveConversion::adjointConversion(jacobian);
221 template<
typename Type>
222 struct ComputationTraits::AdjointConversionImpl<Type, std::complex<Type>> {
225 using Inner = std::complex<Type>;
230 return std::real(jacobian);
236 struct ComputationTraits::TransposeImpl<T, typename std::enable_if<std::is_floating_point<T>::value>::type> {
247 template<
typename Inner>
248 struct ComputationTraits::TransposeImpl<std::complex<Inner>> {
250 using Jacobian = std::complex<Inner>;
251 using Return = std::complex<Inner>;
254 return std::conj(jacobian);
261 template<
typename Inner>
262 struct ComputationTraits::UpdateImpl<Inner, std::complex<Inner>> {
265 using Rhs = std::complex<Inner>;
270 return lhs += std::real(rhs);
#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_ANY
Used in default declarations of expression templates.
Definition macros.hpp:98
#define CODI_STATIC_ASSERT(cond, message)
Static assert in CoDiPack.
Definition macros.hpp:123
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
Perform the conversion of Outer(Inner) in the adjoint context. Default implementation for Outer == In...
Definition computationTraits.hpp:61
int Return
Deduced return type.
Definition computationTraits.hpp:67
T_Inner Inner
See ReduceImpl.
Definition computationTraits.hpp:65
T_Outer Outer
See ReduceImpl.
Definition computationTraits.hpp:64
static Return adjointConversion(Inner const &jacobian)
Perform the adjoint of Outer(Inner).
Perform or if entries are complex. No default implementation available.
Definition computationTraits.hpp:91
T_Jacobian Jacobian
See TransposeImpl.
Definition computationTraits.hpp:95
int Return
Deduced return type.
Definition computationTraits.hpp:97
static Return transpose(Jacobian const &jacobian)
Perform or if entries are complex.
Perform the operation lhs += rhs. Default logic uses operator +=.
Definition computationTraits.hpp:119
static Return update(Lhs &lhs, Rhs const &rhs)
Perform lhs += rhs.
Definition computationTraits.hpp:127
T_Rhs Rhs
See UpdateImpl.
Definition computationTraits.hpp:122
T_Lhs Lhs
See UpdateImpl.
Definition computationTraits.hpp:121
Lhs & Return
Deduced return type.
Definition computationTraits.hpp:124
Default implementation of the Jacobian interface.
Definition jacobian.hpp:60