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

covariance_types.h
1 /* file: covariance_types.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 // Definition of Covariance common types.
21 //--
22 */
23 
24 #ifndef __COVARIANCE_TYPES_H__
25 #define __COVARIANCE_TYPES_H__
26 
27 #include "data_management/data/homogen_numeric_table.h"
28 
29 namespace daal
30 {
31 namespace algorithms
32 {
42 namespace covariance
43 {
48 enum Method
49 {
50  defaultDense = 0,
51  singlePassDense = 1,
53  sumDense = 2,
55  fastCSR = 3,
56  singlePassCSR = 4,
58  sumCSR = 5
60 };
61 
66 enum InputId
67 {
68  data,
69  lastInputId = data
70 };
71 
76 enum PartialResultId
77 {
78  nObservations,
79  crossProduct,
80  sum,
81  lastPartialResultId = sum
82 };
83 
88 enum ResultId
89 {
90  covariance,
91  correlation = covariance,
92  mean,
93  lastResultId = mean
94 };
95 
100 enum OutputMatrixType
101 {
102  covarianceMatrix,
103  correlationMatrix
104 };
105 
110 enum MasterInputId
111 {
112  partialResults,
113  lastMasterInputId = partialResults
114 };
115 
119 namespace interface1
120 {
125 class DAAL_EXPORT InputIface : public daal::algorithms::Input
126 {
127 public:
128  InputIface(size_t nElements) : daal::algorithms::Input(nElements) {}
129  InputIface(const InputIface& other) : daal::algorithms::Input(other){}
130  virtual size_t getNumberOfFeatures() const = 0;
131  virtual ~InputIface() {}
132 };
133 
138 class DAAL_EXPORT Input : public InputIface
139 {
140 public:
141  Input();
142  Input(const Input& other) : InputIface(other){}
143 
144  virtual ~Input() {}
145 
150  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
151 
157  data_management::NumericTablePtr get(InputId id) const;
158 
164  void set(InputId id, const data_management::NumericTablePtr &ptr);
165 
171  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
172 };
173 
180 class DAAL_EXPORT PartialResult : public daal::algorithms::PartialResult
181 {
182 public:
183  DECLARE_SERIALIZABLE_CAST(PartialResult);
184  PartialResult();
185 
186  virtual ~PartialResult()
187  {}
188 
195  template <typename algorithmFPType>
196  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
197 
205  template <typename algorithmFPType>
206  DAAL_EXPORT services::Status initialize(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
207 
212  size_t getNumberOfFeatures() const;
213 
219  data_management::NumericTablePtr get(PartialResultId id) const;
220 
226  void set(PartialResultId id, const data_management::NumericTablePtr &ptr);
227 
234  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
235 
241  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
242 
243 protected:
244 
245  services::Status checkImpl(size_t nFeatures) const;
246 
248  template<typename Archive, bool onDeserialize>
249  services::Status serialImpl(Archive *arch)
250  {
251  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
252  }
253 };
254 typedef services::SharedPtr<PartialResult> PartialResultPtr;
255 
260 struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
261 {
263  Parameter();
264  OutputMatrixType outputMatrixType;
265 };
266 
271 struct DAAL_EXPORT OnlineParameter : public Parameter
272 {
274  OnlineParameter();
275 
280  OnlineParameter(const OnlineParameter& other);
281 
285  services::Status check() const DAAL_C11_OVERRIDE;
286 };
287 
293 class DAAL_EXPORT Result : public daal::algorithms::Result
294 {
295 public:
296  DECLARE_SERIALIZABLE_CAST(Result);
297  Result();
298 
299  virtual ~Result() {}
300 
307  template <typename algorithmFPType>
308  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
309 
316  template <typename algorithmFPType>
317  DAAL_EXPORT services::Status allocate(const daal::algorithms::PartialResult *partialResult, const daal::algorithms::Parameter *parameter, const int method);
318 
324  data_management::NumericTablePtr get(ResultId id) const;
325 
331  void set(ResultId id, const data_management::NumericTablePtr &value);
332 
339  services::Status check(const daal::algorithms::PartialResult *partialResult, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
340 
347  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
348 
349 protected:
350 
351  services::Status checkImpl(size_t nFeatures, OutputMatrixType outputMatrixType) const;
352 
354  template<typename Archive, bool onDeserialize>
355  services::Status serialImpl(Archive *arch)
356  {
357  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
358  }
359 };
360 typedef services::SharedPtr<Result> ResultPtr;
361 
368 template<ComputeStep step>
369 class DistributedInput {};
370 
376 template<>
377 class DAAL_EXPORT DistributedInput<step1Local> : public Input
378 {
379 public:
380  DistributedInput() : Input()
381  {}
382  DistributedInput(const DistributedInput& other) : Input(other)
383  {}
384 
385  virtual ~DistributedInput()
386  {}
387 };
388 
394 template<>
395 class DAAL_EXPORT DistributedInput<step2Master> : public InputIface
396 {
397 public:
398  DistributedInput();
399  DistributedInput(const DistributedInput& other) : InputIface(other)
400  {}
401 
402  virtual ~DistributedInput()
403  {}
404 
409  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
410 
416  void add(MasterInputId id, const PartialResultPtr &partialResult);
417 
423  data_management::DataCollectionPtr get(MasterInputId id) const;
424 
430  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
431 };
433 } // namespace interface1
434 using interface1::InputIface;
435 using interface1::Input;
436 using interface1::PartialResult;
437 using interface1::PartialResultPtr;
438 using interface1::Parameter;
439 using interface1::OnlineParameter;
440 using interface1::Result;
441 using interface1::ResultPtr;
442 using interface1::DistributedInput;
443 
444 } // namespace daal::algorithms::covariance
445 }
446 } // namespace daal
447 #endif // __COVARIANCE_TYPES_H__
daal::step1Local
Definition: daal_defines.h:123
daal::algorithms::covariance::interface1::InputIface
Abstract class that specifies interface for classes that declare input of the correlation or variance...
Definition: covariance_types.h:125
daal::algorithms::covariance::ResultId
ResultId
Available identifiers of results of the correlation or variance-covariance matrix algorithm...
Definition: covariance_types.h:88
daal::algorithms::covariance::InputId
InputId
Definition: covariance_types.h:66
daal::algorithms::covariance::correlationMatrix
Definition: covariance_types.h:103
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:293
daal::algorithms::covariance::covariance
Definition: covariance_types.h:90
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:180
daal::algorithms::covariance::mean
Definition: covariance_types.h:92
daal::algorithms::covariance::Method
Method
Definition: covariance_types.h:48
daal::step2Master
Definition: daal_defines.h:124
daal::algorithms::covariance::nObservations
Definition: covariance_types.h:78
daal::algorithms::covariance::partialResults
Definition: covariance_types.h:112
daal::algorithms::covariance::defaultDense
Definition: covariance_types.h:50
daal::algorithms::covariance::OutputMatrixType
OutputMatrixType
Definition: covariance_types.h:100
daal::algorithms::covariance::sumCSR
Definition: covariance_types.h:58
daal::algorithms::covariance::interface1::DistributedInput
Input parameters of the distributed Covariance algorithm.
Definition: covariance_types.h:369
daal::algorithms::covariance::interface1::OnlineParameter
Parameters of the correlation or variance-covariance matrix algorithm in the online processing mode...
Definition: covariance_types.h:271
daal::algorithms::covariance::correlation
Definition: covariance_types.h:91
daal::algorithms::covariance::PartialResultId
PartialResultId
Definition: covariance_types.h:76
daal::algorithms::covariance::data
Definition: covariance_types.h:68
daal::algorithms::covariance::singlePassCSR
Definition: covariance_types.h:56
daal::algorithms::covariance::crossProduct
Definition: covariance_types.h:79
daal::algorithms::covariance::fastCSR
Definition: covariance_types.h:55
daal::algorithms::covariance::covarianceMatrix
Definition: covariance_types.h:102
daal::algorithms::covariance::singlePassDense
Definition: covariance_types.h:51
daal::algorithms::covariance::interface1::Input
Input objects of the correlation or variance-covariance matrix algorithm
Definition: covariance_types.h:138
daal::algorithms::covariance::sum
Definition: covariance_types.h:80
daal::algorithms::covariance::MasterInputId
MasterInputId
Available identifiers of master node input arguments of the Covariance algorithm. ...
Definition: covariance_types.h:110
daal::algorithms::covariance::sumDense
Definition: covariance_types.h:53
daal::algorithms::math::abs::value
Definition: abs_types.h:88
daal::algorithms::covariance::interface1::Parameter
Parameters of the correlation or variance-covariance matrix algorithm.
Definition: covariance_types.h:260
daal::algorithms::covariance::interface1::Parameter::outputMatrixType
OutputMatrixType outputMatrixType
Definition: covariance_types.h:264

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