francof2a / fxpmath

A python library for fractional fixed-point (base 2) arithmetic and binary manipulation with Numpy compatibility.
MIT License
179 stars 21 forks source link

Precision error when numpy.reshape #77

Closed Ethan-lsh closed 7 months ago

Ethan-lsh commented 1 year ago

Hello.

Now I'm writing the code to implement a mvm operation on fixed-point with numpy and fxpmath.

However, when I applied the numpy.reshape at the array made by fxpmath, the fract bits was remaind but the word bits changed.

This is my code.

a = np.array([[0.762, 0.525], [0.345, 0.875]], dtype=complex)
x = Fxp(a, signed=True, n_word=5, n_frac=3)
# fxp-s5/3-complex

y = np.reshape(x, (1, 4))
# fxp-s4/3-complex

In my opinion, this is because that the numpy cannot fully recognize the sign bit.

Please, let me know how I can solve this issue.

Thanks.

francof2a commented 7 months ago

solved in v0.4.9