1#ifndef LCD_EVEN_CLOSED_FORM_H
2#define LCD_EVEN_CLOSED_FORM_H
4#include <gsl/gsl_errno.h>
5#include <gsl/gsl_sf_expint.h>
71 size_t n = (N % 2 == 0) ? 2 : 1;
72 double aN = (N % 2 == 0)
74 : 0.50 * (
b * std::sqrt(1.00 +
bSqrd) - std::asinh(
b));
76 for (
n += 2;
n <= N;
n += 2) {
77 const double dn =
static_cast<double>(
n);
102 if (
c <= 0.00)
return 0.50 *
bSqrd;
104 const double z = -
c / (4.00 *
bSqrd);
133 const double u = 1.00 + 2.00 *
b *
b;
134 double value =
b * std::pow(
b *
b /
u,
static_cast<double>(
p->k));
137 const double exponent = -
p->cValue / (2.00 *
u);
154 double e0,
double dEi,
double c) {
158 if (
d == 1)
return -0.25 *
dEi;
166 for (
size_t j =
d;; --
j) {
212 size_t shift,
bool reduced =
false) {
218 const double u = 1.00 + 2.00 * bMax * bMax;
222 const double e0 = std::exp(-
c / 2.00);
227 for (
size_t j = 0;
j <= k; ++
j) {
231 binomial *=
static_cast<double>(k -
j) /
static_cast<double>(
j + 1);
234 return std::ldexp(
sum, -
static_cast<int>(k));
260 const double u = 1.00 + 2.00 * bMax * bMax;
262 double sum = (
u - 1.00) -
static_cast<double>(k) * std::log(
u);
264 double binomial =
static_cast<double>(k);
265 for (
size_t j = 2;
j <= k; ++
j) {
266 binomial *=
static_cast<double>(k -
j + 1) /
static_cast<double>(
j);
267 const double dj =
static_cast<double>(
j);
273 return std::ldexp(
sum, -
static_cast<int>(k) - 2);
291 const double u = 1.00 + 2.00 * bMax * bMax;
293 double sum = -1.00 -
static_cast<double>(k) * std::log(
u);
295 double binomial =
static_cast<double>(k);
296 for (
size_t j = 2;
j <= k; ++
j) {
297 binomial *=
static_cast<double>(k -
j + 1) /
static_cast<double>(
j);
298 const double dj =
static_cast<double>(
j);
304 return std::ldexp(
sum, -
static_cast<int>(k) - 2);
326 if (
c <= 0.00)
return 0.00;
390 const size_t k = N / 2;
391 const double bMaxSqrd = bMax * bMax;
410 static_cast<int>(k) + 1) +
Definition dirac_to_dirac_approx_short.h:9
parameters of the raw b-integrand used by the small-c fallback
Definition lcd_even_closed_form.h:111
double cValue
squared norm of the sample
Definition lcd_even_closed_form.h:114
size_t k
half the dimension
Definition lcd_even_closed_form.h:112
bool reduced
true to use expm1, giving dBkk(c) - dBkk(0) directly
Definition lcd_even_closed_form.h:115
size_t q
exponent of (1 + 2b^2); k for dBkk, k+1 for dBkk1
Definition lcd_even_closed_form.h:113