funclut¶
Implements a simple read-only lookup table for arbitrary function on floating point numbers.
-
funclut(x: Fixpnumber, *, f, precision=len(x), dtype=None) → dtype¶ Creates a lookup table for a function
fthat given an inputxin a fixed point format, outputsf(x)also in a fixed point format. The output format can be set either via theprecisionparameter or thedtypeparameter. Ifdtypeparameter is set, than it is used verbatim as the output type, otherwise theprecisionparameter determines the width of the output type in the number of bits.drv(t=Fixp[3, 16], seq=[-pi / 6, pi / 6, pi / 4, pi / 2]) \ | funclut(f=sin) \ | check(ref=[sin(-pi / 6), sin(pi / 6), sin(pi / 4), sin(pi / 2)], cmp=lambda x, y: abs(x - y) <= 2)