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
.categories
.magmatic_algebras
import MagmaticAlgebras
9 from sage
.structure
.element
import is_Matrix
10 from sage
.structure
.category_object
import normalize_names
12 from sage
.algebras
.finite_dimensional_algebras
.finite_dimensional_algebra
import FiniteDimensionalAlgebra
13 from sage
.algebras
.finite_dimensional_algebras
.finite_dimensional_algebra_element
import FiniteDimensionalAlgebraElement
15 class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra
):
17 def __classcall_private__(cls
,
21 assume_associative
=False,
26 mult_table
= [b
.base_extend(field
) for b
in mult_table
]
29 if not (is_Matrix(b
) and b
.dimensions() == (n
, n
)):
30 raise ValueError("input is not a multiplication table")
31 mult_table
= tuple(mult_table
)
33 cat
= MagmaticAlgebras(field
).FiniteDimensional().WithBasis()
34 cat
.or_subcategory(category
)
35 if assume_associative
:
36 cat
= cat
.Associative()
38 names
= normalize_names(n
, names
)
40 fda
= super(FiniteDimensionalEuclideanJordanAlgebra
, cls
)
41 return fda
.__classcall
__(cls
,
44 assume_associative
=assume_associative
,
48 natural_basis
=natural_basis
)
55 assume_associative
=False,
62 By definition, Jordan multiplication commutes::
64 sage: set_random_seed()
65 sage: J = random_eja()
66 sage: x = J.random_element()
67 sage: y = J.random_element()
73 self
._natural
_basis
= natural_basis
74 self
._multiplication
_table
= mult_table
75 fda
= super(FiniteDimensionalEuclideanJordanAlgebra
, self
)
84 Return a string representation of ``self``.
86 fmt
= "Euclidean Jordan algebra of degree {} over {}"
87 return fmt
.format(self
.degree(), self
.base_ring())
90 def characteristic_polynomial(self
):
94 names
= ['X' + str(i
) for i
in range(1,n
+1)]
95 R
= PolynomialRing(self
.base_ring(), names
)
96 J
= FiniteDimensionalEuclideanJordanAlgebra(R
,
97 self
._multiplication
_table
,
104 if not x0
.is_regular():
105 raise ValueError("don't know a regular element")
107 # Get the vector space (as opposed to module) so that
108 # span_of_basis() works.
109 V
= x0
.vector().parent().ambient_vector_space()
110 V1
= V
.span_of_basis( (x0
**k
).vector() for k
in range(r
) )
111 B
= V1
.basis() + V1
.complement().basis()
112 W
= V
.span_of_basis(B
)
115 # The coordinates of e_k with respect to the basis B.
116 # But, the e_k are elements of B...
117 return identity_matrix(J
.base_ring(), n
).column(k
-1).column()
119 # A matrix implementation 1
120 x
= J(vector(R
, R
.gens()))
121 l1
= [column_matrix(W
.coordinates((x
**k
).vector())) for k
in range(r
)]
122 l2
= [e(k
) for k
in range(r
+1, n
+1)]
123 A_of_x
= block_matrix(1, n
, (l1
+ l2
))
124 xr
= W
.coordinates((x
**r
).vector())
129 numerator
= column_matrix(A
.base_ring(), A_cols
).det()
130 denominator
= A
.det()
131 ai
= numerator
/denominator
134 # Note: all entries past the rth should be zero.
138 def inner_product(self
, x
, y
):
140 The inner product associated with this Euclidean Jordan algebra.
142 Defaults to the trace inner product, but can be overridden by
143 subclasses if they are sure that the necessary properties are
148 The inner product must satisfy its axiom for this algebra to truly
149 be a Euclidean Jordan Algebra::
151 sage: set_random_seed()
152 sage: J = random_eja()
153 sage: x = J.random_element()
154 sage: y = J.random_element()
155 sage: z = J.random_element()
156 sage: (x*y).inner_product(z) == y.inner_product(x*z)
160 if (not x
in self
) or (not y
in self
):
161 raise TypeError("arguments must live in this algebra")
162 return x
.trace_inner_product(y
)
165 def natural_basis(self
):
167 Return a more-natural representation of this algebra's basis.
169 Every finite-dimensional Euclidean Jordan Algebra is a direct
170 sum of five simple algebras, four of which comprise Hermitian
171 matrices. This method returns the original "natural" basis
172 for our underlying vector space. (Typically, the natural basis
173 is used to construct the multiplication table in the first place.)
175 Note that this will always return a matrix. The standard basis
176 in `R^n` will be returned as `n`-by-`1` column matrices.
180 sage: J = RealSymmetricEJA(2)
183 sage: J.natural_basis()
191 sage: J = JordanSpinEJA(2)
194 sage: J.natural_basis()
201 if self
._natural
_basis
is None:
202 return tuple( b
.vector().column() for b
in self
.basis() )
204 return self
._natural
_basis
209 Return the rank of this EJA.
211 if self
._rank
is None:
212 raise ValueError("no rank specified at genesis")
217 class Element(FiniteDimensionalAlgebraElement
):
219 An element of a Euclidean Jordan algebra.
222 def __init__(self
, A
, elt
=None):
226 The identity in `S^n` is converted to the identity in the EJA::
228 sage: J = RealSymmetricEJA(3)
229 sage: I = identity_matrix(QQ,3)
230 sage: J(I) == J.one()
233 This skew-symmetric matrix can't be represented in the EJA::
235 sage: J = RealSymmetricEJA(3)
236 sage: A = matrix(QQ,3, lambda i,j: i-j)
238 Traceback (most recent call last):
240 ArithmeticError: vector is not in free module
243 # Goal: if we're given a matrix, and if it lives in our
244 # parent algebra's "natural ambient space," convert it
245 # into an algebra element.
247 # The catch is, we make a recursive call after converting
248 # the given matrix into a vector that lives in the algebra.
249 # This we need to try the parent class initializer first,
250 # to avoid recursing forever if we're given something that
251 # already fits into the algebra, but also happens to live
252 # in the parent's "natural ambient space" (this happens with
255 FiniteDimensionalAlgebraElement
.__init
__(self
, A
, elt
)
257 natural_basis
= A
.natural_basis()
258 if elt
in natural_basis
[0].matrix_space():
259 # Thanks for nothing! Matrix spaces aren't vector
260 # spaces in Sage, so we have to figure out its
261 # natural-basis coordinates ourselves.
262 V
= VectorSpace(elt
.base_ring(), elt
.nrows()**2)
263 W
= V
.span( _mat2vec(s
) for s
in natural_basis
)
264 coords
= W
.coordinates(_mat2vec(elt
))
265 FiniteDimensionalAlgebraElement
.__init
__(self
, A
, coords
)
267 def __pow__(self
, n
):
269 Return ``self`` raised to the power ``n``.
271 Jordan algebras are always power-associative; see for
272 example Faraut and Koranyi, Proposition II.1.2 (ii).
276 We have to override this because our superclass uses row vectors
277 instead of column vectors! We, on the other hand, assume column
282 sage: set_random_seed()
283 sage: x = random_eja().random_element()
284 sage: x.operator_matrix()*x.vector() == (x^2).vector()
287 A few examples of power-associativity::
289 sage: set_random_seed()
290 sage: x = random_eja().random_element()
291 sage: x*(x*x)*(x*x) == x^5
293 sage: (x*x)*(x*x*x) == x^5
296 We also know that powers operator-commute (Koecher, Chapter
299 sage: set_random_seed()
300 sage: x = random_eja().random_element()
301 sage: m = ZZ.random_element(0,10)
302 sage: n = ZZ.random_element(0,10)
303 sage: Lxm = (x^m).operator_matrix()
304 sage: Lxn = (x^n).operator_matrix()
305 sage: Lxm*Lxn == Lxn*Lxm
315 return A( (self
.operator_matrix()**(n
-1))*self
.vector() )
318 def characteristic_polynomial(self
):
320 Return my characteristic polynomial (if I'm a regular
323 Eventually this should be implemented in terms of the parent
324 algebra's characteristic polynomial that works for ALL
327 if self
.is_regular():
328 return self
.minimal_polynomial()
330 raise NotImplementedError('irregular element')
333 def inner_product(self
, other
):
335 Return the parent algebra's inner product of myself and ``other``.
339 The inner product in the Jordan spin algebra is the usual
340 inner product on `R^n` (this example only works because the
341 basis for the Jordan algebra is the standard basis in `R^n`)::
343 sage: J = JordanSpinEJA(3)
344 sage: x = vector(QQ,[1,2,3])
345 sage: y = vector(QQ,[4,5,6])
346 sage: x.inner_product(y)
348 sage: J(x).inner_product(J(y))
351 The inner product on `S^n` is `<X,Y> = trace(X*Y)`, where
352 multiplication is the usual matrix multiplication in `S^n`,
353 so the inner product of the identity matrix with itself
356 sage: J = RealSymmetricEJA(3)
357 sage: J.one().inner_product(J.one())
360 Likewise, the inner product on `C^n` is `<X,Y> =
361 Re(trace(X*Y))`, where we must necessarily take the real
362 part because the product of Hermitian matrices may not be
365 sage: J = ComplexHermitianEJA(3)
366 sage: J.one().inner_product(J.one())
369 Ditto for the quaternions::
371 sage: J = QuaternionHermitianEJA(3)
372 sage: J.one().inner_product(J.one())
377 Ensure that we can always compute an inner product, and that
378 it gives us back a real number::
380 sage: set_random_seed()
381 sage: J = random_eja()
382 sage: x = J.random_element()
383 sage: y = J.random_element()
384 sage: x.inner_product(y) in RR
390 raise TypeError("'other' must live in the same algebra")
392 return P
.inner_product(self
, other
)
395 def operator_commutes_with(self
, other
):
397 Return whether or not this element operator-commutes
402 The definition of a Jordan algebra says that any element
403 operator-commutes with its square::
405 sage: set_random_seed()
406 sage: x = random_eja().random_element()
407 sage: x.operator_commutes_with(x^2)
412 Test Lemma 1 from Chapter III of Koecher::
414 sage: set_random_seed()
415 sage: J = random_eja()
416 sage: u = J.random_element()
417 sage: v = J.random_element()
418 sage: lhs = u.operator_commutes_with(u*v)
419 sage: rhs = v.operator_commutes_with(u^2)
424 if not other
in self
.parent():
425 raise TypeError("'other' must live in the same algebra")
427 A
= self
.operator_matrix()
428 B
= other
.operator_matrix()
434 Return my determinant, the product of my eigenvalues.
438 sage: J = JordanSpinEJA(2)
439 sage: e0,e1 = J.gens()
443 sage: J = JordanSpinEJA(3)
444 sage: e0,e1,e2 = J.gens()
445 sage: x = e0 + e1 + e2
450 cs
= self
.characteristic_polynomial().coefficients(sparse
=False)
453 return cs
[0] * (-1)**r
455 raise ValueError('charpoly had no coefficients')
460 Return the Jordan-multiplicative inverse of this element.
462 We can't use the superclass method because it relies on the
463 algebra being associative.
467 The inverse in the spin factor algebra is given in Alizadeh's
470 sage: set_random_seed()
471 sage: n = ZZ.random_element(1,10)
472 sage: J = JordanSpinEJA(n)
473 sage: x = J.random_element()
474 sage: while x.is_zero():
475 ....: x = J.random_element()
476 sage: x_vec = x.vector()
478 sage: x_bar = x_vec[1:]
479 sage: coeff = 1/(x0^2 - x_bar.inner_product(x_bar))
480 sage: inv_vec = x_vec.parent()([x0] + (-x_bar).list())
481 sage: x_inverse = coeff*inv_vec
482 sage: x.inverse() == J(x_inverse)
487 The identity element is its own inverse::
489 sage: set_random_seed()
490 sage: J = random_eja()
491 sage: J.one().inverse() == J.one()
494 If an element has an inverse, it acts like one. TODO: this
495 can be a lot less ugly once ``is_invertible`` doesn't crash
496 on irregular elements::
498 sage: set_random_seed()
499 sage: J = random_eja()
500 sage: x = J.random_element()
502 ....: x.inverse()*x == J.one()
508 if self
.parent().is_associative():
509 elt
= FiniteDimensionalAlgebraElement(self
.parent(), self
)
512 # TODO: we can do better once the call to is_invertible()
513 # doesn't crash on irregular elements.
514 #if not self.is_invertible():
515 # raise ValueError('element is not invertible')
517 # We do this a little different than the usual recursive
518 # call to a finite-dimensional algebra element, because we
519 # wind up with an inverse that lives in the subalgebra and
520 # we need information about the parent to convert it back.
521 V
= self
.span_of_powers()
522 assoc_subalg
= self
.subalgebra_generated_by()
523 # Mis-design warning: the basis used for span_of_powers()
524 # and subalgebra_generated_by() must be the same, and in
526 elt
= assoc_subalg(V
.coordinates(self
.vector()))
528 # This will be in the subalgebra's coordinates...
529 fda_elt
= FiniteDimensionalAlgebraElement(assoc_subalg
, elt
)
530 subalg_inverse
= fda_elt
.inverse()
532 # So we have to convert back...
533 basis
= [ self
.parent(v
) for v
in V
.basis() ]
534 pairs
= zip(subalg_inverse
.vector(), basis
)
535 return self
.parent().linear_combination(pairs
)
538 def is_invertible(self
):
540 Return whether or not this element is invertible.
542 We can't use the superclass method because it relies on
543 the algebra being associative.
547 The usual way to do this is to check if the determinant is
548 zero, but we need the characteristic polynomial for the
549 determinant. The minimal polynomial is a lot easier to get,
550 so we use Corollary 2 in Chapter V of Koecher to check
551 whether or not the paren't algebra's zero element is a root
552 of this element's minimal polynomial.
556 The identity element is always invertible::
558 sage: set_random_seed()
559 sage: J = random_eja()
560 sage: J.one().is_invertible()
563 The zero element is never invertible::
565 sage: set_random_seed()
566 sage: J = random_eja()
567 sage: J.zero().is_invertible()
571 zero
= self
.parent().zero()
572 p
= self
.minimal_polynomial()
573 return not (p(zero
) == zero
)
576 def is_nilpotent(self
):
578 Return whether or not some power of this element is zero.
580 The superclass method won't work unless we're in an
581 associative algebra, and we aren't. However, we generate
582 an assocoative subalgebra and we're nilpotent there if and
583 only if we're nilpotent here (probably).
587 The identity element is never nilpotent::
589 sage: set_random_seed()
590 sage: random_eja().one().is_nilpotent()
593 The additive identity is always nilpotent::
595 sage: set_random_seed()
596 sage: random_eja().zero().is_nilpotent()
600 # The element we're going to call "is_nilpotent()" on.
601 # Either myself, interpreted as an element of a finite-
602 # dimensional algebra, or an element of an associative
606 if self
.parent().is_associative():
607 elt
= FiniteDimensionalAlgebraElement(self
.parent(), self
)
609 V
= self
.span_of_powers()
610 assoc_subalg
= self
.subalgebra_generated_by()
611 # Mis-design warning: the basis used for span_of_powers()
612 # and subalgebra_generated_by() must be the same, and in
614 elt
= assoc_subalg(V
.coordinates(self
.vector()))
616 # Recursive call, but should work since elt lives in an
617 # associative algebra.
618 return elt
.is_nilpotent()
621 def is_regular(self
):
623 Return whether or not this is a regular element.
627 The identity element always has degree one, but any element
628 linearly-independent from it is regular::
630 sage: J = JordanSpinEJA(5)
631 sage: J.one().is_regular()
633 sage: e0, e1, e2, e3, e4 = J.gens() # e0 is the identity
634 sage: for x in J.gens():
635 ....: (J.one() + x).is_regular()
643 return self
.degree() == self
.parent().rank()
648 Compute the degree of this element the straightforward way
649 according to the definition; by appending powers to a list
650 and figuring out its dimension (that is, whether or not
651 they're linearly dependent).
655 sage: J = JordanSpinEJA(4)
656 sage: J.one().degree()
658 sage: e0,e1,e2,e3 = J.gens()
659 sage: (e0 - e1).degree()
662 In the spin factor algebra (of rank two), all elements that
663 aren't multiples of the identity are regular::
665 sage: set_random_seed()
666 sage: n = ZZ.random_element(1,10)
667 sage: J = JordanSpinEJA(n)
668 sage: x = J.random_element()
669 sage: x == x.coefficient(0)*J.one() or x.degree() == 2
673 return self
.span_of_powers().dimension()
676 def minimal_polynomial(self
):
678 Return the minimal polynomial of this element,
679 as a function of the variable `t`.
683 We restrict ourselves to the associative subalgebra
684 generated by this element, and then return the minimal
685 polynomial of this element's operator matrix (in that
686 subalgebra). This works by Baes Proposition 2.3.16.
690 The minimal polynomial of the identity and zero elements are
693 sage: set_random_seed()
694 sage: J = random_eja()
695 sage: J.one().minimal_polynomial()
697 sage: J.zero().minimal_polynomial()
700 The degree of an element is (by one definition) the degree
701 of its minimal polynomial::
703 sage: set_random_seed()
704 sage: x = random_eja().random_element()
705 sage: x.degree() == x.minimal_polynomial().degree()
708 The minimal polynomial and the characteristic polynomial coincide
709 and are known (see Alizadeh, Example 11.11) for all elements of
710 the spin factor algebra that aren't scalar multiples of the
713 sage: set_random_seed()
714 sage: n = ZZ.random_element(2,10)
715 sage: J = JordanSpinEJA(n)
716 sage: y = J.random_element()
717 sage: while y == y.coefficient(0)*J.one():
718 ....: y = J.random_element()
719 sage: y0 = y.vector()[0]
720 sage: y_bar = y.vector()[1:]
721 sage: actual = y.minimal_polynomial()
722 sage: t = PolynomialRing(J.base_ring(),'t').gen(0)
723 sage: expected = t^2 - 2*y0*t + (y0^2 - norm(y_bar)^2)
724 sage: bool(actual == expected)
728 V
= self
.span_of_powers()
729 assoc_subalg
= self
.subalgebra_generated_by()
730 # Mis-design warning: the basis used for span_of_powers()
731 # and subalgebra_generated_by() must be the same, and in
733 elt
= assoc_subalg(V
.coordinates(self
.vector()))
735 # We get back a symbolic polynomial in 'x' but want a real
737 p_of_x
= elt
.operator_matrix().minimal_polynomial()
738 return p_of_x
.change_variable_name('t')
741 def natural_representation(self
):
743 Return a more-natural representation of this element.
745 Every finite-dimensional Euclidean Jordan Algebra is a
746 direct sum of five simple algebras, four of which comprise
747 Hermitian matrices. This method returns the original
748 "natural" representation of this element as a Hermitian
749 matrix, if it has one. If not, you get the usual representation.
753 sage: J = ComplexHermitianEJA(3)
756 sage: J.one().natural_representation()
766 sage: J = QuaternionHermitianEJA(3)
769 sage: J.one().natural_representation()
770 [1 0 0 0 0 0 0 0 0 0 0 0]
771 [0 1 0 0 0 0 0 0 0 0 0 0]
772 [0 0 1 0 0 0 0 0 0 0 0 0]
773 [0 0 0 1 0 0 0 0 0 0 0 0]
774 [0 0 0 0 1 0 0 0 0 0 0 0]
775 [0 0 0 0 0 1 0 0 0 0 0 0]
776 [0 0 0 0 0 0 1 0 0 0 0 0]
777 [0 0 0 0 0 0 0 1 0 0 0 0]
778 [0 0 0 0 0 0 0 0 1 0 0 0]
779 [0 0 0 0 0 0 0 0 0 1 0 0]
780 [0 0 0 0 0 0 0 0 0 0 1 0]
781 [0 0 0 0 0 0 0 0 0 0 0 1]
784 B
= self
.parent().natural_basis()
785 W
= B
[0].matrix_space()
786 return W
.linear_combination(zip(self
.vector(), B
))
789 def operator_matrix(self
):
791 Return the matrix that represents left- (or right-)
792 multiplication by this element in the parent algebra.
794 We have to override this because the superclass method
795 returns a matrix that acts on row vectors (that is, on
800 Test the first polarization identity from my notes, Koecher Chapter
801 III, or from Baes (2.3)::
803 sage: set_random_seed()
804 sage: J = random_eja()
805 sage: x = J.random_element()
806 sage: y = J.random_element()
807 sage: Lx = x.operator_matrix()
808 sage: Ly = y.operator_matrix()
809 sage: Lxx = (x*x).operator_matrix()
810 sage: Lxy = (x*y).operator_matrix()
811 sage: bool(2*Lx*Lxy + Ly*Lxx == 2*Lxy*Lx + Lxx*Ly)
814 Test the second polarization identity from my notes or from
817 sage: set_random_seed()
818 sage: J = random_eja()
819 sage: x = J.random_element()
820 sage: y = J.random_element()
821 sage: z = J.random_element()
822 sage: Lx = x.operator_matrix()
823 sage: Ly = y.operator_matrix()
824 sage: Lz = z.operator_matrix()
825 sage: Lzy = (z*y).operator_matrix()
826 sage: Lxy = (x*y).operator_matrix()
827 sage: Lxz = (x*z).operator_matrix()
828 sage: bool(Lx*Lzy + Lz*Lxy + Ly*Lxz == Lzy*Lx + Lxy*Lz + Lxz*Ly)
831 Test the third polarization identity from my notes or from
834 sage: set_random_seed()
835 sage: J = random_eja()
836 sage: u = J.random_element()
837 sage: y = J.random_element()
838 sage: z = J.random_element()
839 sage: Lu = u.operator_matrix()
840 sage: Ly = y.operator_matrix()
841 sage: Lz = z.operator_matrix()
842 sage: Lzy = (z*y).operator_matrix()
843 sage: Luy = (u*y).operator_matrix()
844 sage: Luz = (u*z).operator_matrix()
845 sage: Luyz = (u*(y*z)).operator_matrix()
846 sage: lhs = Lu*Lzy + Lz*Luy + Ly*Luz
847 sage: rhs = Luyz + Ly*Lu*Lz + Lz*Lu*Ly
848 sage: bool(lhs == rhs)
852 fda_elt
= FiniteDimensionalAlgebraElement(self
.parent(), self
)
853 return fda_elt
.matrix().transpose()
856 def quadratic_representation(self
, other
=None):
858 Return the quadratic representation of this element.
862 The explicit form in the spin factor algebra is given by
863 Alizadeh's Example 11.12::
865 sage: set_random_seed()
866 sage: n = ZZ.random_element(1,10)
867 sage: J = JordanSpinEJA(n)
868 sage: x = J.random_element()
869 sage: x_vec = x.vector()
871 sage: x_bar = x_vec[1:]
872 sage: A = matrix(QQ, 1, [x_vec.inner_product(x_vec)])
873 sage: B = 2*x0*x_bar.row()
874 sage: C = 2*x0*x_bar.column()
875 sage: D = identity_matrix(QQ, n-1)
876 sage: D = (x0^2 - x_bar.inner_product(x_bar))*D
877 sage: D = D + 2*x_bar.tensor_product(x_bar)
878 sage: Q = block_matrix(2,2,[A,B,C,D])
879 sage: Q == x.quadratic_representation()
882 Test all of the properties from Theorem 11.2 in Alizadeh::
884 sage: set_random_seed()
885 sage: J = random_eja()
886 sage: x = J.random_element()
887 sage: y = J.random_element()
891 sage: actual = x.quadratic_representation(y)
892 sage: expected = ( (x+y).quadratic_representation()
893 ....: -x.quadratic_representation()
894 ....: -y.quadratic_representation() ) / 2
895 sage: actual == expected
900 sage: alpha = QQ.random_element()
901 sage: actual = (alpha*x).quadratic_representation()
902 sage: expected = (alpha^2)*x.quadratic_representation()
903 sage: actual == expected
908 sage: Qy = y.quadratic_representation()
909 sage: actual = J(Qy*x.vector()).quadratic_representation()
910 sage: expected = Qy*x.quadratic_representation()*Qy
911 sage: actual == expected
916 sage: k = ZZ.random_element(1,10)
917 sage: actual = (x^k).quadratic_representation()
918 sage: expected = (x.quadratic_representation())^k
919 sage: actual == expected
925 elif not other
in self
.parent():
926 raise TypeError("'other' must live in the same algebra")
928 L
= self
.operator_matrix()
929 M
= other
.operator_matrix()
930 return ( L
*M
+ M
*L
- (self
*other
).operator_matrix() )
933 def span_of_powers(self
):
935 Return the vector space spanned by successive powers of
938 # The dimension of the subalgebra can't be greater than
939 # the big algebra, so just put everything into a list
940 # and let span() get rid of the excess.
942 # We do the extra ambient_vector_space() in case we're messing
943 # with polynomials and the direct parent is a module.
944 V
= self
.vector().parent().ambient_vector_space()
945 return V
.span( (self
**d
).vector() for d
in xrange(V
.dimension()) )
948 def subalgebra_generated_by(self
):
950 Return the associative subalgebra of the parent EJA generated
955 sage: set_random_seed()
956 sage: x = random_eja().random_element()
957 sage: x.subalgebra_generated_by().is_associative()
960 Squaring in the subalgebra should be the same thing as
961 squaring in the superalgebra::
963 sage: set_random_seed()
964 sage: x = random_eja().random_element()
965 sage: u = x.subalgebra_generated_by().random_element()
966 sage: u.operator_matrix()*u.vector() == (u**2).vector()
970 # First get the subspace spanned by the powers of myself...
971 V
= self
.span_of_powers()
974 # Now figure out the entries of the right-multiplication
975 # matrix for the successive basis elements b0, b1,... of
978 for b_right
in V
.basis():
979 eja_b_right
= self
.parent()(b_right
)
981 # The first row of the right-multiplication matrix by
982 # b1 is what we get if we apply that matrix to b1. The
983 # second row of the right multiplication matrix by b1
984 # is what we get when we apply that matrix to b2...
986 # IMPORTANT: this assumes that all vectors are COLUMN
987 # vectors, unlike our superclass (which uses row vectors).
988 for b_left
in V
.basis():
989 eja_b_left
= self
.parent()(b_left
)
990 # Multiply in the original EJA, but then get the
991 # coordinates from the subalgebra in terms of its
993 this_row
= V
.coordinates((eja_b_left
*eja_b_right
).vector())
994 b_right_rows
.append(this_row
)
995 b_right_matrix
= matrix(F
, b_right_rows
)
996 mats
.append(b_right_matrix
)
998 # It's an algebra of polynomials in one element, and EJAs
999 # are power-associative.
1001 # TODO: choose generator names intelligently.
1002 return FiniteDimensionalEuclideanJordanAlgebra(F
, mats
, assume_associative
=True, names
='f')
1005 def subalgebra_idempotent(self
):
1007 Find an idempotent in the associative subalgebra I generate
1008 using Proposition 2.3.5 in Baes.
1012 sage: set_random_seed()
1013 sage: J = RealCartesianProductEJA(5)
1014 sage: c = J.random_element().subalgebra_idempotent()
1017 sage: J = JordanSpinEJA(5)
1018 sage: c = J.random_element().subalgebra_idempotent()
1023 if self
.is_nilpotent():
1024 raise ValueError("this only works with non-nilpotent elements!")
1026 V
= self
.span_of_powers()
1027 J
= self
.subalgebra_generated_by()
1028 # Mis-design warning: the basis used for span_of_powers()
1029 # and subalgebra_generated_by() must be the same, and in
1031 u
= J(V
.coordinates(self
.vector()))
1033 # The image of the matrix of left-u^m-multiplication
1034 # will be minimal for some natural number s...
1036 minimal_dim
= V
.dimension()
1037 for i
in xrange(1, V
.dimension()):
1038 this_dim
= (u
**i
).operator_matrix().image().dimension()
1039 if this_dim
< minimal_dim
:
1040 minimal_dim
= this_dim
1043 # Now minimal_matrix should correspond to the smallest
1044 # non-zero subspace in Baes's (or really, Koecher's)
1047 # However, we need to restrict the matrix to work on the
1048 # subspace... or do we? Can't we just solve, knowing that
1049 # A(c) = u^(s+1) should have a solution in the big space,
1052 # Beware, solve_right() means that we're using COLUMN vectors.
1053 # Our FiniteDimensionalAlgebraElement superclass uses rows.
1055 A
= u_next
.operator_matrix()
1056 c_coordinates
= A
.solve_right(u_next
.vector())
1058 # Now c_coordinates is the idempotent we want, but it's in
1059 # the coordinate system of the subalgebra.
1061 # We need the basis for J, but as elements of the parent algebra.
1063 basis
= [self
.parent(v
) for v
in V
.basis()]
1064 return self
.parent().linear_combination(zip(c_coordinates
, basis
))
1069 Return my trace, the sum of my eigenvalues.
1073 sage: J = JordanSpinEJA(3)
1074 sage: e0,e1,e2 = J.gens()
1075 sage: x = e0 + e1 + e2
1080 cs
= self
.characteristic_polynomial().coefficients(sparse
=False)
1084 raise ValueError('charpoly had fewer than 2 coefficients')
1087 def trace_inner_product(self
, other
):
1089 Return the trace inner product of myself and ``other``.
1091 if not other
in self
.parent():
1092 raise TypeError("'other' must live in the same algebra")
1094 return (self
*other
).trace()
1097 class RealCartesianProductEJA(FiniteDimensionalEuclideanJordanAlgebra
):
1099 Return the Euclidean Jordan Algebra corresponding to the set
1100 `R^n` under the Hadamard product.
1102 Note: this is nothing more than the Cartesian product of ``n``
1103 copies of the spin algebra. Once Cartesian product algebras
1104 are implemented, this can go.
1108 This multiplication table can be verified by hand::
1110 sage: J = RealCartesianProductEJA(3)
1111 sage: e0,e1,e2 = J.gens()
1127 def __classcall_private__(cls
, n
, field
=QQ
):
1128 # The FiniteDimensionalAlgebra constructor takes a list of
1129 # matrices, the ith representing right multiplication by the ith
1130 # basis element in the vector space. So if e_1 = (1,0,0), then
1131 # right (Hadamard) multiplication of x by e_1 picks out the first
1132 # component of x; and likewise for the ith basis element e_i.
1133 Qs
= [ matrix(field
, n
, n
, lambda k
,j
: 1*(k
== j
== i
))
1134 for i
in xrange(n
) ]
1136 fdeja
= super(RealCartesianProductEJA
, cls
)
1137 return fdeja
.__classcall
_private
__(cls
, field
, Qs
, rank
=n
)
1139 def inner_product(self
, x
, y
):
1140 return _usual_ip(x
,y
)
1145 Return a "random" finite-dimensional Euclidean Jordan Algebra.
1149 For now, we choose a random natural number ``n`` (greater than zero)
1150 and then give you back one of the following:
1152 * The cartesian product of the rational numbers ``n`` times; this is
1153 ``QQ^n`` with the Hadamard product.
1155 * The Jordan spin algebra on ``QQ^n``.
1157 * The ``n``-by-``n`` rational symmetric matrices with the symmetric
1160 * The ``n``-by-``n`` complex-rational Hermitian matrices embedded
1161 in the space of ``2n``-by-``2n`` real symmetric matrices.
1163 * The ``n``-by-``n`` quaternion-rational Hermitian matrices embedded
1164 in the space of ``4n``-by-``4n`` real symmetric matrices.
1166 Later this might be extended to return Cartesian products of the
1172 Euclidean Jordan algebra of degree...
1175 n
= ZZ
.random_element(1,5)
1176 constructor
= choice([RealCartesianProductEJA
,
1179 ComplexHermitianEJA
,
1180 QuaternionHermitianEJA
])
1181 return constructor(n
, field
=QQ
)
1185 def _real_symmetric_basis(n
, field
=QQ
):
1187 Return a basis for the space of real symmetric n-by-n matrices.
1189 # The basis of symmetric matrices, as matrices, in their R^(n-by-n)
1193 for j
in xrange(i
+1):
1194 Eij
= matrix(field
, n
, lambda k
,l
: k
==i
and l
==j
)
1198 # Beware, orthogonal but not normalized!
1199 Sij
= Eij
+ Eij
.transpose()
1204 def _complex_hermitian_basis(n
, field
=QQ
):
1206 Returns a basis for the space of complex Hermitian n-by-n matrices.
1210 sage: set_random_seed()
1211 sage: n = ZZ.random_element(1,5)
1212 sage: all( M.is_symmetric() for M in _complex_hermitian_basis(n) )
1216 F
= QuadraticField(-1, 'I')
1219 # This is like the symmetric case, but we need to be careful:
1221 # * We want conjugate-symmetry, not just symmetry.
1222 # * The diagonal will (as a result) be real.
1226 for j
in xrange(i
+1):
1227 Eij
= matrix(field
, n
, lambda k
,l
: k
==i
and l
==j
)
1229 Sij
= _embed_complex_matrix(Eij
)
1232 # Beware, orthogonal but not normalized! The second one
1233 # has a minus because it's conjugated.
1234 Sij_real
= _embed_complex_matrix(Eij
+ Eij
.transpose())
1236 Sij_imag
= _embed_complex_matrix(I
*Eij
- I
*Eij
.transpose())
1241 def _quaternion_hermitian_basis(n
, field
=QQ
):
1243 Returns a basis for the space of quaternion Hermitian n-by-n matrices.
1247 sage: set_random_seed()
1248 sage: n = ZZ.random_element(1,5)
1249 sage: all( M.is_symmetric() for M in _quaternion_hermitian_basis(n) )
1253 Q
= QuaternionAlgebra(QQ
,-1,-1)
1256 # This is like the symmetric case, but we need to be careful:
1258 # * We want conjugate-symmetry, not just symmetry.
1259 # * The diagonal will (as a result) be real.
1263 for j
in xrange(i
+1):
1264 Eij
= matrix(Q
, n
, lambda k
,l
: k
==i
and l
==j
)
1266 Sij
= _embed_quaternion_matrix(Eij
)
1269 # Beware, orthogonal but not normalized! The second,
1270 # third, and fourth ones have a minus because they're
1272 Sij_real
= _embed_quaternion_matrix(Eij
+ Eij
.transpose())
1274 Sij_I
= _embed_quaternion_matrix(I
*Eij
- I
*Eij
.transpose())
1276 Sij_J
= _embed_quaternion_matrix(J
*Eij
- J
*Eij
.transpose())
1278 Sij_K
= _embed_quaternion_matrix(K
*Eij
- K
*Eij
.transpose())
1284 return vector(m
.base_ring(), m
.list())
1287 return matrix(v
.base_ring(), sqrt(v
.degree()), v
.list())
1289 def _multiplication_table_from_matrix_basis(basis
):
1291 At least three of the five simple Euclidean Jordan algebras have the
1292 symmetric multiplication (A,B) |-> (AB + BA)/2, where the
1293 multiplication on the right is matrix multiplication. Given a basis
1294 for the underlying matrix space, this function returns a
1295 multiplication table (obtained by looping through the basis
1296 elements) for an algebra of those matrices. A reordered copy
1297 of the basis is also returned to work around the fact that
1298 the ``span()`` in this function will change the order of the basis
1299 from what we think it is, to... something else.
1301 # In S^2, for example, we nominally have four coordinates even
1302 # though the space is of dimension three only. The vector space V
1303 # is supposed to hold the entire long vector, and the subspace W
1304 # of V will be spanned by the vectors that arise from symmetric
1305 # matrices. Thus for S^2, dim(V) == 4 and dim(W) == 3.
1306 field
= basis
[0].base_ring()
1307 dimension
= basis
[0].nrows()
1309 V
= VectorSpace(field
, dimension
**2)
1310 W
= V
.span( _mat2vec(s
) for s
in basis
)
1312 # Taking the span above reorders our basis (thanks, jerk!) so we
1313 # need to put our "matrix basis" in the same order as the
1314 # (reordered) vector basis.
1315 S
= tuple( _vec2mat(b
) for b
in W
.basis() )
1319 # Brute force the multiplication-by-s matrix by looping
1320 # through all elements of the basis and doing the computation
1321 # to find out what the corresponding row should be. BEWARE:
1322 # these multiplication tables won't be symmetric! It therefore
1323 # becomes REALLY IMPORTANT that the underlying algebra
1324 # constructor uses ROW vectors and not COLUMN vectors. That's
1325 # why we're computing rows here and not columns.
1328 this_row
= _mat2vec((s
*t
+ t
*s
)/2)
1329 Q_rows
.append(W
.coordinates(this_row
))
1330 Q
= matrix(field
, W
.dimension(), Q_rows
)
1336 def _embed_complex_matrix(M
):
1338 Embed the n-by-n complex matrix ``M`` into the space of real
1339 matrices of size 2n-by-2n via the map the sends each entry `z = a +
1340 bi` to the block matrix ``[[a,b],[-b,a]]``.
1344 sage: F = QuadraticField(-1,'i')
1345 sage: x1 = F(4 - 2*i)
1346 sage: x2 = F(1 + 2*i)
1349 sage: M = matrix(F,2,[[x1,x2],[x3,x4]])
1350 sage: _embed_complex_matrix(M)
1359 Embedding is a homomorphism (isomorphism, in fact)::
1361 sage: set_random_seed()
1362 sage: n = ZZ.random_element(5)
1363 sage: F = QuadraticField(-1, 'i')
1364 sage: X = random_matrix(F, n)
1365 sage: Y = random_matrix(F, n)
1366 sage: actual = _embed_complex_matrix(X) * _embed_complex_matrix(Y)
1367 sage: expected = _embed_complex_matrix(X*Y)
1368 sage: actual == expected
1374 raise ValueError("the matrix 'M' must be square")
1375 field
= M
.base_ring()
1380 blocks
.append(matrix(field
, 2, [[a
,b
],[-b
,a
]]))
1382 # We can drop the imaginaries here.
1383 return block_matrix(field
.base_ring(), n
, blocks
)
1386 def _unembed_complex_matrix(M
):
1388 The inverse of _embed_complex_matrix().
1392 sage: A = matrix(QQ,[ [ 1, 2, 3, 4],
1393 ....: [-2, 1, -4, 3],
1394 ....: [ 9, 10, 11, 12],
1395 ....: [-10, 9, -12, 11] ])
1396 sage: _unembed_complex_matrix(A)
1398 [ 10*i + 9 12*i + 11]
1402 Unembedding is the inverse of embedding::
1404 sage: set_random_seed()
1405 sage: F = QuadraticField(-1, 'i')
1406 sage: M = random_matrix(F, 3)
1407 sage: _unembed_complex_matrix(_embed_complex_matrix(M)) == M
1413 raise ValueError("the matrix 'M' must be square")
1414 if not n
.mod(2).is_zero():
1415 raise ValueError("the matrix 'M' must be a complex embedding")
1417 F
= QuadraticField(-1, 'i')
1420 # Go top-left to bottom-right (reading order), converting every
1421 # 2-by-2 block we see to a single complex element.
1423 for k
in xrange(n
/2):
1424 for j
in xrange(n
/2):
1425 submat
= M
[2*k
:2*k
+2,2*j
:2*j
+2]
1426 if submat
[0,0] != submat
[1,1]:
1427 raise ValueError('bad on-diagonal submatrix')
1428 if submat
[0,1] != -submat
[1,0]:
1429 raise ValueError('bad off-diagonal submatrix')
1430 z
= submat
[0,0] + submat
[0,1]*i
1433 return matrix(F
, n
/2, elements
)
1436 def _embed_quaternion_matrix(M
):
1438 Embed the n-by-n quaternion matrix ``M`` into the space of real
1439 matrices of size 4n-by-4n by first sending each quaternion entry
1440 `z = a + bi + cj + dk` to the block-complex matrix
1441 ``[[a + bi, c+di],[-c + di, a-bi]]`, and then embedding those into
1446 sage: Q = QuaternionAlgebra(QQ,-1,-1)
1447 sage: i,j,k = Q.gens()
1448 sage: x = 1 + 2*i + 3*j + 4*k
1449 sage: M = matrix(Q, 1, [[x]])
1450 sage: _embed_quaternion_matrix(M)
1456 Embedding is a homomorphism (isomorphism, in fact)::
1458 sage: set_random_seed()
1459 sage: n = ZZ.random_element(5)
1460 sage: Q = QuaternionAlgebra(QQ,-1,-1)
1461 sage: X = random_matrix(Q, n)
1462 sage: Y = random_matrix(Q, n)
1463 sage: actual = _embed_quaternion_matrix(X)*_embed_quaternion_matrix(Y)
1464 sage: expected = _embed_quaternion_matrix(X*Y)
1465 sage: actual == expected
1469 quaternions
= M
.base_ring()
1472 raise ValueError("the matrix 'M' must be square")
1474 F
= QuadraticField(-1, 'i')
1479 t
= z
.coefficient_tuple()
1484 cplx_matrix
= matrix(F
, 2, [[ a
+ b
*i
, c
+ d
*i
],
1485 [-c
+ d
*i
, a
- b
*i
]])
1486 blocks
.append(_embed_complex_matrix(cplx_matrix
))
1488 # We should have real entries by now, so use the realest field
1489 # we've got for the return value.
1490 return block_matrix(quaternions
.base_ring(), n
, blocks
)
1493 def _unembed_quaternion_matrix(M
):
1495 The inverse of _embed_quaternion_matrix().
1499 sage: M = matrix(QQ, [[ 1, 2, 3, 4],
1500 ....: [-2, 1, -4, 3],
1501 ....: [-3, 4, 1, -2],
1502 ....: [-4, -3, 2, 1]])
1503 sage: _unembed_quaternion_matrix(M)
1504 [1 + 2*i + 3*j + 4*k]
1508 Unembedding is the inverse of embedding::
1510 sage: set_random_seed()
1511 sage: Q = QuaternionAlgebra(QQ, -1, -1)
1512 sage: M = random_matrix(Q, 3)
1513 sage: _unembed_quaternion_matrix(_embed_quaternion_matrix(M)) == M
1519 raise ValueError("the matrix 'M' must be square")
1520 if not n
.mod(4).is_zero():
1521 raise ValueError("the matrix 'M' must be a complex embedding")
1523 Q
= QuaternionAlgebra(QQ
,-1,-1)
1526 # Go top-left to bottom-right (reading order), converting every
1527 # 4-by-4 block we see to a 2-by-2 complex block, to a 1-by-1
1530 for l
in xrange(n
/4):
1531 for m
in xrange(n
/4):
1532 submat
= _unembed_complex_matrix(M
[4*l
:4*l
+4,4*m
:4*m
+4])
1533 if submat
[0,0] != submat
[1,1].conjugate():
1534 raise ValueError('bad on-diagonal submatrix')
1535 if submat
[0,1] != -submat
[1,0].conjugate():
1536 raise ValueError('bad off-diagonal submatrix')
1537 z
= submat
[0,0].real() + submat
[0,0].imag()*i
1538 z
+= submat
[0,1].real()*j
+ submat
[0,1].imag()*k
1541 return matrix(Q
, n
/4, elements
)
1544 # The usual inner product on R^n.
1546 return x
.vector().inner_product(y
.vector())
1548 # The inner product used for the real symmetric simple EJA.
1549 # We keep it as a separate function because e.g. the complex
1550 # algebra uses the same inner product, except divided by 2.
1551 def _matrix_ip(X
,Y
):
1552 X_mat
= X
.natural_representation()
1553 Y_mat
= Y
.natural_representation()
1554 return (X_mat
*Y_mat
).trace()
1557 class RealSymmetricEJA(FiniteDimensionalEuclideanJordanAlgebra
):
1559 The rank-n simple EJA consisting of real symmetric n-by-n
1560 matrices, the usual symmetric Jordan product, and the trace inner
1561 product. It has dimension `(n^2 + n)/2` over the reals.
1565 sage: J = RealSymmetricEJA(2)
1566 sage: e0, e1, e2 = J.gens()
1576 The degree of this algebra is `(n^2 + n) / 2`::
1578 sage: set_random_seed()
1579 sage: n = ZZ.random_element(1,5)
1580 sage: J = RealSymmetricEJA(n)
1581 sage: J.degree() == (n^2 + n)/2
1584 The Jordan multiplication is what we think it is::
1586 sage: set_random_seed()
1587 sage: n = ZZ.random_element(1,5)
1588 sage: J = RealSymmetricEJA(n)
1589 sage: x = J.random_element()
1590 sage: y = J.random_element()
1591 sage: actual = (x*y).natural_representation()
1592 sage: X = x.natural_representation()
1593 sage: Y = y.natural_representation()
1594 sage: expected = (X*Y + Y*X)/2
1595 sage: actual == expected
1597 sage: J(expected) == x*y
1602 def __classcall_private__(cls
, n
, field
=QQ
):
1603 S
= _real_symmetric_basis(n
, field
=field
)
1604 (Qs
, T
) = _multiplication_table_from_matrix_basis(S
)
1606 fdeja
= super(RealSymmetricEJA
, cls
)
1607 return fdeja
.__classcall
_private
__(cls
,
1613 def inner_product(self
, x
, y
):
1614 return _matrix_ip(x
,y
)
1617 class ComplexHermitianEJA(FiniteDimensionalEuclideanJordanAlgebra
):
1619 The rank-n simple EJA consisting of complex Hermitian n-by-n
1620 matrices over the real numbers, the usual symmetric Jordan product,
1621 and the real-part-of-trace inner product. It has dimension `n^2` over
1626 The degree of this algebra is `n^2`::
1628 sage: set_random_seed()
1629 sage: n = ZZ.random_element(1,5)
1630 sage: J = ComplexHermitianEJA(n)
1631 sage: J.degree() == n^2
1634 The Jordan multiplication is what we think it is::
1636 sage: set_random_seed()
1637 sage: n = ZZ.random_element(1,5)
1638 sage: J = ComplexHermitianEJA(n)
1639 sage: x = J.random_element()
1640 sage: y = J.random_element()
1641 sage: actual = (x*y).natural_representation()
1642 sage: X = x.natural_representation()
1643 sage: Y = y.natural_representation()
1644 sage: expected = (X*Y + Y*X)/2
1645 sage: actual == expected
1647 sage: J(expected) == x*y
1652 def __classcall_private__(cls
, n
, field
=QQ
):
1653 S
= _complex_hermitian_basis(n
)
1654 (Qs
, T
) = _multiplication_table_from_matrix_basis(S
)
1656 fdeja
= super(ComplexHermitianEJA
, cls
)
1657 return fdeja
.__classcall
_private
__(cls
,
1663 def inner_product(self
, x
, y
):
1664 # Since a+bi on the diagonal is represented as
1669 # we'll double-count the "a" entries if we take the trace of
1671 return _matrix_ip(x
,y
)/2
1674 class QuaternionHermitianEJA(FiniteDimensionalEuclideanJordanAlgebra
):
1676 The rank-n simple EJA consisting of self-adjoint n-by-n quaternion
1677 matrices, the usual symmetric Jordan product, and the
1678 real-part-of-trace inner product. It has dimension `2n^2 - n` over
1683 The degree of this algebra is `n^2`::
1685 sage: set_random_seed()
1686 sage: n = ZZ.random_element(1,5)
1687 sage: J = QuaternionHermitianEJA(n)
1688 sage: J.degree() == 2*(n^2) - n
1691 The Jordan multiplication is what we think it is::
1693 sage: set_random_seed()
1694 sage: n = ZZ.random_element(1,5)
1695 sage: J = QuaternionHermitianEJA(n)
1696 sage: x = J.random_element()
1697 sage: y = J.random_element()
1698 sage: actual = (x*y).natural_representation()
1699 sage: X = x.natural_representation()
1700 sage: Y = y.natural_representation()
1701 sage: expected = (X*Y + Y*X)/2
1702 sage: actual == expected
1704 sage: J(expected) == x*y
1709 def __classcall_private__(cls
, n
, field
=QQ
):
1710 S
= _quaternion_hermitian_basis(n
)
1711 (Qs
, T
) = _multiplication_table_from_matrix_basis(S
)
1713 fdeja
= super(QuaternionHermitianEJA
, cls
)
1714 return fdeja
.__classcall
_private
__(cls
,
1720 def inner_product(self
, x
, y
):
1721 # Since a+bi+cj+dk on the diagonal is represented as
1723 # a + bi +cj + dk = [ a b c d]
1728 # we'll quadruple-count the "a" entries if we take the trace of
1730 return _matrix_ip(x
,y
)/4
1733 class JordanSpinEJA(FiniteDimensionalEuclideanJordanAlgebra
):
1735 The rank-2 simple EJA consisting of real vectors ``x=(x0, x_bar)``
1736 with the usual inner product and jordan product ``x*y =
1737 (<x_bar,y_bar>, x0*y_bar + y0*x_bar)``. It has dimension `n` over
1742 This multiplication table can be verified by hand::
1744 sage: J = JordanSpinEJA(4)
1745 sage: e0,e1,e2,e3 = J.gens()
1763 def __classcall_private__(cls
, n
, field
=QQ
):
1765 id_matrix
= identity_matrix(field
, n
)
1767 ei
= id_matrix
.column(i
)
1768 Qi
= zero_matrix(field
, n
)
1770 Qi
.set_column(0, ei
)
1771 Qi
+= diagonal_matrix(n
, [ei
[0]]*n
)
1772 # The addition of the diagonal matrix adds an extra ei[0] in the
1773 # upper-left corner of the matrix.
1774 Qi
[0,0] = Qi
[0,0] * ~
field(2)
1777 # The rank of the spin algebra is two, unless we're in a
1778 # one-dimensional ambient space (because the rank is bounded by
1779 # the ambient dimension).
1780 fdeja
= super(JordanSpinEJA
, cls
)
1781 return fdeja
.__classcall
_private
__(cls
, field
, Qs
, rank
=min(n
,2))
1783 def inner_product(self
, x
, y
):
1784 return _usual_ip(x
,y
)