Bridge++  Ver. 2.0.2
decompose_LUP_Cmplx.h
Go to the documentation of this file.
1 
14 #ifndef DECOMPOSE_LUP_CMPLX_INCLUDED
15 #define DECOMPOSE_LUP_CMPLX_INCLUDED
16 
17 #include <valarray>
18 #include <cfloat>
19 #include <cmath>
20 
21 #include "bridge_complex.h"
22 
23 #include "IO/bridgeIO.h"
24 
26 {
27  public:
28  Decompose_LUP_Cmplx(size_t N) : N(N), N2(2 * N), size(N * N2),
29  m_lu(size), m_pivot(N) {}
30 
31  void set_matrix(const double *mat);
32 
33  // solve Ax = b: vec -> A^{-1} vec
34  void solve(double *vec);
35 
36  // M -> A^{-1}
37  void get_inverse(double *mat_inv);
38 
39  // M -> A^{-1} * M
40  void mult_inverse(double *mat);
41 
42  // return det(A)
43  dcomplex determinant();
44 
45  private:
46  int N;
47  int N2;
48  int size;
49  std::valarray<double> m_lu;
50  // pivot index
51  std::valarray<int> m_pivot;
52  // # of pivot
53  // even -> 1;
54  // odd -> -1;
55  int m_sign;
56 
57  inline size_t re(int i, int j)
58  {
59  return N2 * i + 2 * j;
60  }
61 
62  inline size_t im(int i, int j)
63  {
64  return N2 * i + 2 * j + 1;
65  }
66 
67  inline size_t re(int i)
68  {
69  return 2 * i;
70  }
71 
72  inline size_t im(int i)
73  {
74  return 2 * i + 1;
75  }
76 };
77 #endif
bridgeIO.h
Decompose_LUP_Cmplx::re
size_t re(int i, int j)
Definition: decompose_LUP_Cmplx.h:57
Decompose_LUP_Cmplx::size
int size
Definition: decompose_LUP_Cmplx.h:48
Decompose_LUP_Cmplx
Definition: decompose_LUP_Cmplx.h:25
Decompose_LUP_Cmplx::m_pivot
std::valarray< int > m_pivot
Definition: decompose_LUP_Cmplx.h:51
Decompose_LUP_Cmplx::im
size_t im(int i, int j)
Definition: decompose_LUP_Cmplx.h:62
Decompose_LUP_Cmplx::m_lu
std::valarray< double > m_lu
Definition: decompose_LUP_Cmplx.h:49
Decompose_LUP_Cmplx::solve
void solve(double *vec)
Definition: decompose_LUP_Cmplx.cpp:93
Decompose_LUP_Cmplx::m_sign
int m_sign
Definition: decompose_LUP_Cmplx.h:55
Decompose_LUP_Cmplx::determinant
dcomplex determinant()
Definition: decompose_LUP_Cmplx.cpp:185
Decompose_LUP_Cmplx::Decompose_LUP_Cmplx
Decompose_LUP_Cmplx(size_t N)
Definition: decompose_LUP_Cmplx.h:28
bridge_complex.h
Decompose_LUP_Cmplx::N2
int N2
Definition: decompose_LUP_Cmplx.h:47
Decompose_LUP_Cmplx::N
int N
Definition: decompose_LUP_Cmplx.h:46
Decompose_LUP_Cmplx::im
size_t im(int i)
Definition: decompose_LUP_Cmplx.h:72
Decompose_LUP_Cmplx::get_inverse
void get_inverse(double *mat_inv)
Definition: decompose_LUP_Cmplx.cpp:126
Decompose_LUP_Cmplx::mult_inverse
void mult_inverse(double *mat)
Definition: decompose_LUP_Cmplx.cpp:140
Decompose_LUP_Cmplx::set_matrix
void set_matrix(const double *mat)
Definition: decompose_LUP_Cmplx.cpp:17
Decompose_LUP_Cmplx::re
size_t re(int i)
Definition: decompose_LUP_Cmplx.h:67