@@ -497,7 +497,7 @@ ParticleShapeStatistics::ParticleShapeStatistics(std::shared_ptr<Project> projec
497497
498498// ---------------------------------------------------------------------------
499499int ParticleShapeStatistics::do_pca (std::vector<std::vector<Point>> global_pts, int domainsPerShape) {
500- this -> domains_per_shape_ = domainsPerShape;
500+ domains_per_shape_ = domainsPerShape;
501501
502502 // Assumes all the same size.
503503 num_samples_ = global_pts.size () / domains_per_shape_;
@@ -508,11 +508,6 @@ int ParticleShapeStatistics::do_pca(std::vector<std::vector<Point>> global_pts,
508508 mean_.resize (num_dimensions_);
509509 mean_.fill (0 );
510510
511- std::cout << " VDimension = " << values_per_particle_ << " -------------\n " ;
512- std::cout << " m_numSamples = " << num_samples_ << " -------------\n " ;
513- std::cout << " m_domainsPerShape = " << domains_per_shape_ << " -------------\n " ;
514- std::cout << " global_pts.size() = " << global_pts.size () << " -------------\n " ;
515-
516511 // Compile the "meta shapes"
517512 for (unsigned int i = 0 ; i < num_samples_; i++) {
518513 for (unsigned int k = 0 ; k < domains_per_shape_; k++) {
@@ -638,6 +633,13 @@ int ParticleShapeStatistics::principal_component_projections() {
638633 return 0 ;
639634}
640635
636+ // ---------------------------------------------------------------------------
637+ Eigen::VectorXd ParticleShapeStatistics::project_new_sample (const Eigen::VectorXd& new_sample) {
638+ // Subtract mean and project onto principal components
639+ Eigen::VectorXd centered_sample = new_sample - mean_;
640+ return eigenvectors_.transpose () * centered_sample;
641+ }
642+
641643// ---------------------------------------------------------------------------
642644int ParticleShapeStatistics::write_csv_file (const std::string& s) {
643645 // Write csv file
0 commit comments