cppyy_exactreal#

Python wrappers for exact-real powered by cppyy.

Note that pyexactreal offers a better interface to work with exact-real. Use pyexactreal.exactreal if you need to directly manipulate the underlying C++ objects:

>>> from pyexactreal import exactreal  # random output due to deprecation warnings in cppyy
>>> exactreal.Module[exactreal.IntegerRing].make([])
ℤ-Module()
exception pyexactreal.cppyy_exactreal.NotRepresentableError#

Raised when the result of an operation can not be written in this ring.

EXAMPLES:

>>> from pyexactreal import ZZModule, RealNumber
>>> M = ZZModule(RealNumber.random(), RealNumber.random())
>>> M.gen(0) / M.gen(1)
Traceback (most recent call last):
...
pyexactreal.cppyy_exactreal.NotRepresentableError: result is not representable in this parent
pyexactreal.cppyy_exactreal.NumberFieldModule(K, *gens)#

Return the K-module generated by gens.

EXAMPLES:

>>> from pyexactreal import NumberFieldModule, RealNumber, NumberField
>>> K = NumberField("x^2 - 2", "x", "1.4 +/- 1")
>>> NumberFieldModule(K, RealNumber.rational(1), RealNumber.random())
K-Module(1, ℝ(...))
exception pyexactreal.cppyy_exactreal.PrecisionError#

Raised when the result of an operation can not be decided in ball arithmetic.

EXAMPLES:

>>> from pyexactreal import exactreal
>>> import cppyy
>>> a = exactreal.Arb(cppyy.gbl.mpq_class(1, 3), 64); a
[0.333333 +/- 3.34e-7]
>>> a == 1
False
>>> a == a
Traceback (most recent call last):
...
pyexactreal.cppyy_exactreal.PrecisionError: ...
pyexactreal.cppyy_exactreal.QQModule(*gens)#

Return the Q-module generated by gens.

EXAMPLES:

>>> from pyexactreal import QQModule, RealNumber
>>> QQModule(RealNumber.rational(1), RealNumber.random())
ℚ-Module(1, ℝ(...))
class pyexactreal.cppyy_exactreal.Yap(value, lifelines=[])#

Wrap a boost::yap expression with added lifelines to make them compatible with Python memory management.

TESTS:

>>> from pyexactreal import exactreal
>>> a = exactreal.Arb(1)
>>> a += a
>>> a += a
>>> a += a
>>> a += a
>>> a
arithmetic expression
>>> a(64)
16.0000
pyexactreal.cppyy_exactreal.ZZModule(*gens)#

Return the Z-module generated by gens.

EXAMPLES:

>>> from pyexactreal import ZZModule, RealNumber
>>> ZZModule(RealNumber.rational(1), RealNumber.random())
ℤ-Module(1, ℝ(...))
pyexactreal.cppyy_exactreal.add_pythonization(pythonization, namespace, predicate=<function <lambda>>)#

Conditionally enable a pythonization on a namespace.

pyexactreal.cppyy_exactreal.enable_arithmetic(proxy, name)#

Help cppyy discover arithmetic provided by boost::operators.

TESTS:

>>> from pyexactreal import ZZModule, RealNumber
>>> M = ZZModule(RealNumber.rational(1))
>>> x = M.gen(0)
>>> x + x
2
>>> x - x
0
>>> x * x
1
>>> x / x
1
pyexactreal.cppyy_exactreal.enable_yap(proxy, name)#

Make yap templating machinery accessible from cppyy.

TESTS:

>>> from pyexactreal import exactreal
>>> a = exactreal.Arb(1)
>>> b = a + a; b
arithmetic expression
>>> b(64)
2.00000
>>> b += b
>>> b += a
>>> b(64)
5.00000
>>> a += b
>>> a(64)
6.00000
pyexactreal.cppyy_exactreal.makeModule(traits, gens, ring=None)#

Helper to create a module over a traits ring generated by gens.

EXAMPLES:

>>> from pyexactreal import exactreal, RealNumber
>>> import pyexactreal.cppyy_exactreal
>>> pyexactreal.cppyy_exactreal.makeModule(exactreal.IntegerRing, [RealNumber.random()], ring=None)
ℤ-Module(ℝ(...))