from mjo.eja.eja_utils import _mat2vec
class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
- # This is an ugly hack needed to prevent the category framework
- # from implementing a coercion from our base ring (e.g. the
- # rationals) into the algebra. First of all -- such a coercion is
- # nonsense to begin with. But more importantly, it tries to do so
- # in the category of rings, and since our algebras aren't
- # associative they generally won't be rings.
- _no_generic_basering_coercion = True
+
+ def _coerce_map_from_base_ring(self):
+ """
+ Disable the map from the base ring into the algebra.
+
+ Performing a nonsense conversion like this automatically
+ is counterpedagogical. The fallback is to try the usual
+ element constructor, which should also fail.
+
+ SETUP::
+
+ sage: from mjo.eja.eja_algebra import random_eja
+
+ TESTS::
+
+ sage: set_random_seed()
+ sage: J = random_eja()
+ sage: J(1)
+ Traceback (most recent call last):
+ ...
+ ValueError: not a naturally-represented algebra element
+
+ """
+ return None
def __init__(self,
field,
True
"""
+ msg = "not a naturally-represented algebra element"
if elt == 0:
# The superclass implementation of random_element()
# needs to be able to coerce "0" into the algebra.
return self.zero()
+ elif elt in self.base_ring():
+ # Ensure that no base ring -> algebra coercion is performed
+ # by this method. There's some stupidity in sage that would
+ # otherwise propagate to this method; for example, sage thinks
+ # that the integer 3 belongs to the space of 2-by-2 matrices.
+ raise ValueError(msg)
natural_basis = self.natural_basis()
basis_space = natural_basis[0].matrix_space()
if elt not in basis_space:
- raise ValueError("not a naturally-represented algebra element")
+ raise ValueError(msg)
# Thanks for nothing! Matrix spaces aren't vector spaces in
# Sage, so we have to figure out its natural-basis coordinates
SETUP::
- sage: from mjo.eja.eja_algebra import BilinearFormEJA
+ sage: from mjo.eja.eja_algebra import (BilinearFormEJA,
+ ....: JordanSpinEJA)
EXAMPLES: