Speed up Key operations by
TBB library
// inference/Factor.h
class Factor{
protected:
/// The keys involved in this factor
KeyVector keys_;
}
// inference/Key.h
typedef FastVector<Key> KeyVector;
// base/types.h
typedef std::uint64_t Key; /// Integer nonlinear key type
typedef std::uint64_t FactorIndex; /// Integer nonlinear factor index type
typedef ptrdiff_t DenseIndex; /// The index type for Eigen objects
// base/FastVector.h
// FastVector is a type alias to a std::vector with a custom memory allocator.
// The particular allocator depends on GTSAM's cmake configuration.
template <typename T>
using FastVector =
std::vector<T, typename internal::FastDefaultVectorAllocator<T>::type>;
// base/FastDefaultAllocator.h
/// Default allocator for vector types (we never use boost pool for vectors)
template<typename T>
struct FastDefaultVectorAllocator
{
#if defined GTSAM_ALLOCATOR_TBB
typedef tbb::tbb_allocator<T> type;
static const bool isBoost = false;
static const bool isTBB = true;
static const bool isSTL = false;
#else
typedef std::allocator<T> type;
static const bool isBoost = false;
static const bool isTBB = false;
static const bool isSTL = true;
#endif
};