VariableIndex.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 
18 #include <iostream>
19 
21 
22 namespace gtsam {
23 
24 using namespace std;
25 
26 /* ************************************************************************* */
27 bool VariableIndex::equals(const VariableIndex& other, double tol) const {
28  return this->nEntries_ == other.nEntries_ && this->nFactors_ == other.nFactors_
29  && this->index_ == other.index_;
30 }
31 
32 /* ************************************************************************* */
33 void VariableIndex::print(const string& str, const KeyFormatter& keyFormatter) const {
34  cout << str;
35  cout << "nEntries = " << nEntries() << ", nFactors = " << nFactors() << "\n";
36  for(KeyMap::value_type key_factors: index_) {
37  cout << "var " << keyFormatter(key_factors.first) << ":";
38  for(const auto index: key_factors.second)
39  cout << " " << index;
40  cout << "\n";
41  }
42  cout.flush();
43 }
44 
45 /* ************************************************************************* */
46 void VariableIndex::outputMetisFormat(ostream& os) const {
47  os << size() << " " << nFactors() << "\n";
48  // run over variables, which will be hyper-edges.
49  for(KeyMap::value_type key_factors: index_) {
50  // every variable is a hyper-edge covering its factors
51  for(const auto index: key_factors.second)
52  os << (index+1) << " "; // base 1
53  os << "\n";
54  }
55  os << flush;
56 }
57 
58 /* ************************************************************************* */
59 void VariableIndex::augmentExistingFactor(const FactorIndex factorIndex, const KeySet & newKeys)
60 {
61  gttic(VariableIndex_augmentExistingFactor);
62 
63  for(const Key key: newKeys) {
64  index_[key].push_back(factorIndex);
65  ++nEntries_;
66  }
67 
68  gttoc(VariableIndex_augmentExistingFactor);
69 }
70 
71 }
gttoc
#define gttoc(label)
Definition: timing.h:296
gtsam::FastSet< Key >
os
ofstream os("timeSchurFactors.csv")
gtsam::VariableIndex::outputMetisFormat
void outputMetisFormat(std::ostream &os) const
Definition: VariableIndex.cpp:46
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
gtsam::VariableIndex::augmentExistingFactor
void augmentExistingFactor(const FactorIndex factorIndex, const KeySet &newKeys)
Definition: VariableIndex.cpp:59
gtsam::KeyFormatter
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
gtsam::FactorIndex
std::uint64_t FactorIndex
Integer nonlinear factor index type.
Definition: types.h:100
gtsam::VariableIndex
Definition: VariableIndex.h:41
str
Definition: pytypes.h:1558
key
const gtsam::Symbol key('X', 0)
gtsam
traits
Definition: SFMdata.h:40
std
Definition: BFloat16.h:88
VariableIndex.h
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::VariableIndex::equals
bool equals(const VariableIndex &other, double tol=0.0) const
Test for equality (for unit tests and debug assertions).
Definition: VariableIndex.cpp:27
gtsam::VariableIndex::print
void print(const std::string &str="VariableIndex: ", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Print the variable index (for unit tests and debugging).
Definition: VariableIndex.cpp:33
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam.examples.ShonanAveragingCLI.str
str
Definition: ShonanAveragingCLI.py:115
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gttic
#define gttic(label)
Definition: timing.h:295


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:43:08