Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/sage/rings/number_field/class_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,20 @@
"""
return self.ideal().gens()

class NarrowFractionalIdealClass(FractionalIdealClass):

Check failure on line 324 in src/sage/rings/number_field/class_group.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (E302)

src/sage/rings/number_field/class_group.py:324:1: E302 Expected 2 blank lines, found 1
def _repr_(self):
r"""
Return a string representation of the narrow ideal class of this fractional ideal.

EXAMPLES::

"""
if self.is_trivial():
return 'Trivial narrow ideal class'
return 'Fractional narrow ideal class %s' % self._value._repr_short()

Check warning on line 334 in src/sage/rings/number_field/class_group.py

View check run for this annotation

Codecov / codecov/patch

src/sage/rings/number_field/class_group.py#L332-L334

Added lines #L332 - L334 were not covered by tests
pass

class SFractionalIdealClass(FractionalIdealClass):

Check failure on line 337 in src/sage/rings/number_field/class_group.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (E302)

src/sage/rings/number_field/class_group.py:337:1: E302 Expected 2 blank lines, found 1
r"""
An `S`-fractional ideal class in a number field for a tuple `S` of primes.

Expand Down Expand Up @@ -628,8 +640,26 @@
"""
return self._number_field

class NarrowClassGroup(ClassGroup):

Check failure on line 643 in src/sage/rings/number_field/class_group.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (E302)

src/sage/rings/number_field/class_group.py:643:1: E302 Expected 2 blank lines, found 1
Element = NarrowFractionalIdealClass

def __init__(self, gens_orders, names, number_field, gens, proof=True):
r"""
Create a narrow class group.
"""
AbelianGroupWithValues_class.__init__(self, gens_orders, names, gens,
values_group=number_field.ideal_monoid())
self._proof_flag = proof
self._number_field = number_field

def _repr_(self):
s = 'Narrow class group of order %s ' % self.order()
if self.order() > 1:
s += 'with structure %s ' % self._group_notation(self.gens_orders())
s += 'of %s' % self.number_field()
return s

class SClassGroup(ClassGroup):

Check failure on line 662 in src/sage/rings/number_field/class_group.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (E302)

src/sage/rings/number_field/class_group.py:662:1: E302 Expected 2 blank lines, found 1
r"""
The `S`-class group of a number field.

Expand Down
25 changes: 19 additions & 6 deletions src/sage/rings/number_field/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -6706,7 +6706,7 @@
return S

@cached_method
def narrow_class_group(self, proof=None):
def narrow_class_group(self, proof=None, names='c'):
r"""
Return the narrow class group of this field.

Expand All @@ -6719,19 +6719,32 @@

sage: x = polygen(QQ, 'x')
sage: NumberField(x^3 + x + 9, 'a').narrow_class_group()
Multiplicative Abelian group isomorphic to C2
Narrow class group of order 2 with structure C2 of Number Field in a with defining polynomial x^3 + x + 9

TESTS::

sage: QuadraticField(3, 'a').narrow_class_group()
Multiplicative Abelian group isomorphic to C2
Narrow class group of order 2 with structure C2 of Number Field in a with defining polynomial x^2 - 3 with a = 1.732050807568878?
"""
from sage.groups.abelian_gps.abelian_group import AbelianGroup
from .class_group import NarrowClassGroup

proof = proof_flag(proof)
try:
return self.__narrow_class_group[proof, names]
except KeyError:
pass

Check warning on line 6735 in src/sage/rings/number_field/number_field.py

View check run for this annotation

Codecov / codecov/patch

src/sage/rings/number_field/number_field.py#L6735

Added line #L6735 was not covered by tests
except AttributeError:
self.__narrow_class_group = {}
k = self.pari_bnf(proof)
s = k.bnfnarrow().sage()
return AbelianGroup(s[1])
s = k.bnfnarrow()
cycle_structure = tuple(s[1].sage())

# Gens is a list of ideals (the generators)
gens = tuple(self.ideal(hnf) for hnf in s[2])

G = NarrowClassGroup(cycle_structure, names, self, gens, proof=proof)
self.__narrow_class_group[proof, names] = G
return G

def ngens(self):
"""
Expand Down
Loading