summaryrefslogtreecommitdiffstats
path: root/src/armadillo/include/armadillo_bits/gmm_misc_bones.hpp
blob: 44507d4183485c731f248e1ebfd3656f8fc4e1e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// SPDX-License-Identifier: Apache-2.0
// 
// Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
// Copyright 2008-2016 National ICT Australia (NICTA)
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------


//! \addtogroup gmm_misc
//! @{


struct gmm_dist_mode { const uword id;  inline constexpr explicit gmm_dist_mode(const uword in_id) : id(in_id) {} };

inline bool operator==(const gmm_dist_mode& a, const gmm_dist_mode& b) { return (a.id == b.id); }
inline bool operator!=(const gmm_dist_mode& a, const gmm_dist_mode& b) { return (a.id != b.id); }

struct gmm_dist_eucl : public gmm_dist_mode { inline constexpr gmm_dist_eucl() : gmm_dist_mode(1) {} };
struct gmm_dist_maha : public gmm_dist_mode { inline constexpr gmm_dist_maha() : gmm_dist_mode(2) {} };
struct gmm_dist_prob : public gmm_dist_mode { inline constexpr gmm_dist_prob() : gmm_dist_mode(3) {} };

static constexpr gmm_dist_eucl eucl_dist;
static constexpr gmm_dist_maha maha_dist;
static constexpr gmm_dist_prob prob_dist;



struct gmm_seed_mode { const uword id; inline constexpr explicit gmm_seed_mode(const uword in_id) : id(in_id) {} };

inline bool operator==(const gmm_seed_mode& a, const gmm_seed_mode& b) { return (a.id == b.id); }
inline bool operator!=(const gmm_seed_mode& a, const gmm_seed_mode& b) { return (a.id != b.id); }

struct gmm_seed_keep_existing : public gmm_seed_mode { inline constexpr gmm_seed_keep_existing() : gmm_seed_mode(1) {} };
struct gmm_seed_static_subset : public gmm_seed_mode { inline constexpr gmm_seed_static_subset() : gmm_seed_mode(2) {} };
struct gmm_seed_static_spread : public gmm_seed_mode { inline constexpr gmm_seed_static_spread() : gmm_seed_mode(3) {} };
struct gmm_seed_random_subset : public gmm_seed_mode { inline constexpr gmm_seed_random_subset() : gmm_seed_mode(4) {} };
struct gmm_seed_random_spread : public gmm_seed_mode { inline constexpr gmm_seed_random_spread() : gmm_seed_mode(5) {} };

static constexpr gmm_seed_keep_existing keep_existing;
static constexpr gmm_seed_static_subset static_subset;
static constexpr gmm_seed_static_spread static_spread;
static constexpr gmm_seed_random_subset random_subset;
static constexpr gmm_seed_random_spread random_spread;


namespace gmm_priv
{


template<typename eT> class gmm_diag;
template<typename eT> class gmm_full;


struct gmm_empty_arg {};


// running_mean_scalar

template<typename eT>
class running_mean_scalar
  {
  public:
  
  inline running_mean_scalar();
  inline running_mean_scalar(const running_mean_scalar& in_rms);
  
  inline const running_mean_scalar& operator=(const running_mean_scalar& in_rms);
  
  arma_hot inline void operator() (const eT X);
  
  inline void  reset();
  
  inline uword count() const;
  inline eT    mean()  const;
  
  
  private:
  
  arma_aligned uword counter;
  arma_aligned eT    r_mean;
  };



// distance

template<typename eT, uword dist_id>
struct distance {};


template<typename eT>
struct distance<eT, uword(1)>
  {
  arma_inline static eT eval(const uword N, const eT* A, const eT* B, const eT*);
  };



template<typename eT>
struct distance<eT, uword(2)>
  {
  arma_inline static eT eval(const uword N, const eT* A, const eT* B, const eT* C);
  };


}


//! @}