PartitionWorkSpace.h
Go to the documentation of this file.
1 /*
2  * PartitionWorkSpace.h
3  *
4  * Created on: Nov 24, 2010
5  * Author: nikai
6  * Description: a preallocated memory space used in partitioning
7  */
8 
9 #pragma once
10 
11 #include <vector>
12 #include <memory>
13 
14 namespace gtsam { namespace partition {
15 
16  typedef std::vector<int> PartitionTable;
17 
18  // the work space, preallocated memory
19  struct WorkSpace {
20  std::vector<int> dictionary; // a mapping from the integer key in the original graph to 0-based index in the subgraph, useful when handling a subset of keys and graphs
21  std::shared_ptr<std::vector<size_t> > dsf; // a block memory pre-allocated for DSFVector
22  PartitionTable partitionTable; // a mapping from a key to the submap index, 0 means the separator, i means the ith submap
23 
24  // constructor
25  WorkSpace(const size_t numNodes) : dictionary(numNodes,0),
26  dsf(new std::vector<size_t>(numNodes, 0)), partitionTable(numNodes, -1) { }
27 
28  // set up dictionary: -1: no such key, none-zero: the corresponding 0-based index
29  inline void prepareDictionary(const std::vector<size_t>& keys) {
30  int index = 0;
31  std::fill(dictionary.begin(), dictionary.end(), -1);
32  std::vector<size_t>::const_iterator it=keys.begin(), itLast=keys.end();
33  while(it!=itLast) dictionary[*(it++)] = index++;
34  }
35  };
36 
37 
38  // manually defined cuts
39  struct Cuts {
41  std::vector<std::shared_ptr<Cuts> > children;
42  };
43 
44 }} // namespace
gtsam::partition::WorkSpace::WorkSpace
WorkSpace(const size_t numNodes)
Definition: PartitionWorkSpace.h:25
gtsam::partition::WorkSpace::dictionary
std::vector< int > dictionary
Definition: PartitionWorkSpace.h:20
gtsam::partition::WorkSpace
Definition: PartitionWorkSpace.h:19
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
gtsam::partition::PartitionTable
std::vector< int > PartitionTable
Definition: PartitionWorkSpace.h:16
gtsam::partition::WorkSpace::partitionTable
PartitionTable partitionTable
Definition: PartitionWorkSpace.h:22
gtsam::partition::Cuts::partitionTable
PartitionTable partitionTable
Definition: PartitionWorkSpace.h:40
gtsam::partition::WorkSpace::dsf
std::shared_ptr< std::vector< size_t > > dsf
Definition: PartitionWorkSpace.h:21
gtsam::partition::WorkSpace::prepareDictionary
void prepareDictionary(const std::vector< size_t > &keys)
Definition: PartitionWorkSpace.h:29
size_t
std::size_t size_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:490
gtsam::partition::Cuts
Definition: PartitionWorkSpace.h:39
gtsam
traits
Definition: SFMdata.h:40
std
Definition: BFloat16.h:88
gtsam::partition::Cuts::children
std::vector< std::shared_ptr< Cuts > > children
Definition: PartitionWorkSpace.h:41


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:34:18