C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 2

mse_batch.h
1 /* file: mse_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of the mean squared error (MSE) objective function in the batch
45 // processing mode
46 //--
47 */
48 
49 #ifndef __MSE_BATCH_H__
50 #define __MSE_BATCH_H__
51 
52 #include "algorithms/algorithm.h"
53 #include "data_management/data/numeric_table.h"
54 #include "data_management/data/homogen_numeric_table.h"
55 #include "services/daal_defines.h"
56 #include "sum_of_functions_batch.h"
57 #include "mse_types.h"
58 
59 namespace daal
60 {
61 namespace algorithms
62 {
63 namespace optimization_solver
64 {
65 namespace mse
66 {
67 
68 namespace interface1
69 {
84 template<typename algorithmFPType, Method method, CpuType cpu>
85 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
86 {
87 public:
93  BatchContainer(daal::services::Environment::env *daalEnv);
95  virtual ~BatchContainer();
101  virtual services::Status compute() DAAL_C11_OVERRIDE;
102 };
103 
120 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
121 class DAAL_EXPORT Batch : public sum_of_functions::Batch
122 {
123 public:
124  typedef sum_of_functions::Batch super;
125 
126  typedef algorithms::optimization_solver::mse::Input InputType;
127  typedef algorithms::optimization_solver::mse::Parameter ParameterType;
128  typedef typename super::ResultType ResultType;
129 
133  Batch(size_t numberOfTerms) : parameter(numberOfTerms), sum_of_functions::Batch(numberOfTerms, &input, &parameter)
134  {
135  initialize();
136  }
137 
138  virtual ~Batch() {}
139 
146  Batch(const Batch<algorithmFPType, method> &other) :
147  parameter(other.parameter), sum_of_functions::Batch(other.parameter.numberOfTerms, &input, &parameter), input(other.input)
148  {
149  initialize();
150  }
151 
156  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
157 
163  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
164  {
165  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
166  }
167 
173  services::Status allocate()
174  {
175  return allocateResult();
176  }
177 
178 protected:
179  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
180  {
181  return new Batch<algorithmFPType, method>(*this);
182  }
183 
184  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
185  {
186  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
187  _res = _result.get();
188  return s;
189  }
190 
191  void initialize()
192  {
193  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
194  _in = &input;
195  _par = &parameter;
196  }
197 
198 public:
199  InputType input;
200  ParameterType parameter;
202 };
204 } // namespace interface1
205 using interface1::BatchContainer;
206 using interface1::Batch;
207 
208 } // namespace mse
209 } // namespace optimization_solver
210 } // namespace algorithm
211 } // namespace daal
212 #endif
daal::algorithms::optimization_solver::mse::interface1::Batch::parameter
ParameterType parameter
Definition: mse_batch.h:200
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::optimization_solver::mse::interface1::Batch
Computes the Mean squared error objective function in the batch processing mode.
Definition: mse_batch.h:121
daal::algorithms::optimization_solver::mse::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: mse_batch.h:163
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:79
daal::algorithms::optimization_solver::mse::interface1::Batch::allocate
services::Status allocate()
Definition: mse_batch.h:173
daal::algorithms::optimization_solver::mse::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: mse_batch.h:156
daal::algorithms::optimization_solver::objective_function::interface1::Result
Provides methods to access final results obtained with the compute() method of the Objective function...
Definition: objective_function_types.h:186
daal::algorithms::optimization_solver::mse::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: mse_batch.h:146
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:87
daal::batch
Definition: daal_defines.h:132
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::algorithms::optimization_solver::mse::interface1::Input
Input objects for the Mean squared error objective function
Definition: mse_types.h:146
daal::algorithms::optimization_solver::mse::interface1::Batch::~Batch
virtual ~Batch()
Definition: mse_batch.h:138
daal::algorithms::optimization_solver::mse::interface1::Batch::input
InputType input
Definition: mse_batch.h:199
daal::algorithms::optimization_solver::mse::interface1::Parameter
Parameter for Mean squared error objective function
Definition: mse_types.h:111
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
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:85
daal::algorithms::optimization_solver::mse::interface1::Batch::Batch
Batch(size_t numberOfTerms)
Definition: mse_batch.h:133

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