gmm_misc_bones.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. //! \addtogroup gmm_misc
  16. //! @{
  17. struct gmm_dist_mode { const uword id; inline explicit gmm_dist_mode(const uword in_id) : id(in_id) {} };
  18. inline bool operator==(const gmm_dist_mode& a, const gmm_dist_mode& b) { return (a.id == b.id); }
  19. inline bool operator!=(const gmm_dist_mode& a, const gmm_dist_mode& b) { return (a.id != b.id); }
  20. struct gmm_dist_eucl : public gmm_dist_mode { inline gmm_dist_eucl() : gmm_dist_mode(1) {} };
  21. struct gmm_dist_maha : public gmm_dist_mode { inline gmm_dist_maha() : gmm_dist_mode(2) {} };
  22. struct gmm_dist_prob : public gmm_dist_mode { inline gmm_dist_prob() : gmm_dist_mode(3) {} };
  23. static const gmm_dist_eucl eucl_dist;
  24. static const gmm_dist_maha maha_dist;
  25. static const gmm_dist_prob prob_dist;
  26. struct gmm_seed_mode { const uword id; inline explicit gmm_seed_mode(const uword in_id) : id(in_id) {} };
  27. inline bool operator==(const gmm_seed_mode& a, const gmm_seed_mode& b) { return (a.id == b.id); }
  28. inline bool operator!=(const gmm_seed_mode& a, const gmm_seed_mode& b) { return (a.id != b.id); }
  29. struct gmm_seed_keep_existing : public gmm_seed_mode { inline gmm_seed_keep_existing() : gmm_seed_mode(1) {} };
  30. struct gmm_seed_static_subset : public gmm_seed_mode { inline gmm_seed_static_subset() : gmm_seed_mode(2) {} };
  31. struct gmm_seed_static_spread : public gmm_seed_mode { inline gmm_seed_static_spread() : gmm_seed_mode(3) {} };
  32. struct gmm_seed_random_subset : public gmm_seed_mode { inline gmm_seed_random_subset() : gmm_seed_mode(4) {} };
  33. struct gmm_seed_random_spread : public gmm_seed_mode { inline gmm_seed_random_spread() : gmm_seed_mode(5) {} };
  34. static const gmm_seed_keep_existing keep_existing;
  35. static const gmm_seed_static_subset static_subset;
  36. static const gmm_seed_static_spread static_spread;
  37. static const gmm_seed_random_subset random_subset;
  38. static const gmm_seed_random_spread random_spread;
  39. namespace gmm_priv
  40. {
  41. template<typename eT> class gmm_diag;
  42. template<typename eT> class gmm_full;
  43. struct gmm_empty_arg {};
  44. // running_mean_scalar
  45. template<typename eT>
  46. class running_mean_scalar
  47. {
  48. public:
  49. inline running_mean_scalar();
  50. inline running_mean_scalar(const running_mean_scalar& in_rms);
  51. inline const running_mean_scalar& operator=(const running_mean_scalar& in_rms);
  52. arma_hot inline void operator() (const eT X);
  53. inline void reset();
  54. inline uword count() const;
  55. inline eT mean() const;
  56. private:
  57. arma_aligned uword counter;
  58. arma_aligned eT r_mean;
  59. };
  60. // distance
  61. template<typename eT, uword dist_id>
  62. struct distance {};
  63. template<typename eT>
  64. struct distance<eT, uword(1)>
  65. {
  66. arma_inline arma_hot static eT eval(const uword N, const eT* A, const eT* B, const eT*);
  67. };
  68. template<typename eT>
  69. struct distance<eT, uword(2)>
  70. {
  71. arma_inline arma_hot static eT eval(const uword N, const eT* A, const eT* B, const eT* C);
  72. };
  73. }
  74. //! @}