rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
computed bound is greater than a value set by the eclib
|
computed bound is greater than a value set by the ``eclib``
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
- ``odd_primes_only`` (bool, default False) -- only do
|
- ``odd_primes_only`` (bool, default ``False``) -- only do
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
via 2-descent they should alreday be 2-saturated.)
|
via :meth:``two_descent()`` they should already be 2-saturated.)
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
- ``ok`` (bool) is True if and only if the saturation was
|
- ``ok`` (bool) -- ``True`` if and only if the saturation was
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
the computed saturation bound being too high, then True indicates that the subgroup is saturated at `\emph{all}`
|
the computed saturation bound being too high, then ``True`` indicates that the subgroup is saturated at *all*
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
- ``index`` (int) is the index of the group generated by the
|
- ``index`` (int) -- the index of the group generated by the
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
uses floating points methods based on elliptic logarithms to
|
uses floating point methods based on elliptic logarithms to
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
We emphasize that if this function returns True as the first return argument, and if the default was used for the parameter ``sat_bnd``, then the points in the basis after calling this function are saturated at `\emph{all}` primes,
|
We emphasize that if this function returns ``True`` as the first return argument (``ok``), and if the default was used for the parameter ``max_prime``, then the points in the basis after calling this function are saturated at *all* primes,
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
saturate up to, and that prime is `\leq` ``max_prime``.
|
saturate up to, and that prime might be smaller than ``max_prime``.
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
calling search. So calling search up to height 20 then calling saturate results in another search up to height 18.
|
calling :meth:`search()`. So calling :meth:`search()` up to height 20 then calling :meth:`saturate()` results in another search up to height 18.
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
Subgroup of Mordell Weil group: [[1547:-2967:343], [2707496766203306:864581029138191:2969715140223272], [-13422227300:-49322830557:12167000000]]
|
Subgroup of Mordell-Weil group: [[1547:-2967:343], [2707496766203306:864581029138191:2969715140223272], [-13422227300:-49322830557:12167000000]]
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
Subgroup of Mordell Weil group: [[-2:3:1], [2707496766203306:864581029138191:2969715140223272], [-13422227300:-49322830557:12167000000]]
|
Subgroup of Mordell-Weil group: [[-2:3:1], [2707496766203306:864581029138191:2969715140223272], [-13422227300:-49322830557:12167000000]]
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
Subgroup of Mordell Weil group: [[-2:3:1], [-14:25:8], [-13422227300:-49322830557:12167000000]]
|
Subgroup of Mordell-Weil group: [[-2:3:1], [-14:25:8], [-13422227300:-49322830557:12167000000]]
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
Subgroup of Mordell Weil group: [[-2:3:1], [-14:25:8], [1:-1:1]]
|
Subgroup of Mordell-Weil group: [[-2:3:1], [-14:25:8], [1:-1:1]]
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
Of course, the ``process`` function would have done all this
|
Of course, the :meth:`process()` function would have done all this
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
But we would still need to use the ``saturate`` function to
|
But we would still need to use the :meth:`saturate()` function to
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
side-effect. It proves that the inde of the points in their
|
side-effect. It proves that the index of the points in their
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
by reducing the poits modulo all primes of good reduction up
|
by reducing the points modulo all primes of good reduction up
|
def saturate(self, max_prime=-1, odd_primes_only=False): r""" Saturate this subgroup of the Mordell-Weil group. INPUT: - ``max_prime`` (int, default -1) -- saturation is performed for all primes up to `max_prime`. If `-1` (default) then an upper bound is computed for the primes at which the subgroup may not be saturated, and this is used; however, if the computed bound is greater than a value set by the eclib library (currently 97) then no saturation will be attempted at primes above this. - ``odd_primes_only`` (bool, default False) -- only do saturation at odd primes. (If the points have been found via 2-descent they should alreday be 2-saturated.)
|
On 32-bit machines, this MUST be < 21.48 else $\exp(h_lim)>2^31$ and overflows. On 64-bit machines it must be at most 43.668. However, this bound is a logarithic
|
On 32-bit machines, this *must* be < 21.48 else `\exp(h_{\text{lim}}) > 2^{31}` and overflows. On 64-bit machines, it must be *at most* 43.668. However, this bound is a logarithmic
|
def search(self, height_limit=18, verbose=False): r""" Search for new points, and add them to this subgroup of the Mordell-Weil group.
|
Subgroup of Mordell Weil group: [[1:-1:1], [-2:3:1], [-14:25:8]] In the next example, a serach bound of 12 is needed to find a non-torsin point::
|
Subgroup of Mordell-Weil group: [[1:-1:1], [-2:3:1], [-14:25:8]] In the next example, a search bound of 12 is needed to find a non-torsion point::
|
def search(self, height_limit=18, verbose=False): r""" Search for new points, and add them to this subgroup of the Mordell-Weil group.
|
Subgroup of Mordell Weil group: []
|
Subgroup of Mordell-Weil group: []
|
def search(self, height_limit=18, verbose=False): r""" Search for new points, and add them to this subgroup of the Mordell-Weil group.
|
Subgroup of Mordell Weil group: [[4413270:10381877:27000]]
|
Subgroup of Mordell-Weil group: [[4413270:10381877:27000]]
|
def search(self, height_limit=18, verbose=False): r""" Search for new points, and add them to this subgroup of the Mordell-Weil group.
|
verbose == bool(verbose)
|
verbose = bool(verbose)
|
def search(self, height_limit=18, verbose=False): r""" Search for new points, and add them to this subgroup of the Mordell-Weil group.
|
(list) a list of lists of length 3, each holding the
|
(list) A list of lists of length 3, each holding the
|
def points(self): """ Return a list of the generating points in this Mordell-Weil group.
|
be overfull if : - `n` is odd - It satisfies `2m > (n-1)\Delta(G)`, where `\Delta(G)` denotes the maximal degree of a vertex in `G`
|
be overfull if: - `n` is odd - It satisfies `2m > (n-1)\Delta(G)`, where `\Delta(G)` denotes the maximum degree among all vertices in `G`.
|
def is_overfull(self): r""" Tests whether the current graph is overfull.
|
EXAMPLE: A complete graph is overfull if and only if its number of vertices is odd::
|
EXAMPLES: A complete graph of order `n > 1` is overfull if and only if `n` is odd::
|
def is_overfull(self): r""" Tests whether the current graph is overfull.
|
return (self.order() % 2 == 1) and \ (2*self.size() > max(self.degree())*(self.order()-1))
|
return (self.order() % 2 == 1) and ( 2 * self.size() > max(self.degree()) * (self.order() - 1))
|
def is_overfull(self): r""" Tests whether the current graph is overfull.
|
To see a list of all word constructors, type "words." and then
|
To see a list of all word constructors, type ``words.`` and then
|
def __new__(cls, *args, **kwds): r""" TEST: sage: from sage.combinat.words.word_generators import ChristoffelWord_Lower sage: w = ChristoffelWord_Lower(1,0); w doctest:1: DeprecationWarning: ChristoffelWord_Lower is deprecated, use LowerChristoffelWord instead word: 1 """ from sage.misc.misc import deprecation deprecation("ChristoffelWord_Lower is deprecated, use LowerChristoffelWord instead") return LowerChristoffelWord.__new__(cls, *args, **kwds)
|
This function returns the part of the fractional ideal self which is coprime to the prime ideals in the list S NOTE: This function assumes S is a list of prime ideals, it does not check this. This function will fail if S is not a list of prime ideals.
|
Return the part of this fractional ideal which is coprime to the prime ideals in the list ``S``. .. note:: This function assumes that `S` is a list of prime ideals, but does not check this. This function will fail if `S` is not a list of prime ideals.
|
def prime_to_S_part(self,S): r""" This function returns the part of the fractional ideal self which is coprime to the prime ideals in the list S NOTE: This function assumes S is a list of prime ideals, it does not check this. This function will fail if S is not a list of prime ideals. INPUT: - "self" - fractional ideal - "S" - a list of prime ideals OUTPUT: - an ideal coprime to the ideals in S EXAMPLES:: sage: K.<a> = NumberField(x^2-23) sage: I = K.ideal(24) sage: S = [K.ideal(-a+5),K.ideal(5)] sage: I.prime_to_S_part(S) Fractional ideal (3) sage: J = K.ideal(15) sage: J.prime_to_S_part(S) Fractional ideal (3) sage: K.<a> = NumberField(x^5-23) sage: I = K.ideal(24) sage: S = [K.ideal(15161*a^4 + 28383*a^3 + 53135*a^2 + 99478*a + 186250),K.ideal(2*a^4 + 3*a^3 + 4*a^2 + 15*a + 11), K.ideal(101)] sage: I.prime_to_S_part(S) Fractional ideal (24)
|
- "self" - fractional ideal - "S" - a list of prime ideals
|
- `S` - a list of prime ideals
|
def prime_to_S_part(self,S): r""" This function returns the part of the fractional ideal self which is coprime to the prime ideals in the list S NOTE: This function assumes S is a list of prime ideals, it does not check this. This function will fail if S is not a list of prime ideals. INPUT: - "self" - fractional ideal - "S" - a list of prime ideals OUTPUT: - an ideal coprime to the ideals in S EXAMPLES:: sage: K.<a> = NumberField(x^2-23) sage: I = K.ideal(24) sage: S = [K.ideal(-a+5),K.ideal(5)] sage: I.prime_to_S_part(S) Fractional ideal (3) sage: J = K.ideal(15) sage: J.prime_to_S_part(S) Fractional ideal (3) sage: K.<a> = NumberField(x^5-23) sage: I = K.ideal(24) sage: S = [K.ideal(15161*a^4 + 28383*a^3 + 53135*a^2 + 99478*a + 186250),K.ideal(2*a^4 + 3*a^3 + 4*a^2 + 15*a + 11), K.ideal(101)] sage: I.prime_to_S_part(S) Fractional ideal (24)
|
- an ideal coprime to the ideals in S
|
A fractional ideal coprime to the primes in `S`, whose prime factorization is that of ``self`` withe the primes in `S` removed.
|
def prime_to_S_part(self,S): r""" This function returns the part of the fractional ideal self which is coprime to the prime ideals in the list S NOTE: This function assumes S is a list of prime ideals, it does not check this. This function will fail if S is not a list of prime ideals. INPUT: - "self" - fractional ideal - "S" - a list of prime ideals OUTPUT: - an ideal coprime to the ideals in S EXAMPLES:: sage: K.<a> = NumberField(x^2-23) sage: I = K.ideal(24) sage: S = [K.ideal(-a+5),K.ideal(5)] sage: I.prime_to_S_part(S) Fractional ideal (3) sage: J = K.ideal(15) sage: J.prime_to_S_part(S) Fractional ideal (3) sage: K.<a> = NumberField(x^5-23) sage: I = K.ideal(24) sage: S = [K.ideal(15161*a^4 + 28383*a^3 + 53135*a^2 + 99478*a + 186250),K.ideal(2*a^4 + 3*a^3 + 4*a^2 + 15*a + 11), K.ideal(101)] sage: I.prime_to_S_part(S) Fractional ideal (24)
|
r''' Returns True if the ideal is an unit with respect to the list of primes S. INPUT:: - `S` - a list of prime ideals (not checked if they are indeed prime). OUTPUT:: True, if the ideal is `S`-unit. False, otherwise.
|
r""" Return True if this fractional ideal is a unit with respect to the list of primes ``S``. INPUT: - `S` - a list of prime ideals (not checked if they are indeed prime). .. note:: This function assumes that `S` is a list of prime ideals, but does not check this. This function will fail if `S` is not a list of prime ideals. OUTPUT: True, if the ideal is an `S`-unit: that is, if the valuations of the ideal at all primes not in `S` are zero. False, otherwise.
|
def is_S_unit(self,S): r''' Returns True if the ideal is an unit with respect to the
|
'''
|
"""
|
def is_S_unit(self,S): r''' Returns True if the ideal is an unit with respect to the
|
r''' Returns True if the ideal is an unit with respect to the list of primes S. INPUT:: - `S` - a list of prime ideals (not checked if they are indeed prime). OUTPUT:: True, if the ideal is `S`-integral. False, otherwise.
|
r""" Return True if this fractional ideal is integral with respect to the list of primes ``S``. INPUT: - `S` - a list of prime ideals (not checked if they are indeed prime). .. note:: This function assumes that `S` is a list of prime ideals, but does not check this. This function will fail if `S` is not a list of prime ideals. OUTPUT: True, if the ideal is `S`-integral: that is, if the valuations of the ideal at all primes not in `S` are non-negative. False, otherwise.
|
def is_S_integral(self,S): r''' Returns True if the ideal is an unit with respect to the
|
'''
|
"""
|
def is_S_integral(self,S): r''' Returns True if the ideal is an unit with respect to the
|
EXAMPLES:
|
Load and *execute* the content of ``filename`` in Macaulay2. :param filename: the name of the file to be loaded and executed. :type filename: string :returns: Macaulay2 command loading and executing commands in ``filename``, that is, ``'load "filename"'``. :rtype: string TESTS::
|
def _read_in_file_command(self, filename): """ EXAMPLES: sage: from sage.misc.misc import tmp_filename sage: filename = tmp_filename() sage: f = open(filename, "w") sage: f.write("Hello") sage: f.close() sage: command = macaulay2._read_in_file_command(filename) sage: macaulay2.eval(command) #optional Hello sage: import os sage: os.unlink(filename) """ return 'get "%s"'%filename
|
sage: f.write("Hello")
|
sage: f.write("sage_test = 7;")
|
def _read_in_file_command(self, filename): """ EXAMPLES: sage: from sage.misc.misc import tmp_filename sage: filename = tmp_filename() sage: f = open(filename, "w") sage: f.write("Hello") sage: f.close() sage: command = macaulay2._read_in_file_command(filename) sage: macaulay2.eval(command) #optional Hello sage: import os sage: os.unlink(filename) """ return 'get "%s"'%filename
|
Hello
|
sage: macaulay2.eval("sage_test") 7
|
def _read_in_file_command(self, filename): """ EXAMPLES: sage: from sage.misc.misc import tmp_filename sage: filename = tmp_filename() sage: f = open(filename, "w") sage: f.write("Hello") sage: f.close() sage: command = macaulay2._read_in_file_command(filename) sage: macaulay2.eval(command) #optional Hello sage: import os sage: os.unlink(filename) """ return 'get "%s"'%filename
|
""" return 'get "%s"'%filename
|
sage: macaulay2._read_in_file_command("test") 'load "test"' sage: macaulay2(10^10000) == 10^10000 True """ return 'load "%s"' % filename
|
def _read_in_file_command(self, filename): """ EXAMPLES: sage: from sage.misc.misc import tmp_filename sage: filename = tmp_filename() sage: f = open(filename, "w") sage: f.write("Hello") sage: f.close() sage: command = macaulay2._read_in_file_command(filename) sage: macaulay2.eval(command) #optional Hello sage: import os sage: os.unlink(filename) """ return 'get "%s"'%filename
|
(\$) by a dollar sign ($). Don't change a dollar sign preceded or followed by a backtick (`$ or $`), because of strings like
|
(\\$) by a dollar sign ($). Don't change a dollar sign preceded or followed by a backtick (\`$ or \$`), because of strings like
|
def process_dollars(s): r"""nodetex Replace dollar signs with backticks. More precisely, do a regular expression search. Replace a plain dollar sign ($) by a backtick (`). Replace an escaped dollar sign (\$) by a dollar sign ($). Don't change a dollar sign preceded or followed by a backtick (`$ or $`), because of strings like "``$HOME``". Don't make any changes on lines starting with more spaces than the first nonempty line in ``s``, because those are indented and hence part of a block of code or examples. This also doesn't replaces dollar signs enclosed in curly braces, to avoid nested math environments. EXAMPLES:: sage: from sage.misc.sagedoc import process_dollars sage: process_dollars('hello') 'hello' sage: process_dollars('some math: $x=y$') 'some math: `x=y`' Replace \$ with $, and don't do anything when backticks are involved:: sage: process_dollars(r'a ``$REAL`` dollar sign: \$') 'a ``$REAL`` dollar sign: $' Don't make any changes on lines indented more than the first nonempty line:: sage: s = '\n first line\n indented $x=y$' sage: s == process_dollars(s) True Don't replace dollar signs enclosed in curly braces:: sage: process_dollars(r'f(n) = 0 \text{ if $n$ is prime}') 'f(n) = 0 \\text{ if $n$ is prime}' This is not perfect: sage: process_dollars(r'$f(n) = 0 \text{ if $n$ is prime}$') '`f(n) = 0 \\text{ if $n$ is prime}$' The regular expression search doesn't find the last $. Fortunately, there don't seem to be any instances of this kind of expression in the Sage library, as of this writing. """ if s.find("$") == -1: return s # find how much leading whitespace s has, for later comparison: # ignore all $ on lines which start with more whitespace. whitespace = re.match(r'\s*\S', s.lstrip('\n')) whitespace = ' ' * (whitespace.end() - 1) # leading whitespace # Indices will be a list of pairs of positions in s, to search between. # If the following search has no matches, then indices will be (0, len(s)). indices = [0] # This searches for "$blah$" inside a pair of curly braces -- # don't change these, since they're probably coming from a nested # math environment. So for each match, search to the left of its # start and to the right of its end, but not in between. for m in re.finditer(r"{[^{}$]*\$([^{}$]*)\$[^{}$]*}", s): indices[-1] = (indices[-1], m.start()) indices.append(m.end()) indices[-1] = (indices[-1], len(s)) # regular expression for $ (not \$, `$, $`, and only on a line # with no extra leading whitespace). # # in detail: # re.compile("^" # beginning of line # + "(%s%)?" % whitespace # + r"""(\S # non whitespace # .*?)? # non-greedy match any non-newline characters # (?<!`|\\)\$(?!`) # $ with negative lookbehind and lookahead # """, re.M | re.X) # # except that this doesn't work, so use the equivalent regular # expression without the 're.X' option. Maybe 'whitespace' gets # eaten up by re.X? regexp = "^" + "(%s)?"%whitespace + r"(\S.*?)?(?<!`|\\)\$(?!`)" dollar = re.compile(regexp, re.M) # regular expression for \$ slashdollar = re.compile(r"\\\$") for start, end in indices: while dollar.search(s, start, end): m = dollar.search(s, start, end) s = s[:m.end()-1] + "`" + s[m.end():] while slashdollar.search(s, start, end): m = slashdollar.search(s, start, end) s = s[:m.start()] + "$" + s[m.end():] return s
|
Replace \$ with $, and don't do anything when backticks are involved::
|
Replace \\$ with $, and don't do anything when backticks are involved::
|
def process_dollars(s): r"""nodetex Replace dollar signs with backticks. More precisely, do a regular expression search. Replace a plain dollar sign ($) by a backtick (`). Replace an escaped dollar sign (\$) by a dollar sign ($). Don't change a dollar sign preceded or followed by a backtick (`$ or $`), because of strings like "``$HOME``". Don't make any changes on lines starting with more spaces than the first nonempty line in ``s``, because those are indented and hence part of a block of code or examples. This also doesn't replaces dollar signs enclosed in curly braces, to avoid nested math environments. EXAMPLES:: sage: from sage.misc.sagedoc import process_dollars sage: process_dollars('hello') 'hello' sage: process_dollars('some math: $x=y$') 'some math: `x=y`' Replace \$ with $, and don't do anything when backticks are involved:: sage: process_dollars(r'a ``$REAL`` dollar sign: \$') 'a ``$REAL`` dollar sign: $' Don't make any changes on lines indented more than the first nonempty line:: sage: s = '\n first line\n indented $x=y$' sage: s == process_dollars(s) True Don't replace dollar signs enclosed in curly braces:: sage: process_dollars(r'f(n) = 0 \text{ if $n$ is prime}') 'f(n) = 0 \\text{ if $n$ is prime}' This is not perfect: sage: process_dollars(r'$f(n) = 0 \text{ if $n$ is prime}$') '`f(n) = 0 \\text{ if $n$ is prime}$' The regular expression search doesn't find the last $. Fortunately, there don't seem to be any instances of this kind of expression in the Sage library, as of this writing. """ if s.find("$") == -1: return s # find how much leading whitespace s has, for later comparison: # ignore all $ on lines which start with more whitespace. whitespace = re.match(r'\s*\S', s.lstrip('\n')) whitespace = ' ' * (whitespace.end() - 1) # leading whitespace # Indices will be a list of pairs of positions in s, to search between. # If the following search has no matches, then indices will be (0, len(s)). indices = [0] # This searches for "$blah$" inside a pair of curly braces -- # don't change these, since they're probably coming from a nested # math environment. So for each match, search to the left of its # start and to the right of its end, but not in between. for m in re.finditer(r"{[^{}$]*\$([^{}$]*)\$[^{}$]*}", s): indices[-1] = (indices[-1], m.start()) indices.append(m.end()) indices[-1] = (indices[-1], len(s)) # regular expression for $ (not \$, `$, $`, and only on a line # with no extra leading whitespace). # # in detail: # re.compile("^" # beginning of line # + "(%s%)?" % whitespace # + r"""(\S # non whitespace # .*?)? # non-greedy match any non-newline characters # (?<!`|\\)\$(?!`) # $ with negative lookbehind and lookahead # """, re.M | re.X) # # except that this doesn't work, so use the equivalent regular # expression without the 're.X' option. Maybe 'whitespace' gets # eaten up by re.X? regexp = "^" + "(%s)?"%whitespace + r"(\S.*?)?(?<!`|\\)\$(?!`)" dollar = re.compile(regexp, re.M) # regular expression for \$ slashdollar = re.compile(r"\\\$") for start, end in indices: while dollar.search(s, start, end): m = dollar.search(s, start, end) s = s[:m.end()-1] + "`" + s[m.end():] while slashdollar.search(s, start, end): m = slashdollar.search(s, start, end) s = s[:m.start()] + "$" + s[m.end():] return s
|
This is not perfect:
|
This is not perfect::
|
def process_dollars(s): r"""nodetex Replace dollar signs with backticks. More precisely, do a regular expression search. Replace a plain dollar sign ($) by a backtick (`). Replace an escaped dollar sign (\$) by a dollar sign ($). Don't change a dollar sign preceded or followed by a backtick (`$ or $`), because of strings like "``$HOME``". Don't make any changes on lines starting with more spaces than the first nonempty line in ``s``, because those are indented and hence part of a block of code or examples. This also doesn't replaces dollar signs enclosed in curly braces, to avoid nested math environments. EXAMPLES:: sage: from sage.misc.sagedoc import process_dollars sage: process_dollars('hello') 'hello' sage: process_dollars('some math: $x=y$') 'some math: `x=y`' Replace \$ with $, and don't do anything when backticks are involved:: sage: process_dollars(r'a ``$REAL`` dollar sign: \$') 'a ``$REAL`` dollar sign: $' Don't make any changes on lines indented more than the first nonempty line:: sage: s = '\n first line\n indented $x=y$' sage: s == process_dollars(s) True Don't replace dollar signs enclosed in curly braces:: sage: process_dollars(r'f(n) = 0 \text{ if $n$ is prime}') 'f(n) = 0 \\text{ if $n$ is prime}' This is not perfect: sage: process_dollars(r'$f(n) = 0 \text{ if $n$ is prime}$') '`f(n) = 0 \\text{ if $n$ is prime}$' The regular expression search doesn't find the last $. Fortunately, there don't seem to be any instances of this kind of expression in the Sage library, as of this writing. """ if s.find("$") == -1: return s # find how much leading whitespace s has, for later comparison: # ignore all $ on lines which start with more whitespace. whitespace = re.match(r'\s*\S', s.lstrip('\n')) whitespace = ' ' * (whitespace.end() - 1) # leading whitespace # Indices will be a list of pairs of positions in s, to search between. # If the following search has no matches, then indices will be (0, len(s)). indices = [0] # This searches for "$blah$" inside a pair of curly braces -- # don't change these, since they're probably coming from a nested # math environment. So for each match, search to the left of its # start and to the right of its end, but not in between. for m in re.finditer(r"{[^{}$]*\$([^{}$]*)\$[^{}$]*}", s): indices[-1] = (indices[-1], m.start()) indices.append(m.end()) indices[-1] = (indices[-1], len(s)) # regular expression for $ (not \$, `$, $`, and only on a line # with no extra leading whitespace). # # in detail: # re.compile("^" # beginning of line # + "(%s%)?" % whitespace # + r"""(\S # non whitespace # .*?)? # non-greedy match any non-newline characters # (?<!`|\\)\$(?!`) # $ with negative lookbehind and lookahead # """, re.M | re.X) # # except that this doesn't work, so use the equivalent regular # expression without the 're.X' option. Maybe 'whitespace' gets # eaten up by re.X? regexp = "^" + "(%s)?"%whitespace + r"(\S.*?)?(?<!`|\\)\$(?!`)" dollar = re.compile(regexp, re.M) # regular expression for \$ slashdollar = re.compile(r"\\\$") for start, end in indices: while dollar.search(s, start, end): m = dollar.search(s, start, end) s = s[:m.end()-1] + "`" + s[m.end():] while slashdollar.search(s, start, end): m = slashdollar.search(s, start, end) s = s[:m.start()] + "$" + s[m.end():] return s
|
Replace \mathtt{BLAH} with either \verb|BLAH| (in the notebook) or
|
Replace \\mathtt{BLAH} with either \\verb|BLAH| (in the notebook) or
|
def process_mathtt(s, embedded=False): r"""nodetex Replace \mathtt{BLAH} with either \verb|BLAH| (in the notebook) or BLAH (from the command line). INPUT: - ``s`` - string, in practice a docstring - ``embedded`` - boolean (optional, default False) This function is called by :func:`format`, and if in the notebook, it sets ``embedded`` to be ``True``, otherwise ``False``. EXAMPLES:: sage: from sage.misc.sagedoc import process_mathtt sage: process_mathtt(r'e^\mathtt{self}') 'e^self' sage: process_mathtt(r'e^\mathtt{self}', embedded=True) 'e^{\\verb|self|}' """ replaced = False while True: start = s.find("\\mathtt{") end = s.find("}", start) if start == -1 or end == -1: break if embedded: left = "{\\verb|" right = "|}" else: left = "" right = "" s = s[:start] + left + s[start+8:end] + right + s[end+1:] return s
|
.. rubric:: Migrating classes to :class:`UniqueRepresentation` and unpickling
|
.. rubric:: Migrating classes to ``UniqueRepresentation`` and unpickling
|
... def __reduce__(self):
|
Normalization of arguments; see :cls:`UniqueRepresentation`.
|
Normalization of arguments; see :class:`UniqueRepresentation`.
|
def __classcall_private__(cls, fam, facade=True, keepkey=False): # was *args, **options): """ Normalization of arguments; see :cls:`UniqueRepresentation`.
|
Morphism from module over Integer Ring with invariants (2, 0, 0) to module with invariants (0, 0, 0) that sends the generators to [(0, 0, 0), (0, 0, 1), (0, 1, 0)]
|
Morphism from module over Integer Ring with invariants (2, 0, 0) to module with invariants (0, 0, 0) that sends the generators to [(0, 0, 0), (1, 0, 0), (0, 1, 0)]
|
def hom(self, im_gens, codomain=None, check=True): """ Homomorphism defined by giving the images of ``self.gens()`` in some fixed fg R-module. .. note :: We do not assume that the generators given by ``self.gens()`` are the same as the Smith form generators, since this may not be true for a general derived class. INPUTS:
|
(0, 0, 1)
|
(1, 0, 0)
|
def hom(self, im_gens, codomain=None, check=True): """ Homomorphism defined by giving the images of ``self.gens()`` in some fixed fg R-module. .. note :: We do not assume that the generators given by ``self.gens()`` are the same as the Smith form generators, since this may not be true for a general derived class. INPUTS:
|
Initializes base class Disk.
|
Initializes base class ``Disk``.
|
def __init__(self, point, r, angle, options): """ Initializes base class Disk.
|
Return the allowed options for the Disk class.
|
Return the allowed options for the ``Disk`` class.
|
def _allowed_options(self): """ Return the allowed options for the Disk class.
|
String representation of Disk primitive.
|
String representation of ``Disk`` primitive.
|
def _repr_(self): """ String representation of Disk primitive.
|
EXAMPLES:
|
EXAMPLES::
|
def plot3d(self, z=0, **kwds): """ Plots a 2D disk (actually a 52-gon) in 3D, with default height zero.
|
sage: len(search_doc('tree', whole_word=True, interact=False).splitlines()) < 100
|
sage: len(search_doc('tree', whole_word=True, interact=False).splitlines()) < 200
|
def search_doc(string, extra1='', extra2='', extra3='', extra4='', extra5='', **kwds): """ Search Sage HTML documentation for lines containing ``string``. The search is case-sensitive. The file paths in the output are relative to ``$SAGE_ROOT/devel/sage/doc/output``. INPUT: same as for :func:`search_src`. OUTPUT: same as for :func:`search_src`. EXAMPLES: See the documentation for :func:`search_src` for more examples. :: sage: search_doc('creates a polynomial', path_re='tutorial', interact=False) # random html/en/tutorial/tour_polynomial.html:<p>This creates a polynomial ring and tells Sage to use (the string) If you search the documentation for 'tree', then you will get too many results, because many lines in the documentation contain the word 'toctree'. If you use the ``whole_word`` option, though, you can search for 'tree' without returning all of the instances of 'toctree'. In the following, since ``search_doc('tree', interact=False)`` returns a string with one line for each match, counting the length of ``search_doc('tree', interact=False).splitlines()`` gives the number of matches. :: sage: len(search_doc('tree', interact=False).splitlines()) > 2000 True sage: len(search_doc('tree', whole_word=True, interact=False).splitlines()) < 100 True """ return _search_src_or_doc('doc', string, extra1=extra1, extra2=extra2, extra3=extra3, extra4=extra4, extra5=extra5, **kwds)
|
the curve, then `|h(P) - \hat{h}(P)| \leq B`, where `h(P)` is
|
the curve, then `h(P) \le \hat{h}(P) + B`, where `h(P)` is
|
def CPS_height_bound(self): r""" Return the Cremona-Prickett-Siksek height bound. This is a floating point number B such that if P is a rational point on the curve, then `|h(P) - \hat{h}(P)| \leq B`, where `h(P)` is the naive logarithmic height of `P` and `\hat{h}(P)` is the canonical height.
|
codmain.
|
codomain.
|
def iter_morphisms(self, arg=None, codomain=None, min_length=1): r""" Iterate over all morphisms with domain ``self`` and the given codmain.
|
Return the number type that contains both `self.field()` and `other`.
|
Return the common field for both ``self`` and ``other``.
|
def coerce_field(self, other): """ Return the number type that contains both `self.field()` and `other`.
|
The argument `other` must be either * another `Polyhedron()` object * `QQ` or `RDF` * a constant that can be coerced to `QQ` or `RDF`.
|
The argument ``other`` must be either: * another ``Polyhedron`` object * `\QQ` or `RDF` * a constant that can be coerced to `\QQ` or `RDF`
|
def coerce_field(self, other): """ Return the number type that contains both `self.field()` and `other`.
|
Either `QQ` or `RDF`. Raises `TypeError` if `other` is not a
|
Either `\QQ` or `RDF`. Raises ``TypeError`` if ``other`` is not a
|
def coerce_field(self, other): """ Return the number type that contains both `self.field()` and `other`.
|
NOTE: "Real" numbers in sage are not necessarily elements of `RDF`. For example, the literal `1.0` is not.
|
.. NOTE:: "Real" numbers in sage are not necessarily elements of `RDF`. For example, the literal `1.0` is not.
|
def coerce_field(self, other): """ Return the number type that contains both `self.field()` and `other`.
|
raise TypeError
|
raise TypeError("cannot determine field from %s!" % other)
|
def coerce_field(self, other): """ Return the number type that contains both `self.field()` and `other`.
|
.. note:: Reference for the Sturm bound that we use in the definition of of this function: J. Sturm, On the congruence of modular forms, Number theory (New York, 1984-1985), Springer, Berlin, 1987, pp. 275-280. Useful Remark:
|
sage: CuspForms(Gamma1(144), 3).sturm_bound() 3457 sage: CuspForms(DirichletGroup(144).1^2, 3).sturm_bound() 73 sage: CuspForms(Gamma0(144), 3).sturm_bound() 73 REFERENCE: - [Sturm] J. Sturm, On the congruence of modular forms, Number theory (New York, 1984-1985), Springer, Berlin, 1987, pp. 275-280. NOTE::
|
def sturm_bound(self, M=None): r""" For a space M of modular forms, this function returns an integer B such that two modular forms in either self or M are equal if and only if their q-expansions are equal to precision B (note that this is 1+ the usual Sturm bound, since `O(q^\mathrm{prec})` has precision prec). If M is none, then M is set equal to self. EXAMPLES:: sage: S37=CuspForms(37,2) sage: S37.sturm_bound() 8 sage: M = ModularForms(11,2) sage: M.sturm_bound() 3 sage: ModularForms(Gamma1(15),2).sturm_bound() 33 .. note::
|
`s \geq` the sturm bound for `\Gamma_0` at
|
`s \geq` the Sturm bound for `\Gamma_0` at
|
def sturm_bound(self, M=None): r""" For a space M of modular forms, this function returns an integer B such that two modular forms in either self or M are equal if and only if their q-expansions are equal to precision B (note that this is 1+ the usual Sturm bound, since `O(q^\mathrm{prec})` has precision prec). If M is none, then M is set equal to self. EXAMPLES:: sage: S37=CuspForms(37,2) sage: S37.sturm_bound() 8 sage: M = ModularForms(11,2) sage: M.sturm_bound() 3 sage: ModularForms(Gamma1(15),2).sturm_bound() 33 .. note::
|
self.__sturm_bound = self.group().sturm_bound(self.weight())+1
|
self.__sturm_bound = G.sturm_bound(self.weight())+1
|
def sturm_bound(self, M=None): r""" For a space M of modular forms, this function returns an integer B such that two modular forms in either self or M are equal if and only if their q-expansions are equal to precision B (note that this is 1+ the usual Sturm bound, since `O(q^\mathrm{prec})` has precision prec). If M is none, then M is set equal to self. EXAMPLES:: sage: S37=CuspForms(37,2) sage: S37.sturm_bound() 8 sage: M = ModularForms(11,2) sage: M.sturm_bound() 3 sage: ModularForms(Gamma1(15),2).sturm_bound() 33 .. note::
|
raise ValueError, "n must be greater than lbound: %s"%(lbound)
|
raise ValueError, "n must be at least lbound: %s"%(lbound)
|
def random_prime(n, proof=None, lbound=2): """ Returns a random prime p between `lbound` and n (i.e. `lbound <= p <= n`). The returned prime is chosen uniformly at random from the set of prime numbers less than or equal to n. INPUT: - ``n`` - an integer >= 2. - ``proof`` - bool or None (default: None) If False, the function uses a pseudo-primality test, which is much faster for really big numbers but does not provide a proof of primality. If None, uses the global default (see :mod:`sage.structure.proof.proof`) - ``lbound`` - an integer >= 2 lower bound for the chosen primes EXAMPLES:: sage: random_prime(100000) 88237 sage: random_prime(2) 2 Here we generate a random prime between 100 and 200:: sage: random_prime(200, lbound=100) 149 If all we care about is finding a pseudo prime, then we can pass in ``proof=False`` :: sage: random_prime(200, proof=False, lbound=100) 149 TESTS:: sage: type(random_prime(2)) <type 'sage.rings.integer.Integer'> sage: type(random_prime(100)) <type 'sage.rings.integer.Integer'> sage: random_prime(1, lbound=-2) #caused Sage hang #10112 Traceback (most recent call last): ... ValueError: n must be greater than or equal to 2 AUTHORS: - Jon Hanke (2006-08-08): with standard Stein cleanup - Jonathan Bober (2007-03-17) """ # since we don't want current_randstate to get # pulled when you say "from sage.arith import *". from sage.misc.randstate import current_randstate from sage.structure.proof.proof import get_flag proof = get_flag(proof, "arithmetic") n = ZZ(n) if n < 2: raise ValueError, "n must be greater than or equal to 2" if n < lbound: raise ValueError, "n must be greater than lbound: %s"%(lbound) elif n == 2: return ZZ(n) else: if not proof: prime_test = is_pseudoprime else: prime_test = is_prime randint = current_randstate().python_random().randint while(1): # In order to ensure that the returned prime is chosen # uniformly from the set of primes it is necessary to # choose a random number and then test for primality. # The method of choosing a random number and then returning # the closest prime smaller than it would typically not, # for example, return the first of a pair of twin primes. p = randint(lbound,n) if prime_test(p): return ZZ(p)
|
return ZZ(n)
|
return n lbound = max(2, lbound) if lbound > 2: if lbound == 3 or n <= 2*lbound - 2: if lbound < 25 or n <= 6*lbound/5: if lbound < 2010760 or n <= 16598*lbound/16597: if proof: smallest_prime = ZZ(lbound-1).next_prime() else: smallest_prime = ZZ(lbound-1).next_probable_prime() if smallest_prime > n: raise ValueError, \ "There are no primes between %s and %s (inclusive)" % (lbound, n) if proof: prime_test = is_prime
|
def random_prime(n, proof=None, lbound=2): """ Returns a random prime p between `lbound` and n (i.e. `lbound <= p <= n`). The returned prime is chosen uniformly at random from the set of prime numbers less than or equal to n. INPUT: - ``n`` - an integer >= 2. - ``proof`` - bool or None (default: None) If False, the function uses a pseudo-primality test, which is much faster for really big numbers but does not provide a proof of primality. If None, uses the global default (see :mod:`sage.structure.proof.proof`) - ``lbound`` - an integer >= 2 lower bound for the chosen primes EXAMPLES:: sage: random_prime(100000) 88237 sage: random_prime(2) 2 Here we generate a random prime between 100 and 200:: sage: random_prime(200, lbound=100) 149 If all we care about is finding a pseudo prime, then we can pass in ``proof=False`` :: sage: random_prime(200, proof=False, lbound=100) 149 TESTS:: sage: type(random_prime(2)) <type 'sage.rings.integer.Integer'> sage: type(random_prime(100)) <type 'sage.rings.integer.Integer'> sage: random_prime(1, lbound=-2) #caused Sage hang #10112 Traceback (most recent call last): ... ValueError: n must be greater than or equal to 2 AUTHORS: - Jon Hanke (2006-08-08): with standard Stein cleanup - Jonathan Bober (2007-03-17) """ # since we don't want current_randstate to get # pulled when you say "from sage.arith import *". from sage.misc.randstate import current_randstate from sage.structure.proof.proof import get_flag proof = get_flag(proof, "arithmetic") n = ZZ(n) if n < 2: raise ValueError, "n must be greater than or equal to 2" if n < lbound: raise ValueError, "n must be greater than lbound: %s"%(lbound) elif n == 2: return ZZ(n) else: if not proof: prime_test = is_pseudoprime else: prime_test = is_prime randint = current_randstate().python_random().randint while(1): # In order to ensure that the returned prime is chosen # uniformly from the set of primes it is necessary to # choose a random number and then test for primality. # The method of choosing a random number and then returning # the closest prime smaller than it would typically not, # for example, return the first of a pair of twin primes. p = randint(lbound,n) if prime_test(p): return ZZ(p)
|
if not proof: prime_test = is_pseudoprime else: prime_test = is_prime randint = current_randstate().python_random().randint while(1): p = randint(lbound,n) if prime_test(p): return ZZ(p)
|
prime_test = is_pseudoprime randint = current_randstate().python_random().randint while True: p = randint(lbound, n) if prime_test(p): return ZZ(p)
|
def random_prime(n, proof=None, lbound=2): """ Returns a random prime p between `lbound` and n (i.e. `lbound <= p <= n`). The returned prime is chosen uniformly at random from the set of prime numbers less than or equal to n. INPUT: - ``n`` - an integer >= 2. - ``proof`` - bool or None (default: None) If False, the function uses a pseudo-primality test, which is much faster for really big numbers but does not provide a proof of primality. If None, uses the global default (see :mod:`sage.structure.proof.proof`) - ``lbound`` - an integer >= 2 lower bound for the chosen primes EXAMPLES:: sage: random_prime(100000) 88237 sage: random_prime(2) 2 Here we generate a random prime between 100 and 200:: sage: random_prime(200, lbound=100) 149 If all we care about is finding a pseudo prime, then we can pass in ``proof=False`` :: sage: random_prime(200, proof=False, lbound=100) 149 TESTS:: sage: type(random_prime(2)) <type 'sage.rings.integer.Integer'> sage: type(random_prime(100)) <type 'sage.rings.integer.Integer'> sage: random_prime(1, lbound=-2) #caused Sage hang #10112 Traceback (most recent call last): ... ValueError: n must be greater than or equal to 2 AUTHORS: - Jon Hanke (2006-08-08): with standard Stein cleanup - Jonathan Bober (2007-03-17) """ # since we don't want current_randstate to get # pulled when you say "from sage.arith import *". from sage.misc.randstate import current_randstate from sage.structure.proof.proof import get_flag proof = get_flag(proof, "arithmetic") n = ZZ(n) if n < 2: raise ValueError, "n must be greater than or equal to 2" if n < lbound: raise ValueError, "n must be greater than lbound: %s"%(lbound) elif n == 2: return ZZ(n) else: if not proof: prime_test = is_pseudoprime else: prime_test = is_prime randint = current_randstate().python_random().randint while(1): # In order to ensure that the returned prime is chosen # uniformly from the set of primes it is necessary to # choose a random number and then test for primality. # The method of choosing a random number and then returning # the closest prime smaller than it would typically not, # for example, return the first of a pair of twin primes. p = randint(lbound,n) if prime_test(p): return ZZ(p)
|
sage: c._ambient_space_point(c.lattice().dual()([1,1]))
|
sage: c._ambient_space_point(c.dual_lattice()([1,1]))
|
def _ambient_space_point(self, data): r""" Try to convert ``data`` to a point of the ambient space of ``self``.
|
sage: c.contains(c.lattice().dual()(1,0))
|
sage: c.contains(c.dual_lattice()(1,0))
|
def contains(self, *args): r""" Check if a given point is contained in ``self``.
|
self._dual = Cone(rays, lattice=self.lattice().dual(), check=False)
|
self._dual = Cone(rays, lattice=self.dual_lattice(), check=False)
|
def dual(self): r""" Return the dual cone of ``self``. OUTPUT: - :class:`cone <ConvexRationalPolyhedralCone>`. EXAMPLES:: sage: cone = Cone([(1,0), (-1,3)]) sage: cone.dual().rays() (M(3, 1), M(0, 1)) Now let's look at a more complicated case:: sage: cone = Cone([(-2,-1,2), (4,1,0), (-4,-1,-5), (4,1,5)]) sage: cone.is_strictly_convex() False sage: cone.dim() 3 sage: cone.dual().rays() (M(7, -18, -2), M(1, -4, 0)) sage: cone.dual().dual() is cone True """ if "_dual" not in self.__dict__: rays = list(self.facet_normals()) for ray in self.orthogonal_sublattice().gens(): rays.append(ray) rays.append(-ray) self._dual = Cone(rays, lattice=self.lattice().dual(), check=False) self._dual._dual = self return self._dual
|
M = self.lattice().dual()
|
M = self.dual_lattice()
|
def facet_normals(self): r""" Return normals to facets of ``self``.
|
self.lattice().dual().submodule_with_basis(basis)
|
self.dual_lattice().submodule_with_basis(basis)
|
def _split_ambient_lattice(self): r""" Compute a decomposition of the ``N``-lattice into `N_\sigma` and its complement `N(\sigma)`.
|
Let `M=` ``self.lattice().dual()`` be the lattice dual to the
|
Let `M=` ``self.dual_lattice()`` be the lattice dual to the
|
def orthogonal_sublattice(self, *args, **kwds): r""" The sublattice (in the dual lattice) orthogonal to the sublattice spanned by the cone. Let `M=` ``self.lattice().dual()`` be the lattice dual to the ambient lattice of the given cone `\sigma`. Then, in the notation of [Fulton]_, this method returns the sublattice
|
For example, ::
|
For example::
|
def old_cremona_letter_code(n): r""" Returns the *old* Cremona letter code corresponding to an integer. integer. For example, :: 1 --> A 26 --> Z 27 --> AA 52 --> ZZ 53 --> AAA etc. INPUT: - ``n`` - int OUTPUT: str EXAMPLES:: sage: old_cremona_letter_code(1) 'A' sage: old_cremona_letter_code(26) 'Z' sage: old_cremona_letter_code(27) 'AA' sage: old_cremona_letter_code(521) 'AAAAAAAAAAAAAAAAAAAAA' sage: old_cremona_letter_code(53) 'AAA' sage: old_cremona_letter_code(2005) 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC' """ n -= 1 k = n%26 + 65 label = chr(k)*int(n//26 + 1) return label
|
sage: it.next() Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field sage: it.next() Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field """ return self.iter([11, self.largest_conductor()+1])
|
sage: it.next().label() '11a1' sage: it.next().label() '11a2' sage: it.next().label() '11a3' sage: it.next().label() '14a1' sage: skip = [it.next() for _ in range(100)] sage: it.next().label() '45a3' """ return self.iter(xsrange(11,self.largest_conductor()+1))
|
def __iter__(self): """ Returns an iterator through all EllipticCurve objects in the Cremona database.
|
Returns an iterator through all curves with conductor between Nmin and Nmax-1, inclusive, in the database.
|
Return an iterator through all curves in the database with given conductors.
|
def iter(self, conductors): """ Returns an iterator through all curves with conductor between Nmin and Nmax-1, inclusive, in the database. INPUT: - ``conductors`` - list or generator of ints OUTPUT: generator that iterates over EllipticCurve objects.
|
Returns an iterator through all optimal curves with conductor between Nmin and Nmax-1 in the database.
|
Return an iterator through all optimal curves in the database with given conductors.
|
def iter_optimal(self, conductors): """ Returns an iterator through all optimal curves with conductor between Nmin and Nmax-1 in the database. INPUT:
|
Returns a list of all curves with conductor between Nmin and Nmax-1, inclusive, in the database.
|
Returns a list of all curves with given conductors.
|
def list(self, conductors): """ Returns a list of all curves with conductor between Nmin and Nmax-1, inclusive, in the database. INPUT: - ``conductors`` - list or generator of ints OUTPUT: - list of EllipticCurve objects.
|
Returns a list of all optimal curves with conductor between Nmin and Nmax-1, inclusive, in the database.
|
Returns a list of all optimal curves with given conductors.
|
def list_optimal(self, conductors): """ Returns a list of all optimal curves with conductor between Nmin and Nmax-1, inclusive, in the database. INPUT: - ``conductors`` - list or generator of ints list of EllipticCurve objects. OUTPUT: list of EllipticCurve objects.
|
The smallest conductor for which the database is complete. (Always 1.)
|
The smallest conductor for which the database is complete: always 1.
|
def smallest_conductor(self): """ The smallest conductor for which the database is complete. (Always 1.) OUTPUT: - ``int`` - smallest conductor EXAMPLES:: sage: CremonaDatabase().smallest_conductor() 1 """ return 1
|
OUTPUT: - ``int`` - smallest cond - ``int`` - largest conductor plus one
|
OUTPUT: tuple of ints (N1,N2+1) where N1 is the smallest and N2 the largest conductor for which the database is complete.
|
def conductor_range(self): """ Return the range of conductors that are covered by the database. OUTPUT: - ``int`` - smallest cond - ``int`` - largest conductor plus one EXAMPLES:: sage: from sage.databases.cremona import LargeCremonaDatabase # optional - database_cremona_ellcurve sage: c = LargeCremonaDatabase() # optional - database_cremona_ellcurve sage: c.conductor_range() # optional - database_cremona_ellcurve (1, 130001) """ return 1, self.largest_conductor()+1
|
TESTS::
|
TESTS:
|
def _init_allgens(self, ftpdata, largest_conductor=0): """ Initialize the allgens table by reading the corresponding ftpdata files and importing them into the database. """ if self.read_only: raise RuntimeError, "The database must not be read_only." files = os.listdir(ftpdata) files.sort() name = "allgens" c = _map[name] print "Deleting old data" for N in range(1,largest_conductor+1): self[N][c] = {} self[N] = self[N] # so database knows that self[N] changed. print "Reading new data" for F in files: if not F[:len(name)] == name: continue print F for L in gzip.GzipFile(ftpdata + "/" + F).readlines(): print L v = L.split() N = int(v[0]) if largest_conductor and N > largest_conductor: self.commit() return id = v[1] + v[2] dat = [eval(s.replace(':',',')) for s in v[5:]] if not self[N].has_key(c): self[N][c] = {} self[N][c][id] = dat self[N] = self[N] # so database knows that self[N] changed.
|
""" Returns the image `\{f(x) x in self\}` of this combinatorial
|
r""" Returns the image `\{f(x) | x \in \text{self}\}` of this combinatorial
|
def map(self, f, name=None): """ Returns the image `\{f(x) x in self\}` of this combinatorial class by `f`, as a combinatorial class.
|
sage: K.<a> = NumberField(polygen(QQ)) sage: K._S_class_group_and_units( (K.ideal(5),) ) ([5, -1], [])
|
def _S_class_group_and_units(self, S, proof=True): """ Compute S class group and units. INPUT: - ``S`` - a tuple of primes of the base field - ``proof`` - if False, assume Pari's GRH++ in computing the class group OUTPUT: - ``units, clgp_gens``, where: - ``units`` - A list of generators of the unit group. - ``clgp_gens`` - A list of tuples ``(gen, order, pr)``, where ``gen`` is a tuple of elements which generate a fractional ideal representative of the class group generator of order ``order``, and ``pr`` is a principal generator of `gen^{order}`. EXAMPLE:: sage: K.<a> = NumberField(x^2+5) sage: K._S_class_group_and_units(()) ([-1], [(Fractional ideal (2, a + 1), 2, 2)]) """ from sage.interfaces.gp import gp from sage.rings.number_field.number_field_ideal import \ convert_to_idealprimedec_form, convert_from_idealprimedec_form deg = self.degree() ############################################################### # The following line computes S-class gp and S-units in Pari, # # assuming the Generalized Riemann Hypothesis + other # # "heuristic" assumptions (GRH++), or nothing if certify. # ############################################################### D_gp = gp(self.pari_bnf(certify=proof)) S_gp = [convert_to_idealprimedec_form(self, p) for p in S] units = [] result = D_gp.bnfsunit(S_gp) x = self.gen() for unit in result[1]: sage_unit = QQ(unit.polcoeff(0)) for i in xrange(1, unit.poldegree()+1): sage_unit += QQ(unit.polcoeff(i))*x**i units.append(sage_unit) units += self.unit_group().gens()
|
|
"""
|
r"""
|
def selmer_group(self, S, m, proof=True): """ Compute the Selmer group `K(S,m)`, which is defined to be the subgroup of `K^\times/(K^\times)^m` consisting of elements `a` such that `K(\sqrt[m]{a})/K` is unramified at all primes of `K` lying above a place outside of `S`. INPUT: - ``S`` - A set of primes of self. - ``m`` - A positive integer. - ``proof`` - If False, assume Pari's GRH++ in computing the class group. OUTPUT: A list of generators of `K(S,m)`. EXAMPLES:: sage: K.<a> = QuadraticField(-5) sage: K.selmer_group((), 2) [-1, 2] sage: K.selmer_group([K.ideal(2, -a+1)], 2) [2, -1] sage: K.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1)], 2) [2, a + 1, -1] sage: K.selmer_group((K.ideal(2, -a+1),K.ideal(3, a+1)), 4) [2, a + 1, -1] sage: K.selmer_group([K.ideal(2, -a+1)], 3) [2] sage: K.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1)], 3) [2, a + 1] sage: K.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3) [2, a + 1, -a] sage: K.<a> = NumberField(polygen(QQ)) sage: K.selmer_group([],5) []
|
"""
|
TESTS:: sage: P = PolynomialRing(QQ, 0, '') sage: P(5).univariate_polynomial() 5 """ if self.parent().ngens() == 0: if R is None: return self.base_ring()(self) else: return R(self)
|
def univariate_polynomial(self, R=None): """ Returns a univariate polynomial associated to this multivariate polynomial. INPUT: - ``R`` - (default: None) PolynomialRing If this polynomial is not in at most one variable, then a ValueError exception is raised. This is checked using the is_univariate() method. The new Polynomial is over the same base ring as the given MPolynomial. EXAMPLES:: sage: R.<x,y> = QQbar[] sage: f = 3*x^2 - 2*y + 7*x^2*y^2 + 5 sage: f.univariate_polynomial() Traceback (most recent call last): ... TypeError: polynomial must involve at most one variable sage: g = f.subs({x:10}); g 700*y^2 + (-2)*y + 305 sage: g.univariate_polynomial () 700*y^2 - 2*y + 305 sage: g.univariate_polynomial(PolynomialRing(QQ,'z')) 700*z^2 - 2*z + 305 """ if not self.is_univariate(): raise TypeError, "polynomial must involve at most one variable"
|
if self == 0: raise ArithmeticError, "Prime factorization of 0 not defined." if R.ngens() == 0: base_ring = self.base_ring() if base_ring.is_field(): return Factorization([],unit=self.base_ring()(self)) else: F = base_ring(self).factor() return Factorization([(R(f),m) for f,m in F], unit=F.unit())
|
def factor(self, proof=True): r""" Compute the irreducible factorization of this polynomial. INPUT: - ``proof'' - insist on provably correct results (ignored, always ``True``) ALGORITHM: Use univariate factorization code. If a polynomial is univariate, the appropriate univariate factorization code is called. :: sage: R.<z> = PolynomialRing(CC,1) sage: f = z^4 - 6*z + 3 sage: f.factor() (z - 1.60443920904349) * (z - 0.511399619393097) * (z + 1.05791941421830 - 1.59281852704435*I) * (z + 1.05791941421830 + 1.59281852704435*I) """ R = self.parent()
|
|
sage: import operator
|
def derivative(self, ex, operator): """ EXAMPLES::
|
|
sage: a = function('f', x).diff(x); a
|
sage: f = function('f') sage: a = f(x).diff(x); a
|
def derivative(self, ex, operator): """ EXAMPLES::
|
sage: b = function('f', x).diff(x).diff(x)
|
sage: b = f(x).diff(x, x)
|
def derivative(self, ex, operator): """ EXAMPLES::
|
args = ex.args()
|
args = ex.operands()
|
def derivative(self, ex, operator): """ EXAMPLES::
|
Check if a sage object belongs to self. This methods is a helper for
|
Check if a Sage object belongs to self. This methods is a helper for
|
def _is_a(self, x): """ Check if a sage object belongs to self. This methods is a helper for :meth:`__contains__` and the constructor :meth:`_element_constructor_`.
|
self._error_re = re.compile('(Principal Value|debugmode|Incorrect syntax|Maxima encountered a Lisp error)')
|
self._error_re = re.compile('(Principal Value|debugmode|incorrect syntax|Maxima encountered a Lisp error)')
|
def __init__(self, script_subdirectory=None, logfile=None, server=None, init_code = None): """ Create an instance of the Maxima interpreter.
|
sage: maxima.eval('sage0: x == x;')
|
sage: maxima._eval_line('sage0: x == x;')
|
def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: We check that errors are correctly checked:: sage: maxima._eval_line('1+1;') '2' sage: maxima.eval('sage0: x == x;') Traceback (most recent call last): ... TypeError: error evaluating "sage0: x == x;":... """ if len(line) == 0: return '' line = line.rstrip() if line[-1] != '$' and line[-1] != ';': line += ';'
|
TypeError: error evaluating "sage0: x == x;":...
|
TypeError: Error executing code in Maxima...
|
def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: We check that errors are correctly checked:: sage: maxima._eval_line('1+1;') '2' sage: maxima.eval('sage0: x == x;') Traceback (most recent call last): ... TypeError: error evaluating "sage0: x == x;":... """ if len(line) == 0: return '' line = line.rstrip() if line[-1] != '$' and line[-1] != ';': line += ';'
|
self._expect_expr(self._display_prompt) pre_out = self._before() self._expect_expr() out = self._before()
|
assert line_echo.strip() == line.strip() self._expect_expr(self._display_prompt) out = self._before()
|
def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: We check that errors are correctly checked:: sage: maxima._eval_line('1+1;') '2' sage: maxima.eval('sage0: x == x;') Traceback (most recent call last): ... TypeError: error evaluating "sage0: x == x;":... """ if len(line) == 0: return '' line = line.rstrip() if line[-1] != '$' and line[-1] != ';': line += ';'
|
self._error_check(line, pre_out)
|
def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: We check that errors are correctly checked:: sage: maxima._eval_line('1+1;') '2' sage: maxima.eval('sage0: x == x;') Traceback (most recent call last): ... TypeError: error evaluating "sage0: x == x;":... """ if len(line) == 0: return '' line = line.rstrip() if line[-1] != '$' and line[-1] != ';': line += ';'
|
|
self._expect_expr() assert len(self._before())==0, 'Maxima expect interface is confused!'
|
def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: We check that errors are correctly checked:: sage: maxima._eval_line('1+1;') '2' sage: maxima.eval('sage0: x == x;') Traceback (most recent call last): ... TypeError: error evaluating "sage0: x == x;":... """ if len(line) == 0: return '' line = line.rstrip() if line[-1] != '$' and line[-1] != ';': line += ';'
|
|
i = o.rfind('(%o') return o[:i]
|
def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: We check that errors are correctly checked:: sage: maxima._eval_line('1+1;') '2' sage: maxima.eval('sage0: x == x;') Traceback (most recent call last): ... TypeError: error evaluating "sage0: x == x;":... """ if len(line) == 0: return '' line = line.rstrip() if line[-1] != '$' and line[-1] != ';': line += ';'
|
|
for _ in range(3):
|
for _ in range(5):
|
def _command_runner(self, command, s, redirect=True): """ Run ``command`` in a new Maxima session and return its output as an ``AsciiArtString``. If redirect is set to False, then the output of the command is not returned as a string. Instead, it behaves like os.system. This is used for interactive things like Maxima's demos. See maxima.demo? EXAMPLES:: sage: maxima._command_runner('describe', 'gcd') -- Function: gcd (<p_1>, <p_2>, <x_1>, ...) ... """ cmd = 'maxima --very-quiet -r "%s(%s);" '%(command, s) if sage.server.support.EMBEDDED_MODE: cmd += '< /dev/null'
|
'5.20.1'
|
'5.22.1'
|
def version(self): """ Return the version of Maxima that Sage includes. EXAMPLES:: sage: maxima.version() '5.20.1' """ return maxima_version()
|
def taylor(f, v, a, n):
|
def taylor(f, *args):
|
def taylor(f, v, a, n): """ Expands self in a truncated Taylor or Laurent series in the variable `v` around the point `a`, containing terms through `(x - a)^n`. INPUT: - ``v`` - variable - ``a`` - number - ``n`` - integer EXAMPLES:: sage: var('x,k,n') (x, k, n) sage: taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6) -1/720*(45*k^6 - 60*k^4 + 16*k^2)*x^6 - 1/24*(3*k^4 - 4*k^2)*x^4 - 1/2*k^2*x^2 + 1 sage: taylor ((x + 1)^n, x, 0, 4) 1/24*(n^4 - 6*n^3 + 11*n^2 - 6*n)*x^4 + 1/6*(n^3 - 3*n^2 + 2*n)*x^3 + 1/2*(n^2 - n)*x^2 + n*x + 1 """ if not isinstance(f, Expression): f = SR(f) return f.taylor(v=v,a=a,n=n)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.