21 using namespace Eigen;
23 namespace { MatrixXd cor(MatrixXd x,
int tau = 0,
bool mean_flag =
true); };
33 m_tau[0]=0; m_tau[1]=1; m_tau[2]=2; m_tau[3]=3;
70 Map<MatrixXd> EX(X.
matrix,n,m);
73 MatrixXd M0 = cor(EX,
int(m_tau[0]));
74 EigenSolver<MatrixXd> eig;
76 MatrixXd SPH = (eig.pseudoEigenvectors() * eig.pseudoEigenvalueMatrix().cwiseSqrt() * eig.pseudoEigenvectors ().transpose()).inverse();
77 MatrixXd spx = SPH*EX;
86 for(
int t = 0; t < N; t++)
89 EM = cor(spx,m_tau[t]);
94 Map<MatrixXd> EQ(Q.
matrix,n,n);
99 C = SPH.
inverse() * EQ.transpose();
102 for(
int t = 0; t < C.cols(); t++)
104 C.col(t) /= C.col(t).maxCoeff();
116 MatrixXd cor(MatrixXd x,
int tau,
bool mean_flag)
124 VectorXd mean = x.rowwise().sum();
126 x = x.colwise() - mean;
130 MatrixXd L = x.leftCols(n-tau);
131 MatrixXd R = x.rightCols(n-tau);
135 K = (L * R.transpose()) / (n-tau);
138 K = (K + K.transpose()) / 2.0;
143 #endif // HAVE_EIGEN3 T * get_matrix(index_t matIdx) const
void set_tau(SGVector< float64_t > tau)
static SGMatrix< float64_t > diagonalize(SGNDArray< float64_t > C, SGMatrix< float64_t > V0=SGMatrix< float64_t >(NULL, 0, 0, false), double eps=CMath::MACHINE_EPSILON, int itermax=200)
SGVector< float64_t > get_tau() const
virtual CFeatures * apply(CFeatures *features)
static void inverse(SGMatrix< float64_t > matrix)
inverses square matrix in-place
all of classes and functions are contained in the shogun namespace
class ICAConverter Base class for ICA algorithms
The class Features is the base class of all feature objects.
SGMatrix< float64_t > m_mixing_matrix
SGNDArray< float64_t > get_covs() const