Go to the documentation of this file.
60 static inline double zero() {
return 0.0; }
61 static inline double one() {
return 1.0; }
62 static inline double add(
const double&
a,
const double&
b) {
65 static inline double max(
const double&
a,
const double&
b) {
68 static inline double mul(
const double&
a,
const double&
b) {
71 static inline double div(
const double&
a,
const double&
b) {
74 static inline double id(
const double&
x) {
return x; }
75 static inline double negate(
const double&
x) {
return -
x; }
129 (
const std::vector<typename Base::LabelC>& labelCs,
130 const std::vector<double>& ys) {
132 Base::create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
144 (
const std::vector<typename Base::LabelC>& labelCs,
145 const std::string&
table) {
147 std::vector<double> ys;
148 std::istringstream iss(
table);
149 std::copy(std::istream_iterator<double>(iss),
150 std::istream_iterator<double>(), std::back_inserter(ys));
154 Base::create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
164 template <
typename Iterator>
176 template <
typename M>
178 const std::map<M, L>& map) {
180 std::function<
L(
const M&)> L_of_M = [&map](
const M& label) ->
L {
181 return map.at(label);
183 std::function<double(
const double&)> op =
Ring::id;
198 template <
typename X,
typename Func>
230 auto visitor = [&](
double y) {
sum +=
y; };
231 this->
visit(visitor);
246 auto visitor = [&](
double x) {
min =
x <
min ?
x :
min; };
247 this->
visit(visitor);
255 auto visitor = [&](
double x) {
max =
x >
max ?
x :
max; };
256 this->
visit(visitor);
275 std::stringstream
ss;
276 ss << std::setw(4) << std::setprecision(8) <<
v;
292 template <
typename T>
294 :
public Testable<AlgebraicDecisionTree<T>> {};
static double id(const double &x)
std::function< std::string(Key)> LabelFormatter
AlgebraicDecisionTree operator-() const
AlgebraicDecisionTree(const DecisionTree< L, X > &other, Func f)
Create from an arbitrary DecisionTree<L, X> by operating on it with a functional f.
static Y add(const Y &y1, const Y &y2)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Concept check for values that can be used in unit tests.
AlgebraicDecisionTree(double leaf=1.0)
bool equals(const DecisionTree &other, const CompareFunc &compare=&DefaultCompare) const
AlgebraicDecisionTree operator/(const AlgebraicDecisionTree &g) const
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
static std::string DefaultFormatter(const L &x)
Default method used by labelFormatter or valueFormatter when printing.
static double max(const double &a, const double &b)
void print(const std::string &s, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter) const
GTSAM-style print.
bool equals(const AlgebraicDecisionTree &other, double tol=1e-9) const
Equality method customized to value type double.
double max() const
Find the maximum values amongst all leaves.
static std::stringstream ss
AlgebraicDecisionTree operator+(const AlgebraicDecisionTree &g) const
NodePtr root_
A DecisionTree just contains the root. TODO(dellaert): make protected.
static NodePtr compose(Iterator begin, Iterator end, const L &label)
AlgebraicDecisionTree normalize() const
Helper method to perform normalization such that all leaves in the tree sum to 1.
void visit(Func f) const
Visit all leaves in depth-first fashion.
AlgebraicDecisionTree operator-(const AlgebraicDecisionTree &g) const
AlgebraicDecisionTree(const typename Base::LabelC &labelC, double y1, double y2)
Create a new leaf function splitting on a variable.
static double div(const double &a, const double &b)
DecisionTree apply(const Unary &op) const
AlgebraicDecisionTree sum(const L &label, size_t cardinality) const
void g(const string &key, int i)
double sum() const
Compute sum of all values.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
a decision tree is a function from assignments to values.
static NodePtr create(It begin, It end, ValueIt beginY, ValueIt endY)
AlgebraicDecisionTree(const AlgebraicDecisionTree< M > &other, const std::map< M, L > &map)
void print(const std::string &s="", const typename Base::LabelFormatter &labelFormatter=&DefaultFormatter) const
print method customized to value type double.
AlgebraicDecisionTree(const L &label, double y1, double y2)
std::pair< Key, size_t > LabelC
Array< int, Dynamic, 1 > v
static double mul(const double &a, const double &b)
static double add(const double &a, const double &b)
double min() const
Find the minimum values amongst all leaves.
static double negate(const double &x)
DecisionTree combine(const L &label, size_t cardinality, const Binary &op) const
AlgebraicDecisionTree operator*(const AlgebraicDecisionTree &g) const
static const EIGEN_DEPRECATED end_t end
AlgebraicDecisionTree(const Base &add)
static std::string valueFormatter(const double &v)
AlgebraicDecisionTree(Iterator begin, Iterator end, const L &label)
Create a range of decision trees, splitting on a single variable.
static NodePtr convertFrom(const typename DecisionTree< L, X >::NodePtr &f, std::function< Y(const X &)> Y_of_X)
Convert from a DecisionTree<L, X> to DecisionTree<L, Y>.
AlgebraicDecisionTree sum(const typename Base::LabelC &labelC) const
Matrix< RealScalar, Dynamic, Dynamic > M
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:01:48