1 | initial version |
If f
has a method small_roots
, then you can access the documentation by
sage: f.small_roots?
and the source code by
sage: f.small_roots??
If you don't have an object with that method, you can do
sage: search_doc("small_roots")
or
sage: search_src("small_roots")
to get an idea of where in the documentation, resp. where in the source code, this string appears.
For instance, I get:
sage: search_src("small_roots")
rings/polynomial/polynomial_modn_dense_ntl.pyx:373: def small_roots(self, *args, **kwds):
rings/polynomial/polynomial_modn_dense_ntl.pyx:375: See :func:`sage.rings.polynomial.polynomial_modn_dense_ntl.small_roots`
rings/polynomial/polynomial_modn_dense_ntl.pyx:384: sage: f.small_roots()
rings/polynomial/polynomial_modn_dense_ntl.pyx:387: return small_roots(self, *args, **kwds)
rings/polynomial/polynomial_modn_dense_ntl.pyx:389:def small_roots(self, X=None, beta=1.0, epsilon=None, **kwds):
rings/polynomial/polynomial_modn_dense_ntl.pyx:443: sage: f.small_roots()
rings/polynomial/polynomial_modn_dense_ntl.pyx:484: sage: Kbar = f.small_roots()[0]
rings/polynomial/polynomial_modn_dense_ntl.pyx:513: sage: d = f.small_roots(X=2^hidden-1, beta=0.5)[0] # time random
rings/polynomial/polynomial_zmod_flint.pyx:353: def small_roots(self, *args, **kwds):
rings/polynomial/polynomial_zmod_flint.pyx:355: See :func:`sage.rings.polynomial.polynomial_modn_dense_ntl.small_roots`
rings/polynomial/polynomial_zmod_flint.pyx:364: sage: f.small_roots()
rings/polynomial/polynomial_zmod_flint.pyx:367: from sage.rings.polynomial.polynomial_modn_dense_ntl import small_roots
rings/polynomial/polynomial_zmod_flint.pyx:368: return small_roots(self, *args, **kwds)
Then you can inspect these files in your favourite text editor, for instance open up a terminal and type
vim <SAGE_ROOT>/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx
(replacing <sage_root> with the path to your Sage installation), and go to the specified lines, or use your text editor to search for the string small_roots
, and you get an example of how to use the method, and the source code.
2 | No.2 Revision |
In cases like is_prime
, there is a function with that name in the global namespace, and also some objects have a method called that. What the global function does is usually deal with some special cases, then check if the argument you entered for the function is an object that has a method with the same name, and then apply this method to that object.
You can inspect the source code for the global function is_prime
:
sage: is_prime??
You can see that it's not the same as the source code for the method is_prime
of an integer.
sage: a = 5
sage: a.is_prime??
In cases like small_roots
, it doesn't make sense to have it as a global function in the global namespace. It can only be called as a method, for those objects which have such a method.
If f
has a method small_roots
, then you can access the documentation by
sage: f.small_roots?
and the source code by
sage: f.small_roots??
If you don't have an object with that method, you can do
sage: search_doc("small_roots")
or
sage: search_src("small_roots")
to get an idea of where in the documentation, resp. where in the source code, this string appears.
For instance, I get:
sage: search_src("small_roots")
rings/polynomial/polynomial_modn_dense_ntl.pyx:373: def small_roots(self, *args, **kwds):
rings/polynomial/polynomial_modn_dense_ntl.pyx:375: See :func:`sage.rings.polynomial.polynomial_modn_dense_ntl.small_roots`
rings/polynomial/polynomial_modn_dense_ntl.pyx:384: sage: f.small_roots()
rings/polynomial/polynomial_modn_dense_ntl.pyx:387: return small_roots(self, *args, **kwds)
rings/polynomial/polynomial_modn_dense_ntl.pyx:389:def small_roots(self, X=None, beta=1.0, epsilon=None, **kwds):
rings/polynomial/polynomial_modn_dense_ntl.pyx:443: sage: f.small_roots()
rings/polynomial/polynomial_modn_dense_ntl.pyx:484: sage: Kbar = f.small_roots()[0]
rings/polynomial/polynomial_modn_dense_ntl.pyx:513: sage: d = f.small_roots(X=2^hidden-1, beta=0.5)[0] # time random
rings/polynomial/polynomial_zmod_flint.pyx:353: def small_roots(self, *args, **kwds):
rings/polynomial/polynomial_zmod_flint.pyx:355: See :func:`sage.rings.polynomial.polynomial_modn_dense_ntl.small_roots`
rings/polynomial/polynomial_zmod_flint.pyx:364: sage: f.small_roots()
rings/polynomial/polynomial_zmod_flint.pyx:367: from sage.rings.polynomial.polynomial_modn_dense_ntl import small_roots
rings/polynomial/polynomial_zmod_flint.pyx:368: return small_roots(self, *args, **kwds)
Then you can inspect these files in your favourite text editor, for instance open up a terminal and type
vim <SAGE_ROOT>/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx
(replacing <sage_root> with the path to your Sage installation), and go to the specified lines, or use your text editor to search for the string small_roots
, and you get an example of how to use the method, and the source code.