Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Implemented prime_factors
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinywlui committed Aug 19, 2019
1 parent c1b9b26 commit 3df71d5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/sage/rings/number_field/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -3384,7 +3384,7 @@ def primes_above(self, x, degree=None):
sage: F.prime_above(0)
Traceback (most recent call last):
...
AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
ValueError: Does not make sense to factor (0)
"""
if degree is not None:
degree = ZZ(degree)
Expand Down Expand Up @@ -3479,7 +3479,7 @@ def prime_above(self, x, degree=None):
sage: F.prime_above(0)
Traceback (most recent call last):
...
AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
ValueError: Does not make sense to factor (0)
"""
ids = self.primes_above(x, degree)
Expand Down
42 changes: 36 additions & 6 deletions src/sage/rings/number_field/order_fractional_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ def _richcmp_(self, other, op):
return NotImplemented
return richcmp(self.free_module(), other.free_module(), op)

def is_zero(self):
r"""
Return whether this ideal is the zero ideal.
EXAMPLES::
sage: K.<a> = QuadraticField(5)
sage: O = K.order(a)
sage: O.ideal(0).is_zero()
True
"""
return all(x.is_zero() for x in self.gens())

@cached_method
def is_integral(self):
"""
Expand Down Expand Up @@ -200,14 +213,31 @@ def free_module(self):
"""
return basis_to_module(self.basis(), self.number_field())

# def prime_factors(self):
# O = self.order()
# OK = O.integral_closure()
def prime_factors(self):
r"""
Return a list of the prime ideal factors of `self`.
EXAMPLES::
In this example, 5 splits in `OK` but not in `O`. ::
sage: K.<a> = QuadraticField(-1)
sage: OK = K.maximal_order()
sage: O = K.order(5*a)
sage: OK.ideal(5).prime_factors()
[Fractional ideal (-a - 2), Fractional ideal (2*a + 1)]
sage: O.ideal(5).prime_factors()
[Fractional ideal (5, 5*a) of non-maximal order]
"""
if self.is_zero():
raise ValueError("Does not make sense to factor (0)")
O = self.order()
OK = O.integral_closure()

# aOK = OK.ideal(self.gens())
# above = aOK.prime_factors()
aOK = OK.ideal(self.gens())
above = aOK.prime_factors()

# return [O.intersection(p) for p in above]
return list(set(O.intersection(p) for p in above))


def basis_to_module(B, K):
Expand Down

0 comments on commit 3df71d5

Please sign in to comment.