testTableFactor.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
12 /*
13  * testTableFactor.cpp
14  *
15  * @date Feb 15, 2023
16  * @author Yoonwoo Kim
17  */
18 
20 #include <gtsam/base/Testable.h>
26 
27 #include <chrono>
28 #include <random>
29 
30 using namespace std;
31 using namespace gtsam;
32 
33 vector<double> genArr(double dropout, size_t size) {
34  random_device rd;
35  mt19937 g(rd());
36  vector<double> dropoutmask(size); // Chance of 0
37 
38  uniform_int_distribution<> dist(1, 9);
39  auto gen = [&dist, &g]() { return dist(g); };
40  generate(dropoutmask.begin(), dropoutmask.end(), gen);
41 
42  fill_n(dropoutmask.begin(), dropoutmask.size() * (dropout), 0);
43  shuffle(dropoutmask.begin(), dropoutmask.end(), g);
44 
45  return dropoutmask;
46 }
47 
48 map<double, pair<chrono::microseconds, chrono::microseconds>> measureTime(
49  DiscreteKeys keys1, DiscreteKeys keys2, size_t size) {
50  vector<double> dropouts = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9};
51  map<double, pair<chrono::microseconds, chrono::microseconds>> measured_times;
52 
53  for (auto dropout : dropouts) {
54  vector<double> arr1 = genArr(dropout, size);
55  vector<double> arr2 = genArr(dropout, size);
56  TableFactor f1(keys1, arr1);
57  TableFactor f2(keys2, arr2);
58  DecisionTreeFactor f1_dt(keys1, arr1);
59  DecisionTreeFactor f2_dt(keys2, arr2);
60 
61  // measure time TableFactor
62  auto tb_start = chrono::high_resolution_clock::now();
63  TableFactor actual = f1 * f2;
64  auto tb_end = chrono::high_resolution_clock::now();
65  auto tb_time_diff =
66  chrono::duration_cast<chrono::microseconds>(tb_end - tb_start);
67 
68  // measure time DT
69  auto dt_start = chrono::high_resolution_clock::now();
70  DecisionTreeFactor actual_dt = f1_dt * f2_dt;
71  auto dt_end = chrono::high_resolution_clock::now();
72  auto dt_time_diff =
73  chrono::duration_cast<chrono::microseconds>(dt_end - dt_start);
74 
75  bool flag = true;
76  for (auto assignmentVal : actual_dt.enumerate()) {
77  flag = actual_dt(assignmentVal.first) != actual(assignmentVal.first);
78  if (flag) {
79  std::cout << "something is wrong: " << std::endl;
80  assignmentVal.first.print();
81  std::cout << "dt: " << actual_dt(assignmentVal.first) << std::endl;
82  std::cout << "tb: " << actual(assignmentVal.first) << std::endl;
83  break;
84  }
85  }
86  if (flag) break;
87  measured_times[dropout] = make_pair(tb_time_diff, dt_time_diff);
88  }
89  return measured_times;
90 }
91 
92 void printTime(map<double, pair<chrono::microseconds, chrono::microseconds>>
93  measured_time) {
94  for (auto&& kv : measured_time) {
95  cout << "dropout: " << kv.first
96  << " | TableFactor time: " << kv.second.first.count()
97  << " | DecisionTreeFactor time: " << kv.second.second.count() << endl;
98  }
99 }
100 
101 /* ************************************************************************* */
102 // Check constructors for TableFactor.
103 TEST(TableFactor, constructors) {
104  // Declare a bunch of keys
105  DiscreteKey X(0, 2), Y(1, 3), Z(2, 2), A(3, 5);
106 
107  // Create factors
108  TableFactor f_zeros(A, {0, 0, 0, 0, 1});
109  TableFactor f1(X, {2, 8});
110  TableFactor f2(X & Y, "2 5 3 6 4 7");
111  TableFactor f3(X & Y & Z, "2 5 3 6 4 7 25 55 35 65 45 75");
112  EXPECT_LONGS_EQUAL(1, f1.size());
113  EXPECT_LONGS_EQUAL(2, f2.size());
114  EXPECT_LONGS_EQUAL(3, f3.size());
115 
117  values[0] = 1; // x
118  values[1] = 2; // y
119  values[2] = 1; // z
120  values[3] = 4; // a
121  EXPECT_DOUBLES_EQUAL(1, f_zeros(values), 1e-9);
122  EXPECT_DOUBLES_EQUAL(8, f1(values), 1e-9);
123  EXPECT_DOUBLES_EQUAL(7, f2(values), 1e-9);
124  EXPECT_DOUBLES_EQUAL(75, f3(values), 1e-9);
125 
126  // Assert that error = -log(value)
127  EXPECT_DOUBLES_EQUAL(-log(f1(values)), f1.error(values), 1e-9);
128 
129  // Construct from DiscreteConditional
130  DiscreteConditional conditional(X | Y = "1/1 2/3 1/4");
131  TableFactor f4(conditional);
132  // Manually constructed via inspection and comparison to DecisionTreeFactor
133  TableFactor expected(X & Y, "0.5 0.4 0.2 0.5 0.6 0.8");
135 
136  // Test for 9=3x3 values.
137  DiscreteKey V(0, 3), W(1, 3), O(100, 3);
138  DiscreteConditional conditional5(V | W = "1/2/3 5/6/7 9/10/11");
139  TableFactor f5(conditional5);
140 
141  std::string expected_values =
142  "0.166667 0.277778 0.3 0.333333 0.333333 0.333333 0.5 0.388889 0.366667";
143  TableFactor expected_f5(V & W, expected_values);
144  EXPECT(assert_equal(expected_f5, f5, 1e-6));
145 
146  TableFactor f5_with_wrong_keys(V & O, expected_values);
147  EXPECT(assert_inequal(f5_with_wrong_keys, f5, 1e-9));
148 }
149 
150 /* ************************************************************************* */
151 // Check conversion from DecisionTreeFactor.
152 TEST(TableFactor, Conversion) {
153  /* This is the DecisionTree we are using
154  Choice(m2)
155  0 Choice(m1)
156  0 0 Leaf 0
157  0 1 Choice(m0)
158  0 1 0 Leaf 0
159  0 1 1 Leaf 0.14649446 // 3
160  1 Choice(m1)
161  1 0 Choice(m0)
162  1 0 0 Leaf 0
163  1 0 1 Leaf 0.14648756 // 5
164  1 1 Choice(m0)
165  1 1 0 Leaf 0.14649446 // 6
166  1 1 1 Leaf 0.23918345 // 7
167  */
168  DiscreteKeys dkeys = {{0, 2}, {1, 2}, {2, 2}};
169  DecisionTreeFactor dtf(
170  dkeys, std::vector<double>{0, 0, 0, 0.14649446, 0, 0.14648756, 0.14649446,
171  0.23918345});
172 
173  TableFactor tf(dtf.discreteKeys(), dtf);
174 
175  EXPECT(assert_equal(dtf, tf.toDecisionTreeFactor()));
176 
177  // Test for correct construction when keys are not in reverse order.
178  // This is possible in conditionals e.g. P(x1 | x0)
179  DiscreteKey X(1, 2), Y(0, 2);
180  DiscreteConditional dtf2(
181  X, {Y}, std::vector<double>{0.33333333, 0.6, 0.66666667, 0.4});
182 
183  TableFactor tf2(dtf2);
184  // GTSAM_PRINT(dtf2);
185  // GTSAM_PRINT(tf2);
186  // GTSAM_PRINT(tf2.toDecisionTreeFactor());
187 
188  // Check for ADT equality since the order of keys is irrelevant
190  tf2.toDecisionTreeFactor()));
191 }
192 
193 /* ************************************************************************* */
195  DiscreteKey X(1, 2);
196 
197  TableFactor single = *TableFactor({X}, "1 1").sum(1);
198  // Should not throw a segfault
199  EXPECT(assert_equal(*DecisionTreeFactor(X, "1 1").sum(1),
200  single.toDecisionTreeFactor()));
201 
202  TableFactor empty = *TableFactor({X}, "0 0").sum(1);
203  // Should not throw a segfault
204  EXPECT(assert_equal(*DecisionTreeFactor(X, "0 0").sum(1),
205  empty.toDecisionTreeFactor()));
206 }
207 
208 /* ************************************************************************* */
209 // Check multiplication between two TableFactors.
210 TEST(TableFactor, multiplication) {
211  DiscreteKey v0(0, 2), v1(1, 2), v2(2, 2);
212 
213  // Multiply with a DiscreteDistribution, i.e., Bayes Law!
214  DiscreteDistribution prior(v1 % "1/3");
215  TableFactor f1(v0 & v1, "1 2 3 4");
216  DecisionTreeFactor expected(v0 & v1, "0.25 1.5 0.75 3");
218  f1.toDecisionTreeFactor()));
220 
221  // Multiply two factors
222  TableFactor f2(v1 & v2, "5 6 7 8");
223  TableFactor actual = f1 * f2;
224  TableFactor expected2(v0 & v1 & v2, "5 6 14 16 15 18 28 32");
225  CHECK(assert_equal(expected2, actual));
226 
227  DiscreteKey A(0, 3), B(1, 2), C(2, 2);
228  TableFactor f_zeros1(A & C, "0 0 0 2 0 3");
229  TableFactor f_zeros2(B & C, "4 0 0 5");
230  TableFactor actual_zeros = f_zeros1 * f_zeros2;
231  TableFactor expected3(A & B & C, "0 0 0 0 0 0 0 10 0 0 0 15");
232  CHECK(assert_equal(expected3, actual_zeros));
233 }
234 
235 /* ************************************************************************* */
236 // Benchmark which compares runtime of multiplication of two TableFactors
237 // and two DecisionTreeFactors given sparsity from dense to 90% sparsity.
238 // NOTE: Enable to run.
240  DiscreteKey A(0, 5), B(1, 2), C(2, 5), D(3, 2), E(4, 5), F(5, 2), G(6, 3),
241  H(7, 2), I(8, 5), J(9, 7), K(10, 2), L(11, 3);
242 
243  // 100
244  DiscreteKeys one_1 = {A, B, C, D};
245  DiscreteKeys one_2 = {C, D, E, F};
246  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_1 =
247  measureTime(one_1, one_2, 100);
248  printTime(time_map_1);
249  // 200
250  DiscreteKeys two_1 = {A, B, C, D, F};
251  DiscreteKeys two_2 = {B, C, D, E, F};
252  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_2 =
253  measureTime(two_1, two_2, 200);
254  printTime(time_map_2);
255  // 300
256  DiscreteKeys three_1 = {A, B, C, D, G};
257  DiscreteKeys three_2 = {C, D, E, F, G};
258  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_3 =
259  measureTime(three_1, three_2, 300);
260  printTime(time_map_3);
261  // 400
262  DiscreteKeys four_1 = {A, B, C, D, F, H};
263  DiscreteKeys four_2 = {B, C, D, E, F, H};
264  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_4 =
265  measureTime(four_1, four_2, 400);
266  printTime(time_map_4);
267  // 500
268  DiscreteKeys five_1 = {A, B, C, D, I};
269  DiscreteKeys five_2 = {C, D, E, F, I};
270  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_5 =
271  measureTime(five_1, five_2, 500);
272  printTime(time_map_5);
273  // 600
274  DiscreteKeys six_1 = {A, B, C, D, F, G};
275  DiscreteKeys six_2 = {B, C, D, E, F, G};
276  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_6 =
277  measureTime(six_1, six_2, 600);
278  printTime(time_map_6);
279  // 700
280  DiscreteKeys seven_1 = {A, B, C, D, J};
281  DiscreteKeys seven_2 = {C, D, E, F, J};
282  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_7 =
283  measureTime(seven_1, seven_2, 700);
284  printTime(time_map_7);
285  // 800
286  DiscreteKeys eight_1 = {A, B, C, D, F, H, K};
287  DiscreteKeys eight_2 = {B, C, D, E, F, H, K};
288  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_8 =
289  measureTime(eight_1, eight_2, 800);
290  printTime(time_map_8);
291  // 900
292  DiscreteKeys nine_1 = {A, B, C, D, G, L};
293  DiscreteKeys nine_2 = {C, D, E, F, G, L};
294  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_9 =
295  measureTime(nine_1, nine_2, 900);
296  printTime(time_map_9);
297 }
298 
299 /* ************************************************************************* */
300 // Check sum and max over frontals.
301 TEST(TableFactor, sum_max) {
302  DiscreteKey v0(0, 3), v1(1, 2);
303  TableFactor f1(v0 & v1, "1 2 3 4 5 6");
304 
305  TableFactor expected(v1, "9 12");
306  TableFactor::shared_ptr actual = f1.sum(1);
307  CHECK(assert_equal(expected, *actual, 1e-5));
308 
309  TableFactor expected2(v1, "5 6");
310  TableFactor::shared_ptr actual2 = f1.max(1);
311  CHECK(assert_equal(expected2, *actual2));
312 
313  TableFactor f2(v1 & v0, "1 2 3 4 5 6");
314  TableFactor::shared_ptr actual22 = f2.sum(1);
315 }
316 
317 /* ************************************************************************* */
318 // Check enumerate yields the correct list of assignment/value pairs.
319 TEST(TableFactor, enumerate) {
320  DiscreteKey A(12, 3), B(5, 2);
321  TableFactor f(A & B, "1 2 3 4 5 6");
322  auto actual = f.enumerate();
323  std::vector<std::pair<DiscreteValues, double>> expected;
325  for (size_t a : {0, 1, 2}) {
326  for (size_t b : {0, 1}) {
327  values[12] = a;
328  values[5] = b;
329  expected.emplace_back(values, f(values));
330  }
331  }
332  EXPECT(actual == expected);
333 }
334 
335 /* ************************************************************************* */
336 // Check pruning of the decision tree works as expected.
337 TEST(TableFactor, Prune) {
338  DiscreteKey A(1, 2), B(2, 2), C(3, 2);
339  TableFactor f(A & B & C, "1 5 3 7 2 6 4 8");
340 
341  // Only keep the leaves with the top 5 values.
342  size_t maxNrAssignments = 5;
343  auto pruned5 = f.prune(maxNrAssignments);
344 
345  // Pruned leaves should be 0
346  TableFactor expected(A & B & C, "0 5 0 7 0 6 4 8");
347  EXPECT(assert_equal(expected, pruned5));
348 
349  // Check for more extreme pruning where we only keep the top 2 leaves
350  maxNrAssignments = 2;
351  auto pruned2 = f.prune(maxNrAssignments);
352  TableFactor expected2(A & B & C, "0 0 0 7 0 0 0 8");
353  EXPECT(assert_equal(expected2, pruned2));
354 
355  DiscreteKey D(4, 2);
357  D & C & B & A,
358  "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 "
359  "0.0 0.0 0.99995287 1.0 1.0 1.0 1.0");
360 
361  TableFactor expected3(D & C & B & A,
362  "0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 "
363  "0.999952870000 1.0 1.0 1.0 1.0");
364  maxNrAssignments = 5;
365  auto pruned3 = factor.prune(maxNrAssignments);
366  EXPECT(assert_equal(expected3, pruned3));
367 }
368 
369 /* ************************************************************************* */
370 // Check markdown representation looks as expected.
372  DiscreteKey A(12, 3), B(5, 2);
373  TableFactor f(A & B, "1 2 3 4 5 6");
374  string expected =
375  "|A|B|value|\n"
376  "|:-:|:-:|:-:|\n"
377  "|0|0|1|\n"
378  "|0|1|2|\n"
379  "|1|0|3|\n"
380  "|1|1|4|\n"
381  "|2|0|5|\n"
382  "|2|1|6|\n";
383  auto formatter = [](Key key) { return key == 12 ? "A" : "B"; };
384  string actual = f.markdown(formatter);
385  EXPECT(actual == expected);
386 }
387 
388 /* ************************************************************************* */
389 // Check markdown representation with a value formatter.
390 TEST(TableFactor, markdownWithValueFormatter) {
391  DiscreteKey A(12, 3), B(5, 2);
392  TableFactor f(A & B, "1 2 3 4 5 6");
393  string expected =
394  "|A|B|value|\n"
395  "|:-:|:-:|:-:|\n"
396  "|Zero|-|1|\n"
397  "|Zero|+|2|\n"
398  "|One|-|3|\n"
399  "|One|+|4|\n"
400  "|Two|-|5|\n"
401  "|Two|+|6|\n";
402  auto keyFormatter = [](Key key) { return key == 12 ? "A" : "B"; };
403  TableFactor::Names names{{12, {"Zero", "One", "Two"}}, {5, {"-", "+"}}};
404  string actual = f.markdown(keyFormatter, names);
405  EXPECT(actual == expected);
406 }
407 
408 /* ************************************************************************* */
409 // Check html representation with a value formatter.
410 TEST(TableFactor, htmlWithValueFormatter) {
411  DiscreteKey A(12, 3), B(5, 2);
412  TableFactor f(A & B, "1 2 3 4 5 6");
413  string expected =
414  "<div>\n"
415  "<table class='TableFactor'>\n"
416  " <thead>\n"
417  " <tr><th>A</th><th>B</th><th>value</th></tr>\n"
418  " </thead>\n"
419  " <tbody>\n"
420  " <tr><th>Zero</th><th>-</th><td>1</td></tr>\n"
421  " <tr><th>Zero</th><th>+</th><td>2</td></tr>\n"
422  " <tr><th>One</th><th>-</th><td>3</td></tr>\n"
423  " <tr><th>One</th><th>+</th><td>4</td></tr>\n"
424  " <tr><th>Two</th><th>-</th><td>5</td></tr>\n"
425  " <tr><th>Two</th><th>+</th><td>6</td></tr>\n"
426  " </tbody>\n"
427  "</table>\n"
428  "</div>";
429  auto keyFormatter = [](Key key) { return key == 12 ? "A" : "B"; };
430  TableFactor::Names names{{12, {"Zero", "One", "Two"}}, {5, {"-", "+"}}};
431  string actual = f.html(keyFormatter, names);
432  EXPECT(actual == expected);
433 }
434 
435 /* ************************************************************************* */
436 TEST(TableFactor, Unary) {
437  // Declare a bunch of keys
438  DiscreteKey X(0, 2), Y(1, 3);
439 
440  // Create factors
441  TableFactor f(X & Y, "2 5 3 6 2 7");
442  auto op = [](const double x) { return 2 * x; };
443  auto g = f.apply(op);
444 
445  TableFactor expected(X & Y, "4 10 6 12 4 14");
447 
448  auto sq_op = [](const double x) { return x * x; };
449  auto g_sq = f.apply(sq_op);
450  TableFactor expected_sq(X & Y, "4 25 9 36 4 49");
451  EXPECT(assert_equal(g_sq, expected_sq));
452 }
453 
454 /* ************************************************************************* */
455 TEST(TableFactor, UnaryAssignment) {
456  // Declare a bunch of keys
457  DiscreteKey X(0, 2), Y(1, 3);
458 
459  // Create factors
460  TableFactor f(X & Y, "2 5 3 6 2 7");
461  auto op = [](const Assignment<Key>& key, const double x) { return 2 * x; };
462  auto g = f.apply(op);
463 
464  TableFactor expected(X & Y, "4 10 6 12 4 14");
466 }
467 
468 /* ************************************************************************* */
469 int main() {
470  TestResult tr;
471  return TestRegistry::runAllTests(tr);
472 }
473 /* ************************************************************************* */
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
TEST
TEST(TableFactor, constructors)
Definition: testTableFactor.cpp:103
TEST_DISABLED
TEST_DISABLED(TableFactor, benchmark)
Definition: testTableFactor.cpp:239
H
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 y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Definition: gnuplot_common_settings.hh:74
gtsam::TableFactor
Definition: TableFactor.h:53
gtsam::markdown
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
Definition: DiscreteValues.cpp:130
gtsam::DecisionTreeFactor
Definition: DecisionTreeFactor.h:45
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
measureTime
map< double, pair< chrono::microseconds, chrono::microseconds > > measureTime(DiscreteKeys keys1, DiscreteKeys keys2, size_t size)
Definition: testTableFactor.cpp:48
benchmark
Definition: benchmark.py:1
D
MatrixXcd D
Definition: EigenSolver_EigenSolver_MatrixType.cpp:14
test_constructor::f1
auto f1
Definition: testHybridNonlinearFactor.cpp:56
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
v0
static const double v0
Definition: testCal3DFisheye.cpp:31
EXPECT_LONGS_EQUAL
#define EXPECT_LONGS_EQUAL(expected, actual)
Definition: Test.h:154
Testable.h
Concept check for values that can be used in unit tests.
EXPECT
#define EXPECT(condition)
Definition: Test.h:150
TestHarness.h
genArr
vector< double > genArr(double dropout, size_t size)
Definition: testTableFactor.cpp:33
b
Scalar * b
Definition: benchVecAdd.cpp:17
gtsam::DiscreteDistribution
Definition: DiscreteDistribution.h:33
gtsam::Y
GaussianFactorGraphValuePair Y
Definition: HybridGaussianProductFactor.cpp:29
x
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
Definition: gnuplot_common_settings.hh:12
gtsam::DecisionTreeFactor::prune
DecisionTreeFactor prune(size_t maxNrAssignments) const
Prune the decision tree of discrete variables.
Definition: DecisionTreeFactor.cpp:464
formatter
const KeyFormatter & formatter
Definition: treeTraversal-inst.h:204
f2
double f2(const Vector2 &x)
Definition: testNumericalDerivative.cpp:58
different_sigmas::values
HybridValues values
Definition: testHybridBayesNet.cpp:245
log
const EIGEN_DEVICE_FUNC LogReturnType log() const
Definition: ArrayCwiseUnaryOps.h:128
X
#define X
Definition: icosphere.cpp:20
gtsam::DiscreteKeys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:41
DiscreteConditional.h
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
gtsam::AlgebraicDecisionTree< Key >
pruning_fixture::factor
DecisionTreeFactor factor(D &C &B &A, "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 " "0.0 0.0 0.99995287 1.0 1.0 1.0 1.0")
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
printTime
void printTime(map< double, pair< chrono::microseconds, chrono::microseconds >> measured_time)
Definition: testTableFactor.cpp:92
J
JacobiRotation< float > J
Definition: Jacobi_makeJacobi.cpp:3
I
#define I
Definition: main.h:112
internal::Colamd::Empty
const int Empty
Definition: Eigen_Colamd.h:116
Signature.h
signatures for conditional densities
cholesky::expected
Matrix expected
Definition: testMatrix.cpp:971
L
MatrixXd L
Definition: LLT_example.cpp:6
gtsam::Assignment< Key >
TableFactor.h
gtsam::symbol_shorthand::F
Key F(std::uint64_t j)
Definition: inference/Symbol.h:153
EXPECT_DOUBLES_EQUAL
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
Definition: Test.h:161
g
void g(const string &key, int i)
Definition: testBTree.cpp:41
serializationTestHelpers.h
TestResult
Definition: TestResult.h:26
key
const gtsam::Symbol key('X', 0)
E
DiscreteKey E(5, 2)
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
process_shonan_timing_results.names
dictionary names
Definition: process_shonan_timing_results.py:175
gtsam::symbol_shorthand::O
Key O(std::uint64_t j)
Definition: inference/Symbol.h:162
gtsam::DiscreteConditional
Definition: DiscreteConditional.h:37
main
int main()
Definition: testTableFactor.cpp:469
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
empty
Definition: test_copy_move.cpp:19
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
gtsam
traits
Definition: SFMdata.h:40
K
#define K
Definition: igam.h:8
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
f3
double f3(double x1, double x2)
Definition: testNumericalDerivative.cpp:78
DiscreteDistribution.h
gtsam::symbol_shorthand::W
Key W(std::uint64_t j)
Definition: inference/Symbol.h:170
CHECK
#define CHECK(condition)
Definition: Test.h:108
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:38
std
Definition: BFloat16.h:88
G
JacobiRotation< float > G
Definition: Jacobi_makeGivens.cpp:2
v2
Vector v2
Definition: testSerializationBase.cpp:39
f4
double f4(double x, double y, double z)
Definition: testNumericalDerivative.cpp:107
gtsam::assert_equal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:41
gtsam::DecisionTreeFactor::enumerate
std::vector< std::pair< DiscreteValues, double > > enumerate() const
Enumerate all values into a map from values to double.
Definition: DecisionTreeFactor.cpp:187
V
MatrixXcd V
Definition: EigenSolver_EigenSolver_MatrixType.cpp:15
gtsam::assert_inequal
bool assert_inequal(const Matrix &A, const Matrix &B, double tol)
Definition: Matrix.cpp:61
different_sigmas::prior
const auto prior
Definition: testHybridBayesNet.cpp:238
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
Z
#define Z
Definition: icosphere.cpp:21
gtsam::TableFactor::shared_ptr
std::shared_ptr< TableFactor > shared_ptr
Definition: TableFactor.h:104
v1
Vector v1
Definition: testSerializationBase.cpp:38
gtsam::TableFactor::toDecisionTreeFactor
DecisionTreeFactor toDecisionTreeFactor() const override
Convert into a decisiontree.
Definition: TableFactor.cpp:258


gtsam
Author(s):
autogenerated on Sat Jan 4 2025 04:07:14