36namespace triqs::utility {
39 using dcomplex = std::complex<double>;
73 mpf_class d = z.
re * z.
re + z.
im * z.
im;
75 return {.re = z.
re / d, .im = -z.
im / d};
146 return out <<
" gmp_complex(" << z.
re <<
"," << z.
im <<
")" << std::endl;
173 nda::vector<dcomplex> z_in;
174 nda::vector<dcomplex> a;
194 pade_approximant(
const nda::vector<dcomplex> &z_in,
const nda::vector<dcomplex> &u_in) : z_in(z_in), a(z_in.
size()) {
196 long N = z_in.size();
199 unsigned long old_prec = mpf_get_default_prec();
202 nda::array<gmp_complex, 2> g(N, N);
205 for (
long f = 0; f < N; ++f) { g(0, f) = u_in(f); }
209 for (
long p = 1; p < N; ++p) {
212 if (g(p - 1, p - 1).norm() < 1.0e-20)
break;
214 for (
long j = p; j < N; ++j) {
215 gmp_complex x = g(p - 1, p - 1) / g(p - 1, j) - MP_1;
217 y = z_in(j) - z_in(p - 1);
222 for (
long j = 0; j < N; ++j) {
228 mpf_set_default_prec(old_prec);
253 for (
long i = 0; i <= N - 2; ++i) {
254 dcomplex Anew = A2 + (z - z_in(i)) * a(i + 1) * A1;
255 dcomplex Bnew = 1.0 + (z - z_in(i)) * a(i + 1) * B1;
int size() const
Get the total number of blocks.
Backward-compatibility umbrella header pulling in the nda array library.
dcomplex operator()(dcomplex z) const
Evaluate the Padé continued fraction at the complex point .
pade_approximant(const nda::vector< dcomplex > &z_in, const nda::vector< dcomplex > &u_in)
Constructor computes the Padé coefficients from a set of complex sample points and values.
static const int GMP_default_prec
Default precision (in mantissa bits) used for the GMP floats during coefficient calculation.
TRIQS exception hierarchy and related macros.
#define TRIQS_RUNTIME_ERROR
Throw a triqs::runtime_error with the current source location.
I real(I const &x)
Real part of an integral value.
I imag(I const &x)
Imaginary part of an integral value.
std::complex< double > dcomplex
Convenience alias for std::complex<double>.
Lightweight complex number backed by GMP mpf_class floats, used during Padé coefficient computation.
friend mpf_class real(const gmp_complex &z)
Extract the real part of a complex number.
gmp_complex & operator=(const std::complex< double > &z)
Assign from a regular std::complex<double>.
mpf_class norm() const
Squared magnitude of the complex number .
gmp_complex operator+(const gmp_complex &z) const
Add two complex numbers.
friend gmp_complex inverse(const gmp_complex &z)
Compute the multiplicative inverse of a complex number.
mpf_class im
Imaginary part.
gmp_complex operator/(const gmp_complex &z) const
Divide two complex numbers.
gmp_complex operator*(const gmp_complex &z) const
Multiply two complex numbers.
friend mpf_class imag(const gmp_complex &z)
Extract the imaginary part of a complex number.
gmp_complex operator-(const gmp_complex &z) const
Subtract two complex numbers.
friend std::ostream & operator<<(std::ostream &out, gmp_complex const &z)
Write a gmp_complex to an output stream.