-
-
Notifications
You must be signed in to change notification settings - Fork 510
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 polynomial_element.pyx factor function #10635
Comments
comment:1
As someone interested in this change, let me chime in with a few suggestions of my own. (1) A similar refactoring should be done for roots(). It's true factor() can be used to find roots, but that's not necessarily the best approach. This suggests the names ._univariate_polynomial_x for x=factor,roots,etc. (2) So-called 'modular' gcd algorithms give a real boost to rings where applicable, so it would be nice to let x=gcd in (1). (3) Consider whether options such as 'multiplicities=False' should really be options to .univariate_polynomial_factor() or whether they can be handled 'universally'. |
Attachment: trac_10635_field_hooks.patch.gz Patch implementing desired changes |
comment:2
The patch addresses issue (1) and is for Sage 4.6.2. |
comment:3
Patch applied to sage-4.7.1.alpha2, then did 'sage -b', then 'make testlong'. All tests passed. Positive review! cjh - you need to add your name to the author field. |
Reviewer: Mariah Lenox |
comment:5
The patch should have an example that illustrates that each added capability actually works. That could be a class created in a docstring, or a small demo class added to the source code with an example. |
Author: Christopher Hall |
Changed reviewer from Mariah Lenox to Mariah Lenox, William Stein |
Attachment: trac_10635-new_version_with_tests.patch.gz apply only this patch |
Changed reviewer from Mariah Lenox, William Stein to Mariah Lenox, William Stein, Simon Spicer |
comment:8
Yep, looks fine. Test pass, code works, couldn't even find a typo. Note that this latest patch only sets it up so that if a base ring has a native The ring-specific functionality of these two methods still needs to be moved across to their respective files; to address this I've created patch #11731. |
Changed keywords from none to sd32 |
This comment has been minimized.
This comment has been minimized.
Merged: sage-4.7.2.alpha3 |
Reviewer patch to fix doctest error on some systems (e.g. x86). Apply on top of other patch. |
comment:12
Attachment: trac_10635-fix_doctest_error_due_to_noise.reviewer.patch.gz I've attached a reviewer patch fixing a doctest error in a factorization. (The order of the factors changes, depending on the sign of a "zero" term in the polynomial which is one factor. The example now looks a bit ugly, but I don't want to wait until we have |
This comment has been minimized.
This comment has been minimized.
comment:13
Factorization over function fields (provided by #9054) uses the function defined in this ticket (_factor_univariate_polynomial). However, in some cases it requires a parameter proof=False to work. So, the easy solution for #9054 was to add the default parameter proof=True to polynomial_element.factor() and pass it on to _factor_univariate_polynomial. Replying to @sagetrac-cjh:
|
comment:14
I opened a ticket for the function field case: #12100 |
The "factor" function in polynomial_element.pyx needs to be refactored, because it has to be modified every time a new interesting base ring gets added to Sage.
Instead of importing a ton of different rings, the function should just call a method on the base ring, e.g.,
Since the code in factor is for generic polynomials, it doesn't use their internal representation, so this should be fine. It just turns out that factoring algorithms depend a huge amount on the base ring, and polynomials get created over tons of different bases (but there are far less classes that derive from "polynomial").
I suggest for this ticket, at a minimum we add a quick "hasattr" check at the top of the current factor function, then leave the existing code. Then new code can be written to use this. In the near future somebody can move most of the imports and cases out the current factor function, so it becomes very short, and the code gets put in the right place.
A major motivation for this is that people create their own new rings R in external code that depends on sage, and want to be able to factor polynomials over R. They do not define a new class for polynomials over R. It seems silly for them to have to patch the core sage library to get factorization functionality.
Apply
to the Sage library.
Component: basic arithmetic
Keywords: sd32
Author: Christopher Hall
Reviewer: Mariah Lenox, William Stein, Simon Spicer
Merged: sage-4.7.2.alpha3
Issue created by migration from https://trac.sagemath.org/ticket/10635
The text was updated successfully, but these errors were encountered: