Skip to content

Division with remainder for Ore Polynomials#2674

Merged
fredrik-johansson merged 2 commits into
flintlib:mainfrom
vioneers:gr_ore_poly_divrem
May 22, 2026
Merged

Division with remainder for Ore Polynomials#2674
fredrik-johansson merged 2 commits into
flintlib:mainfrom
vioneers:gr_ore_poly_divrem

Conversation

@vioneers
Copy link
Copy Markdown
Contributor

The goal of this Pull Request is to implement division with remainder for Ore polynomials:

// Returns the unique pair (Q, R) such that U = QV + R and ord(R) < ord(V)
int _gr_ore_poly_divrem(gr_ptr Q, gr_ptr R, gr_srcptr U, slong lenU, gr_srcptr V, slong lenV, gr_ore_poly_ctx_t ctx)
int gr_ore_poly_divrem(gr_ore_poly_t Q, gr_ore_poly_t R, const gr_ore_poly_t U, gr_ore_poly_t V, gr_ore_poly_ctx_t ctx)

Tests and documnetation are also added.

If you have any feedback, please feel free to let me know. Thank you!

Comment thread src/gr_ore_poly/test/t-divrem.c Outdated
Copy link
Copy Markdown
Contributor

@rburing rburing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides adding these new methods, they will have to be registered in the table of GR methods for gr_ore_poly contexts, around here:

flint/src/gr_ore_poly/ctx.c

Lines 300 to 302 in 290bd1b

{GR_METHOD_EUCLIDEAN_DIV, (gr_funcptr) gr_ore_poly_euclidean_div},
{GR_METHOD_EUCLIDEAN_REM, (gr_funcptr) gr_ore_poly_euclidean_rem},
{GR_METHOD_EUCLIDEAN_DIVREM, (gr_funcptr) gr_ore_poly_euclidean_divrem},

See e.g. gr_poly for how that's done:

flint/src/gr/polynomial.c

Lines 843 to 845 in 290bd1b

{GR_METHOD_EUCLIDEAN_DIV, (gr_funcptr) polynomial_euclidean_div},
{GR_METHOD_EUCLIDEAN_REM, (gr_funcptr) polynomial_euclidean_rem},
{GR_METHOD_EUCLIDEAN_DIVREM, (gr_funcptr) polynomial_euclidean_divrem},

Those are some small wrapper functions.

After this, they will also be tested by the generic ring tests.

Comment thread src/gr_ore_poly/divrem.c Outdated
Comment thread src/gr_ore_poly/divrem.c Outdated
Comment thread src/gr_ore_poly/divrem.c Outdated
Comment thread src/gr_ore_poly/divrem.c
Comment thread src/gr_ore_poly/divrem.c Outdated
Comment thread src/gr_ore_poly/divrem.c Outdated
Comment thread src/gr_ore_poly/divrem.c
status |= gr_zero(GR_ENTRY(A, i, el_size), cctx);
status |= gr_set(GR_ENTRY(A, k, el_size), c, cctx);

// B = A * V
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I'm wondering if it wouldn't be better to call lmul_gen repeatedly instead, or introducing a function that multiplies by D^k.

Comment thread src/gr_ore_poly/divrem.c Outdated
Comment thread src/gr_ore_poly/divrem.c Outdated
@fredrik-johansson
Copy link
Copy Markdown
Collaborator

Besides adding these new methods, they will have to be registered in the table of GR methods for gr_ore_poly contexts, around here:

After this, they will also be tested by the generic ring tests.

Yes, though I have no idea if the tests do the right thing in the noncommutative case :-)

@rburing
Copy link
Copy Markdown
Contributor

rburing commented May 13, 2026

Yes, though I have no idea if the tests do the right thing in the noncommutative case :-)

Let's find out! :D

@vioneers vioneers force-pushed the gr_ore_poly_divrem branch from 78cb2a5 to f8d29f3 Compare May 16, 2026 17:36
Comment thread src/gr_ore_poly/divrem.c Outdated
@vioneers vioneers force-pushed the gr_ore_poly_divrem branch from f8d29f3 to 89803d5 Compare May 17, 2026 09:22
Comment thread src/gr_ore_poly/divrem.c Outdated
Comment thread src/gr_ore_poly/divrem.c Outdated
Comment thread src/gr_ore_poly/divrem.c Outdated
Comment thread src/gr_ore_poly/divrem.c Outdated
Comment thread src/gr_ore_poly/divrem.c Outdated
@vioneers vioneers force-pushed the gr_ore_poly_divrem branch from 89803d5 to 45c867a Compare May 21, 2026 21:22
@fredrik-johansson
Copy link
Copy Markdown
Collaborator

After this, they will also be tested by the generic ring tests.

Apparently, these tests are missing.

Anyway, this looks good.

@fredrik-johansson fredrik-johansson merged commit 5a7ea36 into flintlib:main May 22, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants