The matrix representation of an element in the subalgebra is
the same as its matrix representation in the superalgebra::
- sage: set_random_seed()
sage: x = random_eja(field=QQ,orthonormalize=False).random_element()
sage: A = x.subalgebra_generated_by(orthonormalize=False)
sage: y = A.random_element()
works like it does in the superalgebra, even if we orthonormalize
our basis::
- sage: set_random_seed()
- sage: x = random_eja(field=AA).random_element()
- sage: A = x.subalgebra_generated_by(orthonormalize=True)
- sage: y = A.random_element()
- sage: y.operator()(A.one()) == y
+ sage: x = random_eja(field=AA).random_element() # long time
+ sage: A = x.subalgebra_generated_by(orthonormalize=True) # long time
+ sage: y = A.random_element() # long time
+ sage: y.operator()(A.one()) == y # long time
True
"""
We can convert back and forth faithfully::
- sage: set_random_seed()
sage: J = random_eja(field=QQ, orthonormalize=False)
sage: x = J.random_element()
sage: A = x.subalgebra_generated_by(orthonormalize=False)
"""
if elt in self.superalgebra():
- return super()._element_constructor_(elt.to_matrix())
+ # If the subalgebra is trivial, its _matrix_span will be empty
+ # but we still want to be able convert the superalgebra's zero()
+ # element into the subalgebra's zero() element. There's no great
+ # workaround for this because sage checks that your basis is
+ # linearly-independent everywhere, so we can't just give it a
+ # basis consisting of the zero element.
+ m = elt.to_matrix()
+ if self.is_trivial() and m.is_zero():
+ return self.zero()
+ else:
+ return super()._element_constructor_(m)
else:
return super()._element_constructor_(elt)
r"""
Return the embedding from this subalgebra into the superalgebra.
+ SETUP::
+
+ sage: from mjo.eja.eja_algebra import HadamardEJA
+
EXAMPLES::
sage: J = HadamardEJA(4)