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

svd_types.h
1 /* file: svd_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 the SVD common types.
21 //--
22 */
23 
24 #ifndef __SVD_TYPES_H__
25 #define __SVD_TYPES_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "data_management/data/numeric_table.h"
29 #include "data_management/data/homogen_numeric_table.h"
30 #include "services/daal_defines.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
43 namespace svd
44 {
49 enum Method
50 {
51  defaultDense = 0
52 };
53 
58 enum SVDResultFormat
59 {
60  notRequired,
61  requiredInPackedForm
62 };
63 
68 enum InputId
69 {
70  data,
71  lastInputId = data
72 };
73 
78 enum ResultId
79 {
80  singularValues,
81  leftSingularMatrix,
82  rightSingularMatrix,
83  lastResultId = rightSingularMatrix
84 };
85 
91 enum PartialResultId
92 {
93  outputOfStep1ForStep3,
95  outputOfStep1ForStep2,
97  lastPartialResultId = outputOfStep1ForStep2
98 };
99 
105 enum DistributedPartialResultCollectionId
106 {
107  outputOfStep2ForStep3,
108  lastDistributedPartialResultCollectionId = outputOfStep2ForStep3
109 };
110 
116 enum DistributedPartialResultId
117 {
118  finalResultFromStep2Master = lastDistributedPartialResultCollectionId + 1,
119  lastDistributedPartialResultId = finalResultFromStep2Master
120 };
121 
127 enum DistributedPartialResultStep3Id
128 {
129  finalResultFromStep3,
130  lastDistributedPartialResultStep3Id = finalResultFromStep3
131 };
132 
137 enum MasterInputId
138 {
139  inputOfStep2FromStep1,
140  lastMasterInputId = inputOfStep2FromStep1
141 };
142 
147 enum FinalizeOnLocalInputId
148 {
149  inputOfStep3FromStep1,
150  inputOfStep3FromStep2,
151  lastFinalizeOnLocalInputId = inputOfStep3FromStep2
152 };
153 
157 namespace interface1
158 {
163 struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
164 {
170  Parameter(SVDResultFormat _leftSingularMatrix = requiredInPackedForm,
171  SVDResultFormat _rightSingularMatrix = requiredInPackedForm) :
172  leftSingularMatrix(_leftSingularMatrix), rightSingularMatrix(_rightSingularMatrix) {}
173 
174  SVDResultFormat leftSingularMatrix;
175  SVDResultFormat rightSingularMatrix;
176 };
177 
183 class DAAL_EXPORT Input : public daal::algorithms::Input
184 {
185 public:
187  Input();
189  Input(const Input& other);
191  virtual ~Input() {}
192 
198  data_management::NumericTablePtr get(InputId id) const;
199 
205  void set(InputId id, const data_management::NumericTablePtr &value);
206 
207  services::Status getNumberOfColumns(size_t *nFeatures) const;
208 
209  services::Status getNumberOfRows(size_t *nRows) const;
210 
217  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
218 
219 };
220 
225 class DAAL_EXPORT DistributedStep2Input : public daal::algorithms::Input
226 {
227 public:
229  DistributedStep2Input();
230 
232  DistributedStep2Input(const DistributedStep2Input& other);
233 
239  void set(MasterInputId id, const data_management::KeyValueDataCollectionPtr &ptr);
240 
246  data_management::KeyValueDataCollectionPtr get(MasterInputId id) const;
247 
254  void add(MasterInputId id, size_t key, const data_management::DataCollectionPtr &value);
255 
260  size_t getNBlocks();
261 
268  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
269 
270 protected:
275  services::Status getNumberOfColumns(size_t& nCols) const;
276 };
277 
282 class DAAL_EXPORT DistributedStep3Input : public daal::algorithms::Input
283 {
284 public:
286  DistributedStep3Input();
287 
289  DistributedStep3Input(const DistributedStep3Input& other);
290 
296  data_management::DataCollectionPtr get(FinalizeOnLocalInputId id) const;
297 
303  void set(FinalizeOnLocalInputId id, const data_management::DataCollectionPtr &value);
304 
305  services::Status getSizes(size_t &nFeatures, size_t &nVectors) const;
306 
313  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
314 
315 };
316 
322 class DAAL_EXPORT OnlinePartialResult : public daal::algorithms::PartialResult
323 {
324 public:
325  DECLARE_SERIALIZABLE_CAST(OnlinePartialResult);
327  OnlinePartialResult();
329  virtual ~OnlinePartialResult() {}
330 
338  template <typename algorithmFPType>
339  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
340 
348  template <typename algorithmFPType>
349  DAAL_EXPORT services::Status initialize(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
350 
358  template <typename algorithmFPType>
359  DAAL_EXPORT services::Status addPartialResultStorage(size_t m, size_t n, Parameter &par);
360 
366  data_management::DataCollectionPtr get(PartialResultId id) const;
367 
373  void set(PartialResultId id, const data_management::DataCollectionPtr &value);
374 
381  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
382 
383  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
384 
385  size_t getNumberOfColumns() const;
386 
387  size_t getNumberOfRows() const;
388 
389 protected:
391  template<typename Archive, bool onDeserialize>
392  services::Status serialImpl(Archive *arch)
393  {
394  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
395  }
396  services::Status checkImpl(const daal::algorithms::Parameter *parameter, int method, size_t nFeatures, size_t nVectors) const;
397 };
398 typedef services::SharedPtr<OnlinePartialResult> OnlinePartialResultPtr;
399 
405 class DAAL_EXPORT Result : public daal::algorithms::Result
406 {
407 public:
408  DECLARE_SERIALIZABLE_CAST(Result);
410  Result();
412  virtual ~Result() {}
413 
419  data_management::NumericTablePtr get(ResultId id) const;
420 
428  template <typename algorithmFPType>
429  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
430 
438  template <typename algorithmFPType>
439  DAAL_EXPORT services::Status allocate(const daal::algorithms::PartialResult *partialResult, daal::algorithms::Parameter *parameter, const int method);
440 
446  void set(ResultId id, const data_management::NumericTablePtr &value);
447 
455  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
456 
463  services::Status check(const daal::algorithms::PartialResult *pres, const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
464 
472  template <typename algorithmFPType>
473  DAAL_EXPORT services::Status allocateImpl(size_t m, size_t n);
474 
475 protected:
477  template<typename Archive, bool onDeserialize>
478  services::Status serialImpl(Archive *arch)
479  {
480  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
481  }
482 };
483 typedef services::SharedPtr<Result> ResultPtr;
484 
490 class DAAL_EXPORT DistributedPartialResult : public daal::algorithms::PartialResult
491 {
492 public:
493  DECLARE_SERIALIZABLE_CAST(DistributedPartialResult);
495  DistributedPartialResult();
497  virtual ~DistributedPartialResult() {}
498 
503  template <typename algorithmFPType>
504  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
505 
516  template <typename algorithmFPType>
517  DAAL_EXPORT services::Status setPartialResultStorage(data_management::KeyValueDataCollection *inCollection, size_t &nBlocks);
518 
526  data_management::KeyValueDataCollectionPtr get(DistributedPartialResultCollectionId id) const;
527 
534  data_management::DataCollectionPtr get(DistributedPartialResultCollectionId id, size_t idx) const;
535 
541  ResultPtr get(DistributedPartialResultId id) const;
542 
548  void set(DistributedPartialResultCollectionId id, const data_management::KeyValueDataCollectionPtr &value);
549 
555  void set(DistributedPartialResultId id, const ResultPtr &value);
556 
563  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
564 
572  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
573 
574 protected:
576  template<typename Archive, bool onDeserialize>
577  services::Status serialImpl(Archive *arch)
578  {
579  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
580  }
581 };
582 typedef services::SharedPtr<DistributedPartialResult> DistributedPartialResultPtr;
583 
589 class DAAL_EXPORT DistributedPartialResultStep3 : public daal::algorithms::PartialResult
590 {
591 public:
592  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep3);
594  DistributedPartialResultStep3();
596  virtual ~DistributedPartialResultStep3() {}
597 
605  template <typename algorithmFPType>
606  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
607 
613  template <typename algorithmFPType>
614  DAAL_EXPORT services::Status setPartialResultStorage(data_management::DataCollection *qCollection);
615 
621  ResultPtr get(DistributedPartialResultStep3Id id) const;
622 
628  void set(DistributedPartialResultStep3Id id, const ResultPtr &value);
629 
637  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
638 
639 
646  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
647 
648 protected:
650  template<typename Archive, bool onDeserialize>
651  services::Status serialImpl(Archive *arch)
652  {
653  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
654  }
655 };
656 typedef services::SharedPtr<DistributedPartialResultStep3> DistributedPartialResultStep3Ptr;
658 } // namespace interface1
659 using interface1::Parameter;
660 using interface1::Input;
661 using interface1::DistributedStep2Input;
662 using interface1::DistributedStep3Input;
663 using interface1::OnlinePartialResult;
664 using interface1::OnlinePartialResultPtr;
665 using interface1::Result;
666 using interface1::ResultPtr;
667 using interface1::DistributedPartialResult;
668 using interface1::DistributedPartialResultPtr;
669 using interface1::DistributedPartialResultStep3;
670 using interface1::DistributedPartialResultStep3Ptr;
671 
672 } // namespace daal::algorithms::svd
673 } // namespace daal::algorithms
674 } // namespace daal
675 #endif
daal::algorithms::svd::interface1::DistributedPartialResult::~DistributedPartialResult
virtual ~DistributedPartialResult()
Definition: svd_types.h:497
daal::algorithms::svd::defaultDense
Definition: svd_types.h:51
daal::algorithms::svd::outputOfStep2ForStep3
Definition: svd_types.h:107
daal::algorithms::svd::rightSingularMatrix
Definition: svd_types.h:82
daal::algorithms::svd::interface1::Result
Provides methods to access final results obtained with the compute() method of the SVD algorithm in t...
Definition: svd_types.h:405
daal::algorithms::svd::notRequired
Definition: svd_types.h:60
daal::algorithms::svd::inputOfStep3FromStep1
Definition: svd_types.h:149
daal::algorithms::svd::Method
Method
Definition: svd_types.h:49
daal::algorithms::svd::finalResultFromStep3
Definition: svd_types.h:129
daal::algorithms::svd::interface1::Parameter::leftSingularMatrix
SVDResultFormat leftSingularMatrix
Definition: svd_types.h:174
daal::algorithms::svd::interface1::OnlinePartialResult::~OnlinePartialResult
virtual ~OnlinePartialResult()
Definition: svd_types.h:329
daal::algorithms::svd::outputOfStep1ForStep3
Definition: svd_types.h:93
daal::algorithms::svd::finalResultFromStep2Master
Definition: svd_types.h:118
daal::algorithms::svd::outputOfStep1ForStep2
Definition: svd_types.h:95
daal::algorithms::svd::requiredInPackedForm
Definition: svd_types.h:61
daal_defines.h
daal::algorithms::svd::inputOfStep2FromStep1
Definition: svd_types.h:139
daal::algorithms::svd::DistributedPartialResultStep3Id
DistributedPartialResultStep3Id
Available types of partial results obtained in the third step of the SVD algorithm in the distributed...
Definition: svd_types.h:127
daal::algorithms::svd::interface1::Input
Input objects for the SVD algorithm in the batch processing and online processing modes...
Definition: svd_types.h:183
daal::algorithms::svd::MasterInputId
MasterInputId
Partial results from previous steps in the distributed processing mode, required by the second step...
Definition: svd_types.h:137
daal::algorithms::svd::interface1::Parameter
Parameters for the computation method of the SVD algorithm.
Definition: svd_types.h:163
daal::algorithms::svd::interface1::Parameter::rightSingularMatrix
SVDResultFormat rightSingularMatrix
Definition: svd_types.h:175
daal::algorithms::svd::interface1::Input::~Input
virtual ~Input()
Definition: svd_types.h:191
daal::algorithms::svd::FinalizeOnLocalInputId
FinalizeOnLocalInputId
Partial results from previous steps in the distributed processing mode, required by the third step...
Definition: svd_types.h:147
daal::algorithms::svd::interface1::DistributedPartialResult
Provides methods to access partial results obtained with the compute() method of the SVD algorithm in...
Definition: svd_types.h:490
daal::algorithms::svd::PartialResultId
PartialResultId
Available types of partial results of the SVD algorithm obtained in the online processing mode and in...
Definition: svd_types.h:91
daal::algorithms::svd::interface1::Parameter::Parameter
Parameter(SVDResultFormat _leftSingularMatrix=requiredInPackedForm, SVDResultFormat _rightSingularMatrix=requiredInPackedForm)
Definition: svd_types.h:170
daal::algorithms::svd::interface1::Result::~Result
virtual ~Result()
Definition: svd_types.h:412
daal::algorithms::svd::DistributedPartialResultId
DistributedPartialResultId
Available types of partial results obtained in the second step of the SVD algorithm in the distribute...
Definition: svd_types.h:116
daal::algorithms::svd::DistributedPartialResultCollectionId
DistributedPartialResultCollectionId
Available types of partial results obtained in the second step of the SVD algorithm in the distribute...
Definition: svd_types.h:105
daal::algorithms::svd::leftSingularMatrix
Definition: svd_types.h:81
daal::algorithms::svd::interface1::DistributedPartialResultStep3::~DistributedPartialResultStep3
virtual ~DistributedPartialResultStep3()
Definition: svd_types.h:596
daal::algorithms::svd::interface1::OnlinePartialResult
Provides methods to access partial results obtained with the compute() method of the SVD algorithm in...
Definition: svd_types.h:322
daal::algorithms::svd::ResultId
ResultId
Available types of results of the SVD algorithm.
Definition: svd_types.h:78
daal::algorithms::svd::interface1::DistributedPartialResultStep3
Provides methods to access partial results obtained with the compute() method of the SVD algorithm in...
Definition: svd_types.h:589
daal::algorithms::svd::inputOfStep3FromStep2
Definition: svd_types.h:150
daal::algorithms::svd::SVDResultFormat
SVDResultFormat
Definition: svd_types.h:58
daal::algorithms::svd::data
Definition: svd_types.h:70
daal::algorithms::math::abs::value
Definition: abs_types.h:88
daal::algorithms::svd::InputId
InputId
Available types of input objects for the SVD algorithm.
Definition: svd_types.h:68
daal::algorithms::svd::interface1::DistributedStep2Input
Input objects for the second step of the SVD algorithm in the distributed processing mode ...
Definition: svd_types.h:225
daal::algorithms::svd::singularValues
Definition: svd_types.h:80
daal::algorithms::svd::interface1::DistributedStep3Input
Input objects for the third step of the SVD algorithm in the distributed processing mode ...
Definition: svd_types.h:282

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