Skip to content

Implement Field._gcd_univariate_polynomial() #18461

@pjbruin

Description

@pjbruin

The goal of this ticket is to implement a Cython method Field._gcd_univariate_polynomial() using the standard Euclidean algorithm. This is much faster than Fields.ParentMethods._gcd_univariate_polynomial(), which calls EuclideanDomains.ElementMethods.gcd(), since both are Python methods. (The _gcd_univariate_polynomial mechanism was introduced in #13442.)

The following bug can then be fixed by just removing PolynomialRealDense.gcd(), which does not take into account the case where one of the arguments of gcd is zero:

sage: R.<x> = RR[]
sage: x.gcd(R.zero())
Traceback (most recent call last):
...
TypeError: 'MinusInfinity' object cannot be interpreted as an index

Removing this method without implementing Field._gcd_univariate_polynomial() (falling back on Python code) is about twice as slow; with this ticket there is no slowdown.

Similarly, to make CC and QQbar use the new method instead of Python code, we also remove the now obsolete Polynomial_generic_field.gcd().

CC: @saraedum

Component: basic arithmetic

Keywords: polynomial gcd

Author: Peter Bruin

Branch/Commit: 908ace7

Reviewer: Bruno Grenet

Issue created by migration from https://trac.sagemath.org/ticket/18461

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions