]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/euclidean_jordan_algebra.py
eja: add missing set_random_seed() call.
[sage.d.git] / mjo / eja / euclidean_jordan_algebra.py
index f71f75d690054a0facd849de639d7a0ead3b8cbe..52a8a74634dbec03744324634ccefbaa3bd82c06 100644 (file)
@@ -384,6 +384,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
             Squaring in the subalgebra should be the same thing as
             squaring in the superalgebra::
 
+                sage: set_random_seed()
                 sage: J = eja_ln(5)
                 sage: x = J.random_element()
                 sage: u = x.subalgebra_generated_by().random_element()
@@ -643,9 +644,13 @@ def eja_sn(dimension, field=QQ):
     W = V.span( mat2vec(s) for s in S )
 
     for s in S:
-        # Brute force the right-multiplication-by-s matrix by looping
+        # Brute force the multiplication-by-s matrix by looping
         # through all elements of the basis and doing the computation
-        # to find out what the corresponding row should be.
+        # to find out what the corresponding row should be. BEWARE:
+        # these multiplication tables won't be symmetric! It therefore
+        # becomes REALLY IMPORTANT that the underlying algebra
+        # constructor uses ROW vectors and not COLUMN vectors. That's
+        # why we're computing rows here and not columns.
         Q_rows = []
         for t in S:
             this_row = mat2vec((s*t + t*s)/2)
@@ -654,3 +659,34 @@ def eja_sn(dimension, field=QQ):
         Qs.append(Q)
 
     return FiniteDimensionalEuclideanJordanAlgebra(field,Qs,rank=dimension)
+
+
+def random_eja():
+    """
+    Return a "random" finite-dimensional Euclidean Jordan Algebra.
+
+    ALGORITHM:
+
+    For now, we choose a random natural number ``n`` (greater than zero)
+    and then give you back one of the following:
+
+      * The cartesian product of the rational numbers ``n`` times; this is
+        ``QQ^n`` with the Hadamard product.
+
+      * The Jordan spin algebra on ``QQ^n``.
+
+      * The ``n``-by-``n`` rational symmetric matrices with the symmetric
+        product.
+
+    Later this might be extended to return Cartesian products of the
+    EJAs above.
+
+    TESTS::
+
+        sage: random_eja()
+        Euclidean Jordan algebra of degree...
+
+    """
+    n = ZZ.random_element(1,10).abs()
+    constructor = choice([eja_rn, eja_ln, eja_sn])
+    return constructor(dimension=n, field=QQ)