From: Michael Orlitzky Date: Sat, 24 Jan 2026 15:09:11 +0000 (-0500) Subject: mjo/clan: move one() into the NormalDecomposition class X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=b51095cbcb34473d01cffba9bde054b30c8f1ca4;p=sage.d.git mjo/clan: move one() into the NormalDecomposition class We know this in terms of the idempotents, whatever they are. --- diff --git a/mjo/clan/unital_clan.py b/mjo/clan/unital_clan.py index 40fe94e..9079af8 100644 --- a/mjo/clan/unital_clan.py +++ b/mjo/clan/unital_clan.py @@ -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.