#14366: Zero does not belong to zero ideal of a number field
-----------------------------------+--------------------------------
Reporter: olitb | Owner: davidloeffler
Type: defect | Status: positive_review
Priority: major | Milestone: sage-5.11
Component: number fields | Resolution:
Keywords: sd51 | Merged in:
Authors: Michiel Kosters | Reviewers: David Loeffler
Report Upstream: N/A | Work issues:
Branch: | Dependencies:
Stopgaps: |
-----------------------------------+--------------------------------
Description changed by davidloeffler:
Old description:
> The following is mathematically wrong:
>
> {{{
> sage: 0 in CyclotomicField(3).ideal(0)
> False
> }}}
>
> It comes from the function _contains_(self, x) in the class
> NumberFieldIdeal (file sage/rings/number_field/number_field_ideal.py),
> which tries to compute the coordinates of the element in a basis (over
> ZZ) of the ideal. The function coordinates(self, x) fails for the zero
> ideal, raising a TypeError (in fact when _contains_ is called directly, a
> TypeError is raised).
> A workaround is to replace
>
> {{{
> def _contains_(self, x):
> return self.coordinates(self.number_field()(x)).denominator() == 1
> }}}
>
> with
>
> {{{
> def _contains_(self, x):
> return x==0 or self.coordinates(self.number_field()(x)).denominator()
> == 1
> }}}
>
> but I am not sure if it is the "right" way to do it.
> Is it desirable to have the _contains_ function in sage/rings/ideal.py
> catch the TypeError (silently)?
New description:
The following is mathematically wrong:
{{{
sage: 0 in CyclotomicField(3).ideal(0)
False
}}}
It comes from the function _contains_(self, x) in the class
NumberFieldIdeal (file sage/rings/number_field/number_field_ideal.py),
which tries to compute the coordinates of the element in a basis (over ZZ)
of the ideal. The function coordinates(self, x) fails for the zero ideal,
raising a TypeError (in fact when _contains_ is called directly, a
TypeError is raised).
A workaround is to replace
{{{
def _contains_(self, x):
return self.coordinates(self.number_field()(x)).denominator() == 1
}}}
with
{{{
def _contains_(self, x):
return x==0 or self.coordinates(self.number_field()(x)).denominator()
== 1
}}}
but I am not sure if it is the "right" way to do it.
Is it desirable to have the _contains_ function in sage/rings/ideal.py
catch the TypeError (silently)?
'''Apply [attachment:14366_metrod3.patch]'''
--
--
Ticket URL: <http://trac.sagemath.org/ticket/14366#comment:17>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.