1 #ifndef CNTR_DYSON_IMPL_H 2 #define CNTR_DYSON_IMPL_H 79 template <
typename T,
class GG,
int SIZE1>
80 void dyson_timestep_ret(
int n, GG &G, T mu, std::complex<T> *H, GG &Sigma,
82 typedef std::complex<T>
cplx;
83 int k =
I.get_k(), k1 = k + 1, k2 = 2 * k1;
84 int ss, sg, n1, l, j, i, p, q, m, j1, j2, size1 = G.size1();
85 cplx *gret, *gtemp, *mm, *qq, *qqj, *stemp, *one, cplx_i, cweight, *diffw;
90 ss = Sigma.element_size();
91 sg = G.element_size();
92 gtemp =
new cplx[k * sg];
93 diffw =
new cplx[k1 + 1];
94 qq =
new cplx[(n + 1) * sg];
96 mm =
new cplx[k * k * sg];
99 element_set<T, SIZE1>(size1, one, 1);
102 assert(Sigma.nt() >= n);
104 assert(G.sig() == Sigma.sig());
106 gret = G.retptr(n, 0);
108 for (i = 0; i < n1; i++)
111 element_set<T, SIZE1>(size1, G.retptr(n, n), -cplx_i);
113 for (i = 0; i < k * k * sg; i++)
115 for (i = 0; i < k * sg; i++)
117 for (j = 1; j <= k; j++) {
120 for (l = 0; l <= k; l++) {
121 cweight = cplx_i / h *
I.poly_differentiation(j, l);
123 element_incr<T, SIZE1>(size1, qq + p * sg, -cweight, G.retptr(n, n));
126 element_incr<T, SIZE1>(size1, mm + sg * (p * k + q), cweight);
130 element_set<T, SIZE1>(size1, gtemp, H + (n - j) * sg);
131 element_smul<T, SIZE1>(size1, gtemp, -1);
132 for (i = 0; i < sg; i++)
133 gtemp[i] += mu * one[i];
134 element_incr<T, SIZE1>(size1, mm + sg * (p + k * p), gtemp);
136 for (l = 0; l <= k; l++) {
137 weight = h *
I.gregory_weights(j, l);
138 if (n - l >= n - j) {
139 element_set<T, SIZE1>(
141 Sigma.retptr(n - l, n - j));
143 element_set<T, SIZE1>(size1, stemp, Sigma.retptr(n - j, n - l));
144 element_conj<T, SIZE1>(size1, stemp);
148 element_incr<T, SIZE1>(size1, qq + p * sg, weight, G.retptr(n, n), stemp);
151 element_incr<T, SIZE1>(size1, mm + sg * (p * k + q), -weight, stemp);
155 element_linsolve_left<T, SIZE1>(size1, k, gtemp, mm, qq);
156 for (j = 1; j <= k; j++)
157 element_set<T, SIZE1>(size1, G.retptr(n, n - j), gtemp + (j - 1) * sg);
160 for (i = 0; i < sg * (n + 1); i++)
162 for (m = n - k; m <= n; m++) {
163 weight =
I.gregory_omega(n - m);
164 gret = G.retptr(n, m);
165 sret = Sigma.retptr(m, 0);
166 for (j = 0; j <= n - k2; j++) {
167 element_incr<T, SIZE1>(size1, qq + j * sg,
I.gregory_weights(n - j, n - m), gret,
171 j1 = (n - k2 + 1 < 0 ? 0 : n - k2 + 1);
172 for (j = j1; j < n - k; j++) {
173 weight =
I.gregory_weights(n - j, n - m);
174 element_incr<T, SIZE1>(size1, qq + j * sg,
I.gregory_weights(n - j, n - m), gret,
180 for (p = 0; p <= k1; p++)
181 diffw[p] =
I.bd_weights(p) * cplx_i / h;
182 w0 = h *
I.gregory_omega(0);
183 for (l = k + 1; l <= n; l++) {
185 element_set<T, SIZE1>(size1, hj, H + j * sg);
186 element_conj<T, SIZE1>(size1, hj);
189 for (i = 0; i < sg; i++) {
191 for (p = 1; p <= k1; p++)
192 qqj[i] += -diffw[p] * G.retptr(n, n - l + p)[i];
194 element_set<T, SIZE1>(size1, stemp, Sigma.retptr(j, j));
195 for (i = 0; i < sg; i++)
196 mm[i] = diffw[0] * one[i] + mu * one[i] - hj[i] - w0 * stemp[i];
197 element_linsolve_left<T, SIZE1>(size1, G.retptr(n, j), mm, qqj);
200 gret = G.retptr(n, j);
201 sret = Sigma.retptr(j, 0);
202 for (j2 = 0; j2 < j - k; j2++) {
203 element_incr<T, SIZE1>(size1, qq + j2 * sg,
I.gregory_weights(n - j2, n - j),
207 j1 = (j - k < 0 ? 0 : j - k);
208 for (j2 = j1; j2 < j; j2++) {
209 weight =
I.gregory_omega(j - j2);
210 element_incr<T, SIZE1>(size1, qq + j2 * sg,
I.gregory_weights(n - j2, n - j),
257 template <
typename T,
class GG,
int SIZE1>
258 void dyson_start_ret(GG &G, T mu, std::complex<T> *H, GG &Sigma,
260 typedef std::complex<T>
cplx;
262 int sg, l, n, j, p, q, i, dim, size1 = G.size1();
263 cplx ih, *gtemp, *mm, *qq, *stemp, minusi, *one, *hj;
266 sg = G.element_size();
267 assert(Sigma.nt() >= k);
269 assert(G.sig() == Sigma.sig());
272 qq =
new cplx[k * sg];
273 mm =
new cplx[k * k * sg];
276 gtemp =
new cplx[k * sg];
277 stemp =
new cplx[sg];
279 element_set<T, SIZE1>(size1, one, 1.0);
280 minusi =
cplx(0, -1);
283 for (n = 0; n <= k; n++)
284 element_set<T, SIZE1>(size1, G.retptr(n, n),
cplx(0, -1.0));
286 for (j = 0; j < k; j++) {
288 for (i = 0; i < k * sg; i++)
290 for (i = 0; i < k * k * sg; i++)
293 for (n = j + 1; n <= k; n++) {
295 for (l = 0; l <= k; l++) {
298 element_conj<T, SIZE1>(size1, gtemp, G.retptr(j, l));
299 element_smul<T, SIZE1>(size1, gtemp, -1);
300 element_set_zero<T, SIZE1>(size1, stemp);
301 element_incr<T, SIZE1>(size1, stemp, Sigma.retptr(n, l), gtemp);
302 for (i = 0; i < sg; i++)
304 minusi / h *
I.poly_differentiation(n, l) * gtemp[i] +
305 h *
I.poly_integration(j, n, l) * stemp[i];
307 for (i = 0; i < sg; i++)
308 mm[sg * (p * dim + q) + i] =
309 -minusi / h *
I.poly_differentiation(n, l) * one[i];
311 element_set<T, SIZE1>(size1, hj, H + l * sg);
312 for (i = 0; i < sg; i++) {
313 mm[sg * (p * dim + q) + i] += mu * one[i] - hj[i];
316 weight = h *
I.poly_integration(j, n, l);
318 element_set<T, SIZE1>(size1, stemp, Sigma.retptr(n, l));
320 element_set<T, SIZE1>(size1, stemp, Sigma.retptr(l, n));
321 element_conj<T, SIZE1>(size1, stemp);
324 for (i = 0; i < sg; i++)
325 mm[sg * (p * dim + q) + i] -= weight * stemp[i];
330 element_linsolve_right<T, SIZE1>(size1, dim, gtemp, mm, qq);
331 for (n = j + 1; n <= k; n++) {
334 element_set<T, SIZE1>(size1, G.retptr(n, j), gtemp + p * sg);
355 template <
typename T,
class GG,
int SIZE1>
356 void dyson_mat_fourier_dispatch(GG &G, GG &Sigma, T mu, std::complex<T> *H0, T beta,
int order = 3) {
357 typedef std::complex<double>
cplx;
358 cplx *sigmadft, *sigmaiomn, *z1, *z2, *one;
359 cplx *expfac, *gmat, *hj, iomn, *zinv;
360 int ntau, m, r, pcf, p, m2, sg, ss, l, sig, size1 = G.size1();
363 assert(G.ntau() == Sigma.ntau());
365 assert(G.sig() == Sigma.sig());
366 sg = G.element_size();
367 ss = Sigma.element_size();
371 std::cerr <<
"matsubara_inverse: ntau odd" << std::endl;
374 sigmadft =
new cplx[(ntau + 1) * ss];
375 sigmaiomn =
new cplx[ss];
376 expfac =
new cplx[ntau + 1];
377 gmat =
new cplx[(ntau + 1) * sg];
383 element_set<T, SIZE1>(size1, one, 1.0);
384 element_set<T, SIZE1>(size1, hj, H0);
385 for (l = 0; l < sg; l++)
386 hj[l] -= mu * one[l];
389 matsubara_dft<T, GG, SIZE1>(sigmadft, Sigma, sig);
390 set_first_order_tail<T, SIZE1>(gmat, one, beta, sg, ntau, sig, size1);
392 for (m = -m2; m <= m2 - 1; m++) {
393 for (p = -pcf; p <= pcf; p++) {
395 iomn =
cplx(0, get_omega(m + p * ntau, beta, sig));
396 matsubara_ft<T, GG, SIZE1>(sigmaiomn, m + p * ntau, Sigma, sigmadft, sig, beta,
399 element_set<T, SIZE1>(size1, z1, sigmaiomn);
400 element_incr<T, SIZE1>(size1, z1, hj);
402 if (sig == 1 && m + p * ntau == 0) {
407 element_inverse<T, SIZE1>(size1, zinv, z1);
408 element_set<T, SIZE1>(size1, z2, zinv);
409 element_smul<T, SIZE1>(size1, z2, -1.0);
417 for (l = 0; l < sg; l++)
418 z2[l] = iomn * one[l] - z1[l];
419 element_inverse<T, SIZE1>(size1, zinv, z2);
421 element_smul<T, SIZE1>(size1, zinv, 1. / iomn);
422 element_mult<T, SIZE1>(size1, z2, zinv, z1);
425 element_smul<T, SIZE1>(size1, z2, 1 / beta);
426 for (r = 0; r <= ntau; r++) {
427 cplx expfac(std::exp(-get_tau(r, beta, ntau) * iomn));
428 for (l = 0; l < sg; l++)
429 gmat[r * sg + l] += z2[l] * expfac;
433 for (r = 0; r <= ntau; r++) {
434 element_set<T, SIZE1>(size1, G.matptr(r), gmat + r * sg);
450 template <
typename T,
class GG,
int SIZE1>
451 void dyson_mat_fixpoint_dispatch(GG &G, GG &Sigma, T mu, cdmatrix &H0,
455 int ntau = G.ntau(), size1=G.size1();
458 herm_matrix<T> G0(-1,ntau,size1,G.sig());
459 herm_matrix<T> G0xSGM(-1,ntau,size1,G.sig());
463 convolution_matsubara(G0xSGM, G0, Sigma,
I, beta);
466 vie2_mat_fixpoint(G, G0xSGM, G0xSGM, G0, beta,
I, fixpiter);
471 template <
typename T,
class GG,
int SIZE1>
472 void dyson_mat_fixpoint_dispatch(GG &G, GG &Sigma, T mu, cdmatrix &H0, function<T> &SigmaMF,
476 int ntau = G.ntau(), size1=G.size1();
478 herm_matrix<T> G0(-1,ntau,size1,G.sig());
479 herm_matrix<T> G0xSGM(-1,ntau,size1,G.sig());
480 herm_matrix<T> G0xMF(-1,ntau,size1,G.sig());
484 convolution_matsubara(G0xSGM, G0, Sigma,
I, beta);
485 G0xMF.set_timestep(-1,G0);
486 G0xMF.right_multiply(-1,SigmaMF);
487 G0xSGM.incr_timestep(-1,G0xMF);
490 vie2_mat_fixpoint(G, G0xSGM, G0xSGM, G0, beta,
I, fixpiter);
495 template <
typename T,
class GG,
int SIZE1>
496 void dyson_mat_fixpoint_dispatch(GG &G, GG &Sigma, T mu, cdmatrix &H0, cdmatrix &SigmaMF,
500 int ntau = G.ntau(), size1=G.size1();
502 herm_matrix<T> G0(-1,ntau,size1,G.sig());
503 herm_matrix<T> G0xSGM(-1,ntau,size1,G.sig());
504 herm_matrix<T> G0xMF(-1,ntau,size1,G.sig());
505 function<T> sgmf(-1,size1);
509 convolution_matsubara(G0xSGM, G0, Sigma,
I, beta);
510 sgmf.set_value(-1,SigmaMF);
511 G0xMF.set_timestep(-1,G0);
512 G0xMF.right_multiply(-1,sgmf);
513 G0xSGM.incr_timestep(-1,G0xMF);
516 vie2_mat_fixpoint(G, G0xSGM, G0xSGM, G0, beta,
I, fixpiter);
521 template <
typename T,
class GG,
int SIZE1>
522 void dyson_mat_steep_dispatch(GG &G, GG &Sigma, T mu, cdmatrix &H0,
526 int ntau = G.ntau(), size1=G.size1();
528 herm_matrix<T> G0(-1,ntau,size1,G.sig());
529 herm_matrix<T> G0xSGM(-1,ntau,size1,G.sig());
530 herm_matrix<T> SGMxG0(-1,ntau,size1,G.sig());
534 convolution_matsubara(G0xSGM, G0, Sigma,
I, beta);
535 convolution_matsubara(SGMxG0, Sigma, G0,
I, beta);
539 vie2_mat_steep(G, G0xSGM, SGMxG0, G0, beta,
I, maxiter, tol);
544 template <
typename T,
class GG,
int SIZE1>
545 void dyson_mat_steep_dispatch(GG &G, GG &Sigma, T mu, cdmatrix &H0, function<T> &SigmaMF,
549 int ntau = G.ntau(), size1=G.size1();
551 herm_matrix<T> G0(-1,ntau,size1,G.sig());
552 herm_matrix<T> G0xSGM(-1,ntau,size1,G.sig());
553 herm_matrix<T> SGMxG0(-1,ntau,size1,G.sig());
554 herm_matrix<T> G0xMF(-1,ntau,size1,G.sig());
555 herm_matrix<T> MFxG0(-1,ntau,size1,G.sig());
559 G0xMF.set_timestep(-1,G0);
560 G0xMF.right_multiply(-1,SigmaMF);
561 MFxG0.set_timestep(-1,G0);
562 MFxG0.left_multiply(-1,SigmaMF);
564 convolution_matsubara(G0xSGM, G0, Sigma,
I, beta);
565 convolution_matsubara(SGMxG0, Sigma, G0,
I, beta);
566 G0xSGM.incr_timestep(-1,G0xMF);
568 SGMxG0.incr_timestep(-1,MFxG0);
571 vie2_mat_steep(G, G0xSGM, SGMxG0, G0, beta,
I, maxiter, tol);
576 template <
typename T,
class GG,
int SIZE1>
577 void dyson_mat_steep_dispatch(GG &G, GG &Sigma, T mu, cdmatrix &H0, cdmatrix &SigmaMF,
581 int ntau = G.ntau(), size1=G.size1();
583 herm_matrix<T> G0(-1,ntau,size1,G.sig());
584 herm_matrix<T> G0xSGM(-1,ntau,size1,G.sig());
585 herm_matrix<T> SGMxG0(-1,ntau,size1,G.sig());
586 herm_matrix<T> G0xMF(-1,ntau,size1,G.sig());
587 herm_matrix<T> MFxG0(-1,ntau,size1,G.sig());
588 function<T> sgmf(-1,size1);
592 sgmf.set_value(-1,SigmaMF);
593 G0xMF.set_timestep(-1,G0);
594 G0xMF.right_multiply(-1,sgmf);
595 MFxG0.set_timestep(-1,G0);
596 MFxG0.left_multiply(-1,sgmf);
598 convolution_matsubara(G0xSGM, G0, Sigma,
I, beta);
599 convolution_matsubara(SGMxG0, G0, Sigma,
I, beta);
600 G0xSGM.incr_timestep(-1,G0xMF);
602 SGMxG0.incr_timestep(-1,MFxG0);
605 vie2_mat_steep(G, G0xSGM, SGMxG0, G0, beta,
I, maxiter, tol);
650 template <
typename T,
class GG,
int SIZE1>
651 void dyson_timestep_tv(
int n, GG &G, T mu, std::complex<T> *Hn, GG &Sigma,
653 typedef std::complex<T>
cplx;
655 int sg, n1, l, m, j, ntau, size1 = G.size1();
656 cplx *gtv, *gtv1, cweight, ih, *mm, *qq, *stemp, minusi, *one, *htemp;
659 sg = G.element_size();
663 assert(Sigma.nt() >= n);
665 assert(G.sig() == Sigma.sig());
670 stemp =
new cplx[sg];
671 htemp =
new cplx[sg];
672 element_set<T, SIZE1>(size1, one, 1.0);
675 n1 = (ntau + 1) * sg;
676 for (l = 0; l < n1; l++)
679 convolution_timestep_tv<T, herm_matrix<T>, SIZE1>(n, G, Sigma, Sigma, G, G,
I, beta,
683 for (m = n - k - 1; m < n; m++) {
684 cweight = ih *
I.bd_weights(n - m);
686 n1 = (ntau + 1) * sg;
688 gtv1 = G.tvptr(n, 0);
689 for (l = 0; l < n1; l++)
690 gtv1[l] -= cweight * gtv[l];
695 element_set<T, SIZE1>(size1, stemp, Sigma.retptr(n, n));
696 weight = -h *
I.gregory_weights(n, 0);
697 element_set<T, SIZE1>(size1, htemp, Hn);
698 for (l = 0; l < sg; l++)
699 mm[l] = ih *
I.bd_weights(0) * one[l] + weight * stemp[l] + mu * one[l] - htemp[l];
700 for (j = 0; j <= ntau; j++) {
701 for (l = 0; l < sg; l++)
702 qq[l] = G.tvptr(n, j)[l];
703 element_linsolve_right<T, SIZE1>(size1, G.tvptr(n, j), mm, qq);
746 template <
typename T,
class GG,
int SIZE1>
747 void dyson_start_tv(GG &G, T mu, std::complex<T> *H, GG &Sigma,
749 typedef std::complex<T>
cplx;
751 int sg, l, m, j, ntau, p, q, n, sig, size1 = G.size1();
752 cplx cweight, *mm, *qq, *stemp, *one, *gtemp;
755 sg = G.element_size();
760 assert(Sigma.nt() >= k);
762 assert(Sigma.ntau() == ntau);
763 assert(G.sig() == Sigma.sig());
766 qq =
new cplx[k * sg];
767 mm =
new cplx[k * k * sg];
768 stemp =
new cplx[sg];
769 gtemp =
new cplx[k * sg];
770 element_set<T, SIZE1>(size1, one, 1.0);
772 for (m = 0; m <= ntau; m++)
773 for (l = 0; l < sg; l++)
774 G.tvptr(0, m)[l] = ((T)sig) * cplx_i * G.matptr(ntau - m)[l];
776 for (n = 1; n <= k; n++) {
777 for (m = 0; m <= ntau; m++) {
778 matsubara_integral_2<T, SIZE1>(size1, m, ntau, gtemp, Sigma.tvptr(n, 0),
779 G.matptr(0),
I, G.sig());
780 for (l = 0; l < sg; l++)
781 G.tvptr(n, m)[l] = dtau * gtemp[l];
785 for (m = 0; m <= ntau; m++) {
786 for (l = 0; l < k * k * sg; l++)
788 for (l = 0; l < k * sg; l++)
793 for (n = 1; n <= k; n++) {
796 for (j = 0; j <= k; j++) {
797 cweight = cplx_i / h *
I.poly_differentiation(n, j);
799 for (l = 0; l < sg; l++)
800 qq[p * sg + l] -= cweight * G.tvptr(0, m)[l];
803 for (l = 0; l < sg; l++)
804 mm[sg * (p * k + q) + l] += cweight * one[l];
808 element_set<T, SIZE1>(size1, gtemp, H + sg * n);
809 element_smul<T, SIZE1>(size1, gtemp, -1.0);
810 for (l = 0; l < sg; l++)
811 gtemp[l] += mu * one[l];
812 element_incr<T, SIZE1>(size1, mm + sg * (p * k + p), gtemp);
814 for (j = 0; j <= k; j++) {
815 cweight = h *
I.gregory_weights(n, j);
817 element_incr<T, SIZE1>(size1, qq + p * sg, cweight, Sigma.retptr(n, 0),
822 element_set<T, SIZE1>(size1, stemp, Sigma.retptr(n, j));
824 element_set<T, SIZE1>(size1, stemp, Sigma.retptr(j, n));
825 element_conj<T, SIZE1>(size1, stemp);
826 element_smul<T, SIZE1>(size1, stemp, -1);
828 for (l = 0; l < sg; l++)
829 mm[sg * (p * k + q) + l] += -cweight * stemp[l];
833 element_incr<T, SIZE1>(size1, qq + p * sg, G.tvptr(n, m));
835 element_linsolve_right<T, SIZE1>(size1, k, gtemp, mm,
838 for (n = 1; n <= k; n++)
839 element_set<T, SIZE1>(size1, G.tvptr(n, m), gtemp + (n - 1) * sg);
892 template <
typename T,
class GG,
int SIZE1>
893 void dyson_timestep_les(
int n, GG &G, T mu, std::complex<T> *H, GG &Sigma,
895 typedef std::complex<T>
cplx;
896 int k =
I.get_k(), k1 = k + 1;
897 int sg, n1, l, m, j, ntau, p, q, sig, size1 = G.size1();
898 cplx *gles, cweight, ih, *mm, *qq, *stemp, cplx_i =
cplx(0, 1), *one, *gtemp;
900 n1 = (n > k ? n : k);
901 sg = G.element_size();
905 assert(Sigma.nt() >= n1);
906 assert(G.nt() >= n1);
907 assert(G.sig() == Sigma.sig());
910 qq =
new cplx[k * sg];
911 mm =
new cplx[k * k * sg];
912 gtemp =
new cplx[sg];
913 stemp =
new cplx[sg];
914 gles =
new cplx[(n1 + 1) * sg];
915 for (j = 0; j <= n1; j++)
916 element_set_zero<T, SIZE1>(size1, gles + j * sg);
917 element_set<T, SIZE1>(size1, one, 1.0);
922 convolution_timestep_les_tvvt<T, GG, SIZE1>(n, gles, G, Sigma, Sigma, G, G,
I, beta,
924 convolution_timestep_les_lesadv<T, GG, SIZE1>(n, gles, G, Sigma, Sigma, G, G,
I, beta,
927 element_conj<T, SIZE1>(size1, gles, G.tvptr(n, 0));
928 element_smul<T, SIZE1>(size1, gles, -1);
934 for (l = 0; l < k * k * sg; l++)
936 for (l = 0; l < k * sg; l++)
938 for (j = 1; j <= k; j++) {
942 element_incr<T, SIZE1>(size1, qq + p * sg, gles + j * sg);
944 for (m = 0; m <= k; m++) {
945 cweight = cplx_i / h *
I.poly_differentiation(j, m);
947 for (l = 0; l < sg; l++)
948 qq[p * sg + l] -= cweight * gles[0 * sg + l];
951 for (l = 0; l < sg; l++)
952 mm[sg * (p * k + q) + l] += cweight * one[l];
956 element_set<T, SIZE1>(size1, gtemp, H + sg * j);
957 element_smul<T, SIZE1>(size1, gtemp, -1);
958 for (l = 0; l < sg; l++)
959 gtemp[l] += mu * one[l];
960 element_incr<T, SIZE1>(size1, mm + sg * (p * k + p), gtemp);
962 for (m = 0; m <= k; m++) {
963 cweight = h *
I.gregory_weights(j, m);
965 element_incr<T, SIZE1>(size1, qq + p * sg, cweight, Sigma.retptr(j, 0),
970 element_set<T, SIZE1>(size1, stemp, Sigma.retptr(j, m));
972 element_set<T, SIZE1>(size1, stemp, Sigma.retptr(m, j));
973 element_conj<T, SIZE1>(size1, stemp);
974 element_smul<T, SIZE1>(size1, stemp, -1);
976 for (l = 0; l < sg; l++)
977 mm[sg * (p * k + q) + l] += -cweight * stemp[l];
981 element_linsolve_right<T, SIZE1>(size1, k, gles + 1 * sg, mm,
984 for (j = k + 1; j <= n; j++) {
985 element_set_zero<T, SIZE1>(size1, mm);
987 element_set<T, SIZE1>(size1, qq, gles + j * sg);
989 for (p = 1; p <= k1; p++) {
990 cweight = -cplx_i / h *
I.bd_weights(p);
991 for (l = 0; l < sg; l++)
992 qq[l] += cweight * gles[sg * (j - p) + l];
994 for (l = 0; l < sg; l++)
995 mm[l] += cplx_i / h *
I.bd_weights(0) * one[l];
997 element_set<T, SIZE1>(size1, gtemp, H + sg * j);
998 element_smul<T, SIZE1>(size1, gtemp, -1);
999 for (l = 0; l < sg; l++)
1000 gtemp[l] += mu * one[l];
1001 element_incr<T, SIZE1>(size1, mm, gtemp);
1003 element_set<T, SIZE1>(size1, stemp, Sigma.retptr(j, j));
1004 for (l = 0; l < sg; l++)
1005 mm[l] += -h * stemp[l] *
I.gregory_weights(j, j);
1006 for (m = 0; m < j; m++) {
1007 cweight = h *
I.gregory_weights(j, m);
1008 element_incr<T, SIZE1>(size1, qq, cweight, Sigma.retptr(j, m), gles + m * sg);
1010 element_linsolve_right<T, SIZE1>(size1, gles + j * sg, mm, qq);
1013 for (j = 0; j <= n; j++)
1014 element_set<T, SIZE1>(size1, G.lesptr(j, n), gles + j * sg);
1058 template <
typename T,
class GG,
int SIZE1>
1059 void dyson_start_les(GG &G, T mu, std::complex<T> *H, GG &Sigma,
1061 int k =
I.get_k(), n;
1062 for (n = 0; n <= k; n++)
1063 dyson_timestep_les<T, GG, SIZE1>(n, G, mu, H, Sigma,
I, beta, h);
1068 template <
typename T>
1069 void dyson_mat_fourier(herm_matrix<T> &G, herm_matrix<T> &Sigma, T mu, function<T> &H, T beta,
1071 int size1 = G.size1();
1072 assert(G.size1() == Sigma.size1());
1073 assert(G.ntau() == Sigma.ntau());
1075 dyson_mat_fourier_dispatch<T, herm_matrix<T>, 1>(G, Sigma, mu, H.ptr(-1), beta, order);
1077 dyson_mat_fourier_dispatch<T, herm_matrix<T>, LARGESIZE>(G, Sigma, mu, H.ptr(-1), beta,
1081 template <
typename T>
1082 void dyson_mat_fourier(herm_matrix<T> &G, herm_matrix<T> &Sigma, T mu, function<T> &H,
1083 function<T> &SigmaMF, T beta,
int order) {
1084 int size1 = G.size1();
1085 assert(G.size1() == Sigma.size1());
1086 assert(G.ntau() == Sigma.ntau());
1087 std::complex<T> *hmf;
1088 hmf =
new std::complex<T>[size1*size1];
1091 element_set<T, 1>(size1, hmf, H.ptr(-1));
1092 element_incr<T, 1>(size1, hmf, 1.0, SigmaMF.ptr(-1));
1093 dyson_mat_fourier_dispatch<T, herm_matrix<T>, 1>(G, Sigma, mu, hmf, beta, order);
1095 element_set<T, LARGESIZE>(size1, hmf, H.ptr(-1));
1096 element_incr<T, LARGESIZE>(size1, hmf, 1.0, SigmaMF.ptr(-1));
1097 dyson_mat_fourier_dispatch<T, herm_matrix<T>, LARGESIZE>(G, Sigma, mu, hmf, beta,
1103 template <
typename T>
1104 void dyson_mat_fixpoint(herm_matrix<T> &G, herm_matrix<T> &Sigma, T mu, function<T> &H,
1106 assert(G.size1() == Sigma.size1());
1107 assert(G.ntau() == Sigma.ntau());
1108 int size1 = G.size1();
1109 cdmatrix h0(size1,size1);
1113 dyson_mat_fixpoint_dispatch<T, herm_matrix<T>, 1>(G, Sigma, mu, h0,
I, beta, fixpiter);
1115 dyson_mat_fixpoint_dispatch<T, herm_matrix<T>, LARGESIZE>(G, Sigma, mu, h0,
I, beta,
1119 template <
typename T>
1120 void dyson_mat_fixpoint(herm_matrix<T> &G, herm_matrix<T> &Sigma, T mu, function<T> &H,
1122 assert(G.size1() == Sigma.size1());
1123 assert(G.ntau() == Sigma.ntau());
1124 int size1 = G.size1();
1125 cdmatrix h0(size1,size1);
1129 dyson_mat_fixpoint_dispatch<T, herm_matrix<T>, 1>(G, Sigma, mu, h0, SigmaMF,
I, beta, fixpiter);
1131 dyson_mat_fixpoint_dispatch<T, herm_matrix<T>, LARGESIZE>(G, Sigma, mu, h0, SigmaMF,
I, beta,
1137 template <
typename T>
1138 void dyson_mat_steep(herm_matrix<T> &G, herm_matrix<T> &Sigma, T mu, function<T> &H,
1140 assert(G.size1() == Sigma.size1());
1141 assert(G.ntau() == Sigma.ntau());
1142 assert(H.size1() == G.size1() );
1143 int size1 = G.size1();
1144 cdmatrix h0(size1,size1);
1148 dyson_mat_steep_dispatch<T, herm_matrix<T>, 1>(G, Sigma, mu, h0,
I, beta, maxiter, tol);
1150 dyson_mat_steep_dispatch<T, herm_matrix<T>, LARGESIZE>(G, Sigma, mu, h0,
I, beta,
1155 template <
typename T>
1156 void dyson_mat_steep(herm_matrix<T> &G, herm_matrix<T> &Sigma, T mu, function<T> &H,
1158 assert(G.size1() == Sigma.size1());
1159 assert(G.ntau() == Sigma.ntau());
1160 assert(H.size1() == G.size1() );
1161 int size1 = G.size1();
1162 cdmatrix h0(size1,size1);
1166 dyson_mat_steep_dispatch<T, herm_matrix<T>, 1>(G, Sigma, mu, h0, SigmaMF,
I, beta, maxiter, tol);
1168 dyson_mat_steep_dispatch<T, herm_matrix<T>, LARGESIZE>(G, Sigma, mu, h0, SigmaMF,
I, beta,
1208 template <
typename T>
1209 void dyson_mat(herm_matrix<T> &G, herm_matrix<T> &Sigma, T mu, function<T> &H,
1211 const bool force_hermitian){
1212 assert(method <= 2 &&
"UNKNOWN CNTR_MAT_METHOD");
1215 const int fourier_order = 3;
1216 const double tol=1.0e-12;
1219 case CNTR_MAT_FOURIER:
1220 dyson_mat_fourier(G, Sigma, mu, H, SigmaMF, beta, fourier_order);
1224 dyson_mat_steep(G, Sigma, mu, H, SigmaMF,
I, beta, maxiter, tol);
1228 dyson_mat_fixpoint(G, Sigma, mu, H, SigmaMF,
I, beta, maxiter);
1231 if(force_hermitian){
1273 template <
typename T>
1276 const bool force_hermitian){
1277 assert(method <= 2 &&
"UNKNOWN CNTR_MAT_METHOD");
1278 assert(SolveOrder <= MAX_SOLVE_ORDER);
1280 const int fourier_order = 3;
1281 const double tol=1.0e-12;
1284 case CNTR_MAT_FOURIER:
1285 dyson_mat_fourier(G, Sigma, mu, H, SigmaMF, beta, fourier_order);
1289 dyson_mat_steep(G, Sigma, mu, H, SigmaMF, integration::I<T>(SolveOrder), beta, maxiter, tol);
1293 dyson_mat_fixpoint(G, Sigma, mu, H, SigmaMF, integration::I<T>(SolveOrder), beta, maxiter);
1296 if(force_hermitian){
1333 template <
typename T>
1334 void dyson_mat(herm_matrix<T> &G, herm_matrix<T> &Sigma, T mu, function<T> &H,
1336 assert(method <= 2 &&
"UNKNOWN CNTR_MAT_METHOD");
1338 const int fourier_order = 3;
1339 const double tol=1.0e-12;
1344 dyson_mat_fourier(G, Sigma, mu, H, beta, fourier_order);
1348 dyson_mat_steep(G, Sigma, mu, H,
I, beta, maxiter, tol);
1352 dyson_mat_fixpoint(G, Sigma, mu, H,
I, beta, maxiter);
1355 if(force_hermitian){
1392 template <
typename T>
1394 T beta,
const int SolveOrder,
const int method,
const bool force_hermitian){
1395 assert(method <= 2 &&
"UNKNOWN CNTR_MAT_METHOD");
1396 assert(SolveOrder <= MAX_SOLVE_ORDER);
1398 const int fourier_order = 3;
1399 const double tol=1.0e-12;
1404 dyson_mat_fourier(G, Sigma, mu, H, beta, fourier_order);
1408 dyson_mat_steep(G, Sigma, mu, H, integration::I<T>(SolveOrder), beta, maxiter, tol);
1412 dyson_mat_fixpoint(G, Sigma, mu, H, integration::I<T>(SolveOrder), beta, maxiter);
1415 if(force_hermitian){
1451 template <
typename T>
1452 void dyson_start(herm_matrix<T> &G, T mu, function<T> &H, herm_matrix<T> &Sigma,
1454 int size1 = G.size1(), k =
I.k();
1455 assert(G.size1() == Sigma.size1());
1456 assert(G.ntau() == Sigma.ntau());
1457 assert(G.nt() >= k);
1458 assert(Sigma.nt() >= k);
1460 dyson_start_ret<T, herm_matrix<T>, 1>(G, mu, H.ptr(0), Sigma,
I, h);
1461 dyson_start_tv<T, herm_matrix<T>, 1>(G, mu, H.ptr(0), Sigma,
I, beta, h);
1462 dyson_start_les<T, herm_matrix<T>, 1>(G, mu, H.ptr(0), Sigma,
I, beta, h);
1464 dyson_start_ret<T, herm_matrix<T>, LARGESIZE>(G, mu, H.ptr(0), Sigma,
I, h);
1465 dyson_start_tv<T, herm_matrix<T>, LARGESIZE>(G, mu, H.ptr(0), Sigma,
I, beta, h);
1466 dyson_start_les<T, herm_matrix<T>, LARGESIZE>(G, mu, H.ptr(0), Sigma,
I, beta, h);
1501 template <
typename T>
1503 T beta, T h,
const int SolveOrder) {
1504 int size1 = G.
size1();
1507 assert(G.
nt() >= SolveOrder);
1508 assert(Sigma.
nt() >= SolveOrder);
1510 dyson_start_ret<T, herm_matrix<T>, 1>(G, mu, H.
ptr(0), Sigma, integration::I<T>(SolveOrder), h);
1511 dyson_start_tv<T, herm_matrix<T>, 1>(G, mu, H.
ptr(0), Sigma, integration::I<T>(SolveOrder), beta, h);
1512 dyson_start_les<T, herm_matrix<T>, 1>(G, mu, H.
ptr(0), Sigma, integration::I<T>(SolveOrder), beta, h);
1514 dyson_start_ret<T, herm_matrix<T>, LARGESIZE>(G, mu, H.
ptr(0), Sigma, integration::I<T>(SolveOrder), h);
1515 dyson_start_tv<T, herm_matrix<T>, LARGESIZE>(G, mu, H.
ptr(0), Sigma, integration::I<T>(SolveOrder), beta, h);
1516 dyson_start_les<T, herm_matrix<T>, LARGESIZE>(G, mu, H.
ptr(0), Sigma, integration::I<T>(SolveOrder), beta, h);
1557 template <
typename T>
1558 void dyson_timestep(
int n, herm_matrix<T> &G, T mu, function<T> &H, herm_matrix<T> &Sigma,
1560 int size1 = G.size1(), k =
I.k();
1561 assert(G.size1() == Sigma.size1());
1562 assert(G.ntau() == Sigma.ntau());
1563 assert(G.nt() >= n);
1564 assert(Sigma.nt() >= n);
1567 dyson_timestep_ret<T, herm_matrix<T>, 1>(n, G, mu, H.ptr(0), Sigma,
I, h);
1568 dyson_timestep_tv<T, herm_matrix<T>, 1>(n, G, mu, H.ptr(n), Sigma,
I, beta, h);
1569 dyson_timestep_les<T, herm_matrix<T>, 1>(n, G, mu, H.ptr(0), Sigma,
I, beta, h);
1571 dyson_timestep_ret<T, herm_matrix<T>, LARGESIZE>(n, G, mu, H.ptr(0), Sigma,
I, h);
1572 dyson_timestep_tv<T, herm_matrix<T>, LARGESIZE>(n, G, mu, H.ptr(n), Sigma,
I, beta,
1574 dyson_timestep_les<T, herm_matrix<T>, LARGESIZE>(n, G, mu, H.ptr(0), Sigma,
I, beta,
1617 template <
typename T>
1619 T beta, T h,
const int SolveOrder) {
1620 int size1 = G.
size1();
1623 assert(G.
nt() >= n);
1624 assert(Sigma.
nt() >= n);
1625 assert(n > SolveOrder);
1627 dyson_timestep_ret<T, herm_matrix<T>, 1>(n, G, mu, H.
ptr(0), Sigma, integration::I<T>(SolveOrder), h);
1628 dyson_timestep_tv<T, herm_matrix<T>, 1>(n, G, mu, H.
ptr(n), Sigma, integration::I<T>(SolveOrder), beta, h);
1629 dyson_timestep_les<T, herm_matrix<T>, 1>(n, G, mu, H.
ptr(0), Sigma, integration::I<T>(SolveOrder), beta, h);
1631 dyson_timestep_ret<T, herm_matrix<T>, LARGESIZE>(n, G, mu, H.
ptr(0), Sigma, integration::I<T>(SolveOrder), h);
1632 dyson_timestep_tv<T, herm_matrix<T>, LARGESIZE>(n, G, mu, H.
ptr(n), Sigma, integration::I<T>(SolveOrder), beta,
1634 dyson_timestep_les<T, herm_matrix<T>, LARGESIZE>(n, G, mu, H.
ptr(0), Sigma, integration::I<T>(SolveOrder), beta,
1675 template <
typename T>
1676 void dyson(herm_matrix<T> &G, T mu, function<T> &H, herm_matrix<T> &Sigma,
1678 const bool force_hermitian) {
1679 int n, k =
I.k(), nt = G.nt();
1680 dyson_mat(G, Sigma, mu, H,
I, beta, matsubara_method, force_hermitian);
1682 dyson_start(G, mu, H, Sigma,
I, beta, h);
1683 for (n = k + 1; n <= nt; n++)
1684 dyson_timestep(n, G, mu, H, Sigma,
I, beta, h);
1724 template <
typename T>
1726 T beta, T h,
const int SolveOrder,
const int matsubara_method,
1727 const bool force_hermitian) {
1729 dyson_mat(G, mu, H, Sigma, beta, SolveOrder, matsubara_method, force_hermitian);
1731 dyson_start(G, mu, H, Sigma, beta, h, SolveOrder);
1732 for (n = SolveOrder + 1; n <= nt; n++)
1733 dyson_timestep(n, G, mu, H, Sigma, beta, h, SolveOrder);
1737 #endif // CNTR_DYSON_IMPL_H void green_from_H(herm_matrix< T > &G, T mu, cdmatrix &eps, T beta, T h)
Propagator for time-independent free Hamiltonian
Class Integrator contains all kinds of weights for integration and differentiation of a function at ...
void force_matsubara_hermitian(herm_matrix< T > &G)
Force the Matsubara component of herm_matrix to be a hermitian matrix at each . ...
std::complex< double > cplx
Integrator< T > & I(int k)
Class function for objects with time on real axis.
Class herm_matrix for two-time contour objects with hermitian symmetry.