41#include "../computeExpression.hpp"
42#include "../expressionInterface.hpp"
43#include "../real/allOperators.hpp"
44#include "complexPredef.hpp"
45#include "realToComplexCast.hpp"
50 template<
typename T_Tape,
typename T_ParallelToolbox>
67#define OPERATION_LOGIC OperationAdd
68#define FUNCTION operator+
69#include "binaryMixedComplexAndRealOverloads.tpp"
71#define OPERATION_LOGIC OperationSubstract
72#define FUNCTION operator-
73#include "binaryMixedComplexAndRealOverloads.tpp"
75#define OPERATION_LOGIC OperationMultiply
76#define FUNCTION operator*
77#include "binaryMixedComplexAndRealOverloads.tpp"
79#define OPERATION_LOGIC OperationDivide
80#define FUNCTION operator/
81#include "binaryMixedComplexAndRealOverloads.tpp"
89 template<
typename T_ComplexReal>
95 using Real =
typename ComplexReal::value_type;
98 template<
typename ArgA,
typename ArgB>
104 template<
typename Tangent,
typename ArgA,
typename ArgB>
110 template<
typename Adjo
int,
typename ArgA,
typename ArgB>
114 return cos(argB) * std::real(adjoint) +
sin(argB) * std::imag(adjoint);
118 template<
typename Tangent,
typename ArgA,
typename ArgB>
124 template<
typename Adjo
int,
typename ArgA,
typename ArgB>
129 return -std::imag(result) * std::real(adjoint) + std::real(result) * std::imag(adjoint);
138#define FUNCTION polar
139#define OPERATION_LOGIC OperationComplexPolar
140#include "binaryRealToComplexOverloads.tpp"
143 template<
typename T_Real>
151 template<
typename ArgA,
typename ArgB>
153 return pow(argA, argB);
157 template<
typename ArgA,
typename ArgB>
161 return argB *
pow(argA, argB - 1.0);
165 template<
typename ArgA,
typename ArgB>
179#define OPERATION_LOGIC OperationPow
181#include "binaryMixedComplexAndRealOverloads.tpp"
189#include "conditionalBinaryMixedComplexAndRealOverloads.tpp"
192#include "conditionalBinaryMixedComplexAndRealOverloads.tpp"
205 template<
typename T_Real>
213 template<
typename Arg>
219 template<
typename Arg>
235 static CODI_INLINE void checkResult(Real
const& result) {
238 CODI_EXCEPTION(
"Zero divisor for abs derivative.");
245#define OPERATION_LOGIC OperationComplexAbs
246#include "unaryComplexToRealOverloads.tpp"
249 template<
typename T_Real>
257 template<
typename Argument>
259 return arg(argument);
263 template<
typename Argument>
268 checkDivisor(divisor);
269 divisor = 1.0 / divisor;
280 static CODI_INLINE void checkDivisor(Real
const& devisor) {
283 CODI_EXCEPTION(
"Zero divisor for arg derivative.");
290#define OPERATION_LOGIC OperationComplexArg
291#include "unaryComplexToRealOverloads.tpp"
294 template<
typename T_ComplexReal>
301 template<
typename Arg>
307 template<
typename Tangent,
typename Arg>
311 return conj(tangent);
315 template<
typename Adjo
int,
typename Arg>
319 return conj(adjoint);
329#define OPERATION_LOGIC OperationComplexConj
330#include "../real/unaryOverloads.tpp"
333 template<
typename T_Real>
341 template<
typename Arg>
347 template<
typename Arg>
361#define OPERATION_LOGIC OperationComplexImag
362#include "unaryComplexToRealOverloads.tpp"
365 template<
typename T_Real>
373 template<
typename Arg>
379 template<
typename Arg>
393#define OPERATION_LOGIC OperationComplexNorm
394#include "unaryComplexToRealOverloads.tpp"
397 template<
typename T_ComplexReal>
405 template<
typename Arg>
407 return proj(argument);
411 template<
typename Arg>
425#define OPERATION_LOGIC OperationComplexProj
426#include "../real/unaryOverloads.tpp"
429 template<
typename T_Real>
437 template<
typename Arg>
443 template<
typename Arg>
457#define OPERATION_LOGIC OperationComplexReal
458#include "unaryComplexToRealOverloads.tpp"
465 template<
typename Real>
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:96
bool constexpr CheckExpressionArguments
Check for invalid arguments to expressions like division by zero.
Definition config.h:146
inlinePassiveReal< Type > getPassiveValue(Type const &v)
Get the basic primal value of the type.
Definition realTraits.hpp:133
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
inlineauto log(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto conj(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:71
inlineauto cos(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto imag(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlineauto abs(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlineauto real(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:54
inlineauto arg(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlineauto sin(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto norm(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlineauto pow(ExpressionInterface< std::complex< Real >, ArgA > const &argA, ExpressionInterface< Real, ArgB > const &argB)
Function overload for FUNCTION(complex, real).
Definition allOperators.hpp:92
inlineauto proj(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:71
inlineauto polar(ExpressionInterface< Real, ArgA > const &argA, ExpressionInterface< Real, ArgB > const &argB)
Function overload for FUNCTION(real, real).
Definition allOperators.hpp:86
inlinebool isfinite(ExpressionInterface< Real, Arg > const &arg)
Function overload for isfinite.
Definition unaryOperators.hpp:787
Implements BinaryOperation for functions where the gradients can be computed and transposed.
Definition computeExpression.hpp:302
Implements ComputeOperation for two arguments.
Definition computeExpression.hpp:197
UnaryJacobianOperation implementation for complex abs.
Definition allOperators.hpp:206
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition allOperators.hpp:230
T_Real Real
See UnaryJacobianOperation.
Definition allOperators.hpp:209
static inlineReal primal(Arg const &arg)
Definition allOperators.hpp:214
static inlineJacobian gradient(Arg const &arg, Real const &result)
Compute .
Definition allOperators.hpp:220
std::complex< Real > Jacobian
See UnaryJacobianOperation.
Definition allOperators.hpp:210
UnaryJacobianOperation implementation for complex arg.
Definition allOperators.hpp:250
static inlineJacobian gradient(Argument const &argument, Real const &result)
Compute .
Definition allOperators.hpp:264
std::complex< Real > Jacobian
See UnaryJacobianOperation.
Definition allOperators.hpp:254
static inlineReal primal(Argument const &argument)
Definition allOperators.hpp:258
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition allOperators.hpp:275
T_Real Real
See UnaryJacobianOperation.
Definition allOperators.hpp:253
UnaryJacobianOperation implementation for complex conj.
Definition allOperators.hpp:295
static inlineauto applyTangentArg(Tangent const &tangent, ComplexReal const &result, Arg const &arg)
Definition allOperators.hpp:308
static inlineComplexReal primal(Arg const &arg)
Definition allOperators.hpp:302
static inlineauto applyAdjointArg(Adjoint const &adjoint, ComplexReal const &result, Arg const &arg)
Definition allOperators.hpp:316
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition allOperators.hpp:323
T_ComplexReal ComplexReal
See UnaryJacobianOperation.
Definition allOperators.hpp:298
UnaryJacobianOperation implementation for complex imag.
Definition allOperators.hpp:334
std::complex< Real > Jacobian
See UnaryJacobianOperation.
Definition allOperators.hpp:338
T_Real Real
See UnaryJacobianOperation.
Definition allOperators.hpp:337
static inlineReal primal(Arg const &arg)
Definition allOperators.hpp:342
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition allOperators.hpp:355
static inlineJacobian gradient(Arg const &arg, Real const &result)
Compute .
Definition allOperators.hpp:348
UnaryJacobianOperation implementation for complex real.
Definition allOperators.hpp:366
static inlineJacobian gradient(Arg const &arg, Real const &result)
Compute .
Definition allOperators.hpp:380
std::complex< Real > Jacobian
See UnaryJacobianOperation.
Definition allOperators.hpp:370
static inlineReal primal(Arg const &arg)
Definition allOperators.hpp:374
T_Real Real
See UnaryJacobianOperation.
Definition allOperators.hpp:369
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition allOperators.hpp:387
BinaryJacobianOperation specialization for complex polar.
Definition allOperators.hpp:90
static inlineReal applyAdjointArgA(Adjoint const &adjoint, ComplexReal const &result, ArgA const &argA, ArgB const &argB)
Definition allOperators.hpp:111
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition allOperators.hpp:133
T_ComplexReal ComplexReal
See OperationComplexPolar.
Definition allOperators.hpp:93
static inlineReal applyAdjointArgB(Adjoint const &adjoint, ComplexReal const &result, ArgA const &argA, ArgB const &argB)
Definition allOperators.hpp:125
static inlineauto applyTangentArgB(Tangent const &tangent, ComplexReal const &result, ArgA const &argA, ArgB const &argB)
typename ComplexReal::value_type Real
Inner type of the complex value.
Definition allOperators.hpp:95
static inlineComplexReal primal(ArgA const &argA, ArgB const &argB)
Definition allOperators.hpp:99
static inlineauto applyTangentArgA(Tangent const &tangent, ComplexReal const &result, ArgA const &argA, ArgB const &argB)
UnaryJacobianOperation implementation for complex proj.
Definition allOperators.hpp:398
static inlineComplexReal primal(Arg const &argument)
Definition allOperators.hpp:406
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition allOperators.hpp:419
static inlineJacobian gradient(Arg const &argument, ComplexReal const &result)
Compute .
Definition allOperators.hpp:412
double Jacobian
See UnaryJacobianOperation.
Definition allOperators.hpp:402
T_ComplexReal ComplexReal
See UnaryJacobianOperation.
Definition allOperators.hpp:401
UnaryJacobianOperation implementation for complex real.
Definition allOperators.hpp:430
T_Real Real
See UnaryJacobianOperation.
Definition allOperators.hpp:433
static inlineReal primal(Arg const &arg)
Definition allOperators.hpp:438
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition allOperators.hpp:451
static inlineJacobian gradient(Arg const &arg, Real const &result)
Compute .
Definition allOperators.hpp:444
std::complex< Real > Jacobian
See UnaryJacobianOperation.
Definition allOperators.hpp:434
static inlineComplexReal gradientA(ArgA const &argA, ArgB const &argB, ComplexReal const &result)
Compute .
Definition allOperators.hpp:158
std::complex< T_Real > ComplexReal
See BinaryJacobianOperation.
Definition allOperators.hpp:148
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition allOperators.hpp:174
static inlineComplexReal gradientB(ArgA const &argA, ArgB const &argB, ComplexReal const &result)
Compute .
Definition allOperators.hpp:166
static inlineComplexReal primal(ArgA const &argA, ArgB const &argB)
Definition allOperators.hpp:152
BinaryJacobianOperation implementation for pow.
Definition binaryOperators.hpp:726
Represents a concrete lvalue in the CoDiPack expression tree.
Definition parallelActiveType.hpp:54
Implements UnaryOperation for functions where the gradient can be computed and transposed.
Definition computeExpression.hpp:149
Implements ComputeOperation for one argument.
Definition computeExpression.hpp:98