]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: document why an a[0] access is safe.
[sage.d.git] / mjo / eja / eja_algebra.py
index 4091d03fd6a40351e7d4c2789847d1db6fa0e807..ded2df691d95eca3f4b9d25c8b0c77330b5b0c5a 100644 (file)
@@ -1006,8 +1006,10 @@ class MatrixEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebra):
             # we simply undo the basis_normalizer scaling that we
             # performed earlier.
             #
-            # TODO: make this access safe.
-            XS = a[0].variables()
+            # The a[0] access here is safe because trivial algebras
+            # won't have any basis normalizers and therefore won't
+            # make it to this "else" branch.
+            XS = a[0].parent().gens()
             subs_dict = { XS[i]: self._basis_normalizers[i]*XS[i]
                           for i in range(len(XS)) }
             return tuple( a_i.subs(subs_dict) for a_i in a )
@@ -1028,6 +1030,9 @@ class MatrixEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebra):
         # is supposed to hold the entire long vector, and the subspace W
         # of V will be spanned by the vectors that arise from symmetric
         # matrices. Thus for S^2, dim(V) == 4 and dim(W) == 3.
+        if len(basis) == 0:
+            return []
+
         field = basis[0].base_ring()
         dimension = basis[0].nrows()
 
@@ -1185,6 +1190,11 @@ class RealSymmetricEJA(RealMatrixEuclideanJordanAlgebra):
         sage: x.operator().matrix().is_symmetric()
         True
 
+    We can construct the (trivial) algebra of rank zero::
+
+        sage: RealSymmetricEJA(0)
+        Euclidean Jordan algebra of dimension 0 over Algebraic Real Field
+
     """
     @classmethod
     def _denormalized_basis(cls, n, field):
@@ -1458,6 +1468,11 @@ class ComplexHermitianEJA(ComplexMatrixEuclideanJordanAlgebra):
         sage: x.operator().matrix().is_symmetric()
         True
 
+    We can construct the (trivial) algebra of rank zero::
+
+        sage: ComplexHermitianEJA(0)
+        Euclidean Jordan algebra of dimension 0 over Algebraic Real Field
+
     """
 
     @classmethod
@@ -1753,6 +1768,11 @@ class QuaternionHermitianEJA(QuaternionMatrixEuclideanJordanAlgebra):
         sage: x.operator().matrix().is_symmetric()
         True
 
+    We can construct the (trivial) algebra of rank zero::
+
+        sage: QuaternionHermitianEJA(0)
+        Euclidean Jordan algebra of dimension 0 over Algebraic Real Field
+
     """
     @classmethod
     def _denormalized_basis(cls, n, field):