8 #ifndef IMPALGEBRA_EIGEN_ANALYSIS_H
9 #define IMPALGEBRA_EIGEN_ANALYSIS_H
14 #include "IMP/algebra/internal/utility.h"
16 #include <IMP/algebra/internal/jama_svd.h>
19 IMPALGEBRA_BEGIN_NAMESPACE
28 : eigen_vecs_(pcs), eigen_values_(values), centroid_(centroid) {}
33 VectorD<D> get_principal_component(
unsigned int i)
const {
35 return eigen_vecs_[i];
41 double get_principal_value(
unsigned int i)
const {
43 return eigen_values_[i];
56 "Cannot compare against anything other than the default"
57 " PrincipalComponentAnalysis");
58 if (eigen_vecs_.empty() && o.eigen_vecs_.empty()) {
78 PrincipalComponentAnalysis1Ds;
80 PrincipalComponentAnalysis2Ds;
82 PrincipalComponentAnalysis3Ds;
84 PrincipalComponentAnalysis4Ds;
86 PrincipalComponentAnalysis5Ds;
88 PrincipalComponentAnalysis6Ds;
90 PrincipalComponentAnalysisKDs;
94 if (eigen_vecs_.empty()) {
98 out <<
"vectors: " << eigen_vecs_ <<
" weights: " << eigen_values_
99 <<
" centroid: " << centroid_ << std::endl;
111 unsigned int dim = ps[0].get_dimension();
115 internal::TNT::Array2D<double> cov = internal::get_covariance_matrix(ps, m);
117 internal::JAMA::SVD<double> svd(cov);
118 internal::TNT::Array2D<double> V(dim, dim);
119 internal::TNT::Array1D<double> SV;
123 svd.getSingularValues(SV);
126 for (
unsigned int i = 0; i < dim; ++i) {
128 for (
unsigned int j = 0; j < dim; ++j) {
129 vectors[i][j] = V[j][i];
140 const PrincipalComponentAnalysisD<3> &pca1,
141 const PrincipalComponentAnalysisD<3> &pca2);
144 typedef PrincipalComponentAnalysisD<3> PrincipalComponentAnalysis;
147 IMPALGEBRA_END_NAMESPACE
VectorD< D > get_zero_vector_kd(int Di)
Return a dynamically sized vector of zeros.
PrincipalComponentAnalysisD< D > get_principal_components(const base::Vector< VectorD< D > > &ps)
Perform principal components analysis on a set of vectors.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
#define IMP_COMPARISONS(Name)
Implement comparison in a class using a compare function.
#define IMP_SHOWABLE(Name)
A Cartesian vector in D-dimensions.
int compare(const VectorD< D > &a, const VectorD< D > &b)
lexicographic comparison of two vectors
IMP::base::Vector< Transformation3D > Transformation3Ds
Transformation3Ds get_alignments_from_first_to_second(const PrincipalComponentAnalysisD< 3 > &pca1, const PrincipalComponentAnalysisD< 3 > &pca2)
Vector3D get_centroid(const Vector3Ds &ps)
Returns the centroid of a set of vectors.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
Logging and error reporting support.
Simple 3D rotation class.
#define IMP_LOG_VERBOSE(expr)