LdsGen 1.2.6
Loading...
Searching...
No Matches
Functions
ldsgen::detail Namespace Reference

Functions

template<typename T , typename Table >
constexpr auto vdc_digit_sum (unsigned long n, unsigned long base, const Table &weights) -> T
 Core base-b digit/weight summation shared by all van der Corput generators.
 

Function Documentation

◆ vdc_digit_sum()

template<typename T , typename Table >
constexpr auto ldsgen::detail::vdc_digit_sum ( unsigned long  n,
unsigned long  base,
const Table &  weights 
) -> T
constexpr

Core base-b digit/weight summation shared by all van der Corput generators.

Extracts the base-b digits of n (least significant first) and accumulates each digit times its precomputed weight:

\[ \sum_k a_k(n) \cdot \mathrm{weights}[k], \qquad n = \sum_k a_k(n) \, b^k \]

The weights table determines the value type and scaling of the result: reverse powers \(b^{-k-1}\) for the floating-point generators, ascending integer powers for the integer generators.

Template Parameters
TAccumulator/result type (e.g. double or unsigned long).
TableRandom-access table type (e.g. std::array).
Parameters
[in]nThe sequence index to evaluate.
[in]baseThe numeric base.
[in]weightsPrecomputed digit weights.
Returns
The weighted digit sum for index n.