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

covariance_batch.h
1 /* file: covariance_batch.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 correlation or variance-covariance
45 // matrix algorithm in the batch processing mode
46 //--
47 */
48 
49 #ifndef __COVARIANCE_BATCH_H__
50 #define __COVARIANCE_BATCH_H__
51 
52 #include "algorithms/algorithm.h"
53 #include "data_management/data/numeric_table.h"
54 #include "services/daal_defines.h"
55 #include "algorithms/covariance/covariance_types.h"
56 
57 namespace daal
58 {
59 namespace algorithms
60 {
61 namespace covariance
62 {
63 
64 namespace interface1
65 {
76 class BatchContainerIface : public daal::algorithms::AnalysisContainerIface<batch>
77 {
78 public:
80  BatchContainerIface() {};
82  virtual ~BatchContainerIface() {}
83 
88  virtual services::Status compute() = 0;
89 };
90 
99 template<typename algorithmFPType, Method method, CpuType cpu>
100 class DAAL_EXPORT BatchContainer
101 {};
102 
111 template<typename algorithmFPType, CpuType cpu>
112 class DAAL_EXPORT BatchContainer<algorithmFPType, defaultDense, cpu> : public BatchContainerIface
113 {
114 public:
120  BatchContainer(daal::services::Environment::env *daalEnv);
122  virtual ~BatchContainer();
123 
128  virtual services::Status compute() DAAL_C11_OVERRIDE;
129 };
130 
139 template<typename algorithmFPType, CpuType cpu>
140 class DAAL_EXPORT BatchContainer<algorithmFPType, singlePassDense, cpu> : public BatchContainerIface
141 {
142 public:
148  BatchContainer(daal::services::Environment::env *daalEnv);
150  virtual ~BatchContainer();
151 
156  virtual services::Status compute() DAAL_C11_OVERRIDE;
157 };
158 
167 template<typename algorithmFPType, CpuType cpu>
168 class DAAL_EXPORT BatchContainer<algorithmFPType, sumDense, cpu> : public BatchContainerIface
169 {
170 public:
176  BatchContainer(daal::services::Environment::env *daalEnv);
178  virtual ~BatchContainer();
179 
184  virtual services::Status compute() DAAL_C11_OVERRIDE;
185 };
186 
195 template<typename algorithmFPType, CpuType cpu>
196 class DAAL_EXPORT BatchContainer<algorithmFPType, fastCSR, cpu> : public BatchContainerIface
197 {
198 public:
204  BatchContainer(daal::services::Environment::env *daalEnv);
206  virtual ~BatchContainer();
207 
212  virtual services::Status compute() DAAL_C11_OVERRIDE;
213 };
214 
223 template<typename algorithmFPType, CpuType cpu>
224 class DAAL_EXPORT BatchContainer<algorithmFPType, singlePassCSR, cpu> : public BatchContainerIface
225 {
226 public:
232  BatchContainer(daal::services::Environment::env *daalEnv);
234  virtual ~BatchContainer();
235 
240  virtual services::Status compute() DAAL_C11_OVERRIDE;
241 };
242 
251 template<typename algorithmFPType, CpuType cpu>
252 class DAAL_EXPORT BatchContainer<algorithmFPType, sumCSR, cpu> : public BatchContainerIface
253 {
254 public:
260  BatchContainer(daal::services::Environment::env *daalEnv);
262  virtual ~BatchContainer();
263 
268  virtual services::Status compute() DAAL_C11_OVERRIDE;
269 };
270 
276 class DAAL_EXPORT BatchImpl : public daal::algorithms::Analysis<batch>
277 {
278 public:
279  typedef algorithms::covariance::Input InputType;
280  typedef algorithms::covariance::Parameter ParameterType;
281  typedef algorithms::covariance::Result ResultType;
282 
284  BatchImpl()
285  {
286  initialize();
287  };
288 
296  BatchImpl(const BatchImpl &other) : input(other.input), parameter(other.parameter)
297  {
298  initialize();
299  }
300 
305  ResultPtr getResult()
306  {
307  return _result;
308  };
309 
314  virtual services::Status setResult(const ResultPtr &result)
315  {
316  DAAL_CHECK(result, services::ErrorNullResult)
317  _result = result;
318  _res = _result.get();
319  return services::Status();
320  }
321 
328  services::SharedPtr<BatchImpl> clone() const
329  {
330  return services::SharedPtr<BatchImpl>(cloneImpl());
331  }
332 
333  virtual ~BatchImpl() {}
334 
335  InputType input;
336  ParameterType parameter;
338 protected:
339  ResultPtr _result;
340 
341  void initialize()
342  {
343  _result.reset(new ResultType());
344  _in = &input;
345  _par = &parameter;
346  }
347  virtual BatchImpl * cloneImpl() const DAAL_C11_OVERRIDE = 0;
348 };
349 
368 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
369 class DAAL_EXPORT Batch : public BatchImpl
370 {
371 public:
372  typedef BatchImpl super;
373 
374  typedef typename super::InputType InputType;
375  typedef typename super::ParameterType ParameterType;
376  typedef typename super::ResultType ResultType;
377 
379  Batch()
380  {
381  initialize();
382  }
383 
391  Batch(const Batch<algorithmFPType, method> &other) : BatchImpl(other)
392  {
393  initialize();
394  }
395 
396  virtual ~Batch() {}
397 
402  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
403 
410  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
411  {
412  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
413  }
414 
415 protected:
416  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
417  {
418  return new Batch<algorithmFPType, method>(*this);
419  }
420 
421  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
422  {
423  services::Status s = _result->allocate<algorithmFPType>(&input, _par, (int)method);
424  _res = _result.get();
425  return s;
426  }
427 
428  void initialize()
429  {
430  this->_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
431  }
432 };
434 } // namespace interface1
435 using interface1::BatchContainerIface;
436 using interface1::BatchContainer;
437 using interface1::BatchImpl;
438 using interface1::Batch;
439 
440 } // namespace daal::algorithms::covariance
441 }
442 } // namespace daal
443 #endif // __COVARIANCE_BATCH_H__
daal::algorithms::covariance::singlePassCSR
Definition: covariance_types.h:80
daal::algorithms::covariance::interface1::BatchImpl::clone
services::SharedPtr< BatchImpl > clone() const
Definition: covariance_batch.h:328
daal::algorithms::covariance::interface1::BatchContainerIface
Class that specifies interfaces of implementations of the correlation or variance-covariance matrix c...
Definition: covariance_batch.h:76
daal::algorithms::covariance::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: covariance_batch.h:410
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::covariance::interface1::BatchContainer
Provides methods to run implementations of the correlation or variance-covariance matrix algorithm...
Definition: covariance_batch.h:100
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:79
daal::algorithms::covariance::interface1::Parameter
Parameters of the correlation or variance-covariance matrix algorithm.
Definition: covariance_types.h:284
daal::algorithms::covariance::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: covariance_batch.h:402
daal::algorithms::covariance::interface1::BatchImpl::BatchImpl
BatchImpl()
Definition: covariance_batch.h:284
daal::algorithms::covariance::interface1::Input
Input objects of the correlation or variance-covariance matrix algorithm
Definition: covariance_types.h:162
daal_defines.h
daal::algorithms::covariance::sumDense
Definition: covariance_types.h:77
daal::algorithms::covariance::interface1::Batch::Batch
Batch()
Definition: covariance_batch.h:379
daal::algorithms::covariance::interface1::BatchImpl::input
InputType input
Definition: covariance_batch.h:335
daal::algorithms::covariance::fastCSR
Definition: covariance_types.h:79
daal::batch
Definition: daal_defines.h:132
daal::algorithms::covariance::interface1::BatchContainerIface::~BatchContainerIface
virtual ~BatchContainerIface()
Definition: covariance_batch.h:82
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::covariance::interface1::Result
Provides methods to access final results obtained with the compute() method of the correlation or var...
Definition: covariance_types.h:317
daal::algorithms::covariance::interface1::BatchImpl::getResult
ResultPtr getResult()
Definition: covariance_batch.h:305
daal::services::interface1::SharedPtr::get
T * get() const
Definition: daal_shared_ptr.h:332
daal::algorithms::covariance::sumCSR
Definition: covariance_types.h:82
daal::algorithms::covariance::interface1::BatchImpl::setResult
virtual services::Status setResult(const ResultPtr &result)
Definition: covariance_batch.h:314
daal::services::interface1::SharedPtr::reset
void reset()
Definition: daal_shared_ptr.h:265
daal::algorithms::covariance::interface1::BatchContainerIface::BatchContainerIface
BatchContainerIface()
Definition: covariance_batch.h:80
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
daal::algorithms::covariance::covariance
Definition: covariance_types.h:114
daal::algorithms::covariance::interface1::BatchImpl::parameter
ParameterType parameter
Definition: covariance_batch.h:336
daal::algorithms::covariance::interface1::BatchImpl::BatchImpl
BatchImpl(const BatchImpl &other)
Definition: covariance_batch.h:296
daal::algorithms::covariance::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: covariance_batch.h:391
daal::algorithms::covariance::interface1::Batch
Computes correlation or variance-covariance matrix in the batch processing mode.
Definition: covariance_batch.h:369
daal::algorithms::covariance::defaultDense
Definition: covariance_types.h:74
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:276
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::covariance::singlePassDense
Definition: covariance_types.h:75

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