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