fxpmath | python library for fractional fixed | Data Manipulation library
kandi X-RAY | fxpmath Summary
kandi X-RAY | fxpmath Summary
A python library for fractional fixed-point (base 2) arithmetic and binary manipulation with Numpy compatibility. visit documentation for more information. See some examples in the examples folder.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Set the value of the word .
- Sum values along axis .
- r Pow .
- Convert a string to a number .
- Compute a function over two variables .
- Evaluate a function over a single variable .
- Compute the polynomial .
- Calculate the size of the given variables .
- Initialize parameters .
- Compute the truediv derivative .
fxpmath Key Features
fxpmath Examples and Code Snippets
y = x.copy() # copy also the value stored
# or
y = x.deepcopy()
# if you want to preserve a value previously stored in `y` and only copy the properties from `x`:
y = y.like(x)
y = x.copy()(-1.25) # where -1.25 y the new value for `y` aft
0.75 + x # add a constant
x - 0.125 # substract a constant
3 * x # multiply by a constant
x / 1.5 # division by a constant
x // 1.5 # floor division by a constant
x % 2 # modulo
x ** 3 # power
y = 3.25 * (x - 0.5) # y
# at instantiation
x = Fxp(3.25, True, 16, 8, rounding='floor')
# after ...
x.rounding = 'trunc'
# or ...
x.rounding = 'around'
x.rounding = 'floor'
x.rounding = 'ceil'
x.rounding = 'fix'
print(x.precision) # print the precision of x
Community Discussions
Trending Discussions on fxpmath
QUESTION
I'm using the fxpmath
library but basic arithmetic doesn't seem to work. Are values getting corrupted or am I using powers that should not be computed?
ANSWER
Answered 2021-Aug-20 at 15:25The documentation says:
The constant is converted into a new Fxp object before math operation, where the Fxp size for the constant operand is defined by x.config.op_input_size in examples above. The default value for op_input_size is 'best' (best enoguh precision to represent the constant value), but it could be used 'same' to force the constant's size equals to Fxp object size (x in the examples).
If you enter x.config.op_input_size
, it prints 'same'
rather than 'best'
. So, try changing the config by entering x.config.op_input_size='best'
.
The code looks something like this:
QUESTION
I need to convert a float64 value into a fixed point <16,15> (16 bit with 15 bit in the fractional part and 1 in the integer part).
I have already read many solutions:
However I have not really understood the "type" I need in my specific case.
To explain this better, I have implemented a code that generates a simple sine wave inside PYNQ (the Xilinx framework based on Python):
...ANSWER
Answered 2021-May-06 at 13:04I suppose that FFT expects ap_fixed<16,15>, where MSB is the sign bit. In your example you have signed samples (because sinusoidal between -1.0 and 1.0), so your casting must be int
(signed int). But if you need a two-complement representation of signed int, it's right if you cast with uint
. In both cases, cast with 16 bits is enough.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fxpmath
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page