For instance, imagine table_min=0, table_max=1, table_size=2. Then if x == 0.5, we would get idx == 1.0 in the current version, whereas it should be idx == 0.5 (in general, idx == x).
Edit: Additionally, I think the behavior on the left and right sides of the lookup table is different. On the left, there is linear extrapolation, on the right, a constant. I'm running my reimplementation rather than the original code but the computation should be the same.
The reason is that lower is first clipped and then upper is computed as clip(lower + 1). This means that for values lower than min_value, we have lower == 0 and upper == 1 whereas for values larger than max_value, we have lower == upper == table_size - 1.
Hi, in FastNEWT, the continuous array index is computed as (code):
I believe the correct version would be
For instance, imagine
table_min=0, table_max=1, table_size=2
. Then ifx == 0.5
, we would getidx == 1.0
in the current version, whereas it should beidx == 0.5
(in general,idx == x
).Edit: Additionally, I think the behavior on the left and right sides of the lookup table is different. On the left, there is linear extrapolation, on the right, a constant. I'm running my reimplementation rather than the original code but the computation should be the same.
The reason is that
lower
is first clipped and thenupper
is computed asclip(lower + 1)
. This means that for values lower thanmin_value
, we havelower == 0
andupper == 1
whereas for values larger thanmax_value
, we havelower == upper == table_size - 1
.