C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 4

kmeans_init_batch.h
1 /* file: kmeans_init_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for initializing the K-Means algorithm
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __KMEANS_INIT_BATCH_H__
24 #define __KMEANS_INIT_BATCH_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "algorithms/kmeans/kmeans_init_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace kmeans
36 {
37 namespace init
38 {
39 
40 namespace interface2
41 {
56 template<typename algorithmFPType, Method method, CpuType cpu>
57 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
58 {
59 public:
65  BatchContainer(daal::services::Environment::env *daalEnv);
67  virtual ~BatchContainer();
71  virtual services::Status compute() DAAL_C11_OVERRIDE;
72 };
73 
74 
79 class DAAL_EXPORT BatchBase : public daal::algorithms::Analysis<batch>
80 {
81 public:
82  typedef algorithms::kmeans::init::Input InputType;
83  typedef algorithms::kmeans::init::Parameter ParameterType;
84  typedef algorithms::kmeans::init::Result ResultType;
85 
87  virtual ~BatchBase() { }
88 
89 protected:
90  BatchBase() { }
91 
92  explicit BatchBase(ParameterType *parameter)
93  {
94  _par = parameter;
95  }
96 };
97 
111 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
112 class DAAL_EXPORT Batch : public BatchBase
113 {
114 public:
119  Batch(size_t nClusters);
120 
127  Batch(const Batch<algorithmFPType, method> &other);
128 
129 
131  ~Batch()
132  {
133  delete _par;
134  }
135 
140  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
141 
146  ResultPtr getResult()
147  {
148  return _result;
149  }
150 
155  services::Status setResult(const ResultPtr& result)
156  {
157  DAAL_CHECK(result, services::ErrorNullResult)
158  _result = result;
159  _res = _result.get();
160  return services::Status();
161  }
162 
168  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
169  {
170  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
171  }
172 
173 protected:
174  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
175  {
176  return new Batch<algorithmFPType, method>(*this);
177  }
178 
179  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
180  {
181  _result.reset(new ResultType());
182  size_t nFeatures = input.getNumberOfFeatures();
183  services::Status s = _result->allocate<algorithmFPType>(_in, _par, (int) method);
184  _res = _result.get();
185  return s;
186  }
187 
188  void initialize()
189  {
190  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
191  _in = &input;
192  }
193 
194 public:
195  ParameterType &parameter;
196  InputType input;
198 private:
199  ResultPtr _result;
200 };
202 } // namespace interface2
203 using interface2::BatchContainer;
204 using interface2::BatchBase;
205 using interface2::Batch;
206 } // namespace daal::algorithms::kmeans::init
207 } // namespace daal::algorithms::kmeans
208 } // namespace daal::algorithms
209 } // namespace daal
210 #endif
daal::algorithms::kmeans::init::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: kmeans_init_batch.h:140
daal::algorithms::kmeans::init::interface2::Batch::input
InputType input
Definition: kmeans_init_batch.h:196
daal
Definition: algorithm_base_common.h:31
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::kmeans::init::interface2::Batch
Computes initial clusters for the K-Means algorithm in the batch processing mode. ...
Definition: kmeans_init_batch.h:112
daal::algorithms::kmeans::init::interface2::BatchBase::~BatchBase
virtual ~BatchBase()
Definition: kmeans_init_batch.h:87
daal::algorithms::kmeans::init::interface2::Batch::getResult
ResultPtr getResult()
Definition: kmeans_init_batch.h:146
daal_defines.h
daal::batch
Definition: daal_defines.h:110
daal::algorithms::kmeans::init::interface2::Batch::parameter
ParameterType & parameter
Definition: kmeans_init_batch.h:195
daal::algorithms::kmeans::init::interface2::BatchBase
Base class representing an K-Means algorithm initialization in the batch processing mode...
Definition: kmeans_init_batch.h:79
daal::algorithms::kmeans::init::interface2::BatchContainer
Provides methods to run implementations of initialization of the K-Means algorithm. This class is associated with the daal::algorithms::kmeans::init::Batch class and supports the method of computing initial clusters for the K-Means algorithm in the batch processing mode.
Definition: kmeans_init_batch.h:57
daal::algorithms::kmeans::init::interface2::Batch::~Batch
~Batch()
Definition: kmeans_init_batch.h:131
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::kmeans::init::interface2::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: kmeans_init_batch.h:155
daal::algorithms::kmeans::init::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: kmeans_init_batch.h:168
daal::services::ErrorNullResult
Definition: error_indexes.h:96

For more complete information about compiler optimizations, see our Optimization Notice.