1 from sage
.matrix
.constructor
import matrix
2 from sage
.misc
.cachefunc
import cached_method
4 from mjo
.eja
.eja_algebra
import FiniteDimensionalEJA
5 from mjo
.eja
.eja_element
import FiniteDimensionalEJAElement
7 class FiniteDimensionalEJASubalgebraElement(FiniteDimensionalEJAElement
):
11 sage: from mjo.eja.eja_algebra import random_eja
15 The matrix representation of an element in the subalgebra is
16 the same as its matrix representation in the superalgebra::
18 sage: x = random_eja(field=QQ,orthonormalize=False).random_element()
19 sage: A = x.subalgebra_generated_by(orthonormalize=False)
20 sage: y = A.random_element()
21 sage: actual = y.to_matrix()
22 sage: expected = y.superalgebra_element().to_matrix()
23 sage: actual == expected
26 The left-multiplication-by operator for elements in the subalgebra
27 works like it does in the superalgebra, even if we orthonormalize
30 sage: x = random_eja(field=AA).random_element() # long time
31 sage: A = x.subalgebra_generated_by(orthonormalize=True) # long time
32 sage: y = A.random_element() # long time
33 sage: y.operator()(A.one()) == y # long time
38 def superalgebra_element(self
):
40 Return the object in our algebra's superalgebra that corresponds
45 sage: from mjo.eja.eja_algebra import (RealSymmetricEJA,
50 sage: J = RealSymmetricEJA(3)
51 sage: x = sum(J.gens())
53 b0 + b1 + b2 + b3 + b4 + b5
54 sage: A = x.subalgebra_generated_by(orthonormalize=False)
57 sage: A(x).superalgebra_element()
58 b0 + b1 + b2 + b3 + b4 + b5
59 sage: y = sum(A.gens())
62 sage: B = y.subalgebra_generated_by(orthonormalize=False)
65 sage: B(y).superalgebra_element()
70 We can convert back and forth faithfully::
72 sage: J = random_eja(field=QQ, orthonormalize=False)
73 sage: x = J.random_element()
74 sage: A = x.subalgebra_generated_by(orthonormalize=False)
75 sage: A(x).superalgebra_element() == x
77 sage: y = A.random_element()
78 sage: A(y.superalgebra_element()) == y
80 sage: B = y.subalgebra_generated_by(orthonormalize=False)
81 sage: B(y).superalgebra_element() == y
85 return self
.parent().superalgebra_embedding()(self
)
90 class FiniteDimensionalEJASubalgebra(FiniteDimensionalEJA
):
92 A subalgebra of an EJA with a given basis.
96 sage: from mjo.eja.eja_algebra import (ComplexHermitianEJA,
98 ....: RealSymmetricEJA)
99 sage: from mjo.eja.eja_subalgebra import FiniteDimensionalEJASubalgebra
103 The following Peirce subalgebras of the 2-by-2 real symmetric
104 matrices do not contain the superalgebra's identity element::
106 sage: J = RealSymmetricEJA(2)
107 sage: E11 = matrix(AA, [ [1,0],
109 sage: E22 = matrix(AA, [ [0,0],
111 sage: K1 = FiniteDimensionalEJASubalgebra(J, (J(E11),), associative=True)
112 sage: K1.one().to_matrix()
115 sage: K2 = FiniteDimensionalEJASubalgebra(J, (J(E22),), associative=True)
116 sage: K2.one().to_matrix()
122 Ensure that our generator names don't conflict with the
125 sage: J = JordanSpinEJA(3)
126 sage: J.one().subalgebra_generated_by().gens()
128 sage: J = JordanSpinEJA(3, prefix='f')
129 sage: J.one().subalgebra_generated_by().gens()
131 sage: J = JordanSpinEJA(3, prefix='a')
132 sage: J.one().subalgebra_generated_by().gens()
135 Ensure that we can find subalgebras of subalgebras::
137 sage: A = ComplexHermitianEJA(3).one().subalgebra_generated_by()
138 sage: B = A.one().subalgebra_generated_by()
142 def __init__(self
, superalgebra
, basis
, **kwargs
):
143 self
._superalgebra
= superalgebra
144 V
= self
._superalgebra
.vector_space()
145 field
= self
._superalgebra
.base_ring()
147 # A half-assed attempt to ensure that we don't collide with
148 # the superalgebra's prefix (ignoring the fact that there
149 # could be super-superelgrbas in scope). If possible, we
150 # try to "increment" the parent algebra's prefix, although
151 # this idea goes out the window fast because some prefixen
153 prefixen
= ["b","c","d","e","f","g","h","l","m"]
155 prefix
= prefixen
[prefixen
.index(self
._superalgebra
.prefix()) + 1]
159 # The superalgebra constructor expects these to be in original matrix
160 # form, not algebra-element form.
161 matrix_basis
= tuple( b
.to_matrix() for b
in basis
)
162 def jordan_product(x
,y
):
163 return (self
._superalgebra
(x
)*self
._superalgebra
(y
)).to_matrix()
165 def inner_product(x
,y
):
166 return self
._superalgebra
(x
).inner_product(self
._superalgebra
(y
))
168 super().__init
__(matrix_basis
,
172 matrix_space
=superalgebra
.matrix_space(),
178 def _element_constructor_(self
, elt
):
180 Construct an element of this subalgebra from the given one.
181 The only valid arguments are elements of the parent algebra
182 that happen to live in this subalgebra.
186 sage: from mjo.eja.eja_algebra import RealSymmetricEJA
187 sage: from mjo.eja.eja_subalgebra import FiniteDimensionalEJASubalgebra
191 sage: J = RealSymmetricEJA(3)
192 sage: X = matrix(AA, [ [0,0,1],
196 sage: basis = ( x, x^2 ) # x^2 is the identity matrix
197 sage: K = FiniteDimensionalEJASubalgebra(J,
199 ....: associative=True,
200 ....: orthonormalize=False)
209 if elt
in self
.superalgebra():
210 # If the subalgebra is trivial, its _matrix_span will be empty
211 # but we still want to be able convert the superalgebra's zero()
212 # element into the subalgebra's zero() element. There's no great
213 # workaround for this because sage checks that your basis is
214 # linearly-independent everywhere, so we can't just give it a
215 # basis consisting of the zero element.
217 if self
.is_trivial() and m
.is_zero():
220 return super()._element
_constructor
_(m
)
222 return super()._element
_constructor
_(elt
)
225 def superalgebra(self
):
227 Return the superalgebra that this algebra was generated from.
229 return self
._superalgebra
233 def superalgebra_embedding(self
):
235 Return the embedding from this subalgebra into the superalgebra.
239 sage: from mjo.eja.eja_algebra import HadamardEJA
243 sage: J = HadamardEJA(4)
244 sage: A = J.one().subalgebra_generated_by()
245 sage: iota = A.superalgebra_embedding()
247 Linear operator between finite-dimensional Euclidean Jordan algebras represented by the matrix:
252 Domain: Euclidean Jordan algebra of dimension 1 over Algebraic Real Field
253 Codomain: Euclidean Jordan algebra of dimension 4 over Algebraic Real Field
254 sage: iota(A.one()) == J.one()
258 from mjo
.eja
.eja_operator
import FiniteDimensionalEJAOperator
259 mm
= self
._module
_morphism
(lambda j
: self
.superalgebra()(self
.monomial(j
).to_matrix()),
260 codomain
=self
.superalgebra())
261 return FiniteDimensionalEJAOperator(self
,
267 Element
= FiniteDimensionalEJASubalgebraElement