]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: fix some tests, speed improvements.
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 9 Mar 2021 17:04:37 +0000 (12:04 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 9 Mar 2021 17:04:37 +0000 (12:04 -0500)
mjo/eja/eja_algebra.py
mjo/matrix_algebra.py

index 106a0cddec06355a952e71d75699677b25dd7da9..7255533072acda6e0a92664b2d2439004a0beb95 100644 (file)
@@ -1021,7 +1021,8 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
 
             sage: J = ComplexHermitianEJA(2,field=QQ,orthonormalize=False)
             sage: J.matrix_space()
-            Full MatrixSpace of 4 by 4 dense matrices over Rational Field
+            Module of 2 by 2 matrices with entries in Algebraic Field over
+            the scalar ring Rational Field
             sage: J = QuaternionHermitianEJA(1,field=QQ,orthonormalize=False)
             sage: J.matrix_space()
             Module of 1 by 1 matrices with entries in Quaternion
@@ -2162,6 +2163,7 @@ class OctonionHermitianEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA):
 
         sage: from mjo.eja.eja_algebra import (FiniteDimensionalEJA,
         ....:                                  OctonionHermitianEJA)
+        sage: from mjo.hurwitz import Octonions, OctonionMatrixAlgebra
 
     EXAMPLES:
 
@@ -2176,7 +2178,8 @@ class OctonionHermitianEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA):
     After a change-of-basis, the 2-by-2 algebra has the same
     multiplication table as the ten-dimensional Jordan spin algebra::
 
-        sage: b = OctonionHermitianEJA._denormalized_basis(2,QQ)
+        sage: A = OctonionMatrixAlgebra(2,Octonions(QQ),QQ)
+        sage: b = OctonionHermitianEJA._denormalized_basis(A)
         sage: basis = (b[0] + b[9],) + b[1:9] + (b[0] - b[9],)
         sage: jp = OctonionHermitianEJA.jordan_product
         sage: ip = OctonionHermitianEJA.trace_inner_product
@@ -2955,11 +2958,13 @@ class CartesianProductEJA(FiniteDimensionalEJA):
             sage: J2 = ComplexHermitianEJA(1)
             sage: J = cartesian_product([J1,J2])
             sage: J.one().to_matrix()[0]
-            [1 0]
-            [0 1]
+            +---+
+            | 1 |
+            +---+
             sage: J.one().to_matrix()[1]
-            [1 0]
-            [0 1]
+            +---+
+            | 1 |
+            +---+
 
         ::
 
index 73286ff452adf3323a9fdf534dfbeba8c6777bbd..bd173eaba835b8b82632587e62fcf6a8e7ec4e44 100644 (file)
@@ -185,9 +185,8 @@ class MatrixAlgebra(CombinatorialFreeModule):
         if "Unital" in entry_algebra.category().axioms():
             category = category.Unital()
             entry_one = entry_algebra.one()
-            self.one = lambda: sum( (self.monomial((i,i,entry_one))
-                                     for i in range(self.nrows()) ),
-                                    self.zero() )
+            self.one = lambda: self.sum( (self.monomial((i,i,entry_one))
+                                     for i in range(self.nrows()) ) )
 
         if "Associative" in entry_algebra.category().axioms():
             category = category.Associative()
@@ -352,9 +351,10 @@ class MatrixAlgebra(CombinatorialFreeModule):
             # We have to convert alpha_g because a priori it lives in the
             # base ring of the entry algebra.
             R = self.base_ring()
-            return self.sum( R(alpha_g)*self.monomial( (i,l,g) )
-                             for (alpha_g, g)
-                             in zip(p, self.entry_algebra_gens()))
+            return self.sum_of_terms( (((i,l,g), R(alpha_g))
+                                      for (alpha_g, g)
+                                      in zip(p, self.entry_algebra_gens()) ),
+                                      distinct=True)
         else:
             return self.zero()
 
@@ -414,9 +414,10 @@ class MatrixAlgebra(CombinatorialFreeModule):
             # We have to convert alpha_g because a priori it lives in the
             # base ring of the entry algebra.
             R = self.base_ring()
-            return self.sum( R(alpha_g)*self.monomial( (i,j,g) )
-                             for (alpha_g, g)
-                             in zip(p, self.entry_algebra_gens()))
+            return self.sum_of_terms( (((i,j,g), R(alpha_g))
+                                      for (alpha_g, g)
+                                      in zip(p, self.entry_algebra_gens()) ),
+                                      distinct=True)
 
         return self.sum( entry_to_element(i,j,entries[i][j])
                          for j in range(ncols)