Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor fq_default to use gr generics #1765

Merged
merged 9 commits into from
Feb 2, 2024
Merged

Refactor fq_default to use gr generics #1765

merged 9 commits into from
Feb 2, 2024

Conversation

fredrik-johansson
Copy link
Collaborator

A start of reimplementing fq_default so that it's just syntactic sugar over gr generics. In particular, fq_default_ctx is now just an alias for gr_ctx. This PR also adds some missing functionality for nmod, fmpz_mod etc. gr contexts to make this work.

A lot of fq_default methods remain as if-statements; everything should be changed to gr method calls eventually, but this will require more work.

I've tried to make the documented interface completely backwards compatible, but there is possibly going to be some unanticipated breakage in Nemo, e.g. (there will certainly be breakage if some external code attempts to directly access the internals of the fq_default context object).

@fredrik-johansson
Copy link
Collaborator Author

Unfortunately fq_default is so poorly tested that it's hard to know if refactoring will break anything. Fingers crossed...

@thofma
Copy link
Contributor

thofma commented Feb 2, 2024

Bad timing, since we just changed everything to use fq_default[_ctx] and relied on it being a union over the various things.

Is the plan to do more incompatible changes or will these slow down at some point? I guess we just stick with 2.10 and wait till things settle down.

@albinahlback
Copy link
Collaborator

Is the plan to do more incompatible changes or will these slow down at some point? I guess we just stick with 2.10 and wait till things settle down.

I haven't talked to Fredrik about this, but my hope is that most of the breaking changes are between 3.0 and 3.1.

@fredrik-johansson
Copy link
Collaborator Author

Bad timing, since we just changed everything to use fq_default and relied on it being a union over the various things.

fq_default_t is still just a union over all the things. The only thing that has changed is the internal structure of the context object.

@thofma
Copy link
Contributor

thofma commented Feb 2, 2024

So can I still pass fq_default_ctx_t into a function expecting a fq_t if I know that the type is FQ_DEFAULT_FQ?

Edit: Sorry, I was not precise enough with my previous comment. I meant both the elements as well as the context object.

@fredrik-johansson
Copy link
Collaborator Author

So can I still pass fq_default_ctx_t into a function expecting a fq_t if I know that the type is FQ_DEFAULT_FQ?

You can pass a fq_default_t with type FQ_DEFAULT_FQ into a function expecting fq_t and vice versa.

fq_default_ctx_t and fq_ctx_t are not interchangeable, but that was already the case.

@thofma
Copy link
Contributor

thofma commented Feb 2, 2024

Is there a way to get to the fmpz_mod_ctx_t given a fq_default_ctx_t if I know that it has the right type?

@fredrik-johansson
Copy link
Collaborator Author

Fixed the 32-bit test failure which wasn't actually my fault (there was a missing init in the test code).

Seems like nothing tested broke in Nemo, so are there any objections to merging this?

@fredrik-johansson
Copy link
Collaborator Author

fredrik-johansson commented Feb 2, 2024

Is there a way to get to the fmpz_mod_ctx_t given a fq_default_ctx_t if I know that it has the right type?

Yes, gr_ctx_data_as_ptr(ctx) returns a pointer to the internal context object.

With the exception of nmod where the nmod_t is stored inline in the context object and gr_ctx_data_as_ptr(ctx) may be used.

Of course, we could add a less cryptic interface in the fq_default module.

@thofma
Copy link
Contributor

thofma commented Feb 2, 2024

The Nemo run has errors: https://github.com/flintlib/flint/actions/runs/7758309026/job/21159771932?pr=1765#step:7:3333

Given that it apparently does not catch all errors, the error might not be related to this PR.

@fredrik-johansson
Copy link
Collaborator Author

The Nemo run has errors: https://github.com/flintlib/flint/actions/runs/7758309026/job/21159771932?pr=1765#step:7:3333

Given that it apparently does not catch all errors, the error might not be related to this PR.

That error also shows up in the last test run on main.

It is surely a remnant of #1754 since it refers to _fmpz_mod_mat_clear_fn.

@albinahlback
Copy link
Collaborator

The Nemo run has errors: https://github.com/flintlib/flint/actions/runs/7758309026/job/21159771932?pr=1765#step:7:3333

Given that it apparently does not catch all errors, the error might not be related to this PR.

Hopefully I fixed it. I am rerunning the test.

@thofma
Copy link
Contributor

thofma commented Feb 2, 2024

I don't understand why it is still working, but if it works, it works.

@fredrik-johansson
Copy link
Collaborator Author

Added fq_default_ctx_inner to access the internal fq_*_ctx.

@thofma
Copy link
Contributor

thofma commented Feb 2, 2024

Merci

@fredrik-johansson fredrik-johansson merged commit d792df7 into main Feb 2, 2024
16 of 17 checks passed
@fredrik-johansson fredrik-johansson deleted the fq_default branch February 3, 2024 16:31
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.

3 participants