Loading...
Searching...
No Matches
quantumbridge::quadrature Namespace Reference

Classes

struct  Panel

Typedefs

using Real = long double
using Value = std::vector<Real>

Functions

void accumulate (const Value &value, Real wk, Real wg, Value &k, Value &g, Value &absolute)
Panel finish (Real left, Real right, const Value &k, const Value &g, const Value &absolute)
template<class Function>
Panel panel (Real left, Real right, const Function &function, std::size_t &evaluations)

Variables

constexpr std::array< Real, 8 > nodes
constexpr std::array< Real, 8 > kronrod
constexpr std::array< Real, 4 > gauss

Typedef Documentation

◆ Real

using quantumbridge::quadrature::Real = long double

Definition at line 15 of file QuantumBridgeQuadrature.h.

◆ Value

using quantumbridge::quadrature::Value = std::vector<Real>

Definition at line 16 of file QuantumBridgeQuadrature.h.

Function Documentation

◆ accumulate()

void quantumbridge::quadrature::accumulate ( const Value & value,
Real wk,
Real wg,
Value & k,
Value & g,
Value & absolute )
inline

Definition at line 23 of file QuantumBridgeQuadrature.h.

25{
26 if (value.size() != k.size())
27 throw std::invalid_argument("Quadrature vector dimensions differ");
28 for (std::size_t j = 0; j < value.size(); ++j) {
29 if (!std::isfinite(value[j]))
30 throw std::overflow_error("Nonfinite quadrature integrand");
31 k[j] += wk * value[j];
32 g[j] += wg * value[j];
33 absolute[j] += wk * std::abs(value[j]);
34 }
35}

◆ finish()

Panel quantumbridge::quadrature::finish ( Real left,
Real right,
const Value & k,
const Value & g,
const Value & absolute )
inline

Definition at line 36 of file QuantumBridgeQuadrature.h.

38{
39 Panel result;
40 result.left = left;
41 result.right = right;
42 result.integral.resize(k.size());
43 result.error.resize(k.size());
44 const Real half = (right - left) / 2;
45 for (std::size_t j = 0; j < k.size(); ++j) {
46 result.integral[j] = half * k[j];
47 result.error[j] = std::max(
48 std::abs(half * (k[j] - g[j])),
49 64 * std::numeric_limits<Real>::epsilon() * half * absolute[j]);
50 }
51 return result;
52}

◆ panel()

template<class Function>
Panel quantumbridge::quadrature::panel ( Real left,
Real right,
const Function & function,
std::size_t & evaluations )

Definition at line 67 of file QuantumBridgeQuadrature.h.

69{
70 if (!std::isfinite(left) || !std::isfinite(right) ||
71 !std::isgreater(right, left))
72 throw std::invalid_argument(
73 "Finite ordered quadrature endpoints required");
74 const Real center = left + (right - left) / 2;
75 const Real half = (right - left) / 2;
76 const Value value = function(center);
77 ++evaluations;
78 Value k(value.size(), 0), g(value.size(), 0), absolute(value.size(), 0);
79 accumulate(value, kronrod[7], gauss[3], k, g, absolute);
80 for (std::size_t i = 0; i < 7; ++i) {
81 const Real wg = i % 2 ? gauss[i / 2] : 0;
82 accumulate(function(center - half * nodes[i]), kronrod[i], wg, k, g,
83 absolute);
84 accumulate(function(center + half * nodes[i]), kronrod[i], wg, k, g,
85 absolute);
86 evaluations += 2;
87 }
88 return finish(left, right, k, g, absolute);
89}
constexpr std::array< Real, 8 > kronrod
constexpr std::array< Real, 8 > nodes
Panel finish(Real left, Real right, const Value &k, const Value &g, const Value &absolute)
constexpr std::array< Real, 4 > gauss
void accumulate(const Value &value, Real wk, Real wg, Value &k, Value &g, Value &absolute)

Variable Documentation

◆ gauss

std::array<Real, 4> quantumbridge::quadrature::gauss
inlineconstexpr
Initial value:
= {
.129484966168869693270611432679082L, .279705391489276667901467771423780L,
.381830050505118944950369775488975L, .417959183673469387755102040816327L}

Definition at line 63 of file QuantumBridgeQuadrature.h.

63 {
64 .129484966168869693270611432679082L, .279705391489276667901467771423780L,
65 .381830050505118944950369775488975L, .417959183673469387755102040816327L};

◆ kronrod

std::array<Real, 8> quantumbridge::quadrature::kronrod
inlineconstexpr
Initial value:
= {
.022935322010529224963732008058970L, .063092092629978553290700663189204L,
.104790010322250183839876322541518L, .140653259715525918745189590510238L,
.169004726639267902826583426598550L, .190350578064785409913256402421014L,
.204432940075298892414161999234649L, .209482141084727828012999174891714L}

Definition at line 58 of file QuantumBridgeQuadrature.h.

58 {
59 .022935322010529224963732008058970L, .063092092629978553290700663189204L,
60 .104790010322250183839876322541518L, .140653259715525918745189590510238L,
61 .169004726639267902826583426598550L, .190350578064785409913256402421014L,
62 .204432940075298892414161999234649L, .209482141084727828012999174891714L};

◆ nodes

std::array<Real, 8> quantumbridge::quadrature::nodes
inlineconstexpr
Initial value:
= {
.991455371120812639206854697526329L, .949107912342758524526189684047851L,
.864864423359769072789712788640926L, .741531185599394439863864773280788L,
.586087235467691130294144838258730L, .405845151377397166906606412076961L,
.207784955007898467600689403773245L, 0.L}

Definition at line 53 of file QuantumBridgeQuadrature.h.

53 {
54 .991455371120812639206854697526329L, .949107912342758524526189684047851L,
55 .864864423359769072789712788640926L, .741531185599394439863864773280788L,
56 .586087235467691130294144838258730L, .405845151377397166906606412076961L,
57 .207784955007898467600689403773245L, 0.L};