STK++ 0.9.13
STK_GammaMixtureManager.h File Reference

In this file we define the GammaMixtureManager class. More...

Include dependency graph for STK_GammaMixtureManager.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  STK::hidden::MixtureManagerTraits< GammaMixtureManager< DataHandler_ > >
 Specialization for GammaMixtureManager. More...
 
class  STK::GammaMixtureManager< DataHandler >
 A mixture manager is a factory class for injection dependency in the STK++ derived class of the MixtureComposer class. More...
 

Namespaces

namespace  STK
 The namespace STK is the main domain space of the Statistical ToolKit project.
 
namespace  STK::hidden
 The hidden namespace enclose the classes and methods which are used internally by the STK++ classes.
 

Macros

#define STK_CREATE_MIXTURE(Data, Bridge)
 

Detailed Description

In this file we define the GammaMixtureManager class.

Definition in file STK_GammaMixtureManager.h.

Macro Definition Documentation

◆ STK_CREATE_MIXTURE

#define STK_CREATE_MIXTURE (   Data,
  Bridge 
)
Value:
Data* p_data = new Data(idData); \
registerDataBridge(p_data); \
p_handler()->getData(idData, p_data->dataij() ); \
return new Bridge( &(p_data->dataij()), idData, nbCluster);

Definition at line 44 of file STK_GammaMixtureManager.h.

50{
51
52// forward declaration
53template<class DataHandler> class GammaMixtureManager;
54
55namespace hidden
56{
59template <class DataHandler_>
60struct MixtureManagerTraits< GammaMixtureManager<DataHandler_> >
61{
63 typedef DataHandler_ DataHandler;
65 typedef Real Type;
67 typedef std::vector< std::pair<int,int> > MissingIndexes;
69 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
70
71 // All data handlers will store and return a specific container for
72 // the data they handle. The DataHandlerTraits class allow us to know the
73 // type of these containers when data is of type Type.
76 typedef typename DataHandlerTraits<DataHandler, Type>::Data Data;
77 // Classes wrapping the Real and Integer containers
79 typedef DataBridge<Data> DataBridgeType;
80};
81
82}
92template<class DataHandler>
93class GammaMixtureManager: public IMixtureManager<GammaMixtureManager<DataHandler> >
94{
95 public:
96 typedef typename hidden::MixtureManagerTraits< GammaMixtureManager >::Type Type;
97 typedef typename hidden::MixtureManagerTraits< GammaMixtureManager >::MissingIndexes MissingIndexes;
98 typedef typename hidden::MixtureManagerTraits< GammaMixtureManager >::MissingValues MissingValues;
99 typedef typename hidden::MixtureManagerTraits< GammaMixtureManager >::Data Data;
100 typedef typename hidden::MixtureManagerTraits< GammaMixtureManager >::DataBridgeType DataBridgeType;
101
102 typedef IMixtureManager<GammaMixtureManager> Base;
103 using Base::registerDataBridge;
104 using Base::getDataBridge;
105 using Base::getIdModel;
106 using Base::p_handler;
107
108 // All Gamma bridges
109 typedef GammaBridge<Clust::Gamma_ajk_bjk_, Data> MixtureBridge_ajk_bjk;
110 typedef GammaBridge<Clust::Gamma_ajk_bk_, Data> MixtureBridge_ajk_bk;
111 typedef GammaBridge<Clust::Gamma_ajk_bj_, Data> MixtureBridge_ajk_bj;
112 typedef GammaBridge<Clust::Gamma_ajk_b_, Data> MixtureBridge_ajk_b;
113 typedef GammaBridge<Clust::Gamma_ak_bjk_, Data> MixtureBridge_ak_bjk;
114 typedef GammaBridge<Clust::Gamma_ak_bk_, Data> MixtureBridge_ak_bk;
115 typedef GammaBridge<Clust::Gamma_ak_bj_, Data> MixtureBridge_ak_bj;
116 typedef GammaBridge<Clust::Gamma_ak_b_, Data> MixtureBridge_ak_b;
117 typedef GammaBridge<Clust::Gamma_aj_bjk_, Data> MixtureBridge_aj_bjk;
118 typedef GammaBridge<Clust::Gamma_aj_bk_, Data> MixtureBridge_aj_bk;
119 typedef GammaBridge<Clust::Gamma_a_bjk_, Data> MixtureBridge_a_bjk;
120 typedef GammaBridge<Clust::Gamma_a_bk_, Data> MixtureBridge_a_bk;
121
123 GammaMixtureManager(DataHandler const& handler): Base(&handler) {}
125 ~GammaMixtureManager() {}
126
131 void getMissingValuesImpl(IMixture* p_mixture, MissingValues& missing) const
132 {
133 Clust::Mixture idModel = getIdModel(p_mixture->idData());
134 if (idModel == Clust::unknown_mixture_) return;
135 // up-cast... (Yes it's bad....;)...)
136 switch (idModel)
137 {
138 case Clust::Gamma_ajk_bjk_:
139 { static_cast<MixtureBridge_ajk_bjk*>(p_mixture)->getMissingValues(missing);}
140 break;
141 case Clust::Gamma_ajk_bk_:
142 { static_cast<MixtureBridge_ajk_bk*>(p_mixture)->getMissingValues(missing);}
143 break;
144 case Clust::Gamma_ajk_bj_:
145 { static_cast<MixtureBridge_ajk_bj*>(p_mixture)->getMissingValues(missing);}
146 break;
147 case Clust::Gamma_ajk_b_:
148 { static_cast<MixtureBridge_ajk_b*>(p_mixture)->getMissingValues(missing);}
149 break;
150 case Clust::Gamma_ak_bjk_:
151 { static_cast<MixtureBridge_ak_bjk*>(p_mixture)->getMissingValues(missing);}
152 break;
153 case Clust::Gamma_ak_bk_:
154 { static_cast<MixtureBridge_ak_bk*>(p_mixture)->getMissingValues(missing);}
155 break;
156 case Clust::Gamma_ak_bj_:
157 { static_cast<MixtureBridge_ak_bj*>(p_mixture)->getMissingValues(missing);}
158 break;
159 case Clust::Gamma_ak_b_:
160 { static_cast<MixtureBridge_ak_b*>(p_mixture)->getMissingValues(missing);}
161 break;
162 case Clust::Gamma_aj_bjk_:
163 { static_cast<MixtureBridge_aj_bjk*>(p_mixture)->getMissingValues(missing);}
164 break;
165 case Clust::Gamma_aj_bk_:
166 { static_cast<MixtureBridge_aj_bk*>(p_mixture)->getMissingValues(missing);}
167 break;
168 case Clust::Gamma_a_bjk_:
169 { static_cast<MixtureBridge_a_bjk*>(p_mixture)->getMissingValues(missing);}
170 break;
171 case Clust::Gamma_a_bk_:
172 { static_cast<MixtureBridge_a_bk*>(p_mixture)->getMissingValues(missing);}
173 break;
174 default: // idModel is not implemented
175 break;
176 }
177 }
182 void getParametersImpl(IMixture* p_mixture, ArrayXX& param) const
183 {
184 Clust::Mixture idModel = getIdModel(p_mixture->idData());
185 if (idModel == Clust::unknown_mixture_) return;
186 // up-cast... (Yes it's bad....;)...)
187 switch (idModel)
188 {
189 case Clust::Gamma_ajk_bjk_:
190 { static_cast<MixtureBridge_ajk_bjk*>(p_mixture)->getParameters(param);}
191 break;
192 case Clust::Gamma_ajk_bk_:
193 { static_cast<MixtureBridge_ajk_bk*>(p_mixture)->getParameters(param);}
194 break;
195 case Clust::Gamma_ajk_bj_:
196 { static_cast<MixtureBridge_ajk_bj*>(p_mixture)->getParameters(param);}
197 break;
198 case Clust::Gamma_ajk_b_:
199 { static_cast<MixtureBridge_ajk_b*>(p_mixture)->getParameters(param);}
200 break;
201 case Clust::Gamma_ak_bjk_:
202 { static_cast<MixtureBridge_ak_bjk*>(p_mixture)->getParameters(param);}
203 break;
204 case Clust::Gamma_ak_bk_:
205 { static_cast<MixtureBridge_ak_bk*>(p_mixture)->getParameters(param);}
206 break;
207 case Clust::Gamma_ak_bj_:
208 { static_cast<MixtureBridge_ak_bj*>(p_mixture)->getParameters(param);}
209 break;
210 case Clust::Gamma_ak_b_:
211 { static_cast<MixtureBridge_ak_b*>(p_mixture)->getParameters(param);}
212 break;
213 case Clust::Gamma_aj_bjk_:
214 { static_cast<MixtureBridge_aj_bjk*>(p_mixture)->getParameters(param);}
215 break;
216 case Clust::Gamma_aj_bk_:
217 { static_cast<MixtureBridge_aj_bk*>(p_mixture)->getParameters(param);}
218 break;
219 case Clust::Gamma_a_bjk_:
220 { static_cast<MixtureBridge_a_bjk*>(p_mixture)->getParameters(param);}
221 break;
222 case Clust::Gamma_a_bk_:
223 { static_cast<MixtureBridge_a_bk*>(p_mixture)->getParameters(param);}
224 break;
225 default: // idModel is not implemented
226 break;
227 }
228 }
233 void setParametersImpl(IMixture* p_mixture, ArrayXX const& param) const
234 {
235 Clust::Mixture idModel = getIdModel(p_mixture->idData());
236 if (idModel == Clust::unknown_mixture_) return;
237 // up-cast... (Yes it's bad....;)...)
238 switch (idModel)
239 {
240 case Clust::Gamma_ajk_bjk_:
241 { static_cast<MixtureBridge_ajk_bjk*>(p_mixture)->setParameters(param);}
242 break;
243 case Clust::Gamma_ajk_bk_:
244 { static_cast<MixtureBridge_ajk_bk*>(p_mixture)->setParameters(param);}
245 break;
246 case Clust::Gamma_ajk_bj_:
247 { static_cast<MixtureBridge_ajk_bj*>(p_mixture)->setParameters(param);}
248 break;
249 case Clust::Gamma_ajk_b_:
250 { static_cast<MixtureBridge_ajk_b*>(p_mixture)->setParameters(param);}
251 break;
252 case Clust::Gamma_ak_bjk_:
253 { static_cast<MixtureBridge_ak_bjk*>(p_mixture)->setParameters(param);}
254 break;
255 case Clust::Gamma_ak_bk_:
256 { static_cast<MixtureBridge_ak_bk*>(p_mixture)->setParameters(param);}
257 break;
258 case Clust::Gamma_ak_bj_:
259 { static_cast<MixtureBridge_ak_bj*>(p_mixture)->setParameters(param);}
260 break;
261 case Clust::Gamma_ak_b_:
262 { static_cast<MixtureBridge_ak_b*>(p_mixture)->setParameters(param);}
263 break;
264 case Clust::Gamma_aj_bjk_:
265 { static_cast<MixtureBridge_aj_bjk*>(p_mixture)->setParameters(param);}
266 break;
267 case Clust::Gamma_aj_bk_:
268 { static_cast<MixtureBridge_aj_bk*>(p_mixture)->setParameters(param);}
269 break;
270 case Clust::Gamma_a_bjk_:
271 { static_cast<MixtureBridge_a_bjk*>(p_mixture)->setParameters(param);}
272 break;
273 case Clust::Gamma_a_bk_:
274 { static_cast<MixtureBridge_a_bk*>(p_mixture)->setParameters(param);}
275 break;
276 default: // idModel is not implemented
277 break;
278 }
279 }
280
286 IMixture* createMixtureImpl(String const& modelName, String const& idData, int nbCluster)
287 {
288 Clust::Mixture idModel = Clust::stringToMixture(modelName);
289 return createMixtureImpl(idModel, idData, nbCluster);
290 }
291
292 private:
298 IMixture* createMixtureImpl(Clust::Mixture idModel, String const& idData, int nbCluster)
299 {
300 switch (idModel)
301 {
302 // gamma models
303 case Clust::Gamma_ajk_bjk_:
304 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_ajk_bjk)}
305 break;
306 case Clust::Gamma_ajk_bk_:
307 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_ajk_bk)}
308 break;
309 case Clust::Gamma_ajk_bj_:
310 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_ajk_bj)}
311 break;
312 case Clust::Gamma_ajk_b_:
313 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_ajk_b)}
314 break;
315 case Clust::Gamma_ak_bjk_:
316 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_ak_bjk)}
317 break;
318 case Clust::Gamma_ak_bk_:
319 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_ak_bk)}
320 break;
321 case Clust::Gamma_ak_bj_:
322 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_ak_bj)}
323 break;
324 case Clust::Gamma_ak_b_:
325 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_ak_b)}
326 break;
327 case Clust::Gamma_aj_bjk_:
328 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_aj_bjk)}
329 break;
330 case Clust::Gamma_aj_bk_:
331 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_aj_bk)}
332 case Clust::Gamma_a_bjk_:
333 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_a_bjk)}
334 break;
335 case Clust::Gamma_a_bk_:
336 { STK_CREATE_MIXTURE(DataBridgeType, MixtureBridge_a_bk)}
337 default:
338 return 0; // 0 if idModel is not implemented
339 break;
340 }
341 return 0; // 0 if idModel is not a STK++ model
342 }
343};
344
345} // namespace STK
346
347#undef STK_CREATE_MIXTURE
348
349#endif /* STK_GAMMAMIXTUREMANAGER_H */
#define STK_CREATE_MIXTURE(Data, Bridge)
double Real
STK fundamental type of Real values.