Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cardinality of special linear group #36881

Merged
9 changes: 3 additions & 6 deletions src/sage/categories/finite_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,9 @@ def cardinality(self):
sage: G.cardinality()
384
"""
try:
o = self.order
except AttributeError:
return self._cardinality_from_iterator()
else:
return o()
if hasattr(self, 'order'):
return self.order()
return self._cardinality_from_iterator()

def some_elements(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/libgap_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class ParentLibGAP(SageObject):

def minimal_normal_subgroups(self):
"""
Return the nontrivial minimal normal subgroups ``self``.
Return the nontrivial minimal normal subgroups of ``self``.
EXAMPLES::
Expand Down
48 changes: 48 additions & 0 deletions src/sage/groups/matrix_gps/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
from sage.groups.matrix_gps.named_group import (
normalize_args_vectorspace, NamedMatrixGroup_generic)
from sage.misc.latex import latex
from sage.misc.misc_c import prod
from sage.rings.infinity import Infinity


###############################################################################
Expand Down Expand Up @@ -307,3 +309,49 @@ def _check_matrix(self, x, *args):
else:
if x.determinant() == 0:
raise TypeError('matrix must non-zero determinant')

def order(self):
"""
Return the order of ``self``.

EXAMPLES::

sage: G = SL(3, GF(5))
sage: G.order()
372000

TESTS:

Check if :trac:`36876` is fixed::

sage: SL(1, QQ).order()
1
sage: SL(2, ZZ).cardinality()
+Infinity

Check if :trac:`35490` is fixed::

sage: q = 7
sage: FqT.<T> = GF(q)[]
sage: N = T^2+1
sage: FqTN = QuotientRing(FqT, N*FqT)
sage: S = SL(2, FqTN)
sage: S.is_finite()
True
sage: S.order()
117600
"""
n = self.degree()

if self.base_ring().is_finite():
q = self.base_ring().order()
ord = prod(q**n - q**i for i in range(n))
if self._special:
return ord / (q-1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be //.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly yes, but it doesn't look serious to me. Since this ticket is about to be merged, please open a new one!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but also no, rational numbers behave weirdly, e.g. is_prime(7 / 1) is False. But I will open a new PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grhkm21, have you made another PR for the changes you suggested? If not then, should I create a new PR for this?

return ord

if self._special and n == 1:
return 1
return Infinity

cardinality = order
Loading