GenericHouseholder

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#ifndef GenericHouseholder_h
#define GenericHouseholder_h

/** \class GenericHouseholder
 *  Generic implementation of the QR decomposition of a matrix using Householder transformation
 *
 * \author Lorenzo Agostino, R.Ofierzynski, CERN
 */

#include <vector>
#include <iostream>

class GenericHouseholder {
public:
  /// Default constructor
  /// CAVEAT: use normalise = true only if you know what you're doing!
  GenericHouseholder(bool normalise = false);

  /// Destructor
  ~GenericHouseholder();

  /// run the Householder Algorithm several times (nIter). Returns the final vector of calibration coefficients.
  std::vector<float> iterate(const std::vector<std::vector<float> >& eventMatrix,
                             const std::vector<float>& energyVector,
                             const int nIter);

  /// run the Householder Algorithm. Returns the vector of calibration coefficients.
  std::vector<float> iterate(const std::vector<std::vector<float> >& eventMatrix,
                             const std::vector<float>& energyVector);

private:
  /// make decomposition
  /// input: m=number of events, n=number of channels, qr=event matrix
  /// output: qr = new event matrix, alpha, pivot
  /// returns a boolean value, true if decomposition worked, false if it didn't
  bool decompose(const int m,
                 const int n,
                 std::vector<std::vector<float> >& qr,
                 std::vector<float>& alpha,
                 std::vector<int>& pivot);

  /// Apply transformations to rhs
  /// output: r = ?, y = solution
  void solve(int m,
             int n,
             const std::vector<std::vector<float> >& qr,
             const std::vector<float>& alpha,
             const std::vector<int>& pivot,
             std::vector<float>& r,
             std::vector<float>& y);

  bool normaliseFlag;
};

#endif