]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: simplify _inner_product_is_associative() code.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 25 Feb 2021 22:39:52 +0000 (17:39 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 25 Feb 2021 22:39:52 +0000 (17:39 -0500)
mjo/eja/eja_algebra.py

index c6a82caa9cf74ba78d44fe0db88668805d973e44..ad6cde724a0d986e92a3c31a2de8ca0baed9563f 100644 (file)
@@ -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