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

mse_batch.h
1 /* file: mse_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 mean squared error (MSE) objective function in the batch
19 // processing mode
20 //--
21 */
22 
23 #ifndef __MSE_BATCH_H__
24 #define __MSE_BATCH_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "data_management/data/homogen_numeric_table.h"
29 #include "services/daal_defines.h"
30 #include "sum_of_functions_batch.h"
31 #include "mse_types.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace optimization_solver
38 {
39 namespace mse
40 {
41 
42 namespace interface1
43 {
58 template<typename algorithmFPType, Method method, CpuType cpu>
59 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
60 {
61 public:
67  BatchContainer(daal::services::Environment::env *daalEnv);
69  virtual ~BatchContainer();
75  virtual services::Status compute() DAAL_C11_OVERRIDE;
76 };
77 
94 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
95 class DAAL_EXPORT Batch : public sum_of_functions::interface1::Batch
96 {
97 public:
98  typedef sum_of_functions::interface1::Batch super;
99 
100  typedef algorithms::optimization_solver::mse::interface1::Input InputType;
101  typedef algorithms::optimization_solver::mse::interface1::Parameter ParameterType;
102  typedef typename super::ResultType ResultType;
103 
107  Batch(size_t numberOfTerms) : parameter(numberOfTerms), sum_of_functions::interface1::Batch(numberOfTerms, &input, &parameter)
108  {
109  initialize();
110  }
111 
112  virtual ~Batch() {}
113 
120  Batch(const Batch<algorithmFPType, method> &other) :
121  parameter(other.parameter), sum_of_functions::interface1::Batch(other.parameter.numberOfTerms, &input, &parameter), input(other.input)
122  {
123  initialize();
124  }
125 
130  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
131 
137  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
138  {
139  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
140  }
141 
147  services::Status allocate()
148  {
149  return allocateResult();
150  }
151 
152 protected:
153  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
154  {
155  return new Batch<algorithmFPType, method>(*this);
156  }
157 
158  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
159  {
160  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
161  _res = _result.get();
162  return s;
163  }
164 
165  void initialize()
166  {
167  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
168  _in = &input;
169  _par = &parameter;
170  }
171 
172 public:
173  InputType input;
174  ParameterType parameter;
176 };
178 } // namespace interface1
179 
180 namespace interface2
181 {
196 template<typename algorithmFPType, Method method, CpuType cpu>
197 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
198 {
199 public:
205  BatchContainer(daal::services::Environment::env *daalEnv);
207  virtual ~BatchContainer();
213  virtual services::Status compute() DAAL_C11_OVERRIDE;
214 };
215 
232 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
233 class DAAL_EXPORT Batch : public sum_of_functions::Batch
234 {
235 public:
236  typedef sum_of_functions::Batch super;
237 
238  typedef algorithms::optimization_solver::mse::Input InputType;
239  typedef algorithms::optimization_solver::mse::Parameter ParameterType;
240  typedef typename super::ResultType ResultType;
241 
245  Batch(size_t numberOfTerms);
246 
247  virtual ~Batch() {}
248 
255  Batch(const Batch<algorithmFPType, method> &other);
256 
261  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
262 
267  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
268 
273  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
274 
280  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
281  {
282  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
283  }
284 
290  services::Status allocate()
291  {
292  return allocateResult();
293  }
294 
295 protected:
296  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
297  {
298  return new Batch<algorithmFPType, method>(*this);
299  }
300 
301  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
302  {
303  services::Status s = _result->allocate<algorithmFPType>(&input, _par, (int) method);
304  _res = _result.get();
305  return s;
306  }
307 
308  void initialize()
309  {
310  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
311  _in = &input;
312  }
313 
314 public:
315  InputType input;
317 };
319 } // namespace interface2
320 using interface2::BatchContainer;
321 using interface2::Batch;
322 
323 } // namespace mse
324 } // namespace optimization_solver
325 } // namespace algorithm
326 } // namespace daal
327 #endif
daal::algorithms::optimization_solver::mse::interface1::Batch::parameter
ParameterType parameter
Definition: mse_batch.h:174
daal
Definition: algorithm_base_common.h:31
daal::algorithms::optimization_solver::mse::interface1::Batch
Computes the Mean squared error objective function in the batch processing mode.
Definition: mse_batch.h:95
daal::algorithms::optimization_solver::mse::interface2::Batch
Computes the Mean squared error objective function in the batch processing mode.
Definition: mse_batch.h:233
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::optimization_solver::mse::interface1::Batch::allocate
services::Status allocate()
Definition: mse_batch.h:147
daal::algorithms::optimization_solver::mse::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: mse_batch.h:130
daal::algorithms::optimization_solver::mse::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: mse_batch.h:137
daal::algorithms::optimization_solver::mse::interface2::Batch::input
InputType input
Definition: mse_batch.h:315
daal::algorithms::optimization_solver::mse::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: mse_batch.h:120
daal_defines.h
daal::algorithms::optimization_solver::sum_of_functions::interface1::Batch
Interface for computing the Sum of functions in the batch processing mode.
Definition: sum_of_functions_batch.h:61
daal::batch
Definition: daal_defines.h:110
daal::algorithms::optimization_solver::mse::interface2::BatchContainer
Provides methods to run implementations of the mean squared error objective function. This class is associated with the Batch class and supports the method of computing the Mean squared error objective function in the batch processing mode.
Definition: mse_batch.h:197
daal::algorithms::optimization_solver::mse::interface2::Batch::allocate
services::Status allocate()
Definition: mse_batch.h:290
daal::algorithms::optimization_solver::mse::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: mse_batch.h:273
daal::algorithms::optimization_solver::mse::interface2::Batch::parameter
ParameterType & parameter()
Definition: mse_batch.h:261
daal::algorithms::optimization_solver::mse::interface1::Input
Input objects for the Mean squared error objective function
Definition: mse_types.h:139
daal::algorithms::optimization_solver::mse::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: mse_batch.h:280
daal::algorithms::optimization_solver::mse::interface1::Batch::input
InputType input
Definition: mse_batch.h:173
daal::algorithms::optimization_solver::mse::interface1::Parameter
Parameter for Mean squared error objective function
Definition: mse_types.h:105
daal::algorithms::optimization_solver::mse::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: mse_batch.h:267
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::optimization_solver::mse::interface1::BatchContainer
Provides methods to run implementations of the mean squared error objective function. This class is associated with the Batch class and supports the method of computing the Mean squared error objective function in the batch processing mode.
Definition: mse_batch.h:59
daal::algorithms::optimization_solver::mse::interface1::Batch::Batch
Batch(size_t numberOfTerms)
Definition: mse_batch.h:107

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