Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gammaMatrix.cpp
Go to the documentation of this file.
1 
14 #include "gammaMatrix.h"
15 
16 #include <cassert>
17 
19 
20 #include "IO/bridgeIO.h"
21 using Bridge::vout;
22 
23 const std::string GammaMatrix::class_name = "GammaMatrix";
24 
25 //====================================================================
26 void GammaMatrix::set(int row, int index, icomplex val)
27 {
28  assert(row < m_Nd);
29  assert(index < m_Nd);
30 
31  m_gmindex[row] = index; // m_gmindex[a] = b(=index) if \gamma_{ab} \not=0 (SA)
32  m_gmval_i[row] = val; // m_gmval_i[a] = \gamma_{ab}(=val) in complex<int> (SA)
33 
34  set_values(row);
35 }
36 
37 
38 //====================================================================
40 {
41  // \gamma2_{ab}=\gamma_{ac} * \gamma1_{cb} (SA)
42 
43  GammaMatrix gm2;
44 
45  for (int row = 0; row < m_Nd; ++row) {
46  gm2.m_gmindex[row] = gm1.m_gmindex[m_gmindex[row]];
47  gm2.m_gmval_i[row] = m_gmval_i[row]
48  * gm1.m_gmval_i[m_gmindex[row]];
49  // \gamma_{ac} * \gamma1_{cb}, c=m_gmindex[a], (a=row) (SA)
50 
51  gm2.set_values(row);
52  }
53 
54  return gm2;
55 }
56 
57 
58 //====================================================================
60 {
61  // \gamma2_{ab}=i * \gamma_{ac} * \gamma1_{cb} (SA)
62 
63  GammaMatrix gm2;
64 
65  for (int row = 0; row < m_Nd; ++row) {
66  gm2.m_gmindex[row] = gm1.m_gmindex[m_gmindex[row]];
67  gm2.m_gmval_i[row] = icomplex(0, 1) * m_gmval_i[row]
68  * gm1.m_gmval_i[m_gmindex[row]];
69  gm2.set_values(row);
70  }
71 
72  return gm2;
73 }
74 
75 
76 //====================================================================
78 {
79  for (int row = 0; row < m_Nd; ++row) {
80  if (m_gmindex[row] == 0) {
81  vout.general(m_vl, " (%2d,%2d)\n",
82  real(m_gmval_i[row]), imag(m_gmval_i[row]));
83  } else if (m_gmindex[row] == 1) {
84  vout.general(m_vl, " (%2d,%2d)\n",
85  real(m_gmval_i[row]), imag(m_gmval_i[row]));
86  } else if (m_gmindex[row] == 2) {
87  vout.general(m_vl, " (%2d,%2d)\n",
88  real(m_gmval_i[row]), imag(m_gmval_i[row]));
89  } else if (m_gmindex[row] == 3) {
90  vout.general(m_vl, " (%2d,%2d)\n",
91  real(m_gmval_i[row]), imag(m_gmval_i[row]));
92  } else {
93  vout.crucial(m_vl, "Error at %s: gamma matrix not defined.\n", class_name.c_str());
94  exit(EXIT_FAILURE);
95  }
96  }
97 }
98 
99 
100 //====================================================================
102 {
103  m_gmvalue[row] = cmplx((double)real(m_gmval_i[row]),
104  (double)imag(m_gmval_i[row]));
105  // m_gmvalue[a] = \gamma_{ab} in complex<double> (SA)
106 
107  if (real(m_gmval_i[row]) != 0) { // if \gamma_{ab} is real (SA)
108  m_gmindex_c[row] = 0;
109  m_gmvalue_r[row] = real(m_gmvalue[row]);
110  m_gmvalue_i[row] = real(m_gmvalue[row]);
111  } else if (imag(m_gmval_i[row]) != 0) { // if \gamma_{ab} is complex (SA)
112  m_gmindex_c[row] = 1;
113  m_gmvalue_r[row] = -imag(m_gmvalue[row]);
114  m_gmvalue_i[row] = imag(m_gmvalue[row]);
115  } else {
116  vout.crucial(m_vl, "Error at %s: wrong m_gmval_i.\n", class_name.c_str());
117  exit(EXIT_FAILURE);
118  }
119 }
120 
121 
122 //====================================================================
124 {
125  // n * \gamma_{ab} (SA)
126 
127  GammaMatrix gm2;
128 
129  for (int row = 0; row < m_Nd; ++row) {
130  gm2.m_gmindex[row] = m_gmindex[row];
131  gm2.m_gmval_i[row] = m_gmval_i[row] * icomplex(n, 0);
132  gm2.set_values(row);
133  }
134 
135  return gm2;
136 }
137 
138 
139 //====================================================================
140 //============================================================END=====
std::vector< dcomplex > m_gmvalue
Definition: gammaMatrix.h:52
std::vector< double > m_gmvalue_i
Definition: gammaMatrix.h:55
BridgeIO vout
Definition: bridgeIO.cpp:503
std::vector< int > m_gmindex_c
Definition: gammaMatrix.h:53
void general(const char *format,...)
Definition: bridgeIO.cpp:197
void set_values(int row)
static const std::string class_name
Definition: gammaMatrix.h:46
void set(int row, int index, icomplex val_i)
Definition: gammaMatrix.cpp:26
Gamma Matrix class.
Definition: gammaMatrix.h:44
std::vector< int > m_gmindex
Definition: gammaMatrix.h:50
GammaMatrix mult_i(GammaMatrix) const
Definition: gammaMatrix.cpp:59
std::vector< double > m_gmvalue_r
Definition: gammaMatrix.h:54
GammaMatrix mult(GammaMatrix) const
Definition: gammaMatrix.cpp:39
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
Bridge::VerboseLevel m_vl
Definition: gammaMatrix.h:58
std::vector< icomplex > m_gmval_i
Definition: gammaMatrix.h:51
int index(int row) const
Definition: gammaMatrix.h:83
void print()
Definition: gammaMatrix.cpp:77