CholeskyRobust.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * @file CholeskyRobust.h
  3. * @author Erik Rodner
  4. * @date 01/06/2010
  5. */
  6. #ifndef _NICE_NICE_CHOLESKYROBUSTINCLUDE
  7. #define _NICE_NICE_CHOLESKYROBUSTINCLUDE
  8. #include <limits>
  9. #include "core/vector/MatrixT.h"
  10. namespace NICE
  11. {
  12. /** @class CholeskyRobust
  13. * robust cholesky decomposition by adding some noise
  14. *
  15. * @author Erik Rodner
  16. */
  17. class CholeskyRobust
  18. {
  19. protected:
  20. /** output some messages */
  21. const bool m_verbose;
  22. /** noise added to the main diagonal */
  23. const double m_noise;
  24. /** should cuda be used */
  25. const bool m_useCuda;
  26. /** store the logarithm of the determinant */
  27. double m_logDetMatrix;
  28. public:
  29. /**
  30. * @brief constructor
  31. *
  32. * @param verbose whether to display a bunch of messages
  33. * @param noise constant added to the main diagonal
  34. * @param useCuda whether to use cuda with the cholesky-gpu sub-library
  35. */
  36. CholeskyRobust (bool verbose = true, double noise = 1e-8, bool useCuda = true);
  37. /**
  38. * @brief copy constructor
  39. *
  40. * @param src objrec to copy from (settings)
  41. */
  42. CholeskyRobust (const CholeskyRobust & src);
  43. /**
  44. * @brief destructor, currently empty
  45. */
  46. virtual ~CholeskyRobust ();
  47. /**
  48. * @brief Compute the Cholesky decomposition with additional regularization given to the
  49. * constructor of the object
  50. *
  51. * @param A input matrix
  52. * @param cholA Cholesky factor
  53. *
  54. * @return noise added to the diagonal of the matrix
  55. */
  56. virtual double robustChol (const NICE::Matrix & A, NICE::Matrix & cholA);
  57. /**
  58. * @brief Invert a positive definite matrix using its Cholesky decomposition and
  59. * additional regularization. The function uses robustChol and is available for
  60. * every child class.
  61. *
  62. * @param A input matrix
  63. * @param invA inverse of the matrix (take care of the regularization)
  64. *
  65. * @return noise added to the diagonal of the matrix
  66. */
  67. virtual double robustCholInv (const NICE::Matrix & A, NICE::Matrix & invA);
  68. /**
  69. * @brief get the last log determinant computed
  70. *
  71. * @return log determinant of the last calculation
  72. */
  73. double getLastLogDet () const
  74. {
  75. return m_logDetMatrix;
  76. };
  77. /**
  78. * @brief clone the object
  79. */
  80. virtual CholeskyRobust *clone (void) const;
  81. };
  82. }
  83. #endif