Drake
symbolic_test_util.h
Go to the documentation of this file.
1 #pragma once
2 #include <algorithm>
25 #include <vector>
26 
27 #include <gtest/gtest.h>
28 
29 #include "drake/common/symbolic.h"
30 
31 namespace drake {
32 namespace symbolic {
33 namespace test {
34 
35 inline bool VarEqual(const Variable& v1, const Variable& v2) {
36  return v1.equal_to(v2);
37 }
38 
39 inline bool VarNotEqual(const Variable& v1, const Variable& v2) {
40  return !VarEqual(v1, v2);
41 }
42 
43 inline bool VarLess(const Variable& v1, const Variable& v2) {
44  return v1.less(v2);
45 }
46 
47 inline bool VarNotLess(const Variable& v1, const Variable& v2) {
48  return !VarLess(v1, v2);
49 }
50 
51 inline bool ExprEqual(const Expression& e1, const Expression& e2) {
52  return e1.EqualTo(e2);
53 }
54 
55 inline bool ExprNotEqual(const Expression& e1, const Expression& e2) {
56  return !ExprEqual(e1, e2);
57 }
58 
59 inline bool ExprLess(const Expression& e1, const Expression& e2) {
60  return e1.Less(e2);
61 }
62 
63 inline bool ExprNotLess(const Expression& e1, const Expression& e2) {
64  return !ExprLess(e1, e2);
65 }
66 
67 inline bool PolyEqual(const Polynomial& p1, const Polynomial& p2) {
68  return p1.EqualTo(p2);
69 }
70 
71 inline bool PolyNotEqual(const Polynomial& p1, const Polynomial& p2) {
72  return !PolyEqual(p1, p2);
73 }
74 
75 template <typename F>
76 bool all_of(const std::vector<Formula>& formulas, const F& f) {
77  return std::all_of(formulas.begin(), formulas.end(), f);
78 }
79 
80 template <typename F>
81 bool any_of(const std::vector<Formula>& formulas, const F& f) {
82  return std::any_of(formulas.begin(), formulas.end(), f);
83 }
84 
85 inline bool FormulaEqual(const Formula& f1, const Formula& f2) {
86  return f1.EqualTo(f2);
87 }
88 
89 inline bool FormulaNotEqual(const Formula& f1, const Formula& f2) {
90  return !FormulaEqual(f1, f2);
91 }
92 
93 inline bool FormulaLess(const Formula& f1, const Formula& f2) {
94  return f1.Less(f2);
95 }
96 
97 inline bool FormulaNotLess(const Formula& f1, const Formula& f2) {
98  return !FormulaLess(f1, f2);
99 }
100 
101 } // namespace test
102 } // namespace symbolic
103 } // namespace drake
std::vector< snopt::doublereal > F
Definition: snopt_solver.cc:59
bool FormulaNotEqual(const Formula &f1, const Formula &f2)
Definition: symbolic_test_util.h:89
Represents a symbolic variable.
Definition: symbolic_variable.h:24
Definition: automotive_demo.cc:88
bool PolyNotEqual(const Polynomial &p1, const Polynomial &p2)
Definition: symbolic_test_util.h:71
bool all_of(const std::vector< Formula > &formulas, const F &f)
Definition: symbolic_test_util.h:76
Represents a symbolic form of a first-order logic formula.
Definition: symbolic_formula.h:113
bool Less(const Formula &f) const
Checks lexicographical ordering between this and e.
Definition: symbolic_formula.cc:65
bool less(const Variable &v) const
Compares two variables based on their ID values.
Definition: symbolic_variable.h:70
bool EqualTo(const Expression &e) const
Checks structural equality.
Definition: symbolic_expression.cc:115
bool any_of(const std::vector< Formula > &formulas, const F &f)
Definition: symbolic_test_util.h:81
bool ExprNotLess(const Expression &e1, const Expression &e2)
Definition: symbolic_test_util.h:63
bool VarNotEqual(const Variable &v1, const Variable &v2)
Definition: symbolic_test_util.h:39
bool EqualTo(const Polynomial &p) const
Returns true if this polynomial and p are structurally equal.
Definition: symbolic_polynomial.cc:403
bool Less(const Expression &e) const
Provides lexicographical ordering between expressions.
Definition: symbolic_expression.cc:132
bool ExprLess(const Expression &e1, const Expression &e2)
Definition: symbolic_test_util.h:59
bool FormulaNotLess(const Formula &f1, const Formula &f2)
Definition: symbolic_test_util.h:97
Represents a symbolic form of an expression.
Definition: symbolic_expression.h:172
bool ExprNotEqual(const Expression &e1, const Expression &e2)
Definition: symbolic_test_util.h:55
bool VarLess(const Variable &v1, const Variable &v2)
Definition: symbolic_test_util.h:43
bool ExprEqual(const Expression &e1, const Expression &e2)
Definition: symbolic_test_util.h:51
bool FormulaLess(const Formula &f1, const Formula &f2)
Definition: symbolic_test_util.h:93
bool VarEqual(const Variable &v1, const Variable &v2)
Definition: symbolic_test_util.h:35
bool EqualTo(const Formula &f) const
Checks structural equality.
Definition: symbolic_formula.cc:47
Represents symbolic polynomials.
Definition: symbolic_polynomial.h:30
bool FormulaEqual(const Formula &f1, const Formula &f2)
Definition: symbolic_test_util.h:85
Provides public header files of Drake&#39;s symbolic library.
bool equal_to(const Variable &v) const
Checks the equality of two variables based on their ID values.
Definition: symbolic_variable.h:67
bool VarNotLess(const Variable &v1, const Variable &v2)
Definition: symbolic_test_util.h:47
bool PolyEqual(const Polynomial &p1, const Polynomial &p2)
Definition: symbolic_test_util.h:67