From edf66662687e7816871363772214a15cef67d481 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 19 Jul 2019 14:09:26 -0400 Subject: [PATCH] eja: factor out mat2vec() and vec2mat() helper functions. --- mjo/eja/euclidean_jordan_algebra.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index a73cfaf..e30c341 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -1057,6 +1057,12 @@ def _complex_hermitian_basis(n, field=QQ): return tuple(S) +def _mat2vec(m): + return vector(m.base_ring(), m.list()) + +def _vec2mat(v): + return matrix(v.base_ring(), sqrt(v.degree()), v.list()) + def _multiplication_table_from_matrix_basis(basis): """ At least three of the five simple Euclidean Jordan algebras have the @@ -1077,19 +1083,13 @@ def _multiplication_table_from_matrix_basis(basis): field = basis[0].base_ring() dimension = basis[0].nrows() - def mat2vec(m): - return vector(field, m.list()) - - def vec2mat(v): - return matrix(field, dimension, v.list()) - V = VectorSpace(field, dimension**2) - W = V.span( mat2vec(s) for s in basis ) + W = V.span( _mat2vec(s) for s in basis ) # 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 = tuple( vec2mat(b) for b in W.basis() ) + S = tuple( _vec2mat(b) for b in W.basis() ) Qs = [] for s in S: @@ -1102,7 +1102,7 @@ def _multiplication_table_from_matrix_basis(basis): # why we're computing rows here and not columns. Q_rows = [] for t in S: - this_row = mat2vec((s*t + t*s)/2) + this_row = _mat2vec((s*t + t*s)/2) Q_rows.append(W.coordinates(this_row)) Q = matrix(field, W.dimension(), Q_rows) Qs.append(Q) -- 2.44.2