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>
27 
28 #include <chrono>
29 #include <random>
30 
31 using namespace std;
32 using namespace gtsam;
33 
34 vector<double> genArr(double dropout, size_t size) {
35  random_device rd;
36  mt19937 g(rd());
37  vector<double> dropoutmask(size); // Chance of 0
38 
39  uniform_int_distribution<> dist(1, 9);
40  auto gen = [&dist, &g]() { return dist(g); };
41  generate(dropoutmask.begin(), dropoutmask.end(), gen);
42 
43  fill_n(dropoutmask.begin(), dropoutmask.size() * (dropout), 0);
44  shuffle(dropoutmask.begin(), dropoutmask.end(), g);
45 
46  return dropoutmask;
47 }
48 
49 map<double, pair<chrono::microseconds, chrono::microseconds>> measureTime(
50  DiscreteKeys keys1, DiscreteKeys keys2, size_t size) {
51  vector<double> dropouts = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9};
52  map<double, pair<chrono::microseconds, chrono::microseconds>> measured_times;
53 
54  for (auto dropout : dropouts) {
55  vector<double> arr1 = genArr(dropout, size);
56  vector<double> arr2 = genArr(dropout, size);
57  TableFactor f1(keys1, arr1);
58  TableFactor f2(keys2, arr2);
59  DecisionTreeFactor f1_dt(keys1, arr1);
60  DecisionTreeFactor f2_dt(keys2, arr2);
61 
62  // measure time TableFactor
63  auto tb_start = chrono::high_resolution_clock::now();
64  TableFactor actual = f1 * f2;
65  auto tb_end = chrono::high_resolution_clock::now();
66  auto tb_time_diff =
67  chrono::duration_cast<chrono::microseconds>(tb_end - tb_start);
68 
69  // measure time DT
70  auto dt_start = chrono::high_resolution_clock::now();
71  DecisionTreeFactor actual_dt = f1_dt * f2_dt;
72  auto dt_end = chrono::high_resolution_clock::now();
73  auto dt_time_diff =
74  chrono::duration_cast<chrono::microseconds>(dt_end - dt_start);
75 
76  bool flag = true;
77  for (auto assignmentVal : actual_dt.enumerate()) {
78  flag = actual_dt(assignmentVal.first) != actual(assignmentVal.first);
79  if (flag) {
80  std::cout << "something is wrong: " << std::endl;
81  assignmentVal.first.print();
82  std::cout << "dt: " << actual_dt(assignmentVal.first) << std::endl;
83  std::cout << "tb: " << actual(assignmentVal.first) << std::endl;
84  break;
85  }
86  }
87  if (flag) break;
88  measured_times[dropout] = make_pair(tb_time_diff, dt_time_diff);
89  }
90  return measured_times;
91 }
92 
93 void printTime(map<double, pair<chrono::microseconds, chrono::microseconds>>
94  measured_time) {
95  for (auto&& kv : measured_time) {
96  cout << "dropout: " << kv.first
97  << " | TableFactor time: " << kv.second.first.count()
98  << " | DecisionTreeFactor time: " << kv.second.second.count() << endl;
99  }
100 }
101 
102 /* ************************************************************************* */
103 // Check constructors for TableFactor.
104 TEST(TableFactor, constructors) {
105  // Declare a bunch of keys
106  DiscreteKey X(0, 2), Y(1, 3), Z(2, 2), A(3, 5);
107 
108  // Create factors
109  TableFactor f_zeros(A, {0, 0, 0, 0, 1});
110  TableFactor f1(X, {2, 8});
111  TableFactor f2(X & Y, "2 5 3 6 4 7");
112  TableFactor f3(X & Y & Z, "2 5 3 6 4 7 25 55 35 65 45 75");
113  EXPECT_LONGS_EQUAL(1, f1.size());
114  EXPECT_LONGS_EQUAL(2, f2.size());
115  EXPECT_LONGS_EQUAL(3, f3.size());
116 
118  values[0] = 1; // x
119  values[1] = 2; // y
120  values[2] = 1; // z
121  values[3] = 4; // a
122  EXPECT_DOUBLES_EQUAL(1, f_zeros(values), 1e-9);
123  EXPECT_DOUBLES_EQUAL(8, f1(values), 1e-9);
124  EXPECT_DOUBLES_EQUAL(7, f2(values), 1e-9);
125  EXPECT_DOUBLES_EQUAL(75, f3(values), 1e-9);
126 
127  // Assert that error = -log(value)
128  EXPECT_DOUBLES_EQUAL(-log(f1(values)), f1.error(values), 1e-9);
129 
130  // Construct from DiscreteConditional
131  DiscreteConditional conditional(X | Y = "1/1 2/3 1/4");
132  TableFactor f4(conditional);
133  // Manually constructed via inspection and comparison to DecisionTreeFactor
134  TableFactor expected(X & Y, "0.5 0.4 0.2 0.5 0.6 0.8");
136 
137  // Test for 9=3x3 values.
138  DiscreteKey V(0, 3), W(1, 3), O(100, 3);
139  DiscreteConditional conditional5(V | W = "1/2/3 5/6/7 9/10/11");
140  TableFactor f5(conditional5);
141 
142  std::string expected_values =
143  "0.166667 0.277778 0.3 0.333333 0.333333 0.333333 0.5 0.388889 0.366667";
144  TableFactor expected_f5(V & W, expected_values);
145  EXPECT(assert_equal(expected_f5, f5, 1e-6));
146 
147  TableFactor f5_with_wrong_keys(V & O, expected_values);
148  EXPECT(assert_inequal(f5_with_wrong_keys, f5, 1e-9));
149 }
150 
151 /* ************************************************************************* */
152 // Check conversion from DecisionTreeFactor.
153 TEST(TableFactor, Conversion) {
154  /* This is the DecisionTree we are using
155  Choice(m2)
156  0 Choice(m1)
157  0 0 Leaf 0
158  0 1 Choice(m0)
159  0 1 0 Leaf 0
160  0 1 1 Leaf 0.14649446 // 3
161  1 Choice(m1)
162  1 0 Choice(m0)
163  1 0 0 Leaf 0
164  1 0 1 Leaf 0.14648756 // 5
165  1 1 Choice(m0)
166  1 1 0 Leaf 0.14649446 // 6
167  1 1 1 Leaf 0.23918345 // 7
168  */
169  DiscreteKeys dkeys = {{0, 2}, {1, 2}, {2, 2}};
170  DecisionTreeFactor dtf(
171  dkeys, std::vector<double>{0, 0, 0, 0.14649446, 0, 0.14648756, 0.14649446,
172  0.23918345});
173 
174  TableFactor tf(dtf.discreteKeys(), dtf);
175 
176  EXPECT(assert_equal(dtf, tf.toDecisionTreeFactor()));
177 
178  // Test for correct construction when keys are not in reverse order.
179  // This is possible in conditionals e.g. P(x1 | x0)
180  DiscreteKey X(1, 2), Y(0, 2);
181  DiscreteConditional dtf2(
182  X, {Y}, std::vector<double>{0.33333333, 0.6, 0.66666667, 0.4});
183 
184  TableFactor tf2(dtf2);
185  // GTSAM_PRINT(dtf2);
186  // GTSAM_PRINT(tf2);
187  // GTSAM_PRINT(tf2.toDecisionTreeFactor());
188 
189  // Check for ADT equality since the order of keys is irrelevant
191  tf2.toDecisionTreeFactor()));
192 }
193 
194 /* ************************************************************************* */
196  DiscreteKey X(1, 2);
197 
198  auto single = TableFactor({X}, "1 1").sum(1);
199  // Should not throw a segfault
200  auto expected_single = DecisionTreeFactor(X, "1 1").sum(1);
201  EXPECT(assert_equal(expected_single->toDecisionTreeFactor(),
202  single->toDecisionTreeFactor()));
203 
204  auto empty = TableFactor({X}, "0 0").sum(1);
205  // Should not throw a segfault
206  auto expected_empty = DecisionTreeFactor(X, "0 0").sum(1);
207  EXPECT(assert_equal(expected_empty->toDecisionTreeFactor(),
208  empty->toDecisionTreeFactor()));
209 }
210 
211 /* ************************************************************************* */
212 // Check multiplication between two TableFactors.
213 TEST(TableFactor, multiplication) {
214  DiscreteKey v0(0, 2), v1(1, 2), v2(2, 2);
215 
216  // Multiply with a DiscreteDistribution, i.e., Bayes Law!
217  DiscreteDistribution prior(v1 % "1/3");
218  TableFactor f1(v0 & v1, "1 2 3 4");
219  DecisionTreeFactor expected(v0 & v1, "0.25 1.5 0.75 3");
221  f1.toDecisionTreeFactor()));
223 
224  // Multiply two factors
225  TableFactor f2(v1 & v2, "5 6 7 8");
226  TableFactor actual = f1 * f2;
227  TableFactor expected2(v0 & v1 & v2, "5 6 14 16 15 18 28 32");
228  CHECK(assert_equal(expected2, actual));
229 
230  DiscreteKey A(0, 3), B(1, 2), C(2, 2);
231  TableFactor f_zeros1(A & C, "0 0 0 2 0 3");
232  TableFactor f_zeros2(B & C, "4 0 0 5");
233  TableFactor actual_zeros = f_zeros1 * f_zeros2;
234  TableFactor expected3(A & B & C, "0 0 0 0 0 0 0 10 0 0 0 15");
235  CHECK(assert_equal(expected3, actual_zeros));
236 }
237 
238 /* ************************************************************************* */
239 // Benchmark which compares runtime of multiplication of two TableFactors
240 // and two DecisionTreeFactors given sparsity from dense to 90% sparsity.
241 // NOTE: Enable to run.
243  DiscreteKey A(0, 5), B(1, 2), C(2, 5), D(3, 2), E(4, 5), F(5, 2), G(6, 3),
244  H(7, 2), I(8, 5), J(9, 7), K(10, 2), L(11, 3);
245 
246  // 100
247  DiscreteKeys one_1 = {A, B, C, D};
248  DiscreteKeys one_2 = {C, D, E, F};
249  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_1 =
250  measureTime(one_1, one_2, 100);
251  printTime(time_map_1);
252  // 200
253  DiscreteKeys two_1 = {A, B, C, D, F};
254  DiscreteKeys two_2 = {B, C, D, E, F};
255  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_2 =
256  measureTime(two_1, two_2, 200);
257  printTime(time_map_2);
258  // 300
259  DiscreteKeys three_1 = {A, B, C, D, G};
260  DiscreteKeys three_2 = {C, D, E, F, G};
261  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_3 =
262  measureTime(three_1, three_2, 300);
263  printTime(time_map_3);
264  // 400
265  DiscreteKeys four_1 = {A, B, C, D, F, H};
266  DiscreteKeys four_2 = {B, C, D, E, F, H};
267  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_4 =
268  measureTime(four_1, four_2, 400);
269  printTime(time_map_4);
270  // 500
271  DiscreteKeys five_1 = {A, B, C, D, I};
272  DiscreteKeys five_2 = {C, D, E, F, I};
273  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_5 =
274  measureTime(five_1, five_2, 500);
275  printTime(time_map_5);
276  // 600
277  DiscreteKeys six_1 = {A, B, C, D, F, G};
278  DiscreteKeys six_2 = {B, C, D, E, F, G};
279  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_6 =
280  measureTime(six_1, six_2, 600);
281  printTime(time_map_6);
282  // 700
283  DiscreteKeys seven_1 = {A, B, C, D, J};
284  DiscreteKeys seven_2 = {C, D, E, F, J};
285  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_7 =
286  measureTime(seven_1, seven_2, 700);
287  printTime(time_map_7);
288  // 800
289  DiscreteKeys eight_1 = {A, B, C, D, F, H, K};
290  DiscreteKeys eight_2 = {B, C, D, E, F, H, K};
291  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_8 =
292  measureTime(eight_1, eight_2, 800);
293  printTime(time_map_8);
294  // 900
295  DiscreteKeys nine_1 = {A, B, C, D, G, L};
296  DiscreteKeys nine_2 = {C, D, E, F, G, L};
297  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_9 =
298  measureTime(nine_1, nine_2, 900);
299  printTime(time_map_9);
300 }
301 
302 /* ************************************************************************* */
303 // Check sum and max over frontals.
304 TEST(TableFactor, sum_max) {
305  DiscreteKey v0(0, 3), v1(1, 2);
306  TableFactor f1(v0 & v1, "1 2 3 4 5 6");
307 
308  TableFactor expected(v1, "9 12");
309  auto actual = std::dynamic_pointer_cast<TableFactor>(f1.sum(1));
310  CHECK(actual);
311  CHECK(assert_equal(expected, *actual, 1e-5));
312 
313  TableFactor expected2(v1, "5 6");
314  auto actual2 = std::dynamic_pointer_cast<TableFactor>(f1.max(1));
315  CHECK(actual2);
316  CHECK(assert_equal(expected2, *actual2));
317 
318  TableFactor f2(v1 & v0, "1 2 3 4 5 6");
319  auto actual22 = std::dynamic_pointer_cast<TableFactor>(f2.sum(1));
320  CHECK(actual22);
321 }
322 
323 /* ************************************************************************* */
324 // Check enumerate yields the correct list of assignment/value pairs.
325 TEST(TableFactor, enumerate) {
326  DiscreteKey A(12, 3), B(5, 2);
327  TableFactor f(A & B, "1 2 3 4 5 6");
328  auto actual = f.enumerate();
329  std::vector<std::pair<DiscreteValues, double>> expected;
331  for (size_t a : {0, 1, 2}) {
332  for (size_t b : {0, 1}) {
333  values[12] = a;
334  values[5] = b;
335  expected.emplace_back(values, f(values));
336  }
337  }
338  EXPECT(actual == expected);
339 }
340 
341 /* ************************************************************************* */
342 // Check pruning of the decision tree works as expected.
343 TEST(TableFactor, Prune) {
344  DiscreteKey A(1, 2), B(2, 2), C(3, 2);
345  TableFactor f(A & B & C, "1 5 3 7 2 6 4 8");
346 
347  // Only keep the leaves with the top 5 values.
348  size_t maxNrAssignments = 5;
349  auto pruned5 = f.prune(maxNrAssignments);
350 
351  // Pruned leaves should be 0
352  TableFactor expected(A & B & C, "0 5 0 7 0 6 4 8");
353  EXPECT(assert_equal(expected, pruned5));
354 
355  // Check for more extreme pruning where we only keep the top 2 leaves
356  maxNrAssignments = 2;
357  auto pruned2 = f.prune(maxNrAssignments);
358  TableFactor expected2(A & B & C, "0 0 0 7 0 0 0 8");
359  EXPECT(assert_equal(expected2, pruned2));
360 
361  DiscreteKey D(4, 2);
363  D & C & B & A,
364  "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 "
365  "0.0 0.0 0.99995287 1.0 1.0 1.0 1.0");
366 
367  TableFactor expected3(D & C & B & A,
368  "0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 "
369  "0.999952870000 1.0 1.0 1.0 1.0");
370  maxNrAssignments = 5;
371  auto pruned3 = factor.prune(maxNrAssignments);
372  EXPECT(assert_equal(expected3, pruned3));
373 }
374 
375 /* ************************************************************************* */
376 // Check markdown representation looks as expected.
378  DiscreteKey A(12, 3), B(5, 2);
379  TableFactor f(A & B, "1 2 3 4 5 6");
380  string expected =
381  "|A|B|value|\n"
382  "|:-:|:-:|:-:|\n"
383  "|0|0|1|\n"
384  "|0|1|2|\n"
385  "|1|0|3|\n"
386  "|1|1|4|\n"
387  "|2|0|5|\n"
388  "|2|1|6|\n";
389  auto formatter = [](Key key) { return key == 12 ? "A" : "B"; };
390  string actual = f.markdown(formatter);
391  EXPECT(actual == expected);
392 }
393 
394 /* ************************************************************************* */
395 // Check markdown representation with a value formatter.
396 TEST(TableFactor, markdownWithValueFormatter) {
397  DiscreteKey A(12, 3), B(5, 2);
398  TableFactor f(A & B, "1 2 3 4 5 6");
399  string expected =
400  "|A|B|value|\n"
401  "|:-:|:-:|:-:|\n"
402  "|Zero|-|1|\n"
403  "|Zero|+|2|\n"
404  "|One|-|3|\n"
405  "|One|+|4|\n"
406  "|Two|-|5|\n"
407  "|Two|+|6|\n";
408  auto keyFormatter = [](Key key) { return key == 12 ? "A" : "B"; };
409  TableFactor::Names names{{12, {"Zero", "One", "Two"}}, {5, {"-", "+"}}};
410  string actual = f.markdown(keyFormatter, names);
411  EXPECT(actual == expected);
412 }
413 
414 /* ************************************************************************* */
415 // Check html representation with a value formatter.
416 TEST(TableFactor, htmlWithValueFormatter) {
417  DiscreteKey A(12, 3), B(5, 2);
418  TableFactor f(A & B, "1 2 3 4 5 6");
419  string expected =
420  "<div>\n"
421  "<table class='TableFactor'>\n"
422  " <thead>\n"
423  " <tr><th>A</th><th>B</th><th>value</th></tr>\n"
424  " </thead>\n"
425  " <tbody>\n"
426  " <tr><th>Zero</th><th>-</th><td>1</td></tr>\n"
427  " <tr><th>Zero</th><th>+</th><td>2</td></tr>\n"
428  " <tr><th>One</th><th>-</th><td>3</td></tr>\n"
429  " <tr><th>One</th><th>+</th><td>4</td></tr>\n"
430  " <tr><th>Two</th><th>-</th><td>5</td></tr>\n"
431  " <tr><th>Two</th><th>+</th><td>6</td></tr>\n"
432  " </tbody>\n"
433  "</table>\n"
434  "</div>";
435  auto keyFormatter = [](Key key) { return key == 12 ? "A" : "B"; };
436  TableFactor::Names names{{12, {"Zero", "One", "Two"}}, {5, {"-", "+"}}};
437  string actual = f.html(keyFormatter, names);
438  EXPECT(actual == expected);
439 }
440 
441 /* ************************************************************************* */
442 TEST(TableFactor, Unary) {
443  // Declare a bunch of keys
444  DiscreteKey X(0, 2), Y(1, 3);
445 
446  // Create factors
447  TableFactor f(X & Y, "2 5 3 6 2 7");
448  auto op = [](const double x) { return 2 * x; };
449  auto g = f.apply(op);
450 
451  TableFactor expected(X & Y, "4 10 6 12 4 14");
453 
454  auto sq_op = [](const double x) { return x * x; };
455  auto g_sq = f.apply(sq_op);
456  TableFactor expected_sq(X & Y, "4 25 9 36 4 49");
457  EXPECT(assert_equal(g_sq, expected_sq));
458 }
459 
460 /* ************************************************************************* */
461 TEST(TableFactor, UnaryAssignment) {
462  // Declare a bunch of keys
463  DiscreteKey X(0, 2), Y(1, 3);
464 
465  // Create factors
466  TableFactor f(X & Y, "2 5 3 6 2 7");
467  auto op = [](const Assignment<Key>& key, const double x) { return 2 * x; };
468  auto g = f.apply(op);
469 
470  TableFactor expected(X & Y, "4 10 6 12 4 14");
472 }
473 
474 /* ************************************************************************* */
475 int main() {
476  TestResult tr;
477  return TestRegistry::runAllTests(tr);
478 }
479 /* ************************************************************************* */
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
TEST
TEST(TableFactor, constructors)
Definition: testTableFactor.cpp:104
TEST_DISABLED
TEST_DISABLED(TableFactor, benchmark)
Definition: testTableFactor.cpp:242
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:54
gtsam::markdown
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
Definition: DiscreteValues.cpp:148
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:49
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:34
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:508
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:247
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
TestableAssertions.h
Provides additional testing facilities for common data structures.
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:93
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:475
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
gtsam::DecisionTreeFactor::sum
DiscreteFactor::shared_ptr sum(size_t nrFrontals) const override
Create new factor by summing all values with the same separator values.
Definition: DecisionTreeFactor.h:201
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:231
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:240
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
Z
#define Z
Definition: icosphere.cpp:21
v1
Vector v1
Definition: testSerializationBase.cpp:38


gtsam
Author(s):
autogenerated on Sun Feb 16 2025 04:07:35