X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=sidebyside;f=mjo%2Feja%2Feja_algebra.py;h=06f6f531ac46305da59ec2b4290ba808602cea50;hb=0fd07263cc543e345f3cd7668938f8a0de70641f;hp=580c923c37a7c00ed492272161eec70ced95c2de;hpb=ce4c7e206125cd399239698d26f951a4aac073f2;p=sage.d.git diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 580c923..06f6f53 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -12,7 +12,7 @@ from sage.matrix.constructor import matrix from sage.misc.cachefunc import cached_method from sage.misc.prandom import choice from sage.misc.table import table -from sage.modules.free_module import VectorSpace +from sage.modules.free_module import FreeModule, VectorSpace from sage.rings.integer_ring import ZZ from sage.rings.number_field.number_field import QuadraticField from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing @@ -207,8 +207,13 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): determinant). """ z = self._a_regular_element() - V = self.vector_space() - V1 = V.span_of_basis( (z**k).to_vector() for k in range(self.rank()) ) + # Don't use the parent vector space directly here in case this + # happens to be a subalgebra. In that case, we would be e.g. + # two-dimensional but span_of_basis() would expect three + # coordinates. + V = VectorSpace(self.base_ring(), self.vector_space().dimension()) + basis = [ (z**k).to_vector() for k in range(self.rank()) ] + V1 = V.span_of_basis( basis ) b = (V1.basis() + V1.complement().basis()) return V.span_of_basis(b) @@ -263,7 +268,13 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): # have multivatiate polynomial entries. names = tuple('X' + str(i) for i in range(1,n+1)) R = PolynomialRing(self.base_ring(), names) - V = self.vector_space().change_ring(R) + + # Using change_ring() on the parent's vector space doesn't work + # here because, in a subalgebra, that vector space has a basis + # and change_ring() tries to bring the basis along with it. And + # that doesn't work unless the new ring is a PID, which it usually + # won't be. + V = FreeModule(R,n) # Now let x = (X1,X2,...,Xn) be the vector whose entries are # indeterminates... @@ -404,6 +415,29 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): return x.trace_inner_product(y) + def is_trivial(self): + """ + Return whether or not this algebra is trivial. + + A trivial algebra contains only the zero element. + + SETUP:: + + sage: from mjo.eja.eja_algebra import ComplexHermitianEJA + + EXAMPLES:: + + sage: J = ComplexHermitianEJA(3) + sage: J.is_trivial() + False + sage: A = J.zero().subalgebra_generated_by() + sage: A.is_trivial() + True + + """ + return self.dimension() == 0 + + def multiplication_table(self): """ Return a visual representation of this algebra's multiplication @@ -546,6 +580,15 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): return self.linear_combination(zip(self.gens(), coeffs)) + def random_element(self): + # Temporary workaround for https://trac.sagemath.org/ticket/28327 + if self.is_trivial(): + return self.zero() + else: + s = super(FiniteDimensionalEuclideanJordanAlgebra, self) + return s.random_element() + + def rank(self): """ Return the rank of this EJA.