24 #ifndef __PCA_TYPES_H__
25 #define __PCA_TYPES_H__
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 #include "algorithms/covariance/covariance_batch.h"
32 #include "algorithms/covariance/covariance_online.h"
33 #include "algorithms/covariance/covariance_distributed.h"
34 #include "algorithms/normalization/zscore.h"
69 lastInputDatasetId = data
76 enum InputCorrelationId
79 lastInputCorrelationId = correlation
86 enum Step2MasterInputId
89 lastStep2MasterInputId = partialResults
96 enum PartialCorrelationResultId
98 nObservationsCorrelation,
99 crossProductCorrelation,
101 lastPartialCorrelationResultId = sumCorrelation
108 enum PartialSVDTableResultId
113 lastPartialSVDTableResultId = sumSquaresSVD
120 enum PartialSVDCollectionResultId
122 auxiliaryData = lastPartialSVDTableResultId + 1,
124 lastPartialSVDCollectionResultId = distributedInputs
137 lastResultId = variances
144 enum ResultCollectionId
154 enum ResultToComputeId
157 mean = 0x00000001ULL,
158 variance = 0x00000002ULL,
159 eigenvalue = 0x00000004ULL
170 class DAAL_EXPORT InputIface :
public daal::algorithms::Input
173 InputIface(
size_t nElements);
174 InputIface(
const InputIface& other);
180 virtual size_t getNFeatures()
const = 0;
186 virtual bool isCorrelation()
const {
return _isCorrelation; };
188 virtual ~InputIface() {};
198 class DAAL_EXPORT Input :
public InputIface
202 Input(
const Input& other);
211 data_management::NumericTablePtr
get(InputDatasetId id)
const;
218 void set(InputDatasetId
id,
const data_management::NumericTablePtr &value);
225 void set(InputCorrelationId
id,
const data_management::NumericTablePtr &value);
231 size_t getNFeatures()
const DAAL_C11_OVERRIDE;
239 services::Status check(
const daal::algorithms::Parameter *par,
int method)
const DAAL_C11_OVERRIDE;
247 class PartialResultBase :
public daal::algorithms::PartialResult
250 PartialResultBase(
const size_t nElements) : daal::algorithms::PartialResult(nElements) {};
252 virtual size_t getNFeatures()
const = 0;
254 virtual ~PartialResultBase() {};
262 template<Method method>
263 class PartialResult :
public PartialResultBase {};
270 template<>
class DAAL_EXPORT PartialResult<daal::algorithms::pca::correlationDense> :
public PartialResultBase
273 DECLARE_SERIALIZABLE_CAST(PartialResult<daal::algorithms::pca::correlationDense>);
281 data_management::NumericTablePtr
get(PartialCorrelationResultId id)
const;
283 virtual size_t getNFeatures()
const DAAL_C11_OVERRIDE;
290 void set(
const PartialCorrelationResultId
id,
const data_management::NumericTablePtr &value);
292 virtual ~PartialResult() {};
301 services::Status check(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
int method)
const DAAL_C11_OVERRIDE;
310 services::Status check(
const daal::algorithms::Parameter *par,
int method)
const DAAL_C11_OVERRIDE;
319 template <
typename algorithmFPType>
320 DAAL_EXPORT services::Status allocate(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
const int method);
329 template <
typename algorithmFPType>
330 DAAL_EXPORT services::Status initialize(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
const int method);
333 services::Status checkImpl(
size_t nFeatures)
const;
336 template<
typename Archive,
bool onDeserialize>
337 services::Status serialImpl(Archive *arch)
339 return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
348 template<>
class DAAL_EXPORT PartialResult<daal::algorithms::pca::svdDense> :
public PartialResultBase
351 DECLARE_SERIALIZABLE_CAST(PartialResult<daal::algorithms::pca::svdDense>);
359 data_management::NumericTablePtr
get(PartialSVDTableResultId id)
const;
361 virtual size_t getNFeatures()
const DAAL_C11_OVERRIDE;
368 data_management::DataCollectionPtr
get(PartialSVDCollectionResultId id)
const;
376 data_management::NumericTablePtr
get(PartialSVDCollectionResultId id,
const size_t &elementId)
const;
383 void set(PartialSVDTableResultId
id,
const data_management::NumericTablePtr &value);
390 void set(PartialSVDCollectionResultId
id,
const data_management::DataCollectionPtr &value);
397 void add(
const PartialSVDCollectionResultId &
id,
const data_management::DataCollectionPtr &value);
406 services::Status check(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
int method)
const DAAL_C11_OVERRIDE;
414 services::Status check(
const daal::algorithms::Parameter *par,
int method)
const DAAL_C11_OVERRIDE;
416 virtual ~PartialResult() {};
425 template <
typename algorithmFPType>
426 DAAL_EXPORT services::Status allocate(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
const int method);
435 template <
typename algorithmFPType>
436 DAAL_EXPORT services::Status initialize(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
const int method);
440 services::Status checkImpl(
size_t nFeatures)
const;
443 template<
typename Archive,
bool onDeserialize>
444 services::Status serialImpl(Archive *arch)
446 return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
454 template<
typename algorithmFPType, Method method = correlationDense>
455 class DAAL_EXPORT BaseParameter :
public daal::algorithms::Parameter
466 template<
typename algorithmFPType, Method method>
467 class OnlineParameter :
public BaseParameter<algorithmFPType, method> {};
473 template<
typename algorithmFPType>
474 class DAAL_EXPORT OnlineParameter<algorithmFPType, correlationDense> :
public BaseParameter<algorithmFPType, correlationDense>
478 OnlineParameter(
const services::SharedPtr<covariance::OnlineImpl> &covarianceForOnlineParameter =
479 services::SharedPtr<covariance::Online<algorithmFPType, covariance::defaultDense> >
480 (
new covariance::Online<algorithmFPType, covariance::defaultDense>()));
482 services::SharedPtr<covariance::OnlineImpl> covariance;
488 services::Status check() const DAAL_C11_OVERRIDE;
496 template<typename algorithmFPType>
497 class DAAL_EXPORT OnlineParameter<algorithmFPType, svdDense> : public BaseParameter<algorithmFPType, svdDense>
507 services::Status check()
const DAAL_C11_OVERRIDE;
514 template<ComputeStep step,
typename algorithmFPType, Method method>
515 class DistributedParameter :
public BaseParameter<algorithmFPType, method> {};
521 template<
typename algorithmFPType>
522 class DAAL_EXPORT DistributedParameter<step2Master, algorithmFPType, correlationDense> :
public BaseParameter<algorithmFPType, correlationDense>
526 DistributedParameter(
const services::SharedPtr<covariance::DistributedIface<step2Master> > &covarianceForDistributedParameter =
527 services::SharedPtr<covariance::Distributed<step2Master, algorithmFPType, covariance::defaultDense> >
528 (
new covariance::Distributed<step2Master, algorithmFPType, covariance::defaultDense>()));
530 services::SharedPtr<covariance::DistributedIface<step2Master> > covariance;
536 services::Status check() const DAAL_C11_OVERRIDE;
543 template<Method method>
544 class DistributedInput {};
550 template<>
class DAAL_EXPORT DistributedInput<correlationDense> :
public InputIface
554 DistributedInput(
const DistributedInput& other);
561 void set(Step2MasterInputId
id,
const data_management::DataCollectionPtr &ptr);
568 data_management::DataCollectionPtr
get(Step2MasterInputId id)
const;
574 services::SharedPtr<PartialResult<correlationDense> > getPartialResult(
size_t id)
const;
581 void add(Step2MasterInputId
id,
const services::SharedPtr<PartialResult<correlationDense> > &value);
587 size_t getNFeatures()
const DAAL_C11_OVERRIDE;
595 services::Status check(
const daal::algorithms::Parameter *parameter,
int method)
const DAAL_C11_OVERRIDE;
602 template<>
class DAAL_EXPORT DistributedInput<svdDense> :
public InputIface
606 DistributedInput(
const DistributedInput& other);
613 void set(Step2MasterInputId
id,
const data_management::DataCollectionPtr &ptr);
620 data_management::DataCollectionPtr
get(Step2MasterInputId id)
const;
627 void add(Step2MasterInputId
id,
const services::SharedPtr<PartialResult<svdDense> > &value);
633 services::SharedPtr<PartialResult<svdDense> > getPartialResult(
size_t id)
const;
641 services::Status check(
const daal::algorithms::Parameter *parameter,
int method)
const DAAL_C11_OVERRIDE;
647 size_t getNFeatures()
const DAAL_C11_OVERRIDE;
661 class DAAL_EXPORT BaseBatchParameter :
public daal::algorithms::Parameter
665 BaseBatchParameter();
667 DAAL_UINT64 resultsToCompute;
669 bool isDeterministic;
677 template<
typename algorithmFPType, Method method>
678 class BatchParameter {};
685 template<
typename algorithmFPType>
686 class DAAL_EXPORT BatchParameter<algorithmFPType, correlationDense> :
public BaseBatchParameter
690 BatchParameter(
const services::SharedPtr<covariance::BatchImpl> &covarianceForBatchParameter =
691 services::SharedPtr<covariance::Batch<algorithmFPType, covariance::defaultDense> >
692 (
new covariance::Batch<algorithmFPType, covariance::defaultDense>()));
694 services::SharedPtr<covariance::BatchImpl> covariance;
701 services::Status check() const DAAL_C11_OVERRIDE;
708 template<typename algorithmFPType>
709 class DAAL_EXPORT BatchParameter<algorithmFPType, svdDense> : public BaseBatchParameter
713 BatchParameter(
const services::SharedPtr<normalization::zscore::BatchImpl> &normalizationForBatchParameter =
714 services::SharedPtr<normalization::zscore::Batch<algorithmFPType, normalization::zscore::defaultDense> >
715 (
new normalization::zscore::Batch<algorithmFPType, normalization::zscore::defaultDense>()));
717 services::SharedPtr<normalization::zscore::BatchImpl> normalization;
724 services::Status check() const DAAL_C11_OVERRIDE;
731 class DAAL_EXPORT Result : public daal::algorithms::Result
734 DECLARE_SERIALIZABLE_CAST(Result);
735 Result(
const Result& o);
738 virtual ~Result() {};
745 data_management::NumericTablePtr
get(ResultId id)
const;
752 data_management::KeyValueDataCollectionPtr
get(ResultCollectionId id)
const;
760 void set(ResultCollectionId
id, data_management::KeyValueDataCollectionPtr& collection);
768 void set(ResultId
id,
const data_management::NumericTablePtr &value);
776 template<
typename algorithmFPType>
777 DAAL_EXPORT services::Status allocate(
const daal::algorithms::Input *input, daal::algorithms::Parameter *parameter,
const Method method);
784 template<
typename algorithmFPType>
785 DAAL_EXPORT services::Status allocate(
const daal::algorithms::PartialResult *partialResult, daal::algorithms::Parameter *parameter,
const Method method);
794 services::Status check(
const daal::algorithms::Input *_input,
const daal::algorithms::Parameter *par,
int method)
const DAAL_C11_OVERRIDE;
803 services::Status check(
const daal::algorithms::PartialResult *pr,
const daal::algorithms::Parameter *parameter,
int method)
const DAAL_C11_OVERRIDE;
815 services::Status checkImpl(
size_t nFeatures,
size_t nComponents, DAAL_UINT64 resultsToCompute)
const;
818 template<
typename Archive,
bool onDeserialize>
819 services::Status serialImpl(Archive *arch)
821 return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
824 typedef services::SharedPtr<Result> ResultPtr;
827 using interface1::InputIface;
828 using interface1::Input;
829 using interface1::PartialResultBase;
830 using interface1::PartialResult;
831 using interface3::BatchParameter;
832 using interface3::BaseBatchParameter;
833 using interface1::OnlineParameter;
834 using interface1::DistributedParameter;
835 using interface1::DistributedInput;
836 using interface3::Result;
837 using interface3::ResultPtr;
daal::algorithms::pca::mean
Definition: pca_types.h:157
daal::algorithms::pca::eigenvalues
Definition: pca_types.h:133
daal::algorithms::pca::PartialSVDCollectionResultId
PartialSVDCollectionResultId
Definition: pca_types.h:120
daal::algorithms::pca::eigenvectors
Definition: pca_types.h:134
daal::algorithms::pca::correlationDense
Definition: pca_types.h:57
daal::algorithms::pca::ResultCollectionId
ResultCollectionId
Definition: pca_types.h:144
daal::algorithms::pca::variances
Definition: pca_types.h:136
daal::algorithms::pca::interface1::PartialResult< daal::algorithms::pca::correlationDense >
Provides methods to access partial results obtained with the compute() method of the PCA Correlation ...
Definition: pca_types.h:270
daal::algorithms::pca::interface3::Result
Provides methods to access results obtained with the PCA algorithm.
Definition: pca_types.h:731
daal::algorithms::pca::interface1::BaseParameter
Class that specifies the common parameters of the PCA algorithm.
Definition: pca_types.h:455
daal::algorithms::pca::variance
Definition: pca_types.h:158
daal::algorithms::pca::interface3::BaseBatchParameter::resultsToCompute
DAAL_UINT64 resultsToCompute
Definition: pca_types.h:667
daal::step2Master
Definition: daal_defines.h:124
daal::algorithms::pca::interface3::BatchParameter
Class that specifies the parameters of the PCA algorithm in the batch computing mode.
Definition: pca_types.h:678
daal::algorithms::pca::data
Definition: pca_types.h:68
daal::algorithms::pca::interface1::DistributedParameter
Class that specifies the parameters of the PCA algorithm in the distributed computing mode...
Definition: pca_types.h:515
daal::algorithms::pca::Method
Method
Definition: pca_types.h:55
daal::algorithms::pca::svdDense
Definition: pca_types.h:59
daal::algorithms::pca::interface3::BaseBatchParameter::nComponents
size_t nComponents
Definition: pca_types.h:668
daal::algorithms::pca::defaultDense
Definition: pca_types.h:58
daal::algorithms::pca::interface1::Input
Input objects for the PCA algorithm.
Definition: pca_types.h:198
daal::algorithms::pca::ResultId
ResultId
Definition: pca_types.h:131
daal::algorithms::pca::auxiliaryData
Definition: pca_types.h:122
daal::algorithms::pca::interface1::InputIface
Abstract class that specifies interface for classes that declare input of the PCA algorithm...
Definition: pca_types.h:170
daal::algorithms::pca::interface1::PartialResultBase
Provides interface to access partial results obtained with the compute() method of the PCA algorithm ...
Definition: pca_types.h:247
daal::algorithms::pca::PartialCorrelationResultId
PartialCorrelationResultId
Definition: pca_types.h:96
daal::algorithms::pca::interface3::BaseBatchParameter
Class that specifies the common parameters of the PCA Batch algorithms.
Definition: pca_types.h:661
daal::algorithms::pca::interface1::PartialResult
Provides methods to access partial results obtained with the compute() method of the PCA algorithm in...
Definition: pca_types.h:263
daal::algorithms::pca::interface1::DistributedParameter< step2Master, algorithmFPType, correlationDense >::covariance
services::SharedPtr< covariance::DistributedIface< step2Master > > covariance
Definition: pca_types.h:530
daal::algorithms::pca::interface1::PartialResult< daal::algorithms::pca::svdDense >
Provides methods to access partial results obtained with the compute() method of PCA SVD algorithm in...
Definition: pca_types.h:348
daal::algorithms::pca::dataForTransform
Definition: pca_types.h:146
daal::algorithms::pca::eigenvalue
Definition: pca_types.h:159
daal::algorithms::pca::PartialSVDTableResultId
PartialSVDTableResultId
Definition: pca_types.h:108
daal::algorithms::pca::interface1::OnlineParameter< algorithmFPType, correlationDense >::covariance
services::SharedPtr< covariance::OnlineImpl > covariance
Definition: pca_types.h:482
daal::algorithms::pca::partialResults
Definition: pca_types.h:88
daal::algorithms::pca::interface1::InputIface::isCorrelation
virtual bool isCorrelation() const
Definition: pca_types.h:186
daal::algorithms::pca::InputCorrelationId
InputCorrelationId
Definition: pca_types.h:76
daal::algorithms::pca::means
Definition: pca_types.h:135
daal::algorithms::math::abs::value
Definition: abs_types.h:88
daal::algorithms::pca::interface3::BatchParameter< algorithmFPType, correlationDense >::covariance
services::SharedPtr< covariance::BatchImpl > covariance
Definition: pca_types.h:694
daal::algorithms::pca::correlation
Definition: pca_types.h:78
daal::algorithms::pca::interface3::BaseBatchParameter::isDeterministic
bool isDeterministic
Definition: pca_types.h:669
daal::algorithms::pca::distributedInputs
Definition: pca_types.h:123
daal::algorithms::pca::Step2MasterInputId
Step2MasterInputId
Definition: pca_types.h:86
daal::algorithms::pca::InputDatasetId
InputDatasetId
Definition: pca_types.h:66
daal::algorithms::pca::ResultToComputeId
ResultToComputeId
Definition: pca_types.h:154
daal::algorithms::pca::interface1::DistributedInput
Input objects for the PCA algorithm in the distributed processing mode.
Definition: pca_types.h:544
daal::algorithms::pca::interface3::BatchParameter< algorithmFPType, svdDense >::normalization
services::SharedPtr< normalization::zscore::BatchImpl > normalization
Definition: pca_types.h:717
daal::algorithms::pca::interface1::OnlineParameter
Class that specifies the parameters of the PCA algorithm in the online computing mode.
Definition: pca_types.h:467