]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/eja/DESIGN
eja: add a note on debugging to the DESIGN document.
[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 3. When constructing a Cartesian product algebra, we don't know a
52 priori whether or not the result will have matrix-algebra
53 factors. We can figure it out at runtime, but it would be nice if
54 DirectSumEJA always returned the same class. Maybe more
55 importantly, if a Cartesian product has one matrix and one
56 non-matrix factor, then what would its own matrix representation
57 look like? We want to delegate to the factors...
58
59
60 Basis normalization
61 -------------------
62 For performance reasons, we prefer the algebra constructors to
63 orthonormalize their own bases. We _could_ ask the user to do that,
64 but there's a good reason to do it ourselves: if _we_ run
65 Gram-Schmidt, then we can compute/store the matrix that undoes the
66 process. Undoing the change-of-coordinates allows us to perform some
67 computations in the original basis (like the "characteristic
68 polynomial of"), which can be much faster when the original basis
69 contains only rational entries.
70
71 Debugging
72 ---------
73 There are several places in the code where we set check_field=False
74 and check_axioms=False because the theory guarantees that they will be
75 satisfied. Well, you know what they say about theory and practice. The
76 first thing you should do when a problem is discovered it replace all
77 of those with check_field=True and check_axioms=True, and then re-run
78 the test suite.