fpbinary icon indicating copy to clipboard operation
fpbinary copied to clipboard

Vectorized creation of FpBinary Values

Open cdboschen opened this issue 5 months ago • 0 comments

This is not a bug but an enhancement request.

It would be useful if the fpbinary library supported the creation of vectorized FpBinary values directly. I show my work-around below of creating an array of FpBinary values as the fixed point values of a cosine function.

The request is to support numpy arrays for the value parameter in FpBinary, passing in an array of floats or ints and returning a numpy array of FpBinary values.

My current workaround is the folloiwng:

FpBinVec = np.frompyfunc(fpb.FpBinary,4,1) # vectorized FpBinary object my_fp_array = FpBinVect(1, 11, True, np.cos(2pif*t)) # t is an array of time samples

We can then utilize numpy and vector processing on my_fp_array, returning arrays of fpbinary values.

cdboschen avatar Jul 24 '25 14:07 cdboschen