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

covariance_types.h
1 /* file: covariance_types.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 // Definition of Covariance common types.
45 //--
46 */
47 
48 #ifndef __COVARIANCE_TYPES_H__
49 #define __COVARIANCE_TYPES_H__
50 
51 #include "data_management/data/homogen_numeric_table.h"
52 
53 namespace daal
54 {
55 namespace algorithms
56 {
66 namespace covariance
67 {
72 enum Method
73 {
74  defaultDense = 0,
75  singlePassDense = 1,
77  sumDense = 2,
79  fastCSR = 3,
80  singlePassCSR = 4,
82  sumCSR = 5
84 };
85 
90 enum InputId
91 {
92  data,
93  lastInputId = data
94 };
95 
100 enum PartialResultId
101 {
102  nObservations,
103  crossProduct,
104  sum,
105  lastPartialResultId = sum
106 };
107 
112 enum ResultId
113 {
114  covariance,
115  correlation = covariance,
116  mean,
117  lastResultId = mean
118 };
119 
124 enum OutputMatrixType
125 {
126  covarianceMatrix,
127  correlationMatrix
128 };
129 
134 enum MasterInputId
135 {
136  partialResults,
137  lastMasterInputId = partialResults
138 };
139 
143 namespace interface1
144 {
149 class DAAL_EXPORT InputIface : public daal::algorithms::Input
150 {
151 public:
152  InputIface(size_t nElements) : daal::algorithms::Input(nElements) {}
153  InputIface(const InputIface& other) : daal::algorithms::Input(other){}
154  virtual size_t getNumberOfFeatures() const = 0;
155  virtual ~InputIface() {}
156 };
157 
162 class DAAL_EXPORT Input : public InputIface
163 {
164 public:
165  Input();
166  Input(const Input& other) : InputIface(other){}
167 
168  virtual ~Input() {}
169 
174  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
175 
181  data_management::NumericTablePtr get(InputId id) const;
182 
188  void set(InputId id, const data_management::NumericTablePtr &ptr);
189 
195  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
196 };
197 
204 class DAAL_EXPORT PartialResult : public daal::algorithms::PartialResult
205 {
206 public:
207  DECLARE_SERIALIZABLE_CAST(PartialResult);
208  PartialResult();
209 
210  virtual ~PartialResult()
211  {}
212 
219  template <typename algorithmFPType>
220  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
221 
229  template <typename algorithmFPType>
230  DAAL_EXPORT services::Status initialize(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
231 
236  size_t getNumberOfFeatures() const;
237 
243  data_management::NumericTablePtr get(PartialResultId id) const;
244 
250  void set(PartialResultId id, const data_management::NumericTablePtr &ptr);
251 
258  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
259 
265  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
266 
267 protected:
268 
269  services::Status checkImpl(size_t nFeatures) const;
270 
272  template<typename Archive, bool onDeserialize>
273  services::Status serialImpl(Archive *arch)
274  {
275  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
276  }
277 };
278 typedef services::SharedPtr<PartialResult> PartialResultPtr;
279 
284 struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
285 {
287  Parameter();
288  OutputMatrixType outputMatrixType;
289 };
290 
295 struct DAAL_EXPORT OnlineParameter : public Parameter
296 {
298  OnlineParameter();
299 
304  OnlineParameter(const OnlineParameter& other);
305 
309  services::Status check() const DAAL_C11_OVERRIDE;
310 };
311 
317 class DAAL_EXPORT Result : public daal::algorithms::Result
318 {
319 public:
320  DECLARE_SERIALIZABLE_CAST(Result);
321  Result();
322 
323  virtual ~Result() {};
324 
331  template <typename algorithmFPType>
332  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
333 
340  template <typename algorithmFPType>
341  DAAL_EXPORT services::Status allocate(const daal::algorithms::PartialResult *partialResult, const daal::algorithms::Parameter *parameter, const int method);
342 
348  data_management::NumericTablePtr get(ResultId id) const;
349 
355  void set(ResultId id, const data_management::NumericTablePtr &value);
356 
363  services::Status check(const daal::algorithms::PartialResult *partialResult, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
364 
371  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
372 
373 protected:
374 
375  services::Status checkImpl(size_t nFeatures, OutputMatrixType outputMatrixType) const;
376 
378  template<typename Archive, bool onDeserialize>
379  services::Status serialImpl(Archive *arch)
380  {
381  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
382  }
383 };
384 typedef services::SharedPtr<Result> ResultPtr;
385 
392 template<ComputeStep step>
393 class DistributedInput {};
394 
400 template<>
401 class DAAL_EXPORT DistributedInput<step1Local> : public Input
402 {
403 public:
404  DistributedInput() : Input()
405  {}
406  DistributedInput(const DistributedInput& other) : Input(other)
407  {}
408 
409  virtual ~DistributedInput()
410  {}
411 };
412 
418 template<>
419 class DAAL_EXPORT DistributedInput<step2Master> : public InputIface
420 {
421 public:
422  DistributedInput();
423  DistributedInput(const DistributedInput& other) : InputIface(other)
424  {}
425 
426  virtual ~DistributedInput()
427  {}
428 
433  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
434 
440  void add(MasterInputId id, const PartialResultPtr &partialResult);
441 
447  data_management::DataCollectionPtr get(MasterInputId id) const;
448 
454  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
455 };
457 } // namespace interface1
458 using interface1::InputIface;
459 using interface1::Input;
460 using interface1::PartialResult;
461 using interface1::PartialResultPtr;
462 using interface1::Parameter;
463 using interface1::OnlineParameter;
464 using interface1::Result;
465 using interface1::ResultPtr;
466 using interface1::DistributedInput;
467 
468 } // namespace daal::algorithms::covariance
469 }
470 } // namespace daal
471 #endif // __COVARIANCE_TYPES_H__
daal::algorithms::covariance::singlePassCSR
Definition: covariance_types.h:80
daal::algorithms::covariance::interface1::OnlineParameter
Parameters of the correlation or variance-covariance matrix algorithm in the online processing mode...
Definition: covariance_types.h:295
daal::algorithms::covariance::crossProduct
Definition: covariance_types.h:103
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::interface1::Result
Base class to represent final results of the computation. Algorithm-specific final results are repres...
Definition: algorithm_types.h:331
daal::algorithms::covariance::interface1::InputIface
Abstract class that specifies interface for classes that declare input of the correlation or variance...
Definition: covariance_types.h:149
daal::algorithms::covariance::interface1::Parameter
Parameters of the correlation or variance-covariance matrix algorithm.
Definition: covariance_types.h:284
daal::algorithms::interface1::PartialResult
Base class to represent partial results of the computation. Algorithm-specific partial results are re...
Definition: algorithm_types.h:253
daal::algorithms::covariance::Method
Method
Definition: covariance_types.h:72
daal::algorithms::covariance::PartialResultId
PartialResultId
Definition: covariance_types.h:100
daal::algorithms::covariance::interface1::DistributedInput
Input parameters of the distributed Covariance algorithm.
Definition: covariance_types.h:393
daal::algorithms::covariance::interface1::Input
Input objects of the correlation or variance-covariance matrix algorithm
Definition: covariance_types.h:162
daal::algorithms::covariance::sumDense
Definition: covariance_types.h:77
daal::algorithms::covariance::fastCSR
Definition: covariance_types.h:79
daal::algorithms::interface1::Parameter
Base class to represent computation parameters. Algorithm-specific parameters are represented as deri...
Definition: algorithm_types.h:86
daal::algorithms::covariance::data
Definition: covariance_types.h:92
daal::algorithms::covariance::MasterInputId
MasterInputId
Available identifiers of master node input arguments of the Covariance algorithm. ...
Definition: covariance_types.h:134
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::sum
Definition: covariance_types.h:104
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::sumCSR
Definition: covariance_types.h:82
daal::algorithms::covariance::partialResults
Definition: covariance_types.h:136
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:204
daal::algorithms::covariance::ResultId
ResultId
Available identifiers of results of the correlation or variance-covariance matrix algorithm...
Definition: covariance_types.h:112
daal::algorithms::covariance::mean
Definition: covariance_types.h:116
daal::algorithms::covariance::InputId
InputId
Definition: covariance_types.h:90
daal::algorithms::covariance::interface1::Parameter::outputMatrixType
OutputMatrixType outputMatrixType
Definition: covariance_types.h:288
daal::algorithms::covariance::OutputMatrixType
OutputMatrixType
Definition: covariance_types.h:124
daal::algorithms::covariance::covariance
Definition: covariance_types.h:114
daal::algorithms::covariance::correlationMatrix
Definition: covariance_types.h:127
daal::algorithms::math::abs::value
Definition: abs_types.h:112
daal::step1Local
Definition: daal_defines.h:143
daal::step2Master
Definition: daal_defines.h:144
daal::algorithms::covariance::covarianceMatrix
Definition: covariance_types.h:126
daal::algorithms::covariance::defaultDense
Definition: covariance_types.h:74
daal::algorithms::covariance::correlation
Definition: covariance_types.h:115
daal::algorithms::covariance::nObservations
Definition: covariance_types.h:102
daal::algorithms::interface1::Input
Base class to represent computation input arguments. Algorithm-specific input arguments are represent...
Definition: algorithm_types.h:217
daal::algorithms::covariance::singlePassDense
Definition: covariance_types.h:75

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