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
f
that given an inputx
in a fixed point format, outputsf(x)
also in a fixed point format. The output format can be set either via theprecision
parameter or thedtype
parameter. Ifdtype
parameter is set, than it is used verbatim as the output type, otherwise theprecision
parameter 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)