]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/eja/euclidean_jordan_algebra.py
eja: add eja_minimal_polynomial() function.
[sage.d.git] / mjo / eja / euclidean_jordan_algebra.py
1 """
2 Euclidean Jordan Algebras. These are formally-real Jordan Algebras;
3 specifically those where u^2 + v^2 = 0 implies that u = v = 0. They
4 are used in optimization, and have some additional nice methods beyond
5 what can be supported in a general Jordan Algebra.
6 """
7
8 from sage.all import *
9
10 def eja_minimal_polynomial(x):
11 """
12 Return the minimal polynomial of ``x`` in its parent EJA
13 """
14 return x._x.matrix().minimal_polynomial()
15
16
17 def eja_rn(dimension, field=QQ):
18 """
19 Return the Euclidean Jordan Algebra corresponding to the set
20 `R^n` under the Hadamard product.
21
22 EXAMPLES:
23
24 This multiplication table can be verified by hand::
25
26 sage: J = eja_rn(3)
27 sage: e0,e1,e2 = J.gens()
28 sage: e0*e0
29 e0
30 sage: e0*e1
31 0
32 sage: e0*e2
33 0
34 sage: e1*e1
35 e1
36 sage: e1*e2
37 0
38 sage: e2*e2
39 e2
40
41 """
42 # The FiniteDimensionalAlgebra constructor takes a list of
43 # matrices, the ith representing right multiplication by the ith
44 # basis element in the vector space. So if e_1 = (1,0,0), then
45 # right (Hadamard) multiplication of x by e_1 picks out the first
46 # component of x; and likewise for the ith basis element e_i.
47 Qs = [ matrix(field, dimension, dimension, lambda k,j: 1*(k == j == i))
48 for i in xrange(dimension) ]
49 A = FiniteDimensionalAlgebra(QQ,Qs,assume_associative=True)
50 return JordanAlgebra(A)
51
52
53 def eja_ln(dimension, field=QQ):
54 """
55 Return the Jordan algebra corresponding to the Lorenzt "ice cream"
56 cone of the given ``dimension``.
57
58 EXAMPLES:
59
60 This multiplication table can be verified by hand::
61
62 sage: J = eja_ln(4)
63 sage: e0,e1,e2,e3 = J.gens()
64 sage: e0*e0
65 e0
66 sage: e0*e1
67 e1
68 sage: e0*e2
69 e2
70 sage: e0*e3
71 e3
72 sage: e1*e2
73 0
74 sage: e1*e3
75 0
76 sage: e2*e3
77 0
78
79 In one dimension, this is the reals under multiplication::
80
81 sage: J1 = eja_ln(1)
82 sage: J2 = eja_rn(1)
83 sage: J1 == J2
84 True
85
86 """
87 Qs = []
88 id_matrix = identity_matrix(field,dimension)
89 for i in xrange(dimension):
90 ei = id_matrix.column(i)
91 Qi = zero_matrix(field,dimension)
92 Qi.set_row(0, ei)
93 Qi.set_column(0, ei)
94 Qi += diagonal_matrix(dimension, [ei[0]]*dimension)
95 # The addition of the diagonal matrix adds an extra ei[0] in the
96 # upper-left corner of the matrix.
97 Qi[0,0] = Qi[0,0] * ~field(2)
98 Qs.append(Qi)
99
100 A = FiniteDimensionalAlgebra(QQ,Qs,assume_associative=True)
101 return JordanAlgebra(A)