CppADCodeGen
2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
Loading...
Searching...
No Matches
default.hpp
1
#ifndef CPPAD_CG_DEFAULT_INCLUDED
2
#define CPPAD_CG_DEFAULT_INCLUDED
3
/* --------------------------------------------------------------------------
4
* CppADCodeGen: C++ Algorithmic Differentiation with Source Code Generation:
5
* Copyright (C) 2012 Ciengis
6
*
7
* CppADCodeGen is distributed under multiple licenses:
8
*
9
* - Eclipse Public License Version 1.0 (EPL1), and
10
* - GNU General Public License Version 3 (GPL3).
11
*
12
* EPL1 terms and conditions can be found in the file "epl-v10.txt", while
13
* terms and conditions for the GPL3 can be found in the file "gpl3.txt".
14
* ----------------------------------------------------------------------------
15
* Author: Joao Leal
16
*/
17
18
namespace
CppAD
{
19
namespace
cg {
20
24
template
<
class
Base>
25
inline
CG<Base>::CG
() :
26
node_(
nullptr
),
27
value_(
new
Base(0.0)) {
28
}
29
30
template
<
class
Base>
31
inline
CG<Base>::CG
(
OperationNode<Base>
& node) :
32
node_(&node) {
33
}
34
35
template
<
class
Base>
36
inline
CG<Base>::CG
(
const
Argument<Base>
&
arg
) :
37
node_(
arg
.getOperation()),
38
value_(
arg
.getParameter() !=
nullptr
?
new
Base(*
arg
.getParameter()) :
nullptr
) {
39
40
}
41
45
template
<
class
Base>
46
inline
CG<Base>::CG
(
const
Base &
b
) :
47
node_(
nullptr
),
48
value_(
new
Base(
b
)) {
49
}
50
54
template
<
class
Base>
55
inline
CG<Base>::CG
(
const
CG<Base>
&
orig
) :
56
node_(
orig
.node_),
57
value_(
orig
.value_ !=
nullptr
?
new
Base(*
orig
.value_) :
nullptr
) {
58
}
59
63
template
<
class
Base>
64
inline
CG<Base>::CG
(
CG<Base>
&&
orig
):
65
node_(
orig
.node_),
66
value_(std::
move
(
orig
.value_)) {
67
}
68
72
template
<
class
Base>
73
inline
CG<Base>
&
CG<Base>::operator=
(
const
Base&
b
) {
74
node_ =
nullptr
;
75
if
(value_ !=
nullptr
) {
76
*value_ =
b
;
77
}
else
{
78
value_.reset(
new
Base(
b
));
// to replace with value_ = std::make_unique once c++14 is used
79
}
80
return
*
this
;
81
}
82
83
template
<
class
Base>
84
inline
CG<Base>
&
CG<Base>::operator=
(
const
CG<Base>
&
rhs
) {
85
if
(&
rhs
==
this
) {
86
return
*
this
;
87
}
88
node_ =
rhs
.node_;
89
if
(
rhs
.value_ !=
nullptr
) {
90
if
(value_ !=
nullptr
) {
91
*value_ = *
rhs
.value_;
92
}
else
{
93
value_.reset(
new
Base(*
rhs
.value_));
// to replace with value_ = std::make_unique once c++14 is used
94
}
95
}
else
{
96
value_.reset();
97
}
98
99
return
*
this
;
100
}
101
102
template
<
class
Base>
103
inline
CG<Base>
&
CG<Base>::operator=
(
CG<Base>
&&
rhs
) {
104
assert
(
this
!= &
rhs
);
105
106
node_ =
rhs
.node_;
107
108
// steal the value
109
value_ = std::move(
rhs
.value_);
110
111
return
*
this
;
112
}
113
114
template
<
class
Base>
115
CG<Base>::~CG
() =
default
;
116
117
}
// END cg namespace
118
}
// END CppAD namespace
119
120
#endif
CppAD::cg::Argument
Definition
argument.hpp:31
CppAD::cg::CG
Definition
cg.hpp:29
CppAD::cg::CG::operator=
CG & operator=(const CG< Base > &rhs)
Definition
default.hpp:84
CppAD::cg::CG::CG
CG()
Definition
default.hpp:25
CppAD::cg::OperationNode
Definition
operation_node.hpp:28
CppAD
Definition
abstract_atomic_fun.hpp:19
CppAD::GreaterThanZero
bool GreaterThanZero(const cg::CG< Base > &x)
Definition
ordered.hpp:21
include
cppad
cg
default.hpp
Generated on Tue Sep 10 2024 03:29:10 for CppADCodeGen by
1.10.0