The cdd.gmp moduleΒΆ
This module works just the same way like cdd.
The only difference is that all numbers are represented by Fraction
instead of float, and all arithmetic is exact.
Warning
Passing a float will result in a AttributeError:
>>> cdd.gmp.matrix_from_array([[1.12]])
Traceback (most recent call last):
...
AttributeError: 'float' object has no attribute 'numerator'
If the float represents a fraction, you must pass it as a fraction explicitly:
>>> cdd.gmp.matrix_from_array([[Fraction(112, 100)]]).array
[[Fraction(28, 25)]]
If you really must use a float as a fraction,
pass it explicitly to the Fraction constructor:
>>> cdd.gmp.matrix_from_array([[Fraction(1.12)]]).array
[[Fraction(1261007895663739, 1125899906842624)]]
As you can see from the output above, for typical use cases, you will not want to do this.