mixle.engines.arithmetic module¶
Backend-dispatched arithmetic helpers used by mixle classes.
Array operations dispatch on their arguments’ engine (engine_of); scalar constants have no
arguments to dispatch on, so they resolve from the active engine instead – NUMPY_ENGINE by
default (plain floats, the historical behaviour). Select a different one to make the constants come
from it, e.g. the symbolic engine, so that pi stays a symbolic pi and half an exact 1/2
instead of collapsing to floats during exact arithmetic:
import mixle.engines.arithmetic as arith
with arith.using_engine("symbolic"):
arith.pi # SymbolicExpression "pi", not 3.141592...
This is the extension point for letting users control the arithmetic backend without switching mixle to a
full computer-algebra system. maxint / maxrandint / eps are implementation limits and
tolerances (not mathematical constants), so they stay engine-independent.
- constant(value)[source]
Wrap
valuein the active engine’s scalar representation (identity for numeric engines).
- get_default_engine()[source]
Return the engine that supplies scalar constants and the operation-dispatch default.
- Return type:
ComputeEngine