]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/eja/euclidean_jordan_algebra.py
eja: add examples for eja_rn.
[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_rn(dimension, field=QQ):
11 """
12 Return the Euclidean Jordan Algebra corresponding to the set
13 `R^n` under the Hadamard product.
14
15 EXAMPLES:
16
17 This multiplication table can be verified by hand::
18
19 sage: J = eja_rn(3)
20 sage: e0,e1,e2 = J.gens()
21 sage: e0*e0
22 e0
23 sage: e0*e1
24 0
25 sage: e0*e2
26 0
27 sage: e1*e1
28 e1
29 sage: e1*e2
30 0
31 sage: e2*e2
32 e2
33
34 """
35 # The FiniteDimensionalAlgebra constructor takes a list of
36 # matrices, the ith representing right multiplication by the ith
37 # basis element in the vector space. So if e_1 = (1,0,0), then
38 # right (Hadamard) multiplication of x by e_1 picks out the first
39 # component of x; and likewise for the ith basis element e_i.
40 Qs = [ matrix(field, dimension, dimension, lambda k,j: 1*(k == j == i))
41 for i in xrange(dimension) ]
42 A = FiniteDimensionalAlgebra(QQ,Qs,assume_associative=True)
43 return JordanAlgebra(A)