what can be supported in a general Jordan Algebra.
"""
+from itertools import repeat
+
from sage.algebras.quatalg.quaternion_algebra import QuaternionAlgebra
from sage.categories.magmatic_algebras import MagmaticAlgebras
from sage.combinat.free_module import CombinatorialFreeModule
sage: set_random_seed()
sage: J = random_eja()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = J.random_elements(2)
sage: x*y == y*x
True
sage: set_random_seed()
sage: J = random_eja()
- sage: x = J.random_element()
- sage: y = J.random_element()
- sage: z = J.random_element()
+ sage: x,y,z = J.random_elements(3)
sage: (x*y).inner_product(z) == y.inner_product(x*z)
True
s = super(FiniteDimensionalEuclideanJordanAlgebra, self)
return s.random_element()
+ def random_elements(self, count):
+ """
+ Return ``count`` random elements as a tuple.
+
+ SETUP::
+
+ sage: from mjo.eja.eja_algebra import JordanSpinEJA
+
+ EXAMPLES::
+
+ sage: J = JordanSpinEJA(3)
+ sage: x,y,z = J.random_elements(3)
+ sage: all( [ x in J, y in J, z in J ])
+ True
+ sage: len( J.random_elements(10) ) == 10
+ True
+
+ """
+ return tuple( self.random_element() for idx in xrange(count) )
@classmethod
def random_instance(cls, field=QQ, **kwargs):
sage: set_random_seed()
sage: J = RealCartesianProductEJA.random_instance()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = J.random_elements(2)
sage: X = x.natural_representation()
sage: Y = y.natural_representation()
sage: x.inner_product(y) == J.natural_inner_product(X,Y)
sage: set_random_seed()
sage: J = RealSymmetricEJA.random_instance()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = J.random_elements(2)
sage: actual = (x*y).natural_representation()
sage: X = x.natural_representation()
sage: Y = y.natural_representation()
sage: set_random_seed()
sage: J = ComplexHermitianEJA.random_instance()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = J.random_elements(2)
sage: actual = (x*y).natural_representation()
sage: X = x.natural_representation()
sage: Y = y.natural_representation()
sage: set_random_seed()
sage: J = QuaternionHermitianEJA.random_instance()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = J.random_elements(2)
sage: actual = (x*y).natural_representation()
sage: X = x.natural_representation()
sage: Y = y.natural_representation()
sage: set_random_seed()
sage: J = JordanSpinEJA.random_instance()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = J.random_elements(2)
sage: X = x.natural_representation()
sage: Y = y.natural_representation()
sage: x.inner_product(y) == J.natural_inner_product(X,Y)
sage: set_random_seed()
sage: J = random_eja()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = J.random_elements(2)
sage: x.inner_product(y) in RR
True
Test Lemma 1 from Chapter III of Koecher::
sage: set_random_seed()
- sage: J = random_eja()
- sage: u = J.random_element()
- sage: v = J.random_element()
+ sage: u,v = random_eja().random_elements(2)
sage: lhs = u.operator_commutes_with(u*v)
sage: rhs = v.operator_commutes_with(u^2)
sage: lhs == rhs
Chapter III, or from Baes (2.3)::
sage: set_random_seed()
- sage: J = random_eja()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = random_eja().random_elements(2)
sage: Lx = x.operator()
sage: Ly = y.operator()
sage: Lxx = (x*x).operator()
Baes (2.4)::
sage: set_random_seed()
- sage: J = random_eja()
- sage: x = J.random_element()
- sage: y = J.random_element()
- sage: z = J.random_element()
+ sage: x,y,z = random_eja().random_elements(3)
sage: Lx = x.operator()
sage: Ly = y.operator()
sage: Lz = z.operator()
Baes (2.5)::
sage: set_random_seed()
- sage: J = random_eja()
- sage: u = J.random_element()
- sage: y = J.random_element()
- sage: z = J.random_element()
+ sage: u,y,z = random_eja().random_elements(3)
sage: Lu = u.operator()
sage: Ly = y.operator()
sage: Lz = z.operator()
sage: set_random_seed()
sage: J = random_eja().random_element().subalgebra_generated_by()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = J.random_elements(2)
sage: (x*y).det() == x.det()*y.det()
True
sage: set_random_seed()
sage: J = random_eja()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = J.random_elements(2)
sage: x.operator()(y) == x*y
True
sage: y.operator()(x) == x*y
sage: set_random_seed()
sage: J = random_eja()
- sage: x = J.random_element()
- sage: y = J.random_element()
+ sage: x,y = J.random_elements(2)
sage: Lx = x.operator()
sage: Lxx = (x*x).operator()
sage: Qx = x.quadratic_representation()
sage: set_random_seed()
sage: x0 = random_eja().random_element()
sage: A = x0.subalgebra_generated_by()
- sage: x = A.random_element()
- sage: y = A.random_element()
- sage: z = A.random_element()
+ sage: x,y,z = A.random_elements(3)
sage: (x*y)*z == x*(y*z)
True
sage: set_random_seed()
sage: J = random_eja()
- sage: x = J.random_element();
- sage: y = J.random_element()
- sage: z = J.random_element()
+ sage: x,y,z = J.random_elements(3)
sage: # commutative
sage: x.trace_inner_product(y) == y.trace_inner_product(x)
True