SNEX lookup table float index access error
-
I have this array I want to write/read using a float (in real life using an interpolator), but it only wants an integer index.
I get 2 distinct errors when using a float or an interpolator.static const int S = 128; using Interp = index::lerp<index::normalised<float, index::wrapped<S, false>>>; Interp intL; span<float, S> lut; for(int i = 0; i < lut.size(); i++) { lut[0] = 0.5f; // Ok lut[0.0f] = 0.5f; // ERROR: LookupTableTest:Line 30(19): subscript index must be integer type intL = (float)(i / lut.size()); lut[intL] = 0.5f; // ERROR: LookupTableTest:Line 30(24): Can't assign to target }
I assume the second error is not an index issue but a writing one, so in the end my interpolator seems to work if I am not mistaken...
Also @Christoph-Hart, the doc here doesn't seem complete or up to date, and there're quite some errors and typos all along.
For instance,index::safe
does not exist in thesnex_jit_IndexLibrary
-
@Christoph-Hart Ok so the access from a normalised index works
using NormIdx = index::normalised<float, index::wrapped<S, false>>; NormIdx normIdx; // later... normIdx = (float)(i / lut.size()); lut[normIdx] = 0.5f;
But I soon as an interpolator is added it doesn't compile
-
-
@Christoph-Hart Oh I am so dumb! Of course I cannot set an array value with an interpolated index! It's only a read index... I just got confused between read and write access
-