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

svd_online.h
1 /* file: svd_online.h */
2 /*******************************************************************************
3 * Copyright 2014-2017 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  Input input;
121  Parameter parameter;
123  Online()
124  {
125  initialize();
126  }
127 
134  Online(const Online<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
135  {
136  initialize();
137  }
138 
143  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
144 
149  ResultPtr getResult()
150  {
151  return _result;
152  }
153 
158  PartialResultPtr getPartialResult()
159  {
160  return _partialResult;
161  }
162 
167  services::Status setResult(const ResultPtr& res)
168  {
169  DAAL_CHECK(res, services::ErrorNullResult)
170  _result = res;
171  _res = _result.get();
172  return services::Status();
173  }
174 
181  services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag = false)
182  {
183  _partialResult = partialResult;
184  _pres = _partialResult.get();
185  setInitFlag(initFlag);
186  return services::Status();
187  }
188 
193  services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
194  {
195  if(_partialResult)
196  {
197  services::Status s = _partialResult->check(_par, method);
198  if(!s)
199  return s;
200  }
201  else
202  {
203  return services::Status(services::ErrorNullResult);
204  }
205 
206  if(_result)
207  return _result->check(_partialResult.get(), _par, method);
208  return services::Status(services::ErrorNullResult);
209  }
210 
216  services::SharedPtr<Online<algorithmFPType, method> > clone() const
217  {
218  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
219  }
220 
221 protected:
222  virtual Online<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
223  {
224  return new Online<algorithmFPType, method>(*this);
225  }
226 
227  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
228  {
229  _result.reset(new Result());
230  services::Status s = _result->allocate<algorithmFPType>(_pres, 0, 0);
231  _res = _result.get();
232  return s;
233  }
234 
235  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
236  {
237  _partialResult.reset(new PartialResult());
238  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
239  _pres = _partialResult.get();
240  return s;
241  }
242 
243  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
244  {
245  services::Status s = _partialResult->initialize<algorithmFPType>(_in, 0, 0);
246  _pres = _partialResult.get();
247  return s;
248  }
249 
250  void initialize()
251  {
252  Analysis<online>::_ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
253  _in = &input;
254  _par = &parameter;
255  }
256 
257 private:
258  PartialResultPtr _partialResult;
259  ResultPtr _result;
260 };
262 } // namespace interface1
263 using interface1::OnlineContainer;
264 using interface1::Online;
265 
266 } // namespace daal::algorithms::svd
267 } // namespace daal::algorithms
268 } // namespace daal
269 #endif
daal::algorithms::svd::interface1::Parameter
Parameters for the computation method of the SVD algorithm.
Definition: svd_types.h:187
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::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: svd_online.h:216
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:193
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::algorithms::svd::interface1::Online::setResult
services::Status setResult(const ResultPtr &res)
Definition: svd_online.h:167
daal::algorithms::svd::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: svd_online.h:134
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
Input input
Definition: svd_online.h:120
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:158
daal::algorithms::svd::interface1::OnlineContainer::~OnlineContainer
virtual ~OnlineContainer()
daal::online
Definition: daal_defines.h:133
daal::algorithms::svd::interface1::Online::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: svd_online.h:181
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::parameter
Parameter parameter
Definition: svd_online.h:121
daal::algorithms::svd::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: svd_online.h:143
daal::algorithms::svd::interface1::Online::getResult
ResultPtr getResult()
Definition: svd_online.h:149
daal::services::ErrorNullResult
Definition: error_indexes.h:122

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