]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
mjo/clan: move one() into the NormalDecomposition class
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 24 Jan 2026 15:09:11 +0000 (10:09 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 24 Jan 2026 15:09:11 +0000 (10:09 -0500)
We know this in terms of the idempotents, whatever they are.

mjo/clan/unital_clan.py

index 40fe94e5970d7f04051b8ffd9fbcf5ba4d55190e..9079af86593663af540a069a936ab86ec0d75ba0 100644 (file)
@@ -123,13 +123,6 @@ class NormalDecomposition(UnitalClan):
                          prefix=None,
                          bracket=False)
 
-    def rank(self) -> int:
-        r"""
-        The rank of this clan. Not implemented by default,
-        because it is only easy to deduce from a normal decomposition.
-        """
-        return self._rank
-
     def idempotent(self, i):
         r"""
         Return the i'th idempotent in this clan.
@@ -151,6 +144,44 @@ class NormalDecomposition(UnitalClan):
             if j == i and k == i
         )
 
+    def one(self):
+        r"""
+        Return the unit element of this clan.
+
+        EXAMPLES::
+
+            sage: C = SnClan(4)
+            sage: I = C.one()
+            sage: I.lift().lift()
+            [1 0 0 0]
+            [0 1 0 0]
+            [0 0 1 0]
+            [0 0 0 1]
+            sage: all( I*b == b and b*I == b for b in C.basis() )
+            True
+
+        """
+        return self.sum_of_monomials(
+            (i,j,k)
+            for (i,j,k) in self.indices()
+            if i == j
+        )
+
+    def rank(self) -> int:
+        r"""
+        The rank of this clan. Only implemented for normal
+        decompositions because we don't know the rank until
+        we know the (number of) idempotents used for the
+        normal decomposition.
+
+        EXAMPLES::
+
+            sage: C = HnClan(2)
+            sage: C.rank()
+            2
+
+        """
+        return self._rank
 
 class SnClan(NormalDecomposition):
     r"""
@@ -302,26 +333,6 @@ class SnClan(NormalDecomposition):
         return f"Clan S^{self.rank()} over {self.base_ring()}"
 
 
-    def one(self):
-        r"""
-        Return the unit element of this clan.
-
-        EXAMPLES::
-
-            sage: C = SnClan(4)
-            sage: I = C.one()
-            sage: I.lift().lift()
-            [1 0 0 0]
-            [0 1 0 0]
-            [0 0 1 0]
-            [0 0 0 1]
-            sage: all( I*b == b and b*I == b for b in C.basis() )
-            True
-
-        """
-        return sum( self.basis()[i,i,1] for i in range(self.rank()) )
-
-
     def from_matrix(self, x):
         r"""
         Construct an element of this clan from a symmetric matrix.