1 from sage
.matrix
.constructor
import matrix
2 from sage
.misc
.cachefunc
import cached_method
3 from sage
.rings
.all
import QQ
5 from mjo
.eja
.eja_subalgebra
import FiniteDimensionalEJASubalgebra
8 class FiniteDimensionalEJAElementSubalgebra(FiniteDimensionalEJASubalgebra
):
9 def __init__(self
, elt
, **kwargs
):
10 superalgebra
= elt
.parent()
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()) )
19 super().__init
__(superalgebra
,
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
30 self
.rank
.set_cache(self
.dimension())
36 Return the multiplicative identity element of this algebra.
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.
46 sage: from mjo.eja.eja_algebra import (HadamardEJA,
51 sage: J = HadamardEJA(5)
53 e0 + e1 + e2 + e3 + e4
54 sage: x = sum(J.gens())
55 sage: A = x.subalgebra_generated_by(orthonormalize=False)
58 sage: A.one().superalgebra_element()
59 e0 + e1 + e2 + e3 + e4
63 The identity element acts like the identity over the rationals::
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
72 The identity element acts like the identity over the algebraic
73 reals with an orthonormal basis::
75 sage: set_random_seed()
76 sage: x = random_eja().random_element()
77 sage: A = x.subalgebra_generated_by()
78 sage: x = A.random_element()
79 sage: A.one()*x == x and x*A.one() == x
82 The matrix of the unit element's operator is the identity over
85 sage: set_random_seed()
86 sage: x = random_eja(field=QQ,orthonormalize=False).random_element()
87 sage: A = x.subalgebra_generated_by(orthonormalize=False)
88 sage: actual = A.one().operator().matrix()
89 sage: expected = matrix.identity(A.base_ring(), A.dimension())
90 sage: actual == expected
93 The matrix of the unit element's operator is the identity over
94 the algebraic reals with an orthonormal basis::
96 sage: set_random_seed()
97 sage: x = random_eja().random_element()
98 sage: A = x.subalgebra_generated_by()
99 sage: actual = A.one().operator().matrix()
100 sage: expected = matrix.identity(A.base_ring(), A.dimension())
101 sage: actual == expected
105 if self
.dimension() == 0:
108 return self(self
.superalgebra().one())