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  auto single = TableFactor({X}, "1 1").sum(1);
198  // Should not throw a segfault
199  auto expected_single = DecisionTreeFactor(X, "1 1").sum(1);
200  EXPECT(assert_equal(expected_single->toDecisionTreeFactor(),
201  single->toDecisionTreeFactor()));
202 
203  auto empty = TableFactor({X}, "0 0").sum(1);
204  // Should not throw a segfault
205  auto expected_empty = DecisionTreeFactor(X, "0 0").sum(1);
206  EXPECT(assert_equal(expected_empty->toDecisionTreeFactor(),
207  empty->toDecisionTreeFactor()));
208 }
209 
210 /* ************************************************************************* */
211 // Check multiplication between two TableFactors.
212 TEST(TableFactor, multiplication) {
213  DiscreteKey v0(0, 2), v1(1, 2), v2(2, 2);
214 
215  // Multiply with a DiscreteDistribution, i.e., Bayes Law!
216  DiscreteDistribution prior(v1 % "1/3");
217  TableFactor f1(v0 & v1, "1 2 3 4");
218  DecisionTreeFactor expected(v0 & v1, "0.25 1.5 0.75 3");
220  f1.toDecisionTreeFactor()));
222 
223  // Multiply two factors
224  TableFactor f2(v1 & v2, "5 6 7 8");
225  TableFactor actual = f1 * f2;
226  TableFactor expected2(v0 & v1 & v2, "5 6 14 16 15 18 28 32");
227  CHECK(assert_equal(expected2, actual));
228 
229  DiscreteKey A(0, 3), B(1, 2), C(2, 2);
230  TableFactor f_zeros1(A & C, "0 0 0 2 0 3");
231  TableFactor f_zeros2(B & C, "4 0 0 5");
232  TableFactor actual_zeros = f_zeros1 * f_zeros2;
233  TableFactor expected3(A & B & C, "0 0 0 0 0 0 0 10 0 0 0 15");
234  CHECK(assert_equal(expected3, actual_zeros));
235 }
236 
237 /* ************************************************************************* */
238 // Benchmark which compares runtime of multiplication of two TableFactors
239 // and two DecisionTreeFactors given sparsity from dense to 90% sparsity.
240 // NOTE: Enable to run.
242  DiscreteKey A(0, 5), B(1, 2), C(2, 5), D(3, 2), E(4, 5), F(5, 2), G(6, 3),
243  H(7, 2), I(8, 5), J(9, 7), K(10, 2), L(11, 3);
244 
245  // 100
246  DiscreteKeys one_1 = {A, B, C, D};
247  DiscreteKeys one_2 = {C, D, E, F};
248  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_1 =
249  measureTime(one_1, one_2, 100);
250  printTime(time_map_1);
251  // 200
252  DiscreteKeys two_1 = {A, B, C, D, F};
253  DiscreteKeys two_2 = {B, C, D, E, F};
254  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_2 =
255  measureTime(two_1, two_2, 200);
256  printTime(time_map_2);
257  // 300
258  DiscreteKeys three_1 = {A, B, C, D, G};
259  DiscreteKeys three_2 = {C, D, E, F, G};
260  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_3 =
261  measureTime(three_1, three_2, 300);
262  printTime(time_map_3);
263  // 400
264  DiscreteKeys four_1 = {A, B, C, D, F, H};
265  DiscreteKeys four_2 = {B, C, D, E, F, H};
266  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_4 =
267  measureTime(four_1, four_2, 400);
268  printTime(time_map_4);
269  // 500
270  DiscreteKeys five_1 = {A, B, C, D, I};
271  DiscreteKeys five_2 = {C, D, E, F, I};
272  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_5 =
273  measureTime(five_1, five_2, 500);
274  printTime(time_map_5);
275  // 600
276  DiscreteKeys six_1 = {A, B, C, D, F, G};
277  DiscreteKeys six_2 = {B, C, D, E, F, G};
278  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_6 =
279  measureTime(six_1, six_2, 600);
280  printTime(time_map_6);
281  // 700
282  DiscreteKeys seven_1 = {A, B, C, D, J};
283  DiscreteKeys seven_2 = {C, D, E, F, J};
284  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_7 =
285  measureTime(seven_1, seven_2, 700);
286  printTime(time_map_7);
287  // 800
288  DiscreteKeys eight_1 = {A, B, C, D, F, H, K};
289  DiscreteKeys eight_2 = {B, C, D, E, F, H, K};
290  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_8 =
291  measureTime(eight_1, eight_2, 800);
292  printTime(time_map_8);
293  // 900
294  DiscreteKeys nine_1 = {A, B, C, D, G, L};
295  DiscreteKeys nine_2 = {C, D, E, F, G, L};
296  map<double, pair<chrono::microseconds, chrono::microseconds>> time_map_9 =
297  measureTime(nine_1, nine_2, 900);
298  printTime(time_map_9);
299 }
300 
301 /* ************************************************************************* */
302 // Check sum and max over frontals.
303 TEST(TableFactor, sum_max) {
304  DiscreteKey v0(0, 3), v1(1, 2);
305  TableFactor f1(v0 & v1, "1 2 3 4 5 6");
306 
307  TableFactor expected(v1, "9 12");
308  auto actual = std::dynamic_pointer_cast<TableFactor>(f1.sum(1));
309  CHECK(actual);
310  CHECK(assert_equal(expected, *actual, 1e-5));
311 
312  TableFactor expected2(v1, "5 6");
313  auto actual2 = std::dynamic_pointer_cast<TableFactor>(f1.max(1));
314  CHECK(actual2);
315  CHECK(assert_equal(expected2, *actual2));
316 
317  TableFactor f2(v1 & v0, "1 2 3 4 5 6");
318  auto actual22 = std::dynamic_pointer_cast<TableFactor>(f2.sum(1));
319  CHECK(actual22);
320 }
321 
322 /* ************************************************************************* */
323 // Check enumerate yields the correct list of assignment/value pairs.
324 TEST(TableFactor, enumerate) {
325  DiscreteKey A(12, 3), B(5, 2);
326  TableFactor f(A & B, "1 2 3 4 5 6");
327  auto actual = f.enumerate();
328  std::vector<std::pair<DiscreteValues, double>> expected;
330  for (size_t a : {0, 1, 2}) {
331  for (size_t b : {0, 1}) {
332  values[12] = a;
333  values[5] = b;
334  expected.emplace_back(values, f(values));
335  }
336  }
337  EXPECT(actual == expected);
338 }
339 
340 /* ************************************************************************* */
341 // Check pruning of the decision tree works as expected.
342 TEST(TableFactor, Prune) {
343  DiscreteKey A(1, 2), B(2, 2), C(3, 2);
344  TableFactor f(A & B & C, "1 5 3 7 2 6 4 8");
345 
346  // Only keep the leaves with the top 5 values.
347  size_t maxNrAssignments = 5;
348  auto pruned5 = f.prune(maxNrAssignments);
349 
350  // Pruned leaves should be 0
351  TableFactor expected(A & B & C, "0 5 0 7 0 6 4 8");
352  EXPECT(assert_equal(expected, pruned5));
353 
354  // Check for more extreme pruning where we only keep the top 2 leaves
355  maxNrAssignments = 2;
356  auto pruned2 = f.prune(maxNrAssignments);
357  TableFactor expected2(A & B & C, "0 0 0 7 0 0 0 8");
358  EXPECT(assert_equal(expected2, pruned2));
359 
360  DiscreteKey D(4, 2);
362  D & C & B & A,
363  "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 "
364  "0.0 0.0 0.99995287 1.0 1.0 1.0 1.0");
365 
366  TableFactor expected3(D & C & B & A,
367  "0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 "
368  "0.999952870000 1.0 1.0 1.0 1.0");
369  maxNrAssignments = 5;
370  auto pruned3 = factor.prune(maxNrAssignments);
371  EXPECT(assert_equal(expected3, pruned3));
372 }
373 
374 /* ************************************************************************* */
375 // Check markdown representation looks as expected.
377  DiscreteKey A(12, 3), B(5, 2);
378  TableFactor f(A & B, "1 2 3 4 5 6");
379  string expected =
380  "|A|B|value|\n"
381  "|:-:|:-:|:-:|\n"
382  "|0|0|1|\n"
383  "|0|1|2|\n"
384  "|1|0|3|\n"
385  "|1|1|4|\n"
386  "|2|0|5|\n"
387  "|2|1|6|\n";
388  auto formatter = [](Key key) { return key == 12 ? "A" : "B"; };
389  string actual = f.markdown(formatter);
390  EXPECT(actual == expected);
391 }
392 
393 /* ************************************************************************* */
394 // Check markdown representation with a value formatter.
395 TEST(TableFactor, markdownWithValueFormatter) {
396  DiscreteKey A(12, 3), B(5, 2);
397  TableFactor f(A & B, "1 2 3 4 5 6");
398  string expected =
399  "|A|B|value|\n"
400  "|:-:|:-:|:-:|\n"
401  "|Zero|-|1|\n"
402  "|Zero|+|2|\n"
403  "|One|-|3|\n"
404  "|One|+|4|\n"
405  "|Two|-|5|\n"
406  "|Two|+|6|\n";
407  auto keyFormatter = [](Key key) { return key == 12 ? "A" : "B"; };
408  TableFactor::Names names{{12, {"Zero", "One", "Two"}}, {5, {"-", "+"}}};
409  string actual = f.markdown(keyFormatter, names);
410  EXPECT(actual == expected);
411 }
412 
413 /* ************************************************************************* */
414 // Check html representation with a value formatter.
415 TEST(TableFactor, htmlWithValueFormatter) {
416  DiscreteKey A(12, 3), B(5, 2);
417  TableFactor f(A & B, "1 2 3 4 5 6");
418  string expected =
419  "<div>\n"
420  "<table class='TableFactor'>\n"
421  " <thead>\n"
422  " <tr><th>A</th><th>B</th><th>value</th></tr>\n"
423  " </thead>\n"
424  " <tbody>\n"
425  " <tr><th>Zero</th><th>-</th><td>1</td></tr>\n"
426  " <tr><th>Zero</th><th>+</th><td>2</td></tr>\n"
427  " <tr><th>One</th><th>-</th><td>3</td></tr>\n"
428  " <tr><th>One</th><th>+</th><td>4</td></tr>\n"
429  " <tr><th>Two</th><th>-</th><td>5</td></tr>\n"
430  " <tr><th>Two</th><th>+</th><td>6</td></tr>\n"
431  " </tbody>\n"
432  "</table>\n"
433  "</div>";
434  auto keyFormatter = [](Key key) { return key == 12 ? "A" : "B"; };
435  TableFactor::Names names{{12, {"Zero", "One", "Two"}}, {5, {"-", "+"}}};
436  string actual = f.html(keyFormatter, names);
437  EXPECT(actual == expected);
438 }
439 
440 /* ************************************************************************* */
441 TEST(TableFactor, Unary) {
442  // Declare a bunch of keys
443  DiscreteKey X(0, 2), Y(1, 3);
444 
445  // Create factors
446  TableFactor f(X & Y, "2 5 3 6 2 7");
447  auto op = [](const double x) { return 2 * x; };
448  auto g = f.apply(op);
449 
450  TableFactor expected(X & Y, "4 10 6 12 4 14");
452 
453  auto sq_op = [](const double x) { return x * x; };
454  auto g_sq = f.apply(sq_op);
455  TableFactor expected_sq(X & Y, "4 25 9 36 4 49");
456  EXPECT(assert_equal(g_sq, expected_sq));
457 }
458 
459 /* ************************************************************************* */
460 TEST(TableFactor, UnaryAssignment) {
461  // Declare a bunch of keys
462  DiscreteKey X(0, 2), Y(1, 3);
463 
464  // Create factors
465  TableFactor f(X & Y, "2 5 3 6 2 7");
466  auto op = [](const Assignment<Key>& key, const double x) { return 2 * x; };
467  auto g = f.apply(op);
468 
469  TableFactor expected(X & Y, "4 10 6 12 4 14");
471 }
472 
473 /* ************************************************************************* */
474 int main() {
475  TestResult tr;
476  return TestRegistry::runAllTests(tr);
477 }
478 /* ************************************************************************* */
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:241
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: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: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: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:474
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:195
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:238
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 Tue Jan 7 2025 04:08:34