20 using namespace shogun;
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