I've calculated the Daubechies wavelet and scaling filters in `float`

. `double`

. `long double`

, and `quad`

Accuracy and want to make these filters available in a usable API. My problem is this: I want to make sure that these filters are correct for every single bit, so I wrote them as hexadecimal floating-point literals. Then I wanted them to be parsed in the right format, so I have to attach literals like that `f`

. `L`

, or `Q`

, But to analyze it as the right guy, I have to duplicate it over and over again, resulting in a monstrous result `#include`

File, given here

The file is too big to include in the question, but here's a quick example:

```
#ifndef BOOST_MATH_FILTERS_DAUBECHIES_HPP
#define BOOST_MATH_FILTERS_DAUBECHIES_HPP
#include
#ifdef BOOST_HAS_FLOAT128
#include
#endif
namespace boost::math::filters {
template
constexpr std::array daubechies_scaling_filter()
{
static_assert(sizeof(Real) <= 16, "Filter coefficients only computed up to 128 bits of precision.");
static_assert(p < 25, "Filter coefficients only implemented up to 24.");
if constexpr (p == 1) {
if constexpr (std::is_same_v) {
return {0x1.6a09e6p-1f, 0x1.6a09e6p-1f};
}
if constexpr (std::is_same_v) {
return {0x1.6a09e667f3bcdp-1, 0x1.6a09e667f3bcdp-1};
}
if constexpr (std::is_same_v) {
return {0xb.504f333f9de6484p-4L, 0xb.504f333f9de6484p-4L};
}
#ifdef BOOST_HAS_FLOAT128
if constexpr (std::is_same_v) {
return {0x1.6a09e667f3bcc908b2fb1366ea95p-1Q, 0x1.6a09e667f3bcc908b2fb1366ea95p-1Q};
}
#endif
}
if constexpr (p == 2) {
if constexpr (std::is_same_v) {
return {0x1.ee8dd4p-2f, 0x1.ac4bdep-1f, 0x1.cb0bfp-3f, -0x1.0907dcp-3f};
}
if constexpr (std::is_same_v) {
return {0x1.ee8dd4748bf15p-2, 0x1.ac4bdd6e3fd71p-1, 0x1.cb0bf0b6b7109p-3, -0x1.0907dc193069p-3};
}
if constexpr (std::is_same_v) {
return {0xf.746ea3a45f8a62ap-5L, 0xd.625eeb71feb8557p-4L, 0xe.585f85b5b8845bdp-6L, -0x8.483ee0c9834834cp-6L};
}
#ifdef BOOST_HAS_FLOAT128
if constexpr (std::is_same_v) {
return {0x1.ee8dd4748bf14c548b969de58fap-2Q, 0x1.ac4bdd6e3fd70aae9f48d8a63d1bp-1Q, 0x1.cb0bf0b6b7108b79b4bf11d08b16p-3Q, -0x1.0907dc1930690697b13714fd4a15p-3Q};
}
#endif
}
...
template
std::array daubechies_wavelet_filter() {
std::array g;
auto h = daubechies_scaling_filter();
for (size_t i = 0; i < g.size(); i += 2)
{
g(i) = h(g.size() - i - 1);
g(i+1) = -h(g.size() - i - 2);
}
return g;
}
```

Is there a way to specify the filter coefficients only once with the maximum allowable precision and have the compiler analyze it as the user-requested type and save it? `constexpr`

?

Keep the filter coefficients `constexpr`

a reasonable desideratum here? (I'm not even sure if I should do that `p`

a template parameter. , .) If so, note that the scaling filters `constexpr`

but the wavelet filters are not. Is there a way to get around that?

C ++ 17 solutions are acceptable. C ++ 20 solutions are. , , less, but if they can be shown to dramatically improve the code, what is the correct language update?