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

pca_online.h
1 /* file: pca_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 PCA algorithm in the online processing mode
45 //--
46 */
47 
48 #ifndef __PCA_ONLINE_H__
49 #define __PCA_ONLINE_H__
50 
51 #include "algorithms/algorithm.h"
52 #include "data_management/data/numeric_table.h"
53 #include "services/daal_defines.h"
54 #include "services/daal_memory.h"
55 #include "algorithms/pca/pca_types.h"
56 
57 namespace daal
58 {
59 namespace algorithms
60 {
61 namespace pca
62 {
63 
64 namespace interface1
65 {
75 template<typename algorithmFPType, Method method, CpuType cpu>
76 class DAAL_EXPORT OnlineContainer : public AnalysisContainerIface<online> {};
77 
82 template<typename algorithmFPType, CpuType cpu>
83 class DAAL_EXPORT OnlineContainer<algorithmFPType, correlationDense, cpu> : public AnalysisContainerIface<online>
84 {
85 public:
91  OnlineContainer(daal::services::Environment::env *daalEnv);
93  ~OnlineContainer();
94 
98  services::Status compute() DAAL_C11_OVERRIDE;
102  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
103 };
104 
109 template<typename algorithmFPType, CpuType cpu>
110 class DAAL_EXPORT OnlineContainer<algorithmFPType, svdDense, cpu> : public AnalysisContainerIface<online>
111 {
112 public:
118  OnlineContainer(daal::services::Environment::env *daalEnv);
120  ~OnlineContainer();
121 
125  services::Status compute() DAAL_C11_OVERRIDE;
129  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
130 };
131 
139 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = correlationDense>
140 class DAAL_EXPORT Online : public Analysis<online> {};
141 
149 template<typename algorithmFPType>
150 class DAAL_EXPORT Online<algorithmFPType, correlationDense> : public Analysis<online>
151 {
152 public:
153  typedef algorithms::pca::Input InputType;
154  typedef algorithms::pca::OnlineParameter<algorithmFPType, correlationDense> ParameterType;
155  typedef algorithms::pca::Result ResultType;
156  typedef algorithms::pca::PartialResult<correlationDense> PartialResultType;
157 
159  Online()
160  {
161  initialize();
162  }
163 
169  Online(const Online<algorithmFPType, correlationDense> &other) : input(other.input), parameter(other.parameter)
170  {
171  initialize();
172  }
173 
174  ~Online() {}
175 
180  int getMethod() const DAAL_C11_OVERRIDE { return(int)correlationDense; }
181 
186  services::Status setPartialResult(const services::SharedPtr<PartialResult<correlationDense> >& partialResult)
187  {
188  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
189  _partialResult = partialResult;
190  _pres = _partialResult.get();
191  return services::Status();
192  }
193 
198  services::Status setResult(const ResultPtr& res)
199  {
200  DAAL_CHECK(res, services::ErrorNullResult)
201  _result = res;
202  _res = _result.get();
203  return services::Status();
204  }
205 
210  services::SharedPtr<PartialResult<correlationDense> > getPartialResult()
211  {
212  return _partialResult;
213  }
214 
219  ResultPtr getResult()
220  {
221  return _result;
222  }
223 
229  services::SharedPtr<Online<algorithmFPType, correlationDense> > clone() const
230  {
231  return services::SharedPtr<Online<algorithmFPType, correlationDense> >(cloneImpl());
232  }
233 
234  InputType input;
235  OnlineParameter<algorithmFPType, correlationDense> parameter;
237 protected:
238  services::SharedPtr<PartialResult<correlationDense> > _partialResult;
239  ResultPtr _result;
240 
241  virtual Online<algorithmFPType, correlationDense> * cloneImpl() const DAAL_C11_OVERRIDE
242  {
243  return new Online<algorithmFPType, correlationDense>(*this);
244  }
245 
246  services::Status allocateResult() DAAL_C11_OVERRIDE
247  {
248  services::Status s = _result->allocate<algorithmFPType>(_pres, &parameter, correlationDense);
249  _res = _result.get();
250  return s;
251  }
252 
253  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
254  {
255  services::Status s = _partialResult->allocate<algorithmFPType>(&input, &parameter, correlationDense);
256  _pres = _partialResult.get();
257  return s;
258  }
259 
260  services::Status initializePartialResult() DAAL_C11_OVERRIDE
261  {
262  services::Status s = _partialResult->initialize<algorithmFPType>(&input, &parameter, correlationDense);
263  _pres = _partialResult.get();
264  return s;
265  }
266 
267  void initialize()
268  {
269  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, correlationDense)(&_env);
270  _in = &input;
271  _par = &parameter;
272  _partialResult.reset(new PartialResult<correlationDense>());
273  _result.reset(new ResultType());
274  }
275 };
276 
284 template<typename algorithmFPType>
285 class DAAL_EXPORT Online<algorithmFPType, svdDense> : public Analysis<online>
286 {
287 public:
288  typedef algorithms::pca::Input InputType;
289  typedef algorithms::pca::OnlineParameter<algorithmFPType, svdDense> ParameterType;
290  typedef algorithms::pca::Result ResultType;
291  typedef algorithms::pca::PartialResult<svdDense> PartialResultType;
292 
294  Online()
295  {
296  initialize();
297  }
298 
304  Online(const Online<algorithmFPType, svdDense> &other) : input(other.input), parameter(other.parameter)
305  {
306  initialize();
307  }
308 
309  ~Online() {}
310 
315  int getMethod() const DAAL_C11_OVERRIDE { return(int)svdDense; }
316 
321  services::Status setPartialResult(const services::SharedPtr<PartialResult<svdDense> >& partialResult)
322  {
323  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
324  _partialResult = partialResult;
325  _pres = _partialResult.get();
326  return services::Status();
327  }
328 
333  services::Status setResult(const ResultPtr& res)
334  {
335  DAAL_CHECK(res, services::ErrorNullResult)
336  _result = res;
337  _res = _result.get();
338  return services::Status();
339  }
340 
345  services::SharedPtr<PartialResult<svdDense> > getPartialResult()
346  {
347  return _partialResult;
348  }
349 
354  ResultPtr getResult()
355  {
356  return _result;
357  }
358 
364  services::SharedPtr<Online<algorithmFPType, svdDense> > clone() const
365  {
366  return services::SharedPtr<Online<algorithmFPType, svdDense> >(cloneImpl());
367  }
368 
369  InputType input;
370  OnlineParameter<algorithmFPType, svdDense> parameter;
372 protected:
373  services::SharedPtr<PartialResult<svdDense> > _partialResult;
374  ResultPtr _result;
375 
376  virtual Online<algorithmFPType, svdDense> * cloneImpl() const DAAL_C11_OVERRIDE
377  {
378  return new Online<algorithmFPType, svdDense>(*this);
379  }
380 
381  services::Status allocateResult() DAAL_C11_OVERRIDE
382  {
383  services::Status s = _result->allocate<algorithmFPType>(_pres, &parameter, svdDense);
384  _res = _result.get();
385  return s;
386  }
387 
388  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
389  {
390  services::Status s = _partialResult->allocate<algorithmFPType>(&input, &parameter, svdDense);
391  _pres = _partialResult.get();
392  return s;
393  }
394 
395  services::Status initializePartialResult() DAAL_C11_OVERRIDE
396  {
397  services::Status s = _partialResult->initialize<algorithmFPType>(&input, &parameter, svdDense);
398  _pres = _partialResult.get();
399  return s;
400  }
401 
402  void initialize()
403  {
404  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, svdDense)(&_env);
405  _in = &input;
406  _par = &parameter;
407  _partialResult.reset(new PartialResult<svdDense>());
408  _result.reset(new ResultType());
409  }
410 };
412 } // namespace interface1
413 using interface1::OnlineContainer;
414 using interface1::Online;
415 
416 }
417 }
418 }
419 #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:498
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::pca::interface1::Online
Computes the results of the PCA algorithm.
Definition: pca_online.h:140
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:79
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::getMethod
int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_online.h:180
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< svdDense > > &partialResult)
Definition: pca_online.h:321
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >
Computes the results of the PCA SVD algorithm.
Definition: pca_online.h:285
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:131
daal::algorithms::pca::interface1::OnlineContainer
Class containing methods to compute the result of the PCA algorithm.
Definition: pca_online.h:76
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_online.h:333
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::Online
Online()
Definition: pca_online.h:294
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::getPartialResult
services::SharedPtr< PartialResult< svdDense > > getPartialResult()
Definition: pca_online.h:345
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::clone
services::SharedPtr< Online< algorithmFPType, correlationDense > > clone() const
Definition: pca_online.h:229
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::parameter
OnlineParameter< algorithmFPType, correlationDense > parameter
Definition: pca_online.h:235
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::input
InputType input
Definition: pca_online.h:234
daal_defines.h
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::input
InputType input
Definition: pca_online.h:369
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::getMethod
int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_online.h:315
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_online.h:198
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::pca::interface2::Result
Provides methods to access results obtained with the PCA algorithm.
Definition: pca_types.h:753
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::getPartialResult
services::SharedPtr< PartialResult< correlationDense > > getPartialResult()
Definition: pca_online.h:210
daal::algorithms::pca::interface1::OnlineParameter
Class that specifies the parameters of the PCA algorithm in the online computing mode.
Definition: pca_types.h:491
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:287
daal::services::interface1::SharedPtr::get
T * get() const
Definition: daal_shared_ptr.h:332
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >
Computes the results of the PCA Correlation algorithm.
Definition: pca_online.h:150
daal::algorithms::pca::svdDense
Definition: pca_types.h:83
daal::services::interface1::SharedPtr::reset
void reset()
Definition: daal_shared_ptr.h:265
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::parameter
OnlineParameter< algorithmFPType, svdDense > parameter
Definition: pca_online.h:370
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::Online
Online(const Online< algorithmFPType, correlationDense > &other)
Definition: pca_online.h:169
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::Online
Online()
Definition: pca_online.h:159
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::clone
services::SharedPtr< Online< algorithmFPType, svdDense > > clone() const
Definition: pca_online.h:364
daal::online
Definition: daal_defines.h:134
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< correlationDense > > &partialResult)
Definition: pca_online.h:186
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::Online
Online(const Online< algorithmFPType, svdDense > &other)
Definition: pca_online.h:304
daal::algorithms::pca::interface1::Input
Input objects for the PCA algorithm.
Definition: pca_types.h:222
daal::services::ErrorNullResult
Definition: error_indexes.h:122
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:521
daal::algorithms::pca::correlationDense
Definition: pca_types.h:81

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