]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/eja/eja_subalgebra.py
a774b985ff54a2ceeb01468b5887849a22ef2d65
[sage.d.git] / mjo / eja / eja_subalgebra.py
1 from sage.matrix.constructor import matrix
2
3 from mjo.eja.eja_algebra import FiniteDimensionalEuclideanJordanAlgebra
4 from mjo.eja.eja_element import FiniteDimensionalEuclideanJordanAlgebraElement
5
6
7 class FiniteDimensionalEuclideanJordanElementSubalgebraElement(FiniteDimensionalEuclideanJordanAlgebraElement):
8 """
9 SETUP::
10
11 sage: from mjo.eja.eja_algebra import random_eja
12
13 TESTS::
14
15 The natural representation of an element in the subalgebra is
16 the same as its natural representation in the superalgebra::
17
18 sage: set_random_seed()
19 sage: A = random_eja().random_element().subalgebra_generated_by()
20 sage: y = A.random_element()
21 sage: actual = y.natural_representation()
22 sage: expected = y.superalgebra_element().natural_representation()
23 sage: actual == expected
24 True
25
26 """
27 def __init__(self, A, elt):
28 """
29 SETUP::
30
31 sage: from mjo.eja.eja_algebra import RealSymmetricEJA
32 sage: from mjo.eja.eja_subalgebra import FiniteDimensionalEuclideanJordanElementSubalgebra
33
34 EXAMPLES::
35
36 sage: J = RealSymmetricEJA(3)
37 sage: x = sum( i*J.gens()[i] for i in range(6) )
38 sage: K = FiniteDimensionalEuclideanJordanElementSubalgebra(x)
39 sage: [ K.element_class(K,x^k) for k in range(J.rank()) ]
40 [f0, f1, f2]
41
42 ::
43
44 """
45 if elt in A.superalgebra():
46 # Try to convert a parent algebra element into a
47 # subalgebra element...
48 try:
49 coords = A.vector_space().coordinate_vector(elt.to_vector())
50 elt = A.from_vector(coords).monomial_coefficients()
51 except AttributeError:
52 # Catches a missing method in elt.to_vector()
53 pass
54
55 s = super(FiniteDimensionalEuclideanJordanElementSubalgebraElement,
56 self)
57
58 s.__init__(A, elt)
59
60
61 def superalgebra_element(self):
62 """
63 Return the object in our algebra's superalgebra that corresponds
64 to myself.
65
66 SETUP::
67
68 sage: from mjo.eja.eja_algebra import (RealSymmetricEJA,
69 ....: random_eja)
70
71 EXAMPLES::
72
73 sage: J = RealSymmetricEJA(3)
74 sage: x = sum(J.gens())
75 sage: x
76 e0 + e1 + e2 + e3 + e4 + e5
77 sage: A = x.subalgebra_generated_by()
78 sage: A.element_class(A,x)
79 f1
80 sage: A.element_class(A,x).superalgebra_element()
81 e0 + e1 + e2 + e3 + e4 + e5
82
83 TESTS:
84
85 We can convert back and forth faithfully::
86
87 sage: set_random_seed()
88 sage: J = random_eja()
89 sage: x = J.random_element()
90 sage: A = x.subalgebra_generated_by()
91 sage: A.element_class(A,x).superalgebra_element() == x
92 True
93 sage: y = A.random_element()
94 sage: A.element_class(A,y.superalgebra_element()) == y
95 True
96
97 """
98 return self.parent().superalgebra().linear_combination(
99 zip(self.parent()._superalgebra_basis, self.to_vector()) )
100
101
102
103
104 class FiniteDimensionalEuclideanJordanElementSubalgebra(FiniteDimensionalEuclideanJordanAlgebra):
105 """
106 The subalgebra of an EJA generated by a single element.
107 """
108 def __init__(self, elt):
109 superalgebra = elt.parent()
110
111 # First compute the vector subspace spanned by the powers of
112 # the given element.
113 V = superalgebra.vector_space()
114 superalgebra_basis = [superalgebra.one()]
115 basis_vectors = [superalgebra.one().to_vector()]
116 W = V.span_of_basis(basis_vectors)
117 for exponent in range(1, V.dimension()):
118 new_power = elt**exponent
119 basis_vectors.append( new_power.to_vector() )
120 try:
121 W = V.span_of_basis(basis_vectors)
122 superalgebra_basis.append( new_power )
123 except ValueError:
124 # Vectors weren't independent; bail and keep the
125 # last subspace that worked.
126 break
127
128 # Make the basis hashable for UniqueRepresentation.
129 superalgebra_basis = tuple(superalgebra_basis)
130
131 # Now figure out the entries of the right-multiplication
132 # matrix for the successive basis elements b0, b1,... of
133 # that subspace.
134 field = superalgebra.base_ring()
135 mult_table = []
136 for b_right in superalgebra_basis:
137 b_right_rows = []
138 # The first row of the right-multiplication matrix by
139 # b1 is what we get if we apply that matrix to b1. The
140 # second row of the right multiplication matrix by b1
141 # is what we get when we apply that matrix to b2...
142 #
143 # IMPORTANT: this assumes that all vectors are COLUMN
144 # vectors, unlike our superclass (which uses row vectors).
145 for b_left in superalgebra_basis:
146 # Multiply in the original EJA, but then get the
147 # coordinates from the subalgebra in terms of its
148 # basis.
149 this_row = W.coordinates((b_left*b_right).to_vector())
150 b_right_rows.append(this_row)
151 b_right_matrix = matrix(field, b_right_rows)
152 mult_table.append(b_right_matrix)
153
154 for m in mult_table:
155 m.set_immutable()
156 mult_table = tuple(mult_table)
157
158 # TODO: We'll have to redo this and make it unique again...
159 prefix = 'f'
160
161 # The rank is the highest possible degree of a minimal
162 # polynomial, and is bounded above by the dimension. We know
163 # in this case that there's an element whose minimal
164 # polynomial has the same degree as the space's dimension
165 # (remember how we constructed the space?), so that must be
166 # its rank too.
167 rank = W.dimension()
168
169 category = superalgebra.category().Associative()
170 natural_basis = tuple( b.natural_representation()
171 for b in superalgebra_basis )
172
173 self._superalgebra = superalgebra
174 self._vector_space = W
175 self._superalgebra_basis = superalgebra_basis
176
177
178 fdeja = super(FiniteDimensionalEuclideanJordanElementSubalgebra, self)
179 return fdeja.__init__(field,
180 mult_table,
181 rank,
182 prefix=prefix,
183 category=category,
184 natural_basis=natural_basis)
185
186
187
188 def superalgebra(self):
189 """
190 Return the superalgebra that this algebra was generated from.
191 """
192 return self._superalgebra
193
194
195 def vector_space(self):
196 """
197 SETUP::
198
199 sage: from mjo.eja.eja_algebra import RealSymmetricEJA
200 sage: from mjo.eja.eja_subalgebra import FiniteDimensionalEuclideanJordanElementSubalgebra
201
202 EXAMPLES::
203
204 sage: J = RealSymmetricEJA(3)
205 sage: x = sum( i*J.gens()[i] for i in range(6) )
206 sage: K = FiniteDimensionalEuclideanJordanElementSubalgebra(x)
207 sage: K.vector_space()
208 Vector space of degree 6 and dimension 3 over Rational Field
209 User basis matrix:
210 [ 1 0 0 1 0 1]
211 [ 0 1 2 3 4 5]
212 [ 5 11 14 26 34 45]
213 sage: (x^0).to_vector()
214 (1, 0, 0, 1, 0, 1)
215 sage: (x^1).to_vector()
216 (0, 1, 2, 3, 4, 5)
217 sage: (x^2).to_vector()
218 (5, 11, 14, 26, 34, 45)
219
220 """
221 return self._vector_space
222
223
224 Element = FiniteDimensionalEuclideanJordanElementSubalgebraElement