58 static inline double zero() {
return 0.0; }
59 static inline double one() {
return 1.0; }
60 static inline double add(
const double&
a,
const double&
b) {
63 static inline double max(
const double&
a,
const double&
b) {
66 static inline double mul(
const double&
a,
const double&
b) {
69 static inline double div(
const double&
a,
const double&
b) {
72 static inline double id(
const double&
x) {
return x; }
82 :
Base(label, y1, y2) {}
87 :
Base(labelC, y1, y2) {}
91 (
const std::vector<typename Base::LabelC>& labelCs,
92 const std::vector<double>& ys) {
94 Base::create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
99 (
const std::vector<typename Base::LabelC>& labelCs,
100 const std::string&
table) {
102 std::vector<double> ys;
103 std::istringstream iss(
table);
104 std::copy(std::istream_iterator<double>(iss),
105 std::istream_iterator<double>(), std::back_inserter(ys));
109 Base::create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
113 template <
typename Iterator>
116 this->root_ =
compose(begin, end, label);
125 template <
typename M>
127 const std::map<M, L>& map) {
129 std::function<L(const M&)> L_of_M = [&map](
const M& label) ->
L {
130 return map.at(label);
132 std::function<double(const double&)> op =
Ring::id;
148 return this->
apply(g, &Ring::div);
153 return this->combine(label, cardinality, &
Ring::add);
158 return this->combine(labelC, &
Ring::add);
164 &DefaultFormatter)
const {
166 std::stringstream
ss;
167 ss << std::setw(4) << std::setprecision(8) <<
v;
179 return Base::equals(other,
compare);
183 template <
typename T>
185 :
public Testable<AlgebraicDecisionTree<T>> {};
AlgebraicDecisionTree sum(const L &label, size_t cardinality) const
bool equals(const AlgebraicDecisionTree &other, double tol=1e-9) const
Equality method customized to value type double.
NodePtr convertFrom(const typename DecisionTree< M, X >::NodePtr &f, std::function< L(const M &)> L_of_M, std::function< Y(const X &)> Y_of_X) const
Convert from a DecisionTree<M, X> to DecisionTree<L, Y>.
static int id(const int &a)
static int mul(const int &a, const int &b)
Matrix< RealScalar, Dynamic, Dynamic > M
static double add(const double &a, const double &b)
Concept check for values that can be used in unit tests.
AlgebraicDecisionTree(const Base &add)
void print(const std::string &s="", const typename Base::LabelFormatter &labelFormatter=&DefaultFormatter) const
print method customized to value type double.
DecisionTree< L, Y > apply(const DecisionTree< L, Y > &f, const typename DecisionTree< L, Y >::Unary &op)
Apply unary operator op to DecisionTree f.
AlgebraicDecisionTree(const typename Base::LabelC &labelC, double y1, double y2)
AlgebraicDecisionTree operator+(const AlgebraicDecisionTree &g) const
AlgebraicDecisionTree operator*(const AlgebraicDecisionTree &g) const
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
static double max(const double &a, const double &b)
static std::string valueFormatter(const double &v)
void g(const string &key, int i)
AlgebraicDecisionTree operator/(const AlgebraicDecisionTree &g) const
static double mul(const double &a, const double &b)
NodePtr root_
A DecisionTree just contains the root. TODO(dellaert): make protected.
static double div(const double &a, const double &b)
AlgebraicDecisionTree(double leaf=1.0)
Array< int, Dynamic, 1 > v
Array< double, 1, 3 > e(1./3., 0.5, 2.)
AlgebraicDecisionTree(Iterator begin, Iterator end, const L &label)
static std::string DefaultFormatter(const L &x)
Default method used by labelFormatter or valueFormatter when printing.
AlgebraicDecisionTree sum(const typename Base::LabelC &labelC) const
static std::stringstream ss
std::function< std::string(Key)> LabelFormatter
static int add(const int &a, const int &b)
ADT create(const Signature &signature)
Expression< T > compose(const Expression< T > &t1, const Expression< T > &t2)
static EIGEN_DEPRECATED const end_t end
static double id(const double &x)
graph add(PriorFactor< Pose2 >(1, priorMean, priorNoise))
std::pair< Key, size_t > LabelC
AlgebraicDecisionTree(const AlgebraicDecisionTree< M > &other, const std::map< M, L > &map)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
AlgebraicDecisionTree(const L &label, double y1, double y2)