]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/eja/euclidean_jordan_algebra.py
eja: fix field arguments, add comment.
[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
50 # Assuming associativity is wrong here, but it works to
51 # temporarily trick the Jordan algebra constructor into using the
52 # multiplication table.
53 A = FiniteDimensionalAlgebra(field,Qs,assume_associative=True)
54 return JordanAlgebra(A)
55
56
57 def eja_ln(dimension, field=QQ):
58 """
59 Return the Jordan algebra corresponding to the Lorenzt "ice cream"
60 cone of the given ``dimension``.
61
62 EXAMPLES:
63
64 This multiplication table can be verified by hand::
65
66 sage: J = eja_ln(4)
67 sage: e0,e1,e2,e3 = J.gens()
68 sage: e0*e0
69 e0
70 sage: e0*e1
71 e1
72 sage: e0*e2
73 e2
74 sage: e0*e3
75 e3
76 sage: e1*e2
77 0
78 sage: e1*e3
79 0
80 sage: e2*e3
81 0
82
83 In one dimension, this is the reals under multiplication::
84
85 sage: J1 = eja_ln(1)
86 sage: J2 = eja_rn(1)
87 sage: J1 == J2
88 True
89
90 """
91 Qs = []
92 id_matrix = identity_matrix(field,dimension)
93 for i in xrange(dimension):
94 ei = id_matrix.column(i)
95 Qi = zero_matrix(field,dimension)
96 Qi.set_row(0, ei)
97 Qi.set_column(0, ei)
98 Qi += diagonal_matrix(dimension, [ei[0]]*dimension)
99 # The addition of the diagonal matrix adds an extra ei[0] in the
100 # upper-left corner of the matrix.
101 Qi[0,0] = Qi[0,0] * ~field(2)
102 Qs.append(Qi)
103
104 # Assuming associativity is wrong here, but it works to
105 # temporarily trick the Jordan algebra constructor into using the
106 # multiplication table.
107 A = FiniteDimensionalAlgebra(field,Qs,assume_associative=True)
108 return JordanAlgebra(A)