gstlearn  1.0.0
CCC
PCA Class Reference

#include <PCA.hpp>

Inheritance diagram for PCA:
AStringable

Public Member Functions

 PCA (int nvar=0)
 
 PCA (const PCA &m)
 
PCAoperator= (const PCA &m)
 
virtual ~PCA ()
 
virtual String toString (const AStringFormat *strfmt=nullptr) const override
 Interface for AStringable. More...
 
void init (int nvar)
 
const VectorDoublegetEigVals () const
 
double getEigVal (int ivar) const
 
const VectorDoublegetEigVecs () const
 
double getEigVec (int ivar, int jvar) const
 
VectorDouble getVarianceRatio () const
 
const VectorDoublegetMeans () const
 
double getMean (int ivar) const
 
int getNVar () const
 
const VectorDoublegetF2Zs () const
 
double getF2Z (int ivar, int jvar) const
 
const VectorDoublegetZ2Fs () const
 
double getZ2F (int ivar, int jvar) const
 
const VectorDoublegetSigmas () const
 
double getSigma (int ivar) const
 
void setMeans (const VectorDouble &mean)
 
void setSigmas (const VectorDouble &sigma)
 
void setZ2Fs (const VectorDouble &z2f)
 
void setZ2F (int ivar, int jvar, double z2f)
 
void setF2Zs (VectorDouble &f2z)
 
void setF2Z (int ivar, int jvar, double f2z)
 
void setEigVals (VectorDouble &eigval)
 
void setEigVal (int ivar, double eigval)
 
void setEigVecs (const VectorDouble &eigvec)
 
void setEigVec (int ivar, int jvar, double eigvec)
 
int pca_compute (const Db *db, bool verbose=false)
 
int maf_compute (Db *db, const VarioParam &varioparam, int ilag0=1, int idir0=0, bool verbose=false)
 
int maf_compute_interval (Db *db, double hmin, double hmax, bool verbose=false)
 
int dbZ2F (Db *db, bool verbose=false, const NamingConvention &namconv=NamingConvention("F", false))
 
int dbF2Z (Db *db, bool verbose=false, const NamingConvention &namconv=NamingConvention("Z", false))
 
VectorDouble mafOfIndex () const
 
- Public Member Functions inherited from AStringable
 AStringable ()
 
 AStringable (const AStringable &r)
 
AStringableoperator= (const AStringable &r)
 
virtual ~AStringable ()
 
virtual void display (const AStringFormat *strfmt=nullptr) const final
 
virtual void display (int level) const final
 

Private Member Functions

int _getAddress (int ivar, int jvar) const
 
VectorBool _getVectorIsotopic (const Db *db)
 
void _loadData (const Db *db, int iech, VectorDouble &data)
 
int _calculateEigen (bool verbose=false)
 
int _calculateGEigen (bool verbose)
 
void _calculateNormalization (const Db *db, const VectorBool &isoFlag, bool verbose=false, bool flag_nm1=false)
 
void _covariance0 (const Db *db, const VectorBool &isoFlag, bool verbose=false, bool flag_nm1=false)
 
void _variogramh (Db *db, const VarioParam &varioparam, int ilag0, int idir0, double hmin, double hmax, const VectorBool &isoFlag, bool verbose)
 
void _center (VectorDouble &data, const VectorDouble &mean, const VectorDouble &sigma, bool flag_center=true, bool flag_scale=false)
 
void _uncenter (VectorDouble &data, const VectorDouble &mean, const VectorDouble &sigma, bool flag_center=true, bool flag_scale=false)
 
void _pcaZ2F (int iptr, Db *db, const VectorBool isoFlag, const VectorDouble &mean, const VectorDouble &sigma)
 
void _pcaF2Z (int iptr, Db *db, const VectorBool &isoFlag, const VectorDouble &mean, const VectorDouble &sigma)
 
void _pcaFunctions (bool verbose)
 
void _mafFunctions (bool verbose)
 
int _mafCompute (Db *db, const VarioParam &varioparam, int ilag0, int idir0, double hmin, double hmax, bool verbose)
 

Private Attributes

int _nVar
 
VectorDouble _mean
 
VectorDouble _sigma
 
VectorDouble _eigval
 
VectorDouble _eigvec
 
VectorDouble _c0
 
VectorDouble _gh
 
VectorDouble _Z2F
 
VectorDouble _F2Z
 

Constructor & Destructor Documentation

◆ PCA() [1/2]

PCA::PCA ( int  nvar = 0)

◆ PCA() [2/2]

PCA::PCA ( const PCA m)

◆ ~PCA()

PCA::~PCA ( )
virtual

Member Function Documentation

◆ _calculateEigen()

int PCA::_calculateEigen ( bool  verbose = false)
private

◆ _calculateGEigen()

int PCA::_calculateGEigen ( bool  verbose)
private

◆ _calculateNormalization()

void PCA::_calculateNormalization ( const Db db,
const VectorBool isoFlag,
bool  verbose = false,
bool  flag_nm1 = false 
)
private

Fill the mean and variance arrays

Parameters
[in]dbDb descriptor
[in]isoFlagVector of active samples
[in]verboseVerbose flag
[in]flag_nm1When TRUE, variance is scaled by N-1; otherwise by N

◆ _center()

void PCA::_center ( VectorDouble data,
const VectorDouble mean,
const VectorDouble sigma,
bool  flag_center = true,
bool  flag_scale = false 
)
private

Normalize the isotropic array of values

Parameters
[in,out]dataArray of information
[in]meanArray containing the mean
[in]sigmaArray containing the standard deviation
[in]flag_centerTrue if result must be centered by 'mean'
[in]flag_scaleTrue if result must be scaled by 'sigma'

◆ _covariance0()

void PCA::_covariance0 ( const Db db,
const VectorBool isoFlag,
bool  verbose = false,
bool  flag_nm1 = false 
)
private

Calculate the covariance matrix

Parameters
[in]dbDb descriptor
[in]isoFlagVector of active samples
[in]verboseVerbose flag
[in]flag_nm1When TRUE, variance is scaled by N-1; otherwise by N

◆ _getAddress()

int PCA::_getAddress ( int  ivar,
int  jvar 
) const
inlineprivate

◆ _getVectorIsotopic()

VectorBool PCA::_getVectorIsotopic ( const Db db)
private

◆ _loadData()

void PCA::_loadData ( const Db db,
int  iech,
VectorDouble data 
)
private

◆ _mafCompute()

int PCA::_mafCompute ( Db db,
const VarioParam varioparam,
int  ilag0,
int  idir0,
double  hmin,
double  hmax,
bool  verbose 
)
private

Evaluate the MAF on irregular data

Returns
Error returned code
Parameters
[in]dbDb descriptor
[in]varioparamVarioParam structure
[in]ilag0Reference Lag
[in]idir0Reference direction
[in]hminMinimum distance
[in]hmaxMaximum distance
[in]verboseVerbose flag
Remarks
This code functions in two modes:
- either using varioparam, idir0 and ilag0 (if idir0>=0)
- or using only hmin, hmax

◆ _mafFunctions()

void PCA::_mafFunctions ( bool  verbose)
private

◆ _pcaF2Z()

void PCA::_pcaF2Z ( int  iptr,
Db db,
const VectorBool isoFlag,
const VectorDouble mean,
const VectorDouble sigma 
)
private

Procedure for transforming the factors into variables using PCA

Parameters
[in]iptrPointer to the storage
[in]dbDb descriptor
[in]isoFlagVector of active samples
[in]meanArray containing the mean
[in]sigmaArray containing the standard deviation

◆ _pcaFunctions()

void PCA::_pcaFunctions ( bool  verbose)
private

◆ _pcaZ2F()

void PCA::_pcaZ2F ( int  iptr,
Db db,
const VectorBool  isoFlag,
const VectorDouble mean,
const VectorDouble sigma 
)
private

Procedure for transforming the variables into factors using PCA

Parameters
[in]iptrPointer for storing the result in db
[in]dbDb descriptor
[in]isoFlagVector of active samples
[in]meanArray containing the mean
[in]sigmaArray containing the standard deviation

◆ _uncenter()

void PCA::_uncenter ( VectorDouble data,
const VectorDouble mean,
const VectorDouble sigma,
bool  flag_center = true,
bool  flag_scale = false 
)
private

Un-normalize the isotropic array of values

Parameters
[in,out]dataArray of information
[in]meanArray containing the mean
[in]sigmaArray containing the standard deviation
[in]flag_centerTrue if result must be uncentered by 'mean'
[in]flag_scaleTrue if result must be suncaled by 'sigma'

◆ _variogramh()

void PCA::_variogramh ( Db db,
const VarioParam varioparam,
int  ilag0,
int  idir0,
double  hmin,
double  hmax,
const VectorBool isoFlag,
bool  verbose 
)
private

◆ dbF2Z()

int PCA::dbF2Z ( Db db,
bool  verbose = false,
const NamingConvention namconv = NamingConvention("Z", false) 
)

◆ dbZ2F()

int PCA::dbZ2F ( Db db,
bool  verbose = false,
const NamingConvention namconv = NamingConvention("F", false) 
)

◆ getEigVal()

double PCA::getEigVal ( int  ivar) const
inline

◆ getEigVals()

const VectorDouble& PCA::getEigVals ( ) const
inline

◆ getEigVec()

double PCA::getEigVec ( int  ivar,
int  jvar 
) const
inline

◆ getEigVecs()

const VectorDouble& PCA::getEigVecs ( ) const
inline

◆ getF2Z()

double PCA::getF2Z ( int  ivar,
int  jvar 
) const
inline

◆ getF2Zs()

const VectorDouble& PCA::getF2Zs ( ) const
inline

◆ getMean()

double PCA::getMean ( int  ivar) const
inline

◆ getMeans()

const VectorDouble& PCA::getMeans ( ) const
inline

◆ getNVar()

int PCA::getNVar ( ) const
inline

◆ getSigma()

double PCA::getSigma ( int  ivar) const
inline

◆ getSigmas()

const VectorDouble& PCA::getSigmas ( ) const
inline

◆ getVarianceRatio()

VectorDouble PCA::getVarianceRatio ( ) const

◆ getZ2F()

double PCA::getZ2F ( int  ivar,
int  jvar 
) const
inline

◆ getZ2Fs()

const VectorDouble& PCA::getZ2Fs ( ) const
inline

◆ init()

void PCA::init ( int  nvar)

◆ maf_compute()

int PCA::maf_compute ( Db db,
const VarioParam varioparam,
int  ilag0 = 1,
int  idir0 = 0,
bool  verbose = false 
)

Evaluate the MAF

Returns
Error return code
Parameters
[in]dbDb descriptor
[in]varioparamVarioParam structure
[in]ilag0Reference Lag
[in]idir0Reference direction
[in]verboseVerbose flag

◆ maf_compute_interval()

int PCA::maf_compute_interval ( Db db,
double  hmin,
double  hmax,
bool  verbose = false 
)

Evaluate the MAF

Returns
Error return code
Parameters
[in]dbDb descriptor
[in]hminLower bound on distance
[in]hmaxUpper bound on distance
[in]verboseVerbose flag

◆ mafOfIndex()

VectorDouble PCA::mafOfIndex ( ) const

◆ operator=()

PCA & PCA::operator= ( const PCA m)

◆ pca_compute()

int PCA::pca_compute ( const Db db,
bool  verbose = false 
)

◆ setEigVal()

void PCA::setEigVal ( int  ivar,
double  eigval 
)
inline

◆ setEigVals()

void PCA::setEigVals ( VectorDouble eigval)
inline

◆ setEigVec()

void PCA::setEigVec ( int  ivar,
int  jvar,
double  eigvec 
)
inline

◆ setEigVecs()

void PCA::setEigVecs ( const VectorDouble eigvec)
inline

◆ setF2Z()

void PCA::setF2Z ( int  ivar,
int  jvar,
double  f2z 
)
inline

◆ setF2Zs()

void PCA::setF2Zs ( VectorDouble f2z)
inline

◆ setMeans()

void PCA::setMeans ( const VectorDouble mean)
inline

◆ setSigmas()

void PCA::setSigmas ( const VectorDouble sigma)
inline

◆ setZ2F()

void PCA::setZ2F ( int  ivar,
int  jvar,
double  z2f 
)
inline

◆ setZ2Fs()

void PCA::setZ2Fs ( const VectorDouble z2f)
inline

◆ toString()

String PCA::toString ( const AStringFormat strfmt = nullptr) const
overridevirtual

Interface for AStringable.

Reimplemented from AStringable.

Member Data Documentation

◆ _c0

VectorDouble PCA::_c0
private

◆ _eigval

VectorDouble PCA::_eigval
private

◆ _eigvec

VectorDouble PCA::_eigvec
private

◆ _F2Z

VectorDouble PCA::_F2Z
private

◆ _gh

VectorDouble PCA::_gh
private

◆ _mean

VectorDouble PCA::_mean
private

◆ _nVar

int PCA::_nVar
private

◆ _sigma

VectorDouble PCA::_sigma
private

◆ _Z2F

VectorDouble PCA::_Z2F
private

The documentation for this class was generated from the following files: