4 #include "casm/external/Eigen/Dense"
17 template<
typename Derived>
18 PCA(
const Eigen::MatrixBase<Derived> &M,
double singular_value_tol = 1e-14) {
22 mat_mean_zero.colwise() -= (M.rowwise().mean());
25 Eigen::JacobiSVD<Eigen::MatrixXd> svd(mat_mean_zero, Eigen::ComputeFullU);
27 for(
Index i = 0; i < svd.singularValues().size(); i++) {
28 if(std::abs(svd.singularValues()[i]) <= singular_value_tol) {
36 m_reduce = svd.matrixU().block(0, 0, M.rows(),
rank).transpose();
41 size_type
dim()
const {
89 Eigen::MatrixXd result = Eigen::MatrixXd::Zero(M.rows() + n, M.cols() + n);
90 result << M, Eigen::MatrixXd::Zero(M.rows(), n),
91 Eigen::MatrixXd::Zero(n, M.cols()), Eigen::MatrixXd::Identity(n, n);
Eigen::MatrixXd pad(const Eigen::MatrixXd &M, int n)
Construct a matrix consisting of blocks M and Identity(n,n)
Eigen::MatrixXd::Index size_type
size_type rank() const
Rank of the input, equivalent to pca.reduce().rows()
PCA(const Eigen::MatrixBase< Derived > &M, double singular_value_tol=1e-14)
Constructor accepting a column vector matrix M containing points [input...].
Principle component analysis.
EigenIndex Index
For long integer indexing:
Eigen::MatrixXd reduce() const
Orthogonal transformation matrix from a point in full [input...] space to dimension-reduced [range(in...
size_type dim() const
Initial dimension, equivalent to pca.reduce().cols()
Eigen::MatrixXd expand() const
Orthogonal transformation matrix from a point in dimension-reduced [range(input...)] space to full [input...] space.