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

Patch GAP package Alnuth to call OSCAR instead of PARI #2220

Merged
merged 2 commits into from
Apr 13, 2023

Conversation

fingolfin
Copy link
Member

@fingolfin fingolfin commented Apr 5, 2023

There are still some bugs in it, I'll work on fixing those and adding some proper tests next.

Should be fully functional now.

UPDATE: I've also submitted the changes as a PR to Alnuth, so that its next release will support this out of the box.

@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Merging #2220 (8464d2e) into master (138fee2) will increase coverage by 0.00%.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2220   +/-   ##
=======================================
  Coverage   73.43%   73.43%           
=======================================
  Files         367      367           
  Lines       50043    50049    +6     
=======================================
+ Hits        36748    36753    +5     
- Misses      13295    13296    +1     

see 8 files with indirect coverage changes

@fingolfin fingolfin force-pushed the mh/alnuth branch 2 times, most recently from bcb8cd8 to 91fafe0 Compare April 6, 2023 08:41
@fingolfin fingolfin marked this pull request as ready for review April 6, 2023 08:42
@fingolfin fingolfin requested review from ThomasBreuer and fieker April 6, 2023 08:42
Assert(0, Oscar.is_one(facs.unit));

result := [];
# TODO: implement iterating over Julia collections????
Copy link
Member Author

Choose a reason for hiding this comment

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

@fingolfin
Copy link
Member Author

@ThomasBreuer any thoughts on this? Otherwise I'll merge this soon

@@ -0,0 +1,47 @@
# this needs RadiRoot to be loaded
gap> START_TEST("Factorisation of polynomials using PARI/GP");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
gap> START_TEST("Factorisation of polynomials using PARI/GP");
gap> START_TEST("Factorisation of polynomials using Oscar");

for f in JuliaToGAP(IsList, Oscar.collect(facs.fac)) do
# Convert factor to GAP
g := Julia.map(Oscar.coordinates, f[1].coeffs);
g := CallJuliaFunctionWithKeywordArguments(Oscar.GAP.julia_to_gap, [g], rec( recursive := true));
Copy link
Member

Choose a reason for hiding this comment

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

Looks complicated. What is wrong with JuliaToGAP(IsList, g, true)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Huh, good question. I am pretty sure I tried that and there was an error back then, but I probably just did it wrong somehow... It definitely passes the tests now, so I'll use that. Thanks!

Copy link
Member

@ThomasBreuer ThomasBreuer left a comment

Choose a reason for hiding this comment

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

This looks very nice. (I have added just two minor comments.)

If I understand the comment "also store the isomorphism" for _OscarField right then the point is to support isomorphisms from the number fields defined in alnuth (matrix fields) to number fields in Oscar. In order to provide this in a file in Oscar/src/GAP, we have to assume that the alnuth package is already loaded.
I can provide such an isomorphism in a separate pull request.
(In the direction from Oscar to GAP, iso_oscar_gap creates an AlgebraicExtension field from a number field.)

@fingolfin
Copy link
Member Author

@ThomasBreuer yes that sounds right: we are given an "alnuth number field", and want to store not just an isomorphic Oscar field, but also an isomorphism that can compute images and preimages.

Once that is in place, we can start looking into a larger refactoring of Alnuth: in the current setup, a lot of redundant work is done (e.g. GAP code reverses the order of coefficients for a polynomial, as that is what Pari expects; but we hijack that, and have to undo the reverse; compute; then reverse our answer, only for GAP to then re-reverse....). And there are a bunch of Alnuth functions that could be done much more efficiently if we were to "inject" ourselves at a higher level... But this is future work, the first goal is to have this working without Pari, which this PR achieves.

Next, I'll make a new Alnuth release with much of this code in it. Once GAP 4.13.0 is out, we can simplify code here again.

@fingolfin fingolfin merged commit 60f6c2c into oscar-system:master Apr 13, 2023
@fingolfin fingolfin deleted the mh/alnuth branch April 13, 2023 08:05
@ThomasBreuer
Copy link
Member

@fingolfin The natural way to define iso_gap_oscar for the fields used in Alnuth would be to create an Oscar field with the same defining polynomial. In fact, such a method is already available for those fields that are created by FieldByPolynomial (which delegates to AlgebraicExtension), thus only a method for the fields of matrices is missing.

However, the current _OscarField is created from the IntegerDefiningPolynomial of the GAP field, not from its DefiningPolynomial; this fits to the function PolynomialFactorsDescriptionPari, which also accesses the IntegerDefiningPolynomial.
(In fact, I do currently not see where the Alnuth code resolves this "twist" in the end.)

My question is: Shall iso_gap_oscar create an Oscar field from the IntegerDefiningPolynomial of the GAP field (and "scale" the field elements when translating them), or shall the DefiningPolynomial of the GAP field be taken, and the Alnuth code that uses the isomorphism has to take care of this fact?

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.

2 participants