mirror of https://github.com/ecmwf/eccodes.git
Fix index in IbmTable
This commit is contained in:
parent
aee89904a8
commit
00cc6dd250
|
@ -48,21 +48,23 @@ The vmin and vmax boundaries are defined as:
|
|||
struct IbmTable {
|
||||
private:
|
||||
using ValueType = double;
|
||||
static constexpr uint8_t TABLESIZE = 128;
|
||||
static constexpr int TABLESIZE = 128;
|
||||
static constexpr uint32_t mantissa_min = 0x100000;
|
||||
static constexpr uint32_t mantissa_max = 0xffffff;
|
||||
|
||||
public:
|
||||
static constexpr std::array<ValueType, TABLESIZE> e = []() {
|
||||
std::array<ValueType, TABLESIZE> multiplier{};
|
||||
for (uint8_t i = 1; i < TABLESIZE; ++i) {
|
||||
multiplier[0] = 0;
|
||||
for (int i = 0; i < TABLESIZE; ++i) {
|
||||
multiplier[i] = codes_power<ValueType>(i - 70, 16);
|
||||
}
|
||||
return multiplier;
|
||||
}();
|
||||
static constexpr std::array<ValueType, TABLESIZE> v = []() {
|
||||
std::array<ValueType, TABLESIZE> values{};
|
||||
for (uint8_t i = 0; i < TABLESIZE; ++i) {
|
||||
values[0] = 0;
|
||||
for (int i = 0; i < TABLESIZE; ++i) {
|
||||
values[i] = e[i] * mantissa_min;
|
||||
}
|
||||
return values;
|
||||
|
|
|
@ -35,6 +35,7 @@ The table layout is as follows:
|
|||
+-------+----------------+------------------------+
|
||||
| idx (i) | multiplier (e) | value (v = mmin * e) |
|
||||
+-------+----------------+------------------------+
|
||||
| 0 | 0 | 0 |
|
||||
| 1 | 2^(-149) | 0x800000 * 2^(-149) |
|
||||
| 2 | 2^(-148) | 0x800000 * 2^(-148) |
|
||||
| ... | ... | ... |
|
||||
|
@ -52,21 +53,23 @@ template <typename ValueType>
|
|||
struct IeeeTable {
|
||||
private:
|
||||
static_assert(std::is_floating_point<ValueType>::value, "ValueType must be a floating point type");
|
||||
static constexpr uint8_t TABLESIZE = 255;
|
||||
static constexpr int TABLESIZE = 255;
|
||||
static constexpr uint32_t mantissa_min = 0x800000;
|
||||
static constexpr uint32_t mantissa_max = 0xffffff;
|
||||
|
||||
public:
|
||||
static constexpr std::array<ValueType, TABLESIZE> e = []() {
|
||||
std::array<ValueType, TABLESIZE> multiplier{};
|
||||
for (uint8_t i = 1; i < TABLESIZE; ++i) {
|
||||
multiplier[0] = 0;
|
||||
for (int i = 1; i < TABLESIZE; ++i) {
|
||||
multiplier[i] = codes_power<ValueType>(i - 150, 2);
|
||||
}
|
||||
return multiplier;
|
||||
}();
|
||||
static constexpr std::array<ValueType, TABLESIZE> v = []() {
|
||||
std::array<ValueType, TABLESIZE> values{};
|
||||
for (uint8_t i = 1; i < TABLESIZE; ++i) {
|
||||
values[0] = 0;
|
||||
for (int i = 1; i < TABLESIZE; ++i) {
|
||||
values[i] = e[i] * mantissa_min;
|
||||
}
|
||||
return values;
|
||||
|
|
Loading…
Reference in New Issue