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

low_order_moments_batch.h
1 /* file: low_order_moments_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 interface for the low order moments algorithm in the
21 // batch processing mode
22 //--
23 */
24 
25 #ifndef __LOW_ORDER_MOMENTS_BATCH_H__
26 #define __LOW_ORDER_MOMENTS_BATCH_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "services/daal_defines.h"
31 #include "algorithms/moments/low_order_moments_types.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace low_order_moments
38 {
39 
40 namespace interface1
41 {
51 class BatchContainerIface : public daal::algorithms::AnalysisContainerIface<batch>
52 {
53 public:
54  BatchContainerIface() {}
55  virtual ~BatchContainerIface() {}
56 
60  virtual services::Status compute() = 0;
61 };
71 template<typename algorithmFPType, Method method, CpuType cpu>
72 class BatchContainer : public BatchContainerIface
73 {
74 public:
80  BatchContainer(daal::services::Environment::env *daalEnv);
82  virtual ~BatchContainer();
86  virtual services::Status compute() DAAL_C11_OVERRIDE;
87 };
88 
94 class DAAL_EXPORT BatchImpl : public daal::algorithms::Analysis<batch>
95 {
96 public:
97  typedef algorithms::low_order_moments::Input InputType;
98  typedef algorithms::low_order_moments::Parameter ParameterType;
99  typedef algorithms::low_order_moments::Result ResultType;
100 
102  BatchImpl()
103  {
104  initialize();
105  }
106 
113  BatchImpl(const BatchImpl &other) : parameter(other.parameter), input(other.input)
114  {
115  initialize();
116  }
117 
122  ResultPtr getResult()
123  {
124  return _result;
125  }
126 
131  virtual services::Status setResult(const ResultPtr &result)
132  {
133  DAAL_CHECK(result, services::ErrorNullResult)
134  _result = result;
135  _res = _result.get();
136  return services::Status();
137  }
138 
144  services::SharedPtr<BatchImpl> clone() const
145  {
146  return services::SharedPtr<BatchImpl>(cloneImpl());
147  }
148 
149  virtual ~BatchImpl() {}
150 
151  InputType input;
152  ParameterType parameter;
154 protected:
155  ResultPtr _result;
156 
157  void initialize()
158  {
159  _result.reset(new ResultType());
160  _in = &input;
161  _par = &parameter;
162  }
163  virtual BatchImpl *cloneImpl() const DAAL_C11_OVERRIDE = 0;
164 };
165 
183 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
184 class DAAL_EXPORT Batch : public BatchImpl
185 {
186 public:
187  typedef BatchImpl super;
188 
189  typedef typename super::InputType InputType;
190  typedef typename super::ParameterType ParameterType;
191  typedef typename super::ResultType ResultType;
192 
194  Batch()
195  {
196  initialize();
197  }
198 
205  Batch(const Batch<algorithmFPType, method> &other) : BatchImpl(other)
206  {
207  initialize();
208  }
209 
210  virtual ~Batch() {}
211 
216  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
217 
223  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
224  {
225  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
226  }
227 
228 protected:
229  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
230  {
231  return new Batch<algorithmFPType, method>(*this);
232  }
233 
234  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
235  {
236  services::Status s = _result->allocate<algorithmFPType>(&input, 0, 0);
237  _res = _result.get();
238  return s;
239  }
240 
241  void initialize()
242  {
243  this->_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
244  }
245 };
247 } // namespace interface1
248 using interface1::BatchContainerIface;
249 using interface1::BatchContainer;
250 using interface1::BatchImpl;
251 using interface1::Batch;
252 
253 } // namespace daal::algorithms::low_order_moments
254 }
255 } // namespace daal
256 #endif
daal::batch
Definition: daal_defines.h:112
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:94
daal::algorithms::low_order_moments::interface1::BatchImpl::BatchImpl
BatchImpl(const BatchImpl &other)
Definition: low_order_moments_batch.h:113
daal::algorithms::low_order_moments::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: low_order_moments_batch.h:223
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:72
daal::algorithms::low_order_moments::interface1::BatchImpl::getResult
ResultPtr getResult()
Definition: low_order_moments_batch.h:122
daal::algorithms::low_order_moments::interface1::BatchImpl::parameter
ParameterType parameter
Definition: low_order_moments_batch.h:152
daal::algorithms::low_order_moments::interface1::Batch::Batch
Batch()
Definition: low_order_moments_batch.h:194
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal::algorithms::low_order_moments::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: low_order_moments_batch.h:216
daal::algorithms::low_order_moments::Method
Method
Definition: low_order_moments_types.h:48
daal_defines.h
daal::algorithms::low_order_moments::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::low_order_moments::interface1::BatchImpl::input
InputType input
Definition: low_order_moments_batch.h:151
daal::algorithms::low_order_moments::interface1::BatchContainerIface::compute
virtual services::Status compute()=0
daal::algorithms::low_order_moments::defaultDense
Definition: low_order_moments_types.h:50
daal::algorithms::low_order_moments::interface1::BatchImpl::clone
services::SharedPtr< BatchImpl > clone() const
Definition: low_order_moments_batch.h:144
daal::algorithms::low_order_moments::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: low_order_moments_batch.h:205
daal::algorithms::low_order_moments::interface1::BatchContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::low_order_moments::interface1::BatchImpl::setResult
virtual services::Status setResult(const ResultPtr &result)
Definition: low_order_moments_batch.h:131
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:51
daal::algorithms::low_order_moments::interface1::Batch
Computes moments of low order in the batch processing mode.
Definition: low_order_moments_batch.h:184
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::low_order_moments::interface1::BatchContainer::~BatchContainer
virtual ~BatchContainer()
daal::algorithms::low_order_moments::interface1::BatchImpl::BatchImpl
BatchImpl()
Definition: low_order_moments_batch.h:102

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