From ee9ac102b8b392793466c13039a6e50b1e3c4c01 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 24 Feb 2021 21:17:21 -0500 Subject: [PATCH] eja: remove a completed TODO, and doctest it. --- mjo/eja/TODO | 5 +---- mjo/eja/eja_algebra.py | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/mjo/eja/TODO b/mjo/eja/TODO index 93aa9fb..1407ebd 100644 --- a/mjo/eja/TODO +++ b/mjo/eja/TODO @@ -14,9 +14,6 @@ RealSymmetricEJA(4): sage: F = J.base_ring() sage: a0 = (1/4)*X[4]**2*X[6]**2 - (1/2)*X[2]*X[5]*X[6]**2 - (1/2)*X[3]*X[4]*X[6]*X[7] + (F(2).sqrt()/2)*X[1]*X[5]*X[6]*X[7] + (1/4)*X[3]**2*X[7]**2 - (1/2)*X[0]*X[5]*X[7]**2 + (F(2).sqrt()/2)*X[2]*X[3]*X[6]*X[8] - (1/2)*X[1]*X[4]*X[6*X[8] - (1/2)*X[1]*X[3]*X[7]*X[8] + (F(2).sqrt()/2)*X[0]*X[4]*X[7]*X[8] + (1/4)*X[1]**2*X[8]**2 - (1/2)*X[0]*X[2]*X[8]**2 - (1/2)*X[2]*X[3]**2*X[9] + (F(2).sqrt()/2)*X[1]*X[3]*X[4]*X[9] - (1/2)*X[0]*X[4]**2*X[9] - (1/2)*X[1]**2*X[5]*X[9] + X[0]*X[2]*X[5]*X[9] -5. The main EJA element constructor is happy to convert between - e.g. HadamardEJA(3) and JordanSpinEJA(3). - -6. Profile the construction of "large" matrix algebras (like the +5. Profile the construction of "large" matrix algebras (like the 15-dimensional QuaternionHermitianAlgebra(3)) to find out why they're so slow. diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 618e09c..3a832c1 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -447,13 +447,23 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): sage: J(x.to_vector().column()) == x True + We cannot coerce elements between algebras just because their + matrix representations are compatible:: + + sage: J1 = HadamardEJA(3) + sage: J2 = JordanSpinEJA(3) + sage: J2(J1.one()) + Traceback (most recent call last): + ... + ValueError: not an element of this algebra + sage: J1(J2.zero()) + Traceback (most recent call last): + ... + ValueError: not an element of this algebra + """ msg = "not an element of this algebra" - if elt == 0: - # The superclass implementation of random_element() - # needs to be able to coerce "0" into the algebra. - return self.zero() - elif elt in self.base_ring(): + if elt in self.base_ring(): # Ensure that no base ring -> algebra coercion is performed # by this method. There's some stupidity in sage that would # otherwise propagate to this method; for example, sage thinks @@ -461,9 +471,11 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): raise ValueError(msg) try: + # Try to convert a vector into a column-matrix... elt = elt.column() except (AttributeError, TypeError): - # Try to convert a vector into a column-matrix + # and ignore failure, because we weren't really expecting + # a vector as an argument anyway. pass if elt not in self.matrix_space(): @@ -477,7 +489,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): # could be QQ instead of QQbar. # # And, we also have to handle Cartesian product bases (when - # the matric basis consists of tuples) here. The "good news" + # the matrix basis consists of tuples) here. The "good news" # is that we're already converting everything to long vectors, # and that strategy works for tuples as well. # -- 2.44.2