#10174: relative norm and trace in relative number fields are slow
------------------------------+---------------------------------------------
Reporter: thome | Owner: davidloeffler
Type: defect | Status: needs_work
Priority: minor | Milestone:
Component: number fields | Keywords:
Author: Emmanuel Thome | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
------------------------------+---------------------------------------------
Changes (by newvalueoldvalue):
* author: => Emmanuel Thome
Old description:
> There seems to be no relative_norm or absolute_norm method for elements
> of relative number fields (while there is for ideals). norm() works with
> an optional base parameter, which can be set to the base field for
> obtaining the relative norm.
>
> However it's dog slow.
>
> {{{
> sage: K.<v>=NumberField(x^4 + 514*x^2 + 64321)
> sage: L.<w>,e=K.galois_closure(map=True)
> sage: R.<r,v>=L.relativize(e)
> sage: time _=r.norm(K)
> CPU times: user 0.44 s, sys: 0.00 s, total: 0.44 s
> Wall time: 0.45 s
> }}}
>
> The attached patch changes the matrix() method to identify the base field
> as a trivial case, so that r.norm(K) computes the relative norm quickly:
>
> {{{
> sage: K.<v>=NumberField(x^4 + 514*x^2 + 64321)
> sage: L.<w>,e=K.galois_closure(map=True)
> sage: R.<r,v>=L.relativize(e)
> sage: time _=r.norm(K)
> CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
> Wall time: 0.00 s
> }}}
New description:
There seems to be no relative_norm or absolute_norm method for elements of
relative number fields (while there is for ideals). norm() works with an
optional base parameter, which can be set to the base field for obtaining
the relative norm.
However it's dog slow.
{{{
sage: K.<v>=NumberField(x^4 + 514*x^2 + 64321)
sage: L.<w>,e=K.galois_closure(map=True)
sage: R.<r,v>=L.relativize(e)
sage: time _=r.norm(K)
CPU times: user 0.44 s, sys: 0.00 s, total: 0.44 s
Wall time: 0.45 s
}}}
The attached patch changes the matrix() method to identify the base field
as a trivial case, so that r.norm(K) computes the relative norm quickly:
{{{
sage: K.<v>=NumberField(x^4 + 514*x^2 + 64321)
sage: L.<w>,e=K.galois_closure(map=True)
sage: R.<r,v>=L.relativize(e)
sage: time _=r.norm(K)
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
}}}
When you are done, mark the ticket as needing review to advertise the
potential reviewers that they should take a look at the patch.
--
Comment:
Note that the code you have added for the case base = R is never executed.
You are comparing base which is (presumably) a field with self which is a
NumberFieldElement.
Also the code for the case '''base is self.parent()''' is wrong, it will
not work in the following case:
{{{
sage: f = R.random_element()
sage: matrix(1,1,[f]) == f.matrix(R)
False
}}}
I would also add a doctest for a random element as f above.
One last comment. In the doctest you write
{{{
sage: K.<v>=NumberField(QQ['x']([64321, 0, 514, 0, 1]))
}}}
while correct, it can be confusing for the nonexperienced reader. Would it
not be more convenient something like?
{{{
sage: x = QQ['x'].gen()
sage: K.<v>=NumberField(QQ[x](x^4 + 514*x^2 + 64321))
sage: R.<r>=NumberField(K[x](x^2 + 4*v*x + 5*v^2 + 514))
}}}
I could make the changes myself, but I prefer not to change the patch to
give later a faster possitive review.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10174#comment:4>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.