Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:28

0001 #ifndef GenericHouseholder_h
0002 #define GenericHouseholder_h
0003 
0004 /** \class GenericHouseholder
0005  *  Generic implementation of the QR decomposition of a matrix using Householder transformation
0006  *
0007  * \author Lorenzo Agostino, R.Ofierzynski, CERN
0008  */
0009 
0010 #include <vector>
0011 #include <iostream>
0012 
0013 class GenericHouseholder {
0014 public:
0015   /// Default constructor
0016   /// CAVEAT: use normalise = true only if you know what you're doing!
0017   GenericHouseholder(bool normalise = false);
0018 
0019   /// Destructor
0020   ~GenericHouseholder();
0021 
0022   /// run the Householder Algorithm several times (nIter). Returns the final vector of calibration coefficients.
0023   std::vector<float> iterate(const std::vector<std::vector<float> >& eventMatrix,
0024                              const std::vector<float>& energyVector,
0025                              const int nIter);
0026 
0027   /// run the Householder Algorithm. Returns the vector of calibration coefficients.
0028   std::vector<float> iterate(const std::vector<std::vector<float> >& eventMatrix,
0029                              const std::vector<float>& energyVector);
0030 
0031 private:
0032   /// make decomposition
0033   /// input: m=number of events, n=number of channels, qr=event matrix
0034   /// output: qr = new event matrix, alpha, pivot
0035   /// returns a boolean value, true if decomposition worked, false if it didn't
0036   bool decompose(const int m,
0037                  const int n,
0038                  std::vector<std::vector<float> >& qr,
0039                  std::vector<float>& alpha,
0040                  std::vector<int>& pivot);
0041 
0042   /// Apply transformations to rhs
0043   /// output: r = ?, y = solution
0044   void solve(int m,
0045              int n,
0046              const std::vector<std::vector<float> >& qr,
0047              const std::vector<float>& alpha,
0048              const std::vector<int>& pivot,
0049              std::vector<float>& r,
0050              std::vector<float>& y);
0051 
0052   bool normaliseFlag;
0053 };
0054 
0055 #endif