]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/eja/DESIGN
eja: rename operator_inner_product -> operator_trace inner_product.
[sage.d.git] / mjo / eja / DESIGN
1 Overview
2 --------
3 This is a collection of design notes that should eventually wind up in
4 the documentation. I'm just not sure where they go yet.
5
6 Matrix representations
7 ----------------------
8
9 All algebras have a "matrix representation" of their elements. This is
10 the original, ambient representation of the elements as either column
11 (n-by-1) or square (n-by-n) matrices. For example, the elements of the
12 Jordan spin algebra are column vectors, and the elements of real
13 symmetric matrix algebra are... real symmetric matrices.
14
15 The CombinatorialFreeModule class actually supports such an
16 alternative representation of its generators since it subclasses
17 IndexedGenerators. However, using matrices as the index set turns out
18 to be ugly: printing the generators, and especially printing an
19 algebra element as a sum of said generators comes out wonky, since
20 the matrices require more than one line. For example,
21
22 sage: A = matrix(QQ,[[1,2],[3,4]])
23 sage: B = matrix(QQ,[[5,6],[7,8]])
24 sage: A.set_immutable()
25 sage: B.set_immutable()
26 sage: M = CombinatorialFreeModule(QQ,[A,B],bracket=False,prefix="")
27 sage: 2*M(A) + 3*M(B)
28 2*[1 2]
29 [3 4] + 3*[5 6]
30 [7 8]
31
32 And things only get worse if you leave the prefix in there to
33 distinguish between e.g. the super- and sub-algebra elements
34 corresponding to the same matrix. Thus, we store out own copy
35 of the matrix generators, and have our own set of methods for
36 accessing them.
37
38 Why allow matrix representations for all algebras, rather than just
39 the matrix algebras?
40
41 1. We already have a to_vector() operation that turns an algebra
42 element into a vector whose coordinates live in the algebra's
43 base_ring(). Adding a to_matrix() operation is a natural
44 generalization of that.
45
46 2. Having access to the ambient coordinates in a general way is useful
47 when converting between other coordinate systems. If we have two
48 subalgebras B and C of A, we can use to_matrix() to go from, say,
49 C -> A -> B rather than having to convert from C to B directly.
50
51
52 Fielding questions
53 ------------------
54
55 All Euclidean Jordan algebras are over the real scalar field. This
56 presents a problem: in SageMath, the matrix and vector classes don't
57 support scalar fields that are different than their entries. And three
58 of the simple families of Euclidean Jordan algebras are matrices with
59 non-real entries: the Hermitian comples, quaternion, and octonion
60 algebras.
61
62 At least in the complex and quaternion case, we can "embed" the
63 complex numbers and quaternions into the space of 2-by-2 or 4-by-4
64 matrices. But the octonions are not associative, so they can't be
65 embedded (via a homomorphism) into any real matrix space. So what
66 do we do? Write it ourselves, obviously.
67
68 In contrast to the algebra of real symmetric matrices, the complex,
69 quaternion, and octonion matrix algebras are implemented separately,
70 as a subclasses of CombinatorialFreeModule, to work around that
71 issue. The custom class supports a scalar field that is different than
72 the entries of the matrices. However, this means that we actually have
73 FOUR different types of "matrices" to support:
74
75 (1) Sage vectors
76 (2) Sage matrices
77 (3) Our custom matrices
78 (4) Cartesian products of the (1) through (3)
79
80 The real symmetric matrices could of course be implemented in the same
81 manner as the others; but for the sake of the user interface, we must
82 also support at least the usual SageMath vectors and matrices. Having
83 the real symmetric matrices actually be (SageMath) matrices ensures
84 that we don't accidentally break support for such things.
85
86 Note: this has one less-than-obvious consequence: we have to assume
87 that the user has supplied an entirely-correct basis (with entries in
88 the correct structure). We generally cannot mess witht the entries of
89 his basis, or use them to figure out what (for example) the ambient
90 scalar ring is. None of these are insurmountable obstacles; we just
91 have to be a little careful distinguishing between what's inside the
92 algebra elements and what's outside them.
93
94 Basis normalization
95 -------------------
96 For performance reasons, we prefer the algebra constructor to
97 orthonormalize its own basis. We _could_ ask the user to do that,
98 but there's a good reason to do it ourselves: if _we_ run
99 Gram-Schmidt, then we can compute/store the matrix that undoes the
100 process. Undoing the change-of-coordinates allows us to perform some
101 computations in the original basis (like the "characteristic
102 polynomial of"), which can be much faster when the original basis
103 contains only rational entries.
104
105 Debugging
106 ---------
107 There are several places in the code where we set check_field=False
108 and check_axioms=False because the theory guarantees that they will be
109 satisfied. Well, you know what they say about theory and practice. The
110 first thing you should do when a problem is discovered it replace all
111 of those with check_field=True and check_axioms=True, and then re-run
112 the test suite. The Cartesian product class bypasses its superclass
113 constructor, so any extra axiom/field checks on product algebras must
114 be inserted at debug-time.