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

low_order_moments_batch.h
1 /* file: low_order_moments_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 interface for the low order moments algorithm in the
45 // batch processing mode
46 //--
47 */
48 
49 #ifndef __LOW_ORDER_MOMENTS_BATCH_H__
50 #define __LOW_ORDER_MOMENTS_BATCH_H__
51 
52 #include "algorithms/algorithm.h"
53 #include "data_management/data/numeric_table.h"
54 #include "services/daal_defines.h"
55 #include "algorithms/moments/low_order_moments_types.h"
56 
57 namespace daal
58 {
59 namespace algorithms
60 {
61 namespace low_order_moments
62 {
63 
64 namespace interface1
65 {
75 class BatchContainerIface : public daal::algorithms::AnalysisContainerIface<batch>
76 {
77 public:
78  BatchContainerIface() {};
79  virtual ~BatchContainerIface() {}
80 
84  virtual services::Status compute() = 0;
85 };
95 template<typename algorithmFPType, Method method, CpuType cpu>
96 class DAAL_EXPORT BatchContainer : public BatchContainerIface
97 {
98 public:
104  BatchContainer(daal::services::Environment::env *daalEnv);
106  virtual ~BatchContainer();
110  virtual services::Status compute() DAAL_C11_OVERRIDE;
111 };
112 
118 class DAAL_EXPORT BatchImpl : public daal::algorithms::Analysis<batch>
119 {
120 public:
121  typedef algorithms::low_order_moments::Input InputType;
122  typedef algorithms::low_order_moments::Parameter ParameterType;
123  typedef algorithms::low_order_moments::Result ResultType;
124 
126  BatchImpl()
127  {
128  initialize();
129  };
130 
137  BatchImpl(const BatchImpl &other) : parameter(other.parameter), input(other.input)
138  {
139  initialize();
140  }
141 
146  ResultPtr getResult()
147  {
148  return _result;
149  };
150 
155  virtual 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<BatchImpl> clone() const
169  {
170  return services::SharedPtr<BatchImpl>(cloneImpl());
171  }
172 
173  virtual ~BatchImpl() {}
174 
175  InputType input;
176  ParameterType parameter;
178 protected:
179  ResultPtr _result;
180 
181  void initialize()
182  {
183  _result.reset(new ResultType());
184  _in = &input;
185  _par = &parameter;
186  }
187  virtual BatchImpl *cloneImpl() const DAAL_C11_OVERRIDE = 0;
188 };
189 
207 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
208 class DAAL_EXPORT Batch : public BatchImpl
209 {
210 public:
211  typedef BatchImpl super;
212 
213  typedef typename super::InputType InputType;
214  typedef typename super::ParameterType ParameterType;
215  typedef typename super::ResultType ResultType;
216 
218  Batch()
219  {
220  initialize();
221  }
222 
229  Batch(const Batch<algorithmFPType, method> &other) : BatchImpl(other)
230  {
231  initialize();
232  }
233 
234  virtual ~Batch() {}
235 
240  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
241 
247  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
248  {
249  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
250  }
251 
252 protected:
253  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
254  {
255  return new Batch<algorithmFPType, method>(*this);
256  }
257 
258  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
259  {
260  services::Status s = _result->allocate<algorithmFPType>(&input, 0, 0);
261  _res = _result.get();
262  return s;
263  }
264 
265  void initialize()
266  {
267  this->_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
268  }
269 };
271 } // namespace interface1
272 using interface1::BatchContainerIface;
273 using interface1::BatchContainer;
274 using interface1::BatchImpl;
275 using interface1::Batch;
276 
277 } // namespace daal::algorithms::low_order_moments
278 }
279 } // namespace daal
280 #endif
daal::algorithms::low_order_moments::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: low_order_moments_batch.h:247
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::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:79
daal::algorithms::low_order_moments::interface1::BatchContainerIface::compute
virtual services::Status compute()=0
daal::algorithms::low_order_moments::interface1::Batch::Batch
Batch()
Definition: low_order_moments_batch.h:218
daal::algorithms::low_order_moments::interface1::BatchImpl::BatchImpl
BatchImpl()
Definition: low_order_moments_batch.h:126
daal::algorithms::low_order_moments::interface1::BatchContainerIface
Class that specifies interfaces of implementations of the low order moments algorithm.
Definition: low_order_moments_batch.h:75
daal::algorithms::low_order_moments::interface1::Result
Provides methods to access final results obtained with the compute() method of the low order moments ...
Definition: low_order_moments_types.h:308
daal::algorithms::low_order_moments::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: low_order_moments_batch.h:229
daal::algorithms::low_order_moments::interface1::BatchImpl
Abstract class that specifies interface of the algorithms for computing moments of low order in the b...
Definition: low_order_moments_batch.h:118
daal_defines.h
daal::algorithms::low_order_moments::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: low_order_moments_batch.h:240
daal::batch
Definition: daal_defines.h:132
daal::algorithms::low_order_moments::interface1::BatchImpl::clone
services::SharedPtr< BatchImpl > clone() const
Definition: low_order_moments_batch.h:168
daal::algorithms::low_order_moments::interface1::BatchImpl::getResult
ResultPtr getResult()
Definition: low_order_moments_batch.h:146
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::services::interface1::SharedPtr::get
T * get() const
Definition: daal_shared_ptr.h:332
daal::services::interface1::SharedPtr::reset
void reset()
Definition: daal_shared_ptr.h:265
daal::algorithms::low_order_moments::interface1::Parameter
Low order moments algorithm parameters.
Definition: low_order_moments_types.h:293
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
daal::algorithms::low_order_moments::interface1::Batch
Computes moments of low order in the batch processing mode.
Definition: low_order_moments_batch.h:208
daal::algorithms::low_order_moments::interface1::BatchImpl::parameter
ParameterType parameter
Definition: low_order_moments_batch.h:176
daal::algorithms::low_order_moments::interface1::BatchImpl::setResult
virtual services::Status setResult(const ResultPtr &result)
Definition: low_order_moments_batch.h:155
daal::algorithms::low_order_moments::interface1::Input
Input objects for the low order moments algorithm
Definition: low_order_moments_types.h:173
daal::algorithms::low_order_moments::interface1::BatchImpl::BatchImpl
BatchImpl(const BatchImpl &other)
Definition: low_order_moments_batch.h:137
daal::algorithms::low_order_moments::interface1::BatchContainer
Provides methods to run implementations of the low order moments algorithm. This class is associated ...
Definition: low_order_moments_batch.h:96
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::low_order_moments::interface1::BatchImpl::input
InputType input
Definition: low_order_moments_batch.h:175

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