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>
20 IMPALGEBRA_BEGIN_NAMESPACE
29 : eigen_vecs_(pcs), eigen_values_(values), centroid_(centroid) {}
34 VectorD<D> get_principal_component(
unsigned int i)
const {
36 return eigen_vecs_[i];
42 double get_principal_value(
unsigned int i)
const {
44 return eigen_values_[i];
57 "Cannot compare against anything other than the default"
58 " PrincipalComponentAnalysis");
59 if (eigen_vecs_.empty() && o.eigen_vecs_.empty()) {
79 PrincipalComponentAnalysis1Ds;
81 PrincipalComponentAnalysis2Ds;
83 PrincipalComponentAnalysis3Ds;
85 PrincipalComponentAnalysis4Ds;
87 PrincipalComponentAnalysis5Ds;
89 PrincipalComponentAnalysis6Ds;
91 PrincipalComponentAnalysisKDs;
95 if (eigen_vecs_.empty()) {
99 out <<
"vectors: " << eigen_vecs_ <<
" weights: " << eigen_values_
100 <<
" centroid: " << centroid_ << std::endl;
112 unsigned int dim = ps[0].get_dimension();
116 internal::TNT::Array2D<double> cov = internal::get_covariance_matrix(ps, m);
118 internal::JAMA::SVD<double> svd(cov);
119 internal::TNT::Array2D<double> V(dim, dim);
120 internal::TNT::Array1D<double> SV;
124 svd.getSingularValues(SV);
127 for (
unsigned int i = 0; i < dim; ++i) {
129 for (
unsigned int j = 0; j < dim; ++j) {
130 vectors[i][j] = V[j][i];
141 const PrincipalComponentAnalysisD<3> &pca1,
142 const PrincipalComponentAnalysisD<3> &pca2);
145 typedef PrincipalComponentAnalysisD<3> PrincipalComponentAnalysis;
148 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_SHOWABLE(Name)
#define IMP_COMPARISONS(Name)
Implement comparison in a class using a compare function.
#define IMP_LOG_VERBOSE(expr)
Base class for geometric types.
A Cartesian vector in D-dimensions.
int compare(const VectorD< D > &a, const VectorD< D > &b)
lexicographic comparison of two vectors
Logging and error reporting support.
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.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Simple 3D rotation class.
Logging and error reporting support.