From 9708043704809263d2bd543de38c46b458b873cb Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 27 Nov 2020 08:00:26 -0500 Subject: [PATCH] eja: begin working on a new constructor. --- mjo/eja/eja_algebra.py | 69 ++++++++++++++++++++++++++++++++++++++++++ mjo/eja/eja_utils.py | 5 +++ 2 files changed, 74 insertions(+) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index adcf755..44d8314 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -1025,6 +1025,75 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): Element = FiniteDimensionalEuclideanJordanAlgebraElement +class RationalBasisEuclideanJordanAlgebraNg(FiniteDimensionalEuclideanJordanAlgebra): + def __init__(self, + field, + basis, + jordan_product, + inner_product, + orthonormalize=True, + prefix='e', + category=None, + check_field=True, + check_axioms=True): + + n = len(basis) + vector_basis = basis + + from sage.matrix.matrix import is_Matrix + basis_is_matrices = False + + degree = 0 + if n > 0: + if is_Matrix(basis[0]): + basis_is_matrices = True + vector_basis = tuple( map(_mat2vec,basis) ) + degree = basis[0].nrows()**2 + else: + degree = basis[0].degree() + + V = VectorSpace(field, degree) + + self._deorthonormalization_matrix = matrix.identity(field,n) + if orthonormalize: + A = matrix(field, vector_basis) + # uh oh, this is only the "usual" inner product + Q,R = A.gram_schmidt(orthonormal=True) + self._deorthonormalization_matrix = R.inverse().transpose() + vector_basis = Q.rows() + W = V.span_of_basis( vector_basis ) + if basis_is_matrices: + from mjo.eja.eja_utils import _vec2mat + basis = tuple( map(_vec2mat,vector_basis) ) + + mult_table = [ [0 for i in range(n)] for j in range(n) ] + ip_table = [ [0 for i in range(n)] for j in range(n) ] + + for i in range(n): + for j in range(i+1): + # do another mat2vec because the multiplication + # table is in terms of vectors + elt = _mat2vec(jordan_product(basis[i],basis[j])) + elt = W.coordinate_vector(elt) + mult_table[i][j] = elt + mult_table[j][i] = elt + ip = inner_product(basis[i],basis[j]) + ip_table[i][j] = ip + ip_table[j][i] = ip + + self._inner_product_matrix = matrix(field,ip_table) + + if basis_is_matrices: + for m in basis: + m.set_immutable() + + super().__init__(field, + mult_table, + prefix, + category, + basis, + check_field, + check_axioms) class RationalBasisEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebra): r""" diff --git a/mjo/eja/eja_utils.py b/mjo/eja/eja_utils.py index b6b0a03..cbbf1e3 100644 --- a/mjo/eja/eja_utils.py +++ b/mjo/eja/eja_utils.py @@ -1,4 +1,9 @@ +from sage.functions.other import sqrt +from sage.matrix.constructor import matrix from sage.modules.free_module_element import vector def _mat2vec(m): return vector(m.base_ring(), m.list()) + +def _vec2mat(v): + return matrix(v.base_ring(), sqrt(v.degree()), v.list()) -- 2.44.2