X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feuclidean_jordan_algebra.py;h=802171fb0c4cc029c43d4fb4b17004d76bb938ed;hb=d08aa61e7c6adc5d6bed4c23797959c483b021bb;hp=c47f4003690905278904327e63ddaf7dcf9e0b44;hpb=eb48c4d6ce3591d116c85b3f4ab9d1ebb1095367;p=sage.d.git diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index c47f400..802171f 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -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() @@ -640,8 +641,16 @@ def eja_sn(dimension, field=QQ): def mat2vec(m): return vector(field, m.list()) + def vec2mat(v): + return matrix(field, dimension, v.list()) + W = V.span( mat2vec(s) for s in S ) + # Taking the span above reorders our basis (thanks, jerk!) so we + # need to put our "matrix basis" in the same order as the + # (reordered) vector basis. + S = [ vec2mat(b) for b in W.basis() ] + for s in S: # Brute force the multiplication-by-s matrix by looping # through all elements of the basis and doing the computation @@ -658,3 +667,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)