C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 2

svd_online.h
1 /* file: svd_online.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of the interface for the SVD algorithm in the online processing mode
45 //--
46 */
47 
48 #ifndef __SVD_ONLINE_H__
49 #define __SVD_ONLINE_H__
50 
51 #include "algorithms/algorithm.h"
52 #include "data_management/data/numeric_table.h"
53 #include "services/daal_defines.h"
54 #include "algorithms/svd/svd_types.h"
55 
56 namespace daal
57 {
58 namespace algorithms
59 {
60 namespace svd
61 {
62 
63 namespace interface1
64 {
78 template<typename algorithmFPType, Method method, CpuType cpu>
79 class OnlineContainer : public daal::algorithms::AnalysisContainerIface<online>
80 {
81 public:
87  OnlineContainer(daal::services::Environment::env *daalEnv);
89  virtual ~OnlineContainer();
94  services::Status compute() DAAL_C11_OVERRIDE;
99  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
100 };
101 
113 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
114 class Online : public daal::algorithms::Analysis<online>
115 {
116 public:
117  typedef OnlinePartialResult PartialResult;
118  typedef OnlinePartialResultPtr PartialResultPtr;
119 
120  typedef algorithms::svd::Input InputType;
121  typedef algorithms::svd::Parameter ParameterType;
122  typedef algorithms::svd::Result ResultType;
123  typedef algorithms::svd::OnlinePartialResult PartialResultType;
124 
125  InputType input;
126  ParameterType parameter;
128  Online()
129  {
130  initialize();
131  }
132 
139  Online(const Online<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
140  {
141  initialize();
142  }
143 
148  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
149 
154  ResultPtr getResult()
155  {
156  return _result;
157  }
158 
163  PartialResultPtr getPartialResult()
164  {
165  return _partialResult;
166  }
167 
172  services::Status setResult(const ResultPtr& res)
173  {
174  DAAL_CHECK(res, services::ErrorNullResult)
175  _result = res;
176  _res = _result.get();
177  return services::Status();
178  }
179 
186  services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag = false)
187  {
188  _partialResult = partialResult;
189  _pres = _partialResult.get();
190  setInitFlag(initFlag);
191  return services::Status();
192  }
193 
198  services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
199  {
200  if(_partialResult)
201  {
202  services::Status s = _partialResult->check(_par, method);
203  if(!s)
204  return s;
205  }
206  else
207  {
208  return services::Status(services::ErrorNullResult);
209  }
210 
211  if(_result)
212  return _result->check(_partialResult.get(), _par, method);
213  return services::Status(services::ErrorNullResult);
214  }
215 
221  services::SharedPtr<Online<algorithmFPType, method> > clone() const
222  {
223  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
224  }
225 
226 protected:
227  virtual Online<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
228  {
229  return new Online<algorithmFPType, method>(*this);
230  }
231 
232  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
233  {
234  _result.reset(new ResultType());
235  services::Status s = _result->allocate<algorithmFPType>(_pres, 0, 0);
236  _res = _result.get();
237  return s;
238  }
239 
240  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
241  {
242  _partialResult.reset(new PartialResultType());
243  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
244  _pres = _partialResult.get();
245  return s;
246  }
247 
248  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
249  {
250  services::Status s = _partialResult->initialize<algorithmFPType>(_in, 0, 0);
251  _pres = _partialResult.get();
252  return s;
253  }
254 
255  void initialize()
256  {
257  Analysis<online>::_ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
258  _in = &input;
259  _par = &parameter;
260  }
261 
262 private:
263  PartialResultPtr _partialResult;
264  ResultPtr _result;
265 };
267 } // namespace interface1
268 using interface1::OnlineContainer;
269 using interface1::Online;
270 
271 } // namespace daal::algorithms::svd
272 } // namespace daal::algorithms
273 } // namespace daal
274 #endif
daal::algorithms::svd::interface1::Online::parameter
ParameterType parameter
Definition: svd_online.h:126
daal::algorithms::svd::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: svd_online.h:221
daal::algorithms::svd::interface1::Parameter
Parameters for the computation method of the SVD algorithm.
Definition: svd_types.h:187
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:79
daal::algorithms::svd::interface1::Online
Computes results of the SVD algorithm in the online processing mode.
Definition: svd_online.h:114
daal::algorithms::svd::interface1::Result
Provides methods to access final results obtained with the compute() method of the SVD algorithm in t...
Definition: svd_types.h:425
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:198
daal_defines.h
daal::algorithms::svd::interface1::Input
Input objects for the SVD algorithm in the batch processing and online processing modes...
Definition: svd_types.h:207
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::algorithms::svd::interface1::Online::setResult
services::Status setResult(const ResultPtr &res)
Definition: svd_online.h:172
daal::services::interface1::SharedPtr::get
T * get() const
Definition: daal_shared_ptr.h:332
daal::algorithms::svd::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: svd_online.h:139
daal::algorithms::svd::interface1::OnlineContainer
Provides methods to run implementations of the SVD algorithm in the online processing mode...
Definition: svd_online.h:79
daal::algorithms::svd::interface1::Online::input
InputType input
Definition: svd_online.h:125
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:94
daal::algorithms::svd::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: svd_online.h:163
daal::algorithms::svd::interface1::OnlineContainer::~OnlineContainer
virtual ~OnlineContainer()
daal::online
Definition: daal_defines.h:134
daal::algorithms::svd::interface1::Online::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: svd_online.h:186
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:342
daal::algorithms::svd::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: svd_online.h:148
daal::algorithms::svd::interface1::Online::getResult
ResultPtr getResult()
Definition: svd_online.h:154
daal::services::ErrorNullResult
Definition: error_indexes.h:122

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