]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/eja/eja_element_subalgebra.py
ee8e0c67db2773537aefc04d82ee58b7a0b4cca0
[sage.d.git] / mjo / eja / eja_element_subalgebra.py
1 from sage.matrix.constructor import matrix
2 from sage.misc.cachefunc import cached_method
3 from sage.rings.all import QQ
4
5 from mjo.eja.eja_subalgebra import FiniteDimensionalEJASubalgebra
6
7
8 class FiniteDimensionalEJAElementSubalgebra(FiniteDimensionalEJASubalgebra):
9 def __init__(self, elt, orthonormalize=True, **kwargs):
10 superalgebra = elt.parent()
11
12 # TODO: going up to the superalgebra dimension here is
13 # overkill. We should append p vectors as rows to a matrix
14 # and continually rref() it until the rank stops going
15 # up. When n=10 but the dimension of the algebra is 1, that
16 # can save a shitload of time (especially over AA).
17 powers = tuple( elt**k for k in range(elt.degree()) )
18
19 super().__init__(superalgebra,
20 powers,
21 associative=True,
22 **kwargs)
23
24 # The rank is the highest possible degree of a minimal
25 # polynomial, and is bounded above by the dimension. We know
26 # in this case that there's an element whose minimal
27 # polynomial has the same degree as the space's dimension
28 # (remember how we constructed the space?), so that must be
29 # its rank too.
30 self.rank.set_cache(self.dimension())
31
32
33 @cached_method
34 def one(self):
35 """
36 Return the multiplicative identity element of this algebra.
37
38 The superclass method computes the identity element, which is
39 beyond overkill in this case: the superalgebra identity
40 restricted to this algebra is its identity. Note that we can't
41 count on the first basis element being the identity -- it might
42 have been scaled if we orthonormalized the basis.
43
44 SETUP::
45
46 sage: from mjo.eja.eja_algebra import (HadamardEJA,
47 ....: random_eja)
48
49 EXAMPLES::
50
51 sage: J = HadamardEJA(5)
52 sage: J.one()
53 e0 + e1 + e2 + e3 + e4
54 sage: x = sum(J.gens())
55 sage: A = x.subalgebra_generated_by()
56 sage: A.one()
57 f0
58 sage: A.one().superalgebra_element()
59 e0 + e1 + e2 + e3 + e4
60
61 TESTS:
62
63 The identity element acts like the identity over the rationals::
64
65 sage: set_random_seed()
66 sage: x = random_eja(field=QQ,orthonormalize=False).random_element()
67 sage: A = x.subalgebra_generated_by()
68 sage: x = A.random_element()
69 sage: A.one()*x == x and x*A.one() == x
70 True
71
72 The identity element acts like the identity over the algebraic
73 reals with an orthonormal basis::
74
75 sage: set_random_seed()
76 sage: x = random_eja().random_element()
77 sage: A = x.subalgebra_generated_by(orthonormalize_basis=True)
78 sage: x = A.random_element()
79 sage: A.one()*x == x and x*A.one() == x
80 True
81
82 The matrix of the unit element's operator is the identity over
83 the rationals::
84
85 sage: set_random_seed()
86 sage: x = random_eja(field=QQ,orthonormalize=False).random_element()
87 sage: A = x.subalgebra_generated_by()
88 sage: actual = A.one().operator().matrix()
89 sage: expected = matrix.identity(A.base_ring(), A.dimension())
90 sage: actual == expected
91 True
92
93 The matrix of the unit element's operator is the identity over
94 the algebraic reals with an orthonormal basis::
95
96 sage: set_random_seed()
97 sage: x = random_eja().random_element()
98 sage: A = x.subalgebra_generated_by(orthonormalize_basis=True)
99 sage: actual = A.one().operator().matrix()
100 sage: expected = matrix.identity(A.base_ring(), A.dimension())
101 sage: actual == expected
102 True
103
104 """
105 if self.dimension() == 0:
106 return self.zero()
107
108 return self(self.superalgebra().one())
109