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

qr_online.h
1 /* file: qr_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 QR decomposition algorithm in the
21 // online processing mode
22 //--
23 */
24 
25 #ifndef __QR_STREAM_H__
26 #define __QR_STREAM_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "services/daal_defines.h"
31 #include "algorithms/qr/qr_types.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace qr
38 {
39 
40 namespace interface1
41 {
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();
70  virtual services::Status compute() DAAL_C11_OVERRIDE;
74  virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
75 };
76 
88 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
89 class Online : public daal::algorithms::Analysis<online>
90 {
91 public:
92  typedef OnlinePartialResult PartialResult;
93  typedef OnlinePartialResultPtr PartialResultPtr;
94 
95  typedef algorithms::qr::Input InputType;
96  typedef algorithms::qr::Parameter ParameterType;
97  typedef algorithms::qr::Result ResultType;
98  typedef algorithms::qr::OnlinePartialResult PartialResultType;
99 
100  InputType input;
101  ParameterType parameter;
103  Online()
104  {
105  initialize();
106  }
107 
114  Online(const Online<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
115  {
116  initialize();
117  }
118 
123  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
124 
129  ResultPtr getResult()
130  {
131  return _result;
132  }
133 
138  PartialResultPtr getPartialResult()
139  {
140  return _partialResult;
141  }
142 
147  services::Status setResult(const ResultPtr& res)
148  {
149  DAAL_CHECK(res, services::ErrorNullResult)
150  _result = res;
151  _res = _result.get();
152  return services::Status();
153  }
154 
161  services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag = false)
162  {
163  _partialResult = partialResult;
164  _pres = _partialResult.get();
165  setInitFlag(initFlag);
166  return services::Status();
167  }
168 
174  services::SharedPtr<Online<algorithmFPType, method> > clone() const
175  {
176  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
177  }
178 
179 protected:
180  virtual Online<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
181  {
182  return new Online<algorithmFPType, method>(*this);
183  }
184 
185  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
186  {
187  _result.reset(new ResultType());
188  services::Status s = _result->allocate<algorithmFPType>(_pres, 0, 0);
189  _res = _result.get();
190  return s;
191  }
192 
193  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
194  {
195  _partialResult.reset(new PartialResultType());
196  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
197  _pres = _partialResult.get();
198  return s;
199  }
200 
201  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
202  {
203  services::Status s = _partialResult->initialize<algorithmFPType>(_in, 0, 0);
204  _pres = _partialResult.get();
205  return s;
206  }
207 
208  void initialize()
209  {
210  Analysis<online>::_ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
211  _in = &input;
212  _par = &parameter;
213  }
214 
215 private:
216  PartialResultPtr _partialResult;
217  ResultPtr _result;
218 };
220 } // namespace interface1
221 using interface1::OnlineContainer;
222 using interface1::Online;
223 
224 } // namespace daal::algorithms::qr
225 } // namespace daal::algorithms
226 } // namespace daal
227 #endif
daal::algorithms::qr::interface1::Online::setResult
services::Status setResult(const ResultPtr &res)
Definition: qr_online.h:147
daal::algorithms::qr::interface1::OnlineContainer
Provides methods to run implementations of the QR decomposition algorithm in the online processing mo...
Definition: qr_online.h:56
daal::algorithms::qr::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: qr_online.h:174
daal::algorithms::qr::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: qr_online.h:114
daal::algorithms::qr::interface1::Online::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: qr_online.h:161
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::qr::interface1::Online::input
InputType input
Definition: qr_online.h:100
daal::algorithms::qr::interface1::OnlineContainer::finalizeCompute
virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE
daal_defines.h
daal::algorithms::qr::interface1::OnlineContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::qr::interface1::Online
Computes the results of the QR decomposition algorithm in the online processing mode.
Definition: qr_online.h:89
daal::online
Definition: daal_defines.h:114
daal::algorithms::qr::interface1::Online::getResult
ResultPtr getResult()
Definition: qr_online.h:129
daal::algorithms::qr::interface1::Online::parameter
ParameterType parameter
Definition: qr_online.h:101
daal::algorithms::qr::interface1::OnlinePartialResult
Provides methods to access partial results obtained with the compute() method of the QR decomposition...
Definition: qr_types.h:297
daal::algorithms::qr::interface1::OnlineContainer::~OnlineContainer
virtual ~OnlineContainer()
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::qr::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: qr_online.h:123
daal::algorithms::qr::interface1::OnlineContainer::OnlineContainer
OnlineContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::qr::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: qr_online.h:138

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