1 #ifndef CPPAD_CG_COMPARE_INCLUDED
2 #define CPPAD_CG_COMPARE_INCLUDED
22 inline bool operator ==(
const CG<Base>& left,
const CG<Base>& right) {
23 if (left.isParameter() && right.isParameter()) {
24 return left.getValue() == right.getValue();
25 }
else if (left.isParameter() || right.isParameter()) {
28 return left.getOperationNode() == right.getOperationNode();
33 inline bool operator !=(
const CG<Base>& left,
const CG<Base>& right) {
34 if (left.isParameter() && right.isParameter()) {
35 return left.getValue() != right.getValue();
36 }
else if (left.isParameter() || right.isParameter()) {
39 return left.getOperationNode() != right.getOperationNode();
43 #define CPPAD_CG_OPERATOR(Op) \
44 template<class Base> \
45 inline bool operator Op(const CG<Base> &left, const CG<Base> &right) { \
46 if (left.isParameter() && right.isParameter()) { \
47 return left.getValue() Op right.getValue(); \
49 throw CGException("Cannot use the "#Op" comparison operator in non parameter variables");\
54 CPPAD_CG_OPERATOR( >=)
56 CPPAD_CG_OPERATOR( <=)
59 inline
bool operator==(const CG<Base>& left, const Base& right) {
60 if (left.isParameter()) {
61 return left.getValue() == right;
68 inline bool operator==(
const Base& left,
const CG<Base>& right) {
69 if (right.isParameter()) {
70 return left == right.getValue();
77 inline bool operator!=(
const CG<Base>& left, Base right) {
78 if (left.isParameter()) {
79 return left.getValue() != right;
86 inline bool operator!=(
const Base& left,
const CG<Base>& right) {
87 if (right.isParameter()) {
88 return left != right.getValue();
96 inline bool operator!=(
const CG<Base> &left,
double right) {
97 if (left.isParameter()) {
98 return left.getValue() != right;