22 #ifndef __PCA_TYPES_H__
23 #define __PCA_TYPES_H__
25 #include "algorithms/algorithm.h"
26 #include "data_management/data/numeric_table.h"
27 #include "data_management/data/homogen_numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "algorithms/covariance/covariance_batch.h"
30 #include "algorithms/covariance/covariance_online.h"
31 #include "algorithms/covariance/covariance_distributed.h"
32 #include "algorithms/normalization/zscore.h"
67 lastInputDatasetId = data
74 enum InputCorrelationId
77 lastInputCorrelationId = correlation
84 enum Step2MasterInputId
87 lastStep2MasterInputId = partialResults
94 enum PartialCorrelationResultId
96 nObservationsCorrelation,
97 crossProductCorrelation,
99 lastPartialCorrelationResultId = sumCorrelation
106 enum PartialSVDTableResultId
111 lastPartialSVDTableResultId = sumSquaresSVD
118 enum PartialSVDCollectionResultId
120 auxiliaryData = lastPartialSVDTableResultId + 1,
122 lastPartialSVDCollectionResultId = distributedInputs
135 lastResultId = variances
142 enum ResultCollectionId
152 enum ResultToComputeId
155 mean = 0x00000001ULL,
156 variance = 0x00000002ULL,
157 eigenvalue = 0x00000004ULL
168 class DAAL_EXPORT InputIface :
public daal::algorithms::Input
171 InputIface(
size_t nElements);
172 InputIface(
const InputIface& other);
178 virtual size_t getNFeatures()
const = 0;
184 virtual bool isCorrelation()
const {
return _isCorrelation; };
186 virtual ~InputIface() {};
196 class DAAL_EXPORT Input :
public InputIface
200 Input(
const Input& other);
209 data_management::NumericTablePtr
get(InputDatasetId id)
const;
216 void set(InputDatasetId
id,
const data_management::NumericTablePtr &value);
223 void set(InputCorrelationId
id,
const data_management::NumericTablePtr &value);
229 size_t getNFeatures()
const DAAL_C11_OVERRIDE;
237 services::Status check(
const daal::algorithms::Parameter *par,
int method)
const DAAL_C11_OVERRIDE;
245 class PartialResultBase :
public daal::algorithms::PartialResult
248 PartialResultBase(
const size_t nElements) : daal::algorithms::PartialResult(nElements) {};
250 virtual size_t getNFeatures()
const = 0;
252 virtual ~PartialResultBase() {};
260 template<Method method>
261 class PartialResult :
public PartialResultBase {};
268 template<>
class DAAL_EXPORT PartialResult<daal::algorithms::pca::correlationDense> :
public PartialResultBase
271 DECLARE_SERIALIZABLE_CAST(PartialResult<daal::algorithms::pca::correlationDense>);
279 data_management::NumericTablePtr
get(PartialCorrelationResultId id)
const;
281 virtual size_t getNFeatures()
const DAAL_C11_OVERRIDE;
288 void set(
const PartialCorrelationResultId
id,
const data_management::NumericTablePtr &value);
290 virtual ~PartialResult() {};
299 services::Status check(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
int method)
const DAAL_C11_OVERRIDE;
308 services::Status check(
const daal::algorithms::Parameter *par,
int method)
const DAAL_C11_OVERRIDE;
317 template <
typename algorithmFPType>
318 DAAL_EXPORT services::Status allocate(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
const int method);
327 template <
typename algorithmFPType>
328 DAAL_EXPORT services::Status initialize(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
const int method);
331 services::Status checkImpl(
size_t nFeatures)
const;
334 template<
typename Archive,
bool onDeserialize>
335 services::Status serialImpl(Archive *arch)
337 return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
346 template<>
class DAAL_EXPORT PartialResult<daal::algorithms::pca::svdDense> :
public PartialResultBase
349 DECLARE_SERIALIZABLE_CAST(PartialResult<daal::algorithms::pca::svdDense>);
357 data_management::NumericTablePtr
get(PartialSVDTableResultId id)
const;
359 virtual size_t getNFeatures()
const DAAL_C11_OVERRIDE;
366 data_management::DataCollectionPtr
get(PartialSVDCollectionResultId id)
const;
374 data_management::NumericTablePtr
get(PartialSVDCollectionResultId id,
const size_t &elementId)
const;
381 void set(PartialSVDTableResultId
id,
const data_management::NumericTablePtr &value);
388 void set(PartialSVDCollectionResultId
id,
const data_management::DataCollectionPtr &value);
395 void add(
const PartialSVDCollectionResultId &
id,
const data_management::DataCollectionPtr &value);
404 services::Status check(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
int method)
const DAAL_C11_OVERRIDE;
412 services::Status check(
const daal::algorithms::Parameter *par,
int method)
const DAAL_C11_OVERRIDE;
414 virtual ~PartialResult() {};
423 template <
typename algorithmFPType>
424 DAAL_EXPORT services::Status allocate(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
const int method);
433 template <
typename algorithmFPType>
434 DAAL_EXPORT services::Status initialize(
const daal::algorithms::Input *input,
const daal::algorithms::Parameter *parameter,
const int method);
438 services::Status checkImpl(
size_t nFeatures)
const;
441 template<
typename Archive,
bool onDeserialize>
442 services::Status serialImpl(Archive *arch)
444 return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
452 template<
typename algorithmFPType, Method method = correlationDense>
453 class DAAL_EXPORT BaseParameter :
public daal::algorithms::Parameter
464 template<
typename algorithmFPType, Method method>
465 class OnlineParameter :
public BaseParameter<algorithmFPType, method> {};
471 template<
typename algorithmFPType>
472 class DAAL_EXPORT OnlineParameter<algorithmFPType, correlationDense> :
public BaseParameter<algorithmFPType, correlationDense>
476 OnlineParameter(
const services::SharedPtr<covariance::OnlineImpl> &covarianceForOnlineParameter =
477 services::SharedPtr<covariance::Online<algorithmFPType, covariance::defaultDense> >
478 (
new covariance::Online<algorithmFPType, covariance::defaultDense>()));
480 services::SharedPtr<covariance::OnlineImpl> covariance;
486 services::Status check() const DAAL_C11_OVERRIDE;
494 template<typename algorithmFPType>
495 class DAAL_EXPORT OnlineParameter<algorithmFPType, svdDense> : public BaseParameter<algorithmFPType, svdDense>
505 services::Status check()
const DAAL_C11_OVERRIDE;
512 template<ComputeStep step,
typename algorithmFPType, Method method>
513 class DistributedParameter :
public BaseParameter<algorithmFPType, method> {};
519 template<
typename algorithmFPType>
520 class DAAL_EXPORT DistributedParameter<step2Master, algorithmFPType, correlationDense> :
public BaseParameter<algorithmFPType, correlationDense>
524 DistributedParameter(
const services::SharedPtr<covariance::DistributedIface<step2Master> > &covarianceForDistributedParameter =
525 services::SharedPtr<covariance::Distributed<step2Master, algorithmFPType, covariance::defaultDense> >
526 (
new covariance::Distributed<step2Master, algorithmFPType, covariance::defaultDense>()));
528 services::SharedPtr<covariance::DistributedIface<step2Master> > covariance;
534 services::Status check() const DAAL_C11_OVERRIDE;
541 template<Method method>
542 class DistributedInput {};
548 template<>
class DAAL_EXPORT DistributedInput<correlationDense> :
public InputIface
552 DistributedInput(
const DistributedInput& other);
559 void set(Step2MasterInputId
id,
const data_management::DataCollectionPtr &ptr);
566 data_management::DataCollectionPtr
get(Step2MasterInputId id)
const;
572 services::SharedPtr<PartialResult<correlationDense> > getPartialResult(
size_t id)
const;
579 void add(Step2MasterInputId
id,
const services::SharedPtr<PartialResult<correlationDense> > &value);
585 size_t getNFeatures()
const DAAL_C11_OVERRIDE;
593 services::Status check(
const daal::algorithms::Parameter *parameter,
int method)
const DAAL_C11_OVERRIDE;
600 template<>
class DAAL_EXPORT DistributedInput<svdDense> :
public InputIface
604 DistributedInput(
const DistributedInput& other);
611 void set(Step2MasterInputId
id,
const data_management::DataCollectionPtr &ptr);
618 data_management::DataCollectionPtr
get(Step2MasterInputId id)
const;
625 void add(Step2MasterInputId
id,
const services::SharedPtr<PartialResult<svdDense> > &value);
631 services::SharedPtr<PartialResult<svdDense> > getPartialResult(
size_t id)
const;
639 services::Status check(
const daal::algorithms::Parameter *parameter,
int method)
const DAAL_C11_OVERRIDE;
645 size_t getNFeatures()
const DAAL_C11_OVERRIDE;
659 class DAAL_EXPORT BaseBatchParameter :
public daal::algorithms::Parameter
663 BaseBatchParameter();
665 DAAL_UINT64 resultsToCompute;
667 bool isDeterministic;
675 template<
typename algorithmFPType, Method method>
676 class BatchParameter {};
683 template<
typename algorithmFPType>
684 class DAAL_EXPORT BatchParameter<algorithmFPType, correlationDense> :
public BaseBatchParameter
688 BatchParameter(
const services::SharedPtr<covariance::BatchImpl> &covarianceForBatchParameter =
689 services::SharedPtr<covariance::Batch<algorithmFPType, covariance::defaultDense> >
690 (
new covariance::Batch<algorithmFPType, covariance::defaultDense>()));
692 services::SharedPtr<covariance::BatchImpl> covariance;
699 services::Status check() const DAAL_C11_OVERRIDE;
706 template<typename algorithmFPType>
707 class DAAL_EXPORT BatchParameter<algorithmFPType, svdDense> : public BaseBatchParameter
711 BatchParameter(
const services::SharedPtr<normalization::zscore::BatchImpl> &normalizationForBatchParameter =
712 services::SharedPtr<normalization::zscore::Batch<algorithmFPType, normalization::zscore::defaultDense> >
713 (
new normalization::zscore::Batch<algorithmFPType, normalization::zscore::defaultDense>()));
715 services::SharedPtr<normalization::zscore::BatchImpl> normalization;
722 services::Status check() const DAAL_C11_OVERRIDE;
729 class DAAL_EXPORT Result : public daal::algorithms::Result
732 DECLARE_SERIALIZABLE_CAST(Result);
733 Result(
const Result& o);
736 virtual ~Result() {};
743 data_management::NumericTablePtr
get(ResultId id)
const;
750 data_management::KeyValueDataCollectionPtr
get(ResultCollectionId id)
const;
758 void set(ResultCollectionId
id, data_management::KeyValueDataCollectionPtr& collection);
766 void set(ResultId
id,
const data_management::NumericTablePtr &value);
774 template<
typename algorithmFPType>
775 DAAL_EXPORT services::Status allocate(
const daal::algorithms::Input *input, daal::algorithms::Parameter *parameter,
const Method method);
782 template<
typename algorithmFPType>
783 DAAL_EXPORT services::Status allocate(
const daal::algorithms::PartialResult *partialResult, daal::algorithms::Parameter *parameter,
const Method method);
792 services::Status check(
const daal::algorithms::Input *_input,
const daal::algorithms::Parameter *par,
int method)
const DAAL_C11_OVERRIDE;
801 services::Status check(
const daal::algorithms::PartialResult *pr,
const daal::algorithms::Parameter *parameter,
int method)
const DAAL_C11_OVERRIDE;
813 services::Status checkImpl(
size_t nFeatures,
size_t nComponents, DAAL_UINT64 resultsToCompute)
const;
816 template<
typename Archive,
bool onDeserialize>
817 services::Status serialImpl(Archive *arch)
819 return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
822 typedef services::SharedPtr<Result> ResultPtr;
825 using interface1::InputIface;
826 using interface1::Input;
827 using interface1::PartialResultBase;
828 using interface1::PartialResult;
829 using interface3::BatchParameter;
830 using interface3::BaseBatchParameter;
831 using interface1::OnlineParameter;
832 using interface1::DistributedParameter;
833 using interface1::DistributedInput;
834 using interface3::Result;
835 using interface3::ResultPtr;
daal::algorithms::pca::defaultDense
Definition: pca_types.h:56
daal::algorithms::pca::interface1::DistributedParameter
Class that specifies the parameters of the PCA algorithm in the distributed computing mode...
Definition: pca_types.h:513
daal::algorithms::pca::interface3::BatchParameter< algorithmFPType, correlationDense >::covariance
services::SharedPtr< covariance::BatchImpl > covariance
Definition: pca_types.h:692
daal::algorithms::pca::interface3::BaseBatchParameter::resultsToCompute
DAAL_UINT64 resultsToCompute
Definition: pca_types.h:665
daal::algorithms::pca::data
Definition: pca_types.h:66
daal::algorithms::pca::PartialCorrelationResultId
PartialCorrelationResultId
Definition: pca_types.h:94
daal::algorithms::pca::dataForTransform
Definition: pca_types.h:144
daal::algorithms::pca::auxiliaryData
Definition: pca_types.h:120
daal
Definition: algorithm_base_common.h:31
daal::algorithms::pca::interface3::BatchParameter
Class that specifies the parameters of the PCA algorithm in the batch computing mode.
Definition: pca_types.h:676
daal::algorithms::pca::interface1::BaseParameter
Class that specifies the common parameters of the PCA algorithm.
Definition: pca_types.h:453
daal::algorithms::pca::interface1::PartialResultBase
Provides interface to access partial results obtained with the compute() method of the PCA algorithm ...
Definition: pca_types.h:245
daal::algorithms::pca::interface3::BaseBatchParameter
Class that specifies the common parameters of the PCA Batch algorithms.
Definition: pca_types.h:659
daal::algorithms::pca::ResultCollectionId
ResultCollectionId
Definition: pca_types.h:142
daal::algorithms::pca::eigenvalue
Definition: pca_types.h:157
daal::algorithms::pca::eigenvalues
Definition: pca_types.h:131
daal::algorithms::pca::interface1::InputIface::isCorrelation
virtual bool isCorrelation() const
Definition: pca_types.h:184
daal::algorithms::pca::correlation
Definition: pca_types.h:76
daal::algorithms::pca::interface1::DistributedParameter< step2Master, algorithmFPType, correlationDense >::covariance
services::SharedPtr< covariance::DistributedIface< step2Master > > covariance
Definition: pca_types.h:528
daal::algorithms::pca::means
Definition: pca_types.h:133
daal::algorithms::pca::variance
Definition: pca_types.h:156
daal::algorithms::pca::interface1::OnlineParameter
Class that specifies the parameters of the PCA algorithm in the online computing mode.
Definition: pca_types.h:465
daal::algorithms::pca::InputCorrelationId
InputCorrelationId
Definition: pca_types.h:74
daal::algorithms::pca::eigenvectors
Definition: pca_types.h:132
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:346
daal::algorithms::pca::Step2MasterInputId
Step2MasterInputId
Definition: pca_types.h:84
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:261
daal::algorithms::pca::InputDatasetId
InputDatasetId
Definition: pca_types.h:64
daal::algorithms::pca::variances
Definition: pca_types.h:134
daal::algorithms::pca::svdDense
Definition: pca_types.h:57
daal::algorithms::pca::PartialSVDTableResultId
PartialSVDTableResultId
Definition: pca_types.h:106
daal::algorithms::pca::interface3::Result
Provides methods to access results obtained with the PCA algorithm.
Definition: pca_types.h:729
daal::algorithms::pca::Method
Method
Definition: pca_types.h:53
daal::algorithms::pca::ResultToComputeId
ResultToComputeId
Definition: pca_types.h:152
daal::algorithms::pca::interface1::OnlineParameter< algorithmFPType, correlationDense >::covariance
services::SharedPtr< covariance::OnlineImpl > covariance
Definition: pca_types.h:480
daal::algorithms::math::abs::value
Definition: abs_types.h:86
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:268
daal::algorithms::pca::interface3::BatchParameter< algorithmFPType, svdDense >::normalization
services::SharedPtr< normalization::zscore::BatchImpl > normalization
Definition: pca_types.h:715
daal::algorithms::pca::interface3::BaseBatchParameter::isDeterministic
bool isDeterministic
Definition: pca_types.h:667
daal::step2Master
Definition: daal_defines.h:122
daal::algorithms::pca::PartialSVDCollectionResultId
PartialSVDCollectionResultId
Definition: pca_types.h:118
daal::algorithms::pca::mean
Definition: pca_types.h:155
daal::algorithms::pca::distributedInputs
Definition: pca_types.h:121
daal::algorithms::pca::interface3::BaseBatchParameter::nComponents
size_t nComponents
Definition: pca_types.h:666
daal::algorithms::pca::partialResults
Definition: pca_types.h:86
daal::algorithms::pca::correlationDense
Definition: pca_types.h:55
daal::algorithms::pca::ResultId
ResultId
Definition: pca_types.h:129