Skip to content

Division with remainder for Ore Polynomials#2674

Open
vioneers wants to merge 1 commit into
flintlib:mainfrom
vioneers:gr_ore_poly_divrem
Open

Division with remainder for Ore Polynomials#2674
vioneers wants to merge 1 commit 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
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
Comment thread src/gr_ore_poly/divrem.c
Comment thread src/gr_ore_poly/divrem.c
Comment thread src/gr_ore_poly/divrem.c
Comment thread src/gr_ore_poly/divrem.c
Comment thread src/gr_ore_poly/divrem.c
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
Comment thread src/gr_ore_poly/divrem.c
@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

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