Comparison¶
Comparison matrix¶
Library |
APyTypes |
||||||||
---|---|---|---|---|---|---|---|---|---|
Custom fixed-point formats |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes [2] |
Yes |
Yes |
Yes |
Custom floating-point formats |
Yes |
No |
No |
No |
No |
No |
Yes |
No |
No |
Maximum wordlength [6] |
None |
53/None [1] |
None |
None |
None |
64 [2] |
53 [3] |
53 [4] |
None |
Resizing of fixed-point results |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes [2] |
Yes [3] |
Yes [4] |
No |
Arrays |
Yes |
Yes |
No |
No [5] |
Yes |
Yes |
Yes [3] |
Yes [4] |
No |
Matrix multiplication ( |
Yes |
No |
N/A |
N/A |
No |
No |
Yes [3] |
Yes [4] |
N/A |
Written in |
C++/Python |
Python |
Python |
C/Python |
Python |
Python |
Python [3] |
Python [4] |
Python |
Footnotes
Library |
APyTypes |
||||||
---|---|---|---|---|---|---|---|
Custom fixed-point formats |
Yes |
No |
No |
No |
Yes [9] |
No |
No |
Custom floating-point formats |
Yes |
Yes |
Yes |
Yes |
Yes [9] |
Yes |
Yes [10] |
Binary representation of number [11] |
Yes |
No |
No |
No |
No |
Yes |
Yes |
Maximum wordlength |
32 bits for exponent, 64 bits for mantissa [12] |
None |
None |
None |
Yes [9] |
18 bits for exponent, none for mantissa |
Yes [10] |
Stochastic rounding |
Yes |
No |
No |
No |
Yes |
No |
Yes [10] |
Arrays |
Yes |
No |
No |
Yes |
Yes [9] |
No |
Yes [10] |
Matrix multiplication ( |
Yes |
N/A |
N/A |
Yes |
Yes [9] |
N/A |
Yes [10] |
Written in |
C++/Python |
C/Python |
C/Python |
Python [13] |
Python [9] |
Python |
Python [10] |
Footnotes
bigfloat
is a Python wrapper around the GNU MPFR library.
gmpy2
is a Python wrapper around the GNU MPFR and GNU MPC libraries.
pychop
is essentially a package to simply quantize floating-point NumPy, PyTorch, and JAX-arrays to a given fixed-point or floating-point representation. Computation still happens at the precision of the underlying array.
gfloat
is a package for encoding/decoding floating-point numbers. Floating-point NumPy, PyTorch, and JAX-arrays are quantized to a given floating-point representation, and computation still happens at the precision of the underlying array.
This means that it is possible to get a binary representation for comparison with, e.g., a hardware implementation.
This is a design choice since apytypes
is aimed at simulating shorter custom formats. However, there is unlimited word length support for fixed-point values which can, if deemed suitable at a later time, be used for floating-point as well.
mpmath
can use gmpy
as a backend to do faster arithmetic, but uses Python integers by default.
Performance Comparison¶
This benchmark compares relevant fixed-point libraries from the list above. It is updated every documentation build and may vary over time as the code is further optimized.


Feature Comparison¶
