AlgebraTools.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @file AlgebraTools.h
  3. * @brief Algebra Tools
  4. * @author Michael Koch,Erik Rodner
  5. * @date 05/20/2009
  6. */
  7. #ifndef AlgebraToolsINCLUDE
  8. #define AlgebraToolsINCLUDE
  9. #include "core/image/Filter.h"
  10. #include "core/vector/VectorT.h"
  11. #include "core/vector/MatrixT.h"
  12. namespace OBJREC
  13. {
  14. class AlgebraTools
  15. {
  16. public:
  17. //FIXME: find a better place
  18. template<typename T>
  19. static T sign(T n);
  20. static void calculateMean(const NICE::Matrix &data, NICE::Vector &mean);
  21. static void calculateMean(const NICE::Matrix &data,NICE::Vector &mean,NICE::Vector &sigma);
  22. static void orthogonalize(NICE::Matrix &M,bool iterative=true);
  23. static double trace(const NICE::Matrix &M);
  24. static double matrixRowColNorm(const NICE::Matrix &M);
  25. static NICE::Matrix vectorToMatrix(const NICE::Vector &vec);
  26. static NICE::Vector matrixToVector(const NICE::Matrix &mat);
  27. /**
  28. * Converting Vector to diagonal Matrix
  29. * @param diagonalelements diagonal elements
  30. * @return Matrix with diagonal elements
  31. */
  32. static NICE::Matrix diag(const NICE::Vector &diagonalelements);
  33. static double meanOfVector(const NICE::Vector &vec);
  34. static NICE::Vector meanOfMatrix(const NICE::Matrix &M);
  35. };
  36. template<typename T>
  37. T AlgebraTools::sign(T n)
  38. {
  39. if (n < 0) return -1;
  40. if (n > 0) return 1;
  41. return 0;
  42. }
  43. }
  44. #endif