CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
assignmentOperators.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2024 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://www.scicomp.uni-kl.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://www.scicomp.uni-kl.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/macros.hpp"
39#include "../tapes/interfaces/internalStatementRecordingTapeInterface.hpp"
40#include "lhsExpressionInterface.hpp"
41
43namespace codi {
44
53 template<typename T_Tape, typename T_Impl>
55 public:
56
58 using Impl = CODI_DD(T_Impl,
60
61 using Real = CODI_DD(typename Tape::Real, double);
63
66 return static_cast<Impl&>(*this);
67 }
68
70 template<typename Rhs>
72 return cast() = (cast() + rhs);
73 }
74
76 template<typename Rhs>
78 return cast() = (cast() - rhs);
79 }
80
82 template<typename Rhs>
84 return cast() = (cast() * rhs);
85 }
86
88 template<typename Rhs>
90 return cast() = (cast() / rhs);
91 }
92
95 if (Tape::AllowJacobianOptimization) {
96 cast().value() += rhs;
97 } else {
98 cast() = (cast() + rhs);
99 }
100 return cast();
101 }
102
105 if (Tape::AllowJacobianOptimization) {
106 cast().value() -= rhs;
107 } else {
108 cast() = (cast() - rhs);
109 }
110 return cast();
111 }
112
115 return cast() = (cast() * rhs);
116 }
117
120 return cast() = (cast() / rhs);
121 }
122 };
123}
#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 TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition: realTraits.hpp:117
CoDiPack - Code Differentiation Package.
Definition: codi.hpp:90
Implementation of assignment operators for LhsExpressionInterface implementations.
Definition: assignmentOperators.hpp:54
Impl & operator*=(ExpressionInterface< Real, Rhs > const &rhs)
Operator *= for expressions.
Definition: assignmentOperators.hpp:83
Impl & cast()
Cast to the implementation.
Definition: assignmentOperators.hpp:65
Impl & operator-=(PassiveReal const &rhs)
Operator -= for passive values.
Definition: assignmentOperators.hpp:104
T_Impl Impl
See AssignmentOperators.
Definition: assignmentOperators.hpp:59
Impl & operator*=(PassiveReal const &rhs)
Operator *= for passive values.
Definition: assignmentOperators.hpp:114
T_Tape Tape
See AssignmentOperators.
Definition: assignmentOperators.hpp:57
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition: assignmentOperators.hpp:62
Impl & operator/=(ExpressionInterface< Real, Rhs > const &rhs)
Operator /= for expressions.
Definition: assignmentOperators.hpp:89
Impl & operator+=(PassiveReal const &rhs)
Operator += for passive values.
Definition: assignmentOperators.hpp:94
Impl & operator+=(ExpressionInterface< Real, Rhs > const &rhs)
Operator += for expressions.
Definition: assignmentOperators.hpp:71
Impl & operator-=(ExpressionInterface< Real, Rhs > const &rhs)
Operator -= for expressions.
Definition: assignmentOperators.hpp:77
typename Tape::Real Real
See InternalStatementRecordingTapeInterface.
Definition: assignmentOperators.hpp:61
Impl & operator/=(PassiveReal const &rhs)
Operator /= for passive values.
Definition: assignmentOperators.hpp:119
Base class for all CoDiPack expressions.
Definition: expressionInterface.hpp:59
Internal tape interface that is used by active types to trigger the storing of an expression.
Definition: internalStatementRecordingTapeInterface.hpp:65
Base class for all CoDiPack lvalue expression.
Definition: lhsExpressionInterface.hpp:63