]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/eja/euclidean_jordan_algebra.py
eja: begin draft implementation of euclidean jordan algebras.
[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 # The FiniteDimensionalAlgebra constructor takes a list of
16 # matrices, the ith representing right multiplication by the ith
17 # basis element in the vector space. So if e_1 = (1,0,0), then
18 # right (Hadamard) multiplication of x by e_1 picks out the first
19 # component of x; and likewise for the ith basis element e_i.
20 Qs = [ matrix(field, dimension, dimension, lambda k,j: 1*(k == j == i))
21 for i in xrange(dimension) ]
22 A = FiniteDimensionalAlgebra(QQ,Qs,assume_associative=True)
23 return JordanAlgebra(A)