41#include "../../expressions/lhsExpressionInterface.hpp"
43#include "../../tapes/misc/vectorAccessInterface.hpp"
44#include "../../traits/computationTraits.hpp"
45#include "../../traits/expressionTraits.hpp"
46#include "../../traits/realTraits.hpp"
76 template<
typename T_Type,
typename =
void>
79 "Instantiation of unspecialized AggregatedTypeVectorAccessWrapper.");
92 template<
typename T_Real,
typename T_Identifier,
typename T_InnerInterface>
130 for (
size_t curDim = 0; isZero && curDim <
lhs.size(); curDim += 1) {
148 for (
size_t curDim = 0; curDim <
lhs.size(); curDim += 1) {
149 Real update = jacobian *
lhs[curDim];
161 for (
size_t curDim = 0; curDim <
lhs.size(); curDim += 1) {
168 for (
size_t curDim = 0; curDim <
lhs.size(); curDim += 1) {
178 for (
size_t curDim = 0; curDim <
lhs.size(); curDim += 1) {
179 vec[curDim] = this->
getAdjoint(index, curDim);
191 for (
size_t curDim = 0; curDim <
lhs.size(); curDim += 1) {
216 template<
typename T_Type,
typename =
void>
226 template<
typename Real,
typename Identifier>
228 return new RType(access);
237#ifndef DOXYGEN_DISABLE
241 template<
typename T_InnerType>
242 struct AggregatedTypeVectorAccessWrapper<std::complex<T_InnerType>>
243 :
public AggregatedTypeVectorAccessWrapperBase<
244 std::complex<typename T_InnerType::Real>, std::complex<typename T_InnerType::Identifier>,
245 VectorAccessInterface<typename T_InnerType::Real, typename T_InnerType::Identifier>> {
248 using InnerType =
CODI_DD(T_InnerType, CODI_DEFAULT_LHS_EXPRESSION);
249 using Type = std::complex<InnerType>;
251 using InnerInterface = VectorAccessInterface<
252 typename InnerType::Real,
253 typename InnerType::Identifier>;
255 using Real = std::complex<typename InnerType::Real>;
256 using Identifier = std::complex<typename InnerType::Identifier>;
259 AggregatedTypeVectorAccessWrapperBase<Real, Identifier, InnerInterface>;
262 AggregatedTypeVectorAccessWrapper(InnerInterface* innerInterface) : Base(innerInterface) {}
268 void resetAdjoint(Identifier
const& index,
size_t dim) {
269 Base::innerInterface.resetAdjoint(std::real(index), dim);
270 Base::innerInterface.resetAdjoint(std::imag(index), dim);
275 Base::innerInterface.resetAdjointVec(std::real(index));
276 Base::innerInterface.resetAdjointVec(std::imag(index));
281 return Real(Base::innerInterface.
getAdjoint(std::real(index), dim),
282 Base::innerInterface.
getAdjoint(std::imag(index), dim));
287 Base::innerInterface.updateAdjoint(std::real(index), dim, std::real(adjoint));
288 Base::innerInterface.updateAdjoint(std::imag(index), dim, std::imag(adjoint));
295 void setPrimal(Identifier
const& index,
Real const& primal) {
296 Base::innerInterface.setPrimal(std::real(index), std::real(primal));
297 Base::innerInterface.setPrimal(std::imag(index), std::imag(primal));
302 return Real(Base::innerInterface.
getPrimal(std::real(index)), Base::innerInterface.
getPrimal(std::imag(index)));
306 VectorAccessInterface<Real, Identifier>*
clone()
const {
307 return new AggregatedTypeVectorAccessWrapper(Base::innerInterface.
clone());
314 template<
typename T_Type>
315 struct AggregatedTypeVectorAccessWrapperFactory<T_Type, ExpressionTraits::
EnableIfLhsExpression<T_Type>> {
317 using Type =
CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION);
319 using RType = VectorAccessInterface<typename Type::Real, typename Type::Identifier>;
#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
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:111
typename std::enable_if< IsLhsExpression< Expr >::value, T >::type EnableIfLhsExpression
Enable if wrapper for IsLhsExpression.
Definition expressionTraits.hpp:137
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
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52
Implements all methods from AggregatedTypeVectorAccessWrapper, that can be implemented with combinati...
Definition aggregatedTypeVectorAccessWrapper.hpp:93
void updateAdjointWithLhs(Identifier const &index, Real const &jacobian)
Definition aggregatedTypeVectorAccessWrapper.hpp:147
bool isLhsZero()
True if the adjoint set with setLhsAdjoint is zero.
Definition aggregatedTypeVectorAccessWrapper.hpp:127
void setLhsAdjoint(Identifier const &index)
Definition aggregatedTypeVectorAccessWrapper.hpp:141
T_Real Real
See RealTraits::DataExtraction::Real.
Definition aggregatedTypeVectorAccessWrapper.hpp:96
T_InnerInterface InnerInterface
See AggregatedTypeVectorAccessWrapperBase.
Definition aggregatedTypeVectorAccessWrapper.hpp:99
T_Identifier Identifier
See RealTraits::DataExtraction::Identifier.
Definition aggregatedTypeVectorAccessWrapper.hpp:97
size_t getVectorSize() const
Vector size in the current tape evaluation.
Definition aggregatedTypeVectorAccessWrapper.hpp:122
void getAdjointVec(Identifier const &index, Real *const vec)
Get the adjoint entry.
Definition aggregatedTypeVectorAccessWrapper.hpp:177
void updateTangentWithLhs(Identifier const &index, Real const &jacobian)
Definition aggregatedTypeVectorAccessWrapper.hpp:167
InnerInterface & innerInterface
Reference to the accessor of the underlying tape.
Definition aggregatedTypeVectorAccessWrapper.hpp:105
void updateAdjointVec(Identifier const &index, Real const *const vec)
Update the adjoint entry.
Definition aggregatedTypeVectorAccessWrapper.hpp:190
bool hasPrimals()
True if the tape/vector interface has primal values.
Definition aggregatedTypeVectorAccessWrapper.hpp:200
void setLhsTangent(Identifier const &index)
Definition aggregatedTypeVectorAccessWrapper.hpp:158
AggregatedTypeVectorAccessWrapperBase(InnerInterface *innerInterface)
Constructor.
Definition aggregatedTypeVectorAccessWrapper.hpp:113
std::vector< Real > lhs
Temporary storage for indirect adjoint or tangent updates.
Definition aggregatedTypeVectorAccessWrapper.hpp:107
Real const * getAdjointVec(Identifier const &index)
Get the adjoint entry.
Definition aggregatedTypeVectorAccessWrapper.hpp:184
std::vector< Real > buffer
Temporary storage for getAdjointVec access.
Definition aggregatedTypeVectorAccessWrapper.hpp:108
Factory for the creation of AggregatedTypeVectorAccessWrapper instances.
Definition aggregatedTypeVectorAccessWrapper.hpp:217
AggregatedTypeVectorAccessWrapper< Type > RType
Which instances this factory creates.
Definition aggregatedTypeVectorAccessWrapper.hpp:221
static void destroy(RType *access)
Delete the AggregatedTypeVectorAccessWrapper instance created by the crate method.
Definition aggregatedTypeVectorAccessWrapper.hpp:232
T_Type Type
See AggregatedTypeVectorAccessWrapperBase.
Definition aggregatedTypeVectorAccessWrapper.hpp:219
static RType * create(VectorAccessInterface< Real, Identifier > *access)
Definition aggregatedTypeVectorAccessWrapper.hpp:227
Generalized wrapper of the VectorAccessInterface for aggregated data types, e.g. std::complex<codi::R...
Definition aggregatedTypeVectorAccessWrapper.hpp:77
T_Type Type
See AggregatedTypeVectorAccessWrapperBase.
Definition aggregatedTypeVectorAccessWrapper.hpp:81
Unified access to the adjoint vector and primal vector in a tape evaluation.
Definition vectorAccessInterface.hpp:91
virtual void resetAdjoint(Identifier const &index, size_t dim)=0
Set the adjoint component to zero.
virtual void setPrimal(Identifier const &index, Real const &primal)=0
Set the primal value.
int Real
See VectorAccessInterface.
Definition vectorAccessInterface.hpp:94
virtual void resetAdjointVec(Identifier const &index)=0
Set the adjoint entry to zero.
virtual Real getPrimal(Identifier const &index)=0
Get the primal value.
virtual VectorAccessInterface * clone() const=0
virtual void updateAdjoint(Identifier const &index, size_t dim, Real const &adjoint)=0
Update the adjoint component.
virtual Real getAdjoint(Identifier const &index, size_t dim)=0
Get the adjoint component.