]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: add the random_eja() function.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 4 Jul 2019 23:37:52 +0000 (19:37 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 29 Jul 2019 03:19:01 +0000 (23:19 -0400)
mjo/eja/euclidean_jordan_algebra.py

index c47f4003690905278904327e63ddaf7dcf9e0b44..5eb90fd45a03f1de6e826f8a985ef8dd701130c6 100644 (file)
@@ -658,3 +658,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)