Bridge++  Ver. 2.0.2
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::get_R
void get_R(double *mat)
Definition: decompose_QR_Cmplx.cpp:106
Decompose_QR_Cmplx
Definition: decompose_QR_Cmplx.h:28
Decompose_QR_Cmplx::im
size_t im(const size_t i, const size_t j)
Definition: decompose_QR_Cmplx.h:60
Decompose_QR_Cmplx::Decompose_QR_Cmplx
Decompose_QR_Cmplx(const size_t &Nin)
Definition: decompose_QR_Cmplx.h:31
Decompose_QR_Cmplx::get_Qu
void get_Qu(double *mat)
Definition: decompose_QR_Cmplx.cpp:241
Decompose_QR_Cmplx::size
size_t size
Definition: decompose_QR_Cmplx.h:48
Decompose_QR_Cmplx::m_qr
std::valarray< double > m_qr
Definition: decompose_QR_Cmplx.h:51
Decompose_QR_Cmplx::mult_inverse
void mult_inverse(double *mat)
Definition: decompose_QR_Cmplx.cpp:177
Decompose_QR_Cmplx::N2
size_t N2
Definition: decompose_QR_Cmplx.h:47
Decompose_QR_Cmplx::get_inverse
void get_inverse(double *mat)
Definition: decompose_QR_Cmplx.cpp:163
Decompose_QR_Cmplx::im
size_t im(const size_t i)
Definition: decompose_QR_Cmplx.h:71
Decompose_QR_Cmplx::m_tau
std::valarray< double > m_tau
Definition: decompose_QR_Cmplx.h:52
Decompose_QR_Cmplx::re
size_t re(const size_t i)
Definition: decompose_QR_Cmplx.h:66
Decompose_QR_Cmplx::mult_Q
void mult_Q(double *mat)
Definition: decompose_QR_Cmplx.cpp:258
Decompose_QR_Cmplx::set_matrix
void set_matrix(const double *mat)
Definition: decompose_QR_Cmplx.cpp:17
Decompose_QR_Cmplx::get_Q
void get_Q(double *mat)
Definition: decompose_QR_Cmplx.cpp:227
Decompose_QR_Cmplx::N
size_t N
Definition: decompose_QR_Cmplx.h:46
Decompose_QR_Cmplx::re
size_t re(const size_t i, const size_t j)
Definition: decompose_QR_Cmplx.h:55
Decompose_QR_Cmplx::solve
void solve(double *vec)
Definition: decompose_QR_Cmplx.cpp:120