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.
8 from sage
.structure
.unique_representation
import UniqueRepresentation
9 from sage
.algebras
.finite_dimensional_algebras
.finite_dimensional_algebra
import FiniteDimensionalAlgebra
11 class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra
):
13 def __classcall__(cls
, field
, mult_table
, names
='e', category
=None):
14 fda
= super(FiniteDimensionalEuclideanJordanAlgebra
, cls
)
15 return fda
.__classcall
_private
__(cls
,
21 def __init__(self
, field
, mult_table
, names
='e', category
=None):
22 fda
= super(FiniteDimensionalEuclideanJordanAlgebra
, self
)
23 fda
.__init
__(field
, mult_table
, names
, category
)
28 Return a string representation of ``self``.
30 return "Euclidean Jordan algebra of degree {} over {}".format(self
.degree(), self
.base_ring())
34 def eja_rn(dimension
, field
=QQ
):
36 Return the Euclidean Jordan Algebra corresponding to the set
37 `R^n` under the Hadamard product.
41 This multiplication table can be verified by hand::
44 sage: e0,e1,e2 = J.gens()
59 # The FiniteDimensionalAlgebra constructor takes a list of
60 # matrices, the ith representing right multiplication by the ith
61 # basis element in the vector space. So if e_1 = (1,0,0), then
62 # right (Hadamard) multiplication of x by e_1 picks out the first
63 # component of x; and likewise for the ith basis element e_i.
64 Qs
= [ matrix(field
, dimension
, dimension
, lambda k
,j
: 1*(k
== j
== i
))
65 for i
in xrange(dimension
) ]
67 # Assuming associativity is wrong here, but it works to
68 # temporarily trick the Jordan algebra constructor into using the
69 # multiplication table.
70 return FiniteDimensionalEuclideanJordanAlgebra(field
,Qs
)
73 def eja_ln(dimension
, field
=QQ
):
75 Return the Jordan algebra corresponding to the Lorentz "ice cream"
76 cone of the given ``dimension``.
80 This multiplication table can be verified by hand::
83 sage: e0,e1,e2,e3 = J.gens()
99 In one dimension, this is the reals under multiplication::
108 id_matrix
= identity_matrix(field
,dimension
)
109 for i
in xrange(dimension
):
110 ei
= id_matrix
.column(i
)
111 Qi
= zero_matrix(field
,dimension
)
114 Qi
+= diagonal_matrix(dimension
, [ei
[0]]*dimension
)
115 # The addition of the diagonal matrix adds an extra ei[0] in the
116 # upper-left corner of the matrix.
117 Qi
[0,0] = Qi
[0,0] * ~
field(2)
120 return FiniteDimensionalEuclideanJordanAlgebra(field
,Qs
)