STK++ 0.9.13
STK_KernelMixtureManager.cpp
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::Clustering
27 * created on: 15 mars 2014
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
37
38namespace STK
39{
40
41/* Default constructor, need an instance of a DataHandler. */
43/* destructor */
45
46/* set the dimension of the kernel mixture model */
48{
49 if (!p_mixture) return;
51 // up-cast... (Yes it's bad....;)...)
52 switch (idModel)
53 {
54 // Kernel models
55 case Clust::Kmm_sk_:
56 { static_cast<KmmBridge_sk*>(p_mixture)->setDim(dim);}
57 break;
58 case Clust::Kmm_s_:
59 { static_cast<KmmBridge_s*>(p_mixture)->setDim(dim);}
60 break;
61 default: // idModel is not implemented
62 break;
63 }
64}
65
66/* get the parameters from an IMixture.
67 * @param p_mixture pointer on the mixture
68 * @param param the array to return with the parameters
69 **/
71{
72 if (!p_mixture) return;
74 // up-cast... (Yes it's bad....;)...)
75 switch (idModel)
76 {
77 // Kernel models
78 case Clust::Kmm_sk_:
79 { static_cast<KmmBridge_sk*>(p_mixture)->getParameters(param);}
80 break;
81 case Clust::Kmm_s_:
82 { static_cast<KmmBridge_s*>(p_mixture)->getParameters(param);}
83 break;
84 default: // idModel is not implemented
85 break;
86 }
87}
88/* set the parameters from an IMixture.
89 * @param p_mixture pointer on the mixture
90 * @param param the array with the parameters to set
91 **/
93{
94 if (!p_mixture) return;
96 // up-cast... (Yes it's bad....;)...)
97 switch (idModel)
98 {
99 // Kernel models
100 case Clust::Kmm_sk_:
101 { static_cast<KmmBridge_sk*>(p_mixture)->setParameters(param);}
102 break;
103 case Clust::Kmm_s_:
104 { static_cast<KmmBridge_s*>(p_mixture)->setParameters(param);}
105 break;
106 default: // idModel is not implemented
107 break;
108 }
109}
110
112{
113#ifdef STK_MIXTURE_VERY_VERBOSE
114 stk_cout << _T("KernelMixtureManager::Entering createMixtureImpl(") << modelName
115 << _T(",") << idData << _T(",") << nbCluster << _T(")\n");
116#endif
118 return createMixtureImpl(idModel, idData, nbCluster);
119}
120/* create a concrete mixture and initialize it.
121 * @param idModel,idData Id of the model and the data
122 * @param nbCluster number of cluster of the model
123 **/
125{
126 Kernel::IKernel const* p_kernel = p_handler()->getKernel(idData);
127 switch (idModel)
128 {
129 case Clust::Kmm_sk_:
130 {
131 KmmBridge_sk* p_mixture = new KmmBridge_sk( 0, idData, nbCluster);
132 p_mixture->setKernel(p_kernel);
133 return p_mixture;
134 break;
135 }
136 case Clust::Kmm_s_:
137 {
138 KmmBridge_s* p_mixture = new KmmBridge_s( 0, idData, nbCluster);
139 p_mixture->setKernel(p_kernel);
140 return p_mixture;
141 break;
142 }
143 default:
144 return 0; // 0 if idModel does not exists
145 break;
146 }
147 return 0; // 0 if idModel is not a STK++ model
148}
149
150} // namespace STK
151
In this file we define the KernelMixtureManager class.
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
Clust::Mixture getIdModel(String const &idData) const
Utility function allowing to find the idModel from the idData.
void setParameters(IMixture *p_mixture, ArrayXX const &data) const
set the parameters from an IMixture.
DataHandler const *const p_handler() const
void getParameters(IMixture *p_mixture, ArrayXX &data) const
get the parameters from an IMixture.
Interface base class for all the mixture models that will be processed by the composer.
implementation of the DataHandlerBase class for kernel mixture models.
KernelMixtureManager(KernelHandler const &handler)
Default constructor, need an instance of a KernelHandler.
KmmBridge< Clust::Kmm_s_, CSquareX > KmmBridge_s
void setParametersImpl(IMixture *p_mixture, ArrayXX const &param) const
set the parameters from an IMixture.
void setDim(IMixture *p_mixture, Real const &dim) const
set the dimension of the kernel mixture model
IMixture * createMixtureImpl(String const &modelName, String const &idData, int nbCluster)
create a concrete mixture from its string name and initialize it.
void getParametersImpl(IMixture *p_mixture, ArrayXX &param) const
get the parameters from an IMixture.
KmmBridge< Clust::Kmm_sk_, CSquareX > KmmBridge_sk
Interface class for the kernels classes.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Mixture stringToMixture(String const &type)
Convert a String to a Mixture.
Mixture
list of the mixtures that can be used by the composer
std::basic_string< Char > String
STK fundamental type of a String.
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.