from sage.matrix.constructor import matrix
+from sage.misc.cachefunc import cached_method
from mjo.eja.eja_algebra import FiniteDimensionalEJA
from mjo.eja.eja_element import FiniteDimensionalEJAElement
True
"""
- return self.parent().superalgebra()(self.to_matrix())
+ return self.parent().superalgebra_embedding()(self)
jordan_product,
inner_product,
field=field,
+ matrix_space=superalgebra.matrix_space(),
prefix=prefix,
**kwargs)
"""
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)
-
- def matrix_space(self):
- """
- Return the matrix space of this algebra, which is identical to
- that of its superalgebra.
-
- This is correct "by definition," and avoids a mismatch when
- the subalgebra is trivial (with no matrix basis elements to
- infer anything from) and the parent is not.
- """
- return self.superalgebra().matrix_space()
-
-
def superalgebra(self):
"""
Return the superalgebra that this algebra was generated from.
return self._superalgebra
+ @cached_method
+ def superalgebra_embedding(self):
+ r"""
+ Return the embedding from this subalgebra into the superalgebra.
+
+ SETUP::
+
+ sage: from mjo.eja.eja_algebra import HadamardEJA
+
+ EXAMPLES::
+
+ sage: J = HadamardEJA(4)
+ sage: A = J.one().subalgebra_generated_by()
+ sage: iota = A.superalgebra_embedding()
+ sage: iota
+ Linear operator between finite-dimensional Euclidean Jordan algebras represented by the matrix:
+ [1/2]
+ [1/2]
+ [1/2]
+ [1/2]
+ Domain: Euclidean Jordan algebra of dimension 1 over Algebraic Real Field
+ Codomain: Euclidean Jordan algebra of dimension 4 over Algebraic Real Field
+ sage: iota(A.one()) == J.one()
+ True
+
+ """
+ from mjo.eja.eja_operator import FiniteDimensionalEJAOperator
+ mm = self._module_morphism(lambda j: self.superalgebra()(self.monomial(j).to_matrix()),
+ codomain=self.superalgebra())
+ return FiniteDimensionalEJAOperator(self,
+ self.superalgebra(),
+ mm.matrix())
+
+
+
Element = FiniteDimensionalEJASubalgebraElement