DummyFactor.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @file DummyFactor.h
  3. * @brief Just to help in timing overhead
  4. * @author Frank Dellaert
  5. */
  6. #pragma once
  7. #include <gtsam/slam/RegularImplicitSchurFactor.h>
  8. namespace gtsam {
  9. /**
  10. * DummyFactor
  11. */
  12. template<typename CAMERA> //
  13. class DummyFactor: public RegularImplicitSchurFactor<CAMERA> {
  14. public:
  15. typedef Eigen::Matrix<double, 2, CAMERA::dimension> Matrix2D;
  16. typedef std::pair<Key, Matrix2D> KeyMatrix2D;
  17. DummyFactor() {
  18. }
  19. DummyFactor(const std::vector<KeyMatrix2D>& Fblocks, const Matrix& E,
  20. const Matrix3& P, const Vector& b) :
  21. RegularImplicitSchurFactor<CAMERA>(Fblocks, E, P, b) {
  22. }
  23. virtual ~DummyFactor() {
  24. }
  25. public:
  26. /**
  27. * @brief Dummy version to measure overhead of key access
  28. */
  29. void multiplyHessian(double alpha, const VectorValues& x,
  30. VectorValues& y) const {
  31. for(const KeyMatrix2D& Fi: this->Fblocks_) {
  32. static const Vector empty;
  33. Key key = Fi.first;
  34. std::pair<VectorValues::iterator, bool> it = y.tryInsert(key, empty);
  35. Vector& yi = it.first->second;
  36. yi = x.at(key);
  37. }
  38. }
  39. };
  40. // DummyFactor
  41. }