Hello Bruno, * Bruno Grenet <bruno.gre...@gmail.com> [2014-06-12 13:47:59 +0200]:
> Now comes my question, which is basically: How to introduce this new code > into Sage? > [...] > What I'd like to do is to branch a new algorithm there. So my more specific > question: Where should the new algorithm go? A solution may be to have > somewhere a specific code for the sparse polynomials over ZZ, and there put > a a function roots(self,multiplicities=True) to avoid going into the "big" > roots function from rings/polynomial/polynomial_element.pyx. Since your algorithm is specific to the ring Z your code should probably go there. A ring can define a method _roots_univariate_polynomial() which will be called by the generic method roots(). There you could check whether the polynomial is sparse and use the algorithm you implemented or the generic _roots_from_factorization(). > I have side questions, which may improve my code (or my tests): > > [...] > - The algorithm I implemented uses some auxiliary functions that are not of > real interest outside the algorithm. How should I do to avoid this functions > be available for the users? If you turn these auxiliary functions into methods of the ring Z, you can hide them by adding a single (or double but many people dislike this) underscore to the method name. If they are only used by your method to compute roots, you could probably name these methods _roots_from_factorization_method_name(). julian
pgpNzbrQiU2nW.pgp
Description: PGP signature