C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 4

covariance_types.h
1 /* file: covariance_types.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 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 // Definition of Covariance common types.
19 //--
20 */
21 
22 #ifndef __COVARIANCE_TYPES_H__
23 #define __COVARIANCE_TYPES_H__
24 
25 #include "data_management/data/homogen_numeric_table.h"
26 
27 namespace daal
28 {
29 namespace algorithms
30 {
40 namespace covariance
41 {
46 enum Method
47 {
48  defaultDense = 0,
49  singlePassDense = 1,
51  sumDense = 2,
53  fastCSR = 3,
54  singlePassCSR = 4,
56  sumCSR = 5
58 };
59 
64 enum InputId
65 {
66  data,
67  lastInputId = data
68 };
69 
74 enum PartialResultId
75 {
76  nObservations,
77  crossProduct,
78  sum,
79  lastPartialResultId = sum
80 };
81 
86 enum ResultId
87 {
88  covariance,
89  correlation = covariance,
90  mean,
91  lastResultId = mean
92 };
93 
98 enum OutputMatrixType
99 {
100  covarianceMatrix,
101  correlationMatrix
102 };
103 
108 enum MasterInputId
109 {
110  partialResults,
111  lastMasterInputId = partialResults
112 };
113 
117 namespace interface1
118 {
123 class DAAL_EXPORT InputIface : public daal::algorithms::Input
124 {
125 public:
126  InputIface(size_t nElements) : daal::algorithms::Input(nElements) {}
127  InputIface(const InputIface& other) : daal::algorithms::Input(other){}
128  virtual size_t getNumberOfFeatures() const = 0;
129  virtual ~InputIface() {}
130 };
131 
136 class DAAL_EXPORT Input : public InputIface
137 {
138 public:
139  Input();
140  Input(const Input& other) : InputIface(other){}
141 
142  virtual ~Input() {}
143 
148  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
149 
155  data_management::NumericTablePtr get(InputId id) const;
156 
162  void set(InputId id, const data_management::NumericTablePtr &ptr);
163 
169  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
170 };
171 
178 class DAAL_EXPORT PartialResult : public daal::algorithms::PartialResult
179 {
180 public:
181  DECLARE_SERIALIZABLE_CAST(PartialResult);
182  PartialResult();
183 
184  virtual ~PartialResult()
185  {}
186 
193  template <typename algorithmFPType>
194  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
195 
203  template <typename algorithmFPType>
204  DAAL_EXPORT services::Status initialize(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
205 
210  size_t getNumberOfFeatures() const;
211 
217  data_management::NumericTablePtr get(PartialResultId id) const;
218 
224  void set(PartialResultId id, const data_management::NumericTablePtr &ptr);
225 
232  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
233 
239  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
240 
241 protected:
242 
243  services::Status checkImpl(size_t nFeatures) const;
244 
246  template<typename Archive, bool onDeserialize>
247  services::Status serialImpl(Archive *arch)
248  {
249  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
250  }
251 };
252 typedef services::SharedPtr<PartialResult> PartialResultPtr;
253 
258 struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
259 {
261  Parameter();
262  OutputMatrixType outputMatrixType;
263 };
264 
269 struct DAAL_EXPORT OnlineParameter : public Parameter
270 {
272  OnlineParameter();
273 
278  OnlineParameter(const OnlineParameter& other);
279 
283  services::Status check() const DAAL_C11_OVERRIDE;
284 };
285 
291 class DAAL_EXPORT Result : public daal::algorithms::Result
292 {
293 public:
294  DECLARE_SERIALIZABLE_CAST(Result);
295  Result();
296 
297  virtual ~Result() {};
298 
305  template <typename algorithmFPType>
306  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
307 
314  template <typename algorithmFPType>
315  DAAL_EXPORT services::Status allocate(const daal::algorithms::PartialResult *partialResult, const daal::algorithms::Parameter *parameter, const int method);
316 
322  data_management::NumericTablePtr get(ResultId id) const;
323 
329  void set(ResultId id, const data_management::NumericTablePtr &value);
330 
337  services::Status check(const daal::algorithms::PartialResult *partialResult, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
338 
345  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
346 
347 protected:
348 
349  services::Status checkImpl(size_t nFeatures, OutputMatrixType outputMatrixType) const;
350 
352  template<typename Archive, bool onDeserialize>
353  services::Status serialImpl(Archive *arch)
354  {
355  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
356  }
357 };
358 typedef services::SharedPtr<Result> ResultPtr;
359 
366 template<ComputeStep step>
367 class DistributedInput {};
368 
374 template<>
375 class DAAL_EXPORT DistributedInput<step1Local> : public Input
376 {
377 public:
378  DistributedInput() : Input()
379  {}
380  DistributedInput(const DistributedInput& other) : Input(other)
381  {}
382 
383  virtual ~DistributedInput()
384  {}
385 };
386 
392 template<>
393 class DAAL_EXPORT DistributedInput<step2Master> : public InputIface
394 {
395 public:
396  DistributedInput();
397  DistributedInput(const DistributedInput& other) : InputIface(other)
398  {}
399 
400  virtual ~DistributedInput()
401  {}
402 
407  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
408 
414  void add(MasterInputId id, const PartialResultPtr &partialResult);
415 
421  data_management::DataCollectionPtr get(MasterInputId id) const;
422 
428  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
429 };
431 } // namespace interface1
432 using interface1::InputIface;
433 using interface1::Input;
434 using interface1::PartialResult;
435 using interface1::PartialResultPtr;
436 using interface1::Parameter;
437 using interface1::OnlineParameter;
438 using interface1::Result;
439 using interface1::ResultPtr;
440 using interface1::DistributedInput;
441 
442 } // namespace daal::algorithms::covariance
443 }
444 } // namespace daal
445 #endif // __COVARIANCE_TYPES_H__
daal::algorithms::covariance::singlePassCSR
Definition: covariance_types.h:54
daal::algorithms::covariance::interface1::OnlineParameter
Parameters of the correlation or variance-covariance matrix algorithm in the online processing mode...
Definition: covariance_types.h:269
daal::algorithms::covariance::crossProduct
Definition: covariance_types.h:77
daal
Definition: algorithm_base_common.h:31
daal::algorithms::covariance::interface1::InputIface
Abstract class that specifies interface for classes that declare input of the correlation or variance...
Definition: covariance_types.h:123
daal::algorithms::covariance::interface1::Parameter
Parameters of the correlation or variance-covariance matrix algorithm.
Definition: covariance_types.h:258
daal::algorithms::covariance::Method
Method
Definition: covariance_types.h:46
daal::algorithms::covariance::PartialResultId
PartialResultId
Definition: covariance_types.h:74
daal::algorithms::covariance::interface1::DistributedInput
Input parameters of the distributed Covariance algorithm.
Definition: covariance_types.h:367
daal::algorithms::covariance::interface1::Input
Input objects of the correlation or variance-covariance matrix algorithm
Definition: covariance_types.h:136
daal::algorithms::covariance::sumDense
Definition: covariance_types.h:51
daal::algorithms::covariance::fastCSR
Definition: covariance_types.h:53
daal::algorithms::covariance::data
Definition: covariance_types.h:66
daal::algorithms::covariance::MasterInputId
MasterInputId
Available identifiers of master node input arguments of the Covariance algorithm. ...
Definition: covariance_types.h:108
daal::algorithms::covariance::sum
Definition: covariance_types.h:78
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:291
daal::algorithms::covariance::sumCSR
Definition: covariance_types.h:56
daal::algorithms::covariance::partialResults
Definition: covariance_types.h:110
daal::algorithms::covariance::interface1::PartialResult
Provides methods to access partial results obtained with the compute() method of the correlation or v...
Definition: covariance_types.h:178
daal::algorithms::covariance::ResultId
ResultId
Available identifiers of results of the correlation or variance-covariance matrix algorithm...
Definition: covariance_types.h:86
daal::algorithms::covariance::mean
Definition: covariance_types.h:90
daal::algorithms::covariance::InputId
InputId
Definition: covariance_types.h:64
daal::algorithms::covariance::interface1::Parameter::outputMatrixType
OutputMatrixType outputMatrixType
Definition: covariance_types.h:262
daal::algorithms::covariance::OutputMatrixType
OutputMatrixType
Definition: covariance_types.h:98
daal::algorithms::covariance::covariance
Definition: covariance_types.h:88
daal::algorithms::covariance::correlationMatrix
Definition: covariance_types.h:101
daal::algorithms::math::abs::value
Definition: abs_types.h:86
daal::step1Local
Definition: daal_defines.h:121
daal::step2Master
Definition: daal_defines.h:122
daal::algorithms::covariance::covarianceMatrix
Definition: covariance_types.h:100
daal::algorithms::covariance::defaultDense
Definition: covariance_types.h:48
daal::algorithms::covariance::correlation
Definition: covariance_types.h:89
daal::algorithms::covariance::nObservations
Definition: covariance_types.h:76
daal::algorithms::covariance::singlePassDense
Definition: covariance_types.h:49

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