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

covariance_batch.h
1 /* file: covariance_batch.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 correlation or variance-covariance
19 // matrix algorithm in the batch processing mode
20 //--
21 */
22 
23 #ifndef __COVARIANCE_BATCH_H__
24 #define __COVARIANCE_BATCH_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "algorithms/covariance/covariance_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace covariance
36 {
37 
38 namespace interface1
39 {
50 class BatchContainerIface : public daal::algorithms::AnalysisContainerIface<batch>
51 {
52 public:
54  BatchContainerIface() {};
56  virtual ~BatchContainerIface() {}
57 
62  virtual services::Status compute() = 0;
63 };
64 
73 template<typename algorithmFPType, Method method, CpuType cpu>
74 class DAAL_EXPORT BatchContainer
75 {};
76 
85 template<typename algorithmFPType, CpuType cpu>
86 class DAAL_EXPORT BatchContainer<algorithmFPType, defaultDense, cpu> : public BatchContainerIface
87 {
88 public:
94  BatchContainer(daal::services::Environment::env *daalEnv);
96  virtual ~BatchContainer();
97 
102  virtual services::Status compute() DAAL_C11_OVERRIDE;
103 };
104 
113 template<typename algorithmFPType, CpuType cpu>
114 class DAAL_EXPORT BatchContainer<algorithmFPType, singlePassDense, cpu> : public BatchContainerIface
115 {
116 public:
122  BatchContainer(daal::services::Environment::env *daalEnv);
124  virtual ~BatchContainer();
125 
130  virtual services::Status compute() DAAL_C11_OVERRIDE;
131 };
132 
141 template<typename algorithmFPType, CpuType cpu>
142 class DAAL_EXPORT BatchContainer<algorithmFPType, sumDense, cpu> : public BatchContainerIface
143 {
144 public:
150  BatchContainer(daal::services::Environment::env *daalEnv);
152  virtual ~BatchContainer();
153 
158  virtual services::Status compute() DAAL_C11_OVERRIDE;
159 };
160 
169 template<typename algorithmFPType, CpuType cpu>
170 class DAAL_EXPORT BatchContainer<algorithmFPType, fastCSR, cpu> : public BatchContainerIface
171 {
172 public:
178  BatchContainer(daal::services::Environment::env *daalEnv);
180  virtual ~BatchContainer();
181 
186  virtual services::Status compute() DAAL_C11_OVERRIDE;
187 };
188 
197 template<typename algorithmFPType, CpuType cpu>
198 class DAAL_EXPORT BatchContainer<algorithmFPType, singlePassCSR, cpu> : public BatchContainerIface
199 {
200 public:
206  BatchContainer(daal::services::Environment::env *daalEnv);
208  virtual ~BatchContainer();
209 
214  virtual services::Status compute() DAAL_C11_OVERRIDE;
215 };
216 
225 template<typename algorithmFPType, CpuType cpu>
226 class DAAL_EXPORT BatchContainer<algorithmFPType, sumCSR, cpu> : public BatchContainerIface
227 {
228 public:
234  BatchContainer(daal::services::Environment::env *daalEnv);
236  virtual ~BatchContainer();
237 
242  virtual services::Status compute() DAAL_C11_OVERRIDE;
243 };
244 
250 class DAAL_EXPORT BatchImpl : public daal::algorithms::Analysis<batch>
251 {
252 public:
253  typedef algorithms::covariance::Input InputType;
254  typedef algorithms::covariance::Parameter ParameterType;
255  typedef algorithms::covariance::Result ResultType;
256 
258  BatchImpl()
259  {
260  initialize();
261  };
262 
270  BatchImpl(const BatchImpl &other) : input(other.input), parameter(other.parameter)
271  {
272  initialize();
273  }
274 
279  ResultPtr getResult()
280  {
281  return _result;
282  };
283 
288  virtual services::Status setResult(const ResultPtr &result)
289  {
290  DAAL_CHECK(result, services::ErrorNullResult)
291  _result = result;
292  _res = _result.get();
293  return services::Status();
294  }
295 
302  services::SharedPtr<BatchImpl> clone() const
303  {
304  return services::SharedPtr<BatchImpl>(cloneImpl());
305  }
306 
307  virtual ~BatchImpl() {}
308 
309  InputType input;
310  ParameterType parameter;
312 protected:
313  ResultPtr _result;
314 
315  void initialize()
316  {
317  _result.reset(new ResultType());
318  _in = &input;
319  _par = &parameter;
320  }
321  virtual BatchImpl * cloneImpl() const DAAL_C11_OVERRIDE = 0;
322 };
323 
342 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
343 class DAAL_EXPORT Batch : public BatchImpl
344 {
345 public:
346  typedef BatchImpl super;
347 
348  typedef typename super::InputType InputType;
349  typedef typename super::ParameterType ParameterType;
350  typedef typename super::ResultType ResultType;
351 
353  Batch()
354  {
355  initialize();
356  }
357 
365  Batch(const Batch<algorithmFPType, method> &other) : BatchImpl(other)
366  {
367  initialize();
368  }
369 
370  virtual ~Batch() {}
371 
376  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
377 
384  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
385  {
386  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
387  }
388 
389 protected:
390  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
391  {
392  return new Batch<algorithmFPType, method>(*this);
393  }
394 
395  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
396  {
397  services::Status s = _result->allocate<algorithmFPType>(&input, _par, (int)method);
398  _res = _result.get();
399  return s;
400  }
401 
402  void initialize()
403  {
404  this->_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
405  }
406 };
408 } // namespace interface1
409 using interface1::BatchContainerIface;
410 using interface1::BatchContainer;
411 using interface1::BatchImpl;
412 using interface1::Batch;
413 
414 } // namespace daal::algorithms::covariance
415 }
416 } // namespace daal
417 #endif // __COVARIANCE_BATCH_H__
daal::algorithms::covariance::singlePassCSR
Definition: covariance_types.h:54
daal::algorithms::covariance::interface1::BatchContainerIface
Class that specifies interfaces of implementations of the correlation or variance-covariance matrix c...
Definition: covariance_batch.h:50
daal
Definition: algorithm_base_common.h:31
daal::algorithms::covariance::interface1::BatchContainer
Provides methods to run implementations of the correlation or variance-covariance matrix algorithm...
Definition: covariance_batch.h:74
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::covariance::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: covariance_batch.h:376
daal::algorithms::covariance::Method
Method
Definition: covariance_types.h:46
daal::algorithms::covariance::interface1::BatchImpl::BatchImpl
BatchImpl()
Definition: covariance_batch.h:258
daal_defines.h
daal::algorithms::covariance::sumDense
Definition: covariance_types.h:51
daal::algorithms::covariance::interface1::Batch::Batch
Batch()
Definition: covariance_batch.h:353
daal::algorithms::covariance::interface1::BatchImpl::input
InputType input
Definition: covariance_batch.h:309
daal::algorithms::covariance::fastCSR
Definition: covariance_types.h:53
daal::batch
Definition: daal_defines.h:106
daal::algorithms::covariance::interface1::BatchContainerIface::~BatchContainerIface
virtual ~BatchContainerIface()
Definition: covariance_batch.h:56
daal::algorithms::covariance::interface1::BatchImpl::getResult
ResultPtr getResult()
Definition: covariance_batch.h:279
daal::algorithms::covariance::sumCSR
Definition: covariance_types.h:56
daal::algorithms::covariance::interface1::BatchImpl::setResult
virtual services::Status setResult(const ResultPtr &result)
Definition: covariance_batch.h:288
daal::algorithms::covariance::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: covariance_batch.h:384
daal::algorithms::covariance::interface1::BatchContainerIface::BatchContainerIface
BatchContainerIface()
Definition: covariance_batch.h:54
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::covariance::covariance
Definition: covariance_types.h:88
daal::algorithms::covariance::interface1::BatchImpl::parameter
ParameterType parameter
Definition: covariance_batch.h:310
daal::algorithms::covariance::interface1::BatchImpl::BatchImpl
BatchImpl(const BatchImpl &other)
Definition: covariance_batch.h:270
daal::algorithms::covariance::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: covariance_batch.h:365
daal::algorithms::covariance::interface1::Batch
Computes correlation or variance-covariance matrix in the batch processing mode.
Definition: covariance_batch.h:343
daal::algorithms::covariance::interface1::BatchImpl::clone
services::SharedPtr< BatchImpl > clone() const
Definition: covariance_batch.h:302
daal::algorithms::covariance::defaultDense
Definition: covariance_types.h:48
daal::algorithms::covariance::interface1::BatchContainerIface::compute
virtual services::Status compute()=0
daal::algorithms::covariance::interface1::BatchImpl
Abstract class that specifies interface of the algorithms for computing correlation or variance-covar...
Definition: covariance_batch.h:250
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::covariance::singlePassDense
Definition: covariance_types.h:49

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