TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
Math helpers

Detailed Description

Numerical and mathematical helpers (Legendre, Chebyshev, Padé, real-or-complex, ...).

Classes

struct  triqs::utility::gmp_complex
 Lightweight complex number backed by GMP mpf_class floats, used during Padé coefficient computation. More...
class  triqs::utility::legendre_generator
 Recursive generation of Legendre polynomials \( P_l(x) \). More...
class  triqs::utility::pade_approximant
 Padé approximant of a complex function sampled at \( \{ z_i \} \) with values \( \{ u_i \} \). More...
class  triqs::utility::real_or_complex
 Type that can represent either a real or a complex number. More...
struct  triqs::utility::time_pt
 A point in imaginary time, \( \tau_n \in [0, \beta] \), stored on a very fine integer grid. More...
struct  triqs::utility::time_segment
 Represents the imaginary-time segment \( [0, \beta] \). More...

Functions

template<typename T1, typename T2>
requires (std::is_arithmetic_v<T1> and std::is_arithmetic_v<T2>)
bool triqs::utility::kronecker (T1 i, T2 j)
 Kronecker delta \( \delta_{ij} \).
std::complex< double > triqs::utility::legendre_T (int n, int l)
 Get the quantity \( T_{nl} \) from Eq.(E2) in the paper https://doi.org/10.1103/PhysRevB.84.075145.
double triqs::utility::legendre_t (int l, int p)
 Get the quantity \( t_l^{(p)} \) from Eq.(E8) in the paper https://doi.org/10.1103/PhysRevB.84.075145.
double triqs::utility::mod_cyl_bessel_i (int n, double x)
 Get the modified spherical bessel function \( i_n(x) \) of the first kind of order \( n \) evaluated at \( x \).
double operator* (time_pt const &tp1, time_pt const &tp2)
 Multiplication between two time points.
double operator/ (time_pt const &tp1, time_pt const &tp2)
 Division between two time points.
nda::vector< double > triqs::utility::chebyshev_points (long N)
 Compute Chebyshev points of the first kind on the interval \( [-1, 1] \).
nda::vector< double > triqs::utility::chebyshev_barycentric_weights (long N)
 Compute barycentric weights for Chebyshev points of the first kind.
double triqs::utility::to_standard_interval (double x, double a, double b)
 Scale a value from interval \( [a, b] \) to the standard interval \( [-1, 1] \).
double triqs::utility::from_standard_interval (double x, double a, double b)
 Scale a value from the standard interval \( [-1, 1] \) to interval \( [a, b] \).
template<std::integral I>
bool triqs::utility::is_zero (I const &x)
 Exact zero check for integral values.
template<std::floating_point T>
bool triqs::utility::is_zero (T const &x, T tolerance=100 *std::numeric_limits< T >::epsilon())
 Zero check for floating-point values.
template<typename T>
bool triqs::utility::is_zero (std::complex< T > const &z, T tolerance=100 *std::numeric_limits< T >::epsilon())
 Zero check for complex values.
template<std::integral I>
triqs::utility::conj (I const &x)
 Complex conjugate of an integral value.
template<std::floating_point T>
triqs::utility::conj (T const &x)
 Complex conjugate of a floating-point value.
template<typename Z>
requires (triqs::is_complex<Z>::value)
triqs::utility::conj (Z const &z)
 Complex conjugate of a complex value.
template<std::integral I>
triqs::utility::real (I const &x)
 Real part of an integral value.
template<std::floating_point T>
triqs::utility::real (T const &x)
 Real part of a floating-point value.
template<typename Z>
requires (triqs::is_complex<Z>::value)
triqs::utility::real (Z const &z)
 Real part of a complex value.
template<std::integral I>
triqs::utility::imag (I const &x)
 Imaginary part of an integral value.
template<std::floating_point T>
triqs::utility::imag (T const &x)
 Imaginary part of a floating-point value.
template<typename Z>
requires (triqs::is_complex<Z>::value)
triqs::utility::imag (Z const &z)
 Imaginary part of a complex value.

Function Documentation

◆ chebyshev_barycentric_weights()

nda::vector< double > triqs::utility::chebyshev_barycentric_weights ( long N)
inline

#include <triqs/utility/chebyshev.hpp>

Compute barycentric weights for Chebyshev points of the first kind.

Weights are computed as:

\[ w_i = (-1)^i \sin\left(\frac{(2i + 1) \pi}{2N}\right) \]

These weights are used in the barycentric interpolation formula. Weights are returned in the same order as chebyshev_points().

Parameters
NNumber of Chebyshev points.
Returns
Vector of \( N \) barycentric weights.

Definition at line 73 of file chebyshev.hpp.

◆ chebyshev_points()

nda::vector< double > triqs::utility::chebyshev_points ( long N)
inline

#include <triqs/utility/chebyshev.hpp>

Compute Chebyshev points of the first kind on the interval \( [-1, 1] \).

Points are computed as:

\[ x_i = \cos\left(\frac{(2i + 1) \pi}{2N}\right) \quad \text{for } i = 0, \ldots, N-1 \]

These are the roots of the Chebyshev polynomial \( T_N(x) \). Points are returned in ascending order.

Parameters
NNumber of Chebyshev points.
Returns
Vector of \( N \) Chebyshev points in ascending order on \( [-1, 1] \).

Definition at line 50 of file chebyshev.hpp.

◆ conj() [1/3]

template<std::integral I>
I triqs::utility::conj ( I const & x)

#include <triqs/utility/numeric_ops.hpp>

Complex conjugate of an integral value.

Template Parameters
IIntegral type.
Parameters
xValue to conjugate.
Returns
Value \( x \) unchanged.

Definition at line 80 of file numeric_ops.hpp.

◆ conj() [2/3]

template<std::floating_point T>
T triqs::utility::conj ( T const & x)

#include <triqs/utility/numeric_ops.hpp>

Complex conjugate of a floating-point value.

Template Parameters
TFloating-point type.
Parameters
xValue to conjugate.
Returns
Value \( x \) unchanged.

Definition at line 89 of file numeric_ops.hpp.

◆ conj() [3/3]

template<typename Z>
requires (triqs::is_complex<Z>::value)
Z triqs::utility::conj ( Z const & z)

#include <triqs/utility/numeric_ops.hpp>

Complex conjugate of a complex value.

Template Parameters
ZComplex type.
Parameters
zValue to conjugate.
Returns
\( z^* \).

Definition at line 100 of file numeric_ops.hpp.

◆ from_standard_interval()

double triqs::utility::from_standard_interval ( double x,
double a,
double b )
inline

#include <triqs/utility/chebyshev.hpp>

Scale a value from the standard interval \( [-1, 1] \) to interval \( [a, b] \).

Parameters
xValue in \( [-1, 1] \).
aLower bound of the target interval.
bUpper bound of the target interval.
Returns
Scaled value in \( [a, b] \).

Definition at line 102 of file chebyshev.hpp.

◆ imag() [1/3]

template<std::integral I>
I triqs::utility::imag ( I const & x)

#include <triqs/utility/numeric_ops.hpp>

Imaginary part of an integral value.

Template Parameters
IIntegral type.
Parameters
xValue to inspect.
Returns
Zero.

Definition at line 142 of file numeric_ops.hpp.

◆ imag() [2/3]

template<std::floating_point T>
T triqs::utility::imag ( T const & x)

#include <triqs/utility/numeric_ops.hpp>

Imaginary part of a floating-point value.

Template Parameters
TFloating-point type.
Parameters
xValue to inspect.
Returns
Zero.

Definition at line 151 of file numeric_ops.hpp.

◆ imag() [3/3]

template<typename Z>
requires (triqs::is_complex<Z>::value)
Z triqs::utility::imag ( Z const & z)

#include <triqs/utility/numeric_ops.hpp>

Imaginary part of a complex value.

Template Parameters
ZComplex type.
Parameters
zValue to inspect.
Returns
Imaginary part of \( z \), i.e. \( \Im(z) \).

Definition at line 162 of file numeric_ops.hpp.

◆ is_zero() [1/3]

template<std::integral I>
bool triqs::utility::is_zero ( I const & x)

#include <triqs/utility/numeric_ops.hpp>

Exact zero check for integral values.

Template Parameters
IIntegral type.
Parameters
xValue to test.
Returns
True if the given integral value is exactly zero, false otherwise.

Definition at line 49 of file numeric_ops.hpp.

◆ is_zero() [2/3]

template<typename T>
bool triqs::utility::is_zero ( std::complex< T > const & z,
T tolerance = 100 * std::numeric_limits<T>::epsilon() )

#include <triqs/utility/numeric_ops.hpp>

Zero check for complex values.

Template Parameters
TValue type.
Parameters
zValue to test.
toleranceAbsolute tolerance \( \epsilon \).
Returns
True if \( |\Re(z)| < \epsilon \) and \( |\Im(z)| < \epsilon \), false otherwise.

Definition at line 69 of file numeric_ops.hpp.

◆ is_zero() [3/3]

template<std::floating_point T>
bool triqs::utility::is_zero ( T const & x,
T tolerance = 100 * std::numeric_limits<T>::epsilon() )

#include <triqs/utility/numeric_ops.hpp>

Zero check for floating-point values.

Template Parameters
TFloating-point type.
Parameters
xValue to test.
toleranceAbsolute tolerance \( \epsilon \).
Returns
True if \( |x| < \epsilon \), false otherwise.

Definition at line 59 of file numeric_ops.hpp.

◆ kronecker()

template<typename T1, typename T2>
requires (std::is_arithmetic_v<T1> and std::is_arithmetic_v<T2>)
bool triqs::utility::kronecker ( T1 i,
T2 j )
inline

#include <triqs/utility/kronecker.hpp>

Kronecker delta \( \delta_{ij} \).

Template Parameters
T1Arithmetic type of the first index.
T2Arithmetic type of the second index.
Parameters
iIndex \( i \).
jIndex \( j \).
Returns
True if the given indices are equal, false otherwise.

Definition at line 45 of file kronecker.hpp.

◆ legendre_T()

std::complex< double > triqs::utility::legendre_T ( int n,
int l )

#include <triqs/utility/legendre.cpp>

Get the quantity \( T_{nl} \) from Eq.(E2) in the paper https://doi.org/10.1103/PhysRevB.84.075145.

Parameters
nMatsubara index \( n \).
lLegendre polynomial order \( l \).
Returns
\( T_{nl} = (-1)^n i^{l+1} \sqrt{2l + 1} j_l(\bar{\nu_n} / 2) \).

Definition at line 37 of file legendre.cpp.

◆ legendre_t()

double triqs::utility::legendre_t ( int l,
int p )

#include <triqs/utility/legendre.cpp>

Get the quantity \( t_l^{(p)} \) from Eq.(E8) in the paper https://doi.org/10.1103/PhysRevB.84.075145.

Parameters
lLegendre polynomial order \( l \).
pIndex \( p \).
Returns
\( t_l^{(p)} = (-1)^p 2 \sqrt{2l + 1} \frac{(l + p - 1)!}{(p - 1)! (l - p + 1)!} \delta_{p+l,\text{odd}} \).

Definition at line 53 of file legendre.cpp.

◆ mod_cyl_bessel_i()

double triqs::utility::mod_cyl_bessel_i ( int n,
double x )

#include <triqs/utility/legendre.cpp>

Get the modified spherical bessel function \( i_n(x) \) of the first kind of order \( n \) evaluated at \( x \).

Parameters
nOrder \( n \) of the modified spherical Bessel function.
xValue \( x \) at which to evaluate the function.
Returns
\( i_n(x) = \sqrt{\frac{\pi}{2x}} I_{n+1/2}(x) \).

Definition at line 68 of file legendre.cpp.

◆ operator*()

double operator* ( time_pt const & tp1,
time_pt const & tp2 )
related

Multiplication between two time points.

Parameters
tp1Left-hand side time point \( \tau_l \).
tp2Right-hand side time point \( \tau_r \).
Returns
Product of their floating-point values.

Definition at line 224 of file time_pt.hpp.

◆ operator/()

double operator/ ( time_pt const & tp1,
time_pt const & tp2 )
related

Division between two time points.

Parameters
tp1Left-hand side time point \( \tau_l \).
tp2Right-hand side time point \( \tau_r \).
Returns
Ratio of their floating-point values.

Definition at line 234 of file time_pt.hpp.

◆ real() [1/3]

template<std::integral I>
I triqs::utility::real ( I const & x)

#include <triqs/utility/numeric_ops.hpp>

Real part of an integral value.

Template Parameters
IIntegral type.
Parameters
xValue to inspect.
Returns
Value \( x \) unchanged.

Definition at line 111 of file numeric_ops.hpp.

◆ real() [2/3]

template<std::floating_point T>
T triqs::utility::real ( T const & x)

#include <triqs/utility/numeric_ops.hpp>

Real part of a floating-point value.

Template Parameters
TFloating-point type.
Parameters
xValue to inspect.
Returns
Value \( x \) unchanged.

Definition at line 120 of file numeric_ops.hpp.

◆ real() [3/3]

template<typename Z>
requires (triqs::is_complex<Z>::value)
Z triqs::utility::real ( Z const & z)

#include <triqs/utility/numeric_ops.hpp>

Real part of a complex value.

Template Parameters
ZComplex type.
Parameters
zValue to inspect.
Returns
Real part of \( z \), i.e. \( \Re(z) \).

Definition at line 131 of file numeric_ops.hpp.

◆ to_standard_interval()

double triqs::utility::to_standard_interval ( double x,
double a,
double b )
inline

#include <triqs/utility/chebyshev.hpp>

Scale a value from interval \( [a, b] \) to the standard interval \( [-1, 1] \).

Parameters
xValue in \( [a, b] \).
aLower bound of the original interval.
bUpper bound of the original interval.
Returns
Scaled value in \( [-1, 1] \).

Definition at line 92 of file chebyshev.hpp.