template class xf::fintech::PCA

#include "pca.hpp"


Class that will compute the Principal Component Analysis of some input data. Data is assumed to be a set of at most MAX_VARS variables in the rows and at most MAX_OBS observations in the columns.


DT The data type to be used
N The number of components to select from the PCA .
NCU Number of computational units to improve parallelism
MAX_VARS Maximum number of synthetisable rows.
MAX_OBS Maximum number of synthetisable cols.
IMPL_METHOD Choice of implementation method. By default it will use the covariance matrix.
template <
    typename DT,
    unsigned int N,
    unsigned int NCU,
    unsigned int MAX_VARS,
    unsigned int MAX_OBS,
    pcaImplementationMethod IMPL_METHOD = pcaImplementationMethod::Covariance
class PCA



    const unsigned int noVars,
    const unsigned int noObs,
    DT data [MAX_VARS][MAX_OBS]

Calculates the core Principal Component Analysis functionality from the provided matrix with the given method.


noVars Number of variables (rows) in the matrix.
noObs Number of observations (cols) in the matrix.
data The matrix with the data to be analysed.


void getExplainedVariance (DT values [N])

Gets the N principal components’ variance of the input data.


values Vector of N elements wide where the PCA values will be stored.


void getComponents (DT vectors [MAX_VARS][N])

Gets the N principal components of the input data.


vectors Matrix of MAX_VARS x N elements wide where the principal components will be stored.


void getLoadingsMatrix (DT loadings [MAX_VARS][N])

Calculate the loadings matrix of the fitted data.


\[loadings = components^T * \sqrt{explainedVariance}\]


loadings Matrix of MAX_VARS x N elements where the PCA loadings will be stored.