C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

mse_batch.h
1 /* file: mse_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Implementation of the mean squared error (MSE) objective function in the batch
21 // processing mode
22 //--
23 */
24 
25 #ifndef __MSE_BATCH_H__
26 #define __MSE_BATCH_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "data_management/data/homogen_numeric_table.h"
31 #include "services/daal_defines.h"
32 #include "sum_of_functions_batch.h"
33 #include "mse_types.h"
34 
35 namespace daal
36 {
37 namespace algorithms
38 {
39 namespace optimization_solver
40 {
41 namespace mse
42 {
43 
44 namespace interface1
45 {
60 template<typename algorithmFPType, Method method, CpuType cpu>
61 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
62 {
63 public:
69  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
71  DAAL_DEPRECATED_VIRTUAL virtual ~BatchContainer();
77  DAAL_DEPRECATED_VIRTUAL virtual services::Status compute() DAAL_C11_OVERRIDE;
78 };
79 
96 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
97 class DAAL_EXPORT Batch : public sum_of_functions::interface1::Batch
98 {
99 public:
100  typedef sum_of_functions::interface1::Batch super;
101 
102  typedef algorithms::optimization_solver::mse::interface1::Input InputType;
103  typedef algorithms::optimization_solver::mse::interface1::Parameter ParameterType;
104  typedef typename super::ResultType ResultType;
105 
109  DAAL_DEPRECATED Batch(size_t numberOfTerms) : parameter(numberOfTerms), sum_of_functions::interface1::Batch(numberOfTerms, &input, &parameter)
110  {
111  initialize();
112  }
113 
114  DAAL_DEPRECATED_VIRTUAL virtual ~Batch() {}
115 
122  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) :
123  parameter(other.parameter), sum_of_functions::interface1::Batch(other.parameter.numberOfTerms, &input, &parameter), input(other.input)
124  {
125  initialize();
126  }
127 
132  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
133 
139  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
140  {
141  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
142  }
143 
149  DAAL_DEPRECATED services::Status allocate()
150  {
151  return allocateResult();
152  }
153 
154 protected:
155  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
156  {
157  return new Batch<algorithmFPType, method>(*this);
158  }
159 
160  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
161  {
162  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
163  _res = _result.get();
164  return s;
165  }
166 
167  void initialize()
168  {
169  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
170  _in = &input;
171  _par = &parameter;
172  }
173 
174 public:
175  InputType input;
176  ParameterType parameter;
178 };
180 } // namespace interface1
181 
182 namespace interface2
183 {
198 template<typename algorithmFPType, Method method, CpuType cpu>
199 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
200 {
201 public:
207  BatchContainer(daal::services::Environment::env *daalEnv);
209  virtual ~BatchContainer();
215  virtual services::Status compute() DAAL_C11_OVERRIDE;
216 };
217 
234 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
235 class DAAL_EXPORT Batch : public sum_of_functions::Batch
236 {
237 public:
238  typedef sum_of_functions::Batch super;
239 
240  typedef algorithms::optimization_solver::mse::Input InputType;
241  typedef algorithms::optimization_solver::mse::Parameter ParameterType;
242  typedef typename super::ResultType ResultType;
243 
247  Batch(size_t numberOfTerms);
248 
249  virtual ~Batch() {}
250 
257  Batch(const Batch<algorithmFPType, method> &other);
258 
263  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
264 
269  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
270 
275  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
276 
282  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
283  {
284  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
285  }
286 
292  services::Status allocate()
293  {
294  return allocateResult();
295  }
296 
297 protected:
298  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
299  {
300  return new Batch<algorithmFPType, method>(*this);
301  }
302 
303  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
304  {
305  services::Status s = _result->allocate<algorithmFPType>(&input, _par, (int) method);
306  _res = _result.get();
307  return s;
308  }
309 
310  void initialize()
311  {
312  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
313  _in = &input;
314  }
315 
316 public:
317  InputType input;
319 };
321 } // namespace interface2
322 using interface2::BatchContainer;
323 using interface2::Batch;
324 
325 } // namespace mse
326 } // namespace optimization_solver
327 } // namespace algorithm
328 } // namespace daal
329 #endif
daal::algorithms::optimization_solver::mse::interface1::BatchContainer::compute
virtual DAAL_DEPRECATED_VIRTUAL services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::optimization_solver::mse::interface1::BatchContainer::~BatchContainer
virtual DAAL_DEPRECATED_VIRTUAL ~BatchContainer()
daal::algorithms::optimization_solver::mse::interface1::Parameter
Parameter for Mean squared error objective function
Definition: mse_types.h:107
daal::algorithms::optimization_solver::mse::interface2::Batch::allocate
services::Status allocate()
Definition: mse_batch.h:292
daal::batch
Definition: daal_defines.h:112
daal::algorithms::optimization_solver::mse::interface2::BatchContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::optimization_solver::mse::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: mse_batch.h:275
daal::algorithms::optimization_solver::mse::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t numberOfTerms)
Definition: mse_batch.h:109
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:63
daal::algorithms::optimization_solver::mse::interface1::Input
Input objects for the Mean squared error objective function
Definition: mse_types.h:141
daal::algorithms::optimization_solver::mse::interface2::Batch
Computes the Mean squared error objective function in the batch processing mode.
Definition: mse_batch.h:235
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal::algorithms::optimization_solver::mse::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
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:61
daal::algorithms::optimization_solver::mse::interface2::BatchContainer::~BatchContainer
virtual ~BatchContainer()
daal::algorithms::optimization_solver::mse::interface1::Batch::input
InputType input
Definition: mse_batch.h:175
daal_defines.h
daal::algorithms::optimization_solver::mse::interface2::Batch::parameter
ParameterType & parameter()
Definition: mse_batch.h:263
daal::algorithms::optimization_solver::mse::interface2::Batch::input
InputType input
Definition: mse_batch.h:317
daal::algorithms::optimization_solver::mse::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: mse_batch.h:282
daal::algorithms::optimization_solver::mse::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: mse_batch.h:139
daal::algorithms::optimization_solver::mse::interface1::Batch::allocate
DAAL_DEPRECATED services::Status allocate()
Definition: mse_batch.h:149
daal::algorithms::optimization_solver::mse::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: mse_batch.h:269
daal::algorithms::optimization_solver::mse::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::optimization_solver::mse::interface1::Batch
Computes the Mean squared error objective function in the batch processing mode.
Definition: mse_batch.h:97
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::optimization_solver::mse::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: mse_batch.h:122
daal::algorithms::optimization_solver::mse::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: mse_batch.h:132
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:199
daal::algorithms::optimization_solver::mse::interface1::Batch::parameter
ParameterType parameter
Definition: mse_batch.h:176

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