vector representations) back and forth faithfully::
sage: set_random_seed()
- sage: J = RealCartesianProductEJA(5)
+ sage: J = RealCartesianProductEJA.random_instance()
sage: x = J.random_element()
sage: J(x.to_vector().column()) == x
True
- sage: J = JordanSpinEJA(5)
+ sage: J = JordanSpinEJA.random_instance()
sage: x = J.random_element()
sage: J(x.to_vector().column()) == x
True
return s.random_element()
+ @classmethod
+ def random_instance(cls, field=QQ, **kwargs):
+ """
+ Return a random instance of this type of algebra.
+
+ In subclasses for algebras that we know how to construct, this
+ is a shortcut for constructing test cases and examples.
+ """
+ if cls is FiniteDimensionalEuclideanJordanAlgebra:
+ # Red flag! But in theory we could do this I guess. The
+ # only finite-dimensional exceptional EJA is the
+ # octononions. So, we could just create an EJA from an
+ # associative matrix algebra (generated by a subset of
+ # elements) with the symmetric product. Or, we could punt
+ # to random_eja() here, override it in our subclasses, and
+ # not worry about it.
+ raise NotImplementedError
+
+ n = ZZ.random_element(1, cls._max_test_case_size())
+ return cls(n, field, **kwargs)
+
+
def rank(self):
"""
Return the rank of this EJA.
Our inner product satisfies the Jordan axiom::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: J = RealCartesianProductEJA(n)
+ sage: J = RealCartesianProductEJA.random_instance()
sage: x = J.random_element()
sage: y = J.random_element()
sage: z = J.random_element()
over `R^n`::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: J = RealCartesianProductEJA(n)
+ sage: J = RealCartesianProductEJA.random_instance()
sage: x = J.random_element()
sage: y = J.random_element()
sage: X = x.natural_representation()
Euclidean Jordan algebra of dimension...
"""
- constructor = choice([RealCartesianProductEJA,
- JordanSpinEJA,
- RealSymmetricEJA,
- ComplexHermitianEJA,
- QuaternionHermitianEJA])
- n = ZZ.random_element(1, constructor._max_test_case_size())
- return constructor(n, field=QQ)
+ classname = choice([RealCartesianProductEJA,
+ JordanSpinEJA,
+ RealSymmetricEJA,
+ ComplexHermitianEJA,
+ QuaternionHermitianEJA])
+ return classname.random_instance()
SETUP::
- sage: from mjo.eja.eja_algebra import _embed_complex_matrix
+ sage: from mjo.eja.eja_algebra import (_embed_complex_matrix,
+ ....: ComplexHermitianEJA)
EXAMPLES::
Embedding is a homomorphism (isomorphism, in fact)::
sage: set_random_seed()
- sage: n = ZZ.random_element(5)
+ sage: n_max = ComplexHermitianEJA._max_test_case_size()
+ sage: n = ZZ.random_element(n_max)
sage: F = QuadraticField(-1, 'i')
sage: X = random_matrix(F, n)
sage: Y = random_matrix(F, n)
SETUP::
- sage: from mjo.eja.eja_algebra import _embed_quaternion_matrix
+ sage: from mjo.eja.eja_algebra import (_embed_quaternion_matrix,
+ ....: QuaternionHermitianEJA)
EXAMPLES::
Embedding is a homomorphism (isomorphism, in fact)::
sage: set_random_seed()
- sage: n = ZZ.random_element(5)
+ sage: n_max = QuaternionHermitianEJA._max_test_case_size()
+ sage: n = ZZ.random_element(n_max)
sage: Q = QuaternionAlgebra(QQ,-1,-1)
sage: X = random_matrix(Q, n)
sage: Y = random_matrix(Q, n)
The dimension of this algebra is `(n^2 + n) / 2`::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
+ sage: n_max = RealSymmetricEJA._max_test_case_size()
+ sage: n = ZZ.random_element(1, n_max)
sage: J = RealSymmetricEJA(n)
sage: J.dimension() == (n^2 + n)/2
True
The Jordan multiplication is what we think it is::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: J = RealSymmetricEJA(n)
+ sage: J = RealSymmetricEJA.random_instance()
sage: x = J.random_element()
sage: y = J.random_element()
sage: actual = (x*y).natural_representation()
Our inner product satisfies the Jordan axiom::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: J = RealSymmetricEJA(n)
+ sage: J = RealSymmetricEJA.random_instance()
sage: x = J.random_element()
sage: y = J.random_element()
sage: z = J.random_element()
product unless we specify otherwise::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: J = RealSymmetricEJA(n)
+ sage: J = RealSymmetricEJA.random_instance()
sage: all( b.norm() == 1 for b in J.gens() )
True
the operator is self-adjoint by the Jordan axiom::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: x = RealSymmetricEJA(n).random_element()
+ sage: x = RealSymmetricEJA.random_instance().random_element()
sage: x.operator().matrix().is_symmetric()
True
The dimension of this algebra is `n^2`::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
+ sage: n_max = ComplexHermitianEJA._max_test_case_size()
+ sage: n = ZZ.random_element(1, n_max)
sage: J = ComplexHermitianEJA(n)
sage: J.dimension() == n^2
True
The Jordan multiplication is what we think it is::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: J = ComplexHermitianEJA(n)
+ sage: J = ComplexHermitianEJA.random_instance()
sage: x = J.random_element()
sage: y = J.random_element()
sage: actual = (x*y).natural_representation()
Our inner product satisfies the Jordan axiom::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: J = ComplexHermitianEJA(n)
+ sage: J = ComplexHermitianEJA.random_instance()
sage: x = J.random_element()
sage: y = J.random_element()
sage: z = J.random_element()
product unless we specify otherwise::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,4)
- sage: J = ComplexHermitianEJA(n)
+ sage: J = ComplexHermitianEJA.random_instance()
sage: all( b.norm() == 1 for b in J.gens() )
True
the operator is self-adjoint by the Jordan axiom::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: x = ComplexHermitianEJA(n).random_element()
+ sage: x = ComplexHermitianEJA.random_instance().random_element()
sage: x.operator().matrix().is_symmetric()
True
The dimension of this algebra is `2*n^2 - n`::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,4)
+ sage: n_max = QuaternionHermitianEJA._max_test_case_size()
+ sage: n = ZZ.random_element(1, n_max)
sage: J = QuaternionHermitianEJA(n)
sage: J.dimension() == 2*(n^2) - n
True
The Jordan multiplication is what we think it is::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,4)
- sage: J = QuaternionHermitianEJA(n)
+ sage: J = QuaternionHermitianEJA.random_instance()
sage: x = J.random_element()
sage: y = J.random_element()
sage: actual = (x*y).natural_representation()
Our inner product satisfies the Jordan axiom::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,4)
- sage: J = QuaternionHermitianEJA(n)
+ sage: J = QuaternionHermitianEJA.random_instance()
sage: x = J.random_element()
sage: y = J.random_element()
sage: z = J.random_element()
product unless we specify otherwise::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,4)
- sage: J = QuaternionHermitianEJA(n)
+ sage: J = QuaternionHermitianEJA.random_instance()
sage: all( b.norm() == 1 for b in J.gens() )
True
the operator is self-adjoint by the Jordan axiom::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: x = QuaternionHermitianEJA(n).random_element()
+ sage: x = QuaternionHermitianEJA.random_instance().random_element()
sage: x.operator().matrix().is_symmetric()
True
Our inner product satisfies the Jordan axiom::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: J = JordanSpinEJA(n)
+ sage: J = JordanSpinEJA.random_instance()
sage: x = J.random_element()
sage: y = J.random_element()
sage: z = J.random_element()
over `R^n`::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: J = JordanSpinEJA(n)
+ sage: J = JordanSpinEJA.random_instance()
sage: x = J.random_element()
sage: y = J.random_element()
sage: X = x.natural_representation()
Example 11.11::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,10)
- sage: J = JordanSpinEJA(n)
+ sage: J = JordanSpinEJA.random_instance()
sage: x = J.random_element()
sage: while not x.is_invertible():
....: x = J.random_element()
aren't multiples of the identity are regular::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,10)
- sage: J = JordanSpinEJA(n)
+ sage: J = JordanSpinEJA.random_instance()
sage: x = J.random_element()
sage: x == x.coefficient(0)*J.one() or x.degree() == 2
True
The minimal polynomial and the characteristic polynomial coincide
and are known (see Alizadeh, Example 11.11) for all elements of
the spin factor algebra that aren't scalar multiples of the
- identity::
+ identity. We require the dimension of the algebra to be at least
+ two here so that said elements actually exist::
sage: set_random_seed()
- sage: n = ZZ.random_element(2,10)
+ sage: n_max = max(2, JordanSpinEJA._max_test_case_size())
+ sage: n = ZZ.random_element(2, n_max)
sage: J = JordanSpinEJA(n)
sage: y = J.random_element()
sage: while y == y.coefficient(0)*J.one():
and in particular, a re-scaling of the basis::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,5)
- sage: J1 = RealSymmetricEJA(n)
+ sage: n_max = RealSymmetricEJA._max_test_case_size()
+ sage: n = ZZ.random_element(1, n_max)
+ sage: J1 = RealSymmetricEJA(n,QQ)
sage: J2 = RealSymmetricEJA(n,QQ,False)
sage: X = random_matrix(QQ,n)
sage: X = X*X.transpose()
Alizadeh's Example 11.12::
sage: set_random_seed()
- sage: n = ZZ.random_element(1,10)
- sage: J = JordanSpinEJA(n)
- sage: x = J.random_element()
+ sage: x = JordanSpinEJA.random_instance().random_element()
sage: x_vec = x.to_vector()
+ sage: n = x_vec.degree()
sage: x0 = x_vec[0]
sage: x_bar = x_vec[1:]
sage: A = matrix(QQ, 1, [x_vec.inner_product(x_vec)])