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

low_order_moments_online.h
1 /* file: low_order_moments_online.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 interface for the low order moments algorithm in the
19 // online processing mode
20 //--
21 */
22 
23 #ifndef __LOW_ORDER_MOMENTS_ONLINE_H__
24 #define __LOW_ORDER_MOMENTS_ONLINE_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "services/daal_defines.h"
28 #include "algorithms/moments/low_order_moments_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace low_order_moments
35 {
36 
37 namespace interface1
38 {
53 template<typename algorithmFPType, Method method, CpuType cpu>
54 class DAAL_EXPORT OnlineContainer : public daal::algorithms::AnalysisContainerIface<online>
55 {
56 public:
62  OnlineContainer(daal::services::Environment::env *daalEnv);
64  virtual ~OnlineContainer();
69  virtual services::Status compute() DAAL_C11_OVERRIDE;
74  virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
75 };
76 
91 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
92 class DAAL_EXPORT Online : public daal::algorithms::Analysis<online>
93 {
94 public:
95  typedef algorithms::low_order_moments::Input InputType;
96  typedef algorithms::low_order_moments::Parameter ParameterType;
97  typedef algorithms::low_order_moments::Result ResultType;
98  typedef algorithms::low_order_moments::PartialResult PartialResultType;
99 
100  InputType input;
101  ParameterType parameter;
104  Online()
105  {
106  initialize();
107  }
108 
115  Online(const Online<algorithmFPType, method> &other) : parameter(other.parameter), input(other.input)
116  {
117  initialize();
118  }
119 
124  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
125 
130  ResultPtr getResult()
131  {
132  return _result;
133  }
134 
139  services::Status setResult(const ResultPtr &result)
140  {
141  DAAL_CHECK(result, services::ErrorNullResult)
142  _result = result;
143  _res = _result.get();
144  return services::Status();
145  }
146 
151  PartialResultPtr getPartialResult()
152  {
153  return _partialResult;
154  }
155 
161  services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag = false)
162  {
163  _partialResult = partialResult;
164  _pres = _partialResult.get();
165  setInitFlag(initFlag);
166  return services::Status();
167  }
168 
174  services::SharedPtr<Online<algorithmFPType, method> > clone() const
175  {
176  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
177  }
178 
179 protected:
180  virtual Online<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
181  {
182  return new Online<algorithmFPType, method>(*this);
183  }
184 
185  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
186  {
187  services::Status s = _result->allocate<algorithmFPType>(_in, 0, 0);
188  _res = _result.get();
189  _pres = _partialResult.get();
190  return s;
191  }
192 
193  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
194  {
195  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
196  _pres = _partialResult.get();
197  return s;
198  }
199 
200  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
201  {
202  services::Status s = _partialResult->initialize<algorithmFPType>(_in, 0, 0);
203  _pres = _partialResult.get();
204  return s;
205  }
206 
207  void initialize()
208  {
209  Analysis<online>::_ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
210  _in = &input;
211  _par = &parameter;
212  _result.reset(new ResultType());
213  _partialResult.reset(new PartialResultType());
214  }
215 
216 private:
217  PartialResultPtr _partialResult;
218  ResultPtr _result;
219 };
221 } // namespace interface1
222 using interface1::OnlineContainer;
223 using interface1::Online;
224 
225 } // namespace daal::algorithms::low_order_moments
226 }
227 }
228 #endif
daal
Definition: algorithm_base_common.h:31
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::low_order_moments::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: low_order_moments_online.h:174
daal::algorithms::low_order_moments::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: low_order_moments_online.h:124
daal::algorithms::low_order_moments::interface1::Online::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: low_order_moments_online.h:161
daal::algorithms::low_order_moments::interface1::Online::setResult
services::Status setResult(const ResultPtr &result)
Definition: low_order_moments_online.h:139
daal::algorithms::low_order_moments::interface1::Online::input
InputType input
Definition: low_order_moments_online.h:100
daal::algorithms::low_order_moments::interface1::Online
Computes moments of low order in the online processing mode.
Definition: low_order_moments_online.h:92
daal::algorithms::low_order_moments::interface1::OnlineContainer
Provides methods to run implementations of the low order moments algorithm. This class is associated ...
Definition: low_order_moments_online.h:54
daal::algorithms::low_order_moments::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: low_order_moments_online.h:151
daal::algorithms::low_order_moments::interface1::Online::getResult
ResultPtr getResult()
Definition: low_order_moments_online.h:130
daal_defines.h
daal::algorithms::low_order_moments::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: low_order_moments_online.h:115
daal::algorithms::low_order_moments::interface1::Online::Online
Online()
Definition: low_order_moments_online.h:104
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::low_order_moments::interface1::Online::parameter
ParameterType parameter
Definition: low_order_moments_online.h:101
daal::online
Definition: daal_defines.h:112
daal::services::ErrorNullResult
Definition: error_indexes.h:96

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