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

covariance_batch.h
1 /* file: covariance_batch.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 correlation or variance-covariance
21 // matrix algorithm in the batch processing mode
22 //--
23 */
24 
25 #ifndef __COVARIANCE_BATCH_H__
26 #define __COVARIANCE_BATCH_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "services/daal_defines.h"
31 #include "algorithms/covariance/covariance_types.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace covariance
38 {
39 
40 namespace interface1
41 {
52 class BatchContainerIface : public daal::algorithms::AnalysisContainerIface<batch>
53 {
54 public:
56  BatchContainerIface() {}
58  virtual ~BatchContainerIface() {}
59 
64  virtual services::Status compute() = 0;
65 };
66 
75 template<typename algorithmFPType, Method method, CpuType cpu>
76 class BatchContainer
77 {};
78 
87 template<typename algorithmFPType, CpuType cpu>
88 class BatchContainer<algorithmFPType, defaultDense, cpu> : public BatchContainerIface
89 {
90 public:
96  BatchContainer(daal::services::Environment::env *daalEnv);
98  virtual ~BatchContainer();
99 
104  virtual services::Status compute() DAAL_C11_OVERRIDE;
105 };
106 
115 template<typename algorithmFPType, CpuType cpu>
116 class BatchContainer<algorithmFPType, singlePassDense, cpu> : public BatchContainerIface
117 {
118 public:
124  BatchContainer(daal::services::Environment::env *daalEnv);
126  virtual ~BatchContainer();
127 
132  virtual services::Status compute() DAAL_C11_OVERRIDE;
133 };
134 
143 template<typename algorithmFPType, CpuType cpu>
144 class BatchContainer<algorithmFPType, sumDense, cpu> : public BatchContainerIface
145 {
146 public:
152  BatchContainer(daal::services::Environment::env *daalEnv);
154  virtual ~BatchContainer();
155 
160  virtual services::Status compute() DAAL_C11_OVERRIDE;
161 };
162 
171 template<typename algorithmFPType, CpuType cpu>
172 class BatchContainer<algorithmFPType, fastCSR, cpu> : public BatchContainerIface
173 {
174 public:
180  BatchContainer(daal::services::Environment::env *daalEnv);
182  virtual ~BatchContainer();
183 
188  virtual services::Status compute() DAAL_C11_OVERRIDE;
189 };
190 
199 template<typename algorithmFPType, CpuType cpu>
200 class BatchContainer<algorithmFPType, singlePassCSR, cpu> : public BatchContainerIface
201 {
202 public:
208  BatchContainer(daal::services::Environment::env *daalEnv);
210  virtual ~BatchContainer();
211 
216  virtual services::Status compute() DAAL_C11_OVERRIDE;
217 };
218 
227 template<typename algorithmFPType, CpuType cpu>
228 class BatchContainer<algorithmFPType, sumCSR, cpu> : public BatchContainerIface
229 {
230 public:
236  BatchContainer(daal::services::Environment::env *daalEnv);
238  virtual ~BatchContainer();
239 
244  virtual services::Status compute() DAAL_C11_OVERRIDE;
245 };
246 
252 class DAAL_EXPORT BatchImpl : public daal::algorithms::Analysis<batch>
253 {
254 public:
255  typedef algorithms::covariance::Input InputType;
256  typedef algorithms::covariance::Parameter ParameterType;
257  typedef algorithms::covariance::Result ResultType;
258 
260  BatchImpl()
261  {
262  initialize();
263  }
264 
272  BatchImpl(const BatchImpl &other) : input(other.input), parameter(other.parameter)
273  {
274  initialize();
275  }
276 
281  ResultPtr getResult()
282  {
283  return _result;
284  }
285 
290  virtual services::Status setResult(const ResultPtr &result)
291  {
292  DAAL_CHECK(result, services::ErrorNullResult)
293  _result = result;
294  _res = _result.get();
295  return services::Status();
296  }
297 
304  services::SharedPtr<BatchImpl> clone() const
305  {
306  return services::SharedPtr<BatchImpl>(cloneImpl());
307  }
308 
309  virtual ~BatchImpl() {}
310 
311  InputType input;
312  ParameterType parameter;
314 protected:
315  ResultPtr _result;
316 
317  void initialize()
318  {
319  _result.reset(new ResultType());
320  _in = &input;
321  _par = &parameter;
322  }
323  virtual BatchImpl * cloneImpl() const DAAL_C11_OVERRIDE = 0;
324 };
325 
344 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
345 class DAAL_EXPORT Batch : public BatchImpl
346 {
347 public:
348  typedef BatchImpl super;
349 
350  typedef typename super::InputType InputType;
351  typedef typename super::ParameterType ParameterType;
352  typedef typename super::ResultType ResultType;
353 
355  Batch()
356  {
357  initialize();
358  }
359 
367  Batch(const Batch<algorithmFPType, method> &other) : BatchImpl(other)
368  {
369  initialize();
370  }
371 
372  virtual ~Batch() {}
373 
378  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
379 
386  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
387  {
388  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
389  }
390 
391 protected:
392  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
393  {
394  return new Batch<algorithmFPType, method>(*this);
395  }
396 
397  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
398  {
399  services::Status s = _result->allocate<algorithmFPType>(&input, _par, (int)method);
400  _res = _result.get();
401  return s;
402  }
403 
404  void initialize()
405  {
406  this->_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
407  }
408 };
410 } // namespace interface1
411 using interface1::BatchContainerIface;
412 using interface1::BatchContainer;
413 using interface1::BatchImpl;
414 using interface1::Batch;
415 
416 } // namespace daal::algorithms::covariance
417 }
418 } // namespace daal
419 #endif // __COVARIANCE_BATCH_H__
daal::algorithms::covariance::interface1::BatchContainer
Provides methods to run implementations of the correlation or variance-covariance matrix algorithm...
Definition: covariance_batch.h:76
daal::batch
Definition: daal_defines.h:112
daal::algorithms::covariance::interface1::BatchImpl::BatchImpl
BatchImpl()
Definition: covariance_batch.h:260
daal::algorithms::covariance::covariance
Definition: covariance_types.h:90
daal::algorithms::covariance::interface1::BatchImpl
Abstract class that specifies interface of the algorithms for computing correlation or variance-covar...
Definition: covariance_batch.h:252
daal::algorithms::covariance::Method
Method
Definition: covariance_types.h:48
daal::algorithms::covariance::interface1::BatchImpl::parameter
ParameterType parameter
Definition: covariance_batch.h:312
daal::algorithms::covariance::interface1::BatchImpl::getResult
ResultPtr getResult()
Definition: covariance_batch.h:281
daal::algorithms::covariance::interface1::BatchContainerIface
Class that specifies interfaces of implementations of the correlation or variance-covariance matrix c...
Definition: covariance_batch.h:52
daal::algorithms::covariance::interface1::BatchContainerIface::~BatchContainerIface
virtual ~BatchContainerIface()
Definition: covariance_batch.h:58
daal::algorithms::covariance::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: covariance_batch.h:378
daal::algorithms::covariance::interface1::BatchImpl::input
InputType input
Definition: covariance_batch.h:311
daal::algorithms::covariance::interface1::BatchImpl::BatchImpl
BatchImpl(const BatchImpl &other)
Definition: covariance_batch.h:272
daal::algorithms::covariance::defaultDense
Definition: covariance_types.h:50
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::covariance::sumCSR
Definition: covariance_types.h:58
daal_defines.h
daal::algorithms::covariance::singlePassCSR
Definition: covariance_types.h:56
daal::algorithms::covariance::fastCSR
Definition: covariance_types.h:55
daal::algorithms::covariance::singlePassDense
Definition: covariance_types.h:51
daal::algorithms::covariance::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: covariance_batch.h:386
daal::algorithms::covariance::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: covariance_batch.h:367
daal::algorithms::covariance::interface1::BatchContainerIface::compute
virtual services::Status compute()=0
daal::algorithms::covariance::interface1::Batch
Computes correlation or variance-covariance matrix in the batch processing mode.
Definition: covariance_batch.h:345
daal::algorithms::covariance::sumDense
Definition: covariance_types.h:53
daal::algorithms::covariance::interface1::BatchImpl::setResult
virtual services::Status setResult(const ResultPtr &result)
Definition: covariance_batch.h:290
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::covariance::interface1::Batch::Batch
Batch()
Definition: covariance_batch.h:355
daal::algorithms::covariance::interface1::BatchImpl::clone
services::SharedPtr< BatchImpl > clone() const
Definition: covariance_batch.h:304
daal::algorithms::covariance::interface1::BatchContainerIface::BatchContainerIface
BatchContainerIface()
Definition: covariance_batch.h:56

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