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

low_order_moments_online.h
1 /* file: low_order_moments_online.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 // online processing mode
22 //--
23 */
24 
25 #ifndef __LOW_ORDER_MOMENTS_ONLINE_H__
26 #define __LOW_ORDER_MOMENTS_ONLINE_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "services/daal_defines.h"
30 #include "algorithms/moments/low_order_moments_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace low_order_moments
37 {
38 
39 namespace interface1
40 {
55 template<typename algorithmFPType, Method method, CpuType cpu>
56 class OnlineContainer : public daal::algorithms::AnalysisContainerIface<online>
57 {
58 public:
64  OnlineContainer(daal::services::Environment::env *daalEnv);
66  virtual ~OnlineContainer();
71  virtual services::Status compute() DAAL_C11_OVERRIDE;
76  virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
77 };
78 
93 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
94 class DAAL_EXPORT Online : public daal::algorithms::Analysis<online>
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  typedef algorithms::low_order_moments::PartialResult PartialResultType;
101 
102  InputType input;
103  ParameterType parameter;
106  Online()
107  {
108  initialize();
109  }
110 
117  Online(const Online<algorithmFPType, method> &other) : parameter(other.parameter), input(other.input)
118  {
119  initialize();
120  }
121 
126  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
127 
132  ResultPtr getResult()
133  {
134  return _result;
135  }
136 
141  services::Status setResult(const ResultPtr &result)
142  {
143  DAAL_CHECK(result, services::ErrorNullResult)
144  _result = result;
145  _res = _result.get();
146  return services::Status();
147  }
148 
153  PartialResultPtr getPartialResult()
154  {
155  return _partialResult;
156  }
157 
163  services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag = false)
164  {
165  _partialResult = partialResult;
166  _pres = _partialResult.get();
167  setInitFlag(initFlag);
168  return services::Status();
169  }
170 
176  services::SharedPtr<Online<algorithmFPType, method> > clone() const
177  {
178  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
179  }
180 
181 protected:
182  virtual Online<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
183  {
184  return new Online<algorithmFPType, method>(*this);
185  }
186 
187  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
188  {
189  services::Status s = _result->allocate<algorithmFPType>(_in, 0, 0);
190  _res = _result.get();
191  _pres = _partialResult.get();
192  return s;
193  }
194 
195  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
196  {
197  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
198  _pres = _partialResult.get();
199  return s;
200  }
201 
202  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
203  {
204  services::Status s = _partialResult->initialize<algorithmFPType>(_in, 0, 0);
205  _pres = _partialResult.get();
206  return s;
207  }
208 
209  void initialize()
210  {
211  Analysis<online>::_ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
212  _in = &input;
213  _par = &parameter;
214  _result.reset(new ResultType());
215  _partialResult.reset(new PartialResultType());
216  }
217 
218 private:
219  PartialResultPtr _partialResult;
220  ResultPtr _result;
221 };
223 } // namespace interface1
224 using interface1::OnlineContainer;
225 using interface1::Online;
226 
227 } // namespace daal::algorithms::low_order_moments
228 }
229 }
230 #endif
daal::algorithms::low_order_moments::interface1::Online::parameter
ParameterType parameter
Definition: low_order_moments_online.h:103
daal::algorithms::low_order_moments::interface1::Online::setResult
services::Status setResult(const ResultPtr &result)
Definition: low_order_moments_online.h:141
daal::algorithms::low_order_moments::interface1::OnlineContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::low_order_moments::interface1::Online::getResult
ResultPtr getResult()
Definition: low_order_moments_online.h:132
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::low_order_moments::interface1::Online::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: low_order_moments_online.h:163
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::OnlineContainer::finalizeCompute
virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE
daal::algorithms::low_order_moments::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: low_order_moments_online.h:126
daal::algorithms::low_order_moments::interface1::Online
Computes moments of low order in the online processing mode.
Definition: low_order_moments_online.h:94
daal_defines.h
daal::algorithms::low_order_moments::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: low_order_moments_online.h:176
daal::algorithms::low_order_moments::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: low_order_moments_online.h:153
daal::algorithms::low_order_moments::interface1::Online::Online
Online()
Definition: low_order_moments_online.h:106
daal::algorithms::low_order_moments::interface1::OnlineContainer::~OnlineContainer
virtual ~OnlineContainer()
daal::online
Definition: daal_defines.h:114
daal::algorithms::low_order_moments::interface1::Online::input
InputType input
Definition: low_order_moments_online.h:102
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:56
daal::algorithms::low_order_moments::interface1::OnlineContainer::OnlineContainer
OnlineContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::low_order_moments::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: low_order_moments_online.h:117
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70

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