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

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

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