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

Integer-valued polynomial ring #34988

Merged
merged 15 commits into from
Mar 13, 2023
Merged

Conversation

fchapoton
Copy link
Contributor

@fchapoton fchapoton commented Feb 6, 2023

Thanks for contributing to Sage! Detailed instructions to be added shortly.

Please make sure to also have a look at our
Code Style Conventions.

Fixes #34814

@fchapoton fchapoton changed the title U/chapoton/34814 Integer-valued polynomial ring Feb 7, 2023
@codecov-commenter

This comment was marked as off-topic.

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

The same comments apply for the PositiveBasis. It seems like there would be a benefit to avoid some duplication through an ABC.

A = self.parent()
return A.sum(c * A.monomial(i + 1) for i, c in self)

def polynomial(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we cache this?

src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 10, 2023

#34814 (comment) is unresolved

@fchapoton
Copy link
Contributor Author

Now in better state, working with realizations and only importing one thing into the global namespace

@tscrim
Copy link
Collaborator

tscrim commented Feb 20, 2023

@fchapoton Would you like me to go through what's there and leave some comments or are you still going to do some work on it?

@fchapoton
Copy link
Contributor Author

Yes, please have a look if you can. I will not do anything else here for the next 7 days. Maybe moving some documentation to the top could be a good idea.

src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
Comment on lines 60 to 63
S = self.S()
B = self.B()
B.module_morphism(S._from_binomial_basis, codomain=S).register_as_coercion()
S.module_morphism(B._from_shifted_basis, codomain=B).register_as_coercion()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can lead to problems if B and S are garbage collected IIRC. This might be okay though as the realizations are stored and tied to the IVPR.

src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
@fchapoton
Copy link
Contributor Author

I wonder if I should try to factorise the "polynomial" and "from polynomial" methods ? I could create a _basis_polynomial method just returning the value of B[i] and S[i] as polynomials.

@tscrim
Copy link
Collaborator

tscrim commented Mar 2, 2023

I wonder if I should try to factorise the "polynomial" and "from polynomial" methods ? I could create a _basis_polynomial method just returning the value of B[i] and S[i] as polynomials.

I think that would be good. It took me a bit to actually see what the difference between those methods actually ways.

@fchapoton
Copy link
Contributor Author

I wonder if I should try to factorise the "polynomial" and "from polynomial" methods ? I could create a _basis_polynomial method just returning the value of B[i] and S[i] as polynomials.

I think that would be good. It took me a bit to actually see what the difference between those methods actually ways.

Ok, I have now done both the factorisation of polynomial and from_polynomial and the better coercion. This should start to look good. Is there anything that I missed ?

@tscrim
Copy link
Collaborator

tscrim commented Mar 2, 2023

I think you have taken care of everything. The only comment I have on the recent commits is that I think you can simply return the module_morphism in _coerce_map_from_ so it is not recreated every time and that you know the base rings are compatible. Having it in the element constructor means it might pick up something going from, e.g., Z/5Z to Z/2Z as base rings.

@fchapoton
Copy link
Contributor Author

I think you have taken care of everything. The only comment I have on the recent commits is that I think you can simply return the module_morphism in _coerce_map_from_ so it is not recreated every time and that you know the base rings are compatible. Having it in the element constructor means it might pick up something going from, e.g., Z/5Z to Z/2Z as base rings.

oh, I see, thanks. I did not know that one could return a morphism and not a boolean in _coerce_map_from_. Done and it seems to work fine enough.

@tscrim
Copy link
Collaborator

tscrim commented Mar 3, 2023

oh, I see, thanks. I did not know that one could return a morphism and not a boolean in _coerce_map_from_. Done and it seems to work fine enough.

It can also take an arbitrary Python callable object as well as I recall, which then gets wrapped into a coercion morphism.

Anyways, that's all my comments for now. Let me know when you are ready for a full review (which will probably be quite quick at this point).

@fchapoton
Copy link
Contributor Author

ok, this should be almost ready.

@fchapoton fchapoton marked this pull request as ready for review March 6, 2023 08:13
Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

Just a few more little things.

src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
src/sage/rings/polynomial/integer_valued_polynomials.py Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Mar 9, 2023

Documentation preview for this PR is ready! 🎉
Built with commit: 8774a72

@fchapoton
Copy link
Contributor Author

Thanks, Travis. I think I have handled all your points in the latest commit.

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

Thank you. LGTM.

@vbraun vbraun merged commit 1463bac into sagemath:develop Mar 13, 2023
@mkoeppe mkoeppe added this to the sage-10.0 milestone Mar 13, 2023
@fchapoton fchapoton deleted the u/chapoton/34814 branch July 16, 2023 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

adding the ring of integer-valued polynomials
6 participants