AlgebraTools.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 <vislearning/nice_nonvis.h>
  10. namespace OBJREC
  11. {
  12. class AlgebraTools
  13. {
  14. public:
  15. //FIXME: find a better place
  16. template<typename T>
  17. static T sign(T n);
  18. static void calculateMean(const NICE::Matrix &data, NICE::Vector &mean);
  19. static void calculateMean(const NICE::Matrix &data,NICE::Vector &mean,NICE::Vector &sigma);
  20. static void orthogonalize(NICE::Matrix &M,bool iterative=true);
  21. static double trace(const NICE::Matrix &M);
  22. static double matrixRowColNorm(const NICE::Matrix &M);
  23. static NICE::Matrix vectorToMatrix(const NICE::Vector &vec);
  24. static NICE::Vector matrixToVector(const NICE::Matrix &mat);
  25. /**
  26. * Converting Vector to diagonal Matrix
  27. * @param diagonalelements diagonal elements
  28. * @return Matrix with diagonal elements
  29. */
  30. static NICE::Matrix diag(const NICE::Vector &diagonalelements);
  31. static double meanOfVector(const NICE::Vector &vec);
  32. static NICE::Vector meanOfMatrix(const NICE::Matrix &M);
  33. };
  34. template<typename T>
  35. T AlgebraTools::sign(T n)
  36. {
  37. if (n < 0) return -1;
  38. if (n > 0) return 1;
  39. return 0;
  40. }
  41. }
  42. #endif