From: Michael Orlitzky Date: Thu, 25 Feb 2021 22:39:52 +0000 (-0500) Subject: eja: simplify _inner_product_is_associative() code. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=2c0c1339dda541cf9aee33b9becd03e901841499;p=sage.d.git eja: simplify _inner_product_is_associative() code. --- diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index c6a82ca..ad6cde7 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -448,11 +448,14 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): this algebra was constructed with ``check_axioms=False`` and passed an invalid Jordan or inner-product. """ + R = self.base_ring() - # Used to check whether or not something is zero in an inexact - # ring. This number is sufficient to allow the construction of - # QuaternionHermitianEJA(2, field=RDF) with check_axioms=True. - epsilon = 1e-16 + # Used to check whether or not something is zero. + epsilon = R.zero() + if not R.is_exact(): + # This choice is sufficient to allow the construction of + # QuaternionHermitianEJA(2, field=RDF) with check_axioms=True. + epsilon = 1e-16 for i in range(self.dimension()): for j in range(self.dimension()): @@ -462,12 +465,8 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): z = self.gens()[k] diff = (x*y).inner_product(z) - x.inner_product(y*z) - if self.base_ring().is_exact(): - if diff != 0: - return False - else: - if diff.abs() > epsilon: - return False + if diff.abs() > epsilon: + return False return True