Xmipp  v3.23.11-Nereus
Macros | Functions
pca.cpp File Reference
#include <sstream>
#include "pca.h"
Include dependency graph for pca.cpp:

Go to the source code of this file.

Macros

#define rotate(a, i, j, k, l)
 

Functions

std::ostream & operator<< (std::ostream &out, const PCAAnalyzer &PC)
 
std::istream & operator>> (std::istream &in, PCAAnalyzer &PC)
 
std::ostream & operator<< (std::ostream &out, const PCA_set &PS)
 
std::istream & operator>> (std::istream &in, PCA_set &PS)
 

Macro Definition Documentation

◆ rotate

#define rotate (   a,
  i,
  j,
  k,
 
)
Value:
g = a[i][j]; \
h = a[k][l]; \
a[i][j] = g - s *(h + g*tau); \
a[k][l] = h + s*(g - h*tau);
doublereal * g
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
#define j
doublereal * a

Function Documentation

◆ operator<<() [1/2]

std::ostream& operator<< ( std::ostream &  out,
const PCAAnalyzer PC 
)

Show relevant eigenvectors and eigenvalues

Definition at line 369 of file pca.cpp.

370 {
371  out << "Relevant Dimension: " << PC.get_Dimension() << std::endl;
372  out << "Mean vector: ";
373  int size = PC.mean.size();
374  out << "(" << size << ") ---> ";
375  for (int j = 0; j < size; j++)
376  out << PC.mean[j] << " ";
377  out << std::endl;
378  for (int i = 0; i < PC.get_Dimension(); i++)
379  {
380  out << PC.eigenval[i] << " (" << size << ") ---> ";
381  for (int j = 0; j < size; j++)
382  out << PC.eigenvec[i][j] << " ";
383  out << std::endl;
384  }
385  return out;
386 }
#define i
for(j=1;j<=i__1;++j)
#define j
int get_Dimension() const
Definition: pca.h:136
FeatureVector mean
Definition: pca.h:92
FeatureVector eigenval
Definition: pca.h:87
std::vector< FeatureVector > eigenvec
Definition: pca.h:82

◆ operator<<() [2/2]

std::ostream& operator<< ( std::ostream &  out,
const PCA_set PS 
)

Show all PCA

Definition at line 438 of file pca.cpp.

439 {
440  int imax = PS.PCA.size();
441  out << "Number of PCAs: " << imax << std::endl;
442  for (int i = 0; i < imax; i++)
443  out << PS.PCA[i];
444  return out;
445 }
#define i
std::vector< PCAAnalyzer > PCA
Definition: pca.h:191

◆ operator>>() [1/2]

std::istream& operator>> ( std::istream &  in,
PCAAnalyzer PC 
)

Read a set of PCA just as shown

Definition at line 388 of file pca.cpp.

389 {
390  PC.clear();
391  int D;
392  std::string read_line;
393  getline(in, read_line);
394  sscanf(read_line.c_str(), "Relevant Dimension: %d", &D);
395  PC.set_Dimension(D);
396  PC.eigenval.resize(D);
397  PC.eigenvec.resize(D);
398 
399  int size;
400  getline(in, read_line);
401  sscanf(read_line.c_str(), "Mean vector: (%d) --->", &size);
402  read_line.erase(0, read_line.find('>') + 1); // remove until --->
403  PC.mean.resize(size);
404  std::istringstream istr1(read_line.c_str());
405  for (int j = 0; j < size; j++)
406  istr1 >> PC.mean[j];
407 
408  for (int i = 0; i < D; i++)
409  {
410  getline(in, read_line);
411  float f;
412  sscanf(read_line.c_str(), "%f (%d) ---> ", &f, &size);
413  PC.eigenval[i] = f;
414  read_line.erase(0, read_line.find('>') + 1); // remove until --->
415  PC.eigenvec[i].resize(size);
416  std::istringstream istr2(read_line.c_str());
417  for (int j = 0; j < size; j++)
418  istr2 >> PC.eigenvec[i][j];
419  }
420 
421  return in;
422 }
void set_Dimension(int _D)
Definition: pca.h:130
#define i
int in
double * f
for(j=1;j<=i__1;++j)
#define j
void clear()
Definition: pca.cpp:360
FeatureVector mean
Definition: pca.h:92
FeatureVector eigenval
Definition: pca.h:87
std::vector< FeatureVector > eigenvec
Definition: pca.h:82

◆ operator>>() [2/2]

std::istream& operator>> ( std::istream &  in,
PCA_set PS 
)

Read a set of PCA just as shown

Definition at line 447 of file pca.cpp.

448 {
449  int imax;
450  std::string read_line;
451  getline(in, read_line);
452  sscanf(read_line.c_str(), "Number of PCAs: %d\n", &imax);
453  PS.PCA.resize(imax);
454  for (int i = 0; i < imax; i++)
455  {
456  in >> PS.PCA[i];
457  }
458  return in;
459 }
#define i
int in
std::vector< PCAAnalyzer > PCA
Definition: pca.h:191