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

svd_online.h
1 /* file: svd_online.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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 SVD algorithm in the online processing mode
19 //--
20 */
21 
22 #ifndef __SVD_ONLINE_H__
23 #define __SVD_ONLINE_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "data_management/data/numeric_table.h"
27 #include "services/daal_defines.h"
28 #include "algorithms/svd/svd_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace svd
35 {
36 
37 namespace interface1
38 {
52 template<typename algorithmFPType, Method method, CpuType cpu>
53 class OnlineContainer : public daal::algorithms::AnalysisContainerIface<online>
54 {
55 public:
61  OnlineContainer(daal::services::Environment::env *daalEnv);
63  virtual ~OnlineContainer();
68  services::Status compute() DAAL_C11_OVERRIDE;
73  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
74 };
75 
87 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
88 class Online : public daal::algorithms::Analysis<online>
89 {
90 public:
91  typedef OnlinePartialResult PartialResult;
92  typedef OnlinePartialResultPtr PartialResultPtr;
93 
94  typedef algorithms::svd::Input InputType;
95  typedef algorithms::svd::Parameter ParameterType;
96  typedef algorithms::svd::Result ResultType;
97  typedef algorithms::svd::OnlinePartialResult PartialResultType;
98 
99  InputType input;
100  ParameterType parameter;
102  Online()
103  {
104  initialize();
105  }
106 
113  Online(const Online<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
114  {
115  initialize();
116  }
117 
122  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
123 
128  ResultPtr getResult()
129  {
130  return _result;
131  }
132 
137  PartialResultPtr getPartialResult()
138  {
139  return _partialResult;
140  }
141 
146  services::Status setResult(const ResultPtr& res)
147  {
148  DAAL_CHECK(res, services::ErrorNullResult)
149  _result = res;
150  _res = _result.get();
151  return services::Status();
152  }
153 
160  services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag = false)
161  {
162  _partialResult = partialResult;
163  _pres = _partialResult.get();
164  setInitFlag(initFlag);
165  return services::Status();
166  }
167 
172  services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
173  {
174  if(_partialResult)
175  {
176  services::Status s = _partialResult->check(_par, method);
177  if(!s)
178  return s;
179  }
180  else
181  {
182  return services::Status(services::ErrorNullResult);
183  }
184 
185  if(_result)
186  return _result->check(_partialResult.get(), _par, method);
187  return services::Status(services::ErrorNullResult);
188  }
189 
195  services::SharedPtr<Online<algorithmFPType, method> > clone() const
196  {
197  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
198  }
199 
200 protected:
201  virtual Online<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
202  {
203  return new Online<algorithmFPType, method>(*this);
204  }
205 
206  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
207  {
208  _result.reset(new ResultType());
209  services::Status s = _result->allocate<algorithmFPType>(_pres, 0, 0);
210  _res = _result.get();
211  return s;
212  }
213 
214  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
215  {
216  _partialResult.reset(new PartialResultType());
217  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
218  _pres = _partialResult.get();
219  return s;
220  }
221 
222  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
223  {
224  services::Status s = _partialResult->initialize<algorithmFPType>(_in, 0, 0);
225  _pres = _partialResult.get();
226  return s;
227  }
228 
229  void initialize()
230  {
231  Analysis<online>::_ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
232  _in = &input;
233  _par = &parameter;
234  }
235 
236 private:
237  PartialResultPtr _partialResult;
238  ResultPtr _result;
239 };
241 } // namespace interface1
242 using interface1::OnlineContainer;
243 using interface1::Online;
244 
245 } // namespace daal::algorithms::svd
246 } // namespace daal::algorithms
247 } // namespace daal
248 #endif
daal::algorithms::svd::interface1::Online::parameter
ParameterType parameter
Definition: svd_online.h:100
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::svd::interface1::Online
Computes results of the SVD algorithm in the online processing mode.
Definition: svd_online.h:88
daal::algorithms::svd::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: svd_online.h:195
daal::algorithms::svd::interface1::OnlineContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::svd::interface1::OnlineContainer::OnlineContainer
OnlineContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::svd::interface1::Online::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: svd_online.h:172
daal_defines.h
daal::algorithms::svd::interface1::Online::setResult
services::Status setResult(const ResultPtr &res)
Definition: svd_online.h:146
daal::algorithms::svd::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: svd_online.h:113
daal::algorithms::svd::interface1::OnlineContainer
Provides methods to run implementations of the SVD algorithm in the online processing mode...
Definition: svd_online.h:53
daal::algorithms::svd::interface1::Online::input
InputType input
Definition: svd_online.h:99
daal::algorithms::svd::interface1::OnlineContainer::finalizeCompute
services::Status finalizeCompute() DAAL_C11_OVERRIDE
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::svd::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: svd_online.h:137
daal::algorithms::svd::interface1::OnlineContainer::~OnlineContainer
virtual ~OnlineContainer()
daal::online
Definition: daal_defines.h:108
daal::algorithms::svd::interface1::Online::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: svd_online.h:160
daal::algorithms::svd::interface1::OnlinePartialResult
Provides methods to access partial results obtained with the compute() method of the SVD algorithm in...
Definition: svd_types.h:316
daal::algorithms::svd::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: svd_online.h:122
daal::algorithms::svd::interface1::Online::getResult
ResultPtr getResult()
Definition: svd_online.h:128
daal::services::ErrorNullResult
Definition: error_indexes.h:96

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