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

pca_online.h
1 /* file: pca_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 PCA algorithm in the online processing mode
19 //--
20 */
21 
22 #ifndef __PCA_ONLINE_H__
23 #define __PCA_ONLINE_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "data_management/data/numeric_table.h"
27 #include "services/daal_defines.h"
28 #include "services/daal_memory.h"
29 #include "algorithms/pca/pca_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace pca
36 {
37 
38 namespace interface1
39 {
49 template<typename algorithmFPType, Method method, CpuType cpu>
50 class DAAL_EXPORT OnlineContainer : public AnalysisContainerIface<online> {};
51 
56 template<typename algorithmFPType, CpuType cpu>
57 class DAAL_EXPORT OnlineContainer<algorithmFPType, correlationDense, cpu> : public AnalysisContainerIface<online>
58 {
59 public:
65  OnlineContainer(daal::services::Environment::env *daalEnv);
67  ~OnlineContainer();
68 
72  services::Status compute() DAAL_C11_OVERRIDE;
76  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
77 };
78 
83 template<typename algorithmFPType, CpuType cpu>
84 class DAAL_EXPORT OnlineContainer<algorithmFPType, svdDense, cpu> : public AnalysisContainerIface<online>
85 {
86 public:
92  OnlineContainer(daal::services::Environment::env *daalEnv);
94  ~OnlineContainer();
95 
99  services::Status compute() DAAL_C11_OVERRIDE;
103  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
104 };
105 
113 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = correlationDense>
114 class DAAL_EXPORT Online : public Analysis<online> {};
115 
123 template<typename algorithmFPType>
124 class DAAL_EXPORT Online<algorithmFPType, correlationDense> : public Analysis<online>
125 {
126 public:
127  typedef algorithms::pca::Input InputType;
128  typedef algorithms::pca::OnlineParameter<algorithmFPType, correlationDense> ParameterType;
129  typedef algorithms::pca::Result ResultType;
130  typedef algorithms::pca::PartialResult<correlationDense> PartialResultType;
131 
133  Online()
134  {
135  initialize();
136  }
137 
143  Online(const Online<algorithmFPType, correlationDense> &other) : input(other.input), parameter(other.parameter)
144  {
145  initialize();
146  }
147 
148  ~Online() {}
149 
154  int getMethod() const DAAL_C11_OVERRIDE { return(int)correlationDense; }
155 
160  services::Status setPartialResult(const services::SharedPtr<PartialResult<correlationDense> >& partialResult)
161  {
162  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
163  _partialResult = partialResult;
164  _pres = _partialResult.get();
165  return services::Status();
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 
184  services::SharedPtr<PartialResult<correlationDense> > getPartialResult()
185  {
186  return _partialResult;
187  }
188 
193  ResultPtr getResult()
194  {
195  return _result;
196  }
197 
203  services::SharedPtr<Online<algorithmFPType, correlationDense> > clone() const
204  {
205  return services::SharedPtr<Online<algorithmFPType, correlationDense> >(cloneImpl());
206  }
207 
208  InputType input;
209  OnlineParameter<algorithmFPType, correlationDense> parameter;
211 protected:
212  services::SharedPtr<PartialResult<correlationDense> > _partialResult;
213  ResultPtr _result;
214 
215  virtual Online<algorithmFPType, correlationDense> * cloneImpl() const DAAL_C11_OVERRIDE
216  {
217  return new Online<algorithmFPType, correlationDense>(*this);
218  }
219 
220  services::Status allocateResult() DAAL_C11_OVERRIDE
221  {
222  services::Status s = _result->allocate<algorithmFPType>(_pres, &parameter, correlationDense);
223  _res = _result.get();
224  return s;
225  }
226 
227  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
228  {
229  services::Status s = _partialResult->allocate<algorithmFPType>(&input, &parameter, correlationDense);
230  _pres = _partialResult.get();
231  return s;
232  }
233 
234  services::Status initializePartialResult() DAAL_C11_OVERRIDE
235  {
236  services::Status s = _partialResult->initialize<algorithmFPType>(&input, &parameter, correlationDense);
237  _pres = _partialResult.get();
238  return s;
239  }
240 
241  void initialize()
242  {
243  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, correlationDense)(&_env);
244  _in = &input;
245  _par = &parameter;
246  _partialResult.reset(new PartialResult<correlationDense>());
247  _result.reset(new ResultType());
248  }
249 };
250 
258 template<typename algorithmFPType>
259 class DAAL_EXPORT Online<algorithmFPType, svdDense> : public Analysis<online>
260 {
261 public:
262  typedef algorithms::pca::Input InputType;
263  typedef algorithms::pca::OnlineParameter<algorithmFPType, svdDense> ParameterType;
264  typedef algorithms::pca::Result ResultType;
265  typedef algorithms::pca::PartialResult<svdDense> PartialResultType;
266 
268  Online()
269  {
270  initialize();
271  }
272 
278  Online(const Online<algorithmFPType, svdDense> &other) : input(other.input), parameter(other.parameter)
279  {
280  initialize();
281  }
282 
283  ~Online() {}
284 
289  int getMethod() const DAAL_C11_OVERRIDE { return(int)svdDense; }
290 
295  services::Status setPartialResult(const services::SharedPtr<PartialResult<svdDense> >& partialResult)
296  {
297  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
298  _partialResult = partialResult;
299  _pres = _partialResult.get();
300  return services::Status();
301  }
302 
307  services::Status setResult(const ResultPtr& res)
308  {
309  DAAL_CHECK(res, services::ErrorNullResult)
310  _result = res;
311  _res = _result.get();
312  return services::Status();
313  }
314 
319  services::SharedPtr<PartialResult<svdDense> > getPartialResult()
320  {
321  return _partialResult;
322  }
323 
328  ResultPtr getResult()
329  {
330  return _result;
331  }
332 
338  services::SharedPtr<Online<algorithmFPType, svdDense> > clone() const
339  {
340  return services::SharedPtr<Online<algorithmFPType, svdDense> >(cloneImpl());
341  }
342 
343  InputType input;
344  OnlineParameter<algorithmFPType, svdDense> parameter;
346 protected:
347  services::SharedPtr<PartialResult<svdDense> > _partialResult;
348  ResultPtr _result;
349 
350  virtual Online<algorithmFPType, svdDense> * cloneImpl() const DAAL_C11_OVERRIDE
351  {
352  return new Online<algorithmFPType, svdDense>(*this);
353  }
354 
355  services::Status allocateResult() DAAL_C11_OVERRIDE
356  {
357  services::Status s = _result->allocate<algorithmFPType>(_pres, &parameter, svdDense);
358  _res = _result.get();
359  return s;
360  }
361 
362  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
363  {
364  services::Status s = _partialResult->allocate<algorithmFPType>(&input, &parameter, svdDense);
365  _pres = _partialResult.get();
366  return s;
367  }
368 
369  services::Status initializePartialResult() DAAL_C11_OVERRIDE
370  {
371  services::Status s = _partialResult->initialize<algorithmFPType>(&input, &parameter, svdDense);
372  _pres = _partialResult.get();
373  return s;
374  }
375 
376  void initialize()
377  {
378  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, svdDense)(&_env);
379  _in = &input;
380  _par = &parameter;
381  _partialResult.reset(new PartialResult<svdDense>());
382  _result.reset(new ResultType());
383  }
384 };
386 } // namespace interface1
387 using interface1::OnlineContainer;
388 using interface1::Online;
389 
390 }
391 }
392 }
393 #endif
daal::algorithms::pca::interface1::OnlineParameter< algorithmFPType, correlationDense >
Class that specifies the parameters of the PCA Correlation algorithm in the online computing mode...
Definition: pca_types.h:472
daal
Definition: algorithm_base_common.h:31
daal::algorithms::pca::interface1::Online
Computes the results of the PCA algorithm.
Definition: pca_online.h:114
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::getMethod
int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_online.h:154
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::clone
services::SharedPtr< Online< algorithmFPType, correlationDense > > clone() const
Definition: pca_online.h:203
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< svdDense > > &partialResult)
Definition: pca_online.h:295
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >
Computes the results of the PCA SVD algorithm.
Definition: pca_online.h:259
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:105
daal::algorithms::pca::interface1::OnlineContainer
Class containing methods to compute the result of the PCA algorithm.
Definition: pca_online.h:50
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_online.h:307
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::Online
Online()
Definition: pca_online.h:268
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::getPartialResult
services::SharedPtr< PartialResult< svdDense > > getPartialResult()
Definition: pca_online.h:319
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::parameter
OnlineParameter< algorithmFPType, correlationDense > parameter
Definition: pca_online.h:209
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::input
InputType input
Definition: pca_online.h:208
daal_defines.h
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::input
InputType input
Definition: pca_online.h:343
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::getMethod
int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_online.h:289
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_online.h:172
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::getPartialResult
services::SharedPtr< PartialResult< correlationDense > > getPartialResult()
Definition: pca_online.h:184
daal::algorithms::pca::interface1::PartialResult
Provides methods to access partial results obtained with the compute() method of the PCA algorithm in...
Definition: pca_types.h:261
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >
Computes the results of the PCA Correlation algorithm.
Definition: pca_online.h:124
daal::algorithms::pca::svdDense
Definition: pca_types.h:57
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::getResult
ResultPtr getResult()
Definition: pca_online.h:328
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::parameter
OnlineParameter< algorithmFPType, svdDense > parameter
Definition: pca_online.h:344
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::Online
Online(const Online< algorithmFPType, correlationDense > &other)
Definition: pca_online.h:143
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::clone
services::SharedPtr< Online< algorithmFPType, svdDense > > clone() const
Definition: pca_online.h:338
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::Online
Online()
Definition: pca_online.h:133
daal::online
Definition: daal_defines.h:108
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::getResult
ResultPtr getResult()
Definition: pca_online.h:193
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< correlationDense > > &partialResult)
Definition: pca_online.h:160
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::Online
Online(const Online< algorithmFPType, svdDense > &other)
Definition: pca_online.h:278
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::pca::interface1::OnlineParameter< algorithmFPType, svdDense >
Class that specifies the parameters of the PCA SVD algorithm in the online computing mode...
Definition: pca_types.h:495
daal::algorithms::pca::correlationDense
Definition: pca_types.h:55

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