Skip to content

use PARI's qfbsolve() in BinaryQF.solve_integer() #32782

@yyyyx4

Description

@yyyyx4

Currently, solving binary quadratic forms uses a straightforward exponential-time search: https://github.com/sagemath/sage-prod/blob/9.4/src/sage/quadratic_forms/binary_qf.py#L1469

This patch calls PARI's qfbsolve() instead, which is exponentially faster in many cases.

Sage 9.4:

sage: %timeit BinaryQF([randrange(1,10^4), 0, randrange(1,10^4)]).solve_integer(randrange(10^7))
1.86 ms ± 552 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

Using qfbsolve():

sage: %timeit BinaryQF([randrange(1,10^4), 0, randrange(1,10^4)]).solve_integer(randrange(10^7))
38.4 µs ± 673 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)

CC: @collares

Component: quadratic forms

Author: Lorenz Panny

Branch: a1f7cb5

Reviewer: Samuel Lelièvre

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions