Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
decompose_QR_Cmplx.h
Go to the documentation of this file.
1 
14 #ifndef DECOMPOSE_QR_CMPLX_INCLUDED
15 #define DECOMPOSE_QR_CMPLX_INCLUDED
16 
17 #include <cmath>
18 #include <cfloat>
19 #include <valarray>
20 
21 /*
22  Class for QR decomposition with Householder transformation
23  The notation of Householder transformation is the same as that of GSL.
24  H = I - tau vv^\dag
25  H^\dag x = - |x| sign(Re(x_1)) e_1
26  */
27 
29 {
30  public:
31  Decompose_QR_Cmplx(const size_t& Nin) : N(Nin), N2(2 * N), size(N * N2),
32  m_qr(size), m_tau(N2)
33  {
34  }
35 
36  void set_matrix(const double *mat);
37  void get_R(double *mat);
38  void solve(double *vec);
39  void get_inverse(double *mat);
40  void mult_inverse(double *mat);
41  void get_Q(double *mat);
42  void get_Qu(double *mat);
43  void mult_Q(double *mat);
44 
45  private:
46  size_t N;
47  size_t N2;
48  size_t size;
49 
50  // store R and householder vector
51  std::valarray<double> m_qr;
52  std::valarray<double> m_tau;
53 
54  // matrix index [i,j]
55  inline size_t re(const size_t i, const size_t j)
56  {
57  return N2 * i + 2 * j;
58  }
59 
60  inline size_t im(const size_t i, const size_t j)
61  {
62  return N2 * i + 2 * j + 1;
63  }
64 
65  // vector index [i]
66  inline size_t re(const size_t i)
67  {
68  return 2 * i;
69  }
70 
71  inline size_t im(const size_t i)
72  {
73  return 2 * i + 1;
74  }
75 };
76 #endif
Decompose_QR_Cmplx(const size_t &Nin)
size_t re(const size_t i)
size_t re(const size_t i, const size_t j)
std::valarray< double > m_tau
void mult_inverse(double *mat)
size_t im(const size_t i, const size_t j)
void set_matrix(const double *mat)
void solve(double *vec)
void get_R(double *mat)
void get_Q(double *mat)
std::valarray< double > m_qr
void get_Qu(double *mat)
void mult_Q(double *mat)
void get_inverse(double *mat)
size_t im(const size_t i)