SETUP::
- sage: from mjo.eja.eja_algebra import JordanSpinEJA
+ sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
+ ....: random_eja)
EXAMPLES:
True
True
+ TESTS:
+
+ The zero element should never be regular::
+
+ sage: set_random_seed()
+ sage: J = random_eja()
+ sage: J.zero().is_regular()
+ False
+
+ The unit element isn't regular unless the algebra happens to
+ consist of only its scalar multiples::
+
+ sage: set_random_seed()
+ sage: J = random_eja()
+ sage: J.dimension() == 1 or not J.one().is_regular()
+ True
+
"""
return self.degree() == self.parent().rank()
def degree(self):
"""
- Compute the degree of this element the straightforward way
- according to the definition; by appending powers to a list
- and figuring out its dimension (that is, whether or not
- they're linearly dependent).
+ Return the degree of this element, which is defined to be
+ the degree of its minimal polynomial.
+
+ ALGORITHM:
+
+ For now, we skip the messy minimal polynomial computation
+ and instead return the dimension of the vector space spanned
+ by the powers of this element. The latter is a bit more
+ straightforward to compute.
SETUP::
- sage: from mjo.eja.eja_algebra import JordanSpinEJA
+ sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
+ ....: random_eja)
EXAMPLES::
sage: x == x.coefficient(0)*J.one() or x.degree() == 2
True
+ TESTS:
+
+ The zero and unit elements are both of degree one::
+
+ sage: set_random_seed()
+ sage: J = random_eja()
+ sage: J.zero().degree()
+ 1
+ sage: J.one().degree()
+ 1
+
+ Our implementation agrees with the definition::
+
+ sage: set_random_seed()
+ sage: x = random_eja().random_element()
+ sage: x.degree() == x.minimal_polynomial().degree()
+ True
+
"""
return self.span_of_powers().dimension()