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

qr_types.h
1 /* file: qr_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 QR common types.
21 //--
22 */
23 
24 
25 #ifndef __QR_TYPES_H__
26 #define __QR_TYPES_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "data_management/data/homogen_numeric_table.h"
31 #include "services/daal_defines.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
50 namespace qr
51 {
56 enum Method
57 {
58  defaultDense = 0
59 };
60 
65 enum InputId
66 {
67  data,
68  lastInputId = data
69 };
70 
75 enum ResultId
76 {
77  matrixQ,
78  matrixR,
79  lastResultId = matrixR
80 };
81 
87 enum PartialResultId
88 {
89  outputOfStep1ForStep3,
91  outputOfStep1ForStep2,
93  lastPartialResultId = outputOfStep1ForStep2
94 };
95 
101 enum DistributedPartialResultCollectionId
102 {
103  outputOfStep2ForStep3,
105  lastDistributedPartialResultCollectionId = outputOfStep2ForStep3
106 };
107 
112 enum DistributedPartialResultId
113 {
114  finalResultFromStep2Master = lastDistributedPartialResultCollectionId + 1,
115  lastDistributedPartialResultId = finalResultFromStep2Master
116 };
117 
122 enum DistributedPartialResultStep3Id
123 {
124  finalResultFromStep3,
125  lastDistributedPartialResultStep3Id = finalResultFromStep3
126 };
127 
132 enum MasterInputId
133 {
134  inputOfStep2FromStep1,
136  lastMasterInputId = inputOfStep2FromStep1
137 };
138 
143 enum FinalizeOnLocalInputId
144 {
145  inputOfStep3FromStep1,
147  inputOfStep3FromStep2,
149  lastFinalizeOnLocalInputId = inputOfStep3FromStep2
150 };
151 
155 namespace interface1
156 {
162 class DAAL_EXPORT Input : public daal::algorithms::Input
163 {
164 public:
166  Input();
167 
169  Input(const Input& other);
170 
172  virtual ~Input() {}
173 
179  data_management::NumericTablePtr get(InputId id) const;
180 
186  void set(InputId id, const data_management::NumericTablePtr &value);
187 
188  services::Status getNumberOfColumns(size_t *nFeatures) const;
189 
190  services::Status getNumberOfRows(size_t *nRows) const;
191 
197  virtual services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
198 };
199 
204 class DAAL_EXPORT DistributedStep2Input : public daal::algorithms::Input
205 {
206 public:
208  DistributedStep2Input();
209 
211  DistributedStep2Input(const DistributedStep2Input& other);
212 
217  services::Status getNumberOfColumns(size_t *nFeatures) const;
218 
224  void set(MasterInputId id, const data_management::KeyValueDataCollectionPtr &ptr);
225 
231  data_management::KeyValueDataCollectionPtr get(MasterInputId id) const;
232 
239  void add(MasterInputId id, size_t key, const data_management::DataCollectionPtr &value);
240 
245  size_t getNBlocks();
246 
252  virtual services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
253 };
254 
259 class DAAL_EXPORT DistributedStep3Input : public daal::algorithms::Input
260 {
261 public:
263  DistributedStep3Input();
264 
266  DistributedStep3Input(const DistributedStep3Input& other);
267 
273  data_management::DataCollectionPtr get(FinalizeOnLocalInputId id) const;
274 
280  void set(FinalizeOnLocalInputId id, const data_management::DataCollectionPtr &value);
281 
282  services::Status getSizes(size_t &nFeatures, size_t &nVectors) const;
283 
289  virtual services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
290 };
291 
297 class DAAL_EXPORT OnlinePartialResult : public daal::algorithms::PartialResult
298 {
299 public:
300  DECLARE_SERIALIZABLE_CAST(OnlinePartialResult);
302  OnlinePartialResult();
304  virtual ~OnlinePartialResult() {}
305 
312  template <typename algorithmFPType>
313  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
314 
322  template <typename algorithmFPType>
323  DAAL_EXPORT services::Status initialize(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
324 
331  template <typename algorithmFPType>
332  DAAL_EXPORT services::Status addPartialResultStorage(size_t m, size_t n);
333 
339  data_management::DataCollectionPtr get(PartialResultId id) const;
340 
346  void set(PartialResultId id, const data_management::DataCollectionPtr &value);
347 
354  virtual services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
355 
361  virtual services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
362 
368  size_t getNumberOfColumns() const;
369 
374  size_t getNumberOfRows() const;
375 
376 protected:
378  template<typename Archive, bool onDeserialize>
379  services::Status serialImpl(Archive *arch)
380  {
381  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
382  }
383 
384  services::Status checkImpl(const daal::algorithms::Parameter *parameter, int method, size_t nFeatures, size_t nVectors) const;
385 };
386 typedef services::SharedPtr<OnlinePartialResult> OnlinePartialResultPtr;
387 
394 class DAAL_EXPORT Result : public daal::algorithms::Result
395 {
396 public:
397  DECLARE_SERIALIZABLE_CAST(Result);
399  Result();
401  virtual ~Result() {}
402 
408  data_management::NumericTablePtr get(ResultId id) const;
409 
416  template <typename algorithmFPType>
417  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
418 
425  template <typename algorithmFPType>
426  DAAL_EXPORT services::Status allocate(const daal::algorithms::PartialResult *partialResult, daal::algorithms::Parameter *parameter, const int method);
427 
433  void set(ResultId id, const data_management::NumericTablePtr &value);
434 
441  virtual services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
442 
449  virtual services::Status check(const daal::algorithms::PartialResult *pres, const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
450 
457  template <typename algorithmFPType>
458  DAAL_EXPORT services::Status allocateImpl(size_t m, size_t n);
459 
460 protected:
462  template<typename Archive, bool onDeserialize>
463  services::Status serialImpl(Archive *arch)
464  {
465  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
466  }
467 };
468 typedef services::SharedPtr<Result> ResultPtr;
469 
475 class DAAL_EXPORT DistributedPartialResult : public daal::algorithms::PartialResult
476 {
477 public:
478  DECLARE_SERIALIZABLE_CAST(DistributedPartialResult);
480  DistributedPartialResult();
482  virtual ~DistributedPartialResult() {}
483 
490  template <typename algorithmFPType>
491  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
492 
503  template <typename algorithmFPType>
504  DAAL_EXPORT services::Status setPartialResultStorage(data_management::KeyValueDataCollection *inCollection, size_t &nBlocks);
505 
513  data_management::KeyValueDataCollectionPtr get(DistributedPartialResultCollectionId id) const;
514 
520  ResultPtr get(DistributedPartialResultId id) const;
521 
527  void set(DistributedPartialResultCollectionId id, const data_management::KeyValueDataCollectionPtr &value);
528 
534  void set(DistributedPartialResultId id, const ResultPtr &value);
535 
536 
542  virtual services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
543 
550  virtual services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
551 
552 protected:
554  template<typename Archive, bool onDeserialize>
555  services::Status serialImpl(Archive *arch)
556  {
557  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
558  }
559 };
560 typedef services::SharedPtr<DistributedPartialResult>DistributedPartialResultPtr;
561 
567 class DAAL_EXPORT DistributedPartialResultStep3 : public daal::algorithms::PartialResult
568 {
569 public:
570  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep3);
572  DistributedPartialResultStep3();
574  virtual ~DistributedPartialResultStep3() {}
575 
582  template <typename algorithmFPType>
583  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
584 
591  template <typename algorithmFPType>
592  DAAL_EXPORT services::Status setPartialResultStorage(data_management::DataCollection *qCollection);
593 
599  ResultPtr get(DistributedPartialResultStep3Id id) const;
600 
606  void set(DistributedPartialResultStep3Id id, const ResultPtr &value);
607 
614  virtual services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
615 
616 
622  virtual services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
623 
624 protected:
626  template<typename Archive, bool onDeserialize>
627  services::Status serialImpl(Archive *arch)
628  {
629  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
630  }
631 };
632 typedef services::SharedPtr<DistributedPartialResultStep3> DistributedPartialResultStep3Ptr;
633 
638 struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
639 {
643  Parameter() {}
644 };
647 } // namespace interface1
648 using interface1::Input;
649 using interface1::DistributedStep2Input;
650 using interface1::DistributedStep3Input;
651 using interface1::OnlinePartialResult;
652 using interface1::OnlinePartialResultPtr;
653 using interface1::Result;
654 using interface1::ResultPtr;
655 using interface1::DistributedPartialResult;
656 using interface1::DistributedPartialResultPtr;
657 using interface1::DistributedPartialResultStep3;
658 using interface1::DistributedPartialResultStep3Ptr;
659 using interface1::Parameter;
660 
661 } // namespace daal::algorithms::qr
662 } // namespace daal::algorithms
663 } // namespace daal
664 #endif
daal::algorithms::qr::outputOfStep1ForStep3
Definition: qr_types.h:89
daal::algorithms::qr::InputId
InputId
Definition: qr_types.h:65
daal::algorithms::qr::interface1::DistributedPartialResult
Provides methods to access partial results obtained with the compute() method of the second step of t...
Definition: qr_types.h:475
daal::algorithms::qr::interface1::Result::~Result
virtual ~Result()
Definition: qr_types.h:401
daal::algorithms::qr::finalResultFromStep3
Definition: qr_types.h:124
daal::algorithms::qr::matrixR
Definition: qr_types.h:78
daal::algorithms::qr::matrixQ
Definition: qr_types.h:77
daal::algorithms::qr::DistributedPartialResultCollectionId
DistributedPartialResultCollectionId
Definition: qr_types.h:101
daal::algorithms::qr::interface1::OnlinePartialResult::~OnlinePartialResult
virtual ~OnlinePartialResult()
Definition: qr_types.h:304
daal::algorithms::qr::inputOfStep2FromStep1
Definition: qr_types.h:134
daal::algorithms::interface1::Result
Base class to represent final results of the computation. Algorithm-specific final results are repres...
Definition: algorithm_types.h:309
daal::algorithms::qr::interface1::DistributedStep2Input
Input objects for the second step of the QR decomposition algorithm in the distributed processing mod...
Definition: qr_types.h:204
daal::algorithms::qr::defaultDense
Definition: qr_types.h:58
daal::algorithms::qr::interface1::Input
Input objects for the QR decomposition algorithm in the batch and online processing modes and for the...
Definition: qr_types.h:162
daal::algorithms::qr::interface1::DistributedPartialResultStep3
Provides methods to access partial results obtained with the compute() method of the third step of th...
Definition: qr_types.h:567
daal::algorithms::qr::interface1::Result
Provides methods to access final results obtained with the compute() method of the QR decomposition a...
Definition: qr_types.h:394
daal::algorithms::qr::interface1::DistributedStep3Input
Input objects for the third step of the QR decomposition algorithm in the distributed processing mode...
Definition: qr_types.h:259
daal_defines.h
daal::algorithms::qr::FinalizeOnLocalInputId
FinalizeOnLocalInputId
Definition: qr_types.h:143
daal::algorithms::interface1::Input
Base class to represent computation input arguments. Algorithm-specific input arguments are represent...
Definition: algorithm_types.h:193
daal::algorithms::qr::data
Definition: qr_types.h:67
daal::algorithms::qr::MasterInputId
MasterInputId
Definition: qr_types.h:132
daal::algorithms::qr::ResultId
ResultId
Definition: qr_types.h:75
daal::algorithms::qr::finalResultFromStep2Master
Definition: qr_types.h:114
daal::algorithms::qr::outputOfStep2ForStep3
Definition: qr_types.h:103
daal::algorithms::interface1::Parameter
Base class to represent computation parameters. Algorithm-specific parameters are represented as deri...
Definition: algorithm_types.h:62
daal::algorithms::qr::outputOfStep1ForStep2
Definition: qr_types.h:91
daal::algorithms::qr::Method
Method
Definition: qr_types.h:56
daal::algorithms::qr::interface1::DistributedPartialResultStep3::~DistributedPartialResultStep3
virtual ~DistributedPartialResultStep3()
Definition: qr_types.h:574
daal::algorithms::qr::interface1::Input::~Input
virtual ~Input()
Definition: qr_types.h:172
daal::algorithms::qr::DistributedPartialResultId
DistributedPartialResultId
Definition: qr_types.h:112
daal::algorithms::qr::interface1::OnlinePartialResult
Provides methods to access partial results obtained with the compute() method of the QR decomposition...
Definition: qr_types.h:297
daal::algorithms::qr::DistributedPartialResultStep3Id
DistributedPartialResultStep3Id
Definition: qr_types.h:122
daal::algorithms::qr::inputOfStep3FromStep2
Definition: qr_types.h:147
daal::algorithms::qr::interface1::Parameter::Parameter
Parameter()
Definition: qr_types.h:643
daal::algorithms::math::abs::value
Definition: abs_types.h:88
daal::algorithms::qr::PartialResultId
PartialResultId
Definition: qr_types.h:87
daal::algorithms::qr::interface1::Parameter
Parameters for the QR decomposition compute method.
Definition: qr_types.h:638
daal::algorithms::qr::inputOfStep3FromStep1
Definition: qr_types.h:145
daal::algorithms::qr::interface1::DistributedPartialResult::~DistributedPartialResult
virtual ~DistributedPartialResult()
Definition: qr_types.h:482

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