-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add DomainError positive char univariate polynomial rings #199
Conversation
add DomainError for real_roots and complex_roots for positive characteristic univariate polys
381df60
to
f1ff967
Compare
src/flint/flint_base/flint_base.pyx
Outdated
def real_roots(self): | ||
raise AttributeError("Real roots are not supported for this polynomial") | ||
|
||
def complex_roots(self): | ||
raise AttributeError("Complex roots are not supported for this polynomial") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be something like NotImplementedError
at least rather than AttributeError
. The meaning of AttributeError
is that an object does not have an attribute. It should not be used for anything else.
This looks good. We don't necessarily need to do it here but to complete these we should add an implementation of real_roots for arb_poly, fmpz_poly and fmpq_poly. For arb_poly it is: def real_roots(self):
return self.roots() For def real_roots(self):
_, fac = self.factor_squarefree()
roots = []
for f, m in fac:
roots.extend([(r, m) for r, m in arb_poly(f).roots()])
# Sort the roots?
return roots For def real_roots(self):
return self.numer().real_roots() Oh, wait In [4]: arb_poly([1, 0, 1]).roots()
...
NotImplementedError: Polynomial has no factor method, roots cannot be determined I guess we need to add def roots(self):
return acb_poly(self).real_roots() Oh, and there is an interface inconsistency: In [12]: acb_poly([1, 0, -1]).roots()
Out[12]: [-1.00000000000000, 1.00000000000000]
In [13]: fmpz_poly([1, 0, -1]).roots()
Out[13]: [(1, 1), (-1, 1)] I suppose that |
Or maybe for |
I assume that there is some advantage in using |
Okay, let's just merge this for now and consider proper |
Following the discussion in #62