1#ifndef CPPAD_CG_ARITHMETIC_ASSIGN_INCLUDED
2#define CPPAD_CG_ARITHMETIC_ASSIGN_INCLUDED
22inline CG<Base>& CG<Base>::operator+=(
const CG<Base> &
right) {
23 if (isParameter() &&
right.isParameter()) {
24 *value_ += *
right.value_;
29 if (isIdenticalZero()) {
36 }
else if (
right.isParameter()) {
37 if (
right.isIdenticalZero()) {
41 handler = node_->getCodeHandler();
44 CPPADCG_ASSERT_UNKNOWN(node_->getCodeHandler() ==
right.node_->getCodeHandler());
45 handler = node_->getCodeHandler();
48 std::unique_ptr<Base> value;
49 if (isValueDefined() &&
right.isValueDefined()) {
50 value.reset(
new Base(getValue() +
right.getValue()));
53 makeVariable(*
handler->makeNode(CGOpCode::Add,{argument(), right.argument()}), value);
60inline CG<Base>& CG<Base>::operator-=(
const CG<Base> &
right) {
61 if (isParameter() &&
right.isParameter()) {
62 *value_ -= *
right.value_;
69 }
else if (
right.isParameter()) {
70 if (
right.isIdenticalZero()) {
74 handler = node_->getCodeHandler();
77 CPPADCG_ASSERT_UNKNOWN(node_->getCodeHandler() ==
right.node_->getCodeHandler());
78 handler = node_->getCodeHandler();
81 std::unique_ptr<Base> value;
82 if (isValueDefined() &&
right.isValueDefined()) {
83 value.reset(
new Base(getValue() -
right.getValue()));
86 makeVariable(*
handler->makeNode(CGOpCode::Sub,{argument(), right.argument()}), value);
93inline CG<Base>& CG<Base>::operator*=(
const CG<Base> &
right) {
94 if (isParameter() &&
right.isParameter()) {
95 *value_ *= *
right.value_;
100 if (isIdenticalZero()) {
102 }
else if (isIdenticalOne()) {
109 }
else if (
right.isParameter()) {
110 if (
right.isIdenticalZero()) {
111 makeParameter(Base(0.0));
113 }
else if (
right.isIdenticalOne()) {
117 handler = node_->getCodeHandler();
120 CPPADCG_ASSERT_UNKNOWN(node_->getCodeHandler() ==
right.node_->getCodeHandler());
121 handler = node_->getCodeHandler();
124 std::unique_ptr<Base> value;
125 if (isValueDefined() &&
right.isValueDefined()) {
126 value.reset(
new Base(getValue() *
right.getValue()));
129 makeVariable(*
handler->makeNode(CGOpCode::Mul,{argument(), right.argument()}), value);
136inline CG<Base>& CG<Base>::operator/=(
const CG<Base> &
right) {
137 if (isParameter() &&
right.isParameter()) {
138 *value_ /= *
right.value_;
143 if (isIdenticalZero()) {
149 }
else if (
right.isParameter()) {
150 if (
right.isIdenticalOne()) {
154 handler = node_->getCodeHandler();
157 CPPADCG_ASSERT_UNKNOWN(node_->getCodeHandler() ==
right.node_->getCodeHandler());
158 handler = node_->getCodeHandler();
161 std::unique_ptr<Base> value;
162 if (isValueDefined() &&
right.isValueDefined()) {
163 value.reset(
new Base(getValue() /
right.getValue()));
166 makeVariable(*
handler->makeNode(CGOpCode::Div,{argument(), right.argument()}), value);
173inline CG<Base>& CG<Base>::operator+=(
const Base &
right) {
174 return operator+=(CG<Base> (
right));
178inline CG<Base>& CG<Base>::operator-=(
const Base &
right) {
179 return operator-=(CG<Base> (
right));
183inline CG<Base>& CG<Base>::operator/=(
const Base &
right) {
184 return operator/=(CG<Base> (
right));
188inline CG<Base>& CG<Base>::operator*=(
const Base &
right) {
189 return operator*=(CG<Base> (
right));
194inline CG<Base>& CG<Base>::operator+=(
const T &
right) {
195 return operator+=(CG<Base> (
right));
200inline CG<Base>& CG<Base>::operator-=(
const T &
right) {
201 return operator-=(CG<Base> (
right));
206inline CG<Base>& CG<Base>::operator/=(
const T &
right) {
207 return operator/=(CG<Base> (
right));
212inline CG<Base>& CG<Base>::operator*=(
const T &
right) {
213 return operator*=(CG<Base> (
right));
bool GreaterThanZero(const cg::CG< Base > &x)