Documentation of CSL
libdiagonalization_hdata.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
23 #pragma once
24 
25 #include <iostream>
26 
27 namespace csl {
28 
29 void print_libdiagonalization_hdata(std::ostream &out) {
30  out << "#ifndef DIAGONALIZATION_H_INCLUDED\n";
31  out << "#define DIAGONALIZATION_H_INCLUDED\n";
32  out << "\n";
33  out << "#include <iostream>\n";
34  out << "#include <vector>\n";
35  out << "#include <complex>\n";
36  out << "#include <gsl/gsl_matrix.h>\n";
37  out << "#include <gsl/gsl_vector.h>\n";
38  out << "#ifdef QUAD\n";
39  out << "#include <quadmath.h>\n";
40  out << "#endif\n";
41  out << "\n";
42  out << "class Diagonalizer {\n";
43  out << "\n";
44  out << "public:\n";
45  out << "\n";
46  out << "#ifdef QUAD\n";
47  out << " using real = __float128;\n";
48  out << " using complex = __complex128;\n";
49  out << "#else\n";
50  out << " using real = double;\n";
51  out << " using complex = std::complex<real>;\n";
52  out << "#endif\n";
53  out << "\n";
54  out << " static real precision;\n";
55  out << "\n";
56  out << " static void applyDiagonalization(\n";
57  out << " std::initializer_list<complex> massMatrix,\n";
58  out << " std::initializer_list<complex*> transfer,\n";
59  out << " std::initializer_list<real*> masses\n";
60  out << " );\n";
61  out << "\n";
62  out << " static void applyBiDiagonalization(\n";
63  out << " std::initializer_list<complex> massMatrix,\n";
64  out << " std::initializer_list<complex*> transfer,\n";
65  out << " std::initializer_list<complex*> transfer2,\n";
66  out << " std::initializer_list<real*> masses\n";
67  out << " );\n";
68  out << "\n";
69  out << " Diagonalizer(\n";
70  out << " std::initializer_list<complex> massMatrix,\n";
71  out << " bool biDiag = false\n";
72  out << " );\n";
73  out << "\n";
74  out << " ~Diagonalizer() = default;\n";
75  out << "\n";
76  out << " std::vector<complex> const &transfer();\n";
77  out << "\n";
78  out << " std::vector<complex> const &transfer2();\n";
79  out << "\n";
80  out << " std::vector<real> const &mass();\n";
81  out << "\n";
82  out << "private:\n";
83  out << "\n";
84  out << " void updateDiagonalization();\n";
85  out << "\n";
86  out << " void diagonalize(\n";
87  out << " std::vector<complex> massMatrix,\n";
88  out << " std::vector<complex> &transfer,\n";
89  out << " std::vector<real> &mass,\n";
90  out << " bool bidiagonalization = false\n";
91  out << " );\n";
92  out << "\n";
93  out << " void swap(\n";
94  out << " const size_t i,\n";
95  out << " const size_t j,\n";
96  out << " std::vector<complex> &transfer,\n";
97  out << " std::vector<real> &mass\n";
98  out << " );\n";
99  out << "\n";
100  out << " void sort(\n";
101  out << " std::vector<complex> &transfer,\n";
102  out << " std::vector<real> &mass\n";
103  out << " );\n";
104  out << "\n";
105  out << " void sort(\n";
106  out << " std::vector<complex> &transfer,\n";
107  out << " std::vector<complex> &transfer2,\n";
108  out << " std::vector<real> &mass\n";
109  out << " );\n";
110  out << "\n";
111  out << " void diagonalize();\n";
112  out << "\n";
113  out << " void bidiagonalize();\n";
114  out << "\n";
115  out << " inline\n";
116  out << " size_t index(\n";
117  out << " const size_t i,\n";
118  out << " const size_t j\n";
119  out << " ) const \n";
120  out << " {\n";
121  out << " return i * m_N + j;\n";
122  out << " }\n";
123  out << "\n";
124  out << " gsl_matrix_complex *getGSLMassMatrix(\n";
125  out << " std::vector<complex> const &massMatrix\n";
126  out << " ) const;\n";
127  out << "\n";
128  out << " void loadGSLMatrix(\n";
129  out << " gsl_matrix_complex const *matrix,\n";
130  out << " std::vector<complex> &target\n";
131  out << " );\n";
132  out << "\n";
133  out << " void loadGSLVector(\n";
134  out << " gsl_vector const *vect,\n";
135  out << " std::vector<real> &target\n";
136  out << " );\n";
137  out << "\n";
138  out << " void positiveDiagonal(\n";
139  out << " std::vector<complex> &transfer\n";
140  out << " );\n";
141  out << "\n";
142  out << " std::vector<complex> hermitian(\n";
143  out << " std::vector<complex> const &init\n";
144  out << " ) const;\n";
145  out << "\n";
146  out << " std::vector<complex> dot(\n";
147  out << " std::vector<complex> const &A,\n";
148  out << " std::vector<complex> const &B\n";
149  out << " ) const;\n";
150  out << "\n";
151  out << " real det(\n";
152  out << " std::vector<complex> const &A\n";
153  out << " ) const;\n";
154  out << "\n";
155  out << " template<class T>\n";
156  out << " void print(std::vector<T> const &v) const\n";
157  out << " {\n";
158  out << " std::cout << \"( \";\n";
159  out << " for (const auto &e : v)\n";
160  out << " std::cout << (double)crealq(e) << \" \";\n";
161  out << " std::cout << \" )\" << std::endl;\n";
162  out << " }\n";
163  out << "\n";
164  out << "private:\n";
165  out << "\n";
166  out << " std::vector<complex> m_data;\n";
167  out << " size_t m_N;\n";
168  out << " bool m_bidiag;\n";
169  out << " bool m_computed;\n";
170  out << "\n";
171  out << " std::vector<complex> m_transfer;\n";
172  out << " std::vector<complex> m_transfer2;\n";
173  out << " std::vector<real> m_mass;\n";
174  out << "};\n";
175  out << "\n";
176  out << "#endif\n";
177 }
178 
179 } // End of namespace csl
Namespace for csl library.
Definition: abreviation.h:34