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

pca_online.h
1 /* file: pca_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 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:
154  Online()
155  {
156  initialize();
157  }
158 
164  Online(const Online<algorithmFPType, correlationDense> &other) : input(other.input), parameter(other.parameter)
165  {
166  initialize();
167  }
168 
169  ~Online() {}
170 
175  int getMethod() const DAAL_C11_OVERRIDE { return(int)correlationDense; }
176 
181  services::Status setPartialResult(const services::SharedPtr<PartialResult<correlationDense> >& partialResult)
182  {
183  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
184  _partialResult = partialResult;
185  _pres = _partialResult.get();
186  return services::Status();
187  }
188 
193  services::Status setResult(const ResultPtr& res)
194  {
195  DAAL_CHECK(res, services::ErrorNullResult)
196  _result = res;
197  _res = _result.get();
198  return services::Status();
199  }
200 
205  services::SharedPtr<PartialResult<correlationDense> > getPartialResult()
206  {
207  return _partialResult;
208  }
209 
214  ResultPtr getResult()
215  {
216  return _result;
217  }
218 
224  services::SharedPtr<Online<algorithmFPType, correlationDense> > clone() const
225  {
226  return services::SharedPtr<Online<algorithmFPType, correlationDense> >(cloneImpl());
227  }
228 
229  Input input;
230  OnlineParameter<algorithmFPType, correlationDense> parameter;
232 protected:
233  services::SharedPtr<PartialResult<correlationDense> > _partialResult;
234  ResultPtr _result;
235 
236  virtual Online<algorithmFPType, correlationDense> * cloneImpl() const DAAL_C11_OVERRIDE
237  {
238  return new Online<algorithmFPType, correlationDense>(*this);
239  }
240 
241  services::Status allocateResult() DAAL_C11_OVERRIDE
242  {
243  services::Status s = _result->allocate<algorithmFPType>(_pres, &parameter, correlationDense);
244  _res = _result.get();
245  return s;
246  }
247 
248  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
249  {
250  services::Status s = _partialResult->allocate<algorithmFPType>(&input, &parameter, correlationDense);
251  _pres = _partialResult.get();
252  return s;
253  }
254 
255  services::Status initializePartialResult() DAAL_C11_OVERRIDE
256  {
257  services::Status s = _partialResult->initialize<algorithmFPType>(&input, &parameter, correlationDense);
258  _pres = _partialResult.get();
259  return s;
260  }
261 
262  void initialize()
263  {
264  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, correlationDense)(&_env);
265  _in = &input;
266  _par = &parameter;
267  _partialResult.reset(new PartialResult<correlationDense>());
268  _result.reset(new Result());
269  }
270 };
271 
279 template<typename algorithmFPType>
280 class DAAL_EXPORT Online<algorithmFPType, svdDense> : public Analysis<online>
281 {
282 public:
284  Online()
285  {
286  initialize();
287  }
288 
294  Online(const Online<algorithmFPType, svdDense> &other) : input(other.input), parameter(other.parameter)
295  {
296  initialize();
297  }
298 
299  ~Online() {}
300 
305  int getMethod() const DAAL_C11_OVERRIDE { return(int)svdDense; }
306 
311  services::Status setPartialResult(const services::SharedPtr<PartialResult<svdDense> >& partialResult)
312  {
313  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
314  _partialResult = partialResult;
315  _pres = _partialResult.get();
316  return services::Status();
317  }
318 
323  services::Status setResult(const ResultPtr& res)
324  {
325  DAAL_CHECK(res, services::ErrorNullResult)
326  _result = res;
327  _res = _result.get();
328  return services::Status();
329  }
330 
335  services::SharedPtr<PartialResult<svdDense> > getPartialResult()
336  {
337  return _partialResult;
338  }
339 
344  ResultPtr getResult()
345  {
346  return _result;
347  }
348 
354  services::SharedPtr<Online<algorithmFPType, svdDense> > clone() const
355  {
356  return services::SharedPtr<Online<algorithmFPType, svdDense> >(cloneImpl());
357  }
358 
359  Input input;
360  OnlineParameter<algorithmFPType, svdDense> parameter;
362 protected:
363  services::SharedPtr<PartialResult<svdDense> > _partialResult;
364  ResultPtr _result;
365 
366  virtual Online<algorithmFPType, svdDense> * cloneImpl() const DAAL_C11_OVERRIDE
367  {
368  return new Online<algorithmFPType, svdDense>(*this);
369  }
370 
371  services::Status allocateResult() DAAL_C11_OVERRIDE
372  {
373  services::Status s = _result->allocate<algorithmFPType>(_pres, &parameter, svdDense);
374  _res = _result.get();
375  return s;
376  }
377 
378  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
379  {
380  services::Status s = _partialResult->allocate<algorithmFPType>(&input, &parameter, svdDense);
381  _pres = _partialResult.get();
382  return s;
383  }
384 
385  services::Status initializePartialResult() DAAL_C11_OVERRIDE
386  {
387  services::Status s = _partialResult->initialize<algorithmFPType>(&input, &parameter, svdDense);
388  _pres = _partialResult.get();
389  return s;
390  }
391 
392  void initialize()
393  {
394  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, svdDense)(&_env);
395  _in = &input;
396  _par = &parameter;
397  _partialResult.reset(new PartialResult<svdDense>());
398  _result.reset(new Result());
399  }
400 };
402 } // namespace interface1
403 using interface1::OnlineContainer;
404 using interface1::Online;
405 
406 }
407 }
408 }
409 #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
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:175
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::clone
services::SharedPtr< Online< algorithmFPType, correlationDense > > clone() const
Definition: pca_online.h:224
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< svdDense > > &partialResult)
Definition: pca_online.h:311
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >
Computes the results of the PCA SVD algorithm.
Definition: pca_online.h:280
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:323
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::Online
Online()
Definition: pca_online.h:284
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::getPartialResult
services::SharedPtr< PartialResult< svdDense > > getPartialResult()
Definition: pca_online.h:335
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::parameter
OnlineParameter< algorithmFPType, correlationDense > parameter
Definition: pca_online.h:230
daal_defines.h
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::input
Input input
Definition: pca_online.h:359
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::getMethod
int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_online.h:305
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_online.h:193
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::getPartialResult
services::SharedPtr< PartialResult< correlationDense > > getPartialResult()
Definition: pca_online.h:205
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::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::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::getResult
ResultPtr getResult()
Definition: pca_online.h:344
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::parameter
OnlineParameter< algorithmFPType, svdDense > parameter
Definition: pca_online.h:360
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:164
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::clone
services::SharedPtr< Online< algorithmFPType, svdDense > > clone() const
Definition: pca_online.h:354
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::Online
Online()
Definition: pca_online.h:154
daal::online
Definition: daal_defines.h:133
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::input
Input input
Definition: pca_online.h:229
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::getResult
ResultPtr getResult()
Definition: pca_online.h:214
daal::algorithms::pca::interface1::Online< algorithmFPType, correlationDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< correlationDense > > &partialResult)
Definition: pca_online.h:181
daal::algorithms::pca::interface1::Online< algorithmFPType, svdDense >::Online
Online(const Online< algorithmFPType, svdDense > &other)
Definition: pca_online.h:294
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.