ampsci
c++ program for high-precision atomic structure calculations of single-valence systems
Loading...
Searching...
No Matches
SpinorMatrix.hpp
1#pragma once
2#include "LinAlg/Matrix.hpp"
3#include "Maths/Grid.hpp"
4#include "Maths/Interpolator.hpp"
5#include "RadialMatrix.hpp"
6#include "Wavefunction/DiracSpinor.hpp"
7#include <cassert>
8#include <iostream>
9#include <type_traits>
10
11namespace MBPT {
12
42template <typename T>
44
45 std::size_t m_i0, m_stride;
46 std::size_t m_size;
47 std::size_t m_g_size;
48 LinAlg::Matrix<T> m_ff, m_fg, m_gf, m_gg;
49 bool m_incl_g;
50 std::shared_ptr<const Grid> m_rgrid; // "full" grid
51 std::vector<double> sub_r{}; // sub grid
52
53public:
54 //============================================================================
55
56 SpinorMatrix(std::size_t i0, std::size_t stride, std::size_t size,
57 bool incl_g, std::shared_ptr<const Grid> rgrid)
58 : m_i0(i0),
59 m_stride(stride),
60 m_size(size),
61 m_g_size(incl_g ? size : 0),
62 m_ff(m_size),
63 m_fg(m_g_size),
64 m_gf(m_g_size),
65 m_gg(m_g_size),
66 m_incl_g(incl_g),
67 m_rgrid(rgrid) {
68 //------------------
69 // create vector of r on sub-grid, used to interpolate values onto full
70 const auto &r = m_rgrid->r();
71 sub_r.reserve(m_size);
72 assert(m_i0 + m_stride * m_size <= r.size());
73 for (std::size_t i = 0; i < m_size; ++i) {
74 sub_r.push_back(r[index_to_fullgrid(i)]);
75 }
76 assert(m_i0 + m_stride * m_size <= r.size());
77 assert(sub_r[1] == r[index_to_fullgrid(1)]);
78 assert(sub_r[m_size - 1] == r[index_to_fullgrid(m_size - 1)]);
79 //------------------
80 }
81
82 //============================================================================
84 T &ff(std::size_t i, std::size_t j) { return m_ff(i, j); }
85 T &fg(std::size_t i, std::size_t j) { return m_fg(i, j); }
86 T &gf(std::size_t i, std::size_t j) { return m_gf(i, j); }
87 T &gg(std::size_t i, std::size_t j) { return m_gg(i, j); }
88 const T ff(std::size_t i, std::size_t j) const { return m_ff(i, j); }
89 const T fg(std::size_t i, std::size_t j) const { return m_fg(i, j); }
90 const T gf(std::size_t i, std::size_t j) const { return m_gf(i, j); }
91 const T gg(std::size_t i, std::size_t j) const { return m_gg(i, j); }
92
94 const LinAlg::Matrix<T> &ff() const { return m_ff; }
95 const LinAlg::Matrix<T> &fg() const { return m_fg; }
96 const LinAlg::Matrix<T> &gf() const { return m_gf; }
97 const LinAlg::Matrix<T> &gg() const { return m_gg; }
98 LinAlg::Matrix<T> &ff() { return m_ff; }
99 LinAlg::Matrix<T> &fg() { return m_fg; }
100 LinAlg::Matrix<T> &gf() { return m_gf; }
101 LinAlg::Matrix<T> &gg() { return m_gg; }
102
103 std::size_t size() const { return m_size; }
104 std::size_t g_size() const { return m_g_size; }
105 bool includes_g() const { return m_g_size == m_size; };
106 std::size_t i0() const { return m_i0; }
107 std::size_t stride() const { return m_stride; }
108
109 //============================================================================
111 void zero() {
112 m_ff.zero();
113 m_fg.zero();
114 m_gf.zero();
115 m_gg.zero();
116 }
117
118 //============================================================================
121 m_g_size = 0;
122 m_incl_g = false;
123 m_fg.resize(0, 0);
124 m_gf.resize(0, 0);
125 m_gg.resize(0, 0);
126 return *this;
127 }
128
131 m_g_size = m_size;
132 m_incl_g = true;
133 m_fg.resize(m_size, m_size);
134 m_gf.resize(m_size, m_size);
135 m_gg.resize(m_size, m_size);
136 return *this;
137 }
138
139 //============================================================================
142 m_ff += rhs.m_ff;
143 m_fg += rhs.m_fg;
144 m_gf += rhs.m_gf;
145 m_gg += rhs.m_gg;
146 return *this;
147 }
150 m_ff -= rhs.m_ff;
151 m_fg -= rhs.m_fg;
152 m_gf -= rhs.m_gf;
153 m_gg -= rhs.m_gg;
154 return *this;
155 }
158 m_ff *= x;
159 m_fg *= x;
160 m_gf *= x;
161 m_gg *= x;
162 return *this;
163 }
164
166 [[nodiscard]] friend SpinorMatrix<T> operator+(SpinorMatrix<T> lhs,
167 const SpinorMatrix<T> &rhs) {
168 return (lhs += rhs);
169 }
171 [[nodiscard]] friend SpinorMatrix<T> operator-(SpinorMatrix<T> lhs,
172 const SpinorMatrix<T> &rhs) {
173 return (lhs -= rhs);
174 }
176 [[nodiscard]] friend SpinorMatrix<T> operator*(const T x,
177 SpinorMatrix<T> rhs) {
178 return (rhs *= x);
179 }
180
183 m_ff += aI;
184 m_gg += aI;
185 return *this;
186 }
189 m_ff -= aI;
190 m_gg -= aI;
191 return *this;
192 }
193
195 [[nodiscard]] friend SpinorMatrix<T> operator+(SpinorMatrix<T> M, T aI) {
196 return (M += aI);
197 }
199 [[nodiscard]] friend SpinorMatrix<T> operator-(SpinorMatrix<T> M, T aI) {
200 return (M -= aI);
201 }
202
203 //============================================================================
204
207 [[nodiscard]] friend SpinorMatrix<T> operator*(const SpinorMatrix<T> &a,
208 const SpinorMatrix<T> &b) {
209
210 SpinorMatrix<T> out(a.m_i0, a.m_stride, a.m_size, a.m_incl_g, a.m_rgrid);
211
212 // FF = FF*FF + FG*GF
213 // FG = FF*FG + FG*GG
214 // GF = GF*FF + GG*GF
215 // GG = GF*FG + GG*GG
216 out.ff() = a.ff() * b.ff();
217 if (a.m_incl_g && b.m_incl_g) {
218 out.ff() += a.fg() * b.gf();
219 out.fg() = a.ff() * b.fg() + a.fg() * b.gg();
220 out.gf() = a.gf() * b.ff() + a.gg() * b.gf();
221 out.gg() = a.gf() * b.fg() + a.gg() * b.gg();
222 }
223 return out;
224 }
225
226 //============================================================================
229 m_ff.mult_elements_by(rhs.ff());
230 if (this->m_incl_g) {
231 // && rhs.m_incl_g
232 // I WANT an error if matrices not identical!?
233 m_fg.mult_elements_by(rhs.fg());
234 m_gf.mult_elements_by(rhs.gf());
235 m_gg.mult_elements_by(rhs.gg());
236 }
237 return *this;
238 }
240 [[deprecated]] [[nodiscard]] friend SpinorMatrix<T>
242 lhs.mult_elements_by(rhs);
243 return lhs;
244 }
245
246 //============================================================================
249 m_ff.mult_elements_by(rhs.Rmatrix());
250 if (this->m_incl_g) {
251 m_fg.mult_elements_by(rhs.Rmatrix());
252 m_gf.mult_elements_by(rhs.Rmatrix());
253 m_gg.mult_elements_by(rhs.Rmatrix());
254 }
255 return *this;
256 }
257
259 [[nodiscard]] friend SpinorMatrix<T>
261 lhs.mult_elements_by(rhs);
262 return lhs;
263 }
264
266 [[nodiscard]] friend SpinorMatrix<T> mult_elements(const RadialMatrix<T> &rhs,
267 SpinorMatrix<T> lhs) {
268 lhs.mult_elements_by(rhs);
269 return lhs;
270 }
271
272 //============================================================================
273
275 [[nodiscard]] SpinorMatrix<T> conj() const {
276 auto out = *this;
277 out.ff().conj_in_place();
278 out.fg().conj_in_place();
279 out.gf().conj_in_place();
280 out.gg().conj_in_place();
281 return out;
282 }
285 [[nodiscard]] SpinorMatrix<double> real() const {
286 SpinorMatrix<double> out(m_i0, m_stride, m_size, m_incl_g, m_rgrid);
287 out.ff() = m_ff.real();
288 out.fg() = m_fg.real();
289 out.gf() = m_gf.real();
290 out.gg() = m_gg.real();
291 return out;
292 }
294 [[nodiscard]] SpinorMatrix<double> imag() const {
295 SpinorMatrix<double> out(m_i0, m_stride, m_size, m_incl_g, m_rgrid);
296 out.ff() = m_ff.imag();
297 out.fg() = m_fg.imag();
298 out.gf() = m_gf.imag();
299 out.gg() = m_gg.imag();
300 return out;
301 }
305 SpinorMatrix<std::complex<double>> out(m_i0, m_stride, m_size, m_incl_g,
306 m_rgrid);
307 out.ff() = m_ff.complex();
308 out.fg() = m_fg.complex();
309 out.gf() = m_gf.complex();
310 out.gg() = m_gg.complex();
311 return out;
312 }
313
314 //============================================================================
317 m_ff.invert_in_place();
318 if (m_incl_g) {
319 const auto &ai = m_ff; // already inverted
320 const auto &b = m_fg;
321 const auto &c = m_gf;
322 const auto &d = m_gg;
323 const auto cai = c * ai;
324 const auto dmcaib = (d - cai * b).invert_in_place();
325 const auto aib_dmcaib = ai * b * dmcaib;
326 m_ff += aib_dmcaib * cai;
327 m_fg = -1.0 * aib_dmcaib;
328 m_gf = -1.0 * dmcaib * cai;
329 m_gg = dmcaib;
330 }
331 return *this;
332 }
334 [[nodiscard]] SpinorMatrix<T> inverse() const {
335 auto out = *this; //
336 return out.invert_in_place();
337 }
338
339 //============================================================================
342 const auto dus = m_rgrid->du() * double(m_stride);
343 for (auto i = 0ul; i < m_size; ++i) {
344 for (auto j = 0ul; j < m_size; ++j) {
345 const auto sj = index_to_fullgrid(j);
346 const auto dr = m_rgrid->drdu(sj) * dus;
347 m_ff[i][j] *= dr;
348 }
349 }
350 if (m_incl_g) {
351 for (auto i = 0ul; i < m_size; ++i) {
352 for (auto j = 0ul; j < m_size; ++j) {
353 const auto sj = index_to_fullgrid(j);
354 const auto dr = m_rgrid->drdu(sj) * dus;
355 m_fg[i][j] *= dr;
356 m_gf[i][j] *= dr;
357 m_gg[i][j] *= dr;
358 }
359 }
360 }
361 return *this;
362 }
365 const auto dus = m_rgrid->du() * double(m_stride);
366 for (auto i = 0ul; i < m_size; ++i) {
367 const auto si = index_to_fullgrid(i);
368 const auto dr = m_rgrid->drdu(si) * dus;
369 for (auto j = 0ul; j < m_size; ++j) {
370 m_ff[i][j] *= dr;
371 }
372 }
373 if (m_incl_g) {
374 for (auto i = 0ul; i < m_size; ++i) {
375 const auto si = index_to_fullgrid(i);
376 const auto dr = m_rgrid->drdu(si) * dus;
377 for (auto j = 0ul; j < m_size; ++j) {
378 m_fg[i][j] *= dr;
379 m_gf[i][j] *= dr;
380 m_gg[i][j] *= dr;
381 }
382 }
383 }
384 return *this;
385 }
388 auto out = *this;
389 return out.drj_in_place();
390 }
393 auto out = *this;
394 return out.dri_in_place();
395 }
396
398 double dr(std::size_t sub_index) const {
399 const auto full_index = index_to_fullgrid(sub_index);
400 return m_rgrid->drdu(full_index) * m_rgrid->du() * double(m_stride);
401 }
402
403 //============================================================================
405 std::size_t index_to_fullgrid(std::size_t i) const {
406 return m_i0 + i * m_stride;
407 }
408
409 //============================================================================
411 void add(const DiracSpinor &ket, const DiracSpinor &bra, T k = T(1.0)) {
412 // Adds (k)*|ket><bra| to G matrix
413 // G_ij = f * Q_i * W_j
414 // Q = Q(1) = ket, W = W(2) = bra
415 // Takes sub-grid into account; ket,bra are on full grid, G on sub-grid
416 for (auto i = 0ul; i < m_size; ++i) {
417 const auto si = index_to_fullgrid(i);
418 for (auto j = 0ul; j < m_size; ++j) {
419 const auto sj = index_to_fullgrid(j);
420 m_ff[i][j] += k * ket.f(si) * bra.f(sj);
421 }
422 }
423
424 if (m_incl_g) {
425 for (auto i = 0ul; i < m_size; ++i) {
426 const auto si = index_to_fullgrid(i);
427 for (auto j = 0ul; j < m_size; ++j) {
428 const auto sj = index_to_fullgrid(j);
429 // XXX Double check fg/gf right way!
430 m_fg[i][j] += k * ket.f(si) * bra.g(sj);
431 m_gf[i][j] += k * ket.g(si) * bra.f(sj); // symmetric, transpose?
432 m_gg[i][j] += k * ket.g(si) * bra.g(sj);
433 }
434 }
435 }
436 }
437
438 //============================================================================
442
443 const auto &r = Fn.grid().r();
444 // const auto &drdu = Fn.grid().drdu();
445 // const double s_du = double(m_stride) * Fn.grid().du();
446
447 // include dr?? No, not by default?
448 std::vector<double> f(m_size), g;
449 for (auto i = 0ul; i < m_size; ++i) {
450 for (auto j = 0ul; j < m_size; ++j) {
451 const auto j_f = index_to_fullgrid(j);
452 f[i] += m_ff(i, j) * Fn.f(j_f); // * drdu[j_f] * s_du;
453 }
454 }
455 if (m_incl_g) {
456 g.resize(m_size);
457 for (auto i = 0ul; i < m_size; ++i) {
458 for (auto j = 0ul; j < m_size; ++j) {
459 const auto j_f = index_to_fullgrid(j);
460 f[i] += m_fg(i, j) * Fn.g(j_f); // * drdu[j_f] * s_du;
461 g[i] += (m_gf(i, j) * Fn.f(j_f) + m_gg(i, j) * Fn.g(j_f)); // *
462 // drdu[j_f] * s_du;
463 }
464 }
465 }
466
467 DiracSpinor out = Fn * 0.0;
468 // Interpolate from sub-grid to full grid
469 out.f() = Interpolator::interpolate(sub_r, f, r);
470 if (m_incl_g) {
471 out.g() = Interpolator::interpolate(sub_r, g, r);
472 }
473 return out;
474 }
475
476 //============================================================================
477 // For testing only:
478 friend std::ostream &operator<<(std::ostream &os, const SpinorMatrix<T> &a) {
479 os << "FF:\n";
480 os << a.m_ff;
481 if (a.m_incl_g) {
482 os << "FG:\n";
483 os << a.m_fg;
484 os << "GF:\n";
485 os << a.m_gf;
486 os << "GG:\n";
487 os << a.m_gg;
488 }
489 return os;
490 }
491};
492
494template <typename T>
495bool equal(const SpinorMatrix<T> &lhs, const SpinorMatrix<T> &rhs) {
496 return equal(lhs.ff(), rhs.ff()) && equal(lhs.fg(), rhs.fg()) &&
497 equal(lhs.gf(), rhs.gf()) && equal(lhs.gg(), rhs.gg());
498}
499
501template <typename T>
502double max_element(const SpinorMatrix<T> &a) {
503 double xff = 0.0, xfg = 0.0, xgf = 0.0, xgg = 0.0;
504 for (auto i = 0ul; i < a.size(); ++i) {
505 for (auto j = 0ul; j < a.size(); ++j) {
506 if (std::abs(a.ff(i, j)) > xff)
507 xff = std::abs(a.ff(i, j));
508 if (a.g_size() != 0) {
509 if (std::abs(a.fg(i, j)) > xfg)
510 xfg = std::abs(a.fg(i, j));
511 if (std::abs(a.gf(i, j)) > xgf)
512 xgf = std::abs(a.gf(i, j));
513 if (std::abs(a.gg(i, j)) > xgg)
514 xgg = std::abs(a.gg(i, j));
515 }
516 }
517 }
518 return std::max({xff, xfg, xgf, xgg});
519}
520
522template <typename T>
523double max_delta(const SpinorMatrix<T> &a, const SpinorMatrix<T> &b) {
524 double xff = 0.0, xfg = 0.0, xgf = 0.0, xgg = 0.0;
525 for (auto i = 0ul; i < a.size(); ++i) {
526 for (auto j = 0ul; j < a.size(); ++j) {
527 if (std::abs(a.ff(i, j) - b.ff(i, j)) > xff)
528 xff = std::abs(a.ff(i, j) - b.ff(i, j));
529 if (a.g_size() != 0) {
530 if (std::abs(a.fg(i, j) - b.fg(i, j)) > xfg)
531 xfg = std::abs(a.fg(i, j) - b.fg(i, j));
532 if (std::abs(a.gf(i, j) - b.gf(i, j)) > xgf)
533 xgf = std::abs(a.gf(i, j) - b.gf(i, j));
534 if (std::abs(a.gg(i, j) - b.gg(i, j)) > xgg)
535 xgg = std::abs(a.gg(i, j) - b.gg(i, j));
536 }
537 }
538 }
539 return std::max({xff, xfg, xgf, xgg});
540}
541
544template <typename T>
545double max_epsilon(const SpinorMatrix<T> &a, const SpinorMatrix<T> &b) {
546 double xff = 0.0, xfg = 0.0, xgf = 0.0, xgg = 0.0;
547 for (auto i = 0ul; i < a.size(); ++i) {
548 for (auto j = 0ul; j < a.size(); ++j) {
549 const auto eps_ff =
550 std::abs((a.ff(i, j) - b.ff(i, j)) / (a.ff(i, j) + b.ff(i, j)));
551 if (eps_ff > xff)
552 xff = eps_ff;
553 if (a.g_size() != 0) {
554 const auto eps_fg =
555 std::abs((a.fg(i, j) - b.fg(i, j)) / (a.fg(i, j) + b.fg(i, j)));
556 const auto eps_gf =
557 std::abs((a.gf(i, j) - b.gf(i, j)) / (a.gf(i, j) + b.gf(i, j)));
558 const auto eps_gg =
559 std::abs((a.gg(i, j) - b.gg(i, j)) / (a.gg(i, j) + b.gg(i, j)));
560 if (eps_ff > xfg)
561 xfg = eps_fg;
562 if (eps_gf > xgf)
563 xgf = eps_gf;
564 if (eps_gg > xgg)
565 xgg = eps_gg;
566 }
567 }
568 }
569 return std::max({xff, xfg, xgf, xgg});
570}
571
572//==============================================================================
573using GMatrix = SpinorMatrix<double>;
574using ComplexGMatrix = SpinorMatrix<std::complex<double>>;
575using ComplexDouble = std::complex<double>;
576
577} // namespace MBPT
Stores radial Dirac spinor: F_nk = (f, g)
Definition DiracSpinor.hpp:41
const std::vector< double > & f() const
Upper (large) radial component function, f.
Definition DiracSpinor.hpp:125
const Grid & grid() const
Resturns a const reference to the radial grid.
Definition DiracSpinor.hpp:115
const std::vector< double > & g() const
Lower (small) radial component function, g.
Definition DiracSpinor.hpp:132
const std::vector< double > & r() const
Grid points, r.
Definition Grid.hpp:75
Matrix class; row-major.
Definition Matrix.hpp:35
Matrix< T > & invert_in_place()
Inverts the matrix, in place. Uses GSL; via LU decomposition. Only works for double/complex<double>.
Definition Matrix.ipp:77
auto complex() const
Converts a real to complex matrix (changes type; returns a complex matrix)
Definition Matrix.ipp:205
auto imag() const
Returns imag part of complex matrix (changes type; returns a real matrix)
Definition Matrix.ipp:194
Matrix< T > & zero()
Sets all elements to zero, in place.
Definition Matrix.ipp:154
Matrix< T > & mult_elements_by(const Matrix< T > &a)
Muplitplies all the elements by those of matrix a, in place: M_ij *= a_ij.
Definition Matrix.ipp:270
auto real() const
Returns real part of complex matrix (changes type; returns a real matrix)
Definition Matrix.ipp:183
void resize(std::size_t rows, std::size_t cols)
Resizes matrix to new dimension; all values reset to default.
Definition Matrix.hpp:92
Definition RadialMatrix.hpp:27
const LinAlg::Matrix< T > & Rmatrix() const
direct access to radial matrix
Definition RadialMatrix.hpp:69
Definition SpinorMatrix.hpp:43
void add(const DiracSpinor &ket, const DiracSpinor &bra, T k=T(1.0))
Adds k*|ket><bra| to matrix (used for building Green's functions)
Definition SpinorMatrix.hpp:411
SpinorMatrix< T > & operator-=(T aI)
Adition of identity: Matrix<T> -= T : T assumed to be *Identity!
Definition SpinorMatrix.hpp:188
friend SpinorMatrix< T > mult_elements(SpinorMatrix< T > lhs, const SpinorMatrix< T > &rhs)
Multiply elements (new matrix): Gij = Aij*Bij.
Definition SpinorMatrix.hpp:241
SpinorMatrix< std::complex< double > > complex() const
Converts a real to complex matrix (changes type; returns a complex matrix)
Definition SpinorMatrix.hpp:304
SpinorMatrix< T > & create_g()
Creates g parts of spinor matrix - will have value 0.
Definition SpinorMatrix.hpp:130
T & ff(std::size_t i, std::size_t j)
direct access to matrix elements
Definition SpinorMatrix.hpp:84
friend SpinorMatrix< T > operator+(SpinorMatrix< T > M, T aI)
Adition of identity: Matrix<T> + T : T assumed to be *Identity!
Definition SpinorMatrix.hpp:195
SpinorMatrix< T > drj() const
Multiplies by drj: Q_ij -> Q_ij*dr_j. Returns new matrix (orig unchanged)
Definition SpinorMatrix.hpp:387
SpinorMatrix< T > & drj_in_place()
Multiplies by drj: Q_ij -> Q_ij*dr_j, in place.
Definition SpinorMatrix.hpp:341
SpinorMatrix< T > & operator*=(const T x)
Scalar multiplication.
Definition SpinorMatrix.hpp:157
SpinorMatrix< T > & dri_in_place()
Multiplies by dri: Q_ij -> Q_ij*dr_i, in place.
Definition SpinorMatrix.hpp:364
friend SpinorMatrix< T > mult_elements(SpinorMatrix< T > lhs, const RadialMatrix< T > &rhs)
Multiply elements (new matrix): Gij = Aij*Bij.
Definition SpinorMatrix.hpp:260
const LinAlg::Matrix< T > & ff() const
direct access to matrix's
Definition SpinorMatrix.hpp:94
friend SpinorMatrix< T > operator*(const T x, SpinorMatrix< T > rhs)
Scalar multiplication.
Definition SpinorMatrix.hpp:176
SpinorMatrix< T > & operator-=(const SpinorMatrix< T > &rhs)
Matrix adition +,-.
Definition SpinorMatrix.hpp:149
SpinorMatrix< T > & operator+=(T aI)
Adition of identity: Matrix<T> += T : T assumed to be *Identity!
Definition SpinorMatrix.hpp:182
SpinorMatrix< double > imag() const
Returns imag part of complex matrix (changes type; returns a real matrix)
Definition SpinorMatrix.hpp:294
void zero()
Sets all matrix elements to zero.
Definition SpinorMatrix.hpp:111
SpinorMatrix< T > dri() const
Multiplies by dri: Q_ij -> Q_ij*dr_i. Returns new matrix (orig unchanged)
Definition SpinorMatrix.hpp:392
SpinorMatrix< T > & mult_elements_by(const SpinorMatrix< T > &rhs)
Multiply elements (in place): Gij -> Gij*Bij.
Definition SpinorMatrix.hpp:228
DiracSpinor operator*(const DiracSpinor &Fn) const
Action of SpinorMatrix operator on DiracSpinor. Inludes Integration: G*F = Int[G(r,...
Definition SpinorMatrix.hpp:441
SpinorMatrix< T > & drop_g()
Kills g parts of spinor matrix, in place!
Definition SpinorMatrix.hpp:120
SpinorMatrix< T > & operator+=(const SpinorMatrix< T > &rhs)
Matrix adition +,-.
Definition SpinorMatrix.hpp:141
SpinorMatrix< T > & invert_in_place()
Inversion (in place)
Definition SpinorMatrix.hpp:316
friend SpinorMatrix< T > mult_elements(const RadialMatrix< T > &rhs, SpinorMatrix< T > lhs)
Multiply elements (new matrix): Gij = Aij*Bij.
Definition SpinorMatrix.hpp:266
std::size_t index_to_fullgrid(std::size_t i) const
Converts an index on the sub-grid to the full grid.
Definition SpinorMatrix.hpp:405
friend SpinorMatrix< T > operator-(SpinorMatrix< T > M, T aI)
Adition of identity: Matrix<T> - T : T assumed to be *Identity!
Definition SpinorMatrix.hpp:199
double dr(std::size_t sub_index) const
returns dr at position along sub grid
Definition SpinorMatrix.hpp:398
friend SpinorMatrix< T > operator*(const SpinorMatrix< T > &a, const SpinorMatrix< T > &b)
Matrix multplication: C=A*B := Cij = \sum_k Aik*Bkj. Note: integration measure not included: call ....
Definition SpinorMatrix.hpp:207
SpinorMatrix< double > real() const
Returns real part of complex matrix (changes type; returns a real matrix)
Definition SpinorMatrix.hpp:285
friend SpinorMatrix< T > operator+(SpinorMatrix< T > lhs, const SpinorMatrix< T > &rhs)
Matrix adition +,-.
Definition SpinorMatrix.hpp:166
SpinorMatrix< T > inverse() const
Returns inverse of matrix; original matrix unchanged.
Definition SpinorMatrix.hpp:334
SpinorMatrix< T > & mult_elements_by(const RadialMatrix< T > &rhs)
Multiply elements (in place): Gij -> Gij*Bij.
Definition SpinorMatrix.hpp:248
SpinorMatrix< T > conj() const
Returns conjugate of matrix.
Definition SpinorMatrix.hpp:275
friend SpinorMatrix< T > operator-(SpinorMatrix< T > lhs, const SpinorMatrix< T > &rhs)
Matrix adition +,-.
Definition SpinorMatrix.hpp:171
std::vector< double > interpolate(const std::vector< double > &x_in, const std::vector< double > &y_in, const std::vector< double > &x_out, Method method=Method::cspline)
Performs interpolation using GSL (GNU Scientific Library)
Definition Interpolator.hpp:162
Many-body perturbation theory.
Definition CI_Integrals.hpp:9
double max_element(const RadialMatrix< T > &a)
returns maximum element (by abs)
Definition RadialMatrix.hpp:287
bool equal(const RadialMatrix< T > &lhs, const RadialMatrix< T > &rhs)
Checks if two matrix's are equal (to within parts in 10^12)
Definition RadialMatrix.hpp:281
double max_delta(const RadialMatrix< T > &a, const RadialMatrix< T > &b)
returns maximum difference (abs) between two matrixs
Definition RadialMatrix.hpp:301
double max_epsilon(const RadialMatrix< T > &a, const RadialMatrix< T > &b)
returns maximum relative diference [aij-bij/(aij+bij)] (abs) between two matrices
Definition RadialMatrix.hpp:316