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 }
void outputMetisFormat(std::ostream &os) const
Definition: Half.h:150
void print(const std::string &str="VariableIndex: ", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Print the variable index (for unit tests and debugging).
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
#define gttic(label)
Definition: timing.h:280
void augmentExistingFactor(const FactorIndex factorIndex, const KeySet &newKeys)
Definition: pytypes.h:928
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
traits
Definition: chartTesting.h:28
ofstream os("timeSchurFactors.csv")
#define gttoc(label)
Definition: timing.h:281
const G double tol
Definition: Group.h:83
std::uint64_t FactorIndex
Integer nonlinear factor index type.
Definition: types.h:64
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
bool equals(const VariableIndex &other, double tol=0.0) const
Test for equality (for unit tests and debug assertions).


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:51:23