TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
legendre.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2017 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2013-2017 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2019 Simons Foundation
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You may obtain a copy of the License at
16// https://www.gnu.org/licenses/gpl-3.0.txt
17//
18// Authors: Olivier Parcollet, Nils Wentzell
19
24
25#pragma once
26
27#include <array>
28#include <complex>
29
30#include <nda/macros.hpp>
31
32namespace triqs::utility {
33
38
47 std::complex<double> legendre_T(int n, int l);
48
58 double legendre_t(int l, int p);
59
68 double mod_cyl_bessel_i(int n, double x);
69
88 public:
93 legendre_generator(double x = 0.0) : x_(x), arr_{1.0, x} { EXPECTS(x >= -1.0 and x <= 1.0); }
94
101 double next() {
102 if (l_ > 1) {
103 auto idx = static_cast<unsigned int>(l_ % 2);
104 arr_[idx] = ((2 * l_ - 1) * x_ * arr_[1 - idx] - (l_ - 1) * arr_[idx]) / l_;
105 ++l_;
106 return arr_[idx];
107 } else {
108 ++l_;
109 return arr_[l_ - 1];
110 }
111 }
112
117 void reset(double x) {
118 EXPECTS(x >= -1.0 and x <= 1.0);
119 x_ = x;
120 l_ = 0;
121 arr_[0] = 1.0;
122 arr_[1] = x;
123 }
124
125 private:
126 double x_{0.0};
127 unsigned int l_{0};
128 std::array<double, 2> arr_{1.0, 0.0};
129 };
130
132
133} // namespace triqs::utility
legendre_generator(double x=0.0)
Construct a Legendre polynomial generator at a given value .
Definition legendre.hpp:93
void reset(double x)
Reset the generator to 0th order and with a new value.
Definition legendre.hpp:117
double next()
Increase the degree of the polynomial from to using .
Definition legendre.hpp:101
std::complex< double > legendre_T(int n, int l)
Get the quantity from Eq.(E2) in the paper https://doi.org/10.1103/PhysRevB.84.075145.
Definition legendre.cpp:37
double mod_cyl_bessel_i(int n, double x)
Get the modified spherical bessel function of the first kind of order evaluated at .
Definition legendre.cpp:68
double legendre_t(int l, int p)
Get the quantity from Eq.(E8) in the paper https://doi.org/10.1103/PhysRevB.84.075145.
Definition legendre.cpp:53