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

svd_types.h
1 /* file: svd_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 the SVD common types.
45 //--
46 */
47 
48 #ifndef __SVD_TYPES_H__
49 #define __SVD_TYPES_H__
50 
51 #include "algorithms/algorithm.h"
52 #include "data_management/data/numeric_table.h"
53 #include "data_management/data/homogen_numeric_table.h"
54 #include "services/daal_defines.h"
55 
56 namespace daal
57 {
58 namespace algorithms
59 {
67 namespace svd
68 {
73 enum Method
74 {
75  defaultDense = 0
76 };
77 
82 enum SVDResultFormat
83 {
84  notRequired,
85  requiredInPackedForm
86 };
87 
92 enum InputId
93 {
94  data,
95  lastInputId = data
96 };
97 
102 enum ResultId
103 {
104  singularValues,
105  leftSingularMatrix,
106  rightSingularMatrix,
107  lastResultId = rightSingularMatrix
108 };
109 
115 enum PartialResultId
116 {
117  outputOfStep1ForStep3,
119  outputOfStep1ForStep2,
121  lastPartialResultId = outputOfStep1ForStep2
122 };
123 
129 enum DistributedPartialResultCollectionId
130 {
131  outputOfStep2ForStep3,
132  lastDistributedPartialResultCollectionId = outputOfStep2ForStep3
133 };
134 
140 enum DistributedPartialResultId
141 {
142  finalResultFromStep2Master = lastDistributedPartialResultCollectionId + 1,
143  lastDistributedPartialResultId = finalResultFromStep2Master
144 };
145 
151 enum DistributedPartialResultStep3Id
152 {
153  finalResultFromStep3,
154  lastDistributedPartialResultStep3Id = finalResultFromStep3
155 };
156 
161 enum MasterInputId
162 {
163  inputOfStep2FromStep1,
164  lastMasterInputId = inputOfStep2FromStep1
165 };
166 
171 enum FinalizeOnLocalInputId
172 {
173  inputOfStep3FromStep1,
174  inputOfStep3FromStep2,
175  lastFinalizeOnLocalInputId = inputOfStep3FromStep2
176 };
177 
181 namespace interface1
182 {
187 struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
188 {
194  Parameter(SVDResultFormat _leftSingularMatrix = requiredInPackedForm,
195  SVDResultFormat _rightSingularMatrix = requiredInPackedForm) :
196  leftSingularMatrix(_leftSingularMatrix), rightSingularMatrix(_rightSingularMatrix) {}
197 
198  SVDResultFormat leftSingularMatrix;
199  SVDResultFormat rightSingularMatrix;
200 };
201 
207 class DAAL_EXPORT Input : public daal::algorithms::Input
208 {
209 public:
211  Input();
213  Input(const Input& other);
215  virtual ~Input() {}
216 
222  data_management::NumericTablePtr get(InputId id) const;
223 
229  void set(InputId id, const data_management::NumericTablePtr &value);
230 
231  services::Status getNumberOfColumns(size_t *nFeatures) const;
232 
233  services::Status getNumberOfRows(size_t *nRows) const;
234 
241  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
242 
243 };
244 
249 class DAAL_EXPORT DistributedStep2Input : public daal::algorithms::Input
250 {
251 public:
253  DistributedStep2Input();
254 
256  DistributedStep2Input(const DistributedStep2Input& other);
257 
263  void set(MasterInputId id, const data_management::KeyValueDataCollectionPtr &ptr);
264 
270  data_management::KeyValueDataCollectionPtr get(MasterInputId id) const;
271 
278  void add(MasterInputId id, size_t key, const data_management::DataCollectionPtr &value);
279 
280  size_t getNBlocks();
281 
288  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
289 
290 protected:
295  services::Status getNumberOfColumns(size_t& nCols) const;
296 };
297 
302 class DAAL_EXPORT DistributedStep3Input : public daal::algorithms::Input
303 {
304 public:
306  DistributedStep3Input();
307 
309  DistributedStep3Input(const DistributedStep3Input& other);
310 
316  data_management::DataCollectionPtr get(FinalizeOnLocalInputId id) const;
317 
323  void set(FinalizeOnLocalInputId id, const data_management::DataCollectionPtr &value);
324 
325  services::Status getSizes(size_t &nFeatures, size_t &nVectors) const;
326 
333  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
334 
335 };
336 
342 class DAAL_EXPORT OnlinePartialResult : public daal::algorithms::PartialResult
343 {
344 public:
345  DECLARE_SERIALIZABLE_CAST(OnlinePartialResult);
347  OnlinePartialResult();
349  virtual ~OnlinePartialResult() {}
350 
358  template <typename algorithmFPType>
359  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
360 
368  template <typename algorithmFPType>
369  DAAL_EXPORT services::Status initialize(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
370 
378  template <typename algorithmFPType>
379  DAAL_EXPORT services::Status addPartialResultStorage(size_t m, size_t n, Parameter &par);
380 
386  data_management::DataCollectionPtr get(PartialResultId id) const;
387 
393  void set(PartialResultId id, const data_management::DataCollectionPtr &value);
394 
401  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
402 
403  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
404 
405  size_t getNumberOfColumns() const;
406 
407  size_t getNumberOfRows() const;
408 
409 protected:
411  template<typename Archive, bool onDeserialize>
412  services::Status serialImpl(Archive *arch)
413  {
414  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
415  }
416  services::Status checkImpl(const daal::algorithms::Parameter *parameter, int method, size_t nFeatures, size_t nVectors) const;
417 };
418 typedef services::SharedPtr<OnlinePartialResult> OnlinePartialResultPtr;
419 
425 class DAAL_EXPORT Result : public daal::algorithms::Result
426 {
427 public:
428  DECLARE_SERIALIZABLE_CAST(Result);
430  Result();
432  virtual ~Result() {}
433 
439  data_management::NumericTablePtr get(ResultId id) const;
440 
448  template <typename algorithmFPType>
449  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
450 
458  template <typename algorithmFPType>
459  DAAL_EXPORT services::Status allocate(const daal::algorithms::PartialResult *partialResult, daal::algorithms::Parameter *parameter, const int method);
460 
466  void set(ResultId id, const data_management::NumericTablePtr &value);
467 
475  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
476 
483  services::Status check(const daal::algorithms::PartialResult *pres, const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
484 
492  template <typename algorithmFPType>
493  DAAL_EXPORT services::Status allocateImpl(size_t m, size_t n);
494 
495 protected:
497  template<typename Archive, bool onDeserialize>
498  services::Status serialImpl(Archive *arch)
499  {
500  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
501  }
502 };
503 typedef services::SharedPtr<Result> ResultPtr;
504 
510 class DAAL_EXPORT DistributedPartialResult : public daal::algorithms::PartialResult
511 {
512 public:
513  DECLARE_SERIALIZABLE_CAST(DistributedPartialResult);
515  DistributedPartialResult();
517  virtual ~DistributedPartialResult() {}
518 
523  template <typename algorithmFPType>
524  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
525 
536  template <typename algorithmFPType>
537  DAAL_EXPORT services::Status setPartialResultStorage(data_management::KeyValueDataCollection *inCollection, size_t &nBlocks);
538 
546  data_management::KeyValueDataCollectionPtr get(DistributedPartialResultCollectionId id) const;
547 
554  data_management::DataCollectionPtr get(DistributedPartialResultCollectionId id, size_t idx) const;
555 
561  ResultPtr get(DistributedPartialResultId id) const;
562 
568  void set(DistributedPartialResultCollectionId id, const data_management::KeyValueDataCollectionPtr &value);
569 
575  void set(DistributedPartialResultId id, const ResultPtr &value);
576 
583  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
584 
592  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
593 
594 protected:
596  template<typename Archive, bool onDeserialize>
597  services::Status serialImpl(Archive *arch)
598  {
599  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
600  }
601 };
602 typedef services::SharedPtr<DistributedPartialResult> DistributedPartialResultPtr;
603 
609 class DAAL_EXPORT DistributedPartialResultStep3 : public daal::algorithms::PartialResult
610 {
611 public:
612  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep3);
614  DistributedPartialResultStep3();
616  virtual ~DistributedPartialResultStep3() {}
617 
625  template <typename algorithmFPType>
626  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
627 
633  template <typename algorithmFPType>
634  DAAL_EXPORT services::Status setPartialResultStorage(data_management::DataCollection *qCollection);
635 
641  ResultPtr get(DistributedPartialResultStep3Id id) const;
642 
648  void set(DistributedPartialResultStep3Id id, const ResultPtr &value);
649 
657  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
658 
659 
666  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
667 
668 protected:
670  template<typename Archive, bool onDeserialize>
671  services::Status serialImpl(Archive *arch)
672  {
673  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
674  }
675 };
676 typedef services::SharedPtr<DistributedPartialResultStep3> DistributedPartialResultStep3Ptr;
678 } // namespace interface1
679 using interface1::Parameter;
680 using interface1::Input;
681 using interface1::DistributedStep2Input;
682 using interface1::DistributedStep3Input;
683 using interface1::OnlinePartialResult;
684 using interface1::OnlinePartialResultPtr;
685 using interface1::Result;
686 using interface1::ResultPtr;
687 using interface1::DistributedPartialResult;
688 using interface1::DistributedPartialResultPtr;
689 using interface1::DistributedPartialResultStep3;
690 using interface1::DistributedPartialResultStep3Ptr;
691 
692 } // namespace daal::algorithms::svd
693 } // namespace daal::algorithms
694 } // namespace daal
695 #endif
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:140
daal::algorithms::svd::leftSingularMatrix
Definition: svd_types.h:105
daal::algorithms::svd::interface1::Parameter
Parameters for the computation method of the SVD algorithm.
Definition: svd_types.h:187
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::svd::interface1::OnlinePartialResult::~OnlinePartialResult
virtual ~OnlinePartialResult()
Definition: svd_types.h:349
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::svd::SVDResultFormat
SVDResultFormat
Definition: svd_types.h:82
daal::algorithms::svd::inputOfStep3FromStep2
Definition: svd_types.h:174
daal::algorithms::svd::Method
Method
Definition: svd_types.h:73
daal::algorithms::svd::singularValues
Definition: svd_types.h:104
daal::data_management::interface1::DataCollection
Class that provides functionality of Collection container for objects derived from SerializationIface...
Definition: data_collection.h:71
daal::algorithms::svd::inputOfStep2FromStep1
Definition: svd_types.h:163
daal::algorithms::svd::inputOfStep3FromStep1
Definition: svd_types.h:173
daal::algorithms::svd::interface1::Parameter::rightSingularMatrix
SVDResultFormat rightSingularMatrix
Definition: svd_types.h:199
daal::algorithms::svd::data
Definition: svd_types.h:94
daal::algorithms::svd::interface1::DistributedStep2Input
Input objects for the second step of the SVD algorithm in the distributed processing mode ...
Definition: svd_types.h:249
daal::algorithms::svd::InputId
InputId
Available types of input objects for the SVD algorithm.
Definition: svd_types.h:92
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:425
daal::algorithms::svd::FinalizeOnLocalInputId
FinalizeOnLocalInputId
Partial results from previous steps in the distributed processing mode, required by the third step...
Definition: svd_types.h:171
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::svd::interface1::Parameter::leftSingularMatrix
SVDResultFormat leftSingularMatrix
Definition: svd_types.h:198
daal_defines.h
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:609
daal::algorithms::svd::ResultId
ResultId
Available types of results of the SVD algorithm.
Definition: svd_types.h:102
daal::algorithms::svd::interface1::DistributedPartialResult::~DistributedPartialResult
virtual ~DistributedPartialResult()
Definition: svd_types.h:517
daal::algorithms::interface1::Parameter
Base class to represent computation parameters. Algorithm-specific parameters are represented as deri...
Definition: algorithm_types.h:86
daal::algorithms::svd::interface1::Parameter::Parameter
Parameter(SVDResultFormat _leftSingularMatrix=requiredInPackedForm, SVDResultFormat _rightSingularMatrix=requiredInPackedForm)
Definition: svd_types.h:194
daal::algorithms::svd::requiredInPackedForm
Definition: svd_types.h:85
daal::algorithms::svd::interface1::Input
Input objects for the SVD algorithm in the batch processing and online processing modes...
Definition: svd_types.h:207
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::svd::DistributedPartialResultCollectionId
DistributedPartialResultCollectionId
Available types of partial results obtained in the second step of the SVD algorithm in the distribute...
Definition: svd_types.h:129
daal::algorithms::svd::outputOfStep2ForStep3
Definition: svd_types.h:131
daal::algorithms::svd::finalResultFromStep2Master
Definition: svd_types.h:142
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:115
daal::algorithms::svd::interface1::Result::~Result
virtual ~Result()
Definition: svd_types.h:432
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:151
daal::algorithms::svd::rightSingularMatrix
Definition: svd_types.h:106
daal::algorithms::svd::interface1::DistributedStep3Input
Input objects for the third step of the SVD algorithm in the distributed processing mode ...
Definition: svd_types.h:302
daal::algorithms::math::abs::value
Definition: abs_types.h:112
daal::algorithms::svd::finalResultFromStep3
Definition: svd_types.h:153
daal::algorithms::svd::interface1::DistributedPartialResultStep3::~DistributedPartialResultStep3
virtual ~DistributedPartialResultStep3()
Definition: svd_types.h:616
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:342
daal::algorithms::svd::interface1::Input::~Input
virtual ~Input()
Definition: svd_types.h:215
daal::algorithms::svd::MasterInputId
MasterInputId
Partial results from previous steps in the distributed processing mode, required by the second step...
Definition: svd_types.h:161
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:510
daal::algorithms::interface1::Input
Base class to represent computation input arguments. Algorithm-specific input arguments are represent...
Definition: algorithm_types.h:217
daal::algorithms::svd::outputOfStep1ForStep2
Definition: svd_types.h:119
daal::algorithms::svd::outputOfStep1ForStep3
Definition: svd_types.h:117
daal::algorithms::svd::defaultDense
Definition: svd_types.h:75
daal::algorithms::svd::notRequired
Definition: svd_types.h:84

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