From c9c00b355e3afb1f768c9bb7ac103c8e66de0db5 Mon Sep 17 00:00:00 2001 From: David Lucas Date: Thu, 24 Mar 2016 09:54:09 +0100 Subject: [PATCH 001/370] Added dedicated class for BCH codes --- src/sage/coding/bch.py | 183 +++++++++++++++++++++++++++++++ src/sage/coding/codes_catalog.py | 1 + 2 files changed, 184 insertions(+) create mode 100644 src/sage/coding/bch.py diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py new file mode 100644 index 00000000000..3e59250331d --- /dev/null +++ b/src/sage/coding/bch.py @@ -0,0 +1,183 @@ +r""" +BCH Code + +Let `F = GF(q)` and `\Phi` be the splitting field of +`x^{n} - 1` over`F`, with `n` a positive integer. +Let `\alpha` be an element of multiplicative order `n` in `\Phi`. + +A BCH code consists of all codewords `c(x) \in F_{n}[x]` such that +`c(\alpha^{a}) = 0`, for `a = b, b + l, b + 2\times l, \dots, b + (\delta - 2) \times l`, +with `b`, `\delta` integers such that `b < \delta` and `0 < \delta \leq n`. +""" + +#***************************************************************************** +# Copyright (C) 2016 David Lucas +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + +from linear_code import AbstractLinearCode +from cyclic_code import CyclicCode +from grs import GeneralizedReedSolomonCode +from encoder import Encoder +from decoder import Decoder, DecodingError +from sage.modules.free_module_element import vector +from sage.misc.misc_c import prod + +class BCHCode(CyclicCode): + r""" + Representation of a BCH code seen as a cyclic code. + + INPUT: + + - ``F`` -- the base field for this code + + - ``n`` -- the length of the code + + - ``b`` -- the starting point for the elements in the defining set + + - ``delta`` -- the ending point for the elements in the defining set + + - ``l`` -- (default: ``1``) the jump size between two elements of the defining set + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(2), 15, 1, 7) + sage: C + [15, 5] BCH Code over Finite Field of size 2 with x^10 + x^8 + x^5 + x^4 + x^2 + x + 1 as generator polynomial + + sage: C = codes.BCHCode(GF(2), 15, 1, 4, 3) + sage: C + [15, 7] BCH Code over Finite Field of size 2 with x^8 + x^7 + x^5 + x^4 + x^3 + x + 1 + as generator polynomial + """ + + def __init__(self, F, n, b, delta, l = 1): + + if not (delta <= n and delta > 1): + raise ValueError("delta must belong to [2, n]") + + D = [] + d = b + for i in range(0, delta - 1): + D.append(d) + d = (d + l) % n + + try: + super(BCHCode, self).__init__(field = F, length = n, D = D) + except ValueError, e: + raise e + self._default_decoder_name = "UnderlyingGRS" + self._jump_size = l + self._starting_point = b + self._delta = delta + + def __eq__(self, other): + r""" + Tests equality between BCH Code objects. + + EXAMPLES:: + + sage: F = GF(16, 'a') + sage: n = 15 + sage: C1 = codes.BCHCode(F, n, 1, 2) + sage: C2 = codes.BCHCode(F, n, 1, 2) + sage: C1 == C2 + True + """ + return isinstance(other, BCHCode) \ + and self.length() == other.length() \ + and self.jump_size() == other.jump_size() \ + and self.starting_point() == other.starting_point() \ + + def __ne__(self, other): + r""" + Tests inequality of BCH Code objects. + + EXAMPLES:: + + sage: F = GF(16, 'a') + sage: n = 15 + sage: C1 = codes.BCHCode(F, 15, 1, 2) + sage: C2 = codes.BCHCode(F, 13, 1, 2) + sage: C1 != C2 + True + """ + return not self.__eq__(other) + + def _repr_(self): + r""" + Returns a string representation of ``self``. + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(2), 15, 1, 7) + sage: C + [15, 5] BCH Code over Finite Field of size 2 with x^10 + x^8 + x^5 + x^4 + x^2 + x + 1 as generator polynomial + """ + return "[%s, %s] BCH Code over %s with %s as generator polynomial"\ + % (self.length(), self.dimension(),\ + self.base_field(), self.generator_polynomial()) + + def _latex_(self): + r""" + Returns a latex representation of ``self``. + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(2), 15, 1, 7) + sage: latex(C) + [15, 5] \textnormal{ BCH Code over } \Bold{F}_{2} \textnormal{ with } x^{10} + x^{8} + x^{5} + x^{4} + x^{2} + x + 1 \textnormal{ as generator polynomial} + """ + return "[%s, %s] \\textnormal{ BCH Code over } %s \\textnormal{ with } %s \\textnormal{ as generator polynomial}"\ + % (self.length(), self.dimension(),\ + self.base_field()._latex_(), self.generator_polynomial()._latex_()) + + def jump_size(self): + r""" + Returns the jump size between two consecutive elements of the defining set of ``self``. + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(2), 15, 1, 4, 2) + sage: C.jump_size() + 2 + """ + return self._jump_size + + def starting_point(self): + return self._starting_point + + + def bch_to_grs(self): + r""" + Returns the underlying GRS code from which ``self`` was derived. + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(2), 15, 1, 2, 2) + sage: C.bch_to_grs() + [15, 13, 3] Generalized Reed-Solomon Code over Finite Field in b of size 2^4 + """ + l = self.jump_size() + alpha = self.root_of_unity() + b = self.starting_point() + n = self.length() + + grs_dim = n - self.bch_bound(arithmetic = True) + 1 + evals = [] + pcm = [] + for i in range(1, n + 1): + evals.append(alpha ** (l * (i - 1))) + pcm.append(alpha ** (b * (i - 1))) + + + multipliers_product = [1/prod([evals[i] - evals[h] for h in range(len(evals)) if h != i]) + for i in range(len(evals))] + column_multipliers = [multipliers_product[i]/pcm[i] for i in range(n)] + + return GeneralizedReedSolomonCode(evals, grs_dim, column_multipliers) diff --git a/src/sage/coding/codes_catalog.py b/src/sage/coding/codes_catalog.py index dae184932d7..a73c0402b98 100644 --- a/src/sage/coding/codes_catalog.py +++ b/src/sage/coding/codes_catalog.py @@ -29,6 +29,7 @@ ToricCode, TrivialCode, WalshCode) from grs import GeneralizedReedSolomonCode +from bch import BCHCode from guava import BinaryReedMullerCode, QuasiQuadraticResidueCode, RandomLinearCodeGuava From 4bd9d47edd47cf16ca14f5d886cf28aabd1cde2a Mon Sep 17 00:00:00 2001 From: David Lucas Date: Thu, 24 Mar 2016 16:10:51 +0100 Subject: [PATCH 002/370] WIP --- src/sage/coding/bch.py | 74 +++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 3e59250331d..52c011771b8 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -27,6 +27,9 @@ from decoder import Decoder, DecodingError from sage.modules.free_module_element import vector from sage.misc.misc_c import prod +from sage.rings.integer import Integer +from sage.rings.ring import Field +from copy import copy class BCHCode(CyclicCode): r""" @@ -34,15 +37,18 @@ class BCHCode(CyclicCode): INPUT: - - ``F`` -- the base field for this code + - ``base_field`` -- the base field for this code - - ``n`` -- the length of the code + - ``length`` -- the length of the code - - ``b`` -- the starting point for the elements in the defining set + - ``starting_point`` -- the first element to add in the defining set - ``delta`` -- the ending point for the elements in the defining set - - ``l`` -- (default: ``1``) the jump size between two elements of the defining set + - ``jump_size`` -- (default: ``1``) the jump size between two elements of the defining set + + - ``b`` -- (default: ``0``) is exactly the same as ``starting_point``. It is only here + for retro-compatibility purposes with the old signature of `BCHCode` and will be removed soon. EXAMPLES:: @@ -56,23 +62,43 @@ class BCHCode(CyclicCode): as generator polynomial """ - def __init__(self, F, n, b, delta, l = 1): + def __init__(self, base_field, length, starting_point, delta, jump_size = 1, b = 0): + """ + TESTS: + + ``delta`` must be between 2 and ``length`` (inclusive), otherwise an exception + will be raised:: - if not (delta <= n and delta > 1): + sage: C = codes.BCHCode(GF(2), 15, 1, 16) + Traceback (most recent call last): + ... + ValueError: delta must belong to [2, n] + """ + if not (delta <= length and delta > 1): raise ValueError("delta must belong to [2, n]") + if isinstance(base_field, (Integer, int)) and isinstance(starting_point, Field): + from sage.misc.superseded import deprecation + deprecation(42042, "codes.BCHCode(n, delta, F, b=0) is now deprecated. Please use the new signature instead.") + delta = copy(length) + length = copy(base_field) + F = copy(base_field) + if not isinstance(base_field, Field): + raise ValueError("base_field has to be a finite field") + elif not base_field.is_finite(): + raise ValueError("base_field has to be a finite field") D = [] - d = b + point = copy(starting_point) for i in range(0, delta - 1): - D.append(d) - d = (d + l) % n + D.append(point) + point = (point + jump_size) % length try: - super(BCHCode, self).__init__(field = F, length = n, D = D) + super(BCHCode, self).__init__(field = base_field, length = length, D = D) except ValueError, e: raise e self._default_decoder_name = "UnderlyingGRS" - self._jump_size = l + self._jump_size = jump_size self._starting_point = b self._delta = delta @@ -94,21 +120,6 @@ def __eq__(self, other): and self.jump_size() == other.jump_size() \ and self.starting_point() == other.starting_point() \ - def __ne__(self, other): - r""" - Tests inequality of BCH Code objects. - - EXAMPLES:: - - sage: F = GF(16, 'a') - sage: n = 15 - sage: C1 = codes.BCHCode(F, 15, 1, 2) - sage: C2 = codes.BCHCode(F, 13, 1, 2) - sage: C1 != C2 - True - """ - return not self.__eq__(other) - def _repr_(self): r""" Returns a string representation of ``self``. @@ -150,8 +161,17 @@ def jump_size(self): return self._jump_size def starting_point(self): - return self._starting_point + r""" + Returns the starting point which was used to compute the elements in + the defining set of ``self``. + EXAMPLES:: + + sage: C = codes.BCHCode(GF(2), 15, 1, 4, 2) + sage: C.starting_point + 1 + """ + return self._starting_point def bch_to_grs(self): r""" From 32ca611d225330ec533dc15550b27d2c21f6b516 Mon Sep 17 00:00:00 2001 From: David Lucas Date: Thu, 31 Mar 2016 13:50:47 +0200 Subject: [PATCH 003/370] Changed signature of BCHCode class and deprecated the old BCHCode method --- src/sage/coding/bch.py | 86 +++++++++++++++------------ src/sage/coding/code_constructions.py | 70 ---------------------- src/sage/coding/codes_catalog.py | 2 +- 3 files changed, 48 insertions(+), 110 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 52c011771b8..10be2008456 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -28,7 +28,8 @@ from sage.modules.free_module_element import vector from sage.misc.misc_c import prod from sage.rings.integer import Integer -from sage.rings.ring import Field +from sage.categories.fields import Fields +from sage.rings.integer_ring import ZZ from copy import copy class BCHCode(CyclicCode): @@ -41,66 +42,72 @@ class BCHCode(CyclicCode): - ``length`` -- the length of the code - - ``starting_point`` -- the first element to add in the defining set + - ``designed_distance`` -- the resulting minimum distance of the code - - ``delta`` -- the ending point for the elements in the defining set + - ``primitive_element`` -- (default: ``None``) the primitive element + to use when creating the set of roots for the generating polynomial + over the splitting field. It has to be of multiplicative order ``length`` over this + field. If the splitting field is not ``field``, it also have to be a polynomial in ``zx``, + where ``x`` is the degree of the extension field. For instance, + over ``GF(16)``, it has to be a polynomial in ``z4``. + + - ``offset`` -- (default: ``0``) the first element to add in the defining set - ``jump_size`` -- (default: ``1``) the jump size between two elements of the defining set - - ``b`` -- (default: ``0``) is exactly the same as ``starting_point``. It is only here + - ``b`` -- (default: ``0``) is exactly the same as ``offset``. It is only here for retro-compatibility purposes with the old signature of `BCHCode` and will be removed soon. EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 1, 7) + sage: C = codes.BCHCode(GF(2), 15, 7, offset = 1) sage: C [15, 5] BCH Code over Finite Field of size 2 with x^10 + x^8 + x^5 + x^4 + x^2 + x + 1 as generator polynomial - sage: C = codes.BCHCode(GF(2), 15, 1, 4, 3) + sage: C = codes.BCHCode(GF(2), 15, 4, offset = 1, jump_size = 3) sage: C [15, 7] BCH Code over Finite Field of size 2 with x^8 + x^7 + x^5 + x^4 + x^3 + x + 1 as generator polynomial """ - def __init__(self, base_field, length, starting_point, delta, jump_size = 1, b = 0): + def __init__(self, base_field, length, designed_distance, primitive_element = None, offset = 0, jump_size = 1, b = 0): """ TESTS: - ``delta`` must be between 2 and ``length`` (inclusive), otherwise an exception + ``designed_distance`` must be between 2 and ``length`` (inclusive), otherwise an exception will be raised:: - sage: C = codes.BCHCode(GF(2), 15, 1, 16) + sage: C = codes.BCHCode(GF(2), 15, 16) Traceback (most recent call last): ... - ValueError: delta must belong to [2, n] + ValueError: designed_distance must belong to [2, n] """ - if not (delta <= length and delta > 1): - raise ValueError("delta must belong to [2, n]") - if isinstance(base_field, (Integer, int)) and isinstance(starting_point, Field): + if not (designed_distance <= length and designed_distance > 1): + raise ValueError("designed_distance must belong to [2, n]") + if base_field in ZZ and designed_distance in Fields: from sage.misc.superseded import deprecation - deprecation(42042, "codes.BCHCode(n, delta, F, b=0) is now deprecated. Please use the new signature instead.") - delta = copy(length) - length = copy(base_field) - F = copy(base_field) - if not isinstance(base_field, Field): + deprecation(20335, "codes.BCHCode(n, designed_distance, F, b=0) is now deprecated. Please use the new signature instead.") + (length, designed_distance, base_field) = (base_field, length, designed_distance) + offset = b + if not base_field in Fields or not base_field.is_finite(): raise ValueError("base_field has to be a finite field") elif not base_field.is_finite(): raise ValueError("base_field has to be a finite field") D = [] - point = copy(starting_point) - for i in range(0, delta - 1): + point = copy(offset) + for i in range(0, designed_distance - 1): D.append(point) point = (point + jump_size) % length try: - super(BCHCode, self).__init__(field = base_field, length = length, D = D) + super(BCHCode, self).__init__(field = base_field, length = length, D = D, primitive_element = primitive_element) except ValueError, e: raise e - self._default_decoder_name = "UnderlyingGRS" + #self._default_decoder_name = "UnderlyingGRS" self._jump_size = jump_size - self._starting_point = b - self._delta = delta + self._offset = offset + self._designed_distance = designed_distance def __eq__(self, other): r""" @@ -110,15 +117,16 @@ def __eq__(self, other): sage: F = GF(16, 'a') sage: n = 15 - sage: C1 = codes.BCHCode(F, n, 1, 2) - sage: C2 = codes.BCHCode(F, n, 1, 2) + sage: C1 = codes.BCHCode(F, n, 2) + sage: C2 = codes.BCHCode(F, n, 2) sage: C1 == C2 True """ return isinstance(other, BCHCode) \ and self.length() == other.length() \ and self.jump_size() == other.jump_size() \ - and self.starting_point() == other.starting_point() \ + and self.offset() == self.offset()\ + and self.primitive_element() == self.primitive_element() def _repr_(self): r""" @@ -126,7 +134,7 @@ def _repr_(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 1, 7) + sage: C = codes.BCHCode(GF(2), 15, 7, offset = 1) sage: C [15, 5] BCH Code over Finite Field of size 2 with x^10 + x^8 + x^5 + x^4 + x^2 + x + 1 as generator polynomial """ @@ -140,7 +148,7 @@ def _latex_(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 1, 7) + sage: C = codes.BCHCode(GF(2), 15, 7, offset = 1) sage: latex(C) [15, 5] \textnormal{ BCH Code over } \Bold{F}_{2} \textnormal{ with } x^{10} + x^{8} + x^{5} + x^{4} + x^{2} + x + 1 \textnormal{ as generator polynomial} """ @@ -154,24 +162,24 @@ def jump_size(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 1, 4, 2) + sage: C = codes.BCHCode(GF(2), 15, 4, jump_size = 2) sage: C.jump_size() 2 """ return self._jump_size - def starting_point(self): + def offset(self): r""" - Returns the starting point which was used to compute the elements in + Returns the offset which was used to compute the elements in the defining set of ``self``. EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 1, 4, 2) - sage: C.starting_point + sage: C = codes.BCHCode(GF(2), 15, 4, offset = 1) + sage: C.offset() 1 """ - return self._starting_point + return self._offset def bch_to_grs(self): r""" @@ -179,13 +187,13 @@ def bch_to_grs(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 1, 2, 2) + sage: C = codes.BCHCode(GF(2), 15, 2, jump_size = 2, offset = 1) sage: C.bch_to_grs() - [15, 13, 3] Generalized Reed-Solomon Code over Finite Field in b of size 2^4 + [15, 13, 3] Generalized Reed-Solomon Code over Finite Field in z4 of size 2^4 """ l = self.jump_size() - alpha = self.root_of_unity() - b = self.starting_point() + alpha = self.primitive_element() + b = self.offset() n = self.length() grs_dim = n - self.bch_bound(arithmetic = True) + 1 diff --git a/src/sage/coding/code_constructions.py b/src/sage/coding/code_constructions.py index eef7cbb3e38..79bd418182d 100644 --- a/src/sage/coding/code_constructions.py +++ b/src/sage/coding/code_constructions.py @@ -475,76 +475,6 @@ def walsh_matrix(m0): ##################### main constructions ##################### - - -def BCHCode(n,delta,F,b=0): - r""" - A 'Bose-Chaudhuri-Hockenghem code' (or BCH code for short) is the - largest possible cyclic code of length n over field F=GF(q), whose - generator polynomial has zeros (which contain the set) - `Z = \{a^{b},a^{b+1}, ..., a^{b+delta-2}\}`, where a is a - primitive `n^{th}` root of unity in the splitting field - `GF(q^m)`, b is an integer `0\leq b\leq n-delta+1` - and m is the multiplicative order of q modulo n. (The integers - `b,...,b+delta-2` typically lie in the range - `1,...,n-1`.) The integer `delta \geq 1` is called - the "designed distance". The length n of the code and the size q of - the base field must be relatively prime. The generator polynomial - is equal to the least common multiple of the minimal polynomials of - the elements of the set `Z` above. - - Special cases are b=1 (resulting codes are called 'narrow-sense' - BCH codes), and `n=q^m-1` (known as 'primitive' BCH - codes). - - It may happen that several values of delta give rise to the same - BCH code. The largest one is called the Bose distance of the code. - The true minimum distance, d, of the code is greater than or equal - to the Bose distance, so `d\geq delta`. - - EXAMPLES:: - - sage: FF. = GF(3^2,"a") - sage: x = PolynomialRing(FF,"x").gen() - sage: L = [b.minpoly() for b in [a,a^2,a^3]]; g = LCM(L) - sage: f = x^(8)-1 - sage: g.divides(f) - True - sage: C = codes.CyclicCode(generator_pol = g, length = 8); C - [8, 4] Cyclic Code over Finite Field of size 3 with x^4 + 2*x^3 + 2*x + 2 as generator polynomial - sage: C.minimum_distance() - 4 - sage: C = codes.BCHCode(8,3,GF(3),1); C - [8, 4] Cyclic Code over Finite Field of size 3 with x^4 + 2*x^3 + 2*x + 2 as generator polynomial - sage: C.minimum_distance() - 4 - sage: C = codes.BCHCode(8,3,GF(3)); C - [8, 5] Cyclic Code over Finite Field of size 3 with x^3 + x^2 + 1 as generator polynomial - sage: C.minimum_distance() - 3 - sage: C = codes.BCHCode(26, 5, GF(5), b=1); C - [26, 10] Cyclic Code over Finite Field of size 5 with x^16 + 4*x^15 + 4*x^14 + x^13 + 4*x^12 + 3*x^10 + 3*x^9 + x^8 + 3*x^7 + 3*x^6 + 4*x^4 + x^3 + 4*x^2 + 4*x + 1 as generator polynomial - """ - from sage.coding.cyclic_code import CyclicCode - q = F.order() - R = IntegerModRing(n) - m = R(q).multiplicative_order() - FF = GF(q**m,"z") - z = FF.gen() - e = z.multiplicative_order()/n - a = z**e # order n - P = PolynomialRing(F,"x") - x = P.gen() - L1 = [] - for coset in R.cyclotomic_cosets(q, range(b,b+delta-1)): - L1.extend(P((a**j).minpoly()) for j in coset) - g = P(LCM(L1)) - #print cosets, "\n", g, "\n", (x**n-1).factor(), "\n", L1, "\n", g.divides(x**n-1) - if not(g.divides(x**n-1)): - raise ValueError("BCH codes does not exist with the given input.") - return CyclicCode(generator_pol = g, length = n) - - def BinaryGolayCode(): r""" BinaryGolayCode() returns a binary Golay code. This is a perfect diff --git a/src/sage/coding/codes_catalog.py b/src/sage/coding/codes_catalog.py index 8b4298655f5..1bcdf692a41 100644 --- a/src/sage/coding/codes_catalog.py +++ b/src/sage/coding/codes_catalog.py @@ -18,7 +18,7 @@ # This module is imported as "codes" in all.py so that codes. is available # in the global namespace. -from code_constructions import (BCHCode, BinaryGolayCode, CyclicCodeFromGeneratingPolynomial, +from code_constructions import (BinaryGolayCode, CyclicCodeFromGeneratingPolynomial, CyclicCodeFromCheckPolynomial, DuadicCodeEvenPair, DuadicCodeOddPair, ExtendedBinaryGolayCode, ExtendedQuadraticResidueCode, ExtendedTernaryGolayCode, From baa56809e0adeee977b8b76a1ee4bb691a9e9e9c Mon Sep 17 00:00:00 2001 From: David Lucas Date: Thu, 31 Mar 2016 14:20:10 +0200 Subject: [PATCH 004/370] Added decoder for BCH codes --- src/sage/coding/bch.py | 176 +++++++++++++++++++++++++++- src/sage/coding/cyclic_code.py | 1 + src/sage/coding/decoders_catalog.py | 5 + 3 files changed, 181 insertions(+), 1 deletion(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 10be2008456..4fb0e7cadce 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -104,7 +104,7 @@ def __init__(self, base_field, length, designed_distance, primitive_element = No super(BCHCode, self).__init__(field = base_field, length = length, D = D, primitive_element = primitive_element) except ValueError, e: raise e - #self._default_decoder_name = "UnderlyingGRS" + self._default_decoder_name = "UnderlyingGRS" self._jump_size = jump_size self._offset = offset self._designed_distance = designed_distance @@ -209,3 +209,177 @@ def bch_to_grs(self): column_multipliers = [multipliers_product[i]/pcm[i] for i in range(n)] return GeneralizedReedSolomonCode(evals, grs_dim, column_multipliers) + + +class BCHUnderlyingGRSDecoder(Decoder): + r""" + A decoder which decodes through the underlying + :class:`sage.coding.grs.GeneralizedReedSolomonCode` code of the provided BCH code. + + INPUT: + + - ``code`` -- The associated code of this decoder. + + - ``grs_decoder`` -- The string name of the decoder to use over the underlying GRS code + + - ``**kwargs`` -- All extra arguments are forwarded to the GRS decoder + """ + + def __init__(self, code, grs_decoder = "KeyEquationSyndrome", **kwargs): + r""" + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) + sage: D + Decoder through the underlying GRS code of [15, 11] BCH Code over Finite Field in a of size 2^2 with x^4 + a*x^3 + a as generator polynomial + """ + + self._grs_code = code.bch_to_grs() + self._grs_decoder = self._grs_code.decoder(grs_decoder, **kwargs) + self._decoder_type = copy(self._decoder_type) + self._decoder_type.remove("dynamic") + self._decoder_type = self._grs_decoder.decoder_type() + super(BCHUnderlyingGRSDecoder, self).__init__(code, code.ambient_space(), "Vector") + + def _repr_(self): + r""" + Returns a string representation of ``self``. + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) + sage: D + Decoder through the underlying GRS code of [15, 11] BCH Code over Finite Field in a of size 2^2 with x^4 + a*x^3 + a as generator polynomial + """ + return "Decoder through the underlying GRS code of %s" % self.code() + + def _latex_(self): + r""" + Returns a latex representation of ``self``. + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) + sage: latex(D) + \textnormal{Decoder through the underlying GRS code of } [15, 11] \textnormal{ BCH Code over } \Bold{F}_{2^{2}} \textnormal{ with } x^{4} + a x^{3} + a \textnormal{ as generator polynomial} + """ + return "\\textnormal{Decoder through the underlying GRS code of } %s" % (self.code()._latex_()) + + def grs_code(self): + r""" + Returns the underlying GRS code of :meth:`sage.coding.decoder.Decoder.code`. + + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(2), 15, 2, jump_size = 2, offset = 1) + sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) + sage: D.grs_code() + [15, 13, 3] Generalized Reed-Solomon Code over Finite Field in z4 of size 2^4 + """ + return self._grs_code + + def grs_decoder(self): + r""" + Returns the decoder used to decode words of :meth:`grs_code`. + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) + sage: D.grs_decoder() + Key equation decoder for [15, 13, 3] Generalized Reed-Solomon Code over Finite Field in z4 of size 2^4 + """ + return self._grs_decoder + + def bch_word_to_grs(self, c): + r""" + Returns ``c`` converted as a codeword of :meth:`grs_code`. + + EXAMPLES:: + + sage: F = GF(4, 'a') + sage: a = F.gen() + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) + sage: c = vector(F, [0, a, 1, a, 0, 1, 1, 1, a, 0, 0, a + 1, a, 0, 1]) + sage: D.bch_word_to_grs(c) + (0, z4^2 + z4, 1, z4^2 + z4, 0, 1, 1, 1, z4^2 + z4, 0, 0, z4^2 + z4 + 1, z4^2 + z4, 0, 1) + """ + mapping = self.code()._field_embedding.embedding() + a = [mapping(i) for i in c] + + return vector(a) + + def grs_word_to_bch(self, c): + r""" + Returns ``c`` converted as a codeword of :meth:`sage.coding.decoder.Decoder.code`. + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) + sage: Cgrs = D.grs_code() + sage: Fgrs = Cgrs.base_field() + sage: b = Fgrs.gen() + sage: c = vector(Fgrs, [0, b^2 + b, 1, b^2 + b, 0, 1, 1, 1, b^2 + b, 0, 0, b^2 + b + 1, b^2 + b, 0, 1]) + sage: D.grs_word_to_bch(c) + (0, a, 1, a, 0, 1, 1, 1, a, 0, 0, a + 1, a, 0, 1) + """ + C = self.code() + FE = C._field_embedding + a = [] + for i in c: + a.append(FE.small_field_polynomial_representation(i)) + return vector(a) + + def decode_to_code(self, y): + r""" + Decodes ``y`` to an element in :meth:`sage.coding.decoder.Decoder.code`. + + EXAMPLES:: + + sage: F = GF(4, 'a') + sage: a = F.gen() + sage: C = codes.BCHCode(F, 15, 3, jump_size = 2, offset = 1) + sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) + sage: y = vector(F, [a, a + 1, 1, a + 1, 1, a, a + 1, a + 1, 0, 1, a + 1, 1, 1, 1, a]) + sage: D.decode_to_code(y) + (a, a + 1, 1, a + 1, 1, a, a + 1, a + 1, 0, 1, a + 1, 1, 1, 1, a) + sage: D.decode_to_code(y) in C + True + """ + D = self.grs_decoder() + ygrs = self.bch_word_to_grs(y) + try: + cgrs = D.decode_to_code(ygrs) + except DecodingError, e: + raise e + if "list-decoder" in D.decoder_type(): + l = [] + for c in cgrs: + l.append(self.grs_word_to_bch(c)) + return l + return self.grs_word_to_bch(cgrs) + + def decoding_radius(self): + r""" + Returns maximal number of errors that ``self`` can decode. + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) + sage: D.decoding_radius() + 1 + """ + return (self.code().bch_bound(arithmetic = True) - 1) // 2 + +####################### registration ############################### + +BCHCode._registered_decoders["UnderlyingGRS"] = BCHUnderlyingGRSDecoder +BCHUnderlyingGRSDecoder._decoder_type = {"dynamic"} diff --git a/src/sage/coding/cyclic_code.py b/src/sage/coding/cyclic_code.py index 8c26adde326..a8f779cfdc2 100644 --- a/src/sage/coding/cyclic_code.py +++ b/src/sage/coding/cyclic_code.py @@ -523,6 +523,7 @@ def __init__(self, generator_pol=None, length=None, code=None, probabilistic = F else: Fsplit, F_to_Fsplit = F.extension(Integer(s), map = True) FE = FieldEmbedding(Fsplit, F, embedding = F_to_Fsplit) + self._field_embedding = FE if primitive_element is not None and (primitive_element not in Fsplit or multiplicative_order(primitive_element) != n): raise ValueError("primitive_element has to be an element of multplicative order n in the extension field used to compute the generator polynomial") diff --git a/src/sage/coding/decoders_catalog.py b/src/sage/coding/decoders_catalog.py index e652ad887a1..9109cf6ce3c 100644 --- a/src/sage/coding/decoders_catalog.py +++ b/src/sage/coding/decoders_catalog.py @@ -20,6 +20,10 @@ - :class:`grs.GRSKeyEquationSyndromeDecoder ` - :class:`guruswami_sudan.gs_decoder.GRSGuruswamiSudanDecoder ` +**BCH code decoder** + +- :class:`bch.BCHUnderlyingGRSDecoder ` + .. NOTE:: To import these names into the global namespace, use: @@ -43,3 +47,4 @@ GRSKeyEquationSyndromeDecoder, GRSErrorErasureDecoder) from guruswami_sudan.gs_decoder import GRSGuruswamiSudanDecoder +from bch import BCHUnderlyingGRSDecoder From 1449cb42df209bdbcdd0de14bfaae429b72f376f Mon Sep 17 00:00:00 2001 From: David Lucas Date: Thu, 31 Mar 2016 14:39:56 +0200 Subject: [PATCH 005/370] Added decoder for cyclic code --- src/sage/coding/bch.py | 23 ++-- src/sage/coding/cyclic_code.py | 163 +++++++++++++++++++++++++++- src/sage/coding/decoders_catalog.py | 6 + 3 files changed, 180 insertions(+), 12 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 4fb0e7cadce..3432f7194b6 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -310,10 +310,13 @@ def bch_word_to_grs(self, c): sage: D.bch_word_to_grs(c) (0, z4^2 + z4, 1, z4^2 + z4, 0, 1, 1, 1, z4^2 + z4, 0, 0, z4^2 + z4 + 1, z4^2 + z4, 0, 1) """ - mapping = self.code()._field_embedding.embedding() - a = [mapping(i) for i in c] - - return vector(a) + C = self.code() + if hasattr(self.code(), "field_embedding"): + mapping = self.code()._field_embedding.embedding() + a = [mapping(i) for i in c] + return vector(a) + else: + return c def grs_word_to_bch(self, c): r""" @@ -331,11 +334,13 @@ def grs_word_to_bch(self, c): (0, a, 1, a, 0, 1, 1, 1, a, 0, 0, a + 1, a, 0, 1) """ C = self.code() - FE = C._field_embedding - a = [] - for i in c: - a.append(FE.small_field_polynomial_representation(i)) - return vector(a) + if hasattr(self.code(), "field_embedding"): + FE = C._field_embedding + a = [] + for i in c: + a.append(FE.small_field_polynomial_representation(i)) + return vector(a) + return c def decode_to_code(self, y): r""" diff --git a/src/sage/coding/cyclic_code.py b/src/sage/coding/cyclic_code.py index a8f779cfdc2..dd624830276 100644 --- a/src/sage/coding/cyclic_code.py +++ b/src/sage/coding/cyclic_code.py @@ -476,7 +476,7 @@ def __init__(self, generator_pol=None, length=None, code=None, probabilistic = F raise ValueError("Provided polynomial must divide x^n - 1, where n is the provided length") self._dimension = length - deg self._generator_polynomial = generator_pol - super(CyclicCode, self).__init__(F, length, "Vector", "Syndrome") + super(CyclicCode, self).__init__(F, length, "Vector", "SurroundingBCH") elif code is not None: try: g = find_generator_polynomial(code, probabilistic) @@ -486,7 +486,7 @@ def __init__(self, generator_pol=None, length=None, code=None, probabilistic = F g = g.monic() self._generator_polynomial = g self._dimension = code.dimension() - super(CyclicCode, self).__init__(code.base_ring(), code.length(), "Vector", "Syndrome") + super(CyclicCode, self).__init__(code.base_ring(), code.length(), "Vector", "SurroundingBCH") elif D is not None and length is not None and field is not None: F = field n = length @@ -570,7 +570,7 @@ def __init__(self, generator_pol=None, length=None, code=None, probabilistic = F self._defining_set.sort() self._generator_polynomial = g self._dimension = n - g.degree() - super(CyclicCode, self).__init__(F, n, "Vector", "Syndrome") + super(CyclicCode, self).__init__(F, n, "Vector", "SurroundingBCH") else: raise AttributeError("You must provide either a code, or a list of powers and the length\ @@ -881,6 +881,21 @@ def bch_bound(self, arithmetic = False, bch_parameters = False): return bch_bound(n = self.length(), D = self.defining_set(), arithmetic = arithmetic,\ bch_parameters = bch_parameters) + @cached_method + def surrounding_bch_code(self): + r""" + Returns the surrounding BCH code of ``self``. + + EXAMPLES:: + + sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: C.surrounding_bch_code() + [15, 12] BCH Code over Finite Field in a of size 2^4 with x^3 + a^2*x^2 + a*x + a^3 + a^2 + a + 1 as generator polynomial + """ + from bch import BCHCode + delta, params = self.bch_bound(arithmetic = True, bch_parameters = True) + return BCHCode(self.base_field(), self.length(), delta, offset=params[0], jump_size=params[1]) + @@ -1298,9 +1313,151 @@ def message_space(self): """ return self.code().base_ring() ** self.code().dimension() + + + + + + + +class CyclicCodeSurroundingBCHDecoder(Decoder): + r""" + A decoder which decodes through the surrounding BCH code of the cyclic code. + + INPUT: + + - ``code`` -- The associated code of this decoder. + + - ``**kwargs`` -- All extra arguments are forwarded to the BCH decoder + + EXAMPLES:: + + sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) + sage: D + Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over Finite Field in a of size 2^4 with x^5 + (a^3 + a^2 + a)*x^4 + x^3 + (a^3 + 1)*x^2 + (a^2 + 1)*x + a^2 + a + 1 as generator polynomial + """ + def __init__(self, code, **kwargs): + r""" + + EXAMPLES:: + + sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) + sage: D + Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over Finite Field in a of size 2^4 with x^5 + (a^3 + a^2 + a)*x^4 + x^3 + (a^3 + 1)*x^2 + (a^2 + 1)*x + a^2 + a + 1 as generator polynomial + """ + self._bch_code = code.surrounding_bch_code() + self._bch_decoder = self._bch_code.decoder(**kwargs) + self._decoder_type = copy(self._decoder_type) + self._decoder_type.remove("dynamic") + self._decoder_type = self._bch_decoder.decoder_type() + super(CyclicCodeSurroundingBCHDecoder, self).__init__(code, code.ambient_space(), "Vector") + + def __eq__(self, other): + r""" + Tests equality between CyclicCodeSurroundingBCHDecoder objects. + + EXAMPLES:: + + sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: D1 = C.decoder() + sage: D2 = C.decoder() + sage: D1 == D2 + True + """ + return isinstance(other, CyclicCodeSurroundingBCHDecoder) \ + and self.code() == other.code()\ + and self.bch_decoder() == other.bch_decoder() + + def _repr_(self): + r""" + Returns a string representation of ``self``. + + EXAMPLES:: + + sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) + sage: D + Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over Finite Field in a of size 2^4 with x^5 + (a^3 + a^2 + a)*x^4 + x^3 + (a^3 + 1)*x^2 + (a^2 + 1)*x + a^2 + a + 1 as generator polynomial + """ + return "Decoder through the surrounding BCH code of the %s" % self.code() + + def _latex_(self): + r""" + Returns a latex representation of ``self``. + + EXAMPLES:: + + sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) + sage: latex(D) + \textnormal{Decoder through the surrounding BCH code of the }[15, 10] \textnormal{ Cyclic Code over } \Bold{F}_{2^{4}} \textnormal{ with } x^{5} + \left(a^{3} + a^{2} + a\right) x^{4} + x^{3} + \left(a^{3} + 1\right) x^{2} + \left(a^{2} + 1\right) x + a^{2} + a + 1 \textnormal{ as generator polynomial} + """ + return "\\textnormal{Decoder through the surrounding BCH code of the }%s"\ + % self.code()._latex_() + + def bch_code(self): + r""" + Returns the surrounding BCH code of :meth:`sage.coding.encoder.Encoder.code`. + + EXAMPLES:: + + sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) + sage: D.bch_code() + [15, 12] BCH Code over Finite Field in a of size 2^4 with x^3 + a^2*x^2 + a*x + a^3 + a^2 + a + 1 as generator polynomial + """ + return self._bch_code + + def bch_decoder(self): + r""" + Returns the decoder that will be used over the surrounding BCH code. + + EXAMPLES:: + + sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) + sage: D.bch_decoder() + Decoder through the underlying GRS code of [15, 12] BCH Code over Finite Field in a of size 2^4 with x^3 + a^2*x^2 + a*x + a^3 + a^2 + a + 1 as generator polynomial + """ + return self._bch_decoder + + def decode_to_code(self, y): + r""" + Decodes ``r`` to an element in :meth:`sage.coding.encoder.Encoder.code`. + + EXAMPLES:: + + sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: a = GF(16, 'a').gen() + sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) + sage: y = vector(GF(16, 'a'), [0, a^3, a^3 + a^2 + a, 1, a^2 + 1, a^3 + a^2 + 1, a^3 + a^2 + a, a^3 + a^2 + a, a^2 + a, a^2 + 1, a^2 + a + 1, a^3 + 1, a^2, a^3 + a, a^3 + a]) + sage: D.decode_to_code(y) in C + True + """ + return self.bch_code().decode_to_code(y) + + def decoding_radius(self): + r""" + Returns maximal number of errors that ``self`` can decode. + + EXAMPLES:: + + sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) + sage: D.decoding_radius() + 1 + """ + return (self.code().bch_bound(arithmetic = True) - 1) // 2 + + ####################### registration ############################### CyclicCode._registered_encoders["Polynomial"] = CyclicCodePolynomialEncoder CyclicCode._registered_encoders["Vector"] = CyclicCodeVectorEncoder CyclicCode._registered_decoders["Syndrome"] = LinearCodeSyndromeDecoder CyclicCode._registered_decoders["NearestNeighbor"] = LinearCodeNearestNeighborDecoder + +CyclicCode._registered_decoders["SurroundingBCH"] = CyclicCodeSurroundingBCHDecoder +CyclicCodeSurroundingBCHDecoder._decoder_type = {"dynamic"} diff --git a/src/sage/coding/decoders_catalog.py b/src/sage/coding/decoders_catalog.py index 9109cf6ce3c..3e821724033 100644 --- a/src/sage/coding/decoders_catalog.py +++ b/src/sage/coding/decoders_catalog.py @@ -20,6 +20,11 @@ - :class:`grs.GRSKeyEquationSyndromeDecoder ` - :class:`guruswami_sudan.gs_decoder.GRSGuruswamiSudanDecoder ` +**Cyclic code decoder** + +- :class:`cyclic_code.CyclicCodeSurroundingBCHDecoder ` + + **BCH code decoder** - :class:`bch.BCHUnderlyingGRSDecoder ` @@ -48,3 +53,4 @@ GRSErrorErasureDecoder) from guruswami_sudan.gs_decoder import GRSGuruswamiSudanDecoder from bch import BCHUnderlyingGRSDecoder +from cyclic_code import CyclicCodeSurroundingBCHDecoder From 4a52745b734543ca8e65f2ac3050c9a73f223edd Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Wed, 1 Jun 2016 12:27:45 +0200 Subject: [PATCH 006/370] Trac 20746: pushout for real embedded number fields --- .../rings/number_field/number_field_base.pyx | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/sage/rings/number_field/number_field_base.pyx b/src/sage/rings/number_field/number_field_base.pyx index e8bfbbf4628..9fdb9cfbf47 100644 --- a/src/sage/rings/number_field/number_field_base.pyx +++ b/src/sage/rings/number_field/number_field_base.pyx @@ -40,6 +40,50 @@ cdef class NumberField(Field): # This token docstring is mostly there to prevent Sphinx from pasting in # the docstring of the __init__ method inherited from IntegralDomain, which # is rather confusing. + def _pushout_(self, other): + r""" + TESTS: + + Pushout is implemented for number field embedded in ``AA``:: + + sage: K. = NumberField(x^2 - 3, embedding=AA(3)**(1/2)) + sage: L. = NumberField(x^2 - 2, embedding=AA(2)**(1/2)) + sage: cm = sage.structure.element.get_coercion_model() + sage: cm.explain(K,L,operator.add) + Coercion on left operand via + Generic morphism: + From: Number Field in a with defining polynomial x^2 - 3 + To: Algebraic Real Field + Defn: a -> 1.732050807568878? + Coercion on right operand via + Generic morphism: + From: Number Field in b with defining polynomial x^2 - 2 + To: Algebraic Real Field + Defn: b -> 1.414213562373095? + Arithmetic performed after coercions. + Result lives in Algebraic Real Field + Algebraic Real Field + + As a consequence, operations and comparisons work nicely:: + + sage: a + b + 3.146264369941973? + sage: a < b + False + sage: 3*a < 4*b + True + + Using number field with other classes:: + + sage: K. = NumberField(x^3 - 2, embedding=AA(2)**(1/3)) + sage: (cbrt2 + a) * b + 4.231287179063857? + """ + if isinstance(other, NumberField) and \ + self._embedded_real and \ + (other)._embedded_real: + from sage.rings.qqbar import AA + return AA def ring_of_integers(self, *args, **kwds): r""" From b5303b77810f0b92d22724ed4cfa909202426771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Thu, 14 Jul 2016 20:15:45 -0600 Subject: [PATCH 007/370] Add doctest for #15188 Checking the degree of quotient with remainder with p-adic coefficients --- .../padics/polynomial_padic_capped_relative_dense.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py b/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py index 3acae3b11f1..6be0467d799 100644 --- a/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py +++ b/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py @@ -1035,6 +1035,15 @@ def quo_rem(self, right, secure=False): sage: g.quo_rem(f) ((1 + O(3^10))*T^3 + (1 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + 2*3^7 + 2*3^8 + 2*3^9 + O(3^10))*T^2 + (1 + 3 + O(3^10))*T + (1 + 3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + 2*3^7 + 2*3^8 + 2*3^9 + O(3^10)), (2 + 3 + 3^3 + O(3^10))) + + TESTS: + + Verify that :trac:`15188` has been resolved:: + + sage: R. = Qp(3)[] + sage: x.quo_rem(x) + ((1 + O(3^20)), 0) + """ return self._quo_rem_list(right, secure=secure) From 7994411012fac36db9974dd51f4fef938df56067 Mon Sep 17 00:00:00 2001 From: David Lucas Date: Thu, 11 Aug 2016 13:17:31 +0200 Subject: [PATCH 008/370] Fixed broken doctests --- src/sage/coding/bch.py | 17 ++++++++++++++++- src/sage/coding/code_constructions.py | 8 ++++---- src/sage/coding/cyclic_code.py | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 8d17288a6f8..7b906aa1e7a 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -8,6 +8,21 @@ A BCH code consists of all codewords `c(x) \in F_{n}[x]` such that `c(\alpha^{a}) = 0`, for `a = b, b + l, b + 2\times l, \dots, b + (\delta - 2) \times l`, with `b`, `\delta` integers such that `b < \delta` and `0 < \delta \leq n`. + +TESTS: + +This class uses the following experimental feature: +:class:`sage.coding.relative_finite_field_extension.RelativeFiniteFieldExtension`. +This test block is here only to trigger the experimental warning so it does not +interferes with doctests:: + + sage: from sage.coding.relative_finite_field_extension import * + sage: Fqm. = GF(16) + sage: Fq. = GF(4) + sage: RelativeFiniteFieldExtension(Fqm, Fq) + doctest:...: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation. + See http://trac.sagemath.org/20284 for details. + Relative field extension between Finite Field in aa of size 2^4 and Finite Field in a of size 2^2 """ #***************************************************************************** @@ -338,7 +353,7 @@ def grs_word_to_bch(self, c): FE = C._field_embedding a = [] for i in c: - a.append(FE.small_field_polynomial_representation(i)) + a.append(FE.cast_into_relative_field(i)) return vector(a) return c diff --git a/src/sage/coding/code_constructions.py b/src/sage/coding/code_constructions.py index 52cd79c5841..6a10317a9ce 100644 --- a/src/sage/coding/code_constructions.py +++ b/src/sage/coding/code_constructions.py @@ -263,7 +263,7 @@ def is_a_splitting(S1, S2, n, return_automorphism=False): True sage: C1 = codes.CyclicCode(length = n, generator_pol = gcd(i1, x^n - 1)) sage: C2 = codes.CyclicCode(length = n, generator_pol = gcd(1-i2, x^n - 1)) - sage: C1.dual_code().generator_matrix_systematic() == C2.generator_matrix_systematic() + sage: C1.dual_code().systematic_generator_matrix() == C2.systematic_generator_matrix() True This is a special case of Theorem 6.4.3 in [HP]_. @@ -559,7 +559,7 @@ def DuadicCodeEvenPair(F,S1,S2): ([11, 5] Cyclic Code over Finite Field of size 3 with x^6 + x^4 + 2*x^3 + 2*x^2 + 2*x + 1 as generator polynomial, [11, 5] Cyclic Code over Finite Field of size 3 with x^6 + 2*x^5 + 2*x^4 + 2*x^3 + x^2 + 1 as generator polynomial) """ - from cyclic_code import CyclicCode + from .cyclic_code import CyclicCode n = len(S1) + len(S2) + 1 if not is_a_splitting(S1,S2,n): raise TypeError("%s, %s must be a splitting of %s."%(S1,S2,n)) @@ -606,7 +606,7 @@ def DuadicCodeOddPair(F,S1,S2): This is consistent with Theorem 6.1.3 in [HP]_. """ - from cyclic_code import CyclicCode + from .cyclic_code import CyclicCode n = len(S1) + len(S2) + 1 if not is_a_splitting(S1,S2,n): raise TypeError("%s, %s must be a splitting of %s."%(S1,S2,n)) @@ -863,7 +863,7 @@ def QuadraticResidueCodeEvenPair(n,F): True sage: C3 = codes.QuadraticResidueCodeOddPair(17,GF(2))[0] sage: C4 = codes.QuadraticResidueCodeEvenPair(17,GF(2))[1] - sage: C3.generator_matrix_systematic() == C4.dual_code().generator_matrix_systematic() + sage: C3.systematic_generator_matrix() == C4.dual_code().systematic_generator_matrix() True This is consistent with Theorem 6.6.9 and Exercise 365 in [HP]_. diff --git a/src/sage/coding/cyclic_code.py b/src/sage/coding/cyclic_code.py index a75d06b57f9..3b28cdaffde 100644 --- a/src/sage/coding/cyclic_code.py +++ b/src/sage/coding/cyclic_code.py @@ -553,6 +553,7 @@ def __init__(self, generator_pol=None, length=None, code=None, probabilistic = F else: Fsplit, F_to_Fsplit = F.extension(Integer(s), map = True) FE = RelativeFiniteFieldExtension(Fsplit, F, embedding = F_to_Fsplit) + self._field_embedding = FE if primitive_element is not None and (primitive_element not in Fsplit or multiplicative_order(primitive_element) != n): raise ValueError("primitive_element has to be an element of multplicative order n in the extension field used to compute the generator polynomial") From 22bf825a40b7f4b82b9604a1d30fbadfc3a6a2ef Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 7 Nov 2016 18:16:26 +0100 Subject: [PATCH 009/370] OmegaGroup --- omega.py | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 omega.py diff --git a/omega.py b/omega.py new file mode 100644 index 00000000000..e99db4d5a8d --- /dev/null +++ b/omega.py @@ -0,0 +1,74 @@ + +from sage.groups.indexed_free_group import IndexedFreeAbelianGroup +from six import iteritems + +class OmegaGroup(IndexedFreeAbelianGroup): + + @staticmethod + def __classcall__(cls, base_ring, names): + from sage.structure.unique_representation import UniqueRepresentation + names = LaurentPolynomialRing(QQ, names).variable_names() + return UniqueRepresentation.__classcall__(cls, base_ring, names) + + + def __init__(self, base_ring, names): + r""" + EXAMPLES:: + + sage: G = OmegaGroup(QQ, 'x, y'); G + OmegaGroup in x, y over Rational Field + """ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + L = LaurentPolynomialRing(base_ring, names) + self._factor_ring_ = L + super(OmegaGroup, self).__init__(indices=L, prefix='', + names=names, + bracket='(', latex_bracket='(') + + + def factor_ring(self): + return self._factor_ring_ + + + def _repr_(self): + return 'OmegaGroup in {} over {}'.format( + ', '.join(self.variable_names()), + self.factor_ring().base_ring()) + + + def _element_constructor_(self, x=None): + r""" + TESTS:: + + sage: G = OmegaGroup(QQ, 'mu, x, y') + sage: var('mu, x, y') + (mu, x, y) + sage: G(1 / (1-mu*x) / (1-y/mu)) + (1 - mu^-1*y)^-1*(-mu*x + 1)^-1 + """ + if isinstance(x, Expression): + import operator + from sage.symbolic.operators import mul_vararg + factors = [] + if x.operator() == mul_vararg: + x = list( + (f.operands() if f.operator() == operator.pow else (f, 1)) + for f in x.operands()) + elif x.operator() == operator.pow: + x = [x.operands()] + else: + x = [(x, 1)] + L = self.factor_ring() + x = list((L(f), e) for f, e in x) + return super(OmegaGroup, self)._element_constructor_(x) + + + class Element(IndexedFreeAbelianGroup.Element): + def __init__(self, parent, x, normalize=True): + if normalize: + from sage.misc.misc_c import prod + L = parent.factor_ring() + constant = prod( + (f.constant_coefficient()**e for f, e in iteritems(x)), L.one()) + x = {f/f.constant_coefficient(): e for f, e in iteritems(x)} + super(OmegaGroup.Element, self).__init__(parent, x) From 9729b02527203e0311ff17df30729984c71c6cfa Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 7 Nov 2016 18:20:09 +0100 Subject: [PATCH 010/370] move Element outside class --- omega.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/omega.py b/omega.py index e99db4d5a8d..2f6ce4fd4d9 100644 --- a/omega.py +++ b/omega.py @@ -2,8 +2,22 @@ from sage.groups.indexed_free_group import IndexedFreeAbelianGroup from six import iteritems +class OmegaGroupElement(IndexedFreeAbelianGroup.Element): + + def __init__(self, parent, x, normalize=True): + if normalize: + from sage.misc.misc_c import prod + L = parent.factor_ring() + constant = prod( + (f.constant_coefficient()**e for f, e in iteritems(x)), L.one()) + x = {f/f.constant_coefficient(): e for f, e in iteritems(x)} + super(OmegaGroup.Element, self).__init__(parent, x) + + class OmegaGroup(IndexedFreeAbelianGroup): + Element = OmegaGroupElement + @staticmethod def __classcall__(cls, base_ring, names): from sage.structure.unique_representation import UniqueRepresentation @@ -61,14 +75,3 @@ def _element_constructor_(self, x=None): L = self.factor_ring() x = list((L(f), e) for f, e in x) return super(OmegaGroup, self)._element_constructor_(x) - - - class Element(IndexedFreeAbelianGroup.Element): - def __init__(self, parent, x, normalize=True): - if normalize: - from sage.misc.misc_c import prod - L = parent.factor_ring() - constant = prod( - (f.constant_coefficient()**e for f, e in iteritems(x)), L.one()) - x = {f/f.constant_coefficient(): e for f, e in iteritems(x)} - super(OmegaGroup.Element, self).__init__(parent, x) From 1a2b5247a648c7542510b647d7e602dd43d44520 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 7 Nov 2016 20:02:52 +0100 Subject: [PATCH 011/370] copyleft --- omega.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/omega.py b/omega.py index 2f6ce4fd4d9..9151d8e6841 100644 --- a/omega.py +++ b/omega.py @@ -1,4 +1,13 @@ +# ***************************************************************************** +# Copyright (C) 2016 Daniel Krenn +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +# ***************************************************************************** from sage.groups.indexed_free_group import IndexedFreeAbelianGroup from six import iteritems From 3774c807a1703a1fa7e567a977890dbc44ab45f0 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 7 Nov 2016 20:03:05 +0100 Subject: [PATCH 012/370] Python3 imports --- omega.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/omega.py b/omega.py index 9151d8e6841..2baca25bed2 100644 --- a/omega.py +++ b/omega.py @@ -8,6 +8,9 @@ # (at your option) any later version. # http://www.gnu.org/licenses/ # ***************************************************************************** + +from __future__ import print_function +from __future__ import absolute_import from sage.groups.indexed_free_group import IndexedFreeAbelianGroup from six import iteritems From 88967e1a170e9c25a9cc7f298fcfdf55a85f0521 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 7 Nov 2016 20:14:40 +0100 Subject: [PATCH 013/370] homogenous symmetric function --- omega.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/omega.py b/omega.py index 2baca25bed2..f71caa5e8df 100644 --- a/omega.py +++ b/omega.py @@ -14,6 +14,26 @@ from sage.groups.indexed_free_group import IndexedFreeAbelianGroup from six import iteritems + +def HomogenousSymmetricFunction(j, x): + r""" + EXAMPLES:: + + sage: P = PolynomialRing(ZZ, 'X', 3) + sage: HomogenousSymmetricFunction(0, P.gens()) + 1 + sage: HomogenousSymmetricFunction(1, P.gens()) + X0 + X1 + X2 + sage: HomogenousSymmetricFunction(2, P.gens()) + X0^2 + X0*X1 + X1^2 + X0*X2 + X1*X2 + X2^2 + sage: HomogenousSymmetricFunction(3, P.gens()) + X0^3 + X0^2*X1 + X0*X1^2 + X1^3 + X0^2*X2 + + X0*X1*X2 + X1^2*X2 + X0*X2^2 + X1*X2^2 + X2^3 + """ + from sage.combinat.integer_vector import IntegerVectors + return sum(prod(xx**pp for xx, pp in zip(x, p)) + for p in IntegerVectors(j, length=len(x))) + class OmegaGroupElement(IndexedFreeAbelianGroup.Element): def __init__(self, parent, x, normalize=True): From 767391baa311a5d790f18b9b2f7595ccc1506e85 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 7 Nov 2016 20:14:58 +0100 Subject: [PATCH 014/370] Omega_Fundamental --- omega.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/omega.py b/omega.py index f71caa5e8df..727fd799a75 100644 --- a/omega.py +++ b/omega.py @@ -34,6 +34,60 @@ def HomogenousSymmetricFunction(j, x): return sum(prod(xx**pp for xx, pp in zip(x, p)) for p in IntegerVectors(j, length=len(x))) + +def Omega_P(a, x, y): + if len(x) == 1: + return x[0]**(-a) + \ + (prod(1 - x[0]*yy for yy in y) * + sum(HomogenousSymmetricFunction(j, y) * (1-x[0]^(j-a)) + for j in srange(a)) + if a > 0 else 0) + + return (x[-1] * (1-x[-2]) * + prod(1 - x[-2]*yy for yy in y) * + Omega_P(a, x[:-2] + x[-1:], y) + - + x[-2] * (1-x[-1]) * + prod(1 - x[-1]*yy for yy in y) * + Omega_P(a, x[:-1], y)) / (x[-1] - x[-2]) + + +def Omega_Fundamental(a, x, y): + r""" + EXAMPLES:: + + sage: L. = LaurentPolynomialRing(QQ) + sage: Omega_Fundamental(0, [x], [y]) + (1, (-x + 1, -x*y + 1)) + sage: Omega_Fundamental(0, [x], [y, z]) + (1, (-x + 1, -x*y + 1, -x*z + 1)) + sage: Omega_Fundamental(0, [x, y], [z]) + (-x*y*z + 1, (-x + 1, -y + 1, -x*z + 1, -y*z + 1)) + sage: Omega_Fundamental(0, [x, y, z], [w]) + (x*y*z*w^2 + x*y*z*w - x*y*w - x*z*w - y*z*w + 1, + (-x + 1, -y + 1, -z + 1, -x*w + 1, -y*w + 1, -z*w + 1)) + sage: Omega_Fundamental(0, [x, y], [z, w]) + (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1, + (-x + 1, -y + 1, -x*z + 1, -x*w + 1, -y*z + 1, -y*w + 1)) + """ + if not y: + factors_denominator = tuple(1 - xx for xx in x) + return (1 - (prod(factors_denominator) * + sum(HomogenousSymmetricFunction(j, x) + for j in srange(-a)) + if a < 0 else 0), + factors_denominator) + + if not x: + return (sum(HomogenousSymmetricFunction(j, x) + for j in srange(a+1)), + tuple()) + + return (Omega_P(a, x, y), + tuple(1 - xx for xx in x) + + tuple(1 - xx*yy for xx in x for yy in y)) + + class OmegaGroupElement(IndexedFreeAbelianGroup.Element): def __init__(self, parent, x, normalize=True): From 9f42e025fbe4a3d85718b29bf41a950b4734e436 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 8 Nov 2016 15:27:47 +0100 Subject: [PATCH 015/370] correct ^ (vs **) --- omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omega.py b/omega.py index 727fd799a75..7dc3e18dff7 100644 --- a/omega.py +++ b/omega.py @@ -39,7 +39,7 @@ def Omega_P(a, x, y): if len(x) == 1: return x[0]**(-a) + \ (prod(1 - x[0]*yy for yy in y) * - sum(HomogenousSymmetricFunction(j, y) * (1-x[0]^(j-a)) + sum(HomogenousSymmetricFunction(j, y) * (1-x[0]**(j-a)) for j in srange(a)) if a > 0 else 0) From b4443b2d077dc49e36cb72198bd7c1794fb66850 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 8 Nov 2016 15:28:10 +0100 Subject: [PATCH 016/370] rename (lower case function name) --- omega.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/omega.py b/omega.py index 7dc3e18dff7..ebcecf7e95e 100644 --- a/omega.py +++ b/omega.py @@ -52,21 +52,21 @@ def Omega_P(a, x, y): Omega_P(a, x[:-1], y)) / (x[-1] - x[-2]) -def Omega_Fundamental(a, x, y): +def Omega_fundamental(a, x, y): r""" EXAMPLES:: sage: L. = LaurentPolynomialRing(QQ) - sage: Omega_Fundamental(0, [x], [y]) + sage: Omega_fundamental(0, [x], [y]) (1, (-x + 1, -x*y + 1)) - sage: Omega_Fundamental(0, [x], [y, z]) + sage: Omega_fundamental(0, [x], [y, z]) (1, (-x + 1, -x*y + 1, -x*z + 1)) - sage: Omega_Fundamental(0, [x, y], [z]) + sage: Omega_fundamental(0, [x, y], [z]) (-x*y*z + 1, (-x + 1, -y + 1, -x*z + 1, -y*z + 1)) - sage: Omega_Fundamental(0, [x, y, z], [w]) + sage: Omega_fundamental(0, [x, y, z], [w]) (x*y*z*w^2 + x*y*z*w - x*y*w - x*z*w - y*z*w + 1, (-x + 1, -y + 1, -z + 1, -x*w + 1, -y*w + 1, -z*w + 1)) - sage: Omega_Fundamental(0, [x, y], [z, w]) + sage: Omega_fundamental(0, [x, y], [z, w]) (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1, (-x + 1, -y + 1, -x*z + 1, -x*w + 1, -y*z + 1, -y*w + 1)) """ From 60c588b79d13d79a18ebe5fa8b5138c3acf9d37e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 8 Nov 2016 15:28:45 +0100 Subject: [PATCH 017/370] Omega_higher --- omega.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/omega.py b/omega.py index ebcecf7e95e..09f350bdd28 100644 --- a/omega.py +++ b/omega.py @@ -88,6 +88,65 @@ def Omega_fundamental(a, x, y): tuple(1 - xx*yy for xx in x for yy in y)) +def Omega_higher(a, z): + r""" + EXAMPLES:: + + sage: L. = LaurentPolynomialRing(QQ) + sage: Omega_higher(0, [(x, 1), (y, -2)]) # richtiges Zwischenergebnis + (1, (-x + 1, -Omega0*x + 1, Omega0*x + 1)) + sage: Omega_higher(0, [(x, 1), (y, -3)]) # richtiges Zwischenergebnis + (1, (-x + 1, -Omega0*x + 1, (-rho0)*Omega0*x + 1, (rho0 + 1)*Omega0*x + 1)) + """ + class Factor(object): + def __init__(self, zz): + if isinstance(zz, (tuple, list)): + self.value, self.exponent = zz + else: + self.value = zz + self.exponent = 1 + def is_higher(self): + return abs(self.exponent) > 1 + def z(self, positive=True): + if (self.exponent > 0) != positive: + return [] + elif self.is_higher(): + rho = powers[abs(self.exponent)] + w = self.var + return [L_high(rho**j * w) for j in srange(abs(self.exponent))] + else: + return [self.value] + def x(self): + return self.z(positive=True) + def y(self): + return self.z(positive=False) + + z = list(Factor(zz) for zz in z) + + L_orig = z[0].value.parent() + B_orig = L_orig.base_ring() + exponents_pre = sorted(set(abs(factor.exponent) + for factor in z if factor.is_higher())) + B_high = B_orig.extension( + list(cyclotomic_polynomial(r) for r in exponents_pre), + tuple('rho{}'.format(i) for i in srange(len(exponents_pre)))) + powers = dict(zip(exponents_pre, B_high.gens())) + + nv = len(tuple(None for factor in z if factor.is_higher())) + variable_names_high = \ + tuple('Omega{}'.format(i) for i in srange(nv)) + \ + L_orig.variable_names() + L_high = LaurentPolynomialRing(B_high, variable_names_high) + v = iter(L_high.gens()) + for factor in z: + if factor.is_higher(): + factor.var = next(v) + + result_high = Omega_fundamental(a, + sum((factor.x() for factor in z), []), + sum((factor.y() for factor in z), [])) + + return result_high class OmegaGroupElement(IndexedFreeAbelianGroup.Element): def __init__(self, parent, x, normalize=True): From f88f0d34459c2734bd943bf15ef8ddd529fe4c22 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 8 Nov 2016 15:29:30 +0100 Subject: [PATCH 018/370] function prototypes for Omega --- omega.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/omega.py b/omega.py index 09f350bdd28..791fd8a8827 100644 --- a/omega.py +++ b/omega.py @@ -11,6 +11,8 @@ from __future__ import print_function from __future__ import absolute_import + +import operator from sage.groups.indexed_free_group import IndexedFreeAbelianGroup from six import iteritems @@ -147,6 +149,12 @@ def y(self): sum((factor.y() for factor in z), [])) return result_high + + +def Omega(var, numerator, factors_denominator, operator=operator.ge): + pass + + class OmegaGroupElement(IndexedFreeAbelianGroup.Element): def __init__(self, parent, x, normalize=True): @@ -159,6 +167,12 @@ def __init__(self, parent, x, normalize=True): super(OmegaGroup.Element, self).__init__(parent, x) + def Omega(var, operator=operator.ge): + r""" + """ + pass + + class OmegaGroup(IndexedFreeAbelianGroup): Element = OmegaGroupElement From 2f1fb1e489d82734e3bd710dc5f13ebaa05557c6 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 8 Nov 2016 20:15:50 +0100 Subject: [PATCH 019/370] collect common factors --- omega.py | 79 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 11 deletions(-) diff --git a/omega.py b/omega.py index 791fd8a8827..657f47c5183 100644 --- a/omega.py +++ b/omega.py @@ -14,7 +14,7 @@ import operator from sage.groups.indexed_free_group import IndexedFreeAbelianGroup -from six import iteritems +from six import iteritems, itervalues def HomogenousSymmetricFunction(j, x): @@ -95,10 +95,17 @@ def Omega_higher(a, z): EXAMPLES:: sage: L. = LaurentPolynomialRing(QQ) - sage: Omega_higher(0, [(x, 1), (y, -2)]) # richtiges Zwischenergebnis - (1, (-x + 1, -Omega0*x + 1, Omega0*x + 1)) - sage: Omega_higher(0, [(x, 1), (y, -3)]) # richtiges Zwischenergebnis - (1, (-x + 1, -Omega0*x + 1, (-rho0)*Omega0*x + 1, (rho0 + 1)*Omega0*x + 1)) + sage: Omega_higher(0, [(x, 1), (y, -2)]) + (1, [-x + 1, -x^2*y + 1]) + sage: Omega_higher(0, [(x, 2), (y, -1)]) # denominator not fully factored + (x*y + 1, [x^2*y^2 - x*y^2 - x + 1]) + sage: Omega_higher(0, [(x, 1), (y, 1), (z, -2)]) # denominator not fully factored + (-x^2*y*z - x*y^2*z + x*y*z + 1, + [-x + 1, -y + 1, x^2*y^2*z^2 - x^2*z - y^2*z + 1]) + sage: Omega_higher(0, [(x, 1), (y, -3)]) + (1, [-x + 1, -x^3*y + 1]) + sage: Omega_higher(0, [(x, 1), (y, -4)]) + (1, [-x + 1, -x^4*y + 1]) """ class Factor(object): def __init__(self, zz): @@ -140,15 +147,65 @@ def y(self): L_orig.variable_names() L_high = LaurentPolynomialRing(B_high, variable_names_high) v = iter(L_high.gens()) + Omega_map = dict() for factor in z: if factor.is_higher(): factor.var = next(v) - - result_high = Omega_fundamental(a, - sum((factor.x() for factor in z), []), - sum((factor.y() for factor in z), [])) - - return result_high + Omega_map[factor.var] = factor + + numerator_high, factors_denominator_high = Omega_fundamental( + a, + sum((factor.x() for factor in z), []), + sum((factor.y() for factor in z), [])) + + vars_Omega = set(L_high.gens()[:nv]) + factor_Omega = {v: 1 for v in vars_Omega} + factors_else = [] + for factor in factors_denominator_high: + v = set(factor.variables()) & vars_Omega + assert len(v) <= 1 + if len(v) == 1: + factor_Omega[v.pop()] *= factor + else: + factors_else.append(factor) + + def subs_Omega(factor, v): + f = Omega_map[v] + m = abs(f.exponent) + p = tuple(v.dict().popitem()[0]).index(1) + def subs_e(e): + e = list(e) + assert e[p] % m == 0 + e[p] = e[p] // m + return tuple(e) + P = factor.parent() + result = P({subs_e(e): c for e, c in iteritems(factor.dict())}) + try: + return result.subs({v: f.value}) + except TypeError: + print(('o o', result, v, f.value)) + print(result.parent()) + print(v.parent()) + print(f.value.parent()) + return factor + + factor_Omega = list(subs_Omega(factor, v) + for v, factor in iteritems(factor_Omega)) + factors_denominator_low = factors_else + factor_Omega + + def subs_all_Omega(factor): + for v in vars_Omega: + factor = subs_Omega(factor, v) + return factor + + from sage.rings.fraction_field import FractionField_generic + if isinstance(numerator_high.parent(), FractionField_generic): + numerator_low = subs_all_Omega(L_high(numerator_high.numerator())) / \ + subs_all_Omega(L_high(numerator_high.denominator())) + else: + numerator_low = subs_all_Omega(numerator_high) + + return numerator_low, factors_denominator_low def Omega(var, numerator, factors_denominator, operator=operator.ge): From 61a867d36ff09cc4b596ea9767793aa2eb5472c1 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 8 Nov 2016 20:21:37 +0100 Subject: [PATCH 020/370] some comments in code --- omega.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/omega.py b/omega.py index 657f47c5183..118214432b4 100644 --- a/omega.py +++ b/omega.py @@ -132,6 +132,7 @@ def y(self): z = list(Factor(zz) for zz in z) + # -2. create new (larger) laurent polynomial ring L_orig = z[0].value.parent() B_orig = L_orig.base_ring() exponents_pre = sorted(set(abs(factor.exponent) @@ -146,6 +147,8 @@ def y(self): tuple('Omega{}'.format(i) for i in srange(nv)) + \ L_orig.variable_names() L_high = LaurentPolynomialRing(B_high, variable_names_high) + + # -1. rewrite factors with higher powers v = iter(L_high.gens()) Omega_map = dict() for factor in z: @@ -153,11 +156,13 @@ def y(self): factor.var = next(v) Omega_map[factor.var] = factor + # 0. apply Omega numerator_high, factors_denominator_high = Omega_fundamental( a, sum((factor.x() for factor in z), []), sum((factor.y() for factor in z), [])) + # 1. multiply factors of denominator with common helper-variable vars_Omega = set(L_high.gens()[:nv]) factor_Omega = {v: 1 for v in vars_Omega} factors_else = [] @@ -169,6 +174,7 @@ def y(self): else: factors_else.append(factor) + # 2. substitute helper variable with actual value def subs_Omega(factor, v): f = Omega_map[v] m = abs(f.exponent) From 96bcf5205b49fa76977fc1957be3370681cd2952 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 8 Nov 2016 20:22:12 +0100 Subject: [PATCH 021/370] remove forgotten debugging code --- omega.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/omega.py b/omega.py index 118214432b4..4f4aca61e0a 100644 --- a/omega.py +++ b/omega.py @@ -186,14 +186,7 @@ def subs_e(e): return tuple(e) P = factor.parent() result = P({subs_e(e): c for e, c in iteritems(factor.dict())}) - try: - return result.subs({v: f.value}) - except TypeError: - print(('o o', result, v, f.value)) - print(result.parent()) - print(v.parent()) - print(f.value.parent()) - return factor + return result.subs({v: f.value}) factor_Omega = list(subs_Omega(factor, v) for v, factor in iteritems(factor_Omega)) From 2e15ceb4e850d0f53b506fbe892f128dca401e22 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 8 Nov 2016 20:36:19 +0100 Subject: [PATCH 022/370] docstring --- omega.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/omega.py b/omega.py index 4f4aca61e0a..aca39413a4c 100644 --- a/omega.py +++ b/omega.py @@ -56,6 +56,26 @@ def Omega_P(a, x, y): def Omega_fundamental(a, x, y): r""" + Return `\Omega_{\ge}` of the expression specified by the input. + + .. MATH:: + + \Omega_{\ge} \frac{\lambda^a}{ + (1 - x_1 \lambda) \dots (1 - x_n \lambda) + (1 - y_1 / \lambda) \dots (1 - y_m / \lambda) + + INPUT: + + - ``a`` -- an integer. + + - ``x`` and ``y`` -- lists of laurent polynomials + + OUTPUT: + + A pair representing a quotient as follows: Its first component is the + numerator as a laurent polynomial, its second component a factorization + of the denominator as a list of laurent polynomials. + EXAMPLES:: sage: L. = LaurentPolynomialRing(QQ) @@ -92,6 +112,27 @@ def Omega_fundamental(a, x, y): def Omega_higher(a, z): r""" + Return `\Omega_{\ge}` of the expression specified by the input. + + .. MATH:: + + \Omega_{\ge} \frac{\lambda^a}{ + (1 - z_1 \lambda^{e_1}) \dots (1 - z_n \lambda^{e_n}) + + INPUT: + + - ``a`` -- an integer. + + - ``z`` and ``y`` -- a lists with each entry either + a laurent polynomial (implicit exponent `1`) or + a pair of a laurent polynomial and an integer exponent. + + OUTPUT: + + A pair representing a quotient as follows: Its first component is the + numerator as a laurent polynomial, its second component a factorization + of the denominator as a list of laurent polynomials. + EXAMPLES:: sage: L. = LaurentPolynomialRing(QQ) From eb8c97c0d18304ef6dc89c5ed4ca1e6741cd84e2 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 9 Nov 2016 09:45:33 +0100 Subject: [PATCH 023/370] allow grouping in Omega_fundamental --- omega.py | 54 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/omega.py b/omega.py index aca39413a4c..2bfa0d54658 100644 --- a/omega.py +++ b/omega.py @@ -54,7 +54,7 @@ def Omega_P(a, x, y): Omega_P(a, x[:-1], y)) / (x[-1] - x[-2]) -def Omega_fundamental(a, x, y): +def Omega_fundamental(a, x, y, group_factors=False): r""" Return `\Omega_{\ge}` of the expression specified by the input. @@ -92,22 +92,42 @@ def Omega_fundamental(a, x, y): (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1, (-x + 1, -y + 1, -x*z + 1, -x*w + 1, -y*z + 1, -y*w + 1)) """ - if not y: - factors_denominator = tuple(1 - xx for xx in x) - return (1 - (prod(factors_denominator) * - sum(HomogenousSymmetricFunction(j, x) - for j in srange(-a)) - if a < 0 else 0), - factors_denominator) - - if not x: - return (sum(HomogenousSymmetricFunction(j, x) - for j in srange(a+1)), - tuple()) - - return (Omega_P(a, x, y), - tuple(1 - xx for xx in x) + - tuple(1 - xx*yy for xx in x for yy in y)) + def flatten(z): + return sum((tuple(zz) for zz in z), tuple()) + + if group_factors: + flat_x = flatten(x) + flat_y = flatten(y) + else: + flat_x = x + flat_y = y + x = tuple((xx,) for xx in x) + y = tuple((yy,) for yy in y) + + if not flat_y: + numerator = 1 - (prod(factors_denominator) * + sum(HomogenousSymmetricFunction(j, flat_x) + for j in srange(-a)) + if a < 0 else 0) + factors_denominator = \ + tuple(tuple(1 - xx for xx in gx) for gx in x) + + elif not flat_x: + numerator = sum(HomogenousSymmetricFunction(j, flat_x) + for j in srange(a+1)) + factors_denominator = (tuple(),) + + else: + numerator = Omega_P(a, flat_x, flat_y) + factors_denominator = \ + tuple(tuple(1 - xx for xx in gx) for gx in x) + \ + tuple(tuple(1 - xx*yy for xx in gx for yy in gy) + for gx in x for gy in y) + + if not group_factors: + factors_denominator = flatten(factors_denominator) + + return numerator, factors_denominator def Omega_higher(a, z): From bfac5e6161edc0883d9cfd96018962b696e960b0 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 9 Nov 2016 09:46:08 +0100 Subject: [PATCH 024/370] rewrite Omega_higher (to make usage of grouping) --- omega.py | 54 +++++++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/omega.py b/omega.py index 2bfa0d54658..dbb3788b575 100644 --- a/omega.py +++ b/omega.py @@ -185,7 +185,7 @@ def z(self, positive=True): w = self.var return [L_high(rho**j * w) for j in srange(abs(self.exponent))] else: - return [self.value] + return [L_high(self.value)] def x(self): return self.z(positive=True) def y(self): @@ -218,54 +218,50 @@ def y(self): Omega_map[factor.var] = factor # 0. apply Omega - numerator_high, factors_denominator_high = Omega_fundamental( + def nonempty(T): + return tuple(t for t in T if t) + numerator, factors_denominator = Omega_fundamental( a, - sum((factor.x() for factor in z), []), - sum((factor.y() for factor in z), [])) - - # 1. multiply factors of denominator with common helper-variable - vars_Omega = set(L_high.gens()[:nv]) - factor_Omega = {v: 1 for v in vars_Omega} - factors_else = [] - for factor in factors_denominator_high: - v = set(factor.variables()) & vars_Omega - assert len(v) <= 1 - if len(v) == 1: - factor_Omega[v.pop()] *= factor - else: - factors_else.append(factor) + nonempty(factor.x() for factor in z), + nonempty(factor.y() for factor in z), + group_factors=True) + + # 1. multiply grouped factors of denominator + factors_denominator = tuple(prod(factor for factor in factors) + for factors in factors_denominator) # 2. substitute helper variable with actual value def subs_Omega(factor, v): f = Omega_map[v] - m = abs(f.exponent) + value = f.value + exponent = abs(f.exponent) p = tuple(v.dict().popitem()[0]).index(1) def subs_e(e): e = list(e) - assert e[p] % m == 0 - e[p] = e[p] // m + assert e[p] % exponent == 0 + e[p] = e[p] // exponent return tuple(e) P = factor.parent() result = P({subs_e(e): c for e, c in iteritems(factor.dict())}) - return result.subs({v: f.value}) - - factor_Omega = list(subs_Omega(factor, v) - for v, factor in iteritems(factor_Omega)) - factors_denominator_low = factors_else + factor_Omega + return result.subs({v: value}) + vars_Omega = L_high.gens()[:nv] def subs_all_Omega(factor): for v in vars_Omega: factor = subs_Omega(factor, v) return factor + factors_denominator = tuple(subs_all_Omega(factor) + for factor in factors_denominator) + from sage.rings.fraction_field import FractionField_generic - if isinstance(numerator_high.parent(), FractionField_generic): - numerator_low = subs_all_Omega(L_high(numerator_high.numerator())) / \ - subs_all_Omega(L_high(numerator_high.denominator())) + if isinstance(numerator.parent(), FractionField_generic): + numerator = subs_all_Omega(L_high(numerator.numerator())) / \ + subs_all_Omega(L_high(numerator.denominator())) else: - numerator_low = subs_all_Omega(numerator_high) + numerator = subs_all_Omega(numerator) - return numerator_low, factors_denominator_low + return numerator, factors_denominator def Omega(var, numerator, factors_denominator, operator=operator.ge): From 17032a772c585f314b8d34f5bdd4c05913c220b9 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 9 Nov 2016 09:50:49 +0100 Subject: [PATCH 025/370] fix doctests --- omega.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/omega.py b/omega.py index dbb3788b575..a53a2347ebe 100644 --- a/omega.py +++ b/omega.py @@ -157,16 +157,16 @@ def Omega_higher(a, z): sage: L. = LaurentPolynomialRing(QQ) sage: Omega_higher(0, [(x, 1), (y, -2)]) - (1, [-x + 1, -x^2*y + 1]) - sage: Omega_higher(0, [(x, 2), (y, -1)]) # denominator not fully factored - (x*y + 1, [x^2*y^2 - x*y^2 - x + 1]) - sage: Omega_higher(0, [(x, 1), (y, 1), (z, -2)]) # denominator not fully factored + (1, (-x + 1, -x^2*y + 1)) + sage: Omega_higher(0, [(x, 2), (y, -1)]) + (x*y + 1, (-x + 1, -x*y^2 + 1)) + sage: Omega_higher(0, [(x, 1), (y, 1), (z, -2)]) (-x^2*y*z - x*y^2*z + x*y*z + 1, - [-x + 1, -y + 1, x^2*y^2*z^2 - x^2*z - y^2*z + 1]) + (-x + 1, -y + 1, -x^2*z + 1, -y^2*z + 1)) sage: Omega_higher(0, [(x, 1), (y, -3)]) - (1, [-x + 1, -x^3*y + 1]) + (1, (-x + 1, -x^3*y + 1)) sage: Omega_higher(0, [(x, 1), (y, -4)]) - (1, [-x + 1, -x^4*y + 1]) + (1, (-x + 1, -x^4*y + 1)) """ class Factor(object): def __init__(self, zz): From b4fe5f796a3c7478a2f2f82ad923e8eda7996763 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 9 Nov 2016 09:51:53 +0100 Subject: [PATCH 026/370] replace remaining lists by tuple (for consistency) --- omega.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/omega.py b/omega.py index a53a2347ebe..14c4255a85b 100644 --- a/omega.py +++ b/omega.py @@ -179,13 +179,14 @@ def is_higher(self): return abs(self.exponent) > 1 def z(self, positive=True): if (self.exponent > 0) != positive: - return [] + return tuple() elif self.is_higher(): rho = powers[abs(self.exponent)] w = self.var - return [L_high(rho**j * w) for j in srange(abs(self.exponent))] + return tuple(L_high(rho**j * w) + for j in srange(abs(self.exponent))) else: - return [L_high(self.value)] + return (L_high(self.value),) def x(self): return self.z(positive=True) def y(self): From c568c0ed2feb3dca82f21c43c9f5911622c16b04 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 9 Nov 2016 10:02:21 +0100 Subject: [PATCH 027/370] rewrite subs in Omega_higher --- omega.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/omega.py b/omega.py index 14c4255a85b..3653e181888 100644 --- a/omega.py +++ b/omega.py @@ -232,35 +232,38 @@ def nonempty(T): for factors in factors_denominator) # 2. substitute helper variable with actual value - def subs_Omega(factor, v): - f = Omega_map[v] - value = f.value - exponent = abs(f.exponent) - p = tuple(v.dict().popitem()[0]).index(1) + def subs_power(expression, var, exponent, value): + r""" + Substitute ``var^exponent`` by ``value`` in ``expression``. + """ + p = tuple(var.dict().popitem()[0]).index(1) def subs_e(e): e = list(e) assert e[p] % exponent == 0 e[p] = e[p] // exponent return tuple(e) - P = factor.parent() - result = P({subs_e(e): c for e, c in iteritems(factor.dict())}) - return result.subs({v: value}) + parent = expression.parent() + result = parent({subs_e(e): c for e, c in iteritems(expression.dict())}) + return result.subs({var: value}) - vars_Omega = L_high.gens()[:nv] - def subs_all_Omega(factor): - for v in vars_Omega: - factor = subs_Omega(factor, v) - return factor + def subs_Omega(expression): + r""" + Substitute all helper variables by their actual values. + """ + for var, factor in iteritems(Omega_map): + expression = subs_power(expression, var, + abs(factor.exponent), factor.value) + return expression - factors_denominator = tuple(subs_all_Omega(factor) + factors_denominator = tuple(subs_Omega(factor) for factor in factors_denominator) from sage.rings.fraction_field import FractionField_generic if isinstance(numerator.parent(), FractionField_generic): - numerator = subs_all_Omega(L_high(numerator.numerator())) / \ - subs_all_Omega(L_high(numerator.denominator())) + numerator = subs_Omega(L_high(numerator.numerator())) / \ + subs_Omega(L_high(numerator.denominator())) else: - numerator = subs_all_Omega(numerator) + numerator = subs_Omega(numerator) return numerator, factors_denominator From edb9c9c9eb24c0395a21e07af1d39b6232c603f1 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 9 Nov 2016 10:10:53 +0100 Subject: [PATCH 028/370] more doctests --- omega.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/omega.py b/omega.py index 3653e181888..9cbdd4d4109 100644 --- a/omega.py +++ b/omega.py @@ -156,17 +156,28 @@ def Omega_higher(a, z): EXAMPLES:: sage: L. = LaurentPolynomialRing(QQ) + sage: Omega_higher(0, [(x, 1), (y, -2)]) (1, (-x + 1, -x^2*y + 1)) + sage: Omega_higher(0, [(x, 1), (y, -3)]) + (1, (-x + 1, -x^3*y + 1)) + sage: Omega_higher(0, [(x, 1), (y, -4)]) + (1, (-x + 1, -x^4*y + 1)) + sage: Omega_higher(0, [(x, 2), (y, -1)]) (x*y + 1, (-x + 1, -x*y^2 + 1)) + sage: Omega_higher(0, [(x, 3), (y, -1)]) + (x*y^2 + x*y + 1, (-x + 1, -x*y^3 + 1)) + sage: Omega_higher(0, [(x, 4), (y, -1)]) + (x*y^3 + x*y^2 + x*y + 1, (-x + 1, -x*y^4 + 1)) + sage: Omega_higher(0, [(x, 1), (y, 1), (z, -2)]) (-x^2*y*z - x*y^2*z + x*y*z + 1, (-x + 1, -y + 1, -x^2*z + 1, -y^2*z + 1)) - sage: Omega_higher(0, [(x, 1), (y, -3)]) - (1, (-x + 1, -x^3*y + 1)) - sage: Omega_higher(0, [(x, 1), (y, -4)]) - (1, (-x + 1, -x^4*y + 1)) + sage: Omega_higher(0, [(x, 2), (y, -1), (z, -1)]) + (x*y*z + x*y + x*z + 1, (-x + 1, -x*y^2 + 1, -x*z^2 + 1)) + sage: Omega_higher(0, [(x, 2), (y, 1), (z, -1)]) + (-x*y*z^2 - x*y*z + x*z + 1, (-x + 1, -y + 1, -x*z^2 + 1, -y*z + 1)) """ class Factor(object): def __init__(self, zz): From 341f28f999c5ccad021b88cd816a4ad64ee3f24f Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 9 Nov 2016 10:29:30 +0100 Subject: [PATCH 029/370] more doctests --- omega.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/omega.py b/omega.py index 9cbdd4d4109..5b54d257bb5 100644 --- a/omega.py +++ b/omega.py @@ -91,6 +91,15 @@ def Omega_fundamental(a, x, y, group_factors=False): sage: Omega_fundamental(0, [x, y], [z, w]) (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1, (-x + 1, -y + 1, -x*z + 1, -x*w + 1, -y*z + 1, -y*w + 1)) + + sage: Omega_fundamental(-2, [x], [y]) + (x^2, (-x + 1, -x*y + 1)) + sage: Omega_fundamental(-1, [x], [y]) + (x, (-x + 1, -x*y + 1)) + sage: Omega_fundamental(1, [x], [y]) + (-x*y + y + 1, (-x + 1, -x*y + 1)) + sage: Omega_fundamental(2, [x], [y]) + (-x*y^2 - x*y + y^2 + y + 1, (-x + 1, -x*y + 1)) """ def flatten(z): return sum((tuple(zz) for zz in z), tuple()) From 82212259bada0d8b3e162f09e0dc757c07062e05 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 11 Nov 2016 10:08:48 +0100 Subject: [PATCH 030/370] remove omega-group from master-branch --- omega.py | 80 -------------------------------------------------------- 1 file changed, 80 deletions(-) diff --git a/omega.py b/omega.py index 5b54d257bb5..22c38351ef5 100644 --- a/omega.py +++ b/omega.py @@ -291,83 +291,3 @@ def subs_Omega(expression): def Omega(var, numerator, factors_denominator, operator=operator.ge): pass - -class OmegaGroupElement(IndexedFreeAbelianGroup.Element): - - def __init__(self, parent, x, normalize=True): - if normalize: - from sage.misc.misc_c import prod - L = parent.factor_ring() - constant = prod( - (f.constant_coefficient()**e for f, e in iteritems(x)), L.one()) - x = {f/f.constant_coefficient(): e for f, e in iteritems(x)} - super(OmegaGroup.Element, self).__init__(parent, x) - - - def Omega(var, operator=operator.ge): - r""" - """ - pass - - -class OmegaGroup(IndexedFreeAbelianGroup): - - Element = OmegaGroupElement - - @staticmethod - def __classcall__(cls, base_ring, names): - from sage.structure.unique_representation import UniqueRepresentation - names = LaurentPolynomialRing(QQ, names).variable_names() - return UniqueRepresentation.__classcall__(cls, base_ring, names) - - - def __init__(self, base_ring, names): - r""" - EXAMPLES:: - - sage: G = OmegaGroup(QQ, 'x, y'); G - OmegaGroup in x, y over Rational Field - """ - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - L = LaurentPolynomialRing(base_ring, names) - self._factor_ring_ = L - super(OmegaGroup, self).__init__(indices=L, prefix='', - names=names, - bracket='(', latex_bracket='(') - - - def factor_ring(self): - return self._factor_ring_ - - - def _repr_(self): - return 'OmegaGroup in {} over {}'.format( - ', '.join(self.variable_names()), - self.factor_ring().base_ring()) - - - def _element_constructor_(self, x=None): - r""" - TESTS:: - - sage: G = OmegaGroup(QQ, 'mu, x, y') - sage: var('mu, x, y') - (mu, x, y) - sage: G(1 / (1-mu*x) / (1-y/mu)) - (1 - mu^-1*y)^-1*(-mu*x + 1)^-1 - """ - if isinstance(x, Expression): - import operator - from sage.symbolic.operators import mul_vararg - factors = [] - if x.operator() == mul_vararg: - x = list( - (f.operands() if f.operator() == operator.pow else (f, 1)) - for f in x.operands()) - elif x.operator() == operator.pow: - x = [x.operands()] - else: - x = [(x, 1)] - L = self.factor_ring() - x = list((L(f), e) for f, e in x) - return super(OmegaGroup, self)._element_constructor_(x) From 280bc9580af9bb71aa5f3782c30fe8f949533e6a Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 14 Nov 2016 10:37:22 +0100 Subject: [PATCH 031/370] rewrite Omega_P --- omega.py | 71 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/omega.py b/omega.py index 22c38351ef5..49e02ef27d6 100644 --- a/omega.py +++ b/omega.py @@ -37,21 +37,62 @@ def HomogenousSymmetricFunction(j, x): for p in IntegerVectors(j, length=len(x))) -def Omega_P(a, x, y): - if len(x) == 1: - return x[0]**(-a) + \ - (prod(1 - x[0]*yy for yy in y) * - sum(HomogenousSymmetricFunction(j, y) * (1-x[0]**(j-a)) - for j in srange(a)) - if a > 0 else 0) - - return (x[-1] * (1-x[-2]) * - prod(1 - x[-2]*yy for yy in y) * - Omega_P(a, x[:-2] + x[-1:], y) - - - x[-2] * (1-x[-1]) * - prod(1 - x[-1]*yy for yy in y) * - Omega_P(a, x[:-1], y)) / (x[-1] - x[-2]) +def Omega_P(a, n, m): + r""" + EXAMPLES:: + + sage: L. = LaurentPolynomialRing(QQ) + sage: Omega_P(0, 1, 1) + 1 + sage: Omega_P(0, 2, 1) + -x0*x1*y0 + 1 + sage: Omega_P(0, 1, 2) + 1 + sage: Omega_P(0, 3, 1) + x0*x1*x2*y0^2 + x0*x1*x2*y0 - x0*x1*y0 - x0*x2*y0 - x1*x2*y0 + 1 + sage: Omega_P(0, 2, 2) + x0^2*x1*y0*y1 + x0*x1^2*y0*y1 - x0*x1*y0*y1 - x0*x1*y0 - x0*x1*y1 + 1 + + sage: Omega_P(-2, 1, 1) + x0^2 + sage: Omega_P(-1, 1, 1) + x0 + sage: Omega_P(1, 1, 1) + -x0*y0 + y0 + 1 + sage: Omega_P(2, 1, 1) + -x0*y0^2 - x0*y0 + y0^2 + y0 + 1 + """ + Y = LaurentPolynomialRing( + QQ, ', '.join('y{}'.format(mm) for mm in range(m))) + y = Y.gens() + + def P(n): + if n == 1: + L = LaurentPolynomialRing(Y, 'x0') + x0 = L.gen() + return x0**(-a) + \ + (prod(1 - x0*yy for yy in y) * + sum(HomogenousSymmetricFunction(j, y) * (1-x0**(j-a)) + for j in srange(a)) + if a > 0 else 0) + else: + Pprev = P(n-1) + L = LaurentPolynomialRing(Pprev.parent(), 'x{}'.format(n-1)) + x1 = L.gen() + x2 = Pprev.parent().gen() + p1 = L(Pprev.subs({x2: x1})) + p2 = L(Pprev) + x2 = L({0: x2}) + q, r = (x1 * (1-x2) * prod(1 - x2*yy for yy in y) * p1 - \ + x2 * (1-x1) * prod(1 - x1*yy for yy in y) * p2).quo_rem(x1 - x2) + assert r == 0 + return q + + from itertools import chain + XY = LaurentPolynomialRing(QQ, ', '.join(chain( + iter('x{}'.format(nn) for nn in range(n)), + iter('y{}'.format(mm) for mm in range(m))))) + return XY(P(n)) def Omega_fundamental(a, x, y, group_factors=False): From bf8003109d0c6ef2e7aa06d9429bace0e62a5afb Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 14 Nov 2016 10:38:37 +0100 Subject: [PATCH 032/370] rename Omega_P --> Omega_numerator --- omega.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/omega.py b/omega.py index 49e02ef27d6..329356184f5 100644 --- a/omega.py +++ b/omega.py @@ -37,29 +37,29 @@ def HomogenousSymmetricFunction(j, x): for p in IntegerVectors(j, length=len(x))) -def Omega_P(a, n, m): +def Omega_numerator(a, n, m): r""" EXAMPLES:: sage: L. = LaurentPolynomialRing(QQ) - sage: Omega_P(0, 1, 1) + sage: Omega_numerator(0, 1, 1) 1 - sage: Omega_P(0, 2, 1) + sage: Omega_numerator(0, 2, 1) -x0*x1*y0 + 1 - sage: Omega_P(0, 1, 2) + sage: Omega_numerator(0, 1, 2) 1 - sage: Omega_P(0, 3, 1) + sage: Omega_numerator(0, 3, 1) x0*x1*x2*y0^2 + x0*x1*x2*y0 - x0*x1*y0 - x0*x2*y0 - x1*x2*y0 + 1 - sage: Omega_P(0, 2, 2) + sage: Omega_numerator(0, 2, 2) x0^2*x1*y0*y1 + x0*x1^2*y0*y1 - x0*x1*y0*y1 - x0*x1*y0 - x0*x1*y1 + 1 - sage: Omega_P(-2, 1, 1) + sage: Omega_numerator(-2, 1, 1) x0^2 - sage: Omega_P(-1, 1, 1) + sage: Omega_numerator(-1, 1, 1) x0 - sage: Omega_P(1, 1, 1) + sage: Omega_numerator(1, 1, 1) -x0*y0 + y0 + 1 - sage: Omega_P(2, 1, 1) + sage: Omega_numerator(2, 1, 1) -x0*y0^2 - x0*y0 + y0^2 + y0 + 1 """ Y = LaurentPolynomialRing( @@ -168,7 +168,7 @@ def flatten(z): factors_denominator = (tuple(),) else: - numerator = Omega_P(a, flat_x, flat_y) + numerator = Omega_numerator(a, len(flat_x), len(flat_y)) factors_denominator = \ tuple(tuple(1 - xx for xx in gx) for gx in x) + \ tuple(tuple(1 - xx*yy for xx in gx for yy in gy) From 984e0d41eda107d0673eef6d5e366743e15c4872 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 14 Nov 2016 10:48:42 +0100 Subject: [PATCH 033/370] adapt code to previous rewrites --- omega.py | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/omega.py b/omega.py index 329356184f5..b266aa8dea5 100644 --- a/omega.py +++ b/omega.py @@ -92,7 +92,17 @@ def P(n): XY = LaurentPolynomialRing(QQ, ', '.join(chain( iter('x{}'.format(nn) for nn in range(n)), iter('y{}'.format(mm) for mm in range(m))))) - return XY(P(n)) + + if m == 0: + return XY(1 - (prod(factors_denominator) * + sum(HomogenousSymmetricFunction(j, XY.gens()) + for j in srange(-a)) + if a < 0 else 0)) + elif n == 0: + return XY(sum(HomogenousSymmetricFunction(j, XY.gens()) + for j in srange(a+1))) + else: + return XY(P(n)) def Omega_fundamental(a, x, y, group_factors=False): @@ -154,26 +164,14 @@ def flatten(z): x = tuple((xx,) for xx in x) y = tuple((yy,) for yy in y) - if not flat_y: - numerator = 1 - (prod(factors_denominator) * - sum(HomogenousSymmetricFunction(j, flat_x) - for j in srange(-a)) - if a < 0 else 0) - factors_denominator = \ - tuple(tuple(1 - xx for xx in gx) for gx in x) - - elif not flat_x: - numerator = sum(HomogenousSymmetricFunction(j, flat_x) - for j in srange(a+1)) - factors_denominator = (tuple(),) - - else: - numerator = Omega_numerator(a, len(flat_x), len(flat_y)) - factors_denominator = \ - tuple(tuple(1 - xx for xx in gx) for gx in x) + \ - tuple(tuple(1 - xx*yy for xx in gx for yy in gy) - for gx in x for gy in y) + numerator = Omega_numerator(a, len(flat_x), len(flat_y)) + numerator = numerator.subs( + {xi: xj for xi, xj in zip(numerator.parent().gens(), flat_x+flat_y)}) + Factors_denominator = \ + tuple(tuple(1 - xx for xx in gx) for gx in x) + \ + tuple(tuple(1 - xx*yy for xx in gx for yy in gy) + for gx in x for gy in y) if not group_factors: factors_denominator = flatten(factors_denominator) From caf260510e81569f44c131c229e6a842034719a0 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 17 Nov 2016 18:54:38 +0100 Subject: [PATCH 034/370] rewrite to Omega_factors_denominator --- omega.py | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/omega.py b/omega.py index b266aa8dea5..b2dd3cbd775 100644 --- a/omega.py +++ b/omega.py @@ -37,6 +37,13 @@ def HomogenousSymmetricFunction(j, x): for p in IntegerVectors(j, length=len(x))) +def _laurent_polynomial_ring_(n, m): + from itertools import chain + return LaurentPolynomialRing(QQ, ', '.join(chain( + iter('x{}'.format(nn) for nn in range(n)), + iter('y{}'.format(mm) for mm in range(m))))) + + def Omega_numerator(a, n, m): r""" EXAMPLES:: @@ -88,10 +95,7 @@ def P(n): assert r == 0 return q - from itertools import chain - XY = LaurentPolynomialRing(QQ, ', '.join(chain( - iter('x{}'.format(nn) for nn in range(n)), - iter('y{}'.format(mm) for mm in range(m))))) + XY = _laurent_polynomial_ring_(n, m) if m == 0: return XY(1 - (prod(factors_denominator) * @@ -105,8 +109,44 @@ def P(n): return XY(P(n)) -def Omega_fundamental(a, x, y, group_factors=False): +def Omega_factors_denominator(n, m): r""" + EXAMPLES:: + + sage: Omega_factors_denominator(1, 1) + ((-x0 + 1,), (-x0*y0 + 1,)) + sage: Omega_factors_denominator(1, 2) + ((-x0 + 1,), (-x0*y0 + 1,), (-x0*y1 + 1,)) + sage: Omega_factors_denominator(2, 1) + ((-x0 + 1,), (-x1 + 1,), (-x0*y0 + 1,), (-x1*y0 + 1,)) + sage: Omega_factors_denominator(3, 1) + ((-x0 + 1,), (-x1 + 1,), (-x2 + 1,), + (-x0*y0 + 1,), (-x1*y0 + 1,), (-x2*y0 + 1,)) + sage: Omega_factors_denominator(2, 2) + ((-x0 + 1,), (-x1 + 1,), (-x0*y0 + 1,), + (-x0*y1 + 1,), (-x1*y0 + 1,), (-x1*y1 + 1,)) + """ + if isinstance(n, tuple): + x = n + n = sum(x) + else: + x = tuple(1 for _ in range(n)) + if isinstance(m, tuple): + y = m + m = sum(y) + else: + y = tuple(1 for _ in range(m)) + + XY = _laurent_polynomial_ring_(n, m) + ixy = iter(XY.gens()) + x = tuple(tuple(next(ixy) for _ in range(nx)) for nx in x) + y = tuple(tuple(next(ixy) for _ in range(my)) for my in y) + + return tuple(tuple(1 - xx for xx in gx) for gx in x) + \ + tuple(tuple(1 - xx*yy for xx in gx for yy in gy) + for gx in x for gy in y) + + Return `\Omega_{\ge}` of the expression specified by the input. .. MATH:: From c4c1350b797e5797b3279948a5b8acb4f0c0e25d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 17 Nov 2016 18:56:07 +0100 Subject: [PATCH 035/370] rewrite Omega_higher --- omega.py | 230 ++++++++++++++++++++----------------------------------- 1 file changed, 83 insertions(+), 147 deletions(-) diff --git a/omega.py b/omega.py index b2dd3cbd775..413b34cc444 100644 --- a/omega.py +++ b/omega.py @@ -147,6 +147,89 @@ def Omega_factors_denominator(n, m): for gx in x for gy in y) +def Omega_higher(a, z): + r""" + EXAMPLES:: + + sage: Omega_higher(0, [1, -2]) + (1, (-z0 + 1, -z0^2*z1 + 1)) + sage: Omega_higher(0, [1, -3]) + (1, (-z0 + 1, -z0^3*z1 + 1)) + sage: Omega_higher(0, [1, -4]) + (1, (-z0 + 1, -z0^4*z1 + 1)) + + sage: Omega_higher(0, [2, -1]) + (z0*z1 + 1, (-z0 + 1, -z0*z1^2 + 1)) + sage: Omega_higher(0, [3, -1]) + (z0*z1^2 + z0*z1 + 1, (-z0 + 1, -z0*z1^3 + 1)) + sage: Omega_higher(0, [4, -1]) + (z0*z1^3 + z0*z1^2 + z0*z1 + 1, (-z0 + 1, -z0*z1^4 + 1)) + + sage: Omega_higher(0, [1, 1, -2]) + (-z0^2*z1*z2 - z0*z1^2*z2 + z0*z1*z2 + 1, + (-z0 + 1, -z1 + 1, -z0^2*z2 + 1, -z1^2*z2 + 1)) + sage: Omega_higher(0, [2, -1, -1]) + (z0*z1*z2 + z0*z1 + z0*z2 + 1, (-z0 + 1, -z0*z1^2 + 1, -z0*z2^2 + 1)) + sage: Omega_higher(0, [2, 1, -1]) + (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, (-z0 + 1, -z1 + 1, -z0*z2^2 + 1, -z1*z2 + 1)) + """ + if not z or any(zz == 0 for zz in z): + raise NotImplementedError + + x = tuple(zz for zz in z if zz > 0) + y = tuple(-zz for zz in z if zz < 0) + xy = x + y + n = sum(x) + m = sum(y) + + exponents = sorted(set(zz for zz in xy) - set([1])) + B = QQ.extension( + list(cyclotomic_polynomial(r) for r in exponents), + tuple('rho{}'.format(i) for i in range(len(exponents)))) + L = LaurentPolynomialRing(B, ', '.join('z{}'.format(nn) + for nn in range(len(z)))) + powers = dict(zip(exponents, iter(L(g) for g in B.gens()))) + powers[2] = L(-1) + powers[1] = L(1) + + def subs_power(expression, var, exponent, value=None): + r""" + Substitute ``var^exponent`` by ``value`` in ``expression``. + """ + p = tuple(var.dict().popitem()[0]).index(1) + def subs_e(e): + e = list(e) + assert e[p] % exponent == 0 + e[p] = e[p] // exponent + return tuple(e) + parent = expression.parent() + result = parent({subs_e(e): c for e, c in iteritems(expression.dict())}) + if value is None: + return result + return result.subs({var: value}) + + Z = L.change_ring(QQ) + + def de_power(expression): + for zz, var in zip(z, L.gens()): + if abs(zz) == 1: + continue + expression = subs_power(expression, var, abs(zz)) + return Z(expression) + + xy_var = _laurent_polynomial_ring_(n, m).gens() + x_var = iter(xy_var[:n]) + y_var = iter(xy_var[n:]) + rules = {next(x_var) if zz > 0 else next(y_var): + powers[abs(zz)]**j * var + for zz, var in zip(z, L.gens()) for j in range(abs(zz))} + factors_denominator = tuple(de_power(prod(f.subs(rules) for f in factors)) + for factors in Omega_factors_denominator(x, y)) + + numerator = de_power(Omega_numerator(a, n, m).subs(rules)) + + return numerator, factors_denominator + Return `\Omega_{\ge}` of the expression specified by the input. .. MATH:: @@ -167,59 +250,11 @@ def Omega_factors_denominator(n, m): numerator as a laurent polynomial, its second component a factorization of the denominator as a list of laurent polynomials. - EXAMPLES:: - sage: L. = LaurentPolynomialRing(QQ) - sage: Omega_fundamental(0, [x], [y]) - (1, (-x + 1, -x*y + 1)) - sage: Omega_fundamental(0, [x], [y, z]) - (1, (-x + 1, -x*y + 1, -x*z + 1)) - sage: Omega_fundamental(0, [x, y], [z]) - (-x*y*z + 1, (-x + 1, -y + 1, -x*z + 1, -y*z + 1)) - sage: Omega_fundamental(0, [x, y, z], [w]) - (x*y*z*w^2 + x*y*z*w - x*y*w - x*z*w - y*z*w + 1, - (-x + 1, -y + 1, -z + 1, -x*w + 1, -y*w + 1, -z*w + 1)) - sage: Omega_fundamental(0, [x, y], [z, w]) - (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1, - (-x + 1, -y + 1, -x*z + 1, -x*w + 1, -y*z + 1, -y*w + 1)) - - sage: Omega_fundamental(-2, [x], [y]) - (x^2, (-x + 1, -x*y + 1)) - sage: Omega_fundamental(-1, [x], [y]) - (x, (-x + 1, -x*y + 1)) - sage: Omega_fundamental(1, [x], [y]) - (-x*y + y + 1, (-x + 1, -x*y + 1)) - sage: Omega_fundamental(2, [x], [y]) - (-x*y^2 - x*y + y^2 + y + 1, (-x + 1, -x*y + 1)) - """ - def flatten(z): - return sum((tuple(zz) for zz in z), tuple()) - if group_factors: - flat_x = flatten(x) - flat_y = flatten(y) - else: - flat_x = x - flat_y = y - x = tuple((xx,) for xx in x) - y = tuple((yy,) for yy in y) - - numerator = Omega_numerator(a, len(flat_x), len(flat_y)) - numerator = numerator.subs( - {xi: xj for xi, xj in zip(numerator.parent().gens(), flat_x+flat_y)}) - - Factors_denominator = \ - tuple(tuple(1 - xx for xx in gx) for gx in x) + \ - tuple(tuple(1 - xx*yy for xx in gx for yy in gy) - for gx in x for gy in y) - if not group_factors: - factors_denominator = flatten(factors_denominator) - return numerator, factors_denominator -def Omega_higher(a, z): - r""" Return `\Omega_{\ge}` of the expression specified by the input. .. MATH:: @@ -266,105 +301,6 @@ def Omega_higher(a, z): (x*y*z + x*y + x*z + 1, (-x + 1, -x*y^2 + 1, -x*z^2 + 1)) sage: Omega_higher(0, [(x, 2), (y, 1), (z, -1)]) (-x*y*z^2 - x*y*z + x*z + 1, (-x + 1, -y + 1, -x*z^2 + 1, -y*z + 1)) - """ - class Factor(object): - def __init__(self, zz): - if isinstance(zz, (tuple, list)): - self.value, self.exponent = zz - else: - self.value = zz - self.exponent = 1 - def is_higher(self): - return abs(self.exponent) > 1 - def z(self, positive=True): - if (self.exponent > 0) != positive: - return tuple() - elif self.is_higher(): - rho = powers[abs(self.exponent)] - w = self.var - return tuple(L_high(rho**j * w) - for j in srange(abs(self.exponent))) - else: - return (L_high(self.value),) - def x(self): - return self.z(positive=True) - def y(self): - return self.z(positive=False) - - z = list(Factor(zz) for zz in z) - - # -2. create new (larger) laurent polynomial ring - L_orig = z[0].value.parent() - B_orig = L_orig.base_ring() - exponents_pre = sorted(set(abs(factor.exponent) - for factor in z if factor.is_higher())) - B_high = B_orig.extension( - list(cyclotomic_polynomial(r) for r in exponents_pre), - tuple('rho{}'.format(i) for i in srange(len(exponents_pre)))) - powers = dict(zip(exponents_pre, B_high.gens())) - - nv = len(tuple(None for factor in z if factor.is_higher())) - variable_names_high = \ - tuple('Omega{}'.format(i) for i in srange(nv)) + \ - L_orig.variable_names() - L_high = LaurentPolynomialRing(B_high, variable_names_high) - - # -1. rewrite factors with higher powers - v = iter(L_high.gens()) - Omega_map = dict() - for factor in z: - if factor.is_higher(): - factor.var = next(v) - Omega_map[factor.var] = factor - - # 0. apply Omega - def nonempty(T): - return tuple(t for t in T if t) - numerator, factors_denominator = Omega_fundamental( - a, - nonempty(factor.x() for factor in z), - nonempty(factor.y() for factor in z), - group_factors=True) - - # 1. multiply grouped factors of denominator - factors_denominator = tuple(prod(factor for factor in factors) - for factors in factors_denominator) - - # 2. substitute helper variable with actual value - def subs_power(expression, var, exponent, value): - r""" - Substitute ``var^exponent`` by ``value`` in ``expression``. - """ - p = tuple(var.dict().popitem()[0]).index(1) - def subs_e(e): - e = list(e) - assert e[p] % exponent == 0 - e[p] = e[p] // exponent - return tuple(e) - parent = expression.parent() - result = parent({subs_e(e): c for e, c in iteritems(expression.dict())}) - return result.subs({var: value}) - - def subs_Omega(expression): - r""" - Substitute all helper variables by their actual values. - """ - for var, factor in iteritems(Omega_map): - expression = subs_power(expression, var, - abs(factor.exponent), factor.value) - return expression - - factors_denominator = tuple(subs_Omega(factor) - for factor in factors_denominator) - - from sage.rings.fraction_field import FractionField_generic - if isinstance(numerator.parent(), FractionField_generic): - numerator = subs_Omega(L_high(numerator.numerator())) / \ - subs_Omega(L_high(numerator.denominator())) - else: - numerator = subs_Omega(numerator) - - return numerator, factors_denominator def Omega(var, numerator, factors_denominator, operator=operator.ge): From 88983cc5b2925fa3b83f3f1cb22dfd1290c27bc6 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 18 Nov 2016 16:34:50 +0100 Subject: [PATCH 036/370] first working Omega function --- omega.py | 132 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 108 insertions(+), 24 deletions(-) diff --git a/omega.py b/omega.py index 413b34cc444..7af9542e3a1 100644 --- a/omega.py +++ b/omega.py @@ -230,6 +230,11 @@ def de_power(expression): return numerator, factors_denominator + +def Omega(var, expression, denominator=None, op=operator.ge): + r""" + + Return `\Omega_{\ge}` of the expression specified by the input. .. MATH:: @@ -278,31 +283,110 @@ def de_power(expression): EXAMPLES:: - sage: L. = LaurentPolynomialRing(QQ) - - sage: Omega_higher(0, [(x, 1), (y, -2)]) - (1, (-x + 1, -x^2*y + 1)) - sage: Omega_higher(0, [(x, 1), (y, -3)]) - (1, (-x + 1, -x^3*y + 1)) - sage: Omega_higher(0, [(x, 1), (y, -4)]) - (1, (-x + 1, -x^4*y + 1)) - - sage: Omega_higher(0, [(x, 2), (y, -1)]) - (x*y + 1, (-x + 1, -x*y^2 + 1)) - sage: Omega_higher(0, [(x, 3), (y, -1)]) - (x*y^2 + x*y + 1, (-x + 1, -x*y^3 + 1)) - sage: Omega_higher(0, [(x, 4), (y, -1)]) - (x*y^3 + x*y^2 + x*y + 1, (-x + 1, -x*y^4 + 1)) + sage: L. = LaurentPolynomialRing(QQ) + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu]) + 1 * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu, 1 - z/mu]) + 1 * (-x + 1)^-1 * (-x*y + 1)^-1 * (-x*z + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu]) + (-x*y*z + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-x*z + 1)^-1 * (-y*z + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z*mu, 1 - w/mu]) + (x*y*z*w^2 + x*y*z*w - x*y*w - x*z*w - y*z*w + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * (-z + 1)^-1 * + (-x*w + 1)^-1 * (-y*w + 1)^-1 * (-z*w + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu, 1 - w/mu]) + (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * + (-x*z + 1)^-1 * (-x*w + 1)^-1 * (-y*z + 1)^-1 * (-y*w + 1)^-1 + + sage: Omega(mu, mu^-2, [1 - x*mu, 1 - y/mu]) + x^2 * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, mu^-1, [1 - x*mu, 1 - y/mu]) + x * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, mu, [1 - x*mu, 1 - y/mu]) + (-x*y + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, mu^2, [1 - x*mu, 1 - y/mu]) + (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 + + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^2]) + 1 * (-x + 1)^-1 * (-x^2*y + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^3]) + 1 * (-x + 1)^-1 * (-x^3*y + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^4]) + 1 * (-x + 1)^-1 * (-x^4*y + 1)^-1 + + sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu]) + (x*y + 1) * (-x + 1)^-1 * (-x*y^2 + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu^3, 1 - y/mu]) + (x*y^2 + x*y + 1) * (-x + 1)^-1 * (-x*y^3 + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu^4, 1 - y/mu]) + (x*y^3 + x*y^2 + x*y + 1) * (-x + 1)^-1 * (-x*y^4 + 1)^-1 + + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu^2]) + (-x^2*y*z - x*y^2*z + x*y*z + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * (-x^2*z + 1)^-1 * (-y^2*z + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu, 1 - z/mu]) + (x*y*z + x*y + x*z + 1) * + (-x + 1)^-1 * (-x*y^2 + 1)^-1 * (-x*z^2 + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu^2, 1 - y*mu, 1 - z/mu]) + (-x*y*z^2 - x*y*z + x*z + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * (-x*z^2 + 1)^-1 * (-y*z + 1)^-1 + """ + if op != operator.ge: + raise NotImplementedError('TODO') - sage: Omega_higher(0, [(x, 1), (y, 1), (z, -2)]) - (-x^2*y*z - x*y^2*z + x*y*z + 1, - (-x + 1, -y + 1, -x^2*z + 1, -y^2*z + 1)) - sage: Omega_higher(0, [(x, 2), (y, -1), (z, -1)]) - (x*y*z + x*y + x*z + 1, (-x + 1, -x*y^2 + 1, -x*z^2 + 1)) - sage: Omega_higher(0, [(x, 2), (y, 1), (z, -1)]) - (-x*y*z^2 - x*y*z + x*z + 1, (-x + 1, -y + 1, -x*z^2 + 1, -y*z + 1)) + if denominator is None: + numerator = expression.numerator() + denominator = expression.denominator() + else: + numerator = expression + from sage.arith.misc import factor + from sage.structure.factorization import Factorization -def Omega(var, numerator, factors_denominator, operator=operator.ge): - pass + if isinstance(denominator, (list, tuple)): + factors_denominator = denominator + else: + if not isinstance(denominator, Factorization): + denominator = factor(denominator) + if not denominator.is_integral(): + raise ValueError('TODO') + numerator *= denominator.unit() + factors_denominator = tuple(factor + for factor, exponent in denominator + for _ in range(exponent)) + + R = factors_denominator[0].parent() + var = repr(var) + L0 = LaurentPolynomialRing( + R.base_ring(), tuple(v for v in R.variable_names() if v != var)) + L = LaurentPolynomialRing(L0, var) + numerator = L(numerator) + factors_denominator = tuple(L(factor) for factor in factors_denominator) + + def decode_factor(factor): + D = factor.dict() + if len(D) != 2 or D.get(0, 0) != 1: + raise NotImplementedError('Cannot handle factor {}'.format(factor)) + D.pop(0) + exponent, coefficient = next(iteritems(D)) + return -coefficient, exponent + values, z = zip(*tuple(decode_factor(factor) + for factor in factors_denominator)) + + result_numerator = 0 + result_factors_denominator = None + for a, c in iteritems(numerator.dict()): + n, fd = Omega_higher(a, z) + rules = dict(zip(n.parent().gens(), values)) + + fd = tuple(f.subs(rules) for f in fd) + if result_factors_denominator is None: + result_factors_denominator = fd + else: + assert result_factors_denominator == fd + result_numerator += c * n.subs(rules) + return Factorization([(result_numerator, 1)] + + list((f, -1) for f in result_factors_denominator), + sort=False) From ab39353bf7c56eee8ef11157aa42ac919ba4d1da Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 18 Nov 2016 17:18:55 +0100 Subject: [PATCH 037/370] renaming of some variables --- omega.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/omega.py b/omega.py index 7af9542e3a1..0b6a5c91a7a 100644 --- a/omega.py +++ b/omega.py @@ -147,7 +147,7 @@ def Omega_factors_denominator(n, m): for gx in x for gy in y) -def Omega_higher(a, z): +def Omega_higher(a, exponents): r""" EXAMPLES:: @@ -173,22 +173,21 @@ def Omega_higher(a, z): sage: Omega_higher(0, [2, 1, -1]) (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, (-z0 + 1, -z1 + 1, -z0*z2^2 + 1, -z1*z2 + 1)) """ - if not z or any(zz == 0 for zz in z): + if not exponents or any(e == 0 for e in exponents): raise NotImplementedError - x = tuple(zz for zz in z if zz > 0) - y = tuple(-zz for zz in z if zz < 0) - xy = x + y + x = tuple(e for e in exponents if e > 0) + y = tuple(-e for e in exponents if e < 0) n = sum(x) m = sum(y) - exponents = sorted(set(zz for zz in xy) - set([1])) + xy = sorted(set(x + y) - set([1])) B = QQ.extension( - list(cyclotomic_polynomial(r) for r in exponents), - tuple('rho{}'.format(i) for i in range(len(exponents)))) + list(cyclotomic_polynomial(r) for r in xy), + tuple('rho{}'.format(i) for i in range(len(xy)))) L = LaurentPolynomialRing(B, ', '.join('z{}'.format(nn) - for nn in range(len(z)))) - powers = dict(zip(exponents, iter(L(g) for g in B.gens()))) + for nn in range(len(exponents)))) + powers = dict(zip(xy, iter(L(g) for g in B.gens()))) powers[2] = L(-1) powers[1] = L(1) @@ -211,18 +210,18 @@ def subs_e(e): Z = L.change_ring(QQ) def de_power(expression): - for zz, var in zip(z, L.gens()): - if abs(zz) == 1: + for e, var in zip(exponents, L.gens()): + if abs(e) == 1: continue - expression = subs_power(expression, var, abs(zz)) + expression = subs_power(expression, var, abs(e)) return Z(expression) xy_var = _laurent_polynomial_ring_(n, m).gens() x_var = iter(xy_var[:n]) y_var = iter(xy_var[n:]) - rules = {next(x_var) if zz > 0 else next(y_var): - powers[abs(zz)]**j * var - for zz, var in zip(z, L.gens()) for j in range(abs(zz))} + rules = {next(x_var) if e > 0 else next(y_var): + powers[abs(e)]**j * var + for e, var in zip(exponents, L.gens()) for j in range(abs(e))} factors_denominator = tuple(de_power(prod(f.subs(rules) for f in factors)) for factors in Omega_factors_denominator(x, y)) From e52fea04c660a9218239ea12d93555c808ef6910 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 18 Nov 2016 17:34:59 +0100 Subject: [PATCH 038/370] docstrings --- omega.py | 130 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 96 insertions(+), 34 deletions(-) diff --git a/omega.py b/omega.py index 0b6a5c91a7a..096d2468d93 100644 --- a/omega.py +++ b/omega.py @@ -46,6 +46,29 @@ def _laurent_polynomial_ring_(n, m): def Omega_numerator(a, n, m): r""" + Return the numerator of `\Omega_{\ge}` of the expression + specified by the input. + + To be more precise, this calculates + + .. MATH:: + + \Omega_{\ge} \frac{\lambda^a}{ + (1 - x_1 \lambda) \dots (1 - x_n \lambda) + (1 - y_1 / \lambda) \dots (1 - y_m / \lambda) + + and returns its numerator. + + INPUT: + + - ``a`` -- an integer. + + - ``n`` and ``m`` -- nonnegative integers. + + OUTPUT: + + A laurent polynomial. + EXAMPLES:: sage: L. = LaurentPolynomialRing(QQ) @@ -111,6 +134,31 @@ def P(n): def Omega_factors_denominator(n, m): r""" + Return the denominator of `\Omega_{\ge}` of the expression + specified by the input. + + To be more precise, this calculates + + .. MATH:: + + \Omega_{\ge} \frac{1}{ + (1 - x_1 \lambda) \dots (1 - x_n \lambda) + (1 - y_1 / \lambda) \dots (1 - y_m / \lambda) + + and returns a factorization of its denominator. + + INPUT: + + - ``n`` and ``m`` -- nonnegative integers or + tuples of nonnegative integers. The latter specifys how the factors + of the result are grouped. An integer (former case) corresponds to + a tuple consisting of that many `1`s. + + OUTPUT: + + A factorization of the denominator as + a tuple of tuples of laurent polynomials. + EXAMPLES:: sage: Omega_factors_denominator(1, 1) @@ -149,6 +197,29 @@ def Omega_factors_denominator(n, m): def Omega_higher(a, exponents): r""" + Return `\Omega_{\ge}` of the expression specified by the input. + + To be more precise, this calculates + + .. MATH:: + + \Omega_{\ge} \frac{\lambda^a}{ + (1 - z_1 \lambda^{e_1}) \dots (1 - z_n \lambda^{e_n}) + + and returns its numerator and a factorization of its denominator. + + INPUT: + + - ``a`` -- an integer. + + - ``exponents`` -- a tuple of integers. + + OUTPUT: + + A pair representing a quotient as follows: Its first component is the + numerator as a laurent polynomial, its second component a factorization + of the denominator as a list of laurent polynomials. + EXAMPLES:: sage: Omega_higher(0, [1, -2]) @@ -171,7 +242,8 @@ def Omega_higher(a, exponents): sage: Omega_higher(0, [2, -1, -1]) (z0*z1*z2 + z0*z1 + z0*z2 + 1, (-z0 + 1, -z0*z1^2 + 1, -z0*z2^2 + 1)) sage: Omega_higher(0, [2, 1, -1]) - (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, (-z0 + 1, -z1 + 1, -z0*z2^2 + 1, -z1*z2 + 1)) + (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, + (-z0 + 1, -z1 + 1, -z0*z2^2 + 1, -z1*z2 + 1)) """ if not exponents or any(e == 0 for e in exponents): raise NotImplementedError @@ -232,57 +304,47 @@ def de_power(expression): def Omega(var, expression, denominator=None, op=operator.ge): r""" + Return `\Omega_{\mathrm{op}}` of ``expression`` with respect to ``var``. - - Return `\Omega_{\ge}` of the expression specified by the input. + To be more precise, this calculates .. MATH:: - \Omega_{\ge} \frac{\lambda^a}{ - (1 - x_1 \lambda) \dots (1 - x_n \lambda) - (1 - y_1 / \lambda) \dots (1 - y_m / \lambda) - - INPUT: - - - ``a`` -- an integer. - - - ``x`` and ``y`` -- lists of laurent polynomials - - OUTPUT: - - A pair representing a quotient as follows: Its first component is the - numerator as a laurent polynomial, its second component a factorization - of the denominator as a list of laurent polynomials. - - + \Omega_{\mathrm{op}} \frac{n}{d_1 \dots d_n} + for the numerator `n` and the factors `d_1`, ..., `d_n` of + the denominator, all of which are laurent polynomials in ``var`` + and returns a (partial) factorization of the result. + INPUT: + - ``var`` -- a variable or a representation string of a variable. - Return `\Omega_{\ge}` of the expression specified by the input. - - .. MATH:: + - ``expression`` -- an element of the quotient field of some + laurent polynomials. If ``denominator`` is specified, then + this laurent polynomial is interpreted as the numerator of the + expression. - \Omega_{\ge} \frac{\lambda^a}{ - (1 - z_1 \lambda^{e_1}) \dots (1 - z_n \lambda^{e_n}) + - ``denominator`` -- a laurent polynomial or a + :class:`~sage.structure.factorization.Factorization` (consisting + of laurent polynomial factors) or a tuple/list of factors (laurent + polynomials). - INPUT: + - ``op`` -- (default: ``operator.ge``) an operator. - - ``a`` -- an integer. + OUTPUT: - - ``z`` and ``y`` -- a lists with each entry either - a laurent polynomial (implicit exponent `1`) or - a pair of a laurent polynomial and an integer exponent. + A (partial) :class:`~sage.structure.factorization.Factorization` + of the result whose factors are laurent polynomials. - OUTPUT: + .. NOTE:: - A pair representing a quotient as follows: Its first component is the - numerator as a laurent polynomial, its second component a factorization - of the denominator as a list of laurent polynomials. + The numerator of the result may not be factored. EXAMPLES:: sage: L. = LaurentPolynomialRing(QQ) + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu]) 1 * (-x + 1)^-1 * (-x*y + 1)^-1 sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu, 1 - z/mu]) From 60d7fc3c64ee65c0b8f823f42074365e766bf0cd Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 18 Nov 2016 18:27:21 +0100 Subject: [PATCH 039/370] phrase exception messages --- omega.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 096d2468d93..445e697efb0 100644 --- a/omega.py +++ b/omega.py @@ -394,7 +394,7 @@ def Omega(var, expression, denominator=None, op=operator.ge): (-x + 1)^-1 * (-y + 1)^-1 * (-x*z^2 + 1)^-1 * (-y*z + 1)^-1 """ if op != operator.ge: - raise NotImplementedError('TODO') + raise NotImplementedError('At the moment, only Omega_ge is implemented.') if denominator is None: numerator = expression.numerator() @@ -411,7 +411,8 @@ def Omega(var, expression, denominator=None, op=operator.ge): if not isinstance(denominator, Factorization): denominator = factor(denominator) if not denominator.is_integral(): - raise ValueError('TODO') + raise ValueError('Factorization {} of the denominator ' + 'contains negative exponents.'.format(denominator)) numerator *= denominator.unit() factors_denominator = tuple(factor for factor, exponent in denominator From 383cfe8e4e48bed17a553dd2ccb694c44ba1d35d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 18 Nov 2016 18:28:02 +0100 Subject: [PATCH 040/370] handle and test corner cases --- omega.py | 96 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 82 insertions(+), 14 deletions(-) diff --git a/omega.py b/omega.py index 445e697efb0..b5e2231b682 100644 --- a/omega.py +++ b/omega.py @@ -39,9 +39,12 @@ def HomogenousSymmetricFunction(j, x): def _laurent_polynomial_ring_(n, m): from itertools import chain - return LaurentPolynomialRing(QQ, ', '.join(chain( + if n + m == 0: + return QQ, tuple() + L = LaurentPolynomialRing(QQ, ', '.join(chain( iter('x{}'.format(nn) for nn in range(n)), iter('y{}'.format(mm) for mm in range(m))))) + return L, L.gens() def Omega_numerator(a, n, m): @@ -91,10 +94,43 @@ def Omega_numerator(a, n, m): -x0*y0 + y0 + 1 sage: Omega_numerator(2, 1, 1) -x0*y0^2 - x0*y0 + y0^2 + y0 + 1 + + TESTS:: + + sage: Omega_factors_denominator(0, 0) + () + sage: Omega_numerator(0, 0, 0) + 1 + sage: Omega_numerator(+2, 0, 0) + 1 + sage: Omega_numerator(-2, 0, 0) + 0 + + sage: Omega_factors_denominator(1, 0) + ((1 - x0,),) + sage: Omega_numerator(0, 1, 0) + 1 + sage: Omega_numerator(+2, 1, 0) + 1 + sage: Omega_numerator(-2, 1, 0) + x0^2 + + sage: Omega_factors_denominator(0, 1) + () + sage: Omega_numerator(0, 0, 1) + 1 + sage: Omega_numerator(+2, 0, 1) + 1 + y0 + y0^2 + sage: Omega_numerator(-2, 0, 1) + 0 """ - Y = LaurentPolynomialRing( - QQ, ', '.join('y{}'.format(mm) for mm in range(m))) - y = Y.gens() + if m == 0: + Y = QQ + y = tuple() + else: + Y = LaurentPolynomialRing( + QQ, ', '.join('y{}'.format(mm) for mm in range(m))) + y = Y.gens() def P(n): if n == 1: @@ -118,15 +154,15 @@ def P(n): assert r == 0 return q - XY = _laurent_polynomial_ring_(n, m) + XY, xy_vars = _laurent_polynomial_ring_(n, m) if m == 0: - return XY(1 - (prod(factors_denominator) * - sum(HomogenousSymmetricFunction(j, XY.gens()) + return XY(1 - (prod(prod(f) for f in Omega_factors_denominator(n, m)) * + sum(HomogenousSymmetricFunction(j, xy_vars) for j in srange(-a)) if a < 0 else 0)) elif n == 0: - return XY(sum(HomogenousSymmetricFunction(j, XY.gens()) + return XY(sum(HomogenousSymmetricFunction(j, xy_vars) for j in srange(a+1))) else: return XY(P(n)) @@ -173,6 +209,15 @@ def Omega_factors_denominator(n, m): sage: Omega_factors_denominator(2, 2) ((-x0 + 1,), (-x1 + 1,), (-x0*y0 + 1,), (-x0*y1 + 1,), (-x1*y0 + 1,), (-x1*y1 + 1,)) + + TESTS:: + + sage: Omega_factors_denominator(0, 0) + () + sage: Omega_factors_denominator(1, 0) + ((1 - x0,),) + sage: Omega_factors_denominator(0, 1) + () """ if isinstance(n, tuple): x = n @@ -185,8 +230,7 @@ def Omega_factors_denominator(n, m): else: y = tuple(1 for _ in range(m)) - XY = _laurent_polynomial_ring_(n, m) - ixy = iter(XY.gens()) + ixy = iter(_laurent_polynomial_ring_(n, m)[1]) x = tuple(tuple(next(ixy) for _ in range(nx)) for nx in x) y = tuple(tuple(next(ixy) for _ in range(my)) for my in y) @@ -288,10 +332,10 @@ def de_power(expression): expression = subs_power(expression, var, abs(e)) return Z(expression) - xy_var = _laurent_polynomial_ring_(n, m).gens() - x_var = iter(xy_var[:n]) - y_var = iter(xy_var[n:]) - rules = {next(x_var) if e > 0 else next(y_var): + xy_vars = _laurent_polynomial_ring_(n, m)[1] + x_vars = iter(xy_vars[:n]) + y_vars = iter(xy_vars[n:]) + rules = {next(x_vars) if e > 0 else next(y_vars): powers[abs(e)]**j * var for e, var in zip(exponents, L.gens()) for j in range(abs(e))} factors_denominator = tuple(de_power(prod(f.subs(rules) for f in factors)) @@ -392,6 +436,21 @@ def Omega(var, expression, denominator=None, op=operator.ge): sage: Omega(mu, 1, [1 - x*mu^2, 1 - y*mu, 1 - z/mu]) (-x*y*z^2 - x*y*z + x*z + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-x*z^2 + 1)^-1 * (-y*z + 1)^-1 + + TESTS:: + + sage: Omega(mu, 1, [1 - x*mu]) + 1 * (-x + 1)^-1 + sage: Omega(mu, 1, [1 - x/mu]) + 1 + sage: Omega(mu, 0, [1 - x*mu]) + 0 + sage: Omega(mu, L(1), []) + 1 + sage: Omega(mu, L(0), []) + 0 + sage: Omega(mu, 2, []) + 2 """ if op != operator.ge: raise NotImplementedError('At the moment, only Omega_ge is implemented.') @@ -418,12 +477,21 @@ def Omega(var, expression, denominator=None, op=operator.ge): for factor, exponent in denominator for _ in range(exponent)) + if not factors_denominator: + try: + var = numerator.parent()(var) + except (TypeError, ValueError): + return Factorization([(numerator, 1)]) + else: + return Factorization([(numerator.subs({var: 1}), 1)]) R = factors_denominator[0].parent() var = repr(var) L0 = LaurentPolynomialRing( R.base_ring(), tuple(v for v in R.variable_names() if v != var)) L = LaurentPolynomialRing(L0, var) numerator = L(numerator) + if numerator == 0: + return Factorization([], unit=numerator) factors_denominator = tuple(L(factor) for factor in factors_denominator) def decode_factor(factor): From 40f214c083403167064ad82d83d9892baf9eb22f Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 18 Nov 2016 18:34:31 +0100 Subject: [PATCH 041/370] reorder doctests --- omega.py | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/omega.py b/omega.py index b5e2231b682..bbe63e78c7d 100644 --- a/omega.py +++ b/omega.py @@ -391,45 +391,29 @@ def Omega(var, expression, denominator=None, op=operator.ge): sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu]) 1 * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu, 1 - z/mu]) 1 * (-x + 1)^-1 * (-x*y + 1)^-1 * (-x*z + 1)^-1 sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu]) (-x*y*z + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-x*z + 1)^-1 * (-y*z + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z*mu, 1 - w/mu]) - (x*y*z*w^2 + x*y*z*w - x*y*w - x*z*w - y*z*w + 1) * - (-x + 1)^-1 * (-y + 1)^-1 * (-z + 1)^-1 * - (-x*w + 1)^-1 * (-y*w + 1)^-1 * (-z*w + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu, 1 - w/mu]) - (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1) * - (-x + 1)^-1 * (-y + 1)^-1 * - (-x*z + 1)^-1 * (-x*w + 1)^-1 * (-y*z + 1)^-1 * (-y*w + 1)^-1 - - sage: Omega(mu, mu^-2, [1 - x*mu, 1 - y/mu]) - x^2 * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, mu^-1, [1 - x*mu, 1 - y/mu]) - x * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, mu, [1 - x*mu, 1 - y/mu]) - (-x*y + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, mu^2, [1 - x*mu, 1 - y/mu]) - (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^2]) 1 * (-x + 1)^-1 * (-x^2*y + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu]) + (x*y + 1) * (-x + 1)^-1 * (-x*y^2 + 1)^-1 + + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu^2]) + (-x^2*y*z - x*y^2*z + x*y*z + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * (-x^2*z + 1)^-1 * (-y^2*z + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^3]) 1 * (-x + 1)^-1 * (-x^3*y + 1)^-1 sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^4]) 1 * (-x + 1)^-1 * (-x^4*y + 1)^-1 - - sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu]) - (x*y + 1) * (-x + 1)^-1 * (-x*y^2 + 1)^-1 sage: Omega(mu, 1, [1 - x*mu^3, 1 - y/mu]) (x*y^2 + x*y + 1) * (-x + 1)^-1 * (-x*y^3 + 1)^-1 sage: Omega(mu, 1, [1 - x*mu^4, 1 - y/mu]) (x*y^3 + x*y^2 + x*y + 1) * (-x + 1)^-1 * (-x*y^4 + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu^2]) - (-x^2*y*z - x*y^2*z + x*y*z + 1) * - (-x + 1)^-1 * (-y + 1)^-1 * (-x^2*z + 1)^-1 * (-y^2*z + 1)^-1 sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu, 1 - z/mu]) (x*y*z + x*y + x*z + 1) * (-x + 1)^-1 * (-x*y^2 + 1)^-1 * (-x*z^2 + 1)^-1 @@ -437,6 +421,24 @@ def Omega(var, expression, denominator=None, op=operator.ge): (-x*y*z^2 - x*y*z + x*z + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-x*z^2 + 1)^-1 * (-y*z + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z*mu, 1 - w/mu]) + (x*y*z*w^2 + x*y*z*w - x*y*w - x*z*w - y*z*w + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * (-z + 1)^-1 * + (-x*w + 1)^-1 * (-y*w + 1)^-1 * (-z*w + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu, 1 - w/mu]) + (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * + (-x*z + 1)^-1 * (-x*w + 1)^-1 * (-y*z + 1)^-1 * (-y*w + 1)^-1 + + sage: Omega(mu, mu^-2, [1 - x*mu, 1 - y/mu]) + x^2 * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, mu^-1, [1 - x*mu, 1 - y/mu]) + x * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, mu, [1 - x*mu, 1 - y/mu]) + (-x*y + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, mu^2, [1 - x*mu, 1 - y/mu]) + (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 + TESTS:: sage: Omega(mu, 1, [1 - x*mu]) From 8dd9ef148f68bcb6bea8274141203714317bfad7 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 18 Nov 2016 19:07:30 +0100 Subject: [PATCH 042/370] replace list by tuple in doctests of Omega_higher --- omega.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/omega.py b/omega.py index bbe63e78c7d..672585fe1a9 100644 --- a/omega.py +++ b/omega.py @@ -266,26 +266,26 @@ def Omega_higher(a, exponents): EXAMPLES:: - sage: Omega_higher(0, [1, -2]) + sage: Omega_higher(0, (1, -2)) (1, (-z0 + 1, -z0^2*z1 + 1)) - sage: Omega_higher(0, [1, -3]) + sage: Omega_higher(0, (1, -3)) (1, (-z0 + 1, -z0^3*z1 + 1)) - sage: Omega_higher(0, [1, -4]) + sage: Omega_higher(0, (1, -4)) (1, (-z0 + 1, -z0^4*z1 + 1)) - sage: Omega_higher(0, [2, -1]) + sage: Omega_higher(0, (2, -1)) (z0*z1 + 1, (-z0 + 1, -z0*z1^2 + 1)) - sage: Omega_higher(0, [3, -1]) + sage: Omega_higher(0, (3, -1)) (z0*z1^2 + z0*z1 + 1, (-z0 + 1, -z0*z1^3 + 1)) - sage: Omega_higher(0, [4, -1]) + sage: Omega_higher(0, (4, -1)) (z0*z1^3 + z0*z1^2 + z0*z1 + 1, (-z0 + 1, -z0*z1^4 + 1)) - sage: Omega_higher(0, [1, 1, -2]) + sage: Omega_higher(0, (1, 1, -2)) (-z0^2*z1*z2 - z0*z1^2*z2 + z0*z1*z2 + 1, (-z0 + 1, -z1 + 1, -z0^2*z2 + 1, -z1^2*z2 + 1)) - sage: Omega_higher(0, [2, -1, -1]) + sage: Omega_higher(0, (2, -1, -1)) (z0*z1*z2 + z0*z1 + z0*z2 + 1, (-z0 + 1, -z0*z1^2 + 1, -z0*z2^2 + 1)) - sage: Omega_higher(0, [2, 1, -1]) + sage: Omega_higher(0, (2, 1, -1)) (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, (-z0 + 1, -z1 + 1, -z0*z2^2 + 1, -z1*z2 + 1)) """ From 932b0e012205ce442f209c978599bf0ce0c9fc3c Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 18 Nov 2016 19:07:44 +0100 Subject: [PATCH 043/370] enable caching --- omega.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 672585fe1a9..a941ceced61 100644 --- a/omega.py +++ b/omega.py @@ -47,6 +47,7 @@ def _laurent_polynomial_ring_(n, m): return L, L.gens() +@cached_function def Omega_numerator(a, n, m): r""" Return the numerator of `\Omega_{\ge}` of the expression @@ -168,6 +169,7 @@ def P(n): return XY(P(n)) +@cached_function def Omega_factors_denominator(n, m): r""" Return the denominator of `\Omega_{\ge}` of the expression @@ -239,6 +241,7 @@ def Omega_factors_denominator(n, m): for gx in x for gy in y) +@cached_function def Omega_higher(a, exponents): r""" Return `\Omega_{\ge}` of the expression specified by the input. @@ -503,8 +506,12 @@ def decode_factor(factor): D.pop(0) exponent, coefficient = next(iteritems(D)) return -coefficient, exponent - values, z = zip(*tuple(decode_factor(factor) - for factor in factors_denominator)) + # Below we sort to make the caching more efficient. Doing this here + # (in contrast to directly in Omega_higher) results in much cleaner + # code and prevents an additional substitution or passing of a permutation. + values, z = zip(*sorted(tuple(decode_factor(factor) + for factor in factors_denominator), + key=lambda k: -k[1])) result_numerator = 0 result_factors_denominator = None From a39fb534165fea2c80f738f0e270c9a303dee7a6 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 18 Nov 2016 19:24:22 +0100 Subject: [PATCH 044/370] minor correction in docstring --- omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omega.py b/omega.py index a941ceced61..4bcc2d45145 100644 --- a/omega.py +++ b/omega.py @@ -265,7 +265,7 @@ def Omega_higher(a, exponents): A pair representing a quotient as follows: Its first component is the numerator as a laurent polynomial, its second component a factorization - of the denominator as a list of laurent polynomials. + of the denominator as a tuple of laurent polynomials. EXAMPLES:: From 3e909136fc760cbc8c376f079b2803ddb9dd4283 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 18 Nov 2016 19:24:48 +0100 Subject: [PATCH 045/370] create efficient intermediate function _Omega_ for accessing low level functions --- omega.py | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/omega.py b/omega.py index 4bcc2d45145..3ba78937c28 100644 --- a/omega.py +++ b/omega.py @@ -509,23 +509,46 @@ def decode_factor(factor): # Below we sort to make the caching more efficient. Doing this here # (in contrast to directly in Omega_higher) results in much cleaner # code and prevents an additional substitution or passing of a permutation. - values, z = zip(*sorted(tuple(decode_factor(factor) - for factor in factors_denominator), - key=lambda k: -k[1])) + decoded_factors = tuple(decode_factor(factor) + for factor in factors_denominator) result_numerator = 0 result_factors_denominator = None for a, c in iteritems(numerator.dict()): - n, fd = Omega_higher(a, z) - rules = dict(zip(n.parent().gens(), values)) - - fd = tuple(f.subs(rules) for f in fd) + n, fd = _Omega_(a, decoded_factors) if result_factors_denominator is None: result_factors_denominator = fd else: assert result_factors_denominator == fd - result_numerator += c * n.subs(rules) + result_numerator += c * n return Factorization([(result_numerator, 1)] + list((f, -1) for f in result_factors_denominator), sort=False) + + +def _Omega_(a, decoded_factors): + r""" + Helper function for :func:`Omega` which accesses the low level functions + and does the substituting. + + INPUT: + + - ``a`` -- an integer. + + - ``decoded_factors`` -- a tuple or list of pairs `(z, e)` representing + a factor `1 - \lambda^e z`. + + OUTPUT: + + A pair representing a quotient as follows: Its first component is the + numerator as a laurent polynomial, its second component a factorization + of the denominator as a tuple of laurent polynomials. + """ + # Below we sort to make the caching more efficient. Doing this here + # (in contrast to directly in Omega_higher) results in much cleaner + # code and prevents an additional substitution or passing of a permutation. + values, exponents = zip(*sorted(decoded_factors, key=lambda k: -k[1])) + n, fd = Omega_higher(a, exponents) + rules = dict(zip(n.parent().gens(), values)) + return n.subs(rules), tuple(f.subs(rules) for f in fd) From aaf4624ad33c1789ed2250b469145a47ad260c10 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 20 Nov 2016 10:58:31 +0100 Subject: [PATCH 046/370] cleanup --- omega.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/omega.py b/omega.py index 3ba78937c28..ea6a267b66e 100644 --- a/omega.py +++ b/omega.py @@ -506,9 +506,6 @@ def decode_factor(factor): D.pop(0) exponent, coefficient = next(iteritems(D)) return -coefficient, exponent - # Below we sort to make the caching more efficient. Doing this here - # (in contrast to directly in Omega_higher) results in much cleaner - # code and prevents an additional substitution or passing of a permutation. decoded_factors = tuple(decode_factor(factor) for factor in factors_denominator) From ee46eb8cdd7037a7b3d016b81144ceb525e99707 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 20 Nov 2016 16:20:35 +0100 Subject: [PATCH 047/370] __init__.py --- __init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 00000000000..e69de29bb2d From 7c22a92af5dd7a0ea2617c51a29af61348d1e924 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 20 Nov 2016 16:20:51 +0100 Subject: [PATCH 048/370] imports --- omega.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/omega.py b/omega.py index ea6a267b66e..204ce330146 100644 --- a/omega.py +++ b/omega.py @@ -11,10 +11,12 @@ from __future__ import print_function from __future__ import absolute_import +from six import iteritems, itervalues import operator +from sage.misc.cachefunc import cached_function +from sage.misc.misc_c import prod from sage.groups.indexed_free_group import IndexedFreeAbelianGroup -from six import iteritems, itervalues def HomogenousSymmetricFunction(j, x): From 181ae735e50f9977201d9989a369bacdc0a0a066 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 20 Nov 2016 16:21:22 +0100 Subject: [PATCH 049/370] allow factorizations as input --- omega.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/omega.py b/omega.py index 204ce330146..c8cc7b24b71 100644 --- a/omega.py +++ b/omega.py @@ -459,17 +459,24 @@ def Omega(var, expression, denominator=None, op=operator.ge): sage: Omega(mu, 2, []) 2 """ + from sage.arith.misc import factor + from sage.structure.factorization import Factorization + if op != operator.ge: raise NotImplementedError('At the moment, only Omega_ge is implemented.') if denominator is None: - numerator = expression.numerator() - denominator = expression.denominator() + if isinstance(expression, Factorization): + numerator = expression.unit() * \ + prod(f**e for f, e in expression if e > 0) + denominator = tuple(f for f, e in expression if e < 0 + for _ in range(-e)) + else: + numerator = expression.numerator() + denominator = expression.denominator() else: numerator = expression - from sage.arith.misc import factor - from sage.structure.factorization import Factorization if isinstance(denominator, (list, tuple)): factors_denominator = denominator From 2aa270a72429a7fad0d07688221cd46bc4c2c414 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 20 Nov 2016 16:22:19 +0100 Subject: [PATCH 050/370] improve determining working laurent polynomial ring --- omega.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/omega.py b/omega.py index c8cc7b24b71..a4ff328ec39 100644 --- a/omega.py +++ b/omega.py @@ -498,11 +498,17 @@ def Omega(var, expression, denominator=None, op=operator.ge): return Factorization([(numerator, 1)]) else: return Factorization([(numerator.subs({var: 1}), 1)]) - R = factors_denominator[0].parent() - var = repr(var) - L0 = LaurentPolynomialRing( - R.base_ring(), tuple(v for v in R.variable_names() if v != var)) - L = LaurentPolynomialRing(L0, var) + + if not isinstance(var, str) and \ + len(var.parent().gens()) == 1 and var.parent().gen() == var: + L = var.parent() + else: + R = factors_denominator[0].parent() + var = repr(var) + L0 = LaurentPolynomialRing( + R.base_ring(), tuple(v for v in R.variable_names() if v != var)) + L = LaurentPolynomialRing(L0, var) + numerator = L(numerator) if numerator == 0: return Factorization([], unit=numerator) From fa8dcc880c0fe33f7d082a766bba4d612beeab3d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 20 Nov 2016 16:41:19 +0100 Subject: [PATCH 051/370] doctest for Factorization input --- omega.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/omega.py b/omega.py index a4ff328ec39..471db06fbe9 100644 --- a/omega.py +++ b/omega.py @@ -458,6 +458,13 @@ def Omega(var, expression, denominator=None, op=operator.ge): 0 sage: Omega(mu, 2, []) 2 + + :: + + sage: Omega(mu, Factorization([(1/mu, 1), (1 - x*mu, -1), + ....: (1 - y/mu, -2)], unit=2)) + 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 + """ from sage.arith.misc import factor from sage.structure.factorization import Factorization From 02a2c845641a9860f17a727bdfe633dc595d26da Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 20 Nov 2016 16:54:36 +0100 Subject: [PATCH 052/370] function to partition into two sublists --- omega.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/omega.py b/omega.py index 471db06fbe9..14e2230cb70 100644 --- a/omega.py +++ b/omega.py @@ -19,6 +19,34 @@ from sage.groups.indexed_free_group import IndexedFreeAbelianGroup +def partition(items, predicate=bool): + r""" + Split ``items`` into two parts by the given ``predicate``. + + INPUT: + + - ``item`` -- an iterator. + + OUTPUT: + + A pair of iterators; the first contains the elements not satisfying + the ``predicate``, the second the elements satisfying the ``predicate``. + + Source of the code: + `http://nedbatchelder.com/blog/201306/filter_a_list_into_two_parts.html`_ + + EXAMPLES: + + sage: E, O = partition(srange(10), is_odd) + sage: tuple(E), tuple(O) + ((0, 2, 4, 6, 8), (1, 3, 5, 7, 9)) + """ + from itertools import tee + a, b = tee((predicate(item), item) for item in items) + return ((item for pred, item in a if not pred), + (item for pred, item in b if pred)) + + def HomogenousSymmetricFunction(j, x): r""" EXAMPLES:: From 5e85c1fdc5660a44e56f3c07cf09a2054d101a37 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 20 Nov 2016 16:54:57 +0100 Subject: [PATCH 053/370] deal with factors not containing the lambda-variable --- omega.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/omega.py b/omega.py index 14e2230cb70..f4311eed823 100644 --- a/omega.py +++ b/omega.py @@ -493,6 +493,10 @@ def Omega(var, expression, denominator=None, op=operator.ge): ....: (1 - y/mu, -2)], unit=2)) 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 + :: + + sage: Omega(mu, 1, [1 - x*mu, 1 - z, 1 - y/mu]) + 1 * ((-z + 1))^-1 * (-x + 1)^-1 * (-x*y + 1)^-1 """ from sage.arith.misc import factor from sage.structure.factorization import Factorization @@ -543,12 +547,15 @@ def Omega(var, expression, denominator=None, op=operator.ge): L0 = LaurentPolynomialRing( R.base_ring(), tuple(v for v in R.variable_names() if v != var)) L = LaurentPolynomialRing(L0, var) + var = L.gen() numerator = L(numerator) if numerator == 0: return Factorization([], unit=numerator) factors_denominator = tuple(L(factor) for factor in factors_denominator) + other_factors, factors_denominator = partition( + factors_denominator, lambda factor: var in factor.variables()) def decode_factor(factor): D = factor.dict() if len(D) != 2 or D.get(0, 0) != 1: @@ -570,6 +577,7 @@ def decode_factor(factor): result_numerator += c * n return Factorization([(result_numerator, 1)] + + list((f, -1) for f in other_factors) + list((f, -1) for f in result_factors_denominator), sort=False) From 0ed2a48c13bab9a3b2bf70269fcbf8e95864b767 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 20 Nov 2016 17:37:35 +0100 Subject: [PATCH 054/370] replace QQ by ZZ --- omega.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/omega.py b/omega.py index f4311eed823..b6c1a353908 100644 --- a/omega.py +++ b/omega.py @@ -70,8 +70,8 @@ def HomogenousSymmetricFunction(j, x): def _laurent_polynomial_ring_(n, m): from itertools import chain if n + m == 0: - return QQ, tuple() - L = LaurentPolynomialRing(QQ, ', '.join(chain( + return ZZ, tuple() + L = LaurentPolynomialRing(ZZ, ', '.join(chain( iter('x{}'.format(nn) for nn in range(n)), iter('y{}'.format(mm) for mm in range(m))))) return L, L.gens() @@ -105,7 +105,7 @@ def Omega_numerator(a, n, m): EXAMPLES:: - sage: L. = LaurentPolynomialRing(QQ) + sage: L. = LaurentPolynomialRing(ZZ) sage: Omega_numerator(0, 1, 1) 1 sage: Omega_numerator(0, 2, 1) @@ -156,11 +156,11 @@ def Omega_numerator(a, n, m): 0 """ if m == 0: - Y = QQ + Y = ZZ y = tuple() else: Y = LaurentPolynomialRing( - QQ, ', '.join('y{}'.format(mm) for mm in range(m))) + ZZ, ', '.join('y{}'.format(mm) for mm in range(m))) y = Y.gens() def P(n): @@ -356,7 +356,7 @@ def subs_e(e): return result return result.subs({var: value}) - Z = L.change_ring(QQ) + Z = L.change_ring(ZZ) def de_power(expression): for e, var in zip(exponents, L.gens()): @@ -420,7 +420,7 @@ def Omega(var, expression, denominator=None, op=operator.ge): EXAMPLES:: - sage: L. = LaurentPolynomialRing(QQ) + sage: L. = LaurentPolynomialRing(ZZ) sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu]) 1 * (-x + 1)^-1 * (-x*y + 1)^-1 From 178f6a9faa1d1ceeed4217e8e7ac3e9ce9094221 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 20 Nov 2016 17:44:21 +0100 Subject: [PATCH 055/370] restructure and deal with imports --- omega.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index b6c1a353908..6a9e3ba66e1 100644 --- a/omega.py +++ b/omega.py @@ -15,8 +15,6 @@ import operator from sage.misc.cachefunc import cached_function -from sage.misc.misc_c import prod -from sage.groups.indexed_free_group import IndexedFreeAbelianGroup def partition(items, predicate=bool): @@ -63,12 +61,17 @@ def HomogenousSymmetricFunction(j, x): X0*X1*X2 + X1^2*X2 + X0*X2^2 + X1*X2^2 + X2^3 """ from sage.combinat.integer_vector import IntegerVectors + from sage.misc.misc_c import prod + return sum(prod(xx**pp for xx, pp in zip(x, p)) for p in IntegerVectors(j, length=len(x))) def _laurent_polynomial_ring_(n, m): from itertools import chain + from sage.rings.integer_ring import ZZ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + if n + m == 0: return ZZ, tuple() L = LaurentPolynomialRing(ZZ, ', '.join(chain( @@ -155,6 +158,10 @@ def Omega_numerator(a, n, m): sage: Omega_numerator(-2, 0, 1) 0 """ + from sage.misc.misc_c import prod + from sage.rings.integer_ring import ZZ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + if m == 0: Y = ZZ y = tuple() @@ -322,6 +329,11 @@ def Omega_higher(a, exponents): (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, (-z0 + 1, -z1 + 1, -z0*z2^2 + 1, -z1*z2 + 1)) """ + from sage.misc.misc_c import prod + from sage.rings.integer_ring import ZZ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + from sage.rings.rational_field import QQ + if not exponents or any(e == 0 for e in exponents): raise NotImplementedError @@ -499,6 +511,8 @@ def Omega(var, expression, denominator=None, op=operator.ge): 1 * ((-z + 1))^-1 * (-x + 1)^-1 * (-x*y + 1)^-1 """ from sage.arith.misc import factor + from sage.misc.misc_c import prod + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing from sage.structure.factorization import Factorization if op != operator.ge: From c34bf8f15cbcc5819b0af5b714c53270ba439928 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 21 Nov 2016 13:22:56 +0100 Subject: [PATCH 056/370] deal with factors var^(-1) --- omega.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/omega.py b/omega.py index 6a9e3ba66e1..46e44659812 100644 --- a/omega.py +++ b/omega.py @@ -504,11 +504,14 @@ def Omega(var, expression, denominator=None, op=operator.ge): sage: Omega(mu, Factorization([(1/mu, 1), (1 - x*mu, -1), ....: (1 - y/mu, -2)], unit=2)) 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 + sage: Omega(mu, Factorization([(mu, -1), (1 - x*mu, -1), + ....: (1 - y/mu, -2)], unit=2)) + 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 :: sage: Omega(mu, 1, [1 - x*mu, 1 - z, 1 - y/mu]) - 1 * ((-z + 1))^-1 * (-x + 1)^-1 * (-x*y + 1)^-1 + 1 * (-z + 1)^-1 * (-x + 1)^-1 * (-x*y + 1)^-1 """ from sage.arith.misc import factor from sage.misc.misc_c import prod @@ -555,6 +558,7 @@ def Omega(var, expression, denominator=None, op=operator.ge): if not isinstance(var, str) and \ len(var.parent().gens()) == 1 and var.parent().gen() == var: L = var.parent() + L0 = L.base_ring() else: R = factors_denominator[0].parent() var = repr(var) @@ -567,9 +571,16 @@ def Omega(var, expression, denominator=None, op=operator.ge): if numerator == 0: return Factorization([], unit=numerator) factors_denominator = tuple(L(factor) for factor in factors_denominator) - - other_factors, factors_denominator = partition( - factors_denominator, lambda factor: var in factor.variables()) + factors_denominator, to_numerator = partition( + factors_denominator, + lambda factor: factor.variables() == (var,) and len(factor.dict()) == 1) + numerator /= prod(to_numerator) + + factors_denominator, other_factors = partition( + factors_denominator, + lambda factor: var not in factor.variables()) + other_factors = tuple(other_factors) + other_factors = tuple(L0(f) for f in other_factors) def decode_factor(factor): D = factor.dict() if len(D) != 2 or D.get(0, 0) != 1: From 3d3f79e265c0afea17d93762df60c0ca9ddaac66 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 21 Nov 2016 14:08:29 +0100 Subject: [PATCH 057/370] another forgotten import --- omega.py | 1 + 1 file changed, 1 insertion(+) diff --git a/omega.py b/omega.py index 46e44659812..54d7ef09170 100644 --- a/omega.py +++ b/omega.py @@ -158,6 +158,7 @@ def Omega_numerator(a, n, m): sage: Omega_numerator(-2, 0, 1) 0 """ + from sage.arith.srange import srange from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing From 3d0a1c8a55d9091eac812d9c517b4e007e144767 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 21 Nov 2016 14:11:40 +0100 Subject: [PATCH 058/370] gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..0d20b6487c6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc From 1de3d22f493a100c05cf915dd8bdf310bfa1c686 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 23 Nov 2016 15:16:44 +0100 Subject: [PATCH 059/370] minor speedup --- omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omega.py b/omega.py index 54d7ef09170..ae09809a088 100644 --- a/omega.py +++ b/omega.py @@ -605,7 +605,7 @@ def decode_factor(factor): return Factorization([(result_numerator, 1)] + list((f, -1) for f in other_factors) + list((f, -1) for f in result_factors_denominator), - sort=False) + sort=False, simplify=False) def _Omega_(a, decoded_factors): From 8b396182aab815ece7288155f734cc26e4d51a92 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 23 Nov 2016 15:16:59 +0100 Subject: [PATCH 060/370] major speedup (using number_of_terms) --- omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omega.py b/omega.py index ae09809a088..d74845102b0 100644 --- a/omega.py +++ b/omega.py @@ -574,7 +574,7 @@ def Omega(var, expression, denominator=None, op=operator.ge): factors_denominator = tuple(L(factor) for factor in factors_denominator) factors_denominator, to_numerator = partition( factors_denominator, - lambda factor: factor.variables() == (var,) and len(factor.dict()) == 1) + lambda factor: factor.variables() == (var,) and factor.number_of_terms() == 1) numerator /= prod(to_numerator) factors_denominator, other_factors = partition( From 1d46ad1b76c9e100f347e0b5a5c6e12849dab400 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 23 Nov 2016 16:33:44 +0100 Subject: [PATCH 061/370] generating function of inequalities/polyhedron --- omega.py | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/omega.py b/omega.py index d74845102b0..b01f5385017 100644 --- a/omega.py +++ b/omega.py @@ -633,3 +633,68 @@ def _Omega_(a, decoded_factors): n, fd = Omega_higher(a, exponents) rules = dict(zip(n.parent().gens(), values)) return n.subs(rules), tuple(f.subs(rules) for f in fd) + + +def preparation_generating_function_of_polyhedron(polyhedron, indices=None): + + from sage.geometry.polyhedron.representation import Hrepresentation + from sage.rings.integer_ring import ZZ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + from sage.structure.factorization import Factorization + + def inequalities_coeffs(inequalities): + for entry in inequalities: + if isinstance(entry, (tuple, list)): + yield tuple(entry) + elif isinstance(entry, Hrepresentation): + if entry.is_inequality(): + yield tuple(entry.vector()) + elif entry.is_equation(): + e = tuple(entry.vector()) + yield e + yield tuple(-ee for ee in e) + else: + raise ValueError( + 'Cannot handle Hrepresentation {}.'.format(entry)) + else: + raise ValueError('Cannot handle {}.'.format(entry)) + + try: + inequalities = polyhedron.Hrepresentation() + except AttributeError: + inequalities = polyhedron + inequalities = tuple(inequalities_coeffs(inequalities)) + if not inequalities: + raise ValueError('no inequality given') + + if indices is None: + indices = range(len(inequalities[0]) - 1) + B = LaurentPolynomialRing( + ZZ, + ', '.join('y{}'.format(k) for k in indices), + sparse=True) + + n = len(B.gens()) + 1 + if any(len(ineq) != n for ineq in inequalities): + raise ValueError('Not all coefficient vectors of the inequalities ' + 'have the same length.') + + factors = [] + terms = B.gens() + L = B + for i, coeffs in enumerate(inequalities): + L = LaurentPolynomialRing(L, 'lambda{}'.format(i), sparse=True) + l = L.gen() + it_coeffs = iter(coeffs) + factors.append((l, next(it_coeffs))) + terms = tuple(l**c * t for c, t in zip(it_coeffs, terms)) + + return Factorization(factors + list((1-t, -1) for t in terms), + sort=False, simplify=False) + + +def generating_function_of_polyhedron(polyhedron, indices=None): + GF = preparation_generating_function_of_polyhedron(polyhedron, indices) + while repr(GF.universe().gen()).startswith('lambda'): + GF = Omega(GF.universe().gen(), GF) + return GF From b3668bfe0ad5e5bd89dfebfa4d4bf7993fc70db0 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 24 Nov 2016 17:49:18 +0100 Subject: [PATCH 062/370] another import (cyclotomic_polynomial) --- omega.py | 1 + 1 file changed, 1 insertion(+) diff --git a/omega.py b/omega.py index b01f5385017..55011155982 100644 --- a/omega.py +++ b/omega.py @@ -330,6 +330,7 @@ def Omega_higher(a, exponents): (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, (-z0 + 1, -z1 + 1, -z0*z2^2 + 1, -z1*z2 + 1)) """ + from sage.misc.functional import cyclotomic_polynomial from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing From fcfaa9740983dccf3106269a5fad583a2290a199 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 24 Nov 2016 18:16:40 +0100 Subject: [PATCH 063/370] option simplify/sort for Factorization --- omega.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/omega.py b/omega.py index 55011155982..fcf26328447 100644 --- a/omega.py +++ b/omega.py @@ -393,7 +393,8 @@ def de_power(expression): return numerator, factors_denominator -def Omega(var, expression, denominator=None, op=operator.ge): +def Omega(var, expression, denominator=None, op=operator.ge, + Factorization_sort=False, Factorization_simplify=True): r""" Return `\Omega_{\mathrm{op}}` of ``expression`` with respect to ``var``. @@ -606,7 +607,8 @@ def decode_factor(factor): return Factorization([(result_numerator, 1)] + list((f, -1) for f in other_factors) + list((f, -1) for f in result_factors_denominator), - sort=False, simplify=False) + sort=Factorization_sort, + simplify=Factorization_simplify) def _Omega_(a, decoded_factors): @@ -697,5 +699,7 @@ def inequalities_coeffs(inequalities): def generating_function_of_polyhedron(polyhedron, indices=None): GF = preparation_generating_function_of_polyhedron(polyhedron, indices) while repr(GF.universe().gen()).startswith('lambda'): - GF = Omega(GF.universe().gen(), GF) + GF = Omega(GF.universe().gen(), GF, + Factorization_sort=False, + Factorization_simplify=False) return GF From cc6c1a227074c422cdd5d0a3f05ce6735e785076 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 24 Nov 2016 18:17:12 +0100 Subject: [PATCH 064/370] deal with substitution bug int(1)**int(-1) is a float :( --- omega.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/omega.py b/omega.py index fcf26328447..faf97a6d1ae 100644 --- a/omega.py +++ b/omega.py @@ -518,6 +518,7 @@ def Omega(var, expression, denominator=None, op=operator.ge, """ from sage.arith.misc import factor from sage.misc.misc_c import prod + from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing from sage.structure.factorization import Factorization @@ -556,7 +557,7 @@ def Omega(var, expression, denominator=None, op=operator.ge, except (TypeError, ValueError): return Factorization([(numerator, 1)]) else: - return Factorization([(numerator.subs({var: 1}), 1)]) + return Factorization([(numerator.subs({var: ZZ(1)}), 1)]) if not isinstance(var, str) and \ len(var.parent().gens()) == 1 and var.parent().gen() == var: From 1344401fa4a465b315aed0c3c4b34d29a1b8a802 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 24 Nov 2016 18:17:46 +0100 Subject: [PATCH 065/370] deal with factors not containing variable at all --- omega.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/omega.py b/omega.py index faf97a6d1ae..3ebb8fce15d 100644 --- a/omega.py +++ b/omega.py @@ -510,6 +510,8 @@ def Omega(var, expression, denominator=None, op=operator.ge, sage: Omega(mu, Factorization([(mu, -1), (1 - x*mu, -1), ....: (1 - y/mu, -2)], unit=2)) 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 + sage: Omega(mu, Factorization([(mu, -1), (1 - x, -1)])) + 1 * (-x + 1)^-1 :: @@ -594,6 +596,11 @@ def decode_factor(factor): return -coefficient, exponent decoded_factors = tuple(decode_factor(factor) for factor in factors_denominator) + if not decoded_factors: + return Factorization([(numerator.subs({var: ZZ(1)}), 1)] + + list((f, -1) for f in other_factors), + sort=Factorization_sort, + simplify=Factorization_simplify) result_numerator = 0 result_factors_denominator = None From a5102f0a922c869922bb869e4fe154b8127e80be Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 25 Nov 2016 09:14:08 +0100 Subject: [PATCH 066/370] rename xy_vars --> xy --- omega.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/omega.py b/omega.py index 3ebb8fce15d..d785e32a55b 100644 --- a/omega.py +++ b/omega.py @@ -193,15 +193,15 @@ def P(n): assert r == 0 return q - XY, xy_vars = _laurent_polynomial_ring_(n, m) + XY, xy = _laurent_polynomial_ring_(n, m) if m == 0: return XY(1 - (prod(prod(f) for f in Omega_factors_denominator(n, m)) * - sum(HomogenousSymmetricFunction(j, xy_vars) + sum(HomogenousSymmetricFunction(j, xy) for j in srange(-a)) if a < 0 else 0)) elif n == 0: - return XY(sum(HomogenousSymmetricFunction(j, xy_vars) + return XY(sum(HomogenousSymmetricFunction(j, xy) for j in srange(a+1))) else: return XY(P(n)) From 48d7c9bdc49e3f1d2ca38cc133f7e1df5f239b7f Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 25 Nov 2016 10:43:43 +0100 Subject: [PATCH 067/370] use new quo_rem of multivariate laurent polynomial --- omega.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/omega.py b/omega.py index d785e32a55b..cf7bca931d1 100644 --- a/omega.py +++ b/omega.py @@ -163,18 +163,13 @@ def Omega_numerator(a, n, m): from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - if m == 0: - Y = ZZ - y = tuple() - else: - Y = LaurentPolynomialRing( - ZZ, ', '.join('y{}'.format(mm) for mm in range(m))) - y = Y.gens() + XY, xy = _laurent_polynomial_ring_(n, m) + x = xy[:n] + y = xy[n:] def P(n): if n == 1: - L = LaurentPolynomialRing(Y, 'x0') - x0 = L.gen() + x0 = x[0] return x0**(-a) + \ (prod(1 - x0*yy for yy in y) * sum(HomogenousSymmetricFunction(j, y) * (1-x0**(j-a)) @@ -182,19 +177,15 @@ def P(n): if a > 0 else 0) else: Pprev = P(n-1) - L = LaurentPolynomialRing(Pprev.parent(), 'x{}'.format(n-1)) - x1 = L.gen() - x2 = Pprev.parent().gen() - p1 = L(Pprev.subs({x2: x1})) - p2 = L(Pprev) - x2 = L({0: x2}) + x1 = x[n-1] + x2 = x[n-2] + p1 = Pprev.subs({x2: x1}) + p2 = Pprev q, r = (x1 * (1-x2) * prod(1 - x2*yy for yy in y) * p1 - \ x2 * (1-x1) * prod(1 - x1*yy for yy in y) * p2).quo_rem(x1 - x2) assert r == 0 return q - XY, xy = _laurent_polynomial_ring_(n, m) - if m == 0: return XY(1 - (prod(prod(f) for f in Omega_factors_denominator(n, m)) * sum(HomogenousSymmetricFunction(j, xy) From 97d27ac3dc0e12e9bcbceb9c3b1e02584362de0d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 25 Nov 2016 15:34:37 +0100 Subject: [PATCH 068/370] rewrite so that Omega-helper return x instead of 1-x in the denominators --- omega.py | 58 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/omega.py b/omega.py index cf7bca931d1..e400c28261d 100644 --- a/omega.py +++ b/omega.py @@ -299,27 +299,25 @@ def Omega_higher(a, exponents): EXAMPLES:: sage: Omega_higher(0, (1, -2)) - (1, (-z0 + 1, -z0^2*z1 + 1)) + (1, (z0, z0^2*z1)) sage: Omega_higher(0, (1, -3)) - (1, (-z0 + 1, -z0^3*z1 + 1)) + (1, (z0, z0^3*z1)) sage: Omega_higher(0, (1, -4)) - (1, (-z0 + 1, -z0^4*z1 + 1)) + (1, (z0, z0^4*z1)) sage: Omega_higher(0, (2, -1)) - (z0*z1 + 1, (-z0 + 1, -z0*z1^2 + 1)) + (z0*z1 + 1, (z0, z0*z1^2)) sage: Omega_higher(0, (3, -1)) - (z0*z1^2 + z0*z1 + 1, (-z0 + 1, -z0*z1^3 + 1)) + (z0*z1^2 + z0*z1 + 1, (z0, z0*z1^3)) sage: Omega_higher(0, (4, -1)) - (z0*z1^3 + z0*z1^2 + z0*z1 + 1, (-z0 + 1, -z0*z1^4 + 1)) + (z0*z1^3 + z0*z1^2 + z0*z1 + 1, (z0, z0*z1^4)) sage: Omega_higher(0, (1, 1, -2)) - (-z0^2*z1*z2 - z0*z1^2*z2 + z0*z1*z2 + 1, - (-z0 + 1, -z1 + 1, -z0^2*z2 + 1, -z1^2*z2 + 1)) + (-z0^2*z1*z2 - z0*z1^2*z2 + z0*z1*z2 + 1, (z0, z1, z0^2*z2, z1^2*z2)) sage: Omega_higher(0, (2, -1, -1)) - (z0*z1*z2 + z0*z1 + z0*z2 + 1, (-z0 + 1, -z0*z1^2 + 1, -z0*z2^2 + 1)) + (z0*z1*z2 + z0*z1 + z0*z2 + 1, (z0, z0*z1^2, z0*z2^2)) sage: Omega_higher(0, (2, 1, -1)) - (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, - (-z0 + 1, -z1 + 1, -z0*z2^2 + 1, -z1*z2 + 1)) + (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, (z0, z1, z0*z2^2, z1*z2)) """ from sage.misc.functional import cyclotomic_polynomial from sage.misc.misc_c import prod @@ -376,7 +374,7 @@ def de_power(expression): rules = {next(x_vars) if e > 0 else next(y_vars): powers[abs(e)]**j * var for e, var in zip(exponents, L.gens()) for j in range(abs(e))} - factors_denominator = tuple(de_power(prod(f.subs(rules) for f in factors)) + factors_denominator = tuple(1-de_power(prod(f.subs(rules) for f in factors)) for factors in Omega_factors_denominator(x, y)) numerator = de_power(Omega_numerator(a, n, m).subs(rules)) @@ -593,31 +591,25 @@ def decode_factor(factor): sort=Factorization_sort, simplify=Factorization_simplify) - result_numerator = 0 - result_factors_denominator = None - for a, c in iteritems(numerator.dict()): - n, fd = _Omega_(a, decoded_factors) - if result_factors_denominator is None: - result_factors_denominator = fd - else: - assert result_factors_denominator == fd - result_numerator += c * n + result_numerator, result_factors_denominator = \ + _Omega_(numerator.dict(), decoded_factors) return Factorization([(result_numerator, 1)] + list((f, -1) for f in other_factors) + - list((f, -1) for f in result_factors_denominator), + list((1-f, -1) for f in result_factors_denominator), sort=Factorization_sort, simplify=Factorization_simplify) -def _Omega_(a, decoded_factors): +def _Omega_(A, decoded_factors): r""" Helper function for :func:`Omega` which accesses the low level functions and does the substituting. INPUT: - - ``a`` -- an integer. + - ``A`` -- a dictionary mapping `a` to `c` representing a summand + `c\lambda^a` of the numerator. - ``decoded_factors`` -- a tuple or list of pairs `(z, e)` representing a factor `1 - \lambda^e z`. @@ -632,9 +624,21 @@ def _Omega_(a, decoded_factors): # (in contrast to directly in Omega_higher) results in much cleaner # code and prevents an additional substitution or passing of a permutation. values, exponents = zip(*sorted(decoded_factors, key=lambda k: -k[1])) - n, fd = Omega_higher(a, exponents) - rules = dict(zip(n.parent().gens(), values)) - return n.subs(rules), tuple(f.subs(rules) for f in fd) + + numerator = 0 + factors_denominator = None + rules = None + for a, c in iteritems(A): + n, fd = Omega_higher(a, exponents) + if factors_denominator is None: + factors_denominator = fd + else: + assert factors_denominator == fd + if rules is None: + rules = dict(zip(n.parent().gens(), values)) + numerator += c * n.subs(rules) + + return numerator, tuple(f.subs(rules) for f in factors_denominator) def preparation_generating_function_of_polyhedron(polyhedron, indices=None): From 5a7b4d368d885084db44a5e54d2198b889fe5d31 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 25 Nov 2016 15:57:41 +0100 Subject: [PATCH 069/370] major rewrite of generating function of polyhedron --- omega.py | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/omega.py b/omega.py index e400c28261d..5d5cac2114f 100644 --- a/omega.py +++ b/omega.py @@ -641,13 +641,19 @@ def _Omega_(A, decoded_factors): return numerator, tuple(f.subs(rules) for f in factors_denominator) -def preparation_generating_function_of_polyhedron(polyhedron, indices=None): +def generating_function_of_polyhedron(polyhedron, indices=None): from sage.geometry.polyhedron.representation import Hrepresentation from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing from sage.structure.factorization import Factorization + try: + if polyhedron.is_empty(): + return Factorization([], unit=0) + except AttributeError: + pass + def inequalities_coeffs(inequalities): for entry in inequalities: if isinstance(entry, (tuple, list)): @@ -685,24 +691,46 @@ def inequalities_coeffs(inequalities): raise ValueError('Not all coefficient vectors of the inequalities ' 'have the same length.') - factors = [] + def is_unit_vector(it): + found = 0 + for e in it: + if e != 0: + if e != 1: + return False + else: + found += 1 + if found >= 2: + return False + return True + + numerator = B(1) terms = B.gens() L = B for i, coeffs in enumerate(inequalities): + if is_unit_vector(coeffs): + continue L = LaurentPolynomialRing(L, 'lambda{}'.format(i), sparse=True) l = L.gen() it_coeffs = iter(coeffs) - factors.append((l, next(it_coeffs))) + numerator *= l**next(it_coeffs) + assert numerator.parent() == L terms = tuple(l**c * t for c, t in zip(it_coeffs, terms)) - return Factorization(factors + list((1-t, -1) for t in terms), + def decode_factor(factor): + D = factor.dict() + assert len(D) == 1 + exponent, coefficient = next(iteritems(D)) + return coefficient, exponent + + while repr(numerator.parent().gen()).startswith('lambda'): + decoded_factors, other_factors = \ + partition((decode_factor(factor) for factor in terms), + lambda factor: factor[1] == 0) + other_factors = tuple(factor[0] for factor in other_factors) + numerator, factors_denominator = \ + _Omega_(numerator.dict(), tuple(decoded_factors)) + terms = other_factors + factors_denominator + + return Factorization([(numerator, 1)] + + list((1-t, -1) for t in terms), sort=False, simplify=False) - - -def generating_function_of_polyhedron(polyhedron, indices=None): - GF = preparation_generating_function_of_polyhedron(polyhedron, indices) - while repr(GF.universe().gen()).startswith('lambda'): - GF = Omega(GF.universe().gen(), GF, - Factorization_sort=False, - Factorization_simplify=False) - return GF From 42362c2b01c2809c57aff30416f1a5d7b93d846a Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 25 Nov 2016 15:58:09 +0100 Subject: [PATCH 070/370] doctests for gf (quicksort polyhedrons) --- omega.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/omega.py b/omega.py index 5d5cac2114f..432e91b9ee5 100644 --- a/omega.py +++ b/omega.py @@ -642,7 +642,62 @@ def _Omega_(A, decoded_factors): def generating_function_of_polyhedron(polyhedron, indices=None): + r""" + Return the generating function of the integer points of + the polyhedron's orthant with only nonnegative coordinates. + + EXAMPLES:: + + sage: P2 = ( + ....: Polyhedron(ieqs=[(0, 0, 0, 1), (0, 0, 1, 0), (0, 1, 0, -1)]), + ....: Polyhedron(ieqs=[(0, -1, 0, 1), (0, 1, 0, 0), (0, 0, 1, 0)])) + sage: generating_function_of_polyhedron(P2[0]) + 1 * (-y1 + 1)^-1 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 + sage: generating_function_of_polyhedron(P2[1]) + 1 * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 + sage: generating_function_of_polyhedron(P2[0] & P2[1]) + 1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 + :: + + sage: P3 = ( + ....: Polyhedron( + ....: ieqs=[(0, 0, 0, 0, 1), (0, 0, 0, 1, 0), + ....: (0, 0, 1, 0, -1), (-1, 1, 0, -1, -1)]), + ....: Polyhedron( + ....: ieqs=[(0, 0, -1, 0, 1), (0, 1, 0, 0, -1), + ....: (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), (-1, 1, -1, -1, 0)]), + ....: Polyhedron( + ....: ieqs=[(1, -1, 0, 1, 1), (1, -1, 1, 1, 0), + ....: (0, 0, 0, 0, 1), (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), + ....: (1, 0, 1, 1, -1), (0, 1, 0, 0, 0), (1, 1, 1, 0, -1)]), + ....: Polyhedron( + ....: ieqs=[(0, 1, 0, -1, 0), (0, -1, 0, 0, 1), + ....: (-1, 0, -1, -1, 1), (0, 0, 1, 0, 0), (0, 0, 0, 1, 0)]), + ....: Polyhedron( + ....: ieqs=[(0, 1, 0, 0, 0), (0, 0, 1, 0, 0), + ....: (-1, -1, -1, 0, 1), (0, -1, 0, 1, 0)])) + sage: def intersect(I): + ....: I = iter(I) + ....: result = next(I) + ....: for i in I: + ....: result &= i + ....: return result + sage: for J in subsets(range(len(P3))): # TODO: check more results + ....: if not J: + ....: continue + ....: P = intersect([P3[j] for j in J]) + ....: print('{}: {}'.format(J, P.inequalities())) + ....: print(generating_function_of_polyhedron(P)) + [0]: (An inequality (0, 0, 0, 1) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, -1) x + 0 >= 0, + An inequality (1, 0, -1, -1) x - 1 >= 0) + y0 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + ... + [0, 1, 2, 3, 4]: () + 0 + """ from sage.geometry.polyhedron.representation import Hrepresentation from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing From 546f67e6731e1dabea7f24e328dcbe6fdddd38a5 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 25 Nov 2016 16:10:59 +0100 Subject: [PATCH 071/370] minor rewrite of docstring to adapt to previous changes --- omega.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/omega.py b/omega.py index 432e91b9ee5..17a726d92e5 100644 --- a/omega.py +++ b/omega.py @@ -294,7 +294,8 @@ def Omega_higher(a, exponents): A pair representing a quotient as follows: Its first component is the numerator as a laurent polynomial, its second component a factorization - of the denominator as a tuple of laurent polynomials. + of the denominator as a tuple of laurent polynomials, where each + laurent polynomial `z` represents a factor `1 - z`. EXAMPLES:: @@ -612,13 +613,14 @@ def _Omega_(A, decoded_factors): `c\lambda^a` of the numerator. - ``decoded_factors`` -- a tuple or list of pairs `(z, e)` representing - a factor `1 - \lambda^e z`. + a factor `1 - z \lambda^e`. OUTPUT: A pair representing a quotient as follows: Its first component is the numerator as a laurent polynomial, its second component a factorization - of the denominator as a tuple of laurent polynomials. + of the denominator as a tuple of laurent polynomials, where each + laurent polynomial `z` represents a factor `1 - z`. """ # Below we sort to make the caching more efficient. Doing this here # (in contrast to directly in Omega_higher) results in much cleaner From e70d8be5078f657003da78d27d1a87758a35090f Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 25 Nov 2016 16:15:20 +0100 Subject: [PATCH 072/370] _Omega_: deal with empty factorization --- omega.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/omega.py b/omega.py index 17a726d92e5..c5fc858916c 100644 --- a/omega.py +++ b/omega.py @@ -621,7 +621,22 @@ def _Omega_(A, decoded_factors): numerator as a laurent polynomial, its second component a factorization of the denominator as a tuple of laurent polynomials, where each laurent polynomial `z` represents a factor `1 - z`. + + TESTS: + + Extensive testing of this function is done in :func:`Omega`. + + :: + + sage: _Omega_({0: 2, 1: 40, -1: -3}, []) + (42, ()) + sage: _Omega_({-1: 42}, []) + (0, ()) + """ + if not decoded_factors: + return sum(c for a, c in iteritems(A) if a >= 0), tuple() + # Below we sort to make the caching more efficient. Doing this here # (in contrast to directly in Omega_higher) results in much cleaner # code and prevents an additional substitution or passing of a permutation. From 52173b5ae9e5cc66ee426c71be977618b2606349 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 25 Nov 2016 16:23:36 +0100 Subject: [PATCH 073/370] Omega: simplify code (subs in numerator) --- omega.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/omega.py b/omega.py index c5fc858916c..0a2439d9164 100644 --- a/omega.py +++ b/omega.py @@ -491,6 +491,8 @@ def Omega(var, expression, denominator=None, op=operator.ge, 0 sage: Omega(mu, 2, []) 2 + sage: Omega(mu, 2*mu, []) + 2 :: @@ -501,7 +503,7 @@ def Omega(var, expression, denominator=None, op=operator.ge, ....: (1 - y/mu, -2)], unit=2)) 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 sage: Omega(mu, Factorization([(mu, -1), (1 - x, -1)])) - 1 * (-x + 1)^-1 + 0 :: @@ -586,14 +588,11 @@ def decode_factor(factor): return -coefficient, exponent decoded_factors = tuple(decode_factor(factor) for factor in factors_denominator) - if not decoded_factors: - return Factorization([(numerator.subs({var: ZZ(1)}), 1)] + - list((f, -1) for f in other_factors), - sort=Factorization_sort, - simplify=Factorization_simplify) result_numerator, result_factors_denominator = \ _Omega_(numerator.dict(), decoded_factors) + if result_numerator == 0: + return Factorization([], unit=result_numerator) return Factorization([(result_numerator, 1)] + list((f, -1) for f in other_factors) + From b9288f700d6ff3e2ea571f9cffa3d24a37fb2d2a Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 25 Nov 2016 16:56:25 +0100 Subject: [PATCH 074/370] Omega: simpify code (creation of laurent polynomial ring) --- omega.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/omega.py b/omega.py index 0a2439d9164..76a53c28611 100644 --- a/omega.py +++ b/omega.py @@ -493,6 +493,8 @@ def Omega(var, expression, denominator=None, op=operator.ge, 2 sage: Omega(mu, 2*mu, []) 2 + sage: Omega(mu, 2/mu, []) + 0 :: @@ -514,6 +516,7 @@ def Omega(var, expression, denominator=None, op=operator.ge, from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing_univariate from sage.structure.factorization import Factorization if op != operator.ge: @@ -530,7 +533,7 @@ def Omega(var, expression, denominator=None, op=operator.ge, denominator = expression.denominator() else: numerator = expression - + # at this point we have numerator/denominator if isinstance(denominator, (list, tuple)): factors_denominator = denominator @@ -544,26 +547,20 @@ def Omega(var, expression, denominator=None, op=operator.ge, factors_denominator = tuple(factor for factor, exponent in denominator for _ in range(exponent)) + # at this point we have numerator/factors_denominator - if not factors_denominator: - try: - var = numerator.parent()(var) - except (TypeError, ValueError): - return Factorization([(numerator, 1)]) - else: - return Factorization([(numerator.subs({var: ZZ(1)}), 1)]) - - if not isinstance(var, str) and \ - len(var.parent().gens()) == 1 and var.parent().gen() == var: - L = var.parent() + P = var.parent() + if isinstance(P, LaurentPolynomialRing_univariate) and P.gen() == var: + L = P L0 = L.base_ring() - else: - R = factors_denominator[0].parent() + elif var in P.gens(): var = repr(var) L0 = LaurentPolynomialRing( - R.base_ring(), tuple(v for v in R.variable_names() if v != var)) + P.base_ring(), tuple(v for v in P.variable_names() if v != var)) L = LaurentPolynomialRing(L0, var) - var = L.gen() + var = L.gen() + else: + raise ValueError('{} is not a variable.'.format(var)) numerator = L(numerator) if numerator == 0: From baa05700db602667e5fcf54934fd2f42946fcb41 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 25 Nov 2016 17:16:50 +0100 Subject: [PATCH 075/370] Omega: simplify code (decoding of factors) --- omega.py | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/omega.py b/omega.py index 76a53c28611..9a80e7f1f43 100644 --- a/omega.py +++ b/omega.py @@ -506,6 +506,8 @@ def Omega(var, expression, denominator=None, op=operator.ge, 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 sage: Omega(mu, Factorization([(mu, -1), (1 - x, -1)])) 0 + sage: Omega(mu, Factorization([(2, -1)])) + 1 * 2^-1 :: @@ -562,29 +564,29 @@ def Omega(var, expression, denominator=None, op=operator.ge, else: raise ValueError('{} is not a variable.'.format(var)) - numerator = L(numerator) - if numerator == 0: - return Factorization([], unit=numerator) - factors_denominator = tuple(L(factor) for factor in factors_denominator) - factors_denominator, to_numerator = partition( - factors_denominator, - lambda factor: factor.variables() == (var,) and factor.number_of_terms() == 1) - numerator /= prod(to_numerator) - - factors_denominator, other_factors = partition( - factors_denominator, - lambda factor: var not in factor.variables()) - other_factors = tuple(other_factors) - other_factors = tuple(L0(f) for f in other_factors) - def decode_factor(factor): + other_factors = [] + to_numerator = [] + decoded_factors = [] + for factor in factors_denominator: + factor = L(factor) D = factor.dict() - if len(D) != 2 or D.get(0, 0) != 1: - raise NotImplementedError('Cannot handle factor {}'.format(factor)) - D.pop(0) - exponent, coefficient = next(iteritems(D)) - return -coefficient, exponent - decoded_factors = tuple(decode_factor(factor) - for factor in factors_denominator) + if not D: + raise ZeroDivisionError('Denominator contains a factor 0.') + elif len(D) == 1: + exponent, coefficient = next(iteritems(D)) + if exponent == 0: + other_factors.append(L0(factor)) + else: + to_numerator.append(factor) + elif len(D) == 2: + if D.get(0, 0) != 1: + raise NotImplementedError('Factor {} is not normalized.'.format(factor)) + D.pop(0) + exponent, coefficient = next(iteritems(D)) + decoded_factors.append((-coefficient, exponent)) + else: + raise NotImplementedError('Cannot handle factor {}.'.format(factor)) + numerator = L(numerator) / prod(to_numerator) result_numerator, result_factors_denominator = \ _Omega_(numerator.dict(), decoded_factors) @@ -651,6 +653,8 @@ def _Omega_(A, decoded_factors): rules = dict(zip(n.parent().gens(), values)) numerator += c * n.subs(rules) + if numerator == 0: + factors_denominator = tuple() return numerator, tuple(f.subs(rules) for f in factors_denominator) From 9e92d722464c57680dc946d254a1db6bf97bb61b Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 26 Nov 2016 17:26:12 +0100 Subject: [PATCH 076/370] logging --- omega.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/omega.py b/omega.py index 9a80e7f1f43..d7fc418364b 100644 --- a/omega.py +++ b/omega.py @@ -158,6 +158,10 @@ def Omega_numerator(a, n, m): sage: Omega_numerator(-2, 0, 1) 0 """ + import logging + logger = logging.getLogger(__name__) + logger.info('Omega_numerator: a=%s, n=%s, m=%s', a, n, m) + from sage.arith.srange import srange from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ @@ -170,7 +174,7 @@ def Omega_numerator(a, n, m): def P(n): if n == 1: x0 = x[0] - return x0**(-a) + \ + result = x0**(-a) + \ (prod(1 - x0*yy for yy in y) * sum(HomogenousSymmetricFunction(j, y) * (1-x0**(j-a)) for j in srange(a)) @@ -179,12 +183,18 @@ def P(n): Pprev = P(n-1) x1 = x[n-1] x2 = x[n-2] + logger.debug('Omega_numerator: P(%s): substituting...', n) p1 = Pprev.subs({x2: x1}) p2 = Pprev - q, r = (x1 * (1-x2) * prod(1 - x2*yy for yy in y) * p1 - \ - x2 * (1-x1) * prod(1 - x1*yy for yy in y) * p2).quo_rem(x1 - x2) + logger.debug('Omega_numerator: P(%s): preparing...', n) + dividend = x1 * (1-x2) * prod(1 - x2*yy for yy in y) * p1 - \ + x2 * (1-x1) * prod(1 - x1*yy for yy in y) * p2 + logger.debug('Omega_numerator: P(%s): dividing...', n) + q, r = dividend.quo_rem(x1 - x2) assert r == 0 - return q + result = q + logger.debug('Omega_numerator: P(%s) has %s terms', n, result.number_of_terms()) + return result if m == 0: return XY(1 - (prod(prod(f) for f in Omega_factors_denominator(n, m)) * @@ -320,6 +330,10 @@ def Omega_higher(a, exponents): sage: Omega_higher(0, (2, 1, -1)) (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, (z0, z1, z0*z2^2, z1*z2)) """ + import logging + logger = logging.getLogger(__name__) + logger.info('Omega_higher: a=%s, exponents=%s', a, exponents) + from sage.misc.functional import cyclotomic_polynomial from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ @@ -375,11 +389,14 @@ def de_power(expression): rules = {next(x_vars) if e > 0 else next(y_vars): powers[abs(e)]**j * var for e, var in zip(exponents, L.gens()) for j in range(abs(e))} + logger.debug('Omega_higher: preparing denominator') factors_denominator = tuple(1-de_power(prod(f.subs(rules) for f in factors)) for factors in Omega_factors_denominator(x, y)) + logger.debug('Omega_higher: preparing numerator') numerator = de_power(Omega_numerator(a, n, m).subs(rules)) + logger.info('Omega_higher: completed') return numerator, factors_denominator From 0bd40fc033ff7eae035f38c51870d1c71ec89011 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 26 Nov 2016 21:04:06 +0100 Subject: [PATCH 077/370] fix bug due to changes in LaurentPolynomial_mpair.subs --- omega.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/omega.py b/omega.py index d7fc418364b..df74a3a21ad 100644 --- a/omega.py +++ b/omega.py @@ -377,11 +377,12 @@ def subs_e(e): Z = L.change_ring(ZZ) def de_power(expression): + expression = Z(expression) for e, var in zip(exponents, L.gens()): if abs(e) == 1: continue expression = subs_power(expression, var, abs(e)) - return Z(expression) + return expression xy_vars = _laurent_polynomial_ring_(n, m)[1] x_vars = iter(xy_vars[:n]) From 4cebd7b246f20e9e8ec74a41ae3312606a96ab40 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 26 Nov 2016 21:04:17 +0100 Subject: [PATCH 078/370] tiny efficiency improvment --- omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omega.py b/omega.py index df74a3a21ad..c5ddb35a861 100644 --- a/omega.py +++ b/omega.py @@ -391,7 +391,7 @@ def de_power(expression): powers[abs(e)]**j * var for e, var in zip(exponents, L.gens()) for j in range(abs(e))} logger.debug('Omega_higher: preparing denominator') - factors_denominator = tuple(1-de_power(prod(f.subs(rules) for f in factors)) + factors_denominator = tuple(de_power(1 - prod(f.subs(rules) for f in factors)) for factors in Omega_factors_denominator(x, y)) logger.debug('Omega_higher: preparing numerator') From d19bb90cfb53139333fbb96a6c1387b9a663ff2c Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 28 Nov 2016 18:57:14 +0100 Subject: [PATCH 079/370] move P-function out to module-level --- omega.py | 57 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/omega.py b/omega.py index c5ddb35a861..f62d03bce4b 100644 --- a/omega.py +++ b/omega.py @@ -80,6 +80,36 @@ def _laurent_polynomial_ring_(n, m): return L, L.gens() +def Omega_numerator_P(a, x, y): + import logging + logger = logging.getLogger(__name__) + + n = len(x) + if n == 1: + x0 = x[0] + result = x0**(-a) + \ + (prod(1 - x0*yy for yy in y) * + sum(HomogenousSymmetricFunction(j, y) * (1-x0**(j-a)) + for j in srange(a)) + if a > 0 else 0) + else: + Pprev = Omega_numerator_P(a, x[:n-1], y) + x1 = x[n-1] + x2 = x[n-2] + logger.debug('Omega_numerator: P(%s): substituting...', n) + p1 = Pprev.subs({x2: x1}) + p2 = Pprev + logger.debug('Omega_numerator: P(%s): preparing...', n) + dividend = x1 * (1-x2) * prod(1 - x2*yy for yy in y) * p1 - \ + x2 * (1-x1) * prod(1 - x1*yy for yy in y) * p2 + logger.debug('Omega_numerator: P(%s): dividing...', n) + q, r = dividend.quo_rem(x1 - x2) + assert r == 0 + result = q + logger.debug('Omega_numerator: P(%s) has %s terms', n, result.number_of_terms()) + return result + + @cached_function def Omega_numerator(a, n, m): r""" @@ -171,31 +201,6 @@ def Omega_numerator(a, n, m): x = xy[:n] y = xy[n:] - def P(n): - if n == 1: - x0 = x[0] - result = x0**(-a) + \ - (prod(1 - x0*yy for yy in y) * - sum(HomogenousSymmetricFunction(j, y) * (1-x0**(j-a)) - for j in srange(a)) - if a > 0 else 0) - else: - Pprev = P(n-1) - x1 = x[n-1] - x2 = x[n-2] - logger.debug('Omega_numerator: P(%s): substituting...', n) - p1 = Pprev.subs({x2: x1}) - p2 = Pprev - logger.debug('Omega_numerator: P(%s): preparing...', n) - dividend = x1 * (1-x2) * prod(1 - x2*yy for yy in y) * p1 - \ - x2 * (1-x1) * prod(1 - x1*yy for yy in y) * p2 - logger.debug('Omega_numerator: P(%s): dividing...', n) - q, r = dividend.quo_rem(x1 - x2) - assert r == 0 - result = q - logger.debug('Omega_numerator: P(%s) has %s terms', n, result.number_of_terms()) - return result - if m == 0: return XY(1 - (prod(prod(f) for f in Omega_factors_denominator(n, m)) * sum(HomogenousSymmetricFunction(j, xy) @@ -205,7 +210,7 @@ def P(n): return XY(sum(HomogenousSymmetricFunction(j, xy) for j in srange(a+1))) else: - return XY(P(n)) + return XY(Omega_numerator_P(a, x, y)) @cached_function From 462819db1e77bc629b00f0a4e2c748af0ab5e5a9 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 29 Nov 2016 08:28:18 +0100 Subject: [PATCH 080/370] add one extensive doctest --- omega.py | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 1 deletion(-) diff --git a/omega.py b/omega.py index f62d03bce4b..fad665bdb1a 100644 --- a/omega.py +++ b/omega.py @@ -734,7 +734,155 @@ def generating_function_of_polyhedron(polyhedron, indices=None): An inequality (0, 1, 0, -1) x + 0 >= 0, An inequality (1, 0, -1, -1) x - 1 >= 0) y0 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - ... + [1]: (An inequality (0, -1, 0, 1) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, -1, -1, 0) x - 1 >= 0, + An inequality (1, 0, 0, -1) x + 0 >= 0) + (-y0^6*y1^2*y2^2*y3^3 - y0^6*y1^2*y2*y3^3 + y0^5*y1^2*y2*y3^3 + + y0^5*y1^2*y2*y3^2 + y0^4*y1*y2^2*y3^2 + 2*y0^4*y1*y2*y3^2 + + y0^4*y1*y3^2 - y0^3*y1*y2*y3^2 - y0^3*y1*y2*y3 - y0^3*y1*y3^2 - + y0^3*y1*y3 - y0^2*y2*y3 - y0^2*y3 + y0*y3 + y0) * + (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * + (-y0*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 * + (-y0^2*y1*y3 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 + [0, 1]: (An inequality (1, -1, -1, 0) x - 1 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0) + y0 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [2]: (An inequality (-1, 0, 1, 1) x + 1 >= 0, + An inequality (-1, 1, 1, 0) x + 1 >= 0, + An inequality (0, 0, 0, 1) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (0, 1, 1, -1) x + 1 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0, + An inequality (1, 1, 0, -1) x + 1 >= 0) + (y0^7*y1^6*y2^3*y3^5 + y0^7*y1^5*y2^4*y3^4 + y0^6*y1^7*y2^2*y3^5 - + y0^7*y1^5*y2^3*y3^4 + y0^6*y1^6*y2^3*y3^4 - y0^6*y1^6*y2^2*y3^5 - + 2*y0^6*y1^6*y2^2*y3^4 - 3*y0^6*y1^5*y2^3*y3^4 - y0^6*y1^5*y2^2*y3^5 - + y0^6*y1^5*y2^3*y3^3 - y0^6*y1^4*y2^4*y3^3 + y0^6*y1^5*y2^2*y3^4 - + 2*y0^5*y1^6*y2^2*y3^4 - 2*y0^6*y1^4*y2^3*y3^4 - y0^5*y1^6*y2*y3^5 + + y0^6*y1^5*y2^2*y3^3 + y0^6*y1^4*y2^3*y3^3 - y0^5*y1^5*y2^3*y3^3 - + y0^6*y1^3*y2^4*y3^3 + y0^6*y1^4*y2^2*y3^4 - y0^5*y1^5*y2^2*y3^4 + + y0^5*y1^5*y2*y3^5 + 3*y0^5*y1^5*y2^2*y3^3 + y0^6*y1^3*y2^3*y3^3 + + 2*y0^5*y1^5*y2*y3^4 - y0^4*y1^6*y2*y3^4 + 4*y0^5*y1^4*y2^2*y3^4 + + y0^5*y1^4*y2^3*y3^2 + 3*y0^5*y1^4*y2^2*y3^3 + 4*y0^5*y1^3*y2^3*y3^3 - + y0^5*y1^4*y2*y3^4 + 3*y0^4*y1^5*y2*y3^4 + y0^5*y1^3*y2^2*y3^4 - + y0^5*y1^4*y2^2*y3^2 + y0^5*y1^3*y2^3*y3^2 + y0^5*y1^2*y2^4*y3^2 - + y0^5*y1^4*y2*y3^3 + 2*y0^4*y1^5*y2*y3^3 - 2*y0^5*y1^3*y2^2*y3^3 + + 5*y0^4*y1^4*y2^2*y3^3 + y0^5*y1^2*y2^3*y3^3 - y0^5*y1^3*y2^2*y3^2 - + y0^5*y1^2*y2^3*y3^2 + 2*y0^4*y1^3*y2^3*y3^2 - 4*y0^4*y1^4*y2*y3^3 + + 2*y0^3*y1^5*y2*y3^3 - y0^5*y1^2*y2^2*y3^3 - y0^4*y1^3*y2^2*y3^3 + + y0^3*y1^5*y3^4 - y0^4*y1^3*y2*y3^4 - y0^4*y1^4*y2*y3^2 - + 5*y0^4*y1^3*y2^2*y3^2 + y0^3*y1^4*y2^2*y3^2 - y0^4*y1^2*y2^3*y3^2 - + 2*y0^4*y1^3*y2*y3^3 - y0^3*y1^4*y2*y3^3 - 3*y0^4*y1^2*y2^2*y3^3 - + y0^3*y1^4*y3^4 - y0^4*y1^2*y2^3*y3 + y0^4*y1^3*y2*y3^2 - + 3*y0^3*y1^4*y2*y3^2 - y0^4*y1^2*y2^2*y3^2 - 2*y0^3*y1^3*y2^2*y3^2 - + y0^4*y1*y2^3*y3^2 - 2*y0^3*y1^4*y3^3 + y0^4*y1^2*y2*y3^3 - + 5*y0^3*y1^3*y2*y3^3 + y0^4*y1^2*y2^2*y3 - y0^3*y1^3*y2^2*y3 + + y0^4*y1^2*y2*y3^2 - y0^3*y1^3*y2*y3^2 - y0^2*y1^4*y2*y3^2 + + y0^4*y1*y2^2*y3^2 - 4*y0^3*y1^2*y2^2*y3^2 + y0^3*y1^3*y3^3 - + 2*y0^2*y1^4*y3^3 + y0^3*y1^2*y2*y3^3 + y0^3*y1^3*y2*y3 - + y0^3*y1*y2^3*y3 + y0^3*y1^3*y3^2 + 5*y0^3*y1^2*y2*y3^2 - + 2*y0^2*y1^3*y2*y3^2 + y0^3*y1*y2^2*y3^2 + y0^2*y1^3*y3^3 + + y0^3*y1^2*y2*y3 + y0^2*y1^3*y2*y3 + 2*y0^3*y1*y2^2*y3 - + y0^2*y1^2*y2^2*y3 + 3*y0^2*y1^3*y3^2 + 4*y0^2*y1^2*y2*y3^2 + + y0^2*y1^2*y3^3 - y0^3*y1*y2*y3 + 4*y0^2*y1^2*y2*y3 + + 2*y0^2*y1*y2^2*y3 + y0^2*y1^2*y3^2 + y0*y1^3*y3^2 + + 2*y0^2*y1*y2*y3^2 + y0^2*y1*y2^2 - y0^2*y1^2*y3 - y0^2*y1*y2*y3 + + y0*y1^2*y2*y3 + y0^2*y2^2*y3 - y0^2*y1*y3^2 + y0*y1^2*y3^2 - + y0^2*y1*y2 - y0^2*y1*y3 - y0*y1^2*y3 - y0^2*y2*y3 - 2*y0*y1*y3^2 - + y0*y1*y2 - 3*y0*y1*y3 - 2*y0*y2*y3 - + y0*y2 + y0*y3 - y1*y3 + y0 + y3 + 1) * + (-y0*y1*y3 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * + (-y0*y2 + 1)^-1 * (-y0*y2*y3 + 1)^-1 * (-y1*y3 + 1)^-1 * + (-y2 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 * + (-y0*y1^2*y3 + 1)^-1 * (-y0*y1*y2 + 1)^-1 + [0, 2]: (An inequality (-1, 1, 1, 0) x + 1 >= 0, + An inequality (1, 0, -1, 0) x - 1 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0) + y0 * (-y0*y2 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [1, 2]: (An inequality (0, -1, 0, 1) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, 0, -1) x + 0 >= 0, + An inequality (1, -1, 0, 0) x - 1 >= 0) + (y0^4*y1*y2^2*y3^2 - y0^3*y1*y2*y3^2 - y0^3*y1*y2*y3 - + y0^2*y2*y3 + y0*y3 + y0) * + (-y0*y1*y3 + 1)^-1 * (-y0*y2 + 1)^-1 * + (-y0*y2*y3 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 + [0, 1, 2]: (An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, -1, 0, 0) x - 1 >= 0) + y0 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [3]: (An inequality (-1, 0, 0, 1) x + 0 >= 0, + An inequality (0, -1, -1, 1) x - 1 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, -1, 0) x + 0 >= 0) + (-y0*y1*y3^2 - y0*y3^2 + y0*y3 + y3) * + (-y0*y2*y3 + 1)^-1 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * + (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [0, 3]: () + 0 + [1, 3]: (An inequality (1, -1, -1, 0) x - 1 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0) + y0*y3 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1, 3]: () + 0 + [2, 3]: (An inequality (1, 0, -1, 0) x + 0 >= 0, + An inequality (-1, 1, 1, 0) x + 1 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0) + (y0^2*y1^2*y2*y3^4 - y0^2*y1*y2*y3^3 - y0*y1*y2*y3^3 - + y0*y1*y3^2 + y0*y3 + y3) * + (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 * + (-y0*y1*y3 + 1)^-1 * (-y0*y1*y2*y3^2 + 1)^-1 + [0, 2, 3]: () + 0 + [1, 2, 3]: (An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, -1, 0, 0) x - 1 >= 0) + y0*y3 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1, 2, 3]: () + 0 + [4]: (An inequality (-1, -1, 0, 1) x - 1 >= 0, + An inequality (-1, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0) + y3 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 4]: () + 0 + [1, 4]: () + 0 + [0, 1, 4]: () + 0 + [2, 4]: (An inequality (-1, 0, 1, 0) x + 0 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0) + y3 * (-y2 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 2, 4]: () + 0 + [1, 2, 4]: () + 0 + [0, 1, 2, 4]: () + 0 + [3, 4]: (An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (-1, -1, 0, 1) x - 1 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0) + y3 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 3, 4]: () + 0 + [1, 3, 4]: () + 0 + [0, 1, 3, 4]: () + 0 + [2, 3, 4]: (An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0) + y3 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 2, 3, 4]: () + 0 + [1, 2, 3, 4]: () + 0 [0, 1, 2, 3, 4]: () 0 """ From ef6a97035442ead75e44fa39876852e636d0270e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 29 Nov 2016 10:31:34 +0100 Subject: [PATCH 081/370] pretty_inequality --- omega.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/omega.py b/omega.py index fad665bdb1a..5eeb6608d21 100644 --- a/omega.py +++ b/omega.py @@ -681,6 +681,20 @@ def _Omega_(A, decoded_factors): return numerator, tuple(f.subs(rules) for f in factors_denominator) +def pretty_inequality(ineq, indices=None): + from sage.symbolic.ring import SR + from sage.modules.free_module_element import vector + + if indices is None: + indices = range(len(ineq)-1) + vars = vector([1] + list(SR("b{}".format(i)) for i in indices)) + v = vector(ineq) + positive_part = vector([max(c, 0) for c in v]) + negative_part = - (v - positive_part) + assert v == positive_part - negative_part + return '{} >= {}'.format(positive_part*vars, negative_part*vars) + + def generating_function_of_polyhedron(polyhedron, indices=None): r""" Return the generating function of the integer points of From 62b717a5b98da1085e3d7034dd8fb65320203d92 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 29 Nov 2016 10:32:15 +0100 Subject: [PATCH 082/370] logging in gf --- omega.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/omega.py b/omega.py index 5eeb6608d21..c8311fe9702 100644 --- a/omega.py +++ b/omega.py @@ -900,6 +900,9 @@ def generating_function_of_polyhedron(polyhedron, indices=None): [0, 1, 2, 3, 4]: () 0 """ + import logging + logger = logging.getLogger(__name__) + from sage.geometry.polyhedron.representation import Hrepresentation from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing @@ -948,6 +951,9 @@ def inequalities_coeffs(inequalities): raise ValueError('Not all coefficient vectors of the inequalities ' 'have the same length.') + logger.info('generating_function_of_polyhedron: ' + '%s inequalities', len(inequalities)) + def is_unit_vector(it): found = 0 for e in it: @@ -965,9 +971,13 @@ def is_unit_vector(it): L = B for i, coeffs in enumerate(inequalities): if is_unit_vector(coeffs): + logger.debug('generating_function_of_polyhedron: ' + 'skipping %s', pretty_inequality(coeffs)) continue L = LaurentPolynomialRing(L, 'lambda{}'.format(i), sparse=True) l = L.gen() + logger.debug('generating_function_of_polyhedron: ' + '%s --> %s', l, pretty_inequality(coeffs)) it_coeffs = iter(coeffs) numerator *= l**next(it_coeffs) assert numerator.parent() == L @@ -980,6 +990,9 @@ def decode_factor(factor): return coefficient, exponent while repr(numerator.parent().gen()).startswith('lambda'): + logger.info('generating_function_of_polyhedron: ' + 'applying Omega[%s]...', numerator.parent().gen()) + decoded_factors, other_factors = \ partition((decode_factor(factor) for factor in terms), lambda factor: factor[1] == 0) From 9da71a4c26f4508fadd02c56b54a029518751d4f Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 30 Nov 2016 09:12:25 +0100 Subject: [PATCH 083/370] adapt imports (to previous moves) --- omega.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index c8311fe9702..4a289d577a0 100644 --- a/omega.py +++ b/omega.py @@ -84,6 +84,9 @@ def Omega_numerator_P(a, x, y): import logging logger = logging.getLogger(__name__) + from sage.arith.srange import srange + from sage.misc.misc_c import prod + n = len(x) if n == 1: x0 = x[0] @@ -194,8 +197,6 @@ def Omega_numerator(a, n, m): from sage.arith.srange import srange from sage.misc.misc_c import prod - from sage.rings.integer_ring import ZZ - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing XY, xy = _laurent_polynomial_ring_(n, m) x = xy[:n] @@ -983,6 +984,9 @@ def is_unit_vector(it): assert numerator.parent() == L terms = tuple(l**c * t for c, t in zip(it_coeffs, terms)) + logger.info('generating_function_of_polyhedron: ' + 'terms denominator %s', terms) + def decode_factor(factor): D = factor.dict() assert len(D) == 1 From 52ca15348979c4cf22143ac4339b890e27f10f91 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 30 Nov 2016 09:13:41 +0100 Subject: [PATCH 084/370] rename lambda --> mu (consistently) --- omega.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/omega.py b/omega.py index 4a289d577a0..0d2793c2b4d 100644 --- a/omega.py +++ b/omega.py @@ -123,9 +123,9 @@ def Omega_numerator(a, n, m): .. MATH:: - \Omega_{\ge} \frac{\lambda^a}{ - (1 - x_1 \lambda) \dots (1 - x_n \lambda) - (1 - y_1 / \lambda) \dots (1 - y_m / \lambda) + \Omega_{\ge} \frac{\mu^a}{ + (1 - x_1 \mu) \dots (1 - x_n \mu) + (1 - y_1 / \mu) \dots (1 - y_m / \mu) and returns its numerator. @@ -225,8 +225,8 @@ def Omega_factors_denominator(n, m): .. MATH:: \Omega_{\ge} \frac{1}{ - (1 - x_1 \lambda) \dots (1 - x_n \lambda) - (1 - y_1 / \lambda) \dots (1 - y_m / \lambda) + (1 - x_1 \mu) \dots (1 - x_n \mu) + (1 - y_1 / \mu) \dots (1 - y_m / \mu) and returns a factorization of its denominator. @@ -295,8 +295,8 @@ def Omega_higher(a, exponents): .. MATH:: - \Omega_{\ge} \frac{\lambda^a}{ - (1 - z_1 \lambda^{e_1}) \dots (1 - z_n \lambda^{e_n}) + \Omega_{\ge} \frac{\mu^a}{ + (1 - z_1 \mu^{e_1}) \dots (1 - z_n \mu^{e_n}) and returns its numerator and a factorization of its denominator. @@ -632,10 +632,10 @@ def _Omega_(A, decoded_factors): INPUT: - ``A`` -- a dictionary mapping `a` to `c` representing a summand - `c\lambda^a` of the numerator. + `c\mu^a` of the numerator. - ``decoded_factors`` -- a tuple or list of pairs `(z, e)` representing - a factor `1 - z \lambda^e`. + a factor `1 - z \mu^e`. OUTPUT: @@ -975,7 +975,7 @@ def is_unit_vector(it): logger.debug('generating_function_of_polyhedron: ' 'skipping %s', pretty_inequality(coeffs)) continue - L = LaurentPolynomialRing(L, 'lambda{}'.format(i), sparse=True) + L = LaurentPolynomialRing(L, 'mu{}'.format(i), sparse=True) l = L.gen() logger.debug('generating_function_of_polyhedron: ' '%s --> %s', l, pretty_inequality(coeffs)) @@ -993,7 +993,7 @@ def decode_factor(factor): exponent, coefficient = next(iteritems(D)) return coefficient, exponent - while repr(numerator.parent().gen()).startswith('lambda'): + while repr(numerator.parent().gen()).startswith('mu'): logger.info('generating_function_of_polyhedron: ' 'applying Omega[%s]...', numerator.parent().gen()) From 22391d8a3febbc6305b4a8ccde05152630d0db6e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 30 Nov 2016 16:20:54 +0100 Subject: [PATCH 085/370] correct bug in factors_denominator --- omega.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 0d2793c2b4d..f9168c498f9 100644 --- a/omega.py +++ b/omega.py @@ -257,6 +257,16 @@ def Omega_factors_denominator(n, m): ((-x0 + 1,), (-x1 + 1,), (-x0*y0 + 1,), (-x0*y1 + 1,), (-x1*y0 + 1,), (-x1*y1 + 1,)) + :: + + sage: Omega_factors_denominator((2,), (2,)) + ((-x0 + 1, -x1 + 1), + (-x0*y0 + 1, -x1*y0 + 1), (-x0*y1 + 1, -x1*y1 + 1)) + sage: Omega_factors_denominator((2,), (3,)) + ((-x0 + 1, -x1 + 1), + (-x0*y0 + 1, -x0*y1 + 1, -x0*y2 + 1, + -x1*y0 + 1, -x1*y1 + 1, -x1*y2 + 1)) + TESTS:: sage: Omega_factors_denominator(0, 0) @@ -282,8 +292,10 @@ def Omega_factors_denominator(n, m): y = tuple(tuple(next(ixy) for _ in range(my)) for my in y) return tuple(tuple(1 - xx for xx in gx) for gx in x) + \ - tuple(tuple(1 - xx*yy for xx in gx for yy in gy) - for gx in x for gy in y) + sum(((tuple(1 - xx*yy for xx in gx for yy in gy),) + if len(gx) != len(gy) + else tuple(tuple(1 - xx*yy for xx in gx) for yy in gy) + for gx in x for gy in y), tuple()) @cached_function @@ -335,6 +347,17 @@ def Omega_higher(a, exponents): (z0*z1*z2 + z0*z1 + z0*z2 + 1, (z0, z0*z1^2, z0*z2^2)) sage: Omega_higher(0, (2, 1, -1)) (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, (z0, z1, z0*z2^2, z1*z2)) + + :: + + sage: Omega_higher(0, (2, -2)) + (-z0*z1 + 1, (z0, z0*z1, z0*z1)) + sage: Omega_higher(0, (2, -3)) + (z0^2*z1 + 1, (z0, z0^3*z1^2)) + sage: Omega_higher(0, (3, 1, -3)) + (-z0^3*z1^3*z2^3 + 2*z0^2*z1^3*z2^2 - z0*z1^3*z2 + + z0^2*z2^2 - 2*z0*z2 + 1, + (z0, z1, z0*z2, z0*z2, z0*z2, z1^3*z2)) """ import logging logger = logging.getLogger(__name__) From 1aa995e54df8ddf42a17fc92a4f2f71c4e50fe91 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 30 Nov 2016 16:22:26 +0100 Subject: [PATCH 086/370] remove one not needed line of a doctest --- omega.py | 1 - 1 file changed, 1 deletion(-) diff --git a/omega.py b/omega.py index f9168c498f9..dcc854e8f35 100644 --- a/omega.py +++ b/omega.py @@ -141,7 +141,6 @@ def Omega_numerator(a, n, m): EXAMPLES:: - sage: L. = LaurentPolynomialRing(ZZ) sage: Omega_numerator(0, 1, 1) 1 sage: Omega_numerator(0, 2, 1) From aec67d452813586ea9f1df1c0d3240af92686df8 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 30 Nov 2016 16:25:00 +0100 Subject: [PATCH 087/370] simplify code when creating new laurent polynomial rings --- omega.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/omega.py b/omega.py index dcc854e8f35..21aea89123e 100644 --- a/omega.py +++ b/omega.py @@ -68,15 +68,14 @@ def HomogenousSymmetricFunction(j, x): def _laurent_polynomial_ring_(n, m): - from itertools import chain from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing if n + m == 0: return ZZ, tuple() - L = LaurentPolynomialRing(ZZ, ', '.join(chain( - iter('x{}'.format(nn) for nn in range(n)), - iter('y{}'.format(mm) for mm in range(m))))) + L = LaurentPolynomialRing(ZZ, + tuple('x{}'.format(nn) for nn in range(n)) + + tuple('y{}'.format(mm) for mm in range(m))) return L, L.gens() @@ -380,8 +379,8 @@ def Omega_higher(a, exponents): B = QQ.extension( list(cyclotomic_polynomial(r) for r in xy), tuple('rho{}'.format(i) for i in range(len(xy)))) - L = LaurentPolynomialRing(B, ', '.join('z{}'.format(nn) - for nn in range(len(exponents)))) + L = LaurentPolynomialRing(B, tuple('z{}'.format(nn) + for nn in range(len(exponents)))) powers = dict(zip(xy, iter(L(g) for g in B.gens()))) powers[2] = L(-1) powers[1] = L(1) @@ -966,7 +965,7 @@ def inequalities_coeffs(inequalities): indices = range(len(inequalities[0]) - 1) B = LaurentPolynomialRing( ZZ, - ', '.join('y{}'.format(k) for k in indices), + tuple('y{}'.format(k) for k in indices), sparse=True) n = len(B.gens()) + 1 From c5ba7e6e52e326496107d4e56a4399396c971861 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 09:24:17 +0100 Subject: [PATCH 088/370] solve bug with cyclotomic extensions with gcd != 1 of exponents --- omega.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/omega.py b/omega.py index 21aea89123e..5afaf586a99 100644 --- a/omega.py +++ b/omega.py @@ -356,11 +356,20 @@ def Omega_higher(a, exponents): (-z0^3*z1^3*z2^3 + 2*z0^2*z1^3*z2^2 - z0*z1^3*z2 + z0^2*z2^2 - 2*z0*z2 + 1, (z0, z1, z0*z2, z0*z2, z0*z2, z1^3*z2)) + + :: + + sage: Omega_higher(0, (3, 6, -1)) + (-z0*z1*z2^8 - z0*z1*z2^7 - z0*z1*z2^6 - z0*z1*z2^5 - z0*z1*z2^4 + + z1*z2^5 - z0*z1*z2^3 + z1*z2^4 - z0*z1*z2^2 + z1*z2^3 - + z0*z1*z2 + z0*z2^2 + z1*z2^2 + z0*z2 + z1*z2 + 1, + (z0, z1, z0*z2^3, z1*z2^6)) """ import logging logger = logging.getLogger(__name__) logger.info('Omega_higher: a=%s, exponents=%s', a, exponents) + from sage.arith.misc import lcm from sage.misc.functional import cyclotomic_polynomial from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ @@ -375,13 +384,13 @@ def Omega_higher(a, exponents): n = sum(x) m = sum(y) - xy = sorted(set(x + y) - set([1])) - B = QQ.extension( - list(cyclotomic_polynomial(r) for r in xy), - tuple('rho{}'.format(i) for i in range(len(xy)))) + rou = sorted(set(x + y) - set([1])) + ellcm = lcm(rou) + B = QQ.extension(cyclotomic_polynomial(ellcm), 'zeta') + zeta = B.gen() L = LaurentPolynomialRing(B, tuple('z{}'.format(nn) for nn in range(len(exponents)))) - powers = dict(zip(xy, iter(L(g) for g in B.gens()))) + powers = {i: L(zeta**(ellcm//i)) for i in rou} powers[2] = L(-1) powers[1] = L(1) From f60407ccf5aaec0c1d0409d13b8ed6e48d8fabe8 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 10:03:11 +0100 Subject: [PATCH 089/370] more logging --- omega.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/omega.py b/omega.py index 5afaf586a99..adffc9acfda 100644 --- a/omega.py +++ b/omega.py @@ -201,16 +201,22 @@ def Omega_numerator(a, n, m): y = xy[n:] if m == 0: - return XY(1 - (prod(prod(f) for f in Omega_factors_denominator(n, m)) * - sum(HomogenousSymmetricFunction(j, xy) - for j in srange(-a)) - if a < 0 else 0)) + result = 1 - (prod(prod(f) for f in Omega_factors_denominator(n, m)) * + sum(HomogenousSymmetricFunction(j, xy) + for j in srange(-a)) + if a < 0 else 0) elif n == 0: - return XY(sum(HomogenousSymmetricFunction(j, xy) - for j in srange(a+1))) + result = sum(HomogenousSymmetricFunction(j, xy) + for j in srange(a+1)) else: - return XY(Omega_numerator_P(a, x, y)) - + result = Omega_numerator_P(a, x, y) + result = XY(result) + try: + nt = result.number_of_terms() + except AttributeError: + nt = 1 + logger.info('Omega_numerator: %s terms', nt) + return result @cached_function def Omega_factors_denominator(n, m): @@ -274,6 +280,9 @@ def Omega_factors_denominator(n, m): sage: Omega_factors_denominator(0, 1) () """ + import logging + logger = logging.getLogger(__name__) + if isinstance(n, tuple): x = n n = sum(x) @@ -289,6 +298,9 @@ def Omega_factors_denominator(n, m): x = tuple(tuple(next(ixy) for _ in range(nx)) for nx in x) y = tuple(tuple(next(ixy) for _ in range(my)) for my in y) + nf = sum(len(gx) for gx in x) * (1 + sum(len(gy) for gy in y)) + logger.info('Omega_denominator: %s factors', nf) + return tuple(tuple(1 - xx for xx in gx) for gx in x) + \ sum(((tuple(1 - xx*yy for xx in gx for yy in gy),) if len(gx) != len(gy) From 83d55377c99f66c2bfd7130f0eae4639df80cef8 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 13:11:04 +0100 Subject: [PATCH 090/370] subs: rewrite Omega_factors_denominator --- omega.py | 80 +++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 45 deletions(-) diff --git a/omega.py b/omega.py index adffc9acfda..ca91a76076a 100644 --- a/omega.py +++ b/omega.py @@ -218,8 +218,9 @@ def Omega_numerator(a, n, m): logger.info('Omega_numerator: %s terms', nt) return result + @cached_function -def Omega_factors_denominator(n, m): +def Omega_factors_denominator(x, y): r""" Return the denominator of `\Omega_{\ge}` of the expression specified by the input. @@ -248,64 +249,53 @@ def Omega_factors_denominator(n, m): EXAMPLES:: - sage: Omega_factors_denominator(1, 1) - ((-x0 + 1,), (-x0*y0 + 1,)) - sage: Omega_factors_denominator(1, 2) - ((-x0 + 1,), (-x0*y0 + 1,), (-x0*y1 + 1,)) - sage: Omega_factors_denominator(2, 1) - ((-x0 + 1,), (-x1 + 1,), (-x0*y0 + 1,), (-x1*y0 + 1,)) - sage: Omega_factors_denominator(3, 1) - ((-x0 + 1,), (-x1 + 1,), (-x2 + 1,), - (-x0*y0 + 1,), (-x1*y0 + 1,), (-x2*y0 + 1,)) - sage: Omega_factors_denominator(2, 2) - ((-x0 + 1,), (-x1 + 1,), (-x0*y0 + 1,), - (-x0*y1 + 1,), (-x1*y0 + 1,), (-x1*y1 + 1,)) + sage: L. = LaurentPolynomialRing(ZZ) + sage: Omega_factors_denominator(((x0,),), ((y0,),)) + (-x0 + 1, -x0*y0 + 1) + sage: Omega_factors_denominator(((x0,),), ((y0,), (y1,))) + (-x0 + 1, -x0*y0 + 1, -x0*y1 + 1) + sage: Omega_factors_denominator(((x0,), (x1,)), ((y0,),)) + (-x0 + 1, -x1 + 1, -x0*y0 + 1, -x1*y0 + 1) + sage: Omega_factors_denominator(((x0,), (x1,), (x2,)), ((y0,),)) + (-x0 + 1, -x1 + 1, -x2 + 1, -x0*y0 + 1, -x1*y0 + 1, -x2*y0 + 1) + sage: Omega_factors_denominator(((x0,), (x1,)), ((y0,), (y1,))) + (-x0 + 1, -x1 + 1, -x0*y0 + 1, -x0*y1 + 1, -x1*y0 + 1, -x1*y1 + 1) :: - sage: Omega_factors_denominator((2,), (2,)) - ((-x0 + 1, -x1 + 1), - (-x0*y0 + 1, -x1*y0 + 1), (-x0*y1 + 1, -x1*y1 + 1)) - sage: Omega_factors_denominator((2,), (3,)) - ((-x0 + 1, -x1 + 1), - (-x0*y0 + 1, -x0*y1 + 1, -x0*y2 + 1, - -x1*y0 + 1, -x1*y1 + 1, -x1*y2 + 1)) + sage: B. = ZZ.extension(cyclotomic_polynomial(3)) + sage: L. = LaurentPolynomialRing(B) + sage: Omega_factors_denominator(((x, -x),), ((y,),)) + (-x^2 + 1, -x^2*y^2 + 1) + sage: Omega_factors_denominator(((x, -x),), ((y, zeta*y, zeta^2*y),)) + (-x^2 + 1, -x^6*y^6 + 1) + sage: Omega_factors_denominator(((x, -x),), ((y, -y),)) + (-x^2 + 1, -x^2*y^2 + 1, -x^2*y^2 + 1) TESTS:: - sage: Omega_factors_denominator(0, 0) + sage: L. = LaurentPolynomialRing(ZZ) + sage: Omega_factors_denominator((), ()) () - sage: Omega_factors_denominator(1, 0) - ((1 - x0,),) - sage: Omega_factors_denominator(0, 1) + sage: Omega_factors_denominator(((x0,),), ()) + (-x0 + 1,) + sage: Omega_factors_denominator((), ((y0,),)) () """ import logging logger = logging.getLogger(__name__) - if isinstance(n, tuple): - x = n - n = sum(x) - else: - x = tuple(1 for _ in range(n)) - if isinstance(m, tuple): - y = m - m = sum(y) - else: - y = tuple(1 for _ in range(m)) - - ixy = iter(_laurent_polynomial_ring_(n, m)[1]) - x = tuple(tuple(next(ixy) for _ in range(nx)) for nx in x) - y = tuple(tuple(next(ixy) for _ in range(my)) for my in y) + from sage.misc.misc_c import prod - nf = sum(len(gx) for gx in x) * (1 + sum(len(gy) for gy in y)) - logger.info('Omega_denominator: %s factors', nf) + result = tuple(prod(1 - xx for xx in gx) for gx in x) + \ + sum(((prod(1 - xx*yy for xx in gx for yy in gy),) + if len(gx) != len(gy) + else tuple(prod(1 - xx*yy for xx in gx) for yy in gy) + for gx in x for gy in y), + tuple()) - return tuple(tuple(1 - xx for xx in gx) for gx in x) + \ - sum(((tuple(1 - xx*yy for xx in gx for yy in gy),) - if len(gx) != len(gy) - else tuple(tuple(1 - xx*yy for xx in gx) for yy in gy) - for gx in x for gy in y), tuple()) + logger.info('Omega_denominator: %s factors', len(result)) + return result @cached_function From 9ed032857ed4f3b07dbc950bbd3f6d28380caa9d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 13:11:32 +0100 Subject: [PATCH 091/370] subs: rewrite P --- omega.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/omega.py b/omega.py index ca91a76076a..a4e6f6c016b 100644 --- a/omega.py +++ b/omega.py @@ -78,8 +78,7 @@ def _laurent_polynomial_ring_(n, m): tuple('y{}'.format(mm) for mm in range(m))) return L, L.gens() - -def Omega_numerator_P(a, x, y): +def Omega_numerator_P(a, x, y, t): import logging logger = logging.getLogger(__name__) @@ -88,19 +87,19 @@ def Omega_numerator_P(a, x, y): n = len(x) if n == 1: - x0 = x[0] + x0 = t result = x0**(-a) + \ (prod(1 - x0*yy for yy in y) * sum(HomogenousSymmetricFunction(j, y) * (1-x0**(j-a)) for j in srange(a)) if a > 0 else 0) else: - Pprev = Omega_numerator_P(a, x[:n-1], y) - x1 = x[n-1] + Pprev = Omega_numerator_P(a, x[:n-1], y, t) x2 = x[n-2] logger.debug('Omega_numerator: P(%s): substituting...', n) - p1 = Pprev.subs({x2: x1}) - p2 = Pprev + x1 = t + p1 = Pprev + p2 = Pprev.subs({t: x2}) logger.debug('Omega_numerator: P(%s): preparing...', n) dividend = x1 * (1-x2) * prod(1 - x2*yy for yy in y) * p1 - \ x2 * (1-x1) * prod(1 - x1*yy for yy in y) * p2 From 15a63087bec854329ee90b7357a0fe37dfd55190 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 13:12:05 +0100 Subject: [PATCH 092/370] subs: rewrite Omega_numerator --- omega.py | 85 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/omega.py b/omega.py index a4e6f6c016b..738610085c1 100644 --- a/omega.py +++ b/omega.py @@ -111,8 +111,7 @@ def Omega_numerator_P(a, x, y, t): return result -@cached_function -def Omega_numerator(a, n, m): +def Omega_numerator(a, x, y, t): r""" Return the numerator of `\Omega_{\ge}` of the expression specified by the input. @@ -131,7 +130,9 @@ def Omega_numerator(a, n, m): - ``a`` -- an integer. - - ``n`` and ``m`` -- nonnegative integers. + - ``x`` and ``y`` -- list/tuple of laurent polynomials. + + - ``t`` -- a temporary laurent polynomial variable used for substituting. OUTPUT: @@ -139,68 +140,81 @@ def Omega_numerator(a, n, m): EXAMPLES:: - sage: Omega_numerator(0, 1, 1) + sage: L. = LaurentPolynomialRing(ZZ) + sage: Omega_numerator(0, ((x0,),), ((y0,),), t) 1 - sage: Omega_numerator(0, 2, 1) + sage: Omega_numerator(0, ((x0,), (x1,)), ((y0,),), t) -x0*x1*y0 + 1 - sage: Omega_numerator(0, 1, 2) + sage: Omega_numerator(0, ((x0,),), ((y0,), (y1,)), t) 1 - sage: Omega_numerator(0, 3, 1) + sage: Omega_numerator(0, ((x0,), (x1,), (x2,)), ((y0,),), t) x0*x1*x2*y0^2 + x0*x1*x2*y0 - x0*x1*y0 - x0*x2*y0 - x1*x2*y0 + 1 - sage: Omega_numerator(0, 2, 2) + sage: Omega_numerator(0, ((x0,), (x1,)), ((y0,), (y1,)), t) x0^2*x1*y0*y1 + x0*x1^2*y0*y1 - x0*x1*y0*y1 - x0*x1*y0 - x0*x1*y1 + 1 - sage: Omega_numerator(-2, 1, 1) + sage: Omega_numerator(-2, ((x0,),), ((y0,),), t) x0^2 - sage: Omega_numerator(-1, 1, 1) + sage: Omega_numerator(-1, ((x0,),), ((y0,),), t) x0 - sage: Omega_numerator(1, 1, 1) + sage: Omega_numerator(1, ((x0,),), ((y0,),), t) -x0*y0 + y0 + 1 - sage: Omega_numerator(2, 1, 1) + sage: Omega_numerator(2, ((x0,),), ((y0,),), t) -x0*y0^2 - x0*y0 + y0^2 + y0 + 1 TESTS:: - sage: Omega_factors_denominator(0, 0) + sage: Omega_factors_denominator((), ()) () - sage: Omega_numerator(0, 0, 0) + sage: Omega_numerator(0, (), (), t) 1 - sage: Omega_numerator(+2, 0, 0) + sage: Omega_numerator(+2, (), (), t) 1 - sage: Omega_numerator(-2, 0, 0) + sage: Omega_numerator(-2, (), (), t) 0 - sage: Omega_factors_denominator(1, 0) - ((1 - x0,),) - sage: Omega_numerator(0, 1, 0) + sage: Omega_factors_denominator(((x0,),), ()) + (-x0 + 1,) + sage: Omega_numerator(0, ((x0,),), (), t) 1 - sage: Omega_numerator(+2, 1, 0) + sage: Omega_numerator(+2, ((x0,),), (), t) 1 - sage: Omega_numerator(-2, 1, 0) + sage: Omega_numerator(-2, ((x0,),), (), t) x0^2 - sage: Omega_factors_denominator(0, 1) + sage: Omega_factors_denominator((), ((y0,),)) () - sage: Omega_numerator(0, 0, 1) + sage: Omega_numerator(0, (), ((y0,),), t) 1 - sage: Omega_numerator(+2, 0, 1) - 1 + y0 + y0^2 - sage: Omega_numerator(-2, 0, 1) + sage: Omega_numerator(+2, (), ((y0,),), t) + y0^2 + y0 + 1 + sage: Omega_numerator(-2, (), ((y0,),), t) 0 - """ - import logging - logger = logging.getLogger(__name__) - logger.info('Omega_numerator: a=%s, n=%s, m=%s', a, n, m) + :: + + sage: L. = LaurentPolynomialRing(ZZ) + sage: Omega_numerator(2, ((X,),), ((Y,),), t) + -X*Y^2 - X*Y + Y^2 + Y + 1 + """ from sage.arith.srange import srange from sage.misc.misc_c import prod - XY, xy = _laurent_polynomial_ring_(n, m) - x = xy[:n] - y = xy[n:] + x_flat = sum(x, tuple()) + y_flat = sum(y, tuple()) + n = len(x_flat) + m = len(y_flat) + xy = x_flat + y_flat + if xy: + XY = xy[0].parent() + else: + XY = ZZ + + import logging + logger = logging.getLogger(__name__) + logger.info('Omega_numerator: a=%s, n=%s, m=%s', a, n, m) if m == 0: - result = 1 - (prod(prod(f) for f in Omega_factors_denominator(n, m)) * + result = 1 - (prod(Omega_factors_denominator(x, y)) * sum(HomogenousSymmetricFunction(j, xy) for j in srange(-a)) if a < 0 else 0) @@ -208,7 +222,8 @@ def Omega_numerator(a, n, m): result = sum(HomogenousSymmetricFunction(j, xy) for j in srange(a+1)) else: - result = Omega_numerator_P(a, x, y) + result = Omega_numerator_P(a, x_flat, y_flat, t).subs({t: x_flat[-1]}) + result = XY(result) try: nt = result.number_of_terms() From 57c957328710f8e3849be4600b94be251cd14b3d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 13:12:20 +0100 Subject: [PATCH 093/370] subs: remove _laurent_plolynomial_ring_ --- omega.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/omega.py b/omega.py index 738610085c1..e711aacbb03 100644 --- a/omega.py +++ b/omega.py @@ -67,17 +67,6 @@ def HomogenousSymmetricFunction(j, x): for p in IntegerVectors(j, length=len(x))) -def _laurent_polynomial_ring_(n, m): - from sage.rings.integer_ring import ZZ - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - - if n + m == 0: - return ZZ, tuple() - L = LaurentPolynomialRing(ZZ, - tuple('x{}'.format(nn) for nn in range(n)) + - tuple('y{}'.format(mm) for mm in range(m))) - return L, L.gens() - def Omega_numerator_P(a, x, y, t): import logging logger = logging.getLogger(__name__) From 48fbf87a8615182935db91237334e9e56426ae0b Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 13:12:44 +0100 Subject: [PATCH 094/370] subs: rewrite Omega_higher --- omega.py | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/omega.py b/omega.py index e711aacbb03..de6b9925f19 100644 --- a/omega.py +++ b/omega.py @@ -375,6 +375,7 @@ def Omega_higher(a, exponents): logger.info('Omega_higher: a=%s, exponents=%s', a, exponents) from sage.arith.misc import lcm + from sage.arith.srange import srange from sage.misc.functional import cyclotomic_polynomial from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ @@ -384,20 +385,22 @@ def Omega_higher(a, exponents): if not exponents or any(e == 0 for e in exponents): raise NotImplementedError - x = tuple(e for e in exponents if e > 0) - y = tuple(-e for e in exponents if e < 0) - n = sum(x) - m = sum(y) - - rou = sorted(set(x + y) - set([1])) + rou = sorted(set(abs(e) for e in exponents) - set([1])) ellcm = lcm(rou) B = QQ.extension(cyclotomic_polynomial(ellcm), 'zeta') zeta = B.gen() - L = LaurentPolynomialRing(B, tuple('z{}'.format(nn) - for nn in range(len(exponents)))) + z_names = tuple('z{}'.format(i) for i in range(len(exponents))) + L = LaurentPolynomialRing(B, ('t',) + z_names) + t = L.gens()[0] + Z = LaurentPolynomialRing(ZZ, z_names) powers = {i: L(zeta**(ellcm//i)) for i in rou} powers[2] = L(-1) powers[1] = L(1) + exponents_and_values = tuple( + (e, tuple(powers[abs(e)]**j * z for j in srange(abs(e)))) + for z, e in zip(L.gens()[1:], exponents)) + x = tuple(v for e, v in exponents_and_values if e > 0) + y = tuple(v for e, v in exponents_and_values if e < 0) def subs_power(expression, var, exponent, value=None): r""" @@ -415,28 +418,20 @@ def subs_e(e): return result return result.subs({var: value}) - Z = L.change_ring(ZZ) - def de_power(expression): expression = Z(expression) - for e, var in zip(exponents, L.gens()): + for e, var in zip(exponents, Z.gens()): if abs(e) == 1: continue expression = subs_power(expression, var, abs(e)) return expression - xy_vars = _laurent_polynomial_ring_(n, m)[1] - x_vars = iter(xy_vars[:n]) - y_vars = iter(xy_vars[n:]) - rules = {next(x_vars) if e > 0 else next(y_vars): - powers[abs(e)]**j * var - for e, var in zip(exponents, L.gens()) for j in range(abs(e))} logger.debug('Omega_higher: preparing denominator') - factors_denominator = tuple(de_power(1 - prod(f.subs(rules) for f in factors)) - for factors in Omega_factors_denominator(x, y)) + factors_denominator = tuple(de_power(1 - factor) + for factor in Omega_factors_denominator(x, y)) logger.debug('Omega_higher: preparing numerator') - numerator = de_power(Omega_numerator(a, n, m).subs(rules)) + numerator = de_power(Omega_numerator(a, x, y, t)) logger.info('Omega_higher: completed') return numerator, factors_denominator From 47e2f8e1b560c8d8e13ba2d233e77c38a0a31838 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 13:40:55 +0100 Subject: [PATCH 095/370] adapt docstrings --- omega.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/omega.py b/omega.py index de6b9925f19..e8820afd60f 100644 --- a/omega.py +++ b/omega.py @@ -119,7 +119,9 @@ def Omega_numerator(a, x, y, t): - ``a`` -- an integer. - - ``x`` and ``y`` -- list/tuple of laurent polynomials. + - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The + flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the + `y_1,...,y_m`. - ``t`` -- a temporary laurent polynomial variable used for substituting. @@ -240,15 +242,14 @@ def Omega_factors_denominator(x, y): INPUT: - - ``n`` and ``m`` -- nonnegative integers or - tuples of nonnegative integers. The latter specifys how the factors - of the result are grouped. An integer (former case) corresponds to - a tuple consisting of that many `1`s. + - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The + flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the + `y_1,...,y_m`. OUTPUT: A factorization of the denominator as - a tuple of tuples of laurent polynomials. + a tuple of laurent polynomials. EXAMPLES:: From 1a95eb38bf4c9add7ae3807756f5d6187c7ef648 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 13:41:30 +0100 Subject: [PATCH 096/370] minor simplification of code --- omega.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/omega.py b/omega.py index e8820afd60f..4563cdfb62b 100644 --- a/omega.py +++ b/omega.py @@ -195,10 +195,6 @@ def Omega_numerator(a, x, y, t): n = len(x_flat) m = len(y_flat) xy = x_flat + y_flat - if xy: - XY = xy[0].parent() - else: - XY = ZZ import logging logger = logging.getLogger(__name__) @@ -214,13 +210,10 @@ def Omega_numerator(a, x, y, t): for j in srange(a+1)) else: result = Omega_numerator_P(a, x_flat, y_flat, t).subs({t: x_flat[-1]}) + L = t.parent() + result = L(result) - result = XY(result) - try: - nt = result.number_of_terms() - except AttributeError: - nt = 1 - logger.info('Omega_numerator: %s terms', nt) + logger.info('Omega_numerator: %s terms', result.number_of_terms()) return result From f336130af943301f0e4f6331e1fc8827bd853366 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 13:41:39 +0100 Subject: [PATCH 097/370] align code --- omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omega.py b/omega.py index 4563cdfb62b..535e74d5b45 100644 --- a/omega.py +++ b/omega.py @@ -207,7 +207,7 @@ def Omega_numerator(a, x, y, t): if a < 0 else 0) elif n == 0: result = sum(HomogenousSymmetricFunction(j, xy) - for j in srange(a+1)) + for j in srange(a+1)) else: result = Omega_numerator_P(a, x_flat, y_flat, t).subs({t: x_flat[-1]}) L = t.parent() From 906919940c8e708af898b12f4ea7db25b9c4bb4e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 1 Dec 2016 13:56:35 +0100 Subject: [PATCH 098/370] Omega_higher: add one long doctest --- omega.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/omega.py b/omega.py index 535e74d5b45..5c176a7ae0e 100644 --- a/omega.py +++ b/omega.py @@ -363,6 +363,11 @@ def Omega_higher(a, exponents): z1*z2^5 - z0*z1*z2^3 + z1*z2^4 - z0*z1*z2^2 + z1*z2^3 - z0*z1*z2 + z0*z2^2 + z1*z2^2 + z0*z2 + z1*z2 + 1, (z0, z1, z0*z2^3, z1*z2^6)) + + :: + + sage: Omega_higher(0, (2, 2, 1, 1, 1, 1, 1, -1, -1))[0].number_of_terms() # long time + 27837 """ import logging logger = logging.getLogger(__name__) From f6adc200476283b75f82cc0e02e43fe4a3b04860 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 2 Dec 2016 17:46:15 +0100 Subject: [PATCH 099/370] code for splitting polyhedron --- omega.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/omega.py b/omega.py index 5c176a7ae0e..dd9bd6bd420 100644 --- a/omega.py +++ b/omega.py @@ -725,7 +725,8 @@ def pretty_inequality(ineq, indices=None): return '{} >= {}'.format(positive_part*vars, negative_part*vars) -def generating_function_of_polyhedron(polyhedron, indices=None): + +def generating_function_of_polyhedron(polyhedron, indices=None, split=False): r""" Return the generating function of the integer points of the polyhedron's orthant with only nonnegative coordinates. @@ -944,6 +945,27 @@ def generating_function_of_polyhedron(polyhedron, indices=None): except AttributeError: pass + if split: + from sage.combinat.permutation import Permutations + from sage.geometry.polyhedron.constructor import Polyhedron + + d = polyhedron.dim() + result = [] + for pi in Permutations(d): + logger.info('generating_function_of_polyhedron: ' + 'split by %s', + ' <= '.join('b{}'.format(a-1) for a in pi)) + ph = polyhedron & Polyhedron(ieqs= + [tuple(1 if i==b else (-1 if i==a else 0) + for i in range(d+1)) + for a, b in zip(pi[:-1], pi[1:])]) + logger.info('polyhedron: %s', + ', '.join(h.repr_pretty(prefix='b') + for h in ph.Hrepresentation())) + result.append(generating_function_of_polyhedron( + ph, indices=indices, split=False)) + return result + def inequalities_coeffs(inequalities): for entry in inequalities: if isinstance(entry, (tuple, list)): From 2ae867022a2208e175abbd9cfc084dd0bcd66096 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 2 Dec 2016 17:46:30 +0100 Subject: [PATCH 100/370] minor improve of inner function code --- omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omega.py b/omega.py index dd9bd6bd420..982744083cc 100644 --- a/omega.py +++ b/omega.py @@ -1016,7 +1016,7 @@ def is_unit_vector(it): found += 1 if found >= 2: return False - return True + return found == 1 numerator = B(1) terms = B.gens() From 1df96d52d01407830b011dd89ab3963f5983c78f Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 2 Dec 2016 17:46:38 +0100 Subject: [PATCH 101/370] more logging --- omega.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/omega.py b/omega.py index 982744083cc..3bb8a7d19d9 100644 --- a/omega.py +++ b/omega.py @@ -1047,6 +1047,8 @@ def decode_factor(factor): while repr(numerator.parent().gen()).startswith('mu'): logger.info('generating_function_of_polyhedron: ' 'applying Omega[%s]...', numerator.parent().gen()) + logger.info('...on terms denominator %s', terms) + logger.info('...(numerator has %s)', numerator.number_of_terms()) decoded_factors, other_factors = \ partition((decode_factor(factor) for factor in terms), From 1990ed72669e0b8f97f358f3eee075e5967e6d63 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 2 Dec 2016 17:47:08 +0100 Subject: [PATCH 102/370] code for preparing inequalities --- omega.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/omega.py b/omega.py index 3bb8a7d19d9..67eac61c7ce 100644 --- a/omega.py +++ b/omega.py @@ -725,6 +725,57 @@ def pretty_inequality(ineq, indices=None): return '{} >= {}'.format(positive_part*vars, negative_part*vars) +def prepare_inequalities(inequalities): + r""" + EXAMPLES:: + + sage: prepare_inequalities([(0, -1, 1, 0), (2, -1, -1, 1)]) + [(2, -2, -1, 1)] + sage: prepare_inequalities([(-1, -1, 1, 0), (2, -1, -1, 1)]) + [(1, -2, -1, 1)] + sage: prepare_inequalities([(2, -1, 1, 0), (2, -1, -1, 1)]) + [(4, -2, -1, 1)] + """ + from itertools import combinations + from sage.matrix.constructor import matrix + from sage.modules.free_module_element import vector + + inequalities_filtered = [] + chain_links = {} + for coeffs in inequalities: + n = len(coeffs) + constant = coeffs[0] + ones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == 1) + mones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == -1) + absgetwo = tuple(i+1 for i, c in enumerate(coeffs[1:]) if abs(c) >= 2) + if len(ones) == 1 and not mones and not absgetwo: + if constant >= 0: + logger.debug('generating_function_of_polyhedron: ' + 'skipping %s', pretty_inequality(coeffs)) + else: + # TODO: could be skipped... + inequalities_filtered.append(coeffs) + elif len(ones) == 1 and len(mones) == 1 and not absgetwo: + chain_links[(mones[0], ones[0])] = constant + else: + inequalities_filtered.append(coeffs) + D = {c: 1 + for chain in Poset((sum(chain_links, ()), chain_links)).maximal_chains() + for c in combinations(chain, 2)} + for i in range(n): + D[(i, i)] = 1 + for chain in Poset((sum(chain_links, ()), chain_links)).maximal_chains(): + first = chain[0] + constant = 0 + itchain = enumerate(chain) + next(itchain) + for i, c in itchain: + constant += chain_links[(chain[i-1], chain[i])] + D[(0, c)] = -constant + T = matrix(ZZ, n, n, D) + + return list(tuple(T*vector(ieq)) for ieq in inequalities_filtered) + def generating_function_of_polyhedron(polyhedron, indices=None, split=False): r""" @@ -1018,6 +1069,25 @@ def is_unit_vector(it): return False return found == 1 + def is_aleb(it): + founda = 0 + foundb = 0 + for e in it: + if e != 0: + if abs(e) != 1: + return False + elif e == -1: + founda += 1 + if founda >= 2: + return False + elif e == 1: + foundb += 1 + if foundb >= 2: + return False + return founda == 1 and foundb == 1 + + + numerator = B(1) terms = B.gens() L = B From fdd6cf3633d20670f6c773bad31e4c6a623bcc33 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 2 Dec 2016 17:52:27 +0100 Subject: [PATCH 103/370] simplify code --- omega.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/omega.py b/omega.py index 67eac61c7ce..655edb96763 100644 --- a/omega.py +++ b/omega.py @@ -759,13 +759,13 @@ def prepare_inequalities(inequalities): chain_links[(mones[0], ones[0])] = constant else: inequalities_filtered.append(coeffs) - D = {c: 1 - for chain in Poset((sum(chain_links, ()), chain_links)).maximal_chains() - for c in combinations(chain, 2)} + + D = {} for i in range(n): D[(i, i)] = 1 for chain in Poset((sum(chain_links, ()), chain_links)).maximal_chains(): - first = chain[0] + for c in combinations(chain, 2): + D[c] = 1 constant = 0 itchain = enumerate(chain) next(itchain) From afdea22373e03477dbd5d8a9e8c9893b59450e8e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 2 Dec 2016 17:55:27 +0100 Subject: [PATCH 104/370] more code simplification --- omega.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/omega.py b/omega.py index 655edb96763..c5b934c5a4c 100644 --- a/omega.py +++ b/omega.py @@ -764,13 +764,11 @@ def prepare_inequalities(inequalities): for i in range(n): D[(i, i)] = 1 for chain in Poset((sum(chain_links, ()), chain_links)).maximal_chains(): - for c in combinations(chain, 2): - D[c] = 1 + for cl in combinations(chain, 2): + D[cl] = 1 constant = 0 - itchain = enumerate(chain) - next(itchain) - for i, c in itchain: - constant += chain_links[(chain[i-1], chain[i])] + for cc, c in zip(chain[:-1], chain[1:]): + constant += chain_links[(cc, c)] D[(0, c)] = -constant T = matrix(ZZ, n, n, D) From e90f04ac53aea9d9b6ee0d1b688c74f526157b44 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 2 Dec 2016 18:19:21 +0100 Subject: [PATCH 105/370] additional doctest --- omega.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/omega.py b/omega.py index c5b934c5a4c..b05bf569db2 100644 --- a/omega.py +++ b/omega.py @@ -735,6 +735,9 @@ def prepare_inequalities(inequalities): [(1, -2, -1, 1)] sage: prepare_inequalities([(2, -1, 1, 0), (2, -1, -1, 1)]) [(4, -2, -1, 1)] + + sage: prepare_inequalities([(1, 1, -1, 0), (1, -1, 0, 1), (2, -1, -1, 3)]) + [(-3, 2, 1, 3)] """ from itertools import combinations from sage.matrix.constructor import matrix From 635763012cd38cb71fa507b442db69377d641ca2 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 4 Dec 2016 15:11:12 +0100 Subject: [PATCH 106/370] prepare_inequalities: pass laurent ring --- omega.py | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/omega.py b/omega.py index b05bf569db2..b46f939ae62 100644 --- a/omega.py +++ b/omega.py @@ -725,23 +725,26 @@ def pretty_inequality(ineq, indices=None): return '{} >= {}'.format(positive_part*vars, negative_part*vars) -def prepare_inequalities(inequalities): +def prepare_inequalities(inequalities, B): r""" EXAMPLES:: - sage: prepare_inequalities([(0, -1, 1, 0), (2, -1, -1, 1)]) - [(2, -2, -1, 1)] - sage: prepare_inequalities([(-1, -1, 1, 0), (2, -1, -1, 1)]) - [(1, -2, -1, 1)] - sage: prepare_inequalities([(2, -1, 1, 0), (2, -1, -1, 1)]) - [(4, -2, -1, 1)] - - sage: prepare_inequalities([(1, 1, -1, 0), (1, -1, 0, 1), (2, -1, -1, 3)]) - [(-3, 2, 1, 3)] + sage: B = LaurentPolynomialRing(ZZ, 'y', 3) + sage: prepare_inequalities([(0, -1, 1, 0), (2, -1, -1, 1)], B) + ([(2, -2, -1, 1)], 1, {y2: y2, y1: y1, y0: y0*y1}) + sage: prepare_inequalities([(-1, -1, 1, 0), (2, -1, -1, 1)], B) + ([(1, -2, -1, 1)], y1, {y2: y2, y1: y1, y0: y0*y1}) + sage: prepare_inequalities([(2, -1, 1, 0), (2, -1, -1, 1)], B) + ([(4, -2, -1, 1)], y1^-2, {y2: y2, y1: y1, y0: y0*y1}) + + sage: prepare_inequalities([(1, 1, -1, 0), (1, -1, 0, 1), + ....: (2, -1, -1, 3)], B) + ([(-3, 2, 1, 3)], y0^-1*y2^-2, {y2: y2, y1: y0*y1*y2, y0: y0*y2}) """ from itertools import combinations from sage.matrix.constructor import matrix from sage.modules.free_module_element import vector + from sage.rings.integer_ring import ZZ inequalities_filtered = [] chain_links = {} @@ -775,7 +778,14 @@ def prepare_inequalities(inequalities): D[(0, c)] = -constant T = matrix(ZZ, n, n, D) - return list(tuple(T*vector(ieq)) for ieq in inequalities_filtered) + inequalities = list(tuple(T*vector(ieq)) for ieq in inequalities_filtered) + + rules_pre = iter((y, B({tuple(row[1:]): 1})) + for y, row in zip((1,) + B.gens(), T.rows())) + factor = next(rules_pre)[1] + rules = dict(rules_pre) + + return inequalities, factor, rules def generating_function_of_polyhedron(polyhedron, indices=None, split=False): From 3bed0dfee5c8e5f690f380912451b2dccb851290 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 5 Dec 2016 10:50:15 +0100 Subject: [PATCH 107/370] missing imports --- omega.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/omega.py b/omega.py index b46f939ae62..cb1391e36e5 100644 --- a/omega.py +++ b/omega.py @@ -741,7 +741,11 @@ def prepare_inequalities(inequalities, B): ....: (2, -1, -1, 3)], B) ([(-3, 2, 1, 3)], y0^-1*y2^-2, {y2: y2, y1: y0*y1*y2, y0: y0*y2}) """ + import logging + logger = logging.getLogger(__name__) + from itertools import combinations + from sage.combinat.posets.posets import Poset from sage.matrix.constructor import matrix from sage.modules.free_module_element import vector from sage.rings.integer_ring import ZZ From 2bcc6af63af610f2bd806befafc4f2c1023bb0ec Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 5 Dec 2016 10:50:37 +0100 Subject: [PATCH 108/370] prepare equations --- omega.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/omega.py b/omega.py index cb1391e36e5..1f2fc5439a8 100644 --- a/omega.py +++ b/omega.py @@ -792,6 +792,41 @@ def prepare_inequalities(inequalities, B): return inequalities, factor, rules +def prepare_equations(equations, B): + r""" + EXAMPLES:: + + sage: B = LaurentPolynomialRing(ZZ, 'y', 4) + sage: prepare_equations([(1, 1, 1, -1, 0)], B) + (y2, {y1: y1*y2, y0: y0*y2}, (3,)) + sage: prepare_equations([(-1, 0, 1, -1, -1), (1, 1, 0, 1, 2)], B) + (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (3, 4)) + """ + import logging + logger = logging.getLogger(__name__) + + from sage.matrix.constructor import matrix + from sage.misc.misc_c import prod + + E = matrix(equations) + cols = E.columns() + indices_nonzero = tuple(i for i, col in enumerate(cols) + if not col.is_zero()) + indices = indices_nonzero[-E.nrows():] + indicesn = indices_nonzero[:-E.nrows()] + T = E.matrix_from_columns(indices).inverse() + + gens = (1,) + B.gens() + z = tuple(gens[i] for i in indices) + gens_cols = zip(gens, cols) + rules_pre = iter((y, y * prod(zz**(-c) for zz, c in zip(z, T*col))) + for y, col in (gens_cols[i] for i in indicesn)) + factor = next(rules_pre)[1] + rules = dict(rules_pre) + + return factor, rules, indices + + def generating_function_of_polyhedron(polyhedron, indices=None, split=False): r""" Return the generating function of the integer points of From ef281a9cff11b07a6ee0dec184e489036aad8b15 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 5 Dec 2016 12:15:41 +0100 Subject: [PATCH 109/370] prepare equations: no equations --- omega.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/omega.py b/omega.py index 1f2fc5439a8..3f5de2117c4 100644 --- a/omega.py +++ b/omega.py @@ -809,6 +809,9 @@ def prepare_equations(equations, B): from sage.misc.misc_c import prod E = matrix(equations) + if not E: + return 1, {}, () + cols = E.columns() indices_nonzero = tuple(i for i, col in enumerate(cols) if not col.is_zero()) From fd2210d7055cfd558c5a8d732026361de4d7044e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 5 Dec 2016 12:16:01 +0100 Subject: [PATCH 110/370] prepare_equations: shift indices --- omega.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/omega.py b/omega.py index 3f5de2117c4..297e7a49816 100644 --- a/omega.py +++ b/omega.py @@ -798,9 +798,9 @@ def prepare_equations(equations, B): sage: B = LaurentPolynomialRing(ZZ, 'y', 4) sage: prepare_equations([(1, 1, 1, -1, 0)], B) - (y2, {y1: y1*y2, y0: y0*y2}, (3,)) + (y2, {y1: y1*y2, y0: y0*y2}, (2,)) sage: prepare_equations([(-1, 0, 1, -1, -1), (1, 1, 0, 1, 2)], B) - (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (3, 4)) + (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (2, 3)) """ import logging logger = logging.getLogger(__name__) @@ -827,7 +827,7 @@ def prepare_equations(equations, B): factor = next(rules_pre)[1] rules = dict(rules_pre) - return factor, rules, indices + return factor, rules, tuple(i-1 for i in indices) def generating_function_of_polyhedron(polyhedron, indices=None, split=False): From a62e7056e24c77971fad18ee5b5fa5510a30f4c7 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Mon, 5 Dec 2016 12:16:20 +0100 Subject: [PATCH 111/370] prepare_equations: fix a bug --- omega.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 297e7a49816..cbd1f659722 100644 --- a/omega.py +++ b/omega.py @@ -799,6 +799,8 @@ def prepare_equations(equations, B): sage: B = LaurentPolynomialRing(ZZ, 'y', 4) sage: prepare_equations([(1, 1, 1, -1, 0)], B) (y2, {y1: y1*y2, y0: y0*y2}, (2,)) + sage: prepare_equations([(0, 1, 0, -1, 0)], B) + (1, {y0: y0*y2}, (2,)) sage: prepare_equations([(-1, 0, 1, -1, -1), (1, 1, 0, 1, 2)], B) (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (2, 3)) """ @@ -814,9 +816,9 @@ def prepare_equations(equations, B): cols = E.columns() indices_nonzero = tuple(i for i, col in enumerate(cols) - if not col.is_zero()) + if i > 0 and not col.is_zero()) indices = indices_nonzero[-E.nrows():] - indicesn = indices_nonzero[:-E.nrows()] + indicesn = (0,) + indices_nonzero[:-E.nrows()] T = E.matrix_from_columns(indices).inverse() gens = (1,) + B.gens() From aa5323aab9e029f400be3d76d668a590780ed4a0 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 12:18:53 +0100 Subject: [PATCH 112/370] sort/simplify options --- omega.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index cbd1f659722..afc4c4bb6ae 100644 --- a/omega.py +++ b/omega.py @@ -832,7 +832,9 @@ def prepare_equations(equations, B): return factor, rules, tuple(i-1 for i in indices) -def generating_function_of_polyhedron(polyhedron, indices=None, split=False): + +def generating_function_of_polyhedron(polyhedron, indices=None, split=False, + Factorization_sort=False, Factorization_simplify=False): r""" Return the generating function of the integer points of the polyhedron's orthant with only nonnegative coordinates. @@ -1185,4 +1187,5 @@ def decode_factor(factor): return Factorization([(numerator, 1)] + list((1-t, -1) for t in terms), - sort=False, simplify=False) + sort=Factorization_sort, + simplify=Factorization_simplify) From 4da396f99fef3a67a0d6b0b8a5b74637c35868b5 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 12:19:16 +0100 Subject: [PATCH 113/370] extend doctests --- omega.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/omega.py b/omega.py index afc4c4bb6ae..89578ca1808 100644 --- a/omega.py +++ b/omega.py @@ -848,6 +848,10 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, 1 * (-y1 + 1)^-1 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 sage: generating_function_of_polyhedron(P2[1]) 1 * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 + sage: (P2[0] & P2[1]).Hrepresentation() + (An equation (1, 0, -1) x + 0 == 0, + An inequality (1, 0, 0) x + 0 >= 0, + An inequality (0, 1, 0) x + 0 >= 0) sage: generating_function_of_polyhedron(P2[0] & P2[1]) 1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 @@ -880,7 +884,7 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, ....: if not J: ....: continue ....: P = intersect([P3[j] for j in J]) - ....: print('{}: {}'.format(J, P.inequalities())) + ....: print('{}: {}'.format(J, P.Hrepresentation())) ....: print(generating_function_of_polyhedron(P)) [0]: (An inequality (0, 0, 0, 1) x + 0 >= 0, An inequality (0, 0, 1, 0) x + 0 >= 0, From 9a681a910f5a4c99b46d792b35bea697b3f79cd0 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 12:20:17 +0100 Subject: [PATCH 114/370] major rewrite prepare_inequalities to use digraphs (instead of posets) --- omega.py | 100 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 14 deletions(-) diff --git a/omega.py b/omega.py index 89578ca1808..85ceb329a98 100644 --- a/omega.py +++ b/omega.py @@ -737,15 +737,67 @@ def prepare_inequalities(inequalities, B): sage: prepare_inequalities([(2, -1, 1, 0), (2, -1, -1, 1)], B) ([(4, -2, -1, 1)], y1^-2, {y2: y2, y1: y1, y0: y0*y1}) + TESTS:: + + sage: B = LaurentPolynomialRing(ZZ, 'y', 3) sage: prepare_inequalities([(1, 1, -1, 0), (1, -1, 0, 1), ....: (2, -1, -1, 3)], B) ([(-3, 2, 1, 3)], y0^-1*y2^-2, {y2: y2, y1: y0*y1*y2, y0: y0*y2}) + + sage: B = LaurentPolynomialRing(ZZ, 'y', 4) + sage: prepare_inequalities([(-1, 1, -1, 0, 0)], B) + sage: prepare_inequalities([(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), + ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)], B) + sage: prepare_inequalities([(-2, 1, -1, 0, 0)], B) + sage: prepare_inequalities([(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), + ....: (0, 1, 0, 0, -1), (-2, 1, -1, 0, 0)], B) + + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), + ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y2^3*y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), + ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y2^2*y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y1^2*y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y1^3*y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y1^2*y2^3*y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y1^3*y2^2*y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) """ import logging logger = logging.getLogger(__name__) - from itertools import combinations - from sage.combinat.posets.posets import Poset + from itertools import takewhile + from sage.graphs.digraph import DiGraph from sage.matrix.constructor import matrix from sage.modules.free_module_element import vector from sage.rings.integer_ring import ZZ @@ -753,7 +805,7 @@ def prepare_inequalities(inequalities, B): inequalities_filtered = [] chain_links = {} for coeffs in inequalities: - n = len(coeffs) + dim = len(coeffs) constant = coeffs[0] ones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == 1) mones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == -1) @@ -770,19 +822,39 @@ def prepare_inequalities(inequalities, B): else: inequalities_filtered.append(coeffs) + G = DiGraph(chain_links, format='list_of_edges') + potential = {} + paths = {} D = {} - for i in range(n): + inequalities_extra = [] + for i in range(dim): D[(i, i)] = 1 - for chain in Poset((sum(chain_links, ()), chain_links)).maximal_chains(): - for cl in combinations(chain, 2): - D[cl] = 1 - constant = 0 - for cc, c in zip(chain[:-1], chain[1:]): - constant += chain_links[(cc, c)] - D[(0, c)] = -constant - T = matrix(ZZ, n, n, D) - - inequalities = list(tuple(T*vector(ieq)) for ieq in inequalities_filtered) + for v in G.topological_sort(): + NP = iter(sorted(((n, potential[n] + chain_links[(n, v)]) + for n in G.neighbor_in_iterator(v)), + key=lambda k: k[1])) + n, p = next(NP, (None, 0)) + potential[v] = p + D[(0, v)] = -p + paths[v] = paths.get(n, ()) + (v,) + for u in paths[v]: + D[(u, v)] = 1 + + for n, p in NP: + ell = len(tuple(takewhile(lambda u: u[0] == u[1], + zip(paths[n], paths[v])))) + coeffs = dim*[0] + for u in paths[v][ell:]: + coeffs[u] = 1 + for u in paths[n][ell:]: + coeffs[u] = -1 + coeffs[0] = p - potential[v] + inequalities_extra.append(tuple(coeffs)) + T = matrix(ZZ, dim, dim, D) + + inequalities = list(tuple(T*vector(ieq)) + for ieq in inequalities_filtered) + \ + inequalities_extra rules_pre = iter((y, B({tuple(row[1:]): 1})) for y, row in zip((1,) + B.gens(), T.rows())) From da47f9ac6fc4c4b0c85942003f5024634d4ffcb4 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 12:22:19 +0100 Subject: [PATCH 115/370] major rewrite to use new preparation routines --- omega.py | 88 +++++++++++++++++++++----------------------------------- 1 file changed, 32 insertions(+), 56 deletions(-) diff --git a/omega.py b/omega.py index 85ceb329a98..c4597b5f983 100644 --- a/omega.py +++ b/omega.py @@ -1118,6 +1118,7 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, import logging logger = logging.getLogger(__name__) + from sage.geometry.polyhedron.constructor import Polyhedron from sage.geometry.polyhedron.representation import Hrepresentation from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing @@ -1131,7 +1132,6 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, if split: from sage.combinat.permutation import Permutations - from sage.geometry.polyhedron.constructor import Polyhedron d = polyhedron.dim() result = [] @@ -1150,30 +1150,21 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, ph, indices=indices, split=False)) return result - def inequalities_coeffs(inequalities): - for entry in inequalities: - if isinstance(entry, (tuple, list)): - yield tuple(entry) - elif isinstance(entry, Hrepresentation): - if entry.is_inequality(): - yield tuple(entry.vector()) - elif entry.is_equation(): - e = tuple(entry.vector()) - yield e - yield tuple(-ee for ee in e) - else: - raise ValueError( - 'Cannot handle Hrepresentation {}.'.format(entry)) - else: - raise ValueError('Cannot handle {}.'.format(entry)) - try: - inequalities = polyhedron.Hrepresentation() + Hrepr = polyhedron.Hrepresentation() except AttributeError: - inequalities = polyhedron - inequalities = tuple(inequalities_coeffs(inequalities)) + Hrepr = polyhedron + #inequalities = tuple(reversed(tuple(inequalities_coeffs(inequalities)))) + + inequalities = tuple(tuple(entry) + for entry in Hrepr if entry.is_inequality()) + equations = tuple(tuple(entry) + for entry in Hrepr if entry.is_equation()) + if len(inequalities) + len(equations) != len(Hrepr): + raise ValueError('Cannot handle {}.'.format(polyhedron)) + if not inequalities: - raise ValueError('no inequality given') + raise NotImplementedError('no inequality given') if indices is None: indices = range(len(inequalities[0]) - 1) @@ -1183,52 +1174,27 @@ def inequalities_coeffs(inequalities): sparse=True) n = len(B.gens()) + 1 - if any(len(ineq) != n for ineq in inequalities): + if any(len(ieq) != n for ieq in inequalities): raise ValueError('Not all coefficient vectors of the inequalities ' 'have the same length.') + if any(len(eq) != n for eq in equations): + raise ValueError('Not all coefficient vectors of the equations ' + 'have the same length.') logger.info('generating_function_of_polyhedron: ' '%s inequalities', len(inequalities)) - def is_unit_vector(it): - found = 0 - for e in it: - if e != 0: - if e != 1: - return False - else: - found += 1 - if found >= 2: - return False - return found == 1 - - def is_aleb(it): - founda = 0 - foundb = 0 - for e in it: - if e != 0: - if abs(e) != 1: - return False - elif e == -1: - founda += 1 - if founda >= 2: - return False - elif e == 1: - foundb += 1 - if foundb >= 2: - return False - return founda == 1 and foundb == 1 - + extra_inequalities, gf_extra_factor_equations, \ + rules_equations, indices_equations = \ + prepare_equations(equations, B) + inequalities, gf_extra_factor_inequalities, rules_inequalities = \ + prepare_inequalities(inequalities, B) numerator = B(1) terms = B.gens() L = B for i, coeffs in enumerate(inequalities): - if is_unit_vector(coeffs): - logger.debug('generating_function_of_polyhedron: ' - 'skipping %s', pretty_inequality(coeffs)) - continue L = LaurentPolynomialRing(L, 'mu{}'.format(i), sparse=True) l = L.gen() logger.debug('generating_function_of_polyhedron: ' @@ -1237,6 +1203,10 @@ def is_aleb(it): numerator *= l**next(it_coeffs) assert numerator.parent() == L terms = tuple(l**c * t for c, t in zip(it_coeffs, terms)) + assert all(y == t for y, t in + (zip(B.gens(), terms)[i] for i in indices_equations)) + terms = tuple(t for i, t in enumerate(terms) + if i not in indices_equations) logger.info('generating_function_of_polyhedron: ' 'terms denominator %s', terms) @@ -1261,6 +1231,12 @@ def decode_factor(factor): _Omega_(numerator.dict(), tuple(decoded_factors)) terms = other_factors + factors_denominator + numerator = (numerator.subs(rules_inequalities) * + gf_extra_factor_inequalities).subs(rules_equations) * \ + gf_extra_factor_equations + terms = tuple(t.subs(rules_inequalities).subs(rules_equations) + for t in terms) + return Factorization([(numerator, 1)] + list((1-t, -1) for t in terms), sort=Factorization_sort, From ed13808c08c2d045a78144ea503a643f963e471a Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 12:23:23 +0100 Subject: [PATCH 116/370] fix doctests (modulo permutation of factors) --- omega.py | 87 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/omega.py b/omega.py index c4597b5f983..1ac1e1734fd 100644 --- a/omega.py +++ b/omega.py @@ -968,14 +968,11 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (1, -1, -1, 0) x - 1 >= 0, An inequality (1, 0, 0, -1) x + 0 >= 0) - (-y0^6*y1^2*y2^2*y3^3 - y0^6*y1^2*y2*y3^3 + y0^5*y1^2*y2*y3^3 + - y0^5*y1^2*y2*y3^2 + y0^4*y1*y2^2*y3^2 + 2*y0^4*y1*y2*y3^2 + - y0^4*y1*y3^2 - y0^3*y1*y2*y3^2 - y0^3*y1*y2*y3 - y0^3*y1*y3^2 - - y0^3*y1*y3 - y0^2*y2*y3 - y0^2*y3 + y0*y3 + y0) * - (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * - (-y0*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 * - (-y0^2*y1*y3 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 - [0, 1]: (An inequality (1, -1, -1, 0) x - 1 >= 0, + (-y0^2*y2*y3 - y0^2*y3 + y0*y3 + y0) * + (-y0*y1*y3 + 1)^-1 * (-y0 + 1)^-1 * (-y0*y3 + 1)^-1 * + (-y0*y2 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1]: (An equation (0, 1, 0, -1) x + 0 == 0, + An inequality (1, -1, -1, 0) x - 1 >= 0, An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (0, 0, 1, 0) x + 0 >= 0) y0 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 @@ -1028,19 +1025,21 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, (-y0*y2 + 1)^-1 * (-y0*y2*y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y2 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 * (-y0*y1^2*y3 + 1)^-1 * (-y0*y1*y2 + 1)^-1 - [0, 2]: (An inequality (-1, 1, 1, 0) x + 1 >= 0, + [0, 2]: (An equation (1, 0, -1, -1) x - 1 == 0, + An inequality (-1, 1, 1, 0) x + 1 >= 0, An inequality (1, 0, -1, 0) x - 1 >= 0, An inequality (0, 0, 1, 0) x + 0 >= 0) y0 * (-y0*y2 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [1, 2]: (An inequality (0, -1, 0, 1) x + 0 >= 0, + [1, 2]: (An equation (1, -1, -1, 0) x - 1 == 0, + An inequality (0, -1, 0, 1) x + 0 >= 0, An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (1, 0, 0, -1) x + 0 >= 0, An inequality (1, -1, 0, 0) x - 1 >= 0) - (y0^4*y1*y2^2*y3^2 - y0^3*y1*y2*y3^2 - y0^3*y1*y2*y3 - - y0^2*y2*y3 + y0*y3 + y0) * - (-y0*y1*y3 + 1)^-1 * (-y0*y2 + 1)^-1 * - (-y0*y2*y3 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 - [0, 1, 2]: (An inequality (0, 1, 0, 0) x + 0 >= 0, + (-y0^2*y2*y3 + y0*y3 + y0) * + (-y0*y1*y3 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1, 2]: (An equation (0, 1, 0, -1) x + 0 == 0, + An equation (1, -1, -1, 0) x - 1 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (1, -1, 0, 0) x - 1 >= 0) y0 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 [3]: (An inequality (-1, 0, 0, 1) x + 0 >= 0, @@ -1051,68 +1050,74 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, (-y0*y1*y3^2 - y0*y3^2 + y0*y3 + y3) * (-y0*y2*y3 + 1)^-1 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [0, 3]: () + [0, 3]: (An equation -1 == 0,) 0 - [1, 3]: (An inequality (1, -1, -1, 0) x - 1 >= 0, + [1, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, + An inequality (1, -1, -1, 0) x - 1 >= 0, An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (0, 0, 1, 0) x + 0 >= 0) y0*y3 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 3]: () + [0, 1, 3]: (An equation -1 == 0,) 0 - [2, 3]: (An inequality (1, 0, -1, 0) x + 0 >= 0, + [2, 3]: (An equation (0, 1, 1, -1) x + 1 == 0, + An inequality (1, 0, -1, 0) x + 0 >= 0, An inequality (-1, 1, 1, 0) x + 1 >= 0, An inequality (0, 0, 1, 0) x + 0 >= 0, An inequality (0, 1, 0, 0) x + 0 >= 0) - (y0^2*y1^2*y2*y3^4 - y0^2*y1*y2*y3^3 - y0*y1*y2*y3^3 - - y0*y1*y3^2 + y0*y3 + y3) * - (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 * - (-y0*y1*y3 + 1)^-1 * (-y0*y1*y2*y3^2 + 1)^-1 - [0, 2, 3]: () + (-y0*y1*y3^2 + y0*y3 + y3) * + (-y0*y2*y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [0, 2, 3]: (An equation -1 == 0,) 0 - [1, 2, 3]: (An inequality (0, 1, 0, 0) x + 0 >= 0, + [1, 2, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, + An equation (1, -1, -1, 0) x - 1 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (1, -1, 0, 0) x - 1 >= 0) y0*y3 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 2, 3]: () + [0, 1, 2, 3]: (An equation -1 == 0,) 0 [4]: (An inequality (-1, -1, 0, 1) x - 1 >= 0, An inequality (-1, 0, 1, 0) x + 0 >= 0, An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (1, 0, 0, 0) x + 0 >= 0) y3 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 4]: () + [0, 4]: (An equation -1 == 0,) 0 - [1, 4]: () + [1, 4]: (An equation -1 == 0,) 0 - [0, 1, 4]: () + [0, 1, 4]: (An equation -1 == 0,) 0 - [2, 4]: (An inequality (-1, 0, 1, 0) x + 0 >= 0, + [2, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, + An inequality (-1, 0, 1, 0) x + 0 >= 0, An inequality (1, 0, 0, 0) x + 0 >= 0, An inequality (0, 1, 0, 0) x + 0 >= 0) y3 * (-y2 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 4]: () + [0, 2, 4]: (An equation -1 == 0,) 0 - [1, 2, 4]: () + [1, 2, 4]: (An equation -1 == 0,) 0 - [0, 1, 2, 4]: () + [0, 1, 2, 4]: (An equation -1 == 0,) 0 - [3, 4]: (An inequality (0, 1, 0, 0) x + 0 >= 0, + [3, 4]: (An equation (1, 0, -1, 0) x + 0 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (-1, -1, 0, 1) x - 1 >= 0, An inequality (1, 0, 0, 0) x + 0 >= 0) y3 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 3, 4]: () + [0, 3, 4]: (An equation -1 == 0,) 0 - [1, 3, 4]: () + [1, 3, 4]: (An equation -1 == 0,) 0 - [0, 1, 3, 4]: () + [0, 1, 3, 4]: (An equation -1 == 0,) 0 - [2, 3, 4]: (An inequality (0, 1, 0, 0) x + 0 >= 0, + [2, 3, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, + An equation (1, 0, -1, 0) x + 0 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (1, 0, 0, 0) x + 0 >= 0) y3 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 3, 4]: () + [0, 2, 3, 4]: (An equation -1 == 0,) 0 - [1, 2, 3, 4]: () + [1, 2, 3, 4]: (An equation -1 == 0,) 0 - [0, 1, 2, 3, 4]: () + [0, 1, 2, 3, 4]: (An equation -1 == 0,) 0 """ import logging From f1ad1560321793f74e997af6d0547e252c822e01 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 13:02:03 +0100 Subject: [PATCH 117/370] sorting of factors --- omega.py | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/omega.py b/omega.py index 1ac1e1734fd..e1c50ff64a6 100644 --- a/omega.py +++ b/omega.py @@ -905,8 +905,10 @@ def prepare_equations(equations, B): -def generating_function_of_polyhedron(polyhedron, indices=None, split=False, - Factorization_sort=False, Factorization_simplify=False): +def generating_function_of_polyhedron( + polyhedron, indices=None, split=False, + Factorization_sort=False, Factorization_simplify=False, + sort_factors=False): r""" Return the generating function of the integer points of the polyhedron's orthant with only nonnegative coordinates. @@ -916,15 +918,15 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, sage: P2 = ( ....: Polyhedron(ieqs=[(0, 0, 0, 1), (0, 0, 1, 0), (0, 1, 0, -1)]), ....: Polyhedron(ieqs=[(0, -1, 0, 1), (0, 1, 0, 0), (0, 0, 1, 0)])) - sage: generating_function_of_polyhedron(P2[0]) - 1 * (-y1 + 1)^-1 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 - sage: generating_function_of_polyhedron(P2[1]) + sage: generating_function_of_polyhedron(P2[0], sort_factors=True) + 1 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 + sage: generating_function_of_polyhedron(P2[1], sort_factors=True) 1 * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 sage: (P2[0] & P2[1]).Hrepresentation() (An equation (1, 0, -1) x + 0 == 0, An inequality (1, 0, 0) x + 0 >= 0, An inequality (0, 1, 0) x + 0 >= 0) - sage: generating_function_of_polyhedron(P2[0] & P2[1]) + sage: generating_function_of_polyhedron(P2[0] & P2[1], sort_factors=True) 1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 :: @@ -957,20 +959,20 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, ....: continue ....: P = intersect([P3[j] for j in J]) ....: print('{}: {}'.format(J, P.Hrepresentation())) - ....: print(generating_function_of_polyhedron(P)) + ....: print(generating_function_of_polyhedron(P, sort_factors=True)) [0]: (An inequality (0, 0, 0, 1) x + 0 >= 0, An inequality (0, 0, 1, 0) x + 0 >= 0, An inequality (0, 1, 0, -1) x + 0 >= 0, An inequality (1, 0, -1, -1) x - 1 >= 0) - y0 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + y0 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 [1]: (An inequality (0, -1, 0, 1) x + 0 >= 0, An inequality (0, 0, 1, 0) x + 0 >= 0, An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (1, -1, -1, 0) x - 1 >= 0, An inequality (1, 0, 0, -1) x + 0 >= 0) (-y0^2*y2*y3 - y0^2*y3 + y0*y3 + y0) * - (-y0*y1*y3 + 1)^-1 * (-y0 + 1)^-1 * (-y0*y3 + 1)^-1 * - (-y0*y2 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y3 + 1)^-1 * + (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 [0, 1]: (An equation (0, 1, 0, -1) x + 0 == 0, An inequality (1, -1, -1, 0) x - 1 >= 0, An inequality (0, 1, 0, 0) x + 0 >= 0, @@ -1021,22 +1023,21 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, y0^2*y1*y2 - y0^2*y1*y3 - y0*y1^2*y3 - y0^2*y2*y3 - 2*y0*y1*y3^2 - y0*y1*y2 - 3*y0*y1*y3 - 2*y0*y2*y3 - y0*y2 + y0*y3 - y1*y3 + y0 + y3 + 1) * - (-y0*y1*y3 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * - (-y0*y2 + 1)^-1 * (-y0*y2*y3 + 1)^-1 * (-y1*y3 + 1)^-1 * - (-y2 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 * - (-y0*y1^2*y3 + 1)^-1 * (-y0*y1*y2 + 1)^-1 + (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y1*y3 + 1)^-1 * + (-y0*y1*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * + (-y0*y2*y3 + 1)^-1 * (-y0*y1^2*y3 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 [0, 2]: (An equation (1, 0, -1, -1) x - 1 == 0, An inequality (-1, 1, 1, 0) x + 1 >= 0, An inequality (1, 0, -1, 0) x - 1 >= 0, An inequality (0, 0, 1, 0) x + 0 >= 0) - y0 * (-y0*y2 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + y0 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 [1, 2]: (An equation (1, -1, -1, 0) x - 1 == 0, An inequality (0, -1, 0, 1) x + 0 >= 0, An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (1, 0, 0, -1) x + 0 >= 0, An inequality (1, -1, 0, 0) x - 1 >= 0) (-y0^2*y2*y3 + y0*y3 + y0) * - (-y0*y1*y3 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 [0, 1, 2]: (An equation (0, 1, 0, -1) x + 0 == 0, An equation (1, -1, -1, 0) x - 1 == 0, An inequality (0, 1, 0, 0) x + 0 >= 0, @@ -1048,8 +1049,8 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, An inequality (0, 1, 0, 0) x + 0 >= 0, An inequality (1, 0, -1, 0) x + 0 >= 0) (-y0*y1*y3^2 - y0*y3^2 + y0*y3 + y3) * - (-y0*y2*y3 + 1)^-1 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * - (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + (-y3 + 1)^-1 * (-y0*y3 + 1)^-1 * + (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 [0, 3]: (An equation -1 == 0,) 0 [1, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, @@ -1065,7 +1066,7 @@ def generating_function_of_polyhedron(polyhedron, indices=None, split=False, An inequality (0, 0, 1, 0) x + 0 >= 0, An inequality (0, 1, 0, 0) x + 0 >= 0) (-y0*y1*y3^2 + y0*y3 + y3) * - (-y0*y2*y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 [0, 2, 3]: (An equation -1 == 0,) 0 [1, 2, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, @@ -1242,6 +1243,11 @@ def decode_factor(factor): terms = tuple(t.subs(rules_inequalities).subs(rules_equations) for t in terms) + if sort_factors: + def key(t): + D = t.dict().popitem()[0] + return (-sum(abs(d) for d in D), D) + terms = sorted(terms, key=key, reverse=True) return Factorization([(numerator, 1)] + list((1-t, -1) for t in terms), sort=Factorization_sort, From 5ec87c4e353fe06d88eacf8826aa710f414cf07e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 13:04:20 +0100 Subject: [PATCH 118/370] fix some more doctests --- omega.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/omega.py b/omega.py index e1c50ff64a6..ad5f94f975f 100644 --- a/omega.py +++ b/omega.py @@ -1120,6 +1120,19 @@ def generating_function_of_polyhedron( 0 [0, 1, 2, 3, 4]: (An equation -1 == 0,) 0 + + TESTS:: + + sage: generating_function_of_polyhedron( + ....: Polyhedron(ieqs=[(0, 0, 1, 0, 0), (-1, 1, -1, 0, 0)]), + ....: sort_factors=True) + y0 * (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y0*y1 + 1)^-1 + sage: generating_function_of_polyhedron( + ....: Polyhedron(ieqs=[(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), + ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)]), + ....: sort_factors=True) + (-y0^2*y3 + y0*y3 + y0) * + (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 """ import logging logger = logging.getLogger(__name__) From 6f69a9424dfe89a02558a26c2c5def633a8d724c Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 13:06:18 +0100 Subject: [PATCH 119/370] minor rewrite prepare_equations --- omega.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/omega.py b/omega.py index ad5f94f975f..67b068c3bd8 100644 --- a/omega.py +++ b/omega.py @@ -886,17 +886,17 @@ def prepare_equations(equations, B): if not E: return 1, {}, () - cols = E.columns() - indices_nonzero = tuple(i for i, col in enumerate(cols) + indices_nonzero = tuple(i for i, col in enumerate(E.columns()) if i > 0 and not col.is_zero()) indices = indices_nonzero[-E.nrows():] indicesn = (0,) + indices_nonzero[:-E.nrows()] T = E.matrix_from_columns(indices).inverse() + TE = T*E gens = (1,) + B.gens() z = tuple(gens[i] for i in indices) - gens_cols = zip(gens, cols) - rules_pre = iter((y, y * prod(zz**(-c) for zz, c in zip(z, T*col))) + gens_cols = zip(gens, TE.columns()) + rules_pre = iter((y, y * prod(zz**(-c) for zz, c in zip(z, col))) for y, col in (gens_cols[i] for i in indicesn)) factor = next(rules_pre)[1] rules = dict(rules_pre) From 0ce001d1751fa1cba4e4d47240228918adf31d38 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 13:09:42 +0100 Subject: [PATCH 120/370] fixup --- omega.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 67b068c3bd8..6817af507e8 100644 --- a/omega.py +++ b/omega.py @@ -1203,8 +1203,7 @@ def generating_function_of_polyhedron( logger.info('generating_function_of_polyhedron: ' '%s inequalities', len(inequalities)) - extra_inequalities, gf_extra_factor_equations, \ - rules_equations, indices_equations = \ + gf_extra_factor_equations, rules_equations, indices_equations = \ prepare_equations(equations, B) inequalities, gf_extra_factor_inequalities, rules_inequalities = \ From 967f028d922d21e5a79996524eda1917fbc86b13 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 13:09:48 +0100 Subject: [PATCH 121/370] fix doctests --- omega.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 6817af507e8..41a99b4c0d8 100644 --- a/omega.py +++ b/omega.py @@ -746,11 +746,12 @@ def prepare_inequalities(inequalities, B): sage: B = LaurentPolynomialRing(ZZ, 'y', 4) sage: prepare_inequalities([(-1, 1, -1, 0, 0)], B) + ([], y0, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) sage: prepare_inequalities([(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)], B) + ([(1, 1, 0, 0, -1)], y0, {y3: y3, y2: y2, y1: y0*y1*y3, y0: y0}) sage: prepare_inequalities([(-2, 1, -1, 0, 0)], B) - sage: prepare_inequalities([(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), - ....: (0, 1, 0, 0, -1), (-2, 1, -1, 0, 0)], B) + ([], y0^2, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) @@ -875,6 +876,11 @@ def prepare_equations(equations, B): (1, {y0: y0*y2}, (2,)) sage: prepare_equations([(-1, 0, 1, -1, -1), (1, 1, 0, 1, 2)], B) (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (2, 3)) + + :: + + sage: prepare_equations([(0, 0, 1, 0, -1), (-1, 1, -1, -1, 0)], B) + (y2^-1, {y1: y1*y2^-1*y3, y0: y0*y2}, (2, 3)) """ import logging logger = logging.getLogger(__name__) From c2fefef8fc74a0594d6e14009b9721f51bf1e5ab Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 6 Dec 2016 14:31:22 +0100 Subject: [PATCH 122/370] prepare_equations: solve singular-matrix bug --- omega.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/omega.py b/omega.py index 41a99b4c0d8..be62b9b8ab0 100644 --- a/omega.py +++ b/omega.py @@ -877,10 +877,16 @@ def prepare_equations(equations, B): sage: prepare_equations([(-1, 0, 1, -1, -1), (1, 1, 0, 1, 2)], B) (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (2, 3)) - :: + TESTS:: + sage: B = LaurentPolynomialRing(ZZ, 'y', 4) sage: prepare_equations([(0, 0, 1, 0, -1), (-1, 1, -1, -1, 0)], B) (y2^-1, {y1: y1*y2^-1*y3, y0: y0*y2}, (2, 3)) + + sage: B = LaurentPolynomialRing(ZZ, 'y', 5) + sage: prepare_equations([(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), + ....: (0, 1, -1, 0, 0, 0)], B) + (1, {y2: y2*y4, y0: y0*y1*y3}, (1, 3, 4)) """ import logging logger = logging.getLogger(__name__) @@ -894,8 +900,20 @@ def prepare_equations(equations, B): indices_nonzero = tuple(i for i, col in enumerate(E.columns()) if i > 0 and not col.is_zero()) - indices = indices_nonzero[-E.nrows():] - indicesn = (0,) + indices_nonzero[:-E.nrows()] + indices = [] + r = 0 + for i in reversed(indices_nonzero): + indices.append(i) + r1 = E.matrix_from_columns(indices).rank() + if r1 > r: + r = r1 + if len(indices) >= E.nrows(): + break + else: + indices = indices[:-1] + assert len(indices) == E.nrows() + indices = tuple(reversed(indices)) + indicesn = (0,) + tuple(i for i in indices_nonzero if i not in indices) T = E.matrix_from_columns(indices).inverse() TE = T*E @@ -1139,6 +1157,13 @@ def generating_function_of_polyhedron( ....: sort_factors=True) (-y0^2*y3 + y0*y3 + y0) * (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + + sage: generating_function_of_polyhedron( + ....: Polyhedron(ieqs=[(0, 1, 0, -1, 0, 0), (0, 0, 0, 1, 0, 0)], + ....: eqns=[(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), + ....: (0, 1, -1, 0, 0, 0)]), + ....: sort_factors=True) + 1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y2*y3*y4 + 1)^-1 """ import logging logger = logging.getLogger(__name__) From 73cc648fb9b04efe4beaa5d3d100990ea771190c Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 7 Dec 2016 14:49:47 +0100 Subject: [PATCH 123/370] disjoint splitting polyhedra --- omega.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index be62b9b8ab0..41f62567b3f 100644 --- a/omega.py +++ b/omega.py @@ -1184,15 +1184,23 @@ def generating_function_of_polyhedron( from sage.combinat.permutation import Permutations d = polyhedron.dim() + if d <= 1: + raise ValueError('Cannot do splitting with only ' + 'dimension {}.'.format(d)) result = [] for pi in Permutations(d): logger.info('generating_function_of_polyhedron: ' 'split by %s', - ' <= '.join('b{}'.format(a-1) for a in pi)) + ' <= '.join('b{}'.format(a-1) for a in pi[:-1]) + + (' <= ' if pi[-2] < pi[-1] else ' < ') + + 'b{}'.format(pi[-1]-1)) ph = polyhedron & Polyhedron(ieqs= [tuple(1 if i==b else (-1 if i==a else 0) for i in range(d+1)) - for a, b in zip(pi[:-1], pi[1:])]) + for a, b in zip(pi[:-2], pi[1:-1])] + + [tuple(1 if i==pi[-1] else + (-1 if i==pi[-2] or i==0 and pi[-2] > pi[-1] else 0) + for i in range(d+1))]) logger.info('polyhedron: %s', ', '.join(h.repr_pretty(prefix='b') for h in ph.Hrepresentation())) From 1a4bc327da2c1c02af3a7b14e38690fae88d3550 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 7 Dec 2016 16:13:47 +0100 Subject: [PATCH 124/370] fix a splitting bug: use "correct" polyhedra --- omega.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/omega.py b/omega.py index 41f62567b3f..4d71b7de49d 100644 --- a/omega.py +++ b/omega.py @@ -1190,22 +1190,22 @@ def generating_function_of_polyhedron( result = [] for pi in Permutations(d): logger.info('generating_function_of_polyhedron: ' - 'split by %s', - ' <= '.join('b{}'.format(a-1) for a in pi[:-1]) + - (' <= ' if pi[-2] < pi[-1] else ' < ') + - 'b{}'.format(pi[-1]-1)) + 'split by %s%s', pi[0]-1, + ''.join((' <= ' if a < b else ' < ') + + 'b{}'.format(b-1) + for a, b in zip(pi[:-1], pi[1:]))) ph = polyhedron & Polyhedron(ieqs= - [tuple(1 if i==b else (-1 if i==a else 0) + [tuple(1 if i==b else (-1 if i==a or i==0 and a > b else 0) for i in range(d+1)) - for a, b in zip(pi[:-2], pi[1:-1])] + - [tuple(1 if i==pi[-1] else - (-1 if i==pi[-2] or i==0 and pi[-2] > pi[-1] else 0) - for i in range(d+1))]) + for a, b in zip(pi[:-1], pi[1:])]) logger.info('polyhedron: %s', ', '.join(h.repr_pretty(prefix='b') for h in ph.Hrepresentation())) result.append(generating_function_of_polyhedron( - ph, indices=indices, split=False)) + ph, indices=indices, split=False, + Factorization_sort=Factorization_sort, + Factorization_simplify=Factorization_simplify, + sort_factors=sort_factors)) return result try: From 25efbdbad5f0c1621efed100e47d8ef0db1426db Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 7 Dec 2016 16:13:56 +0100 Subject: [PATCH 125/370] doctests for splitting --- omega.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/omega.py b/omega.py index 4d71b7de49d..ce786b4d1b4 100644 --- a/omega.py +++ b/omega.py @@ -1164,6 +1164,26 @@ def generating_function_of_polyhedron( ....: (0, 1, -1, 0, 0, 0)]), ....: sort_factors=True) 1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y2*y3*y4 + 1)^-1 + + :: + + sage: G = generating_function_of_polyhedron(P2[0], sort_factors=True) + sage: S = generating_function_of_polyhedron(P2[0], sort_factors=True, + ....: split=True) + sage: sum(S) == G.value() + True + + sage: G = generating_function_of_polyhedron(P2[1], sort_factors=True) + sage: S = generating_function_of_polyhedron(P2[1], sort_factors=True, + ....: split=True) + sage: sum(S) == G.value() + True + + sage: G = generating_function_of_polyhedron(P3[0], sort_factors=True) + sage: S = generating_function_of_polyhedron(P3[0], sort_factors=True, + ....: split=True) + sage: sum(S) == G.value() + True """ import logging logger = logging.getLogger(__name__) From 2e47b415e1bd08b490c587af01d3680d2821e99b Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 9 Dec 2016 14:40:30 +0100 Subject: [PATCH 126/370] dim --> ambient_dim --- omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omega.py b/omega.py index ce786b4d1b4..9da0b82b563 100644 --- a/omega.py +++ b/omega.py @@ -1203,7 +1203,7 @@ def generating_function_of_polyhedron( if split: from sage.combinat.permutation import Permutations - d = polyhedron.dim() + d = polyhedron.ambient_dim() if d <= 1: raise ValueError('Cannot do splitting with only ' 'dimension {}.'.format(d)) From 71b61a3c63e1c99a37e3192e368ba996b5131aae Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 9 Dec 2016 14:40:39 +0100 Subject: [PATCH 127/370] missing b in logging output --- omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omega.py b/omega.py index 9da0b82b563..50e619d67e3 100644 --- a/omega.py +++ b/omega.py @@ -1210,7 +1210,7 @@ def generating_function_of_polyhedron( result = [] for pi in Permutations(d): logger.info('generating_function_of_polyhedron: ' - 'split by %s%s', pi[0]-1, + 'split by %s%s', 'b{}'.format(pi[0]-1), ''.join((' <= ' if a < b else ' < ') + 'b{}'.format(b-1) for a, b in zip(pi[:-1], pi[1:]))) From 89ecd7c36e74c8c254aa4fbdbec0907717381595 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 9 Dec 2016 14:50:27 +0100 Subject: [PATCH 128/370] simplify test for empty polyhedron --- omega.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/omega.py b/omega.py index 50e619d67e3..e57acac2a56 100644 --- a/omega.py +++ b/omega.py @@ -1194,11 +1194,6 @@ def generating_function_of_polyhedron( from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing from sage.structure.factorization import Factorization - try: - if polyhedron.is_empty(): - return Factorization([], unit=0) - except AttributeError: - pass if split: from sage.combinat.permutation import Permutations @@ -1227,6 +1222,8 @@ def generating_function_of_polyhedron( Factorization_simplify=Factorization_simplify, sort_factors=sort_factors)) return result + if polyhedron.is_empty(): + return Factorization([], unit=0) try: Hrepr = polyhedron.Hrepresentation() From 342e901204d83051d88c630e73864266765987d2 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 9 Dec 2016 14:51:02 +0100 Subject: [PATCH 129/370] rewrite code to be more structured (introduce helper _generating_function_of_polyhedron_) --- omega.py | 79 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/omega.py b/omega.py index e57acac2a56..3527f499fc6 100644 --- a/omega.py +++ b/omega.py @@ -929,10 +929,7 @@ def prepare_equations(equations, B): -def generating_function_of_polyhedron( - polyhedron, indices=None, split=False, - Factorization_sort=False, Factorization_simplify=False, - sort_factors=False): +def generating_function_of_polyhedron(polyhedron, split=False, **kwds): r""" Return the generating function of the integer points of the polyhedron's orthant with only nonnegative coordinates. @@ -1194,37 +1191,57 @@ def generating_function_of_polyhedron( from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing from sage.structure.factorization import Factorization + if polyhedron.is_empty(): + return Factorization([], unit=0) + + if split is False: + return _generating_function_of_polyhedron_(polyhedron, **kwds) + + from sage.combinat.permutation import Permutations + + d = polyhedron.ambient_dim() + if d <= 1: + raise ValueError('Cannot do splitting with only ' + 'dimension {}.'.format(d)) + result = [] + for pi in Permutations(d): + logger.info('generating_function_of_polyhedron: ' + 'split by %s%s', 'b{}'.format(pi[0]-1), + ''.join((' <= ' if a < b else ' < ') + + 'b{}'.format(b-1) + for a, b in zip(pi[:-1], pi[1:]))) + ph = polyhedron & Polyhedron(ieqs= + [tuple(1 if i==b else (-1 if i==a or i==0 and a > b else 0) + for i in range(d+1)) + for a, b in zip(pi[:-1], pi[1:])]) + logger.info('polyhedron: %s', + ', '.join(h.repr_pretty(prefix='b') + for h in ph.Hrepresentation())) + result.append(generating_function_of_polyhedron( + ph, split=False, **kwds)) + return result + + +def _generating_function_of_polyhedron_( + polyhedron, indices=None, + Factorization_sort=False, Factorization_simplify=False, + sort_factors=False): + r""" + Helper function for :func:`generating_function_of_polyhedron` which + does the actual computation of the generating function. + """ + import logging + logger = logging.getLogger(__name__) - if split: - from sage.combinat.permutation import Permutations - - d = polyhedron.ambient_dim() - if d <= 1: - raise ValueError('Cannot do splitting with only ' - 'dimension {}.'.format(d)) - result = [] - for pi in Permutations(d): - logger.info('generating_function_of_polyhedron: ' - 'split by %s%s', 'b{}'.format(pi[0]-1), - ''.join((' <= ' if a < b else ' < ') + - 'b{}'.format(b-1) - for a, b in zip(pi[:-1], pi[1:]))) - ph = polyhedron & Polyhedron(ieqs= - [tuple(1 if i==b else (-1 if i==a or i==0 and a > b else 0) - for i in range(d+1)) - for a, b in zip(pi[:-1], pi[1:])]) - logger.info('polyhedron: %s', - ', '.join(h.repr_pretty(prefix='b') - for h in ph.Hrepresentation())) - result.append(generating_function_of_polyhedron( - ph, indices=indices, split=False, - Factorization_sort=Factorization_sort, - Factorization_simplify=Factorization_simplify, - sort_factors=sort_factors)) - return result if polyhedron.is_empty(): return Factorization([], unit=0) + from sage.geometry.polyhedron.constructor import Polyhedron + from sage.geometry.polyhedron.representation import Hrepresentation + from sage.rings.integer_ring import ZZ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + from sage.structure.factorization import Factorization + try: Hrepr = polyhedron.Hrepresentation() except AttributeError: From 2f4351e4ec670585b314df2ca647067644ab7a33 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 9 Dec 2016 14:51:56 +0100 Subject: [PATCH 130/370] simplify element extraction --- omega.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/omega.py b/omega.py index 3527f499fc6..123c47ae4cc 100644 --- a/omega.py +++ b/omega.py @@ -1242,11 +1242,7 @@ def _generating_function_of_polyhedron_( from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing from sage.structure.factorization import Factorization - try: - Hrepr = polyhedron.Hrepresentation() - except AttributeError: - Hrepr = polyhedron - #inequalities = tuple(reversed(tuple(inequalities_coeffs(inequalities)))) + Hrepr = polyhedron.Hrepresentation() inequalities = tuple(tuple(entry) for entry in Hrepr if entry.is_inequality()) From accae0edf3f6c705842fab7b6a2c7eb30141fc45 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 9 Dec 2016 15:06:03 +0100 Subject: [PATCH 131/370] code restructures --- omega.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/omega.py b/omega.py index 123c47ae4cc..23823f3dee1 100644 --- a/omega.py +++ b/omega.py @@ -1185,40 +1185,40 @@ def generating_function_of_polyhedron(polyhedron, split=False, **kwds): import logging logger = logging.getLogger(__name__) + from sage.combinat.permutation import Permutations from sage.geometry.polyhedron.constructor import Polyhedron - from sage.geometry.polyhedron.representation import Hrepresentation - from sage.rings.integer_ring import ZZ - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - from sage.structure.factorization import Factorization if polyhedron.is_empty(): + from sage.structure.factorization import Factorization return Factorization([], unit=0) + logger.info('generating_function_of_polyhedron: %s', polyhedron) + if split is False: return _generating_function_of_polyhedron_(polyhedron, **kwds) - from sage.combinat.permutation import Permutations - d = polyhedron.ambient_dim() if d <= 1: raise ValueError('Cannot do splitting with only ' 'dimension {}.'.format(d)) + + if split is True: + split = iter( + (Polyhedron( + ieqs=[tuple(1 if i==b else (-1 if i==a or i==0 and a > b else 0) + for i in range(d+1)) + for a, b in zip(pi[:-1], pi[1:])]), + 'b{}'.format(pi[0]-1) + + ''.join((' <= ' if a < b else ' < ') + + 'b{}'.format(b-1) + for a, b in zip(pi[:-1], pi[1:]))) + for pi in Permutations(d)) + result = [] - for pi in Permutations(d): - logger.info('generating_function_of_polyhedron: ' - 'split by %s%s', 'b{}'.format(pi[0]-1), - ''.join((' <= ' if a < b else ' < ') + - 'b{}'.format(b-1) - for a, b in zip(pi[:-1], pi[1:]))) - ph = polyhedron & Polyhedron(ieqs= - [tuple(1 if i==b else (-1 if i==a or i==0 and a > b else 0) - for i in range(d+1)) - for a, b in zip(pi[:-1], pi[1:])]) - logger.info('polyhedron: %s', - ', '.join(h.repr_pretty(prefix='b') - for h in ph.Hrepresentation())) + for split_polyhedron, pi_log in split: + logger.info('split polyhedron by %s', pi_log) result.append(generating_function_of_polyhedron( - ph, split=False, **kwds)) + polyhedron & split_polyhedron, split=False, **kwds)) return result @@ -1233,6 +1233,9 @@ def _generating_function_of_polyhedron_( import logging logger = logging.getLogger(__name__) + logger.info('polyhedron: %s', + polyhedron.repr_pretty_Hrepresentation(prefix='b')) + if polyhedron.is_empty(): return Factorization([], unit=0) From 70b7c634e6cc9f1310f386923a41a98f183fbb82 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 9 Dec 2016 15:19:42 +0100 Subject: [PATCH 132/370] result_as_tuple option --- omega.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 23823f3dee1..f96afb667c9 100644 --- a/omega.py +++ b/omega.py @@ -929,7 +929,8 @@ def prepare_equations(equations, B): -def generating_function_of_polyhedron(polyhedron, split=False, **kwds): +def generating_function_of_polyhedron(polyhedron, split=False, + result_as_tuple=None, **kwds): r""" Return the generating function of the integer points of the polyhedron's orthant with only nonnegative coordinates. @@ -1195,7 +1196,11 @@ def generating_function_of_polyhedron(polyhedron, split=False, **kwds): logger.info('generating_function_of_polyhedron: %s', polyhedron) if split is False: - return _generating_function_of_polyhedron_(polyhedron, **kwds) + result = _generating_function_of_polyhedron_(polyhedron, **kwds) + if result_as_tuple is True: + return (result,) + else: + return result d = polyhedron.ambient_dim() if d <= 1: @@ -1219,6 +1224,8 @@ def generating_function_of_polyhedron(polyhedron, split=False, **kwds): logger.info('split polyhedron by %s', pi_log) result.append(generating_function_of_polyhedron( polyhedron & split_polyhedron, split=False, **kwds)) + if result_as_tuple is False: + raise ValueError('Cannot unpack result.') return result From b3219049a5ed07e6e69cf9a41c1d9f7285f55c04 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 10 Dec 2016 11:24:37 +0100 Subject: [PATCH 133/370] split helper function (to prepare for handling moduli) --- omega.py | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/omega.py b/omega.py index f96afb667c9..30083f57588 100644 --- a/omega.py +++ b/omega.py @@ -1218,6 +1218,9 @@ def generating_function_of_polyhedron(polyhedron, split=False, 'b{}'.format(b-1) for a, b in zip(pi[:-1], pi[1:]))) for pi in Permutations(d)) + else: + split = iter((ph, ph.repr_pretty_Hrepresentation(prefix='b')) + for ph in split) result = [] for split_polyhedron, pi_log in split: @@ -1230,9 +1233,7 @@ def generating_function_of_polyhedron(polyhedron, split=False, def _generating_function_of_polyhedron_( - polyhedron, indices=None, - Factorization_sort=False, Factorization_simplify=False, - sort_factors=False): + polyhedron, indices=None, **kwds): r""" Helper function for :func:`generating_function_of_polyhedron` which does the actual computation of the generating function. @@ -1246,12 +1247,6 @@ def _generating_function_of_polyhedron_( if polyhedron.is_empty(): return Factorization([], unit=0) - from sage.geometry.polyhedron.constructor import Polyhedron - from sage.geometry.polyhedron.representation import Hrepresentation - from sage.rings.integer_ring import ZZ - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - from sage.structure.factorization import Factorization - Hrepr = polyhedron.Hrepresentation() inequalities = tuple(tuple(entry) @@ -1266,12 +1261,8 @@ def _generating_function_of_polyhedron_( if indices is None: indices = range(len(inequalities[0]) - 1) - B = LaurentPolynomialRing( - ZZ, - tuple('y{}'.format(k) for k in indices), - sparse=True) - n = len(B.gens()) + 1 + n = len(indices) + 1 if any(len(ieq) != n for ieq in inequalities): raise ValueError('Not all coefficient vectors of the inequalities ' 'have the same length.') @@ -1282,6 +1273,30 @@ def _generating_function_of_polyhedron_( logger.info('generating_function_of_polyhedron: ' '%s inequalities', len(inequalities)) + return __generating_function_of_polyhedron__( + indices, inequalities, equations, **kwds) + + +def __generating_function_of_polyhedron__( + indices, inequalities, equations, + Factorization_sort=False, Factorization_simplify=False, + sort_factors=False): + r""" + Helper function for :func:`generating_function_of_polyhedron` which + does the actual computation of the generating function. + """ + import logging + logger = logging.getLogger(__name__) + + from sage.rings.integer_ring import ZZ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + from sage.structure.factorization import Factorization + + B = LaurentPolynomialRing( + ZZ, + tuple('y{}'.format(k) for k in indices), + sparse=True) + gf_extra_factor_equations, rules_equations, indices_equations = \ prepare_equations(equations, B) From 83e0aac3b66a5a3cb63a0b98864a24e9b84f4459 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 10 Dec 2016 12:40:48 +0100 Subject: [PATCH 134/370] prepare_mod --- omega.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/omega.py b/omega.py index 30083f57588..0a8432ff4b4 100644 --- a/omega.py +++ b/omega.py @@ -928,6 +928,39 @@ def prepare_equations(equations, B): return factor, rules, tuple(i-1 for i in indices) +def prepare_mod(mod, B, *vecs): + r""" + EXAMPLES:: + + sage: B = LaurentPolynomialRing(ZZ, 'y', 3) + sage: prepare_mod({0: (2, 1)}, B, [(1, -1, 0, 2)]) + (y0, {y2: y2, y1: y1, y0: y0^2}, ((0, -2, 0, 2),)) + sage: prepare_mod({0: (2, 1), 1: (2, 1)}, B, + ....: [(0, -1, -1, 2)], [(0, -1, 1, 0)]) + (y0*y1, {y2: y2, y1: y1^2, y0: y0^2}, + ((-2, -2, -2, 2),), ((0, -2, 2, 0),)) + """ + if not mod: + return (1, {}) + vecs + + n = len(B.gens()) + 1 + + D = {(i, i): 1 for i in range(n)} + for i, mr in iteritems(mod): + D[(i+1, i+1)] = mr[0] + D[(i+1, 0)] = mr[1] + T = matrix(ZZ, n, n, D) + + + rules_pre = iter((y, B({tuple(row[1:]): 1})) + for y, row in zip((1,) + B.gens(), T.columns())) + factor = next(rules_pre)[1] + rules = dict(rules_pre) + + vecs = tuple(tuple(tuple(vector(e)*T) for e in vec) for vec in vecs) + + return (factor, rules) + vecs + def generating_function_of_polyhedron(polyhedron, split=False, result_as_tuple=None, **kwds): From 69281a9d173caead0947e0b3832c149513e0589a Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 10 Dec 2016 12:41:00 +0100 Subject: [PATCH 135/370] minor change variables --- omega.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 0a8432ff4b4..ef886ddf152 100644 --- a/omega.py +++ b/omega.py @@ -1296,10 +1296,10 @@ def _generating_function_of_polyhedron_( indices = range(len(inequalities[0]) - 1) n = len(indices) + 1 - if any(len(ieq) != n for ieq in inequalities): + if any(len(e) != n for e in inequalities): raise ValueError('Not all coefficient vectors of the inequalities ' 'have the same length.') - if any(len(eq) != n for eq in equations): + if any(len(e) != n for e in equations): raise ValueError('Not all coefficient vectors of the equations ' 'have the same length.') From 6bb288626d25b379eafe4a41319cd316b7d862d0 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 10 Dec 2016 12:41:36 +0100 Subject: [PATCH 136/370] use new prepare_mod --- omega.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/omega.py b/omega.py index ef886ddf152..1988661392d 100644 --- a/omega.py +++ b/omega.py @@ -951,7 +951,6 @@ def prepare_mod(mod, B, *vecs): D[(i+1, 0)] = mr[1] T = matrix(ZZ, n, n, D) - rules_pre = iter((y, B({tuple(row[1:]): 1})) for y, row in zip((1,) + B.gens(), T.columns())) factor = next(rules_pre)[1] @@ -1307,11 +1306,11 @@ def _generating_function_of_polyhedron_( '%s inequalities', len(inequalities)) return __generating_function_of_polyhedron__( - indices, inequalities, equations, **kwds) + indices, inequalities, equations, {}, **kwds) def __generating_function_of_polyhedron__( - indices, inequalities, equations, + indices, inequalities, equations, mod, Factorization_sort=False, Factorization_simplify=False, sort_factors=False): r""" @@ -1321,6 +1320,7 @@ def __generating_function_of_polyhedron__( import logging logger = logging.getLogger(__name__) + from sage.matrix.constructor import matrix from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing from sage.structure.factorization import Factorization @@ -1330,8 +1330,11 @@ def __generating_function_of_polyhedron__( tuple('y{}'.format(k) for k in indices), sparse=True) + gf_extra_factor_mod, rules_mod, inequalities, equations = \ + prepare_mod(mod, B, inequalities, equations) + gf_extra_factor_equations, rules_equations, indices_equations = \ - prepare_equations(equations, B) + prepare_equations(equations, B) inequalities, gf_extra_factor_inequalities, rules_inequalities = \ prepare_inequalities(inequalities, B) From 3bdfc82a2fafcde95f80fe409f259b8458e99617 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 10 Dec 2016 12:43:42 +0100 Subject: [PATCH 137/370] simplify variable names --- omega.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/omega.py b/omega.py index 1988661392d..d26782ef6e5 100644 --- a/omega.py +++ b/omega.py @@ -1330,13 +1330,13 @@ def __generating_function_of_polyhedron__( tuple('y{}'.format(k) for k in indices), sparse=True) - gf_extra_factor_mod, rules_mod, inequalities, equations = \ + extra_factor_mod, rules_mod, inequalities, equations = \ prepare_mod(mod, B, inequalities, equations) - gf_extra_factor_equations, rules_equations, indices_equations = \ + extra_factor_equations, rules_equations, indices_equations = \ prepare_equations(equations, B) - inequalities, gf_extra_factor_inequalities, rules_inequalities = \ + inequalities, extra_factor_inequalities, rules_inequalities = \ prepare_inequalities(inequalities, B) numerator = B(1) @@ -1380,8 +1380,8 @@ def decode_factor(factor): terms = other_factors + factors_denominator numerator = (numerator.subs(rules_inequalities) * - gf_extra_factor_inequalities).subs(rules_equations) * \ - gf_extra_factor_equations + extra_factor_inequalities).subs(rules_equations) * \ + extra_factor_equations terms = tuple(t.subs(rules_inequalities).subs(rules_equations) for t in terms) From cf758ec972105e8a9bd899d9cbb3b2d73f9f1a32 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 10 Dec 2016 13:22:10 +0100 Subject: [PATCH 138/370] fix bug in Omega_higher: uni- vs. multivariate ring --- omega.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/omega.py b/omega.py index 5c176a7ae0e..2c6b101355f 100644 --- a/omega.py +++ b/omega.py @@ -364,10 +364,15 @@ def Omega_higher(a, exponents): z0*z1*z2 + z0*z2^2 + z1*z2^2 + z0*z2 + z1*z2 + 1, (z0, z1, z0*z2^3, z1*z2^6)) - :: + TESTS:: sage: Omega_higher(0, (2, 2, 1, 1, 1, 1, 1, -1, -1))[0].number_of_terms() # long time 27837 + + :: + + sage: Omega_higher(1, (2,)) + (1, (z0,)) """ import logging logger = logging.getLogger(__name__) @@ -389,9 +394,9 @@ def Omega_higher(a, exponents): B = QQ.extension(cyclotomic_polynomial(ellcm), 'zeta') zeta = B.gen() z_names = tuple('z{}'.format(i) for i in range(len(exponents))) - L = LaurentPolynomialRing(B, ('t',) + z_names) + L = LaurentPolynomialRing(B, ('t',) + z_names, len(z_names) + 1) t = L.gens()[0] - Z = LaurentPolynomialRing(ZZ, z_names) + Z = LaurentPolynomialRing(ZZ, z_names, len(z_names)) powers = {i: L(zeta**(ellcm//i)) for i in rou} powers[2] = L(-1) powers[1] = L(1) From eaa84191dde87f7ad26a100656c07d8437da89ff Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 10 Dec 2016 14:00:12 +0100 Subject: [PATCH 139/370] imports --- omega.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/omega.py b/omega.py index e97b7c55b49..b9209446d23 100644 --- a/omega.py +++ b/omega.py @@ -945,6 +945,10 @@ def prepare_mod(mod, B, *vecs): (y0*y1, {y2: y2, y1: y1^2, y0: y0^2}, ((-2, -2, -2, 2),), ((0, -2, 2, 0),)) """ + from sage.matrix.constructor import matrix + from sage.modules.free_module_element import vector + from sage.rings.integer_ring import ZZ + if not mod: return (1, {}) + vecs @@ -1325,7 +1329,6 @@ def __generating_function_of_polyhedron__( import logging logger = logging.getLogger(__name__) - from sage.matrix.constructor import matrix from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing from sage.structure.factorization import Factorization From ecfe2d0f26d2d35a89e2713e1ab2f636594503f2 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 10 Dec 2016 14:00:35 +0100 Subject: [PATCH 140/370] enable moduli --- omega.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/omega.py b/omega.py index b9209446d23..bdd428d7a53 100644 --- a/omega.py +++ b/omega.py @@ -1325,6 +1325,22 @@ def __generating_function_of_polyhedron__( r""" Helper function for :func:`generating_function_of_polyhedron` which does the actual computation of the generating function. + + TESTS:: + + sage: __generating_function_of_polyhedron__( + ....: (0, 2), [(0, 1, 0)], [(1, -1, 2)], + ....: {0: (2, 1)}, sort_factors=True) + y0 * (-y0^2*y2 + 1)^-1 + sage: __generating_function_of_polyhedron__( + ....: srange(3), [(0, 1, 0, 0), (0, 0, 1, 0)], [(1, -1, 0, 2)], + ....: {0: (2, 1)}, sort_factors=True) + y0 * (-y1 + 1)^-1 * (-y0^2*y2 + 1)^-1 + sage: __generating_function_of_polyhedron__( + ....: srange(3), [(0, 1, 0, 0), (0, -1, 1, 0)], [(0, -1, -1, 2)], + ....: {0: (2, 1), 1: (2, 1)}, sort_factors=True) + (-y0^3*y1^3*y2^3 + y0*y1*y2) * + (-y1^2*y2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 """ import logging logger = logging.getLogger(__name__) @@ -1387,11 +1403,13 @@ def decode_factor(factor): _Omega_(numerator.dict(), tuple(decoded_factors)) terms = other_factors + factors_denominator - numerator = (numerator.subs(rules_inequalities) * - extra_factor_inequalities).subs(rules_equations) * \ - extra_factor_equations - terms = tuple(t.subs(rules_inequalities).subs(rules_equations) - for t in terms) + numerator = \ + (((numerator.subs(rules_inequalities) * extra_factor_inequalities + ).subs(rules_equations) * extra_factor_equations + ).subs(rules_mod) * extra_factor_mod) + terms = tuple( + t.subs(rules_inequalities).subs(rules_equations).subs(rules_mod) + for t in terms) if sort_factors: def key(t): From d206b6150a5926b29782979b28f5b719056aeaaf Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 10 Dec 2016 14:06:52 +0100 Subject: [PATCH 141/370] enhancement on skipping inequalities --- omega.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/omega.py b/omega.py index bdd428d7a53..59ed3996470 100644 --- a/omega.py +++ b/omega.py @@ -812,18 +812,23 @@ def prepare_inequalities(inequalities, B): chain_links = {} for coeffs in inequalities: dim = len(coeffs) + if all(c >= 0 for c in coeffs): + logger.debug('generating_function_of_polyhedron: ' + 'skipping %s (all coefficients >= 0)', + pretty_inequality(coeffs)) + continue constant = coeffs[0] ones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == 1) mones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == -1) absgetwo = tuple(i+1 for i, c in enumerate(coeffs[1:]) if abs(c) >= 2) if len(ones) == 1 and not mones and not absgetwo: - if constant >= 0: - logger.debug('generating_function_of_polyhedron: ' - 'skipping %s', pretty_inequality(coeffs)) - else: + if constant < 0: # TODO: could be skipped... inequalities_filtered.append(coeffs) elif len(ones) == 1 and len(mones) == 1 and not absgetwo: + logger.debug('generating_function_of_polyhedron: ' + 'handling %s', + pretty_inequality(coeffs)) chain_links[(mones[0], ones[0])] = constant else: inequalities_filtered.append(coeffs) From ae0b71e3296dfe8a0cde60960f2b193e97df97a7 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 10 Dec 2016 14:26:28 +0100 Subject: [PATCH 142/370] split prepare_equations --- omega.py | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/omega.py b/omega.py index 59ed3996470..f4526419871 100644 --- a/omega.py +++ b/omega.py @@ -875,6 +875,38 @@ def prepare_inequalities(inequalities, B): return inequalities, factor, rules +def prepare_equations_transformation(E): + r""" + TESTS:: + + sage: prepare_equations_transformation(matrix([(0, 1, 0, -2)])) + ([ 0 -1/2 0 1], (3,), (0, 1)) + sage: prepare_equations_transformation(matrix([(0, 1, 0, -2), (0, 2, 0, -3)])) + ( + [0 1 0 0] + [0 0 0 1], (1, 3), (0,) + ) + """ + indices_nonzero = tuple(i for i, col in enumerate(E.columns()) + if i > 0 and not col.is_zero()) + indices = [] + r = 0 + for i in reversed(indices_nonzero): + indices.append(i) + r1 = E.matrix_from_columns(indices).rank() + if r1 > r: + r = r1 + if len(indices) >= E.nrows(): + break + else: + indices = indices[:-1] + assert len(indices) == E.nrows() + indices = tuple(reversed(indices)) + indicesn = (0,) + tuple(i for i in indices_nonzero if i not in indices) + TE = E.matrix_from_columns(indices).inverse() * E + return TE, indices, indicesn + + def prepare_equations(equations, B): r""" EXAMPLES:: @@ -898,9 +930,6 @@ def prepare_equations(equations, B): ....: (0, 1, -1, 0, 0, 0)], B) (1, {y2: y2*y4, y0: y0*y1*y3}, (1, 3, 4)) """ - import logging - logger = logging.getLogger(__name__) - from sage.matrix.constructor import matrix from sage.misc.misc_c import prod @@ -908,24 +937,7 @@ def prepare_equations(equations, B): if not E: return 1, {}, () - indices_nonzero = tuple(i for i, col in enumerate(E.columns()) - if i > 0 and not col.is_zero()) - indices = [] - r = 0 - for i in reversed(indices_nonzero): - indices.append(i) - r1 = E.matrix_from_columns(indices).rank() - if r1 > r: - r = r1 - if len(indices) >= E.nrows(): - break - else: - indices = indices[:-1] - assert len(indices) == E.nrows() - indices = tuple(reversed(indices)) - indicesn = (0,) + tuple(i for i in indices_nonzero if i not in indices) - T = E.matrix_from_columns(indices).inverse() - TE = T*E + TE, indices, indicesn = prepare_equations_transformation(E) gens = (1,) + B.gens() z = tuple(gens[i] for i in indices) From 3cf8a1201e1c7325ecbf112a100975e86277406e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 10:20:23 +0100 Subject: [PATCH 143/370] compositions_mod --- omega.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/omega.py b/omega.py index f4526419871..b4a87131620 100644 --- a/omega.py +++ b/omega.py @@ -1290,6 +1290,48 @@ def generating_function_of_polyhedron(polyhedron, split=False, return result +def compositions_mod(u, m, r=0): + r""" + Return an iterable of tuples `a` such that `a u \equiv r \mod m`. + + INPUT: + + - ``u`` -- the coefficients as a tuple. + + - ``m`` -- the modulus as a positive integer. + + - ``r`` -- the remainder as a nonnegative integer. + + OUTPUT: + + An iterable of tuples; all these tuples have the same size as ``u``. + + EXAMPLES:: + + sage: list(compositions_mod([1, 1], 2)) + [(0, 0), (1, 1)] + sage: list(compositions_mod([1, 2, 3], 6)) + [(0, 0, 0), (1, 1, 1), (2, 2, 0), (3, 0, 1), (4, 1, 0), (5, 2, 1)] + + TESTS:: + + sage: list(compositions_mod([1, 0], 2)) + [(0, 0)] + """ + if not u: + if r == 0: + yield () + return + + from sage.arith.srange import srange + from sage.rings.finite_rings.integer_mod_ring import Zmod + + v = Zmod(m)(u[0]) + for j in srange(v.order()): + for a in compositions_mod(u[1:], m, r-j*v): + yield (j,) + a + + def _generating_function_of_polyhedron_( polyhedron, indices=None, **kwds): r""" From 29ddb8c2aae1194980ea367a60320ca836b965e6 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 10:41:12 +0100 Subject: [PATCH 144/370] compositions_mod: prepare for multidimensional --- omega.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/omega.py b/omega.py index b4a87131620..228b37eea8e 100644 --- a/omega.py +++ b/omega.py @@ -1290,9 +1290,9 @@ def generating_function_of_polyhedron(polyhedron, split=False, return result -def compositions_mod(u, m, r=0): +def compositions_mod(u, m, r=0, multidimensional=False): r""" - Return an iterable of tuples `a` such that `a u \equiv r \mod m`. + Return an iterable of tuples `a` such that `a u^T \equiv r \mod m`. INPUT: @@ -1318,17 +1318,30 @@ def compositions_mod(u, m, r=0): sage: list(compositions_mod([1, 0], 2)) [(0, 0)] """ + from sage.modules.free_module_element import vector + from sage.rings.finite_rings.integer_mod_ring import Zmod + + Z = Zmod(m) + if multidimensional: + raise NotImplementedError + else: + return _compositions_mod_(tuple(vector([Z(uu)]) for uu in u), + vector([Z(r)])) + + +def _compositions_mod_(u, r): if not u: - if r == 0: + if all(rr == 0 for rr in r): yield () return + from itertools import product from sage.arith.srange import srange - from sage.rings.finite_rings.integer_mod_ring import Zmod + from sage.modules.free_module_element import vector - v = Zmod(m)(u[0]) - for j in srange(v.order()): - for a in compositions_mod(u[1:], m, r-j*v): + v = u[0] + for j in srange(max(vv.order() for vv in v)): + for a in _compositions_mod_(u[1:], r - j*v): yield (j,) + a From f1bebc9f937918a6a4cbc99426358bcf92a2505a Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 10:56:08 +0100 Subject: [PATCH 145/370] multidimensional compositions_mod --- omega.py | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/omega.py b/omega.py index 228b37eea8e..9a2f7c257d0 100644 --- a/omega.py +++ b/omega.py @@ -1296,11 +1296,23 @@ def compositions_mod(u, m, r=0, multidimensional=False): INPUT: + - ``m`` -- the modulus as a positive integer. + + - ``multidimensional`` -- (default: ``False``) a boolean. + + If ``multidimensional=False``: + - ``u`` -- the coefficients as a tuple. - - ``m`` -- the modulus as a positive integer. + - ``r`` -- (default: `0`) + the remainder as a nonnegative integer. + + If ``multidimensional=True``: + + - ``u`` -- the coefficients as a tuple of tuples (read column-wise). - - ``r`` -- the remainder as a nonnegative integer. + - ``r`` -- (default: the zero vector) + the remainder as a tuple of nonnegative integers. OUTPUT: @@ -1312,6 +1324,18 @@ def compositions_mod(u, m, r=0, multidimensional=False): [(0, 0), (1, 1)] sage: list(compositions_mod([1, 2, 3], 6)) [(0, 0, 0), (1, 1, 1), (2, 2, 0), (3, 0, 1), (4, 1, 0), (5, 2, 1)] + sage: list(compositions_mod([2, 2, 2], 6)) + [(0, 0, 0), (0, 1, 2), (0, 2, 1), (1, 0, 2), + (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0), (2, 2, 2)] + + :: + + sage: list(compositions_mod([(1, 0), (0, 1)], 2, + ....: multidimensional=True)) + [(0, 0)] + sage: list(compositions_mod([(1, 2), (2, 2), (3, 2)], 6, + ....: multidimensional=True)) + [(0, 0, 0), (1, 1, 1), (2, 2, 2)] TESTS:: @@ -1322,11 +1346,17 @@ def compositions_mod(u, m, r=0, multidimensional=False): from sage.rings.finite_rings.integer_mod_ring import Zmod Z = Zmod(m) - if multidimensional: - raise NotImplementedError + if not multidimensional: + u = tuple(vector([Z(uu)]) for uu in u) + r = vector([Z(r)]) else: - return _compositions_mod_(tuple(vector([Z(uu)]) for uu in u), - vector([Z(r)])) + u = tuple(vector(Z(uuu) for uuu in uu) for uu in u) + if r == 0: + r = vector(Z(0) for _ in range(len(u[0]))) + else: + r = vector(Z(rr) for rr in r) + + return _compositions_mod_(u, r) def _compositions_mod_(u, r): From 9b0ed978d0a4cfc3aaceff0995e2e75edd57dfe8 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 11:59:07 +0100 Subject: [PATCH 146/370] compositions_mod: make values in output residue classes (instead of plain integers) --- omega.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 9a2f7c257d0..5a5884e784c 100644 --- a/omega.py +++ b/omega.py @@ -1368,11 +1368,14 @@ def _compositions_mod_(u, r): from itertools import product from sage.arith.srange import srange from sage.modules.free_module_element import vector + from sage.rings.finite_rings.integer_mod_ring import Zmod v = u[0] - for j in srange(max(vv.order() for vv in v)): + m = max(vv.order() for vv in v) + Z = Zmod(m) + for j in srange(m): for a in _compositions_mod_(u[1:], r - j*v): - yield (j,) + a + yield (Z(j),) + a def _generating_function_of_polyhedron_( From 2a6484af5fba37dbbe421fe4c85adeeaa6c4bebf Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 11:59:29 +0100 Subject: [PATCH 147/370] rewrite one doctest in prepare_equations --- omega.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/omega.py b/omega.py index 5a5884e784c..1b70ea6aa2f 100644 --- a/omega.py +++ b/omega.py @@ -881,10 +881,10 @@ def prepare_equations_transformation(E): sage: prepare_equations_transformation(matrix([(0, 1, 0, -2)])) ([ 0 -1/2 0 1], (3,), (0, 1)) - sage: prepare_equations_transformation(matrix([(0, 1, 0, -2), (0, 2, 0, -3)])) + sage: prepare_equations_transformation(matrix([(0, 1, -2, 0), (0, 2, 0, -3)])) ( - [0 1 0 0] - [0 0 0 1], (1, 3), (0,) + [ 0 -1/2 1 0] + [ 0 -2/3 0 1], (2, 3), (0, 1) ) """ indices_nonzero = tuple(i for i, col in enumerate(E.columns()) From e061c4cd621930ec7fc63a237c7d51edc4cb8d79 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 12:00:21 +0100 Subject: [PATCH 148/370] rewrite to handle implicit congruence relations coming from equations --- omega.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 1b70ea6aa2f..e600256134b 100644 --- a/omega.py +++ b/omega.py @@ -1387,6 +1387,10 @@ def _generating_function_of_polyhedron_( import logging logger = logging.getLogger(__name__) + from sage.matrix.constructor import matrix + from sage.rings.integer_ring import ZZ + from sage.rings.rational_field import QQ + logger.info('polyhedron: %s', polyhedron.repr_pretty_Hrepresentation(prefix='b')) @@ -1419,8 +1423,29 @@ def _generating_function_of_polyhedron_( logger.info('generating_function_of_polyhedron: ' '%s inequalities', len(inequalities)) - return __generating_function_of_polyhedron__( - indices, inequalities, equations, {}, **kwds) + TE, TEi, TEin = prepare_equations_transformation(matrix(equations)) + if TE.base_ring() == ZZ: + mods = [{}] + elif TE.base_ring() == QQ: + m = lcm([e.denominator() for e in TE.list()]) + if m == 1: + mods = [{}] + else: + cols = TE.columns() + assert all(cols[j][i] == 1 for i, j in enumerate(TEi)) + pre_mods = compositions_mod((tuple(ZZ(cc*m) for cc in cols[i]) + for i in TEin), + m, r=(-cc for cc in cols[0]), + multidimensional=True) + mods = tuple({i-1: (aa.modulus(), ZZ(aa)) + for i, aa in zip(TEin, a) if aa.modulus() > 1} + for a in pre_mods) + else: + raise TypeError('Equations over ZZ or QQ expected, but got ' + 'equations over {}.'.format(TE.base_ring())) + + return tuple(__generating_function_of_polyhedron__( + indices, inequalities, equations, mod, **kwds) for mod in mods) def __generating_function_of_polyhedron__( From 55517a59991ce2162ee5cea02bb64068f5a2d74e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 12:18:23 +0100 Subject: [PATCH 149/370] handle return values (tuple or not) correctly --- omega.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/omega.py b/omega.py index e600256134b..0932d14aa2a 100644 --- a/omega.py +++ b/omega.py @@ -1247,18 +1247,28 @@ def generating_function_of_polyhedron(polyhedron, split=False, from sage.combinat.permutation import Permutations from sage.geometry.polyhedron.constructor import Polyhedron + if result_as_tuple is None: + result_as_tuple = split + if polyhedron.is_empty(): from sage.structure.factorization import Factorization - return Factorization([], unit=0) + result = Factorization([], unit=0) + if result_as_tuple: + return (result,) + else: + return result logger.info('generating_function_of_polyhedron: %s', polyhedron) if split is False: result = _generating_function_of_polyhedron_(polyhedron, **kwds) - if result_as_tuple is True: - return (result,) - else: + if result_as_tuple: return result + else: + if len(result) != 1: + raise ValueError("Cannot unpack result. " + "(Set 'result_as_tuple=True'.)") + return result[0] d = polyhedron.ambient_dim() if d <= 1: @@ -1283,11 +1293,12 @@ def generating_function_of_polyhedron(polyhedron, split=False, result = [] for split_polyhedron, pi_log in split: logger.info('split polyhedron by %s', pi_log) - result.append(generating_function_of_polyhedron( - polyhedron & split_polyhedron, split=False, **kwds)) - if result_as_tuple is False: - raise ValueError('Cannot unpack result.') - return result + result.append(_generating_function_of_polyhedron_( + polyhedron & split_polyhedron, **kwds)) + if not result_as_tuple: + raise ValueError("Cannot unpack result." + "(Unset 'result_as_tuple=False'.)") + return sum(result, ()) def compositions_mod(u, m, r=0, multidimensional=False): @@ -1395,7 +1406,7 @@ def _generating_function_of_polyhedron_( polyhedron.repr_pretty_Hrepresentation(prefix='b')) if polyhedron.is_empty(): - return Factorization([], unit=0) + return (Factorization([], unit=0),) Hrepr = polyhedron.Hrepresentation() From 99a0fde1751dec09cd83fd471bed161a20f38ce0 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 12:39:58 +0100 Subject: [PATCH 150/370] class Summandization --- omega.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/omega.py b/omega.py index 0932d14aa2a..2166ce8a2e9 100644 --- a/omega.py +++ b/omega.py @@ -730,6 +730,13 @@ def pretty_inequality(ineq, indices=None): return '{} >= {}'.format(positive_part*vars, negative_part*vars) +class Summandization(tuple): + def __repr__(self): + return ' + '.join(repr(s) for s in self) + + __str__ = __repr__ + + def prepare_inequalities(inequalities, B): r""" EXAMPLES:: @@ -1254,7 +1261,7 @@ def generating_function_of_polyhedron(polyhedron, split=False, from sage.structure.factorization import Factorization result = Factorization([], unit=0) if result_as_tuple: - return (result,) + return Summandization((result,)) else: return result @@ -1263,7 +1270,7 @@ def generating_function_of_polyhedron(polyhedron, split=False, if split is False: result = _generating_function_of_polyhedron_(polyhedron, **kwds) if result_as_tuple: - return result + return Summandization(result) else: if len(result) != 1: raise ValueError("Cannot unpack result. " @@ -1298,7 +1305,7 @@ def generating_function_of_polyhedron(polyhedron, split=False, if not result_as_tuple: raise ValueError("Cannot unpack result." "(Unset 'result_as_tuple=False'.)") - return sum(result, ()) + return Summandization(sum(result, ())) def compositions_mod(u, m, r=0, multidimensional=False): From d15d4302b44ff8b88244f00436d69aad8ff5975c Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 12:40:54 +0100 Subject: [PATCH 151/370] doctesting gf of polyhedron where implicit congruences needed --- omega.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/omega.py b/omega.py index 2166ce8a2e9..52929785c91 100644 --- a/omega.py +++ b/omega.py @@ -1401,6 +1401,17 @@ def _generating_function_of_polyhedron_( r""" Helper function for :func:`generating_function_of_polyhedron` which does the actual computation of the generating function. + + TESTS:: + + sage: generating_function_of_polyhedron( # indirect doctest + ....: Polyhedron(ieqs=[(0, 1, 0, 0), (0, -1, 1, 0)], + ....: eqns=[(0, -1, -1, 2)]), + ....: result_as_tuple=True, sort_factors=True) + (-y0^2*y1^2*y2^2 + 1) * (-y1^2*y2 + 1)^-1 * + (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 + + (-y0^3*y1^3*y2^3 + y0*y1*y2) * (-y1^2*y2 + 1)^-1 * + (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 """ import logging logger = logging.getLogger(__name__) From c700bdd631d5bc3d8ecd7a14cb8d4e467c8e4f09 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 12:47:32 +0100 Subject: [PATCH 152/370] fix imports --- omega.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/omega.py b/omega.py index 52929785c91..86183fd91de 100644 --- a/omega.py +++ b/omega.py @@ -1416,6 +1416,7 @@ def _generating_function_of_polyhedron_( import logging logger = logging.getLogger(__name__) + from sage.arith.misc import lcm from sage.matrix.constructor import matrix from sage.rings.integer_ring import ZZ from sage.rings.rational_field import QQ @@ -1424,6 +1425,7 @@ def _generating_function_of_polyhedron_( polyhedron.repr_pretty_Hrepresentation(prefix='b')) if polyhedron.is_empty(): + from sage.structure.factorization import Factorization return (Factorization([], unit=0),) Hrepr = polyhedron.Hrepresentation() From 6ce002fa60576cc6bbf7c088f6ca1ba7cedc9a5d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 12:53:09 +0100 Subject: [PATCH 153/370] small bug fix calling compositions_mod --- omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omega.py b/omega.py index 86183fd91de..909e8bf4218 100644 --- a/omega.py +++ b/omega.py @@ -1466,7 +1466,7 @@ def _generating_function_of_polyhedron_( assert all(cols[j][i] == 1 for i, j in enumerate(TEi)) pre_mods = compositions_mod((tuple(ZZ(cc*m) for cc in cols[i]) for i in TEin), - m, r=(-cc for cc in cols[0]), + m, r=(-cc*m for cc in cols[0]), multidimensional=True) mods = tuple({i-1: (aa.modulus(), ZZ(aa)) for i, aa in zip(TEin, a) if aa.modulus() > 1} From 47411b852e7944135761e12764b2d07278dabca2 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 13:00:58 +0100 Subject: [PATCH 154/370] small bug fix in getting congruences: deal with index of first column --- omega.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/omega.py b/omega.py index 909e8bf4218..53f71f47081 100644 --- a/omega.py +++ b/omega.py @@ -1455,6 +1455,7 @@ def _generating_function_of_polyhedron_( '%s inequalities', len(inequalities)) TE, TEi, TEin = prepare_equations_transformation(matrix(equations)) + TEin = TEin[1:] if TE.base_ring() == ZZ: mods = [{}] elif TE.base_ring() == QQ: @@ -1475,6 +1476,8 @@ def _generating_function_of_polyhedron_( raise TypeError('Equations over ZZ or QQ expected, but got ' 'equations over {}.'.format(TE.base_ring())) + logger.info('splitting by moduli %s', mods) + return tuple(__generating_function_of_polyhedron__( indices, inequalities, equations, mod, **kwds) for mod in mods) From 8ee492cc10785eb89e83508a3bdb7f8ddf7ea02d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 11 Dec 2016 15:47:22 +0100 Subject: [PATCH 155/370] restructure (create subfunction generate_mods) --- omega.py | 59 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/omega.py b/omega.py index 53f71f47081..5cc02e01938 100644 --- a/omega.py +++ b/omega.py @@ -957,6 +957,37 @@ def prepare_equations(equations, B): return factor, rules, tuple(i-1 for i in indices) +def generate_mods(equations): + from sage.arith.misc import lcm + from sage.matrix.constructor import matrix + from sage.rings.integer_ring import ZZ + from sage.rings.rational_field import QQ + + TE, TEi, TEin = prepare_equations_transformation(matrix(equations)) + TEin = TEin[1:] + if TE.base_ring() == ZZ: + mods = [{}] + elif TE.base_ring() == QQ: + m = lcm([e.denominator() for e in TE.list()]) + if m == 1: + mods = [{}] + else: + cols = TE.columns() + assert all(cols[j][i] == 1 for i, j in enumerate(TEi)) + pre_mods = compositions_mod((tuple(ZZ(cc*m) for cc in cols[i]) + for i in TEin), + m, r=(-cc*m for cc in cols[0]), + multidimensional=True) + mods = tuple({i-1: (aa.modulus(), ZZ(aa)) + for i, aa in zip(TEin, a) if aa.modulus() > 1} + for a in pre_mods) + else: + raise TypeError('Equations over ZZ or QQ expected, but got ' + 'equations over {}.'.format(TE.base_ring())) + + return mods + + def prepare_mod(mod, B, *vecs): r""" EXAMPLES:: @@ -1416,11 +1447,6 @@ def _generating_function_of_polyhedron_( import logging logger = logging.getLogger(__name__) - from sage.arith.misc import lcm - from sage.matrix.constructor import matrix - from sage.rings.integer_ring import ZZ - from sage.rings.rational_field import QQ - logger.info('polyhedron: %s', polyhedron.repr_pretty_Hrepresentation(prefix='b')) @@ -1454,28 +1480,7 @@ def _generating_function_of_polyhedron_( logger.info('generating_function_of_polyhedron: ' '%s inequalities', len(inequalities)) - TE, TEi, TEin = prepare_equations_transformation(matrix(equations)) - TEin = TEin[1:] - if TE.base_ring() == ZZ: - mods = [{}] - elif TE.base_ring() == QQ: - m = lcm([e.denominator() for e in TE.list()]) - if m == 1: - mods = [{}] - else: - cols = TE.columns() - assert all(cols[j][i] == 1 for i, j in enumerate(TEi)) - pre_mods = compositions_mod((tuple(ZZ(cc*m) for cc in cols[i]) - for i in TEin), - m, r=(-cc*m for cc in cols[0]), - multidimensional=True) - mods = tuple({i-1: (aa.modulus(), ZZ(aa)) - for i, aa in zip(TEin, a) if aa.modulus() > 1} - for a in pre_mods) - else: - raise TypeError('Equations over ZZ or QQ expected, but got ' - 'equations over {}.'.format(TE.base_ring())) - + mods = generate_mods(equations) logger.info('splitting by moduli %s', mods) return tuple(__generating_function_of_polyhedron__( From e394f3530b6de701000ae47959f7b00c7157832e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 13 Dec 2016 14:34:15 +0100 Subject: [PATCH 156/370] split off generating_function_of_polyhedron (to separate file) --- generating_function_of_polyhedron.py | 889 +++++++++++++++++++++++++++ omega.py | 875 -------------------------- 2 files changed, 889 insertions(+), 875 deletions(-) create mode 100644 generating_function_of_polyhedron.py diff --git a/generating_function_of_polyhedron.py b/generating_function_of_polyhedron.py new file mode 100644 index 00000000000..6bac2569ff2 --- /dev/null +++ b/generating_function_of_polyhedron.py @@ -0,0 +1,889 @@ + +# ***************************************************************************** +# Copyright (C) 2016 Daniel Krenn +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +# ***************************************************************************** + +from __future__ import print_function +from __future__ import absolute_import +from six import iteritems, itervalues + + +def pretty_inequality(ineq, indices=None): + from sage.symbolic.ring import SR + from sage.modules.free_module_element import vector + + if indices is None: + indices = range(len(ineq)-1) + vars = vector([1] + list(SR("b{}".format(i)) for i in indices)) + v = vector(ineq) + positive_part = vector([max(c, 0) for c in v]) + negative_part = - (v - positive_part) + assert v == positive_part - negative_part + return '{} >= {}'.format(positive_part*vars, negative_part*vars) + + +class Summandization(tuple): + def __repr__(self): + return ' + '.join(repr(s) for s in self) + + __str__ = __repr__ + + +def prepare_inequalities(inequalities, B): + r""" + EXAMPLES:: + + sage: B = LaurentPolynomialRing(ZZ, 'y', 3) + sage: prepare_inequalities([(0, -1, 1, 0), (2, -1, -1, 1)], B) + ([(2, -2, -1, 1)], 1, {y2: y2, y1: y1, y0: y0*y1}) + sage: prepare_inequalities([(-1, -1, 1, 0), (2, -1, -1, 1)], B) + ([(1, -2, -1, 1)], y1, {y2: y2, y1: y1, y0: y0*y1}) + sage: prepare_inequalities([(2, -1, 1, 0), (2, -1, -1, 1)], B) + ([(4, -2, -1, 1)], y1^-2, {y2: y2, y1: y1, y0: y0*y1}) + + TESTS:: + + sage: B = LaurentPolynomialRing(ZZ, 'y', 3) + sage: prepare_inequalities([(1, 1, -1, 0), (1, -1, 0, 1), + ....: (2, -1, -1, 3)], B) + ([(-3, 2, 1, 3)], y0^-1*y2^-2, {y2: y2, y1: y0*y1*y2, y0: y0*y2}) + + sage: B = LaurentPolynomialRing(ZZ, 'y', 4) + sage: prepare_inequalities([(-1, 1, -1, 0, 0)], B) + ([], y0, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) + sage: prepare_inequalities([(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), + ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)], B) + ([(1, 1, 0, 0, -1)], y0, {y3: y3, y2: y2, y1: y0*y1*y3, y0: y0}) + sage: prepare_inequalities([(-2, 1, -1, 0, 0)], B) + ([], y0^2, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) + + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), + ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y2^3*y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), + ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y2^2*y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y1^2*y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y1^3*y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y1^2*y2^3*y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y1^3*y2^2*y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + """ + import logging + logger = logging.getLogger(__name__) + + from itertools import takewhile + from sage.graphs.digraph import DiGraph + from sage.matrix.constructor import matrix + from sage.modules.free_module_element import vector + from sage.rings.integer_ring import ZZ + + inequalities_filtered = [] + chain_links = {} + for coeffs in inequalities: + dim = len(coeffs) + if all(c >= 0 for c in coeffs): + logger.debug('generating_function_of_polyhedron: ' + 'skipping %s (all coefficients >= 0)', + pretty_inequality(coeffs)) + continue + constant = coeffs[0] + ones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == 1) + mones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == -1) + absgetwo = tuple(i+1 for i, c in enumerate(coeffs[1:]) if abs(c) >= 2) + if len(ones) == 1 and not mones and not absgetwo: + if constant < 0: + # TODO: could be skipped... + inequalities_filtered.append(coeffs) + elif len(ones) == 1 and len(mones) == 1 and not absgetwo: + logger.debug('generating_function_of_polyhedron: ' + 'handling %s', + pretty_inequality(coeffs)) + chain_links[(mones[0], ones[0])] = constant + else: + inequalities_filtered.append(coeffs) + + G = DiGraph(chain_links, format='list_of_edges') + potential = {} + paths = {} + D = {} + inequalities_extra = [] + for i in range(dim): + D[(i, i)] = 1 + for v in G.topological_sort(): + NP = iter(sorted(((n, potential[n] + chain_links[(n, v)]) + for n in G.neighbor_in_iterator(v)), + key=lambda k: k[1])) + n, p = next(NP, (None, 0)) + potential[v] = p + D[(0, v)] = -p + paths[v] = paths.get(n, ()) + (v,) + for u in paths[v]: + D[(u, v)] = 1 + + for n, p in NP: + ell = len(tuple(takewhile(lambda u: u[0] == u[1], + zip(paths[n], paths[v])))) + coeffs = dim*[0] + for u in paths[v][ell:]: + coeffs[u] = 1 + for u in paths[n][ell:]: + coeffs[u] = -1 + coeffs[0] = p - potential[v] + inequalities_extra.append(tuple(coeffs)) + T = matrix(ZZ, dim, dim, D) + + inequalities = list(tuple(T*vector(ieq)) + for ieq in inequalities_filtered) + \ + inequalities_extra + + rules_pre = iter((y, B({tuple(row[1:]): 1})) + for y, row in zip((1,) + B.gens(), T.rows())) + factor = next(rules_pre)[1] + rules = dict(rules_pre) + + return inequalities, factor, rules + + +def prepare_equations_transformation(E): + r""" + TESTS:: + + sage: prepare_equations_transformation(matrix([(0, 1, 0, -2)])) + ([ 0 -1/2 0 1], (3,), (0, 1)) + sage: prepare_equations_transformation(matrix([(0, 1, -2, 0), (0, 2, 0, -3)])) + ( + [ 0 -1/2 1 0] + [ 0 -2/3 0 1], (2, 3), (0, 1) + ) + """ + indices_nonzero = tuple(i for i, col in enumerate(E.columns()) + if i > 0 and not col.is_zero()) + indices = [] + r = 0 + for i in reversed(indices_nonzero): + indices.append(i) + r1 = E.matrix_from_columns(indices).rank() + if r1 > r: + r = r1 + if len(indices) >= E.nrows(): + break + else: + indices = indices[:-1] + assert len(indices) == E.nrows() + indices = tuple(reversed(indices)) + indicesn = (0,) + tuple(i for i in indices_nonzero if i not in indices) + TE = E.matrix_from_columns(indices).inverse() * E + return TE, indices, indicesn + + +def prepare_equations(equations, B): + r""" + EXAMPLES:: + + sage: B = LaurentPolynomialRing(ZZ, 'y', 4) + sage: prepare_equations([(1, 1, 1, -1, 0)], B) + (y2, {y1: y1*y2, y0: y0*y2}, (2,)) + sage: prepare_equations([(0, 1, 0, -1, 0)], B) + (1, {y0: y0*y2}, (2,)) + sage: prepare_equations([(-1, 0, 1, -1, -1), (1, 1, 0, 1, 2)], B) + (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (2, 3)) + + TESTS:: + + sage: B = LaurentPolynomialRing(ZZ, 'y', 4) + sage: prepare_equations([(0, 0, 1, 0, -1), (-1, 1, -1, -1, 0)], B) + (y2^-1, {y1: y1*y2^-1*y3, y0: y0*y2}, (2, 3)) + + sage: B = LaurentPolynomialRing(ZZ, 'y', 5) + sage: prepare_equations([(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), + ....: (0, 1, -1, 0, 0, 0)], B) + (1, {y2: y2*y4, y0: y0*y1*y3}, (1, 3, 4)) + """ + from sage.matrix.constructor import matrix + from sage.misc.misc_c import prod + + E = matrix(equations) + if not E: + return 1, {}, () + + TE, indices, indicesn = prepare_equations_transformation(E) + + gens = (1,) + B.gens() + z = tuple(gens[i] for i in indices) + gens_cols = zip(gens, TE.columns()) + rules_pre = iter((y, y * prod(zz**(-c) for zz, c in zip(z, col))) + for y, col in (gens_cols[i] for i in indicesn)) + factor = next(rules_pre)[1] + rules = dict(rules_pre) + + return factor, rules, tuple(i-1 for i in indices) + + +def generate_mods(equations): + from sage.arith.misc import lcm + from sage.matrix.constructor import matrix + from sage.rings.integer_ring import ZZ + from sage.rings.rational_field import QQ + + TE, TEi, TEin = prepare_equations_transformation(matrix(equations)) + TEin = TEin[1:] + if TE.base_ring() == ZZ: + mods = [{}] + elif TE.base_ring() == QQ: + m = lcm([e.denominator() for e in TE.list()]) + if m == 1: + mods = [{}] + else: + cols = TE.columns() + assert all(cols[j][i] == 1 for i, j in enumerate(TEi)) + pre_mods = compositions_mod((tuple(ZZ(cc*m) for cc in cols[i]) + for i in TEin), + m, r=(-cc*m for cc in cols[0]), + multidimensional=True) + mods = tuple({i-1: (aa.modulus(), ZZ(aa)) + for i, aa in zip(TEin, a) if aa.modulus() > 1} + for a in pre_mods) + else: + raise TypeError('Equations over ZZ or QQ expected, but got ' + 'equations over {}.'.format(TE.base_ring())) + + return mods + + +def prepare_mod(mod, B, *vecs): + r""" + EXAMPLES:: + + sage: B = LaurentPolynomialRing(ZZ, 'y', 3) + sage: prepare_mod({0: (2, 1)}, B, [(1, -1, 0, 2)]) + (y0, {y2: y2, y1: y1, y0: y0^2}, ((0, -2, 0, 2),)) + sage: prepare_mod({0: (2, 1), 1: (2, 1)}, B, + ....: [(0, -1, -1, 2)], [(0, -1, 1, 0)]) + (y0*y1, {y2: y2, y1: y1^2, y0: y0^2}, + ((-2, -2, -2, 2),), ((0, -2, 2, 0),)) + """ + from sage.matrix.constructor import matrix + from sage.modules.free_module_element import vector + from sage.rings.integer_ring import ZZ + + if not mod: + return (1, {}) + vecs + + n = len(B.gens()) + 1 + + D = {(i, i): 1 for i in range(n)} + for i, mr in iteritems(mod): + D[(i+1, i+1)] = mr[0] + D[(i+1, 0)] = mr[1] + T = matrix(ZZ, n, n, D) + + rules_pre = iter((y, B({tuple(row[1:]): 1})) + for y, row in zip((1,) + B.gens(), T.columns())) + factor = next(rules_pre)[1] + rules = dict(rules_pre) + + vecs = tuple(tuple(tuple(vector(e)*T) for e in vec) for vec in vecs) + + return (factor, rules) + vecs + + +def generating_function_of_polyhedron(polyhedron, split=False, + result_as_tuple=None, **kwds): + r""" + Return the generating function of the integer points of + the polyhedron's orthant with only nonnegative coordinates. + + EXAMPLES:: + + sage: P2 = ( + ....: Polyhedron(ieqs=[(0, 0, 0, 1), (0, 0, 1, 0), (0, 1, 0, -1)]), + ....: Polyhedron(ieqs=[(0, -1, 0, 1), (0, 1, 0, 0), (0, 0, 1, 0)])) + sage: generating_function_of_polyhedron(P2[0], sort_factors=True) + 1 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 + sage: generating_function_of_polyhedron(P2[1], sort_factors=True) + 1 * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 + sage: (P2[0] & P2[1]).Hrepresentation() + (An equation (1, 0, -1) x + 0 == 0, + An inequality (1, 0, 0) x + 0 >= 0, + An inequality (0, 1, 0) x + 0 >= 0) + sage: generating_function_of_polyhedron(P2[0] & P2[1], sort_factors=True) + 1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 + + :: + + sage: P3 = ( + ....: Polyhedron( + ....: ieqs=[(0, 0, 0, 0, 1), (0, 0, 0, 1, 0), + ....: (0, 0, 1, 0, -1), (-1, 1, 0, -1, -1)]), + ....: Polyhedron( + ....: ieqs=[(0, 0, -1, 0, 1), (0, 1, 0, 0, -1), + ....: (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), (-1, 1, -1, -1, 0)]), + ....: Polyhedron( + ....: ieqs=[(1, -1, 0, 1, 1), (1, -1, 1, 1, 0), + ....: (0, 0, 0, 0, 1), (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), + ....: (1, 0, 1, 1, -1), (0, 1, 0, 0, 0), (1, 1, 1, 0, -1)]), + ....: Polyhedron( + ....: ieqs=[(0, 1, 0, -1, 0), (0, -1, 0, 0, 1), + ....: (-1, 0, -1, -1, 1), (0, 0, 1, 0, 0), (0, 0, 0, 1, 0)]), + ....: Polyhedron( + ....: ieqs=[(0, 1, 0, 0, 0), (0, 0, 1, 0, 0), + ....: (-1, -1, -1, 0, 1), (0, -1, 0, 1, 0)])) + sage: def intersect(I): + ....: I = iter(I) + ....: result = next(I) + ....: for i in I: + ....: result &= i + ....: return result + sage: for J in subsets(range(len(P3))): # TODO: check more results + ....: if not J: + ....: continue + ....: P = intersect([P3[j] for j in J]) + ....: print('{}: {}'.format(J, P.Hrepresentation())) + ....: print(generating_function_of_polyhedron(P, sort_factors=True)) + [0]: (An inequality (0, 0, 0, 1) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, -1) x + 0 >= 0, + An inequality (1, 0, -1, -1) x - 1 >= 0) + y0 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [1]: (An inequality (0, -1, 0, 1) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, -1, -1, 0) x - 1 >= 0, + An inequality (1, 0, 0, -1) x + 0 >= 0) + (-y0^2*y2*y3 - y0^2*y3 + y0*y3 + y0) * + (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y3 + 1)^-1 * + (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1]: (An equation (0, 1, 0, -1) x + 0 == 0, + An inequality (1, -1, -1, 0) x - 1 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0) + y0 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [2]: (An inequality (-1, 0, 1, 1) x + 1 >= 0, + An inequality (-1, 1, 1, 0) x + 1 >= 0, + An inequality (0, 0, 0, 1) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (0, 1, 1, -1) x + 1 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0, + An inequality (1, 1, 0, -1) x + 1 >= 0) + (y0^7*y1^6*y2^3*y3^5 + y0^7*y1^5*y2^4*y3^4 + y0^6*y1^7*y2^2*y3^5 - + y0^7*y1^5*y2^3*y3^4 + y0^6*y1^6*y2^3*y3^4 - y0^6*y1^6*y2^2*y3^5 - + 2*y0^6*y1^6*y2^2*y3^4 - 3*y0^6*y1^5*y2^3*y3^4 - y0^6*y1^5*y2^2*y3^5 - + y0^6*y1^5*y2^3*y3^3 - y0^6*y1^4*y2^4*y3^3 + y0^6*y1^5*y2^2*y3^4 - + 2*y0^5*y1^6*y2^2*y3^4 - 2*y0^6*y1^4*y2^3*y3^4 - y0^5*y1^6*y2*y3^5 + + y0^6*y1^5*y2^2*y3^3 + y0^6*y1^4*y2^3*y3^3 - y0^5*y1^5*y2^3*y3^3 - + y0^6*y1^3*y2^4*y3^3 + y0^6*y1^4*y2^2*y3^4 - y0^5*y1^5*y2^2*y3^4 + + y0^5*y1^5*y2*y3^5 + 3*y0^5*y1^5*y2^2*y3^3 + y0^6*y1^3*y2^3*y3^3 + + 2*y0^5*y1^5*y2*y3^4 - y0^4*y1^6*y2*y3^4 + 4*y0^5*y1^4*y2^2*y3^4 + + y0^5*y1^4*y2^3*y3^2 + 3*y0^5*y1^4*y2^2*y3^3 + 4*y0^5*y1^3*y2^3*y3^3 - + y0^5*y1^4*y2*y3^4 + 3*y0^4*y1^5*y2*y3^4 + y0^5*y1^3*y2^2*y3^4 - + y0^5*y1^4*y2^2*y3^2 + y0^5*y1^3*y2^3*y3^2 + y0^5*y1^2*y2^4*y3^2 - + y0^5*y1^4*y2*y3^3 + 2*y0^4*y1^5*y2*y3^3 - 2*y0^5*y1^3*y2^2*y3^3 + + 5*y0^4*y1^4*y2^2*y3^3 + y0^5*y1^2*y2^3*y3^3 - y0^5*y1^3*y2^2*y3^2 - + y0^5*y1^2*y2^3*y3^2 + 2*y0^4*y1^3*y2^3*y3^2 - 4*y0^4*y1^4*y2*y3^3 + + 2*y0^3*y1^5*y2*y3^3 - y0^5*y1^2*y2^2*y3^3 - y0^4*y1^3*y2^2*y3^3 + + y0^3*y1^5*y3^4 - y0^4*y1^3*y2*y3^4 - y0^4*y1^4*y2*y3^2 - + 5*y0^4*y1^3*y2^2*y3^2 + y0^3*y1^4*y2^2*y3^2 - y0^4*y1^2*y2^3*y3^2 - + 2*y0^4*y1^3*y2*y3^3 - y0^3*y1^4*y2*y3^3 - 3*y0^4*y1^2*y2^2*y3^3 - + y0^3*y1^4*y3^4 - y0^4*y1^2*y2^3*y3 + y0^4*y1^3*y2*y3^2 - + 3*y0^3*y1^4*y2*y3^2 - y0^4*y1^2*y2^2*y3^2 - 2*y0^3*y1^3*y2^2*y3^2 - + y0^4*y1*y2^3*y3^2 - 2*y0^3*y1^4*y3^3 + y0^4*y1^2*y2*y3^3 - + 5*y0^3*y1^3*y2*y3^3 + y0^4*y1^2*y2^2*y3 - y0^3*y1^3*y2^2*y3 + + y0^4*y1^2*y2*y3^2 - y0^3*y1^3*y2*y3^2 - y0^2*y1^4*y2*y3^2 + + y0^4*y1*y2^2*y3^2 - 4*y0^3*y1^2*y2^2*y3^2 + y0^3*y1^3*y3^3 - + 2*y0^2*y1^4*y3^3 + y0^3*y1^2*y2*y3^3 + y0^3*y1^3*y2*y3 - + y0^3*y1*y2^3*y3 + y0^3*y1^3*y3^2 + 5*y0^3*y1^2*y2*y3^2 - + 2*y0^2*y1^3*y2*y3^2 + y0^3*y1*y2^2*y3^2 + y0^2*y1^3*y3^3 + + y0^3*y1^2*y2*y3 + y0^2*y1^3*y2*y3 + 2*y0^3*y1*y2^2*y3 - + y0^2*y1^2*y2^2*y3 + 3*y0^2*y1^3*y3^2 + 4*y0^2*y1^2*y2*y3^2 + + y0^2*y1^2*y3^3 - y0^3*y1*y2*y3 + 4*y0^2*y1^2*y2*y3 + + 2*y0^2*y1*y2^2*y3 + y0^2*y1^2*y3^2 + y0*y1^3*y3^2 + + 2*y0^2*y1*y2*y3^2 + y0^2*y1*y2^2 - y0^2*y1^2*y3 - y0^2*y1*y2*y3 + + y0*y1^2*y2*y3 + y0^2*y2^2*y3 - y0^2*y1*y3^2 + y0*y1^2*y3^2 - + y0^2*y1*y2 - y0^2*y1*y3 - y0*y1^2*y3 - y0^2*y2*y3 - 2*y0*y1*y3^2 - + y0*y1*y2 - 3*y0*y1*y3 - 2*y0*y2*y3 - + y0*y2 + y0*y3 - y1*y3 + y0 + y3 + 1) * + (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y1*y3 + 1)^-1 * + (-y0*y1*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * + (-y0*y2*y3 + 1)^-1 * (-y0*y1^2*y3 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 + [0, 2]: (An equation (1, 0, -1, -1) x - 1 == 0, + An inequality (-1, 1, 1, 0) x + 1 >= 0, + An inequality (1, 0, -1, 0) x - 1 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0) + y0 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [1, 2]: (An equation (1, -1, -1, 0) x - 1 == 0, + An inequality (0, -1, 0, 1) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, 0, -1) x + 0 >= 0, + An inequality (1, -1, 0, 0) x - 1 >= 0) + (-y0^2*y2*y3 + y0*y3 + y0) * + (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1, 2]: (An equation (0, 1, 0, -1) x + 0 == 0, + An equation (1, -1, -1, 0) x - 1 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, -1, 0, 0) x - 1 >= 0) + y0 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [3]: (An inequality (-1, 0, 0, 1) x + 0 >= 0, + An inequality (0, -1, -1, 1) x - 1 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, -1, 0) x + 0 >= 0) + (-y0*y1*y3^2 - y0*y3^2 + y0*y3 + y3) * + (-y3 + 1)^-1 * (-y0*y3 + 1)^-1 * + (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 3]: (An equation -1 == 0,) + 0 + [1, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, + An inequality (1, -1, -1, 0) x - 1 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0) + y0*y3 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1, 3]: (An equation -1 == 0,) + 0 + [2, 3]: (An equation (0, 1, 1, -1) x + 1 == 0, + An inequality (1, 0, -1, 0) x + 0 >= 0, + An inequality (-1, 1, 1, 0) x + 1 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0) + (-y0*y1*y3^2 + y0*y3 + y3) * + (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 2, 3]: (An equation -1 == 0,) + 0 + [1, 2, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, + An equation (1, -1, -1, 0) x - 1 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, -1, 0, 0) x - 1 >= 0) + y0*y3 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1, 2, 3]: (An equation -1 == 0,) + 0 + [4]: (An inequality (-1, -1, 0, 1) x - 1 >= 0, + An inequality (-1, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0) + y3 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 4]: (An equation -1 == 0,) + 0 + [1, 4]: (An equation -1 == 0,) + 0 + [0, 1, 4]: (An equation -1 == 0,) + 0 + [2, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, + An inequality (-1, 0, 1, 0) x + 0 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0) + y3 * (-y2 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 2, 4]: (An equation -1 == 0,) + 0 + [1, 2, 4]: (An equation -1 == 0,) + 0 + [0, 1, 2, 4]: (An equation -1 == 0,) + 0 + [3, 4]: (An equation (1, 0, -1, 0) x + 0 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (-1, -1, 0, 1) x - 1 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0) + y3 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 3, 4]: (An equation -1 == 0,) + 0 + [1, 3, 4]: (An equation -1 == 0,) + 0 + [0, 1, 3, 4]: (An equation -1 == 0,) + 0 + [2, 3, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, + An equation (1, 0, -1, 0) x + 0 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0) + y3 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 2, 3, 4]: (An equation -1 == 0,) + 0 + [1, 2, 3, 4]: (An equation -1 == 0,) + 0 + [0, 1, 2, 3, 4]: (An equation -1 == 0,) + 0 + + TESTS:: + + sage: generating_function_of_polyhedron( + ....: Polyhedron(ieqs=[(0, 0, 1, 0, 0), (-1, 1, -1, 0, 0)]), + ....: sort_factors=True) + y0 * (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y0*y1 + 1)^-1 + sage: generating_function_of_polyhedron( + ....: Polyhedron(ieqs=[(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), + ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)]), + ....: sort_factors=True) + (-y0^2*y3 + y0*y3 + y0) * + (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + + sage: generating_function_of_polyhedron( + ....: Polyhedron(ieqs=[(0, 1, 0, -1, 0, 0), (0, 0, 0, 1, 0, 0)], + ....: eqns=[(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), + ....: (0, 1, -1, 0, 0, 0)]), + ....: sort_factors=True) + 1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y2*y3*y4 + 1)^-1 + + :: + + sage: G = generating_function_of_polyhedron(P2[0], sort_factors=True) + sage: S = generating_function_of_polyhedron(P2[0], sort_factors=True, + ....: split=True) + sage: sum(S) == G.value() + True + + sage: G = generating_function_of_polyhedron(P2[1], sort_factors=True) + sage: S = generating_function_of_polyhedron(P2[1], sort_factors=True, + ....: split=True) + sage: sum(S) == G.value() + True + + sage: G = generating_function_of_polyhedron(P3[0], sort_factors=True) + sage: S = generating_function_of_polyhedron(P3[0], sort_factors=True, + ....: split=True) + sage: sum(S) == G.value() + True + """ + import logging + logger = logging.getLogger(__name__) + + from sage.combinat.permutation import Permutations + from sage.geometry.polyhedron.constructor import Polyhedron + + if result_as_tuple is None: + result_as_tuple = split + + if polyhedron.is_empty(): + from sage.structure.factorization import Factorization + result = Factorization([], unit=0) + if result_as_tuple: + return Summandization((result,)) + else: + return result + + logger.info('generating_function_of_polyhedron: %s', polyhedron) + + if split is False: + result = _generating_function_of_polyhedron_(polyhedron, **kwds) + if result_as_tuple: + return Summandization(result) + else: + if len(result) != 1: + raise ValueError("Cannot unpack result. " + "(Set 'result_as_tuple=True'.)") + return result[0] + + d = polyhedron.ambient_dim() + if d <= 1: + raise ValueError('Cannot do splitting with only ' + 'dimension {}.'.format(d)) + + if split is True: + split = iter( + (Polyhedron( + ieqs=[tuple(1 if i==b else (-1 if i==a or i==0 and a > b else 0) + for i in range(d+1)) + for a, b in zip(pi[:-1], pi[1:])]), + 'b{}'.format(pi[0]-1) + + ''.join((' <= ' if a < b else ' < ') + + 'b{}'.format(b-1) + for a, b in zip(pi[:-1], pi[1:]))) + for pi in Permutations(d)) + else: + split = iter((ph, ph.repr_pretty_Hrepresentation(prefix='b')) + for ph in split) + + result = [] + for split_polyhedron, pi_log in split: + logger.info('split polyhedron by %s', pi_log) + result.append(_generating_function_of_polyhedron_( + polyhedron & split_polyhedron, **kwds)) + if not result_as_tuple: + raise ValueError("Cannot unpack result." + "(Unset 'result_as_tuple=False'.)") + return Summandization(sum(result, ())) + + +def compositions_mod(u, m, r=0, multidimensional=False): + r""" + Return an iterable of tuples `a` such that `a u^T \equiv r \mod m`. + + INPUT: + + - ``m`` -- the modulus as a positive integer. + + - ``multidimensional`` -- (default: ``False``) a boolean. + + If ``multidimensional=False``: + + - ``u`` -- the coefficients as a tuple. + + - ``r`` -- (default: `0`) + the remainder as a nonnegative integer. + + If ``multidimensional=True``: + + - ``u`` -- the coefficients as a tuple of tuples (read column-wise). + + - ``r`` -- (default: the zero vector) + the remainder as a tuple of nonnegative integers. + + OUTPUT: + + An iterable of tuples; all these tuples have the same size as ``u``. + + EXAMPLES:: + + sage: list(compositions_mod([1, 1], 2)) + [(0, 0), (1, 1)] + sage: list(compositions_mod([1, 2, 3], 6)) + [(0, 0, 0), (1, 1, 1), (2, 2, 0), (3, 0, 1), (4, 1, 0), (5, 2, 1)] + sage: list(compositions_mod([2, 2, 2], 6)) + [(0, 0, 0), (0, 1, 2), (0, 2, 1), (1, 0, 2), + (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0), (2, 2, 2)] + + :: + + sage: list(compositions_mod([(1, 0), (0, 1)], 2, + ....: multidimensional=True)) + [(0, 0)] + sage: list(compositions_mod([(1, 2), (2, 2), (3, 2)], 6, + ....: multidimensional=True)) + [(0, 0, 0), (1, 1, 1), (2, 2, 2)] + + TESTS:: + + sage: list(compositions_mod([1, 0], 2)) + [(0, 0)] + """ + from sage.modules.free_module_element import vector + from sage.rings.finite_rings.integer_mod_ring import Zmod + + Z = Zmod(m) + if not multidimensional: + u = tuple(vector([Z(uu)]) for uu in u) + r = vector([Z(r)]) + else: + u = tuple(vector(Z(uuu) for uuu in uu) for uu in u) + if r == 0: + r = vector(Z(0) for _ in range(len(u[0]))) + else: + r = vector(Z(rr) for rr in r) + + return _compositions_mod_(u, r) + + +def _compositions_mod_(u, r): + if not u: + if all(rr == 0 for rr in r): + yield () + return + + from itertools import product + from sage.arith.srange import srange + from sage.modules.free_module_element import vector + from sage.rings.finite_rings.integer_mod_ring import Zmod + + v = u[0] + m = max(vv.order() for vv in v) + Z = Zmod(m) + for j in srange(m): + for a in _compositions_mod_(u[1:], r - j*v): + yield (Z(j),) + a + + +def _generating_function_of_polyhedron_( + polyhedron, indices=None, **kwds): + r""" + Helper function for :func:`generating_function_of_polyhedron` which + does the actual computation of the generating function. + + TESTS:: + + sage: generating_function_of_polyhedron( # indirect doctest + ....: Polyhedron(ieqs=[(0, 1, 0, 0), (0, -1, 1, 0)], + ....: eqns=[(0, -1, -1, 2)]), + ....: result_as_tuple=True, sort_factors=True) + (-y0^2*y1^2*y2^2 + 1) * (-y1^2*y2 + 1)^-1 * + (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 + + (-y0^3*y1^3*y2^3 + y0*y1*y2) * (-y1^2*y2 + 1)^-1 * + (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 + """ + import logging + logger = logging.getLogger(__name__) + + logger.info('polyhedron: %s', + polyhedron.repr_pretty_Hrepresentation(prefix='b')) + + if polyhedron.is_empty(): + from sage.structure.factorization import Factorization + return (Factorization([], unit=0),) + + Hrepr = polyhedron.Hrepresentation() + + inequalities = tuple(tuple(entry) + for entry in Hrepr if entry.is_inequality()) + equations = tuple(tuple(entry) + for entry in Hrepr if entry.is_equation()) + if len(inequalities) + len(equations) != len(Hrepr): + raise ValueError('Cannot handle {}.'.format(polyhedron)) + + if not inequalities: + raise NotImplementedError('no inequality given') + + if indices is None: + indices = range(len(inequalities[0]) - 1) + + n = len(indices) + 1 + if any(len(e) != n for e in inequalities): + raise ValueError('Not all coefficient vectors of the inequalities ' + 'have the same length.') + if any(len(e) != n for e in equations): + raise ValueError('Not all coefficient vectors of the equations ' + 'have the same length.') + + logger.info('generating_function_of_polyhedron: ' + '%s inequalities', len(inequalities)) + + mods = generate_mods(equations) + logger.info('splitting by moduli %s', mods) + + return tuple(__generating_function_of_polyhedron__( + indices, inequalities, equations, mod, **kwds) for mod in mods) + + +def __generating_function_of_polyhedron__( + indices, inequalities, equations, mod, + Factorization_sort=False, Factorization_simplify=False, + sort_factors=False): + r""" + Helper function for :func:`generating_function_of_polyhedron` which + does the actual computation of the generating function. + + TESTS:: + + sage: __generating_function_of_polyhedron__( + ....: (0, 2), [(0, 1, 0)], [(1, -1, 2)], + ....: {0: (2, 1)}, sort_factors=True) + y0 * (-y0^2*y2 + 1)^-1 + sage: __generating_function_of_polyhedron__( + ....: srange(3), [(0, 1, 0, 0), (0, 0, 1, 0)], [(1, -1, 0, 2)], + ....: {0: (2, 1)}, sort_factors=True) + y0 * (-y1 + 1)^-1 * (-y0^2*y2 + 1)^-1 + sage: __generating_function_of_polyhedron__( + ....: srange(3), [(0, 1, 0, 0), (0, -1, 1, 0)], [(0, -1, -1, 2)], + ....: {0: (2, 1), 1: (2, 1)}, sort_factors=True) + (-y0^3*y1^3*y2^3 + y0*y1*y2) * + (-y1^2*y2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 + """ + import logging + logger = logging.getLogger(__name__) + + from sage.rings.integer_ring import ZZ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + from sage.structure.factorization import Factorization + + B = LaurentPolynomialRing( + ZZ, + tuple('y{}'.format(k) for k in indices), + sparse=True) + + extra_factor_mod, rules_mod, inequalities, equations = \ + prepare_mod(mod, B, inequalities, equations) + + extra_factor_equations, rules_equations, indices_equations = \ + prepare_equations(equations, B) + + inequalities, extra_factor_inequalities, rules_inequalities = \ + prepare_inequalities(inequalities, B) + + numerator = B(1) + terms = B.gens() + L = B + for i, coeffs in enumerate(inequalities): + L = LaurentPolynomialRing(L, 'mu{}'.format(i), sparse=True) + l = L.gen() + logger.debug('generating_function_of_polyhedron: ' + '%s --> %s', l, pretty_inequality(coeffs)) + it_coeffs = iter(coeffs) + numerator *= l**next(it_coeffs) + assert numerator.parent() == L + terms = tuple(l**c * t for c, t in zip(it_coeffs, terms)) + assert all(y == t for y, t in + (zip(B.gens(), terms)[i] for i in indices_equations)) + terms = tuple(t for i, t in enumerate(terms) + if i not in indices_equations) + + logger.info('generating_function_of_polyhedron: ' + 'terms denominator %s', terms) + + def decode_factor(factor): + D = factor.dict() + assert len(D) == 1 + exponent, coefficient = next(iteritems(D)) + return coefficient, exponent + + while repr(numerator.parent().gen()).startswith('mu'): + logger.info('generating_function_of_polyhedron: ' + 'applying Omega[%s]...', numerator.parent().gen()) + logger.info('...on terms denominator %s', terms) + logger.info('...(numerator has %s)', numerator.number_of_terms()) + + decoded_factors, other_factors = \ + partition((decode_factor(factor) for factor in terms), + lambda factor: factor[1] == 0) + other_factors = tuple(factor[0] for factor in other_factors) + numerator, factors_denominator = \ + _Omega_(numerator.dict(), tuple(decoded_factors)) + terms = other_factors + factors_denominator + + numerator = \ + (((numerator.subs(rules_inequalities) * extra_factor_inequalities + ).subs(rules_equations) * extra_factor_equations + ).subs(rules_mod) * extra_factor_mod) + terms = tuple( + t.subs(rules_inequalities).subs(rules_equations).subs(rules_mod) + for t in terms) + + if sort_factors: + def key(t): + D = t.dict().popitem()[0] + return (-sum(abs(d) for d in D), D) + terms = sorted(terms, key=key, reverse=True) + return Factorization([(numerator, 1)] + + list((1-t, -1) for t in terms), + sort=Factorization_sort, + simplify=Factorization_simplify) diff --git a/omega.py b/omega.py index 5cc02e01938..7ac1d04b850 100644 --- a/omega.py +++ b/omega.py @@ -714,878 +714,3 @@ def _Omega_(A, decoded_factors): if numerator == 0: factors_denominator = tuple() return numerator, tuple(f.subs(rules) for f in factors_denominator) - - -def pretty_inequality(ineq, indices=None): - from sage.symbolic.ring import SR - from sage.modules.free_module_element import vector - - if indices is None: - indices = range(len(ineq)-1) - vars = vector([1] + list(SR("b{}".format(i)) for i in indices)) - v = vector(ineq) - positive_part = vector([max(c, 0) for c in v]) - negative_part = - (v - positive_part) - assert v == positive_part - negative_part - return '{} >= {}'.format(positive_part*vars, negative_part*vars) - - -class Summandization(tuple): - def __repr__(self): - return ' + '.join(repr(s) for s in self) - - __str__ = __repr__ - - -def prepare_inequalities(inequalities, B): - r""" - EXAMPLES:: - - sage: B = LaurentPolynomialRing(ZZ, 'y', 3) - sage: prepare_inequalities([(0, -1, 1, 0), (2, -1, -1, 1)], B) - ([(2, -2, -1, 1)], 1, {y2: y2, y1: y1, y0: y0*y1}) - sage: prepare_inequalities([(-1, -1, 1, 0), (2, -1, -1, 1)], B) - ([(1, -2, -1, 1)], y1, {y2: y2, y1: y1, y0: y0*y1}) - sage: prepare_inequalities([(2, -1, 1, 0), (2, -1, -1, 1)], B) - ([(4, -2, -1, 1)], y1^-2, {y2: y2, y1: y1, y0: y0*y1}) - - TESTS:: - - sage: B = LaurentPolynomialRing(ZZ, 'y', 3) - sage: prepare_inequalities([(1, 1, -1, 0), (1, -1, 0, 1), - ....: (2, -1, -1, 3)], B) - ([(-3, 2, 1, 3)], y0^-1*y2^-2, {y2: y2, y1: y0*y1*y2, y0: y0*y2}) - - sage: B = LaurentPolynomialRing(ZZ, 'y', 4) - sage: prepare_inequalities([(-1, 1, -1, 0, 0)], B) - ([], y0, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) - sage: prepare_inequalities([(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), - ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)], B) - ([(1, 1, 0, 0, -1)], y0, {y3: y3, y2: y2, y1: y0*y1*y3, y0: y0}) - sage: prepare_inequalities([(-2, 1, -1, 0, 0)], B) - ([], y0^2, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) - - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), - ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y2^3*y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), - ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y2^2*y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y1^2*y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y1^3*y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y1^2*y2^3*y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y1^3*y2^2*y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - """ - import logging - logger = logging.getLogger(__name__) - - from itertools import takewhile - from sage.graphs.digraph import DiGraph - from sage.matrix.constructor import matrix - from sage.modules.free_module_element import vector - from sage.rings.integer_ring import ZZ - - inequalities_filtered = [] - chain_links = {} - for coeffs in inequalities: - dim = len(coeffs) - if all(c >= 0 for c in coeffs): - logger.debug('generating_function_of_polyhedron: ' - 'skipping %s (all coefficients >= 0)', - pretty_inequality(coeffs)) - continue - constant = coeffs[0] - ones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == 1) - mones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == -1) - absgetwo = tuple(i+1 for i, c in enumerate(coeffs[1:]) if abs(c) >= 2) - if len(ones) == 1 and not mones and not absgetwo: - if constant < 0: - # TODO: could be skipped... - inequalities_filtered.append(coeffs) - elif len(ones) == 1 and len(mones) == 1 and not absgetwo: - logger.debug('generating_function_of_polyhedron: ' - 'handling %s', - pretty_inequality(coeffs)) - chain_links[(mones[0], ones[0])] = constant - else: - inequalities_filtered.append(coeffs) - - G = DiGraph(chain_links, format='list_of_edges') - potential = {} - paths = {} - D = {} - inequalities_extra = [] - for i in range(dim): - D[(i, i)] = 1 - for v in G.topological_sort(): - NP = iter(sorted(((n, potential[n] + chain_links[(n, v)]) - for n in G.neighbor_in_iterator(v)), - key=lambda k: k[1])) - n, p = next(NP, (None, 0)) - potential[v] = p - D[(0, v)] = -p - paths[v] = paths.get(n, ()) + (v,) - for u in paths[v]: - D[(u, v)] = 1 - - for n, p in NP: - ell = len(tuple(takewhile(lambda u: u[0] == u[1], - zip(paths[n], paths[v])))) - coeffs = dim*[0] - for u in paths[v][ell:]: - coeffs[u] = 1 - for u in paths[n][ell:]: - coeffs[u] = -1 - coeffs[0] = p - potential[v] - inequalities_extra.append(tuple(coeffs)) - T = matrix(ZZ, dim, dim, D) - - inequalities = list(tuple(T*vector(ieq)) - for ieq in inequalities_filtered) + \ - inequalities_extra - - rules_pre = iter((y, B({tuple(row[1:]): 1})) - for y, row in zip((1,) + B.gens(), T.rows())) - factor = next(rules_pre)[1] - rules = dict(rules_pre) - - return inequalities, factor, rules - - -def prepare_equations_transformation(E): - r""" - TESTS:: - - sage: prepare_equations_transformation(matrix([(0, 1, 0, -2)])) - ([ 0 -1/2 0 1], (3,), (0, 1)) - sage: prepare_equations_transformation(matrix([(0, 1, -2, 0), (0, 2, 0, -3)])) - ( - [ 0 -1/2 1 0] - [ 0 -2/3 0 1], (2, 3), (0, 1) - ) - """ - indices_nonzero = tuple(i for i, col in enumerate(E.columns()) - if i > 0 and not col.is_zero()) - indices = [] - r = 0 - for i in reversed(indices_nonzero): - indices.append(i) - r1 = E.matrix_from_columns(indices).rank() - if r1 > r: - r = r1 - if len(indices) >= E.nrows(): - break - else: - indices = indices[:-1] - assert len(indices) == E.nrows() - indices = tuple(reversed(indices)) - indicesn = (0,) + tuple(i for i in indices_nonzero if i not in indices) - TE = E.matrix_from_columns(indices).inverse() * E - return TE, indices, indicesn - - -def prepare_equations(equations, B): - r""" - EXAMPLES:: - - sage: B = LaurentPolynomialRing(ZZ, 'y', 4) - sage: prepare_equations([(1, 1, 1, -1, 0)], B) - (y2, {y1: y1*y2, y0: y0*y2}, (2,)) - sage: prepare_equations([(0, 1, 0, -1, 0)], B) - (1, {y0: y0*y2}, (2,)) - sage: prepare_equations([(-1, 0, 1, -1, -1), (1, 1, 0, 1, 2)], B) - (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (2, 3)) - - TESTS:: - - sage: B = LaurentPolynomialRing(ZZ, 'y', 4) - sage: prepare_equations([(0, 0, 1, 0, -1), (-1, 1, -1, -1, 0)], B) - (y2^-1, {y1: y1*y2^-1*y3, y0: y0*y2}, (2, 3)) - - sage: B = LaurentPolynomialRing(ZZ, 'y', 5) - sage: prepare_equations([(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), - ....: (0, 1, -1, 0, 0, 0)], B) - (1, {y2: y2*y4, y0: y0*y1*y3}, (1, 3, 4)) - """ - from sage.matrix.constructor import matrix - from sage.misc.misc_c import prod - - E = matrix(equations) - if not E: - return 1, {}, () - - TE, indices, indicesn = prepare_equations_transformation(E) - - gens = (1,) + B.gens() - z = tuple(gens[i] for i in indices) - gens_cols = zip(gens, TE.columns()) - rules_pre = iter((y, y * prod(zz**(-c) for zz, c in zip(z, col))) - for y, col in (gens_cols[i] for i in indicesn)) - factor = next(rules_pre)[1] - rules = dict(rules_pre) - - return factor, rules, tuple(i-1 for i in indices) - - -def generate_mods(equations): - from sage.arith.misc import lcm - from sage.matrix.constructor import matrix - from sage.rings.integer_ring import ZZ - from sage.rings.rational_field import QQ - - TE, TEi, TEin = prepare_equations_transformation(matrix(equations)) - TEin = TEin[1:] - if TE.base_ring() == ZZ: - mods = [{}] - elif TE.base_ring() == QQ: - m = lcm([e.denominator() for e in TE.list()]) - if m == 1: - mods = [{}] - else: - cols = TE.columns() - assert all(cols[j][i] == 1 for i, j in enumerate(TEi)) - pre_mods = compositions_mod((tuple(ZZ(cc*m) for cc in cols[i]) - for i in TEin), - m, r=(-cc*m for cc in cols[0]), - multidimensional=True) - mods = tuple({i-1: (aa.modulus(), ZZ(aa)) - for i, aa in zip(TEin, a) if aa.modulus() > 1} - for a in pre_mods) - else: - raise TypeError('Equations over ZZ or QQ expected, but got ' - 'equations over {}.'.format(TE.base_ring())) - - return mods - - -def prepare_mod(mod, B, *vecs): - r""" - EXAMPLES:: - - sage: B = LaurentPolynomialRing(ZZ, 'y', 3) - sage: prepare_mod({0: (2, 1)}, B, [(1, -1, 0, 2)]) - (y0, {y2: y2, y1: y1, y0: y0^2}, ((0, -2, 0, 2),)) - sage: prepare_mod({0: (2, 1), 1: (2, 1)}, B, - ....: [(0, -1, -1, 2)], [(0, -1, 1, 0)]) - (y0*y1, {y2: y2, y1: y1^2, y0: y0^2}, - ((-2, -2, -2, 2),), ((0, -2, 2, 0),)) - """ - from sage.matrix.constructor import matrix - from sage.modules.free_module_element import vector - from sage.rings.integer_ring import ZZ - - if not mod: - return (1, {}) + vecs - - n = len(B.gens()) + 1 - - D = {(i, i): 1 for i in range(n)} - for i, mr in iteritems(mod): - D[(i+1, i+1)] = mr[0] - D[(i+1, 0)] = mr[1] - T = matrix(ZZ, n, n, D) - - rules_pre = iter((y, B({tuple(row[1:]): 1})) - for y, row in zip((1,) + B.gens(), T.columns())) - factor = next(rules_pre)[1] - rules = dict(rules_pre) - - vecs = tuple(tuple(tuple(vector(e)*T) for e in vec) for vec in vecs) - - return (factor, rules) + vecs - - -def generating_function_of_polyhedron(polyhedron, split=False, - result_as_tuple=None, **kwds): - r""" - Return the generating function of the integer points of - the polyhedron's orthant with only nonnegative coordinates. - - EXAMPLES:: - - sage: P2 = ( - ....: Polyhedron(ieqs=[(0, 0, 0, 1), (0, 0, 1, 0), (0, 1, 0, -1)]), - ....: Polyhedron(ieqs=[(0, -1, 0, 1), (0, 1, 0, 0), (0, 0, 1, 0)])) - sage: generating_function_of_polyhedron(P2[0], sort_factors=True) - 1 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 - sage: generating_function_of_polyhedron(P2[1], sort_factors=True) - 1 * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 - sage: (P2[0] & P2[1]).Hrepresentation() - (An equation (1, 0, -1) x + 0 == 0, - An inequality (1, 0, 0) x + 0 >= 0, - An inequality (0, 1, 0) x + 0 >= 0) - sage: generating_function_of_polyhedron(P2[0] & P2[1], sort_factors=True) - 1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 - - :: - - sage: P3 = ( - ....: Polyhedron( - ....: ieqs=[(0, 0, 0, 0, 1), (0, 0, 0, 1, 0), - ....: (0, 0, 1, 0, -1), (-1, 1, 0, -1, -1)]), - ....: Polyhedron( - ....: ieqs=[(0, 0, -1, 0, 1), (0, 1, 0, 0, -1), - ....: (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), (-1, 1, -1, -1, 0)]), - ....: Polyhedron( - ....: ieqs=[(1, -1, 0, 1, 1), (1, -1, 1, 1, 0), - ....: (0, 0, 0, 0, 1), (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), - ....: (1, 0, 1, 1, -1), (0, 1, 0, 0, 0), (1, 1, 1, 0, -1)]), - ....: Polyhedron( - ....: ieqs=[(0, 1, 0, -1, 0), (0, -1, 0, 0, 1), - ....: (-1, 0, -1, -1, 1), (0, 0, 1, 0, 0), (0, 0, 0, 1, 0)]), - ....: Polyhedron( - ....: ieqs=[(0, 1, 0, 0, 0), (0, 0, 1, 0, 0), - ....: (-1, -1, -1, 0, 1), (0, -1, 0, 1, 0)])) - sage: def intersect(I): - ....: I = iter(I) - ....: result = next(I) - ....: for i in I: - ....: result &= i - ....: return result - sage: for J in subsets(range(len(P3))): # TODO: check more results - ....: if not J: - ....: continue - ....: P = intersect([P3[j] for j in J]) - ....: print('{}: {}'.format(J, P.Hrepresentation())) - ....: print(generating_function_of_polyhedron(P, sort_factors=True)) - [0]: (An inequality (0, 0, 0, 1) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, -1) x + 0 >= 0, - An inequality (1, 0, -1, -1) x - 1 >= 0) - y0 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [1]: (An inequality (0, -1, 0, 1) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, -1, -1, 0) x - 1 >= 0, - An inequality (1, 0, 0, -1) x + 0 >= 0) - (-y0^2*y2*y3 - y0^2*y3 + y0*y3 + y0) * - (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y3 + 1)^-1 * - (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1]: (An equation (0, 1, 0, -1) x + 0 == 0, - An inequality (1, -1, -1, 0) x - 1 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0) - y0 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [2]: (An inequality (-1, 0, 1, 1) x + 1 >= 0, - An inequality (-1, 1, 1, 0) x + 1 >= 0, - An inequality (0, 0, 0, 1) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (0, 1, 1, -1) x + 1 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0, - An inequality (1, 1, 0, -1) x + 1 >= 0) - (y0^7*y1^6*y2^3*y3^5 + y0^7*y1^5*y2^4*y3^4 + y0^6*y1^7*y2^2*y3^5 - - y0^7*y1^5*y2^3*y3^4 + y0^6*y1^6*y2^3*y3^4 - y0^6*y1^6*y2^2*y3^5 - - 2*y0^6*y1^6*y2^2*y3^4 - 3*y0^6*y1^5*y2^3*y3^4 - y0^6*y1^5*y2^2*y3^5 - - y0^6*y1^5*y2^3*y3^3 - y0^6*y1^4*y2^4*y3^3 + y0^6*y1^5*y2^2*y3^4 - - 2*y0^5*y1^6*y2^2*y3^4 - 2*y0^6*y1^4*y2^3*y3^4 - y0^5*y1^6*y2*y3^5 + - y0^6*y1^5*y2^2*y3^3 + y0^6*y1^4*y2^3*y3^3 - y0^5*y1^5*y2^3*y3^3 - - y0^6*y1^3*y2^4*y3^3 + y0^6*y1^4*y2^2*y3^4 - y0^5*y1^5*y2^2*y3^4 + - y0^5*y1^5*y2*y3^5 + 3*y0^5*y1^5*y2^2*y3^3 + y0^6*y1^3*y2^3*y3^3 + - 2*y0^5*y1^5*y2*y3^4 - y0^4*y1^6*y2*y3^4 + 4*y0^5*y1^4*y2^2*y3^4 + - y0^5*y1^4*y2^3*y3^2 + 3*y0^5*y1^4*y2^2*y3^3 + 4*y0^5*y1^3*y2^3*y3^3 - - y0^5*y1^4*y2*y3^4 + 3*y0^4*y1^5*y2*y3^4 + y0^5*y1^3*y2^2*y3^4 - - y0^5*y1^4*y2^2*y3^2 + y0^5*y1^3*y2^3*y3^2 + y0^5*y1^2*y2^4*y3^2 - - y0^5*y1^4*y2*y3^3 + 2*y0^4*y1^5*y2*y3^3 - 2*y0^5*y1^3*y2^2*y3^3 + - 5*y0^4*y1^4*y2^2*y3^3 + y0^5*y1^2*y2^3*y3^3 - y0^5*y1^3*y2^2*y3^2 - - y0^5*y1^2*y2^3*y3^2 + 2*y0^4*y1^3*y2^3*y3^2 - 4*y0^4*y1^4*y2*y3^3 + - 2*y0^3*y1^5*y2*y3^3 - y0^5*y1^2*y2^2*y3^3 - y0^4*y1^3*y2^2*y3^3 + - y0^3*y1^5*y3^4 - y0^4*y1^3*y2*y3^4 - y0^4*y1^4*y2*y3^2 - - 5*y0^4*y1^3*y2^2*y3^2 + y0^3*y1^4*y2^2*y3^2 - y0^4*y1^2*y2^3*y3^2 - - 2*y0^4*y1^3*y2*y3^3 - y0^3*y1^4*y2*y3^3 - 3*y0^4*y1^2*y2^2*y3^3 - - y0^3*y1^4*y3^4 - y0^4*y1^2*y2^3*y3 + y0^4*y1^3*y2*y3^2 - - 3*y0^3*y1^4*y2*y3^2 - y0^4*y1^2*y2^2*y3^2 - 2*y0^3*y1^3*y2^2*y3^2 - - y0^4*y1*y2^3*y3^2 - 2*y0^3*y1^4*y3^3 + y0^4*y1^2*y2*y3^3 - - 5*y0^3*y1^3*y2*y3^3 + y0^4*y1^2*y2^2*y3 - y0^3*y1^3*y2^2*y3 + - y0^4*y1^2*y2*y3^2 - y0^3*y1^3*y2*y3^2 - y0^2*y1^4*y2*y3^2 + - y0^4*y1*y2^2*y3^2 - 4*y0^3*y1^2*y2^2*y3^2 + y0^3*y1^3*y3^3 - - 2*y0^2*y1^4*y3^3 + y0^3*y1^2*y2*y3^3 + y0^3*y1^3*y2*y3 - - y0^3*y1*y2^3*y3 + y0^3*y1^3*y3^2 + 5*y0^3*y1^2*y2*y3^2 - - 2*y0^2*y1^3*y2*y3^2 + y0^3*y1*y2^2*y3^2 + y0^2*y1^3*y3^3 + - y0^3*y1^2*y2*y3 + y0^2*y1^3*y2*y3 + 2*y0^3*y1*y2^2*y3 - - y0^2*y1^2*y2^2*y3 + 3*y0^2*y1^3*y3^2 + 4*y0^2*y1^2*y2*y3^2 + - y0^2*y1^2*y3^3 - y0^3*y1*y2*y3 + 4*y0^2*y1^2*y2*y3 + - 2*y0^2*y1*y2^2*y3 + y0^2*y1^2*y3^2 + y0*y1^3*y3^2 + - 2*y0^2*y1*y2*y3^2 + y0^2*y1*y2^2 - y0^2*y1^2*y3 - y0^2*y1*y2*y3 + - y0*y1^2*y2*y3 + y0^2*y2^2*y3 - y0^2*y1*y3^2 + y0*y1^2*y3^2 - - y0^2*y1*y2 - y0^2*y1*y3 - y0*y1^2*y3 - y0^2*y2*y3 - 2*y0*y1*y3^2 - - y0*y1*y2 - 3*y0*y1*y3 - 2*y0*y2*y3 - - y0*y2 + y0*y3 - y1*y3 + y0 + y3 + 1) * - (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y1*y3 + 1)^-1 * - (-y0*y1*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * - (-y0*y2*y3 + 1)^-1 * (-y0*y1^2*y3 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 - [0, 2]: (An equation (1, 0, -1, -1) x - 1 == 0, - An inequality (-1, 1, 1, 0) x + 1 >= 0, - An inequality (1, 0, -1, 0) x - 1 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0) - y0 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [1, 2]: (An equation (1, -1, -1, 0) x - 1 == 0, - An inequality (0, -1, 0, 1) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, 0, -1) x + 0 >= 0, - An inequality (1, -1, 0, 0) x - 1 >= 0) - (-y0^2*y2*y3 + y0*y3 + y0) * - (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 2]: (An equation (0, 1, 0, -1) x + 0 == 0, - An equation (1, -1, -1, 0) x - 1 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, -1, 0, 0) x - 1 >= 0) - y0 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [3]: (An inequality (-1, 0, 0, 1) x + 0 >= 0, - An inequality (0, -1, -1, 1) x - 1 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, -1, 0) x + 0 >= 0) - (-y0*y1*y3^2 - y0*y3^2 + y0*y3 + y3) * - (-y3 + 1)^-1 * (-y0*y3 + 1)^-1 * - (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 3]: (An equation -1 == 0,) - 0 - [1, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, - An inequality (1, -1, -1, 0) x - 1 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0) - y0*y3 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 3]: (An equation -1 == 0,) - 0 - [2, 3]: (An equation (0, 1, 1, -1) x + 1 == 0, - An inequality (1, 0, -1, 0) x + 0 >= 0, - An inequality (-1, 1, 1, 0) x + 1 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0) - (-y0*y1*y3^2 + y0*y3 + y3) * - (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 3]: (An equation -1 == 0,) - 0 - [1, 2, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, - An equation (1, -1, -1, 0) x - 1 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, -1, 0, 0) x - 1 >= 0) - y0*y3 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 2, 3]: (An equation -1 == 0,) - 0 - [4]: (An inequality (-1, -1, 0, 1) x - 1 >= 0, - An inequality (-1, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0) - y3 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 4]: (An equation -1 == 0,) - 0 - [1, 4]: (An equation -1 == 0,) - 0 - [0, 1, 4]: (An equation -1 == 0,) - 0 - [2, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, - An inequality (-1, 0, 1, 0) x + 0 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0) - y3 * (-y2 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 4]: (An equation -1 == 0,) - 0 - [1, 2, 4]: (An equation -1 == 0,) - 0 - [0, 1, 2, 4]: (An equation -1 == 0,) - 0 - [3, 4]: (An equation (1, 0, -1, 0) x + 0 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (-1, -1, 0, 1) x - 1 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0) - y3 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 3, 4]: (An equation -1 == 0,) - 0 - [1, 3, 4]: (An equation -1 == 0,) - 0 - [0, 1, 3, 4]: (An equation -1 == 0,) - 0 - [2, 3, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, - An equation (1, 0, -1, 0) x + 0 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0) - y3 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 3, 4]: (An equation -1 == 0,) - 0 - [1, 2, 3, 4]: (An equation -1 == 0,) - 0 - [0, 1, 2, 3, 4]: (An equation -1 == 0,) - 0 - - TESTS:: - - sage: generating_function_of_polyhedron( - ....: Polyhedron(ieqs=[(0, 0, 1, 0, 0), (-1, 1, -1, 0, 0)]), - ....: sort_factors=True) - y0 * (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y0*y1 + 1)^-1 - sage: generating_function_of_polyhedron( - ....: Polyhedron(ieqs=[(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), - ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)]), - ....: sort_factors=True) - (-y0^2*y3 + y0*y3 + y0) * - (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - - sage: generating_function_of_polyhedron( - ....: Polyhedron(ieqs=[(0, 1, 0, -1, 0, 0), (0, 0, 0, 1, 0, 0)], - ....: eqns=[(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), - ....: (0, 1, -1, 0, 0, 0)]), - ....: sort_factors=True) - 1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y2*y3*y4 + 1)^-1 - - :: - - sage: G = generating_function_of_polyhedron(P2[0], sort_factors=True) - sage: S = generating_function_of_polyhedron(P2[0], sort_factors=True, - ....: split=True) - sage: sum(S) == G.value() - True - - sage: G = generating_function_of_polyhedron(P2[1], sort_factors=True) - sage: S = generating_function_of_polyhedron(P2[1], sort_factors=True, - ....: split=True) - sage: sum(S) == G.value() - True - - sage: G = generating_function_of_polyhedron(P3[0], sort_factors=True) - sage: S = generating_function_of_polyhedron(P3[0], sort_factors=True, - ....: split=True) - sage: sum(S) == G.value() - True - """ - import logging - logger = logging.getLogger(__name__) - - from sage.combinat.permutation import Permutations - from sage.geometry.polyhedron.constructor import Polyhedron - - if result_as_tuple is None: - result_as_tuple = split - - if polyhedron.is_empty(): - from sage.structure.factorization import Factorization - result = Factorization([], unit=0) - if result_as_tuple: - return Summandization((result,)) - else: - return result - - logger.info('generating_function_of_polyhedron: %s', polyhedron) - - if split is False: - result = _generating_function_of_polyhedron_(polyhedron, **kwds) - if result_as_tuple: - return Summandization(result) - else: - if len(result) != 1: - raise ValueError("Cannot unpack result. " - "(Set 'result_as_tuple=True'.)") - return result[0] - - d = polyhedron.ambient_dim() - if d <= 1: - raise ValueError('Cannot do splitting with only ' - 'dimension {}.'.format(d)) - - if split is True: - split = iter( - (Polyhedron( - ieqs=[tuple(1 if i==b else (-1 if i==a or i==0 and a > b else 0) - for i in range(d+1)) - for a, b in zip(pi[:-1], pi[1:])]), - 'b{}'.format(pi[0]-1) + - ''.join((' <= ' if a < b else ' < ') + - 'b{}'.format(b-1) - for a, b in zip(pi[:-1], pi[1:]))) - for pi in Permutations(d)) - else: - split = iter((ph, ph.repr_pretty_Hrepresentation(prefix='b')) - for ph in split) - - result = [] - for split_polyhedron, pi_log in split: - logger.info('split polyhedron by %s', pi_log) - result.append(_generating_function_of_polyhedron_( - polyhedron & split_polyhedron, **kwds)) - if not result_as_tuple: - raise ValueError("Cannot unpack result." - "(Unset 'result_as_tuple=False'.)") - return Summandization(sum(result, ())) - - -def compositions_mod(u, m, r=0, multidimensional=False): - r""" - Return an iterable of tuples `a` such that `a u^T \equiv r \mod m`. - - INPUT: - - - ``m`` -- the modulus as a positive integer. - - - ``multidimensional`` -- (default: ``False``) a boolean. - - If ``multidimensional=False``: - - - ``u`` -- the coefficients as a tuple. - - - ``r`` -- (default: `0`) - the remainder as a nonnegative integer. - - If ``multidimensional=True``: - - - ``u`` -- the coefficients as a tuple of tuples (read column-wise). - - - ``r`` -- (default: the zero vector) - the remainder as a tuple of nonnegative integers. - - OUTPUT: - - An iterable of tuples; all these tuples have the same size as ``u``. - - EXAMPLES:: - - sage: list(compositions_mod([1, 1], 2)) - [(0, 0), (1, 1)] - sage: list(compositions_mod([1, 2, 3], 6)) - [(0, 0, 0), (1, 1, 1), (2, 2, 0), (3, 0, 1), (4, 1, 0), (5, 2, 1)] - sage: list(compositions_mod([2, 2, 2], 6)) - [(0, 0, 0), (0, 1, 2), (0, 2, 1), (1, 0, 2), - (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0), (2, 2, 2)] - - :: - - sage: list(compositions_mod([(1, 0), (0, 1)], 2, - ....: multidimensional=True)) - [(0, 0)] - sage: list(compositions_mod([(1, 2), (2, 2), (3, 2)], 6, - ....: multidimensional=True)) - [(0, 0, 0), (1, 1, 1), (2, 2, 2)] - - TESTS:: - - sage: list(compositions_mod([1, 0], 2)) - [(0, 0)] - """ - from sage.modules.free_module_element import vector - from sage.rings.finite_rings.integer_mod_ring import Zmod - - Z = Zmod(m) - if not multidimensional: - u = tuple(vector([Z(uu)]) for uu in u) - r = vector([Z(r)]) - else: - u = tuple(vector(Z(uuu) for uuu in uu) for uu in u) - if r == 0: - r = vector(Z(0) for _ in range(len(u[0]))) - else: - r = vector(Z(rr) for rr in r) - - return _compositions_mod_(u, r) - - -def _compositions_mod_(u, r): - if not u: - if all(rr == 0 for rr in r): - yield () - return - - from itertools import product - from sage.arith.srange import srange - from sage.modules.free_module_element import vector - from sage.rings.finite_rings.integer_mod_ring import Zmod - - v = u[0] - m = max(vv.order() for vv in v) - Z = Zmod(m) - for j in srange(m): - for a in _compositions_mod_(u[1:], r - j*v): - yield (Z(j),) + a - - -def _generating_function_of_polyhedron_( - polyhedron, indices=None, **kwds): - r""" - Helper function for :func:`generating_function_of_polyhedron` which - does the actual computation of the generating function. - - TESTS:: - - sage: generating_function_of_polyhedron( # indirect doctest - ....: Polyhedron(ieqs=[(0, 1, 0, 0), (0, -1, 1, 0)], - ....: eqns=[(0, -1, -1, 2)]), - ....: result_as_tuple=True, sort_factors=True) - (-y0^2*y1^2*y2^2 + 1) * (-y1^2*y2 + 1)^-1 * - (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 + - (-y0^3*y1^3*y2^3 + y0*y1*y2) * (-y1^2*y2 + 1)^-1 * - (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 - """ - import logging - logger = logging.getLogger(__name__) - - logger.info('polyhedron: %s', - polyhedron.repr_pretty_Hrepresentation(prefix='b')) - - if polyhedron.is_empty(): - from sage.structure.factorization import Factorization - return (Factorization([], unit=0),) - - Hrepr = polyhedron.Hrepresentation() - - inequalities = tuple(tuple(entry) - for entry in Hrepr if entry.is_inequality()) - equations = tuple(tuple(entry) - for entry in Hrepr if entry.is_equation()) - if len(inequalities) + len(equations) != len(Hrepr): - raise ValueError('Cannot handle {}.'.format(polyhedron)) - - if not inequalities: - raise NotImplementedError('no inequality given') - - if indices is None: - indices = range(len(inequalities[0]) - 1) - - n = len(indices) + 1 - if any(len(e) != n for e in inequalities): - raise ValueError('Not all coefficient vectors of the inequalities ' - 'have the same length.') - if any(len(e) != n for e in equations): - raise ValueError('Not all coefficient vectors of the equations ' - 'have the same length.') - - logger.info('generating_function_of_polyhedron: ' - '%s inequalities', len(inequalities)) - - mods = generate_mods(equations) - logger.info('splitting by moduli %s', mods) - - return tuple(__generating_function_of_polyhedron__( - indices, inequalities, equations, mod, **kwds) for mod in mods) - - -def __generating_function_of_polyhedron__( - indices, inequalities, equations, mod, - Factorization_sort=False, Factorization_simplify=False, - sort_factors=False): - r""" - Helper function for :func:`generating_function_of_polyhedron` which - does the actual computation of the generating function. - - TESTS:: - - sage: __generating_function_of_polyhedron__( - ....: (0, 2), [(0, 1, 0)], [(1, -1, 2)], - ....: {0: (2, 1)}, sort_factors=True) - y0 * (-y0^2*y2 + 1)^-1 - sage: __generating_function_of_polyhedron__( - ....: srange(3), [(0, 1, 0, 0), (0, 0, 1, 0)], [(1, -1, 0, 2)], - ....: {0: (2, 1)}, sort_factors=True) - y0 * (-y1 + 1)^-1 * (-y0^2*y2 + 1)^-1 - sage: __generating_function_of_polyhedron__( - ....: srange(3), [(0, 1, 0, 0), (0, -1, 1, 0)], [(0, -1, -1, 2)], - ....: {0: (2, 1), 1: (2, 1)}, sort_factors=True) - (-y0^3*y1^3*y2^3 + y0*y1*y2) * - (-y1^2*y2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 - """ - import logging - logger = logging.getLogger(__name__) - - from sage.rings.integer_ring import ZZ - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - from sage.structure.factorization import Factorization - - B = LaurentPolynomialRing( - ZZ, - tuple('y{}'.format(k) for k in indices), - sparse=True) - - extra_factor_mod, rules_mod, inequalities, equations = \ - prepare_mod(mod, B, inequalities, equations) - - extra_factor_equations, rules_equations, indices_equations = \ - prepare_equations(equations, B) - - inequalities, extra_factor_inequalities, rules_inequalities = \ - prepare_inequalities(inequalities, B) - - numerator = B(1) - terms = B.gens() - L = B - for i, coeffs in enumerate(inequalities): - L = LaurentPolynomialRing(L, 'mu{}'.format(i), sparse=True) - l = L.gen() - logger.debug('generating_function_of_polyhedron: ' - '%s --> %s', l, pretty_inequality(coeffs)) - it_coeffs = iter(coeffs) - numerator *= l**next(it_coeffs) - assert numerator.parent() == L - terms = tuple(l**c * t for c, t in zip(it_coeffs, terms)) - assert all(y == t for y, t in - (zip(B.gens(), terms)[i] for i in indices_equations)) - terms = tuple(t for i, t in enumerate(terms) - if i not in indices_equations) - - logger.info('generating_function_of_polyhedron: ' - 'terms denominator %s', terms) - - def decode_factor(factor): - D = factor.dict() - assert len(D) == 1 - exponent, coefficient = next(iteritems(D)) - return coefficient, exponent - - while repr(numerator.parent().gen()).startswith('mu'): - logger.info('generating_function_of_polyhedron: ' - 'applying Omega[%s]...', numerator.parent().gen()) - logger.info('...on terms denominator %s', terms) - logger.info('...(numerator has %s)', numerator.number_of_terms()) - - decoded_factors, other_factors = \ - partition((decode_factor(factor) for factor in terms), - lambda factor: factor[1] == 0) - other_factors = tuple(factor[0] for factor in other_factors) - numerator, factors_denominator = \ - _Omega_(numerator.dict(), tuple(decoded_factors)) - terms = other_factors + factors_denominator - - numerator = \ - (((numerator.subs(rules_inequalities) * extra_factor_inequalities - ).subs(rules_equations) * extra_factor_equations - ).subs(rules_mod) * extra_factor_mod) - terms = tuple( - t.subs(rules_inequalities).subs(rules_equations).subs(rules_mod) - for t in terms) - - if sort_factors: - def key(t): - D = t.dict().popitem()[0] - return (-sum(abs(d) for d in D), D) - terms = sorted(terms, key=key, reverse=True) - return Factorization([(numerator, 1)] + - list((1-t, -1) for t in terms), - sort=Factorization_sort, - simplify=Factorization_simplify) From e055cbf1928fa2ec39ace3fea146cf5eb3af3c5b Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 13 Dec 2016 14:46:30 +0100 Subject: [PATCH 157/370] fix imports --- generating_function_of_polyhedron.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generating_function_of_polyhedron.py b/generating_function_of_polyhedron.py index 6bac2569ff2..38804640899 100644 --- a/generating_function_of_polyhedron.py +++ b/generating_function_of_polyhedron.py @@ -812,6 +812,8 @@ def __generating_function_of_polyhedron__( import logging logger = logging.getLogger(__name__) + from omega import _Omega_ + from omega import partition from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing from sage.structure.factorization import Factorization From 1dff10a4b59ee88781d2ec05832abc2be10d1249 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 13 Dec 2016 14:50:22 +0100 Subject: [PATCH 158/370] move functions around in generating_function_of_polyhedron --- generating_function_of_polyhedron.py | 1422 +++++++++++++------------- 1 file changed, 712 insertions(+), 710 deletions(-) diff --git a/generating_function_of_polyhedron.py b/generating_function_of_polyhedron.py index 38804640899..c99b810b1c4 100644 --- a/generating_function_of_polyhedron.py +++ b/generating_function_of_polyhedron.py @@ -14,627 +14,793 @@ from six import iteritems, itervalues -def pretty_inequality(ineq, indices=None): - from sage.symbolic.ring import SR - from sage.modules.free_module_element import vector +def generating_function_of_polyhedron(polyhedron, split=False, + result_as_tuple=None, **kwds): + r""" + Return the generating function of the integer points of + the polyhedron's orthant with only nonnegative coordinates. - if indices is None: - indices = range(len(ineq)-1) - vars = vector([1] + list(SR("b{}".format(i)) for i in indices)) - v = vector(ineq) - positive_part = vector([max(c, 0) for c in v]) - negative_part = - (v - positive_part) - assert v == positive_part - negative_part - return '{} >= {}'.format(positive_part*vars, negative_part*vars) + EXAMPLES:: + sage: P2 = ( + ....: Polyhedron(ieqs=[(0, 0, 0, 1), (0, 0, 1, 0), (0, 1, 0, -1)]), + ....: Polyhedron(ieqs=[(0, -1, 0, 1), (0, 1, 0, 0), (0, 0, 1, 0)])) + sage: generating_function_of_polyhedron(P2[0], sort_factors=True) + 1 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 + sage: generating_function_of_polyhedron(P2[1], sort_factors=True) + 1 * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 + sage: (P2[0] & P2[1]).Hrepresentation() + (An equation (1, 0, -1) x + 0 == 0, + An inequality (1, 0, 0) x + 0 >= 0, + An inequality (0, 1, 0) x + 0 >= 0) + sage: generating_function_of_polyhedron(P2[0] & P2[1], sort_factors=True) + 1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 -class Summandization(tuple): - def __repr__(self): - return ' + '.join(repr(s) for s in self) + :: - __str__ = __repr__ + sage: P3 = ( + ....: Polyhedron( + ....: ieqs=[(0, 0, 0, 0, 1), (0, 0, 0, 1, 0), + ....: (0, 0, 1, 0, -1), (-1, 1, 0, -1, -1)]), + ....: Polyhedron( + ....: ieqs=[(0, 0, -1, 0, 1), (0, 1, 0, 0, -1), + ....: (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), (-1, 1, -1, -1, 0)]), + ....: Polyhedron( + ....: ieqs=[(1, -1, 0, 1, 1), (1, -1, 1, 1, 0), + ....: (0, 0, 0, 0, 1), (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), + ....: (1, 0, 1, 1, -1), (0, 1, 0, 0, 0), (1, 1, 1, 0, -1)]), + ....: Polyhedron( + ....: ieqs=[(0, 1, 0, -1, 0), (0, -1, 0, 0, 1), + ....: (-1, 0, -1, -1, 1), (0, 0, 1, 0, 0), (0, 0, 0, 1, 0)]), + ....: Polyhedron( + ....: ieqs=[(0, 1, 0, 0, 0), (0, 0, 1, 0, 0), + ....: (-1, -1, -1, 0, 1), (0, -1, 0, 1, 0)])) + sage: def intersect(I): + ....: I = iter(I) + ....: result = next(I) + ....: for i in I: + ....: result &= i + ....: return result + sage: for J in subsets(range(len(P3))): # TODO: check more results + ....: if not J: + ....: continue + ....: P = intersect([P3[j] for j in J]) + ....: print('{}: {}'.format(J, P.Hrepresentation())) + ....: print(generating_function_of_polyhedron(P, sort_factors=True)) + [0]: (An inequality (0, 0, 0, 1) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, -1) x + 0 >= 0, + An inequality (1, 0, -1, -1) x - 1 >= 0) + y0 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [1]: (An inequality (0, -1, 0, 1) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, -1, -1, 0) x - 1 >= 0, + An inequality (1, 0, 0, -1) x + 0 >= 0) + (-y0^2*y2*y3 - y0^2*y3 + y0*y3 + y0) * + (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y3 + 1)^-1 * + (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1]: (An equation (0, 1, 0, -1) x + 0 == 0, + An inequality (1, -1, -1, 0) x - 1 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0) + y0 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [2]: (An inequality (-1, 0, 1, 1) x + 1 >= 0, + An inequality (-1, 1, 1, 0) x + 1 >= 0, + An inequality (0, 0, 0, 1) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (0, 1, 1, -1) x + 1 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0, + An inequality (1, 1, 0, -1) x + 1 >= 0) + (y0^7*y1^6*y2^3*y3^5 + y0^7*y1^5*y2^4*y3^4 + y0^6*y1^7*y2^2*y3^5 - + y0^7*y1^5*y2^3*y3^4 + y0^6*y1^6*y2^3*y3^4 - y0^6*y1^6*y2^2*y3^5 - + 2*y0^6*y1^6*y2^2*y3^4 - 3*y0^6*y1^5*y2^3*y3^4 - y0^6*y1^5*y2^2*y3^5 - + y0^6*y1^5*y2^3*y3^3 - y0^6*y1^4*y2^4*y3^3 + y0^6*y1^5*y2^2*y3^4 - + 2*y0^5*y1^6*y2^2*y3^4 - 2*y0^6*y1^4*y2^3*y3^4 - y0^5*y1^6*y2*y3^5 + + y0^6*y1^5*y2^2*y3^3 + y0^6*y1^4*y2^3*y3^3 - y0^5*y1^5*y2^3*y3^3 - + y0^6*y1^3*y2^4*y3^3 + y0^6*y1^4*y2^2*y3^4 - y0^5*y1^5*y2^2*y3^4 + + y0^5*y1^5*y2*y3^5 + 3*y0^5*y1^5*y2^2*y3^3 + y0^6*y1^3*y2^3*y3^3 + + 2*y0^5*y1^5*y2*y3^4 - y0^4*y1^6*y2*y3^4 + 4*y0^5*y1^4*y2^2*y3^4 + + y0^5*y1^4*y2^3*y3^2 + 3*y0^5*y1^4*y2^2*y3^3 + 4*y0^5*y1^3*y2^3*y3^3 - + y0^5*y1^4*y2*y3^4 + 3*y0^4*y1^5*y2*y3^4 + y0^5*y1^3*y2^2*y3^4 - + y0^5*y1^4*y2^2*y3^2 + y0^5*y1^3*y2^3*y3^2 + y0^5*y1^2*y2^4*y3^2 - + y0^5*y1^4*y2*y3^3 + 2*y0^4*y1^5*y2*y3^3 - 2*y0^5*y1^3*y2^2*y3^3 + + 5*y0^4*y1^4*y2^2*y3^3 + y0^5*y1^2*y2^3*y3^3 - y0^5*y1^3*y2^2*y3^2 - + y0^5*y1^2*y2^3*y3^2 + 2*y0^4*y1^3*y2^3*y3^2 - 4*y0^4*y1^4*y2*y3^3 + + 2*y0^3*y1^5*y2*y3^3 - y0^5*y1^2*y2^2*y3^3 - y0^4*y1^3*y2^2*y3^3 + + y0^3*y1^5*y3^4 - y0^4*y1^3*y2*y3^4 - y0^4*y1^4*y2*y3^2 - + 5*y0^4*y1^3*y2^2*y3^2 + y0^3*y1^4*y2^2*y3^2 - y0^4*y1^2*y2^3*y3^2 - + 2*y0^4*y1^3*y2*y3^3 - y0^3*y1^4*y2*y3^3 - 3*y0^4*y1^2*y2^2*y3^3 - + y0^3*y1^4*y3^4 - y0^4*y1^2*y2^3*y3 + y0^4*y1^3*y2*y3^2 - + 3*y0^3*y1^4*y2*y3^2 - y0^4*y1^2*y2^2*y3^2 - 2*y0^3*y1^3*y2^2*y3^2 - + y0^4*y1*y2^3*y3^2 - 2*y0^3*y1^4*y3^3 + y0^4*y1^2*y2*y3^3 - + 5*y0^3*y1^3*y2*y3^3 + y0^4*y1^2*y2^2*y3 - y0^3*y1^3*y2^2*y3 + + y0^4*y1^2*y2*y3^2 - y0^3*y1^3*y2*y3^2 - y0^2*y1^4*y2*y3^2 + + y0^4*y1*y2^2*y3^2 - 4*y0^3*y1^2*y2^2*y3^2 + y0^3*y1^3*y3^3 - + 2*y0^2*y1^4*y3^3 + y0^3*y1^2*y2*y3^3 + y0^3*y1^3*y2*y3 - + y0^3*y1*y2^3*y3 + y0^3*y1^3*y3^2 + 5*y0^3*y1^2*y2*y3^2 - + 2*y0^2*y1^3*y2*y3^2 + y0^3*y1*y2^2*y3^2 + y0^2*y1^3*y3^3 + + y0^3*y1^2*y2*y3 + y0^2*y1^3*y2*y3 + 2*y0^3*y1*y2^2*y3 - + y0^2*y1^2*y2^2*y3 + 3*y0^2*y1^3*y3^2 + 4*y0^2*y1^2*y2*y3^2 + + y0^2*y1^2*y3^3 - y0^3*y1*y2*y3 + 4*y0^2*y1^2*y2*y3 + + 2*y0^2*y1*y2^2*y3 + y0^2*y1^2*y3^2 + y0*y1^3*y3^2 + + 2*y0^2*y1*y2*y3^2 + y0^2*y1*y2^2 - y0^2*y1^2*y3 - y0^2*y1*y2*y3 + + y0*y1^2*y2*y3 + y0^2*y2^2*y3 - y0^2*y1*y3^2 + y0*y1^2*y3^2 - + y0^2*y1*y2 - y0^2*y1*y3 - y0*y1^2*y3 - y0^2*y2*y3 - 2*y0*y1*y3^2 - + y0*y1*y2 - 3*y0*y1*y3 - 2*y0*y2*y3 - + y0*y2 + y0*y3 - y1*y3 + y0 + y3 + 1) * + (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y1*y3 + 1)^-1 * + (-y0*y1*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * + (-y0*y2*y3 + 1)^-1 * (-y0*y1^2*y3 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 + [0, 2]: (An equation (1, 0, -1, -1) x - 1 == 0, + An inequality (-1, 1, 1, 0) x + 1 >= 0, + An inequality (1, 0, -1, 0) x - 1 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0) + y0 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [1, 2]: (An equation (1, -1, -1, 0) x - 1 == 0, + An inequality (0, -1, 0, 1) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, 0, -1) x + 0 >= 0, + An inequality (1, -1, 0, 0) x - 1 >= 0) + (-y0^2*y2*y3 + y0*y3 + y0) * + (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1, 2]: (An equation (0, 1, 0, -1) x + 0 == 0, + An equation (1, -1, -1, 0) x - 1 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, -1, 0, 0) x - 1 >= 0) + y0 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + [3]: (An inequality (-1, 0, 0, 1) x + 0 >= 0, + An inequality (0, -1, -1, 1) x - 1 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, -1, 0) x + 0 >= 0) + (-y0*y1*y3^2 - y0*y3^2 + y0*y3 + y3) * + (-y3 + 1)^-1 * (-y0*y3 + 1)^-1 * + (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 3]: (An equation -1 == 0,) + 0 + [1, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, + An inequality (1, -1, -1, 0) x - 1 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0) + y0*y3 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1, 3]: (An equation -1 == 0,) + 0 + [2, 3]: (An equation (0, 1, 1, -1) x + 1 == 0, + An inequality (1, 0, -1, 0) x + 0 >= 0, + An inequality (-1, 1, 1, 0) x + 1 >= 0, + An inequality (0, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0) + (-y0*y1*y3^2 + y0*y3 + y3) * + (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 2, 3]: (An equation -1 == 0,) + 0 + [1, 2, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, + An equation (1, -1, -1, 0) x - 1 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, -1, 0, 0) x - 1 >= 0) + y0*y3 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 1, 2, 3]: (An equation -1 == 0,) + 0 + [4]: (An inequality (-1, -1, 0, 1) x - 1 >= 0, + An inequality (-1, 0, 1, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0) + y3 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 4]: (An equation -1 == 0,) + 0 + [1, 4]: (An equation -1 == 0,) + 0 + [0, 1, 4]: (An equation -1 == 0,) + 0 + [2, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, + An inequality (-1, 0, 1, 0) x + 0 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0, + An inequality (0, 1, 0, 0) x + 0 >= 0) + y3 * (-y2 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 2, 4]: (An equation -1 == 0,) + 0 + [1, 2, 4]: (An equation -1 == 0,) + 0 + [0, 1, 2, 4]: (An equation -1 == 0,) + 0 + [3, 4]: (An equation (1, 0, -1, 0) x + 0 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (-1, -1, 0, 1) x - 1 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0) + y3 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 3, 4]: (An equation -1 == 0,) + 0 + [1, 3, 4]: (An equation -1 == 0,) + 0 + [0, 1, 3, 4]: (An equation -1 == 0,) + 0 + [2, 3, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, + An equation (1, 0, -1, 0) x + 0 == 0, + An inequality (0, 1, 0, 0) x + 0 >= 0, + An inequality (1, 0, 0, 0) x + 0 >= 0) + y3 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 + [0, 2, 3, 4]: (An equation -1 == 0,) + 0 + [1, 2, 3, 4]: (An equation -1 == 0,) + 0 + [0, 1, 2, 3, 4]: (An equation -1 == 0,) + 0 + TESTS:: -def prepare_inequalities(inequalities, B): - r""" - EXAMPLES:: + sage: generating_function_of_polyhedron( + ....: Polyhedron(ieqs=[(0, 0, 1, 0, 0), (-1, 1, -1, 0, 0)]), + ....: sort_factors=True) + y0 * (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y0*y1 + 1)^-1 + sage: generating_function_of_polyhedron( + ....: Polyhedron(ieqs=[(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), + ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)]), + ....: sort_factors=True) + (-y0^2*y3 + y0*y3 + y0) * + (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - sage: B = LaurentPolynomialRing(ZZ, 'y', 3) - sage: prepare_inequalities([(0, -1, 1, 0), (2, -1, -1, 1)], B) - ([(2, -2, -1, 1)], 1, {y2: y2, y1: y1, y0: y0*y1}) - sage: prepare_inequalities([(-1, -1, 1, 0), (2, -1, -1, 1)], B) - ([(1, -2, -1, 1)], y1, {y2: y2, y1: y1, y0: y0*y1}) - sage: prepare_inequalities([(2, -1, 1, 0), (2, -1, -1, 1)], B) - ([(4, -2, -1, 1)], y1^-2, {y2: y2, y1: y1, y0: y0*y1}) + sage: generating_function_of_polyhedron( + ....: Polyhedron(ieqs=[(0, 1, 0, -1, 0, 0), (0, 0, 0, 1, 0, 0)], + ....: eqns=[(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), + ....: (0, 1, -1, 0, 0, 0)]), + ....: sort_factors=True) + 1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y2*y3*y4 + 1)^-1 - TESTS:: + :: - sage: B = LaurentPolynomialRing(ZZ, 'y', 3) - sage: prepare_inequalities([(1, 1, -1, 0), (1, -1, 0, 1), - ....: (2, -1, -1, 3)], B) - ([(-3, 2, 1, 3)], y0^-1*y2^-2, {y2: y2, y1: y0*y1*y2, y0: y0*y2}) + sage: G = generating_function_of_polyhedron(P2[0], sort_factors=True) + sage: S = generating_function_of_polyhedron(P2[0], sort_factors=True, + ....: split=True) + sage: sum(S) == G.value() + True - sage: B = LaurentPolynomialRing(ZZ, 'y', 4) - sage: prepare_inequalities([(-1, 1, -1, 0, 0)], B) - ([], y0, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) - sage: prepare_inequalities([(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), - ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)], B) - ([(1, 1, 0, 0, -1)], y0, {y3: y3, y2: y2, y1: y0*y1*y3, y0: y0}) - sage: prepare_inequalities([(-2, 1, -1, 0, 0)], B) - ([], y0^2, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) + sage: G = generating_function_of_polyhedron(P2[1], sort_factors=True) + sage: S = generating_function_of_polyhedron(P2[1], sort_factors=True, + ....: split=True) + sage: sum(S) == G.value() + True - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), - ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y2^3*y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), - ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y2^2*y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y1^2*y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y1^3*y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y1^2*y2^3*y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y1^3*y2^2*y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + sage: G = generating_function_of_polyhedron(P3[0], sort_factors=True) + sage: S = generating_function_of_polyhedron(P3[0], sort_factors=True, + ....: split=True) + sage: sum(S) == G.value() + True """ import logging logger = logging.getLogger(__name__) - from itertools import takewhile - from sage.graphs.digraph import DiGraph - from sage.matrix.constructor import matrix - from sage.modules.free_module_element import vector - from sage.rings.integer_ring import ZZ + from sage.combinat.permutation import Permutations + from sage.geometry.polyhedron.constructor import Polyhedron - inequalities_filtered = [] - chain_links = {} - for coeffs in inequalities: - dim = len(coeffs) - if all(c >= 0 for c in coeffs): - logger.debug('generating_function_of_polyhedron: ' - 'skipping %s (all coefficients >= 0)', - pretty_inequality(coeffs)) - continue - constant = coeffs[0] - ones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == 1) - mones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == -1) - absgetwo = tuple(i+1 for i, c in enumerate(coeffs[1:]) if abs(c) >= 2) - if len(ones) == 1 and not mones and not absgetwo: - if constant < 0: - # TODO: could be skipped... - inequalities_filtered.append(coeffs) - elif len(ones) == 1 and len(mones) == 1 and not absgetwo: - logger.debug('generating_function_of_polyhedron: ' - 'handling %s', - pretty_inequality(coeffs)) - chain_links[(mones[0], ones[0])] = constant + if result_as_tuple is None: + result_as_tuple = split + + if polyhedron.is_empty(): + from sage.structure.factorization import Factorization + result = Factorization([], unit=0) + if result_as_tuple: + return Summandization((result,)) else: - inequalities_filtered.append(coeffs) + return result - G = DiGraph(chain_links, format='list_of_edges') - potential = {} - paths = {} - D = {} - inequalities_extra = [] - for i in range(dim): - D[(i, i)] = 1 - for v in G.topological_sort(): - NP = iter(sorted(((n, potential[n] + chain_links[(n, v)]) - for n in G.neighbor_in_iterator(v)), - key=lambda k: k[1])) - n, p = next(NP, (None, 0)) - potential[v] = p - D[(0, v)] = -p - paths[v] = paths.get(n, ()) + (v,) - for u in paths[v]: - D[(u, v)] = 1 + logger.info('generating_function_of_polyhedron: %s', polyhedron) - for n, p in NP: - ell = len(tuple(takewhile(lambda u: u[0] == u[1], - zip(paths[n], paths[v])))) - coeffs = dim*[0] - for u in paths[v][ell:]: - coeffs[u] = 1 - for u in paths[n][ell:]: - coeffs[u] = -1 - coeffs[0] = p - potential[v] - inequalities_extra.append(tuple(coeffs)) - T = matrix(ZZ, dim, dim, D) + if split is False: + result = _generating_function_of_polyhedron_(polyhedron, **kwds) + if result_as_tuple: + return Summandization(result) + else: + if len(result) != 1: + raise ValueError("Cannot unpack result. " + "(Set 'result_as_tuple=True'.)") + return result[0] - inequalities = list(tuple(T*vector(ieq)) - for ieq in inequalities_filtered) + \ - inequalities_extra + d = polyhedron.ambient_dim() + if d <= 1: + raise ValueError('Cannot do splitting with only ' + 'dimension {}.'.format(d)) - rules_pre = iter((y, B({tuple(row[1:]): 1})) - for y, row in zip((1,) + B.gens(), T.rows())) - factor = next(rules_pre)[1] - rules = dict(rules_pre) + if split is True: + split = iter( + (Polyhedron( + ieqs=[tuple(1 if i==b else (-1 if i==a or i==0 and a > b else 0) + for i in range(d+1)) + for a, b in zip(pi[:-1], pi[1:])]), + 'b{}'.format(pi[0]-1) + + ''.join((' <= ' if a < b else ' < ') + + 'b{}'.format(b-1) + for a, b in zip(pi[:-1], pi[1:]))) + for pi in Permutations(d)) + else: + split = iter((ph, ph.repr_pretty_Hrepresentation(prefix='b')) + for ph in split) - return inequalities, factor, rules + result = [] + for split_polyhedron, pi_log in split: + logger.info('split polyhedron by %s', pi_log) + result.append(_generating_function_of_polyhedron_( + polyhedron & split_polyhedron, **kwds)) + if not result_as_tuple: + raise ValueError("Cannot unpack result." + "(Unset 'result_as_tuple=False'.)") + return Summandization(sum(result, ())) -def prepare_equations_transformation(E): +def _generating_function_of_polyhedron_( + polyhedron, indices=None, **kwds): r""" + Helper function for :func:`generating_function_of_polyhedron` which + does the actual computation of the generating function. + TESTS:: - sage: prepare_equations_transformation(matrix([(0, 1, 0, -2)])) - ([ 0 -1/2 0 1], (3,), (0, 1)) - sage: prepare_equations_transformation(matrix([(0, 1, -2, 0), (0, 2, 0, -3)])) - ( - [ 0 -1/2 1 0] - [ 0 -2/3 0 1], (2, 3), (0, 1) - ) + sage: generating_function_of_polyhedron( # indirect doctest + ....: Polyhedron(ieqs=[(0, 1, 0, 0), (0, -1, 1, 0)], + ....: eqns=[(0, -1, -1, 2)]), + ....: result_as_tuple=True, sort_factors=True) + (-y0^2*y1^2*y2^2 + 1) * (-y1^2*y2 + 1)^-1 * + (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 + + (-y0^3*y1^3*y2^3 + y0*y1*y2) * (-y1^2*y2 + 1)^-1 * + (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 """ - indices_nonzero = tuple(i for i, col in enumerate(E.columns()) - if i > 0 and not col.is_zero()) - indices = [] - r = 0 - for i in reversed(indices_nonzero): - indices.append(i) - r1 = E.matrix_from_columns(indices).rank() - if r1 > r: - r = r1 - if len(indices) >= E.nrows(): - break - else: - indices = indices[:-1] - assert len(indices) == E.nrows() - indices = tuple(reversed(indices)) - indicesn = (0,) + tuple(i for i in indices_nonzero if i not in indices) - TE = E.matrix_from_columns(indices).inverse() * E - return TE, indices, indicesn + import logging + logger = logging.getLogger(__name__) + logger.info('polyhedron: %s', + polyhedron.repr_pretty_Hrepresentation(prefix='b')) -def prepare_equations(equations, B): - r""" - EXAMPLES:: + if polyhedron.is_empty(): + from sage.structure.factorization import Factorization + return (Factorization([], unit=0),) - sage: B = LaurentPolynomialRing(ZZ, 'y', 4) - sage: prepare_equations([(1, 1, 1, -1, 0)], B) - (y2, {y1: y1*y2, y0: y0*y2}, (2,)) - sage: prepare_equations([(0, 1, 0, -1, 0)], B) - (1, {y0: y0*y2}, (2,)) - sage: prepare_equations([(-1, 0, 1, -1, -1), (1, 1, 0, 1, 2)], B) - (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (2, 3)) + Hrepr = polyhedron.Hrepresentation() - TESTS:: + inequalities = tuple(tuple(entry) + for entry in Hrepr if entry.is_inequality()) + equations = tuple(tuple(entry) + for entry in Hrepr if entry.is_equation()) + if len(inequalities) + len(equations) != len(Hrepr): + raise ValueError('Cannot handle {}.'.format(polyhedron)) - sage: B = LaurentPolynomialRing(ZZ, 'y', 4) - sage: prepare_equations([(0, 0, 1, 0, -1), (-1, 1, -1, -1, 0)], B) - (y2^-1, {y1: y1*y2^-1*y3, y0: y0*y2}, (2, 3)) + if not inequalities: + raise NotImplementedError('no inequality given') - sage: B = LaurentPolynomialRing(ZZ, 'y', 5) - sage: prepare_equations([(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), - ....: (0, 1, -1, 0, 0, 0)], B) - (1, {y2: y2*y4, y0: y0*y1*y3}, (1, 3, 4)) - """ - from sage.matrix.constructor import matrix - from sage.misc.misc_c import prod + if indices is None: + indices = range(len(inequalities[0]) - 1) - E = matrix(equations) - if not E: - return 1, {}, () + n = len(indices) + 1 + if any(len(e) != n for e in inequalities): + raise ValueError('Not all coefficient vectors of the inequalities ' + 'have the same length.') + if any(len(e) != n for e in equations): + raise ValueError('Not all coefficient vectors of the equations ' + 'have the same length.') - TE, indices, indicesn = prepare_equations_transformation(E) + logger.info('generating_function_of_polyhedron: ' + '%s inequalities', len(inequalities)) - gens = (1,) + B.gens() - z = tuple(gens[i] for i in indices) - gens_cols = zip(gens, TE.columns()) - rules_pre = iter((y, y * prod(zz**(-c) for zz, c in zip(z, col))) - for y, col in (gens_cols[i] for i in indicesn)) - factor = next(rules_pre)[1] - rules = dict(rules_pre) + mods = generate_mods(equations) + logger.info('splitting by moduli %s', mods) - return factor, rules, tuple(i-1 for i in indices) + return tuple(__generating_function_of_polyhedron__( + indices, inequalities, equations, mod, **kwds) for mod in mods) -def generate_mods(equations): - from sage.arith.misc import lcm - from sage.matrix.constructor import matrix +def __generating_function_of_polyhedron__( + indices, inequalities, equations, mod, + Factorization_sort=False, Factorization_simplify=False, + sort_factors=False): + r""" + Helper function for :func:`generating_function_of_polyhedron` which + does the actual computation of the generating function. + + TESTS:: + + sage: __generating_function_of_polyhedron__( + ....: (0, 2), [(0, 1, 0)], [(1, -1, 2)], + ....: {0: (2, 1)}, sort_factors=True) + y0 * (-y0^2*y2 + 1)^-1 + sage: __generating_function_of_polyhedron__( + ....: srange(3), [(0, 1, 0, 0), (0, 0, 1, 0)], [(1, -1, 0, 2)], + ....: {0: (2, 1)}, sort_factors=True) + y0 * (-y1 + 1)^-1 * (-y0^2*y2 + 1)^-1 + sage: __generating_function_of_polyhedron__( + ....: srange(3), [(0, 1, 0, 0), (0, -1, 1, 0)], [(0, -1, -1, 2)], + ....: {0: (2, 1), 1: (2, 1)}, sort_factors=True) + (-y0^3*y1^3*y2^3 + y0*y1*y2) * + (-y1^2*y2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 + """ + import logging + logger = logging.getLogger(__name__) + + from omega import _Omega_ + from omega import partition from sage.rings.integer_ring import ZZ - from sage.rings.rational_field import QQ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + from sage.structure.factorization import Factorization - TE, TEi, TEin = prepare_equations_transformation(matrix(equations)) - TEin = TEin[1:] - if TE.base_ring() == ZZ: - mods = [{}] - elif TE.base_ring() == QQ: - m = lcm([e.denominator() for e in TE.list()]) - if m == 1: - mods = [{}] - else: - cols = TE.columns() - assert all(cols[j][i] == 1 for i, j in enumerate(TEi)) - pre_mods = compositions_mod((tuple(ZZ(cc*m) for cc in cols[i]) - for i in TEin), - m, r=(-cc*m for cc in cols[0]), - multidimensional=True) - mods = tuple({i-1: (aa.modulus(), ZZ(aa)) - for i, aa in zip(TEin, a) if aa.modulus() > 1} - for a in pre_mods) - else: - raise TypeError('Equations over ZZ or QQ expected, but got ' - 'equations over {}.'.format(TE.base_ring())) + B = LaurentPolynomialRing( + ZZ, + tuple('y{}'.format(k) for k in indices), + sparse=True) - return mods + extra_factor_mod, rules_mod, inequalities, equations = \ + prepare_mod(mod, B, inequalities, equations) + extra_factor_equations, rules_equations, indices_equations = \ + prepare_equations(equations, B) -def prepare_mod(mod, B, *vecs): - r""" - EXAMPLES:: + inequalities, extra_factor_inequalities, rules_inequalities = \ + prepare_inequalities(inequalities, B) - sage: B = LaurentPolynomialRing(ZZ, 'y', 3) - sage: prepare_mod({0: (2, 1)}, B, [(1, -1, 0, 2)]) - (y0, {y2: y2, y1: y1, y0: y0^2}, ((0, -2, 0, 2),)) - sage: prepare_mod({0: (2, 1), 1: (2, 1)}, B, - ....: [(0, -1, -1, 2)], [(0, -1, 1, 0)]) - (y0*y1, {y2: y2, y1: y1^2, y0: y0^2}, - ((-2, -2, -2, 2),), ((0, -2, 2, 0),)) - """ - from sage.matrix.constructor import matrix - from sage.modules.free_module_element import vector - from sage.rings.integer_ring import ZZ + numerator = B(1) + terms = B.gens() + L = B + for i, coeffs in enumerate(inequalities): + L = LaurentPolynomialRing(L, 'mu{}'.format(i), sparse=True) + l = L.gen() + logger.debug('generating_function_of_polyhedron: ' + '%s --> %s', l, pretty_inequality(coeffs)) + it_coeffs = iter(coeffs) + numerator *= l**next(it_coeffs) + assert numerator.parent() == L + terms = tuple(l**c * t for c, t in zip(it_coeffs, terms)) + assert all(y == t for y, t in + (zip(B.gens(), terms)[i] for i in indices_equations)) + terms = tuple(t for i, t in enumerate(terms) + if i not in indices_equations) - if not mod: - return (1, {}) + vecs + logger.info('generating_function_of_polyhedron: ' + 'terms denominator %s', terms) - n = len(B.gens()) + 1 + def decode_factor(factor): + D = factor.dict() + assert len(D) == 1 + exponent, coefficient = next(iteritems(D)) + return coefficient, exponent - D = {(i, i): 1 for i in range(n)} - for i, mr in iteritems(mod): - D[(i+1, i+1)] = mr[0] - D[(i+1, 0)] = mr[1] - T = matrix(ZZ, n, n, D) + while repr(numerator.parent().gen()).startswith('mu'): + logger.info('generating_function_of_polyhedron: ' + 'applying Omega[%s]...', numerator.parent().gen()) + logger.info('...on terms denominator %s', terms) + logger.info('...(numerator has %s)', numerator.number_of_terms()) - rules_pre = iter((y, B({tuple(row[1:]): 1})) - for y, row in zip((1,) + B.gens(), T.columns())) - factor = next(rules_pre)[1] - rules = dict(rules_pre) + decoded_factors, other_factors = \ + partition((decode_factor(factor) for factor in terms), + lambda factor: factor[1] == 0) + other_factors = tuple(factor[0] for factor in other_factors) + numerator, factors_denominator = \ + _Omega_(numerator.dict(), tuple(decoded_factors)) + terms = other_factors + factors_denominator - vecs = tuple(tuple(tuple(vector(e)*T) for e in vec) for vec in vecs) + numerator = \ + (((numerator.subs(rules_inequalities) * extra_factor_inequalities + ).subs(rules_equations) * extra_factor_equations + ).subs(rules_mod) * extra_factor_mod) + terms = tuple( + t.subs(rules_inequalities).subs(rules_equations).subs(rules_mod) + for t in terms) - return (factor, rules) + vecs + if sort_factors: + def key(t): + D = t.dict().popitem()[0] + return (-sum(abs(d) for d in D), D) + terms = sorted(terms, key=key, reverse=True) + return Factorization([(numerator, 1)] + + list((1-t, -1) for t in terms), + sort=Factorization_sort, + simplify=Factorization_simplify) -def generating_function_of_polyhedron(polyhedron, split=False, - result_as_tuple=None, **kwds): - r""" - Return the generating function of the integer points of - the polyhedron's orthant with only nonnegative coordinates. +def pretty_inequality(ineq, indices=None): + from sage.symbolic.ring import SR + from sage.modules.free_module_element import vector + + if indices is None: + indices = range(len(ineq)-1) + vars = vector([1] + list(SR("b{}".format(i)) for i in indices)) + v = vector(ineq) + positive_part = vector([max(c, 0) for c in v]) + negative_part = - (v - positive_part) + assert v == positive_part - negative_part + return '{} >= {}'.format(positive_part*vars, negative_part*vars) + + +class Summandization(tuple): + def __repr__(self): + return ' + '.join(repr(s) for s in self) + + __str__ = __repr__ + +def prepare_inequalities(inequalities, B): + r""" EXAMPLES:: - sage: P2 = ( - ....: Polyhedron(ieqs=[(0, 0, 0, 1), (0, 0, 1, 0), (0, 1, 0, -1)]), - ....: Polyhedron(ieqs=[(0, -1, 0, 1), (0, 1, 0, 0), (0, 0, 1, 0)])) - sage: generating_function_of_polyhedron(P2[0], sort_factors=True) - 1 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 - sage: generating_function_of_polyhedron(P2[1], sort_factors=True) - 1 * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 - sage: (P2[0] & P2[1]).Hrepresentation() - (An equation (1, 0, -1) x + 0 == 0, - An inequality (1, 0, 0) x + 0 >= 0, - An inequality (0, 1, 0) x + 0 >= 0) - sage: generating_function_of_polyhedron(P2[0] & P2[1], sort_factors=True) - 1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 + sage: B = LaurentPolynomialRing(ZZ, 'y', 3) + sage: prepare_inequalities([(0, -1, 1, 0), (2, -1, -1, 1)], B) + ([(2, -2, -1, 1)], 1, {y2: y2, y1: y1, y0: y0*y1}) + sage: prepare_inequalities([(-1, -1, 1, 0), (2, -1, -1, 1)], B) + ([(1, -2, -1, 1)], y1, {y2: y2, y1: y1, y0: y0*y1}) + sage: prepare_inequalities([(2, -1, 1, 0), (2, -1, -1, 1)], B) + ([(4, -2, -1, 1)], y1^-2, {y2: y2, y1: y1, y0: y0*y1}) - :: + TESTS:: + + sage: B = LaurentPolynomialRing(ZZ, 'y', 3) + sage: prepare_inequalities([(1, 1, -1, 0), (1, -1, 0, 1), + ....: (2, -1, -1, 3)], B) + ([(-3, 2, 1, 3)], y0^-1*y2^-2, {y2: y2, y1: y0*y1*y2, y0: y0*y2}) + + sage: B = LaurentPolynomialRing(ZZ, 'y', 4) + sage: prepare_inequalities([(-1, 1, -1, 0, 0)], B) + ([], y0, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) + sage: prepare_inequalities([(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), + ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)], B) + ([(1, 1, 0, 0, -1)], y0, {y3: y3, y2: y2, y1: y0*y1*y3, y0: y0}) + sage: prepare_inequalities([(-2, 1, -1, 0, 0)], B) + ([], y0^2, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) + + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), + ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y2^3*y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), + ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y2^2*y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y1^2*y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y1^3*y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, -1, 1, 1)], + y1^2*y2^3*y3^3, + {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) + sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), + ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) + ([(1, 0, 1, -1, 1)], + y1^3*y2^2*y3^3, + {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) + """ + import logging + logger = logging.getLogger(__name__) + + from itertools import takewhile + from sage.graphs.digraph import DiGraph + from sage.matrix.constructor import matrix + from sage.modules.free_module_element import vector + from sage.rings.integer_ring import ZZ + + inequalities_filtered = [] + chain_links = {} + for coeffs in inequalities: + dim = len(coeffs) + if all(c >= 0 for c in coeffs): + logger.debug('generating_function_of_polyhedron: ' + 'skipping %s (all coefficients >= 0)', + pretty_inequality(coeffs)) + continue + constant = coeffs[0] + ones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == 1) + mones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == -1) + absgetwo = tuple(i+1 for i, c in enumerate(coeffs[1:]) if abs(c) >= 2) + if len(ones) == 1 and not mones and not absgetwo: + if constant < 0: + # TODO: could be skipped... + inequalities_filtered.append(coeffs) + elif len(ones) == 1 and len(mones) == 1 and not absgetwo: + logger.debug('generating_function_of_polyhedron: ' + 'handling %s', + pretty_inequality(coeffs)) + chain_links[(mones[0], ones[0])] = constant + else: + inequalities_filtered.append(coeffs) + + G = DiGraph(chain_links, format='list_of_edges') + potential = {} + paths = {} + D = {} + inequalities_extra = [] + for i in range(dim): + D[(i, i)] = 1 + for v in G.topological_sort(): + NP = iter(sorted(((n, potential[n] + chain_links[(n, v)]) + for n in G.neighbor_in_iterator(v)), + key=lambda k: k[1])) + n, p = next(NP, (None, 0)) + potential[v] = p + D[(0, v)] = -p + paths[v] = paths.get(n, ()) + (v,) + for u in paths[v]: + D[(u, v)] = 1 + + for n, p in NP: + ell = len(tuple(takewhile(lambda u: u[0] == u[1], + zip(paths[n], paths[v])))) + coeffs = dim*[0] + for u in paths[v][ell:]: + coeffs[u] = 1 + for u in paths[n][ell:]: + coeffs[u] = -1 + coeffs[0] = p - potential[v] + inequalities_extra.append(tuple(coeffs)) + T = matrix(ZZ, dim, dim, D) + + inequalities = list(tuple(T*vector(ieq)) + for ieq in inequalities_filtered) + \ + inequalities_extra + + rules_pre = iter((y, B({tuple(row[1:]): 1})) + for y, row in zip((1,) + B.gens(), T.rows())) + factor = next(rules_pre)[1] + rules = dict(rules_pre) + + return inequalities, factor, rules - sage: P3 = ( - ....: Polyhedron( - ....: ieqs=[(0, 0, 0, 0, 1), (0, 0, 0, 1, 0), - ....: (0, 0, 1, 0, -1), (-1, 1, 0, -1, -1)]), - ....: Polyhedron( - ....: ieqs=[(0, 0, -1, 0, 1), (0, 1, 0, 0, -1), - ....: (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), (-1, 1, -1, -1, 0)]), - ....: Polyhedron( - ....: ieqs=[(1, -1, 0, 1, 1), (1, -1, 1, 1, 0), - ....: (0, 0, 0, 0, 1), (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), - ....: (1, 0, 1, 1, -1), (0, 1, 0, 0, 0), (1, 1, 1, 0, -1)]), - ....: Polyhedron( - ....: ieqs=[(0, 1, 0, -1, 0), (0, -1, 0, 0, 1), - ....: (-1, 0, -1, -1, 1), (0, 0, 1, 0, 0), (0, 0, 0, 1, 0)]), - ....: Polyhedron( - ....: ieqs=[(0, 1, 0, 0, 0), (0, 0, 1, 0, 0), - ....: (-1, -1, -1, 0, 1), (0, -1, 0, 1, 0)])) - sage: def intersect(I): - ....: I = iter(I) - ....: result = next(I) - ....: for i in I: - ....: result &= i - ....: return result - sage: for J in subsets(range(len(P3))): # TODO: check more results - ....: if not J: - ....: continue - ....: P = intersect([P3[j] for j in J]) - ....: print('{}: {}'.format(J, P.Hrepresentation())) - ....: print(generating_function_of_polyhedron(P, sort_factors=True)) - [0]: (An inequality (0, 0, 0, 1) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, -1) x + 0 >= 0, - An inequality (1, 0, -1, -1) x - 1 >= 0) - y0 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [1]: (An inequality (0, -1, 0, 1) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, -1, -1, 0) x - 1 >= 0, - An inequality (1, 0, 0, -1) x + 0 >= 0) - (-y0^2*y2*y3 - y0^2*y3 + y0*y3 + y0) * - (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y3 + 1)^-1 * - (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1]: (An equation (0, 1, 0, -1) x + 0 == 0, - An inequality (1, -1, -1, 0) x - 1 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0) - y0 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [2]: (An inequality (-1, 0, 1, 1) x + 1 >= 0, - An inequality (-1, 1, 1, 0) x + 1 >= 0, - An inequality (0, 0, 0, 1) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (0, 1, 1, -1) x + 1 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0, - An inequality (1, 1, 0, -1) x + 1 >= 0) - (y0^7*y1^6*y2^3*y3^5 + y0^7*y1^5*y2^4*y3^4 + y0^6*y1^7*y2^2*y3^5 - - y0^7*y1^5*y2^3*y3^4 + y0^6*y1^6*y2^3*y3^4 - y0^6*y1^6*y2^2*y3^5 - - 2*y0^6*y1^6*y2^2*y3^4 - 3*y0^6*y1^5*y2^3*y3^4 - y0^6*y1^5*y2^2*y3^5 - - y0^6*y1^5*y2^3*y3^3 - y0^6*y1^4*y2^4*y3^3 + y0^6*y1^5*y2^2*y3^4 - - 2*y0^5*y1^6*y2^2*y3^4 - 2*y0^6*y1^4*y2^3*y3^4 - y0^5*y1^6*y2*y3^5 + - y0^6*y1^5*y2^2*y3^3 + y0^6*y1^4*y2^3*y3^3 - y0^5*y1^5*y2^3*y3^3 - - y0^6*y1^3*y2^4*y3^3 + y0^6*y1^4*y2^2*y3^4 - y0^5*y1^5*y2^2*y3^4 + - y0^5*y1^5*y2*y3^5 + 3*y0^5*y1^5*y2^2*y3^3 + y0^6*y1^3*y2^3*y3^3 + - 2*y0^5*y1^5*y2*y3^4 - y0^4*y1^6*y2*y3^4 + 4*y0^5*y1^4*y2^2*y3^4 + - y0^5*y1^4*y2^3*y3^2 + 3*y0^5*y1^4*y2^2*y3^3 + 4*y0^5*y1^3*y2^3*y3^3 - - y0^5*y1^4*y2*y3^4 + 3*y0^4*y1^5*y2*y3^4 + y0^5*y1^3*y2^2*y3^4 - - y0^5*y1^4*y2^2*y3^2 + y0^5*y1^3*y2^3*y3^2 + y0^5*y1^2*y2^4*y3^2 - - y0^5*y1^4*y2*y3^3 + 2*y0^4*y1^5*y2*y3^3 - 2*y0^5*y1^3*y2^2*y3^3 + - 5*y0^4*y1^4*y2^2*y3^3 + y0^5*y1^2*y2^3*y3^3 - y0^5*y1^3*y2^2*y3^2 - - y0^5*y1^2*y2^3*y3^2 + 2*y0^4*y1^3*y2^3*y3^2 - 4*y0^4*y1^4*y2*y3^3 + - 2*y0^3*y1^5*y2*y3^3 - y0^5*y1^2*y2^2*y3^3 - y0^4*y1^3*y2^2*y3^3 + - y0^3*y1^5*y3^4 - y0^4*y1^3*y2*y3^4 - y0^4*y1^4*y2*y3^2 - - 5*y0^4*y1^3*y2^2*y3^2 + y0^3*y1^4*y2^2*y3^2 - y0^4*y1^2*y2^3*y3^2 - - 2*y0^4*y1^3*y2*y3^3 - y0^3*y1^4*y2*y3^3 - 3*y0^4*y1^2*y2^2*y3^3 - - y0^3*y1^4*y3^4 - y0^4*y1^2*y2^3*y3 + y0^4*y1^3*y2*y3^2 - - 3*y0^3*y1^4*y2*y3^2 - y0^4*y1^2*y2^2*y3^2 - 2*y0^3*y1^3*y2^2*y3^2 - - y0^4*y1*y2^3*y3^2 - 2*y0^3*y1^4*y3^3 + y0^4*y1^2*y2*y3^3 - - 5*y0^3*y1^3*y2*y3^3 + y0^4*y1^2*y2^2*y3 - y0^3*y1^3*y2^2*y3 + - y0^4*y1^2*y2*y3^2 - y0^3*y1^3*y2*y3^2 - y0^2*y1^4*y2*y3^2 + - y0^4*y1*y2^2*y3^2 - 4*y0^3*y1^2*y2^2*y3^2 + y0^3*y1^3*y3^3 - - 2*y0^2*y1^4*y3^3 + y0^3*y1^2*y2*y3^3 + y0^3*y1^3*y2*y3 - - y0^3*y1*y2^3*y3 + y0^3*y1^3*y3^2 + 5*y0^3*y1^2*y2*y3^2 - - 2*y0^2*y1^3*y2*y3^2 + y0^3*y1*y2^2*y3^2 + y0^2*y1^3*y3^3 + - y0^3*y1^2*y2*y3 + y0^2*y1^3*y2*y3 + 2*y0^3*y1*y2^2*y3 - - y0^2*y1^2*y2^2*y3 + 3*y0^2*y1^3*y3^2 + 4*y0^2*y1^2*y2*y3^2 + - y0^2*y1^2*y3^3 - y0^3*y1*y2*y3 + 4*y0^2*y1^2*y2*y3 + - 2*y0^2*y1*y2^2*y3 + y0^2*y1^2*y3^2 + y0*y1^3*y3^2 + - 2*y0^2*y1*y2*y3^2 + y0^2*y1*y2^2 - y0^2*y1^2*y3 - y0^2*y1*y2*y3 + - y0*y1^2*y2*y3 + y0^2*y2^2*y3 - y0^2*y1*y3^2 + y0*y1^2*y3^2 - - y0^2*y1*y2 - y0^2*y1*y3 - y0*y1^2*y3 - y0^2*y2*y3 - 2*y0*y1*y3^2 - - y0*y1*y2 - 3*y0*y1*y3 - 2*y0*y2*y3 - - y0*y2 + y0*y3 - y1*y3 + y0 + y3 + 1) * - (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y1*y3 + 1)^-1 * - (-y0*y1*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * - (-y0*y2*y3 + 1)^-1 * (-y0*y1^2*y3 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 - [0, 2]: (An equation (1, 0, -1, -1) x - 1 == 0, - An inequality (-1, 1, 1, 0) x + 1 >= 0, - An inequality (1, 0, -1, 0) x - 1 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0) - y0 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [1, 2]: (An equation (1, -1, -1, 0) x - 1 == 0, - An inequality (0, -1, 0, 1) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, 0, -1) x + 0 >= 0, - An inequality (1, -1, 0, 0) x - 1 >= 0) - (-y0^2*y2*y3 + y0*y3 + y0) * - (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 2]: (An equation (0, 1, 0, -1) x + 0 == 0, - An equation (1, -1, -1, 0) x - 1 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, -1, 0, 0) x - 1 >= 0) - y0 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [3]: (An inequality (-1, 0, 0, 1) x + 0 >= 0, - An inequality (0, -1, -1, 1) x - 1 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, -1, 0) x + 0 >= 0) - (-y0*y1*y3^2 - y0*y3^2 + y0*y3 + y3) * - (-y3 + 1)^-1 * (-y0*y3 + 1)^-1 * - (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 3]: (An equation -1 == 0,) - 0 - [1, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, - An inequality (1, -1, -1, 0) x - 1 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0) - y0*y3 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 3]: (An equation -1 == 0,) - 0 - [2, 3]: (An equation (0, 1, 1, -1) x + 1 == 0, - An inequality (1, 0, -1, 0) x + 0 >= 0, - An inequality (-1, 1, 1, 0) x + 1 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0) - (-y0*y1*y3^2 + y0*y3 + y3) * - (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 3]: (An equation -1 == 0,) - 0 - [1, 2, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, - An equation (1, -1, -1, 0) x - 1 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, -1, 0, 0) x - 1 >= 0) - y0*y3 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 2, 3]: (An equation -1 == 0,) - 0 - [4]: (An inequality (-1, -1, 0, 1) x - 1 >= 0, - An inequality (-1, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0) - y3 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 4]: (An equation -1 == 0,) - 0 - [1, 4]: (An equation -1 == 0,) - 0 - [0, 1, 4]: (An equation -1 == 0,) - 0 - [2, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, - An inequality (-1, 0, 1, 0) x + 0 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0) - y3 * (-y2 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 4]: (An equation -1 == 0,) - 0 - [1, 2, 4]: (An equation -1 == 0,) - 0 - [0, 1, 2, 4]: (An equation -1 == 0,) - 0 - [3, 4]: (An equation (1, 0, -1, 0) x + 0 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (-1, -1, 0, 1) x - 1 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0) - y3 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 3, 4]: (An equation -1 == 0,) - 0 - [1, 3, 4]: (An equation -1 == 0,) - 0 - [0, 1, 3, 4]: (An equation -1 == 0,) - 0 - [2, 3, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, - An equation (1, 0, -1, 0) x + 0 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0) - y3 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 3, 4]: (An equation -1 == 0,) - 0 - [1, 2, 3, 4]: (An equation -1 == 0,) - 0 - [0, 1, 2, 3, 4]: (An equation -1 == 0,) - 0 +def prepare_equations_transformation(E): + r""" TESTS:: - sage: generating_function_of_polyhedron( - ....: Polyhedron(ieqs=[(0, 0, 1, 0, 0), (-1, 1, -1, 0, 0)]), - ....: sort_factors=True) - y0 * (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y0*y1 + 1)^-1 - sage: generating_function_of_polyhedron( - ....: Polyhedron(ieqs=[(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), - ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)]), - ....: sort_factors=True) - (-y0^2*y3 + y0*y3 + y0) * - (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 + sage: prepare_equations_transformation(matrix([(0, 1, 0, -2)])) + ([ 0 -1/2 0 1], (3,), (0, 1)) + sage: prepare_equations_transformation(matrix([(0, 1, -2, 0), (0, 2, 0, -3)])) + ( + [ 0 -1/2 1 0] + [ 0 -2/3 0 1], (2, 3), (0, 1) + ) + """ + indices_nonzero = tuple(i for i, col in enumerate(E.columns()) + if i > 0 and not col.is_zero()) + indices = [] + r = 0 + for i in reversed(indices_nonzero): + indices.append(i) + r1 = E.matrix_from_columns(indices).rank() + if r1 > r: + r = r1 + if len(indices) >= E.nrows(): + break + else: + indices = indices[:-1] + assert len(indices) == E.nrows() + indices = tuple(reversed(indices)) + indicesn = (0,) + tuple(i for i in indices_nonzero if i not in indices) + TE = E.matrix_from_columns(indices).inverse() * E + return TE, indices, indicesn - sage: generating_function_of_polyhedron( - ....: Polyhedron(ieqs=[(0, 1, 0, -1, 0, 0), (0, 0, 0, 1, 0, 0)], - ....: eqns=[(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), - ....: (0, 1, -1, 0, 0, 0)]), - ....: sort_factors=True) - 1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y2*y3*y4 + 1)^-1 - :: +def prepare_equations(equations, B): + r""" + EXAMPLES:: - sage: G = generating_function_of_polyhedron(P2[0], sort_factors=True) - sage: S = generating_function_of_polyhedron(P2[0], sort_factors=True, - ....: split=True) - sage: sum(S) == G.value() - True + sage: B = LaurentPolynomialRing(ZZ, 'y', 4) + sage: prepare_equations([(1, 1, 1, -1, 0)], B) + (y2, {y1: y1*y2, y0: y0*y2}, (2,)) + sage: prepare_equations([(0, 1, 0, -1, 0)], B) + (1, {y0: y0*y2}, (2,)) + sage: prepare_equations([(-1, 0, 1, -1, -1), (1, 1, 0, 1, 2)], B) + (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (2, 3)) + + TESTS:: + + sage: B = LaurentPolynomialRing(ZZ, 'y', 4) + sage: prepare_equations([(0, 0, 1, 0, -1), (-1, 1, -1, -1, 0)], B) + (y2^-1, {y1: y1*y2^-1*y3, y0: y0*y2}, (2, 3)) + + sage: B = LaurentPolynomialRing(ZZ, 'y', 5) + sage: prepare_equations([(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), + ....: (0, 1, -1, 0, 0, 0)], B) + (1, {y2: y2*y4, y0: y0*y1*y3}, (1, 3, 4)) + """ + from sage.matrix.constructor import matrix + from sage.misc.misc_c import prod + + E = matrix(equations) + if not E: + return 1, {}, () + + TE, indices, indicesn = prepare_equations_transformation(E) + + gens = (1,) + B.gens() + z = tuple(gens[i] for i in indices) + gens_cols = zip(gens, TE.columns()) + rules_pre = iter((y, y * prod(zz**(-c) for zz, c in zip(z, col))) + for y, col in (gens_cols[i] for i in indicesn)) + factor = next(rules_pre)[1] + rules = dict(rules_pre) + + return factor, rules, tuple(i-1 for i in indices) + + +def generate_mods(equations): + from sage.arith.misc import lcm + from sage.matrix.constructor import matrix + from sage.rings.integer_ring import ZZ + from sage.rings.rational_field import QQ + + TE, TEi, TEin = prepare_equations_transformation(matrix(equations)) + TEin = TEin[1:] + if TE.base_ring() == ZZ: + mods = [{}] + elif TE.base_ring() == QQ: + m = lcm([e.denominator() for e in TE.list()]) + if m == 1: + mods = [{}] + else: + cols = TE.columns() + assert all(cols[j][i] == 1 for i, j in enumerate(TEi)) + pre_mods = compositions_mod((tuple(ZZ(cc*m) for cc in cols[i]) + for i in TEin), + m, r=(-cc*m for cc in cols[0]), + multidimensional=True) + mods = tuple({i-1: (aa.modulus(), ZZ(aa)) + for i, aa in zip(TEin, a) if aa.modulus() > 1} + for a in pre_mods) + else: + raise TypeError('Equations over ZZ or QQ expected, but got ' + 'equations over {}.'.format(TE.base_ring())) - sage: G = generating_function_of_polyhedron(P2[1], sort_factors=True) - sage: S = generating_function_of_polyhedron(P2[1], sort_factors=True, - ....: split=True) - sage: sum(S) == G.value() - True + return mods - sage: G = generating_function_of_polyhedron(P3[0], sort_factors=True) - sage: S = generating_function_of_polyhedron(P3[0], sort_factors=True, - ....: split=True) - sage: sum(S) == G.value() - True - """ - import logging - logger = logging.getLogger(__name__) - from sage.combinat.permutation import Permutations - from sage.geometry.polyhedron.constructor import Polyhedron +def prepare_mod(mod, B, *vecs): + r""" + EXAMPLES:: - if result_as_tuple is None: - result_as_tuple = split + sage: B = LaurentPolynomialRing(ZZ, 'y', 3) + sage: prepare_mod({0: (2, 1)}, B, [(1, -1, 0, 2)]) + (y0, {y2: y2, y1: y1, y0: y0^2}, ((0, -2, 0, 2),)) + sage: prepare_mod({0: (2, 1), 1: (2, 1)}, B, + ....: [(0, -1, -1, 2)], [(0, -1, 1, 0)]) + (y0*y1, {y2: y2, y1: y1^2, y0: y0^2}, + ((-2, -2, -2, 2),), ((0, -2, 2, 0),)) + """ + from sage.matrix.constructor import matrix + from sage.modules.free_module_element import vector + from sage.rings.integer_ring import ZZ - if polyhedron.is_empty(): - from sage.structure.factorization import Factorization - result = Factorization([], unit=0) - if result_as_tuple: - return Summandization((result,)) - else: - return result + if not mod: + return (1, {}) + vecs - logger.info('generating_function_of_polyhedron: %s', polyhedron) + n = len(B.gens()) + 1 - if split is False: - result = _generating_function_of_polyhedron_(polyhedron, **kwds) - if result_as_tuple: - return Summandization(result) - else: - if len(result) != 1: - raise ValueError("Cannot unpack result. " - "(Set 'result_as_tuple=True'.)") - return result[0] + D = {(i, i): 1 for i in range(n)} + for i, mr in iteritems(mod): + D[(i+1, i+1)] = mr[0] + D[(i+1, 0)] = mr[1] + T = matrix(ZZ, n, n, D) - d = polyhedron.ambient_dim() - if d <= 1: - raise ValueError('Cannot do splitting with only ' - 'dimension {}.'.format(d)) + rules_pre = iter((y, B({tuple(row[1:]): 1})) + for y, row in zip((1,) + B.gens(), T.columns())) + factor = next(rules_pre)[1] + rules = dict(rules_pre) - if split is True: - split = iter( - (Polyhedron( - ieqs=[tuple(1 if i==b else (-1 if i==a or i==0 and a > b else 0) - for i in range(d+1)) - for a, b in zip(pi[:-1], pi[1:])]), - 'b{}'.format(pi[0]-1) + - ''.join((' <= ' if a < b else ' < ') + - 'b{}'.format(b-1) - for a, b in zip(pi[:-1], pi[1:]))) - for pi in Permutations(d)) - else: - split = iter((ph, ph.repr_pretty_Hrepresentation(prefix='b')) - for ph in split) + vecs = tuple(tuple(tuple(vector(e)*T) for e in vec) for vec in vecs) - result = [] - for split_polyhedron, pi_log in split: - logger.info('split polyhedron by %s', pi_log) - result.append(_generating_function_of_polyhedron_( - polyhedron & split_polyhedron, **kwds)) - if not result_as_tuple: - raise ValueError("Cannot unpack result." - "(Unset 'result_as_tuple=False'.)") - return Summandization(sum(result, ())) + return (factor, rules) + vecs def compositions_mod(u, m, r=0, multidimensional=False): @@ -725,167 +891,3 @@ def _compositions_mod_(u, r): yield (Z(j),) + a -def _generating_function_of_polyhedron_( - polyhedron, indices=None, **kwds): - r""" - Helper function for :func:`generating_function_of_polyhedron` which - does the actual computation of the generating function. - - TESTS:: - - sage: generating_function_of_polyhedron( # indirect doctest - ....: Polyhedron(ieqs=[(0, 1, 0, 0), (0, -1, 1, 0)], - ....: eqns=[(0, -1, -1, 2)]), - ....: result_as_tuple=True, sort_factors=True) - (-y0^2*y1^2*y2^2 + 1) * (-y1^2*y2 + 1)^-1 * - (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 + - (-y0^3*y1^3*y2^3 + y0*y1*y2) * (-y1^2*y2 + 1)^-1 * - (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 - """ - import logging - logger = logging.getLogger(__name__) - - logger.info('polyhedron: %s', - polyhedron.repr_pretty_Hrepresentation(prefix='b')) - - if polyhedron.is_empty(): - from sage.structure.factorization import Factorization - return (Factorization([], unit=0),) - - Hrepr = polyhedron.Hrepresentation() - - inequalities = tuple(tuple(entry) - for entry in Hrepr if entry.is_inequality()) - equations = tuple(tuple(entry) - for entry in Hrepr if entry.is_equation()) - if len(inequalities) + len(equations) != len(Hrepr): - raise ValueError('Cannot handle {}.'.format(polyhedron)) - - if not inequalities: - raise NotImplementedError('no inequality given') - - if indices is None: - indices = range(len(inequalities[0]) - 1) - - n = len(indices) + 1 - if any(len(e) != n for e in inequalities): - raise ValueError('Not all coefficient vectors of the inequalities ' - 'have the same length.') - if any(len(e) != n for e in equations): - raise ValueError('Not all coefficient vectors of the equations ' - 'have the same length.') - - logger.info('generating_function_of_polyhedron: ' - '%s inequalities', len(inequalities)) - - mods = generate_mods(equations) - logger.info('splitting by moduli %s', mods) - - return tuple(__generating_function_of_polyhedron__( - indices, inequalities, equations, mod, **kwds) for mod in mods) - - -def __generating_function_of_polyhedron__( - indices, inequalities, equations, mod, - Factorization_sort=False, Factorization_simplify=False, - sort_factors=False): - r""" - Helper function for :func:`generating_function_of_polyhedron` which - does the actual computation of the generating function. - - TESTS:: - - sage: __generating_function_of_polyhedron__( - ....: (0, 2), [(0, 1, 0)], [(1, -1, 2)], - ....: {0: (2, 1)}, sort_factors=True) - y0 * (-y0^2*y2 + 1)^-1 - sage: __generating_function_of_polyhedron__( - ....: srange(3), [(0, 1, 0, 0), (0, 0, 1, 0)], [(1, -1, 0, 2)], - ....: {0: (2, 1)}, sort_factors=True) - y0 * (-y1 + 1)^-1 * (-y0^2*y2 + 1)^-1 - sage: __generating_function_of_polyhedron__( - ....: srange(3), [(0, 1, 0, 0), (0, -1, 1, 0)], [(0, -1, -1, 2)], - ....: {0: (2, 1), 1: (2, 1)}, sort_factors=True) - (-y0^3*y1^3*y2^3 + y0*y1*y2) * - (-y1^2*y2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 - """ - import logging - logger = logging.getLogger(__name__) - - from omega import _Omega_ - from omega import partition - from sage.rings.integer_ring import ZZ - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - from sage.structure.factorization import Factorization - - B = LaurentPolynomialRing( - ZZ, - tuple('y{}'.format(k) for k in indices), - sparse=True) - - extra_factor_mod, rules_mod, inequalities, equations = \ - prepare_mod(mod, B, inequalities, equations) - - extra_factor_equations, rules_equations, indices_equations = \ - prepare_equations(equations, B) - - inequalities, extra_factor_inequalities, rules_inequalities = \ - prepare_inequalities(inequalities, B) - - numerator = B(1) - terms = B.gens() - L = B - for i, coeffs in enumerate(inequalities): - L = LaurentPolynomialRing(L, 'mu{}'.format(i), sparse=True) - l = L.gen() - logger.debug('generating_function_of_polyhedron: ' - '%s --> %s', l, pretty_inequality(coeffs)) - it_coeffs = iter(coeffs) - numerator *= l**next(it_coeffs) - assert numerator.parent() == L - terms = tuple(l**c * t for c, t in zip(it_coeffs, terms)) - assert all(y == t for y, t in - (zip(B.gens(), terms)[i] for i in indices_equations)) - terms = tuple(t for i, t in enumerate(terms) - if i not in indices_equations) - - logger.info('generating_function_of_polyhedron: ' - 'terms denominator %s', terms) - - def decode_factor(factor): - D = factor.dict() - assert len(D) == 1 - exponent, coefficient = next(iteritems(D)) - return coefficient, exponent - - while repr(numerator.parent().gen()).startswith('mu'): - logger.info('generating_function_of_polyhedron: ' - 'applying Omega[%s]...', numerator.parent().gen()) - logger.info('...on terms denominator %s', terms) - logger.info('...(numerator has %s)', numerator.number_of_terms()) - - decoded_factors, other_factors = \ - partition((decode_factor(factor) for factor in terms), - lambda factor: factor[1] == 0) - other_factors = tuple(factor[0] for factor in other_factors) - numerator, factors_denominator = \ - _Omega_(numerator.dict(), tuple(decoded_factors)) - terms = other_factors + factors_denominator - - numerator = \ - (((numerator.subs(rules_inequalities) * extra_factor_inequalities - ).subs(rules_equations) * extra_factor_equations - ).subs(rules_mod) * extra_factor_mod) - terms = tuple( - t.subs(rules_inequalities).subs(rules_equations).subs(rules_mod) - for t in terms) - - if sort_factors: - def key(t): - D = t.dict().popitem()[0] - return (-sum(abs(d) for d in D), D) - terms = sorted(terms, key=key, reverse=True) - return Factorization([(numerator, 1)] + - list((1-t, -1) for t in terms), - sort=Factorization_sort, - simplify=Factorization_simplify) From 3cd80b77286c67b2da3befeac736629e040eb62a Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 13 Dec 2016 14:54:06 +0100 Subject: [PATCH 159/370] move code around in omega --- omega.py | 858 +++++++++++++++++++++++++++---------------------------- 1 file changed, 429 insertions(+), 429 deletions(-) diff --git a/omega.py b/omega.py index 7ac1d04b850..111082c764a 100644 --- a/omega.py +++ b/omega.py @@ -17,282 +17,279 @@ from sage.misc.cachefunc import cached_function -def partition(items, predicate=bool): +def Omega(var, expression, denominator=None, op=operator.ge, + Factorization_sort=False, Factorization_simplify=True): r""" - Split ``items`` into two parts by the given ``predicate``. - - INPUT: - - - ``item`` -- an iterator. - - OUTPUT: - - A pair of iterators; the first contains the elements not satisfying - the ``predicate``, the second the elements satisfying the ``predicate``. - - Source of the code: - `http://nedbatchelder.com/blog/201306/filter_a_list_into_two_parts.html`_ - - EXAMPLES: - - sage: E, O = partition(srange(10), is_odd) - sage: tuple(E), tuple(O) - ((0, 2, 4, 6, 8), (1, 3, 5, 7, 9)) - """ - from itertools import tee - a, b = tee((predicate(item), item) for item in items) - return ((item for pred, item in a if not pred), - (item for pred, item in b if pred)) - + Return `\Omega_{\mathrm{op}}` of ``expression`` with respect to ``var``. -def HomogenousSymmetricFunction(j, x): - r""" - EXAMPLES:: + To be more precise, this calculates - sage: P = PolynomialRing(ZZ, 'X', 3) - sage: HomogenousSymmetricFunction(0, P.gens()) - 1 - sage: HomogenousSymmetricFunction(1, P.gens()) - X0 + X1 + X2 - sage: HomogenousSymmetricFunction(2, P.gens()) - X0^2 + X0*X1 + X1^2 + X0*X2 + X1*X2 + X2^2 - sage: HomogenousSymmetricFunction(3, P.gens()) - X0^3 + X0^2*X1 + X0*X1^2 + X1^3 + X0^2*X2 + - X0*X1*X2 + X1^2*X2 + X0*X2^2 + X1*X2^2 + X2^3 - """ - from sage.combinat.integer_vector import IntegerVectors - from sage.misc.misc_c import prod + .. MATH:: - return sum(prod(xx**pp for xx, pp in zip(x, p)) - for p in IntegerVectors(j, length=len(x))) + \Omega_{\mathrm{op}} \frac{n}{d_1 \dots d_n} + for the numerator `n` and the factors `d_1`, ..., `d_n` of + the denominator, all of which are laurent polynomials in ``var`` + and returns a (partial) factorization of the result. -def Omega_numerator_P(a, x, y, t): - import logging - logger = logging.getLogger(__name__) + INPUT: - from sage.arith.srange import srange - from sage.misc.misc_c import prod + - ``var`` -- a variable or a representation string of a variable. - n = len(x) - if n == 1: - x0 = t - result = x0**(-a) + \ - (prod(1 - x0*yy for yy in y) * - sum(HomogenousSymmetricFunction(j, y) * (1-x0**(j-a)) - for j in srange(a)) - if a > 0 else 0) - else: - Pprev = Omega_numerator_P(a, x[:n-1], y, t) - x2 = x[n-2] - logger.debug('Omega_numerator: P(%s): substituting...', n) - x1 = t - p1 = Pprev - p2 = Pprev.subs({t: x2}) - logger.debug('Omega_numerator: P(%s): preparing...', n) - dividend = x1 * (1-x2) * prod(1 - x2*yy for yy in y) * p1 - \ - x2 * (1-x1) * prod(1 - x1*yy for yy in y) * p2 - logger.debug('Omega_numerator: P(%s): dividing...', n) - q, r = dividend.quo_rem(x1 - x2) - assert r == 0 - result = q - logger.debug('Omega_numerator: P(%s) has %s terms', n, result.number_of_terms()) - return result + - ``expression`` -- an element of the quotient field of some + laurent polynomials. If ``denominator`` is specified, then + this laurent polynomial is interpreted as the numerator of the + expression. + - ``denominator`` -- a laurent polynomial or a + :class:`~sage.structure.factorization.Factorization` (consisting + of laurent polynomial factors) or a tuple/list of factors (laurent + polynomials). -def Omega_numerator(a, x, y, t): - r""" - Return the numerator of `\Omega_{\ge}` of the expression - specified by the input. + - ``op`` -- (default: ``operator.ge``) an operator. - To be more precise, this calculates + OUTPUT: - .. MATH:: + A (partial) :class:`~sage.structure.factorization.Factorization` + of the result whose factors are laurent polynomials. - \Omega_{\ge} \frac{\mu^a}{ - (1 - x_1 \mu) \dots (1 - x_n \mu) - (1 - y_1 / \mu) \dots (1 - y_m / \mu) + .. NOTE:: - and returns its numerator. + The numerator of the result may not be factored. - INPUT: + EXAMPLES:: - - ``a`` -- an integer. + sage: L. = LaurentPolynomialRing(ZZ) - - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The - flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the - `y_1,...,y_m`. + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu]) + 1 * (-x + 1)^-1 * (-x*y + 1)^-1 - - ``t`` -- a temporary laurent polynomial variable used for substituting. + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu, 1 - z/mu]) + 1 * (-x + 1)^-1 * (-x*y + 1)^-1 * (-x*z + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu]) + (-x*y*z + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-x*z + 1)^-1 * (-y*z + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^2]) + 1 * (-x + 1)^-1 * (-x^2*y + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu]) + (x*y + 1) * (-x + 1)^-1 * (-x*y^2 + 1)^-1 - OUTPUT: + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu^2]) + (-x^2*y*z - x*y^2*z + x*y*z + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * (-x^2*z + 1)^-1 * (-y^2*z + 1)^-1 - A laurent polynomial. + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^3]) + 1 * (-x + 1)^-1 * (-x^3*y + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^4]) + 1 * (-x + 1)^-1 * (-x^4*y + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu^3, 1 - y/mu]) + (x*y^2 + x*y + 1) * (-x + 1)^-1 * (-x*y^3 + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu^4, 1 - y/mu]) + (x*y^3 + x*y^2 + x*y + 1) * (-x + 1)^-1 * (-x*y^4 + 1)^-1 - EXAMPLES:: + sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu, 1 - z/mu]) + (x*y*z + x*y + x*z + 1) * + (-x + 1)^-1 * (-x*y^2 + 1)^-1 * (-x*z^2 + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu^2, 1 - y*mu, 1 - z/mu]) + (-x*y*z^2 - x*y*z + x*z + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * (-x*z^2 + 1)^-1 * (-y*z + 1)^-1 - sage: L. = LaurentPolynomialRing(ZZ) - sage: Omega_numerator(0, ((x0,),), ((y0,),), t) - 1 - sage: Omega_numerator(0, ((x0,), (x1,)), ((y0,),), t) - -x0*x1*y0 + 1 - sage: Omega_numerator(0, ((x0,),), ((y0,), (y1,)), t) - 1 - sage: Omega_numerator(0, ((x0,), (x1,), (x2,)), ((y0,),), t) - x0*x1*x2*y0^2 + x0*x1*x2*y0 - x0*x1*y0 - x0*x2*y0 - x1*x2*y0 + 1 - sage: Omega_numerator(0, ((x0,), (x1,)), ((y0,), (y1,)), t) - x0^2*x1*y0*y1 + x0*x1^2*y0*y1 - x0*x1*y0*y1 - x0*x1*y0 - x0*x1*y1 + 1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z*mu, 1 - w/mu]) + (x*y*z*w^2 + x*y*z*w - x*y*w - x*z*w - y*z*w + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * (-z + 1)^-1 * + (-x*w + 1)^-1 * (-y*w + 1)^-1 * (-z*w + 1)^-1 + sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu, 1 - w/mu]) + (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1) * + (-x + 1)^-1 * (-y + 1)^-1 * + (-x*z + 1)^-1 * (-x*w + 1)^-1 * (-y*z + 1)^-1 * (-y*w + 1)^-1 - sage: Omega_numerator(-2, ((x0,),), ((y0,),), t) - x0^2 - sage: Omega_numerator(-1, ((x0,),), ((y0,),), t) - x0 - sage: Omega_numerator(1, ((x0,),), ((y0,),), t) - -x0*y0 + y0 + 1 - sage: Omega_numerator(2, ((x0,),), ((y0,),), t) - -x0*y0^2 - x0*y0 + y0^2 + y0 + 1 + sage: Omega(mu, mu^-2, [1 - x*mu, 1 - y/mu]) + x^2 * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, mu^-1, [1 - x*mu, 1 - y/mu]) + x * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, mu, [1 - x*mu, 1 - y/mu]) + (-x*y + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega(mu, mu^2, [1 - x*mu, 1 - y/mu]) + (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 TESTS:: - sage: Omega_factors_denominator((), ()) - () - sage: Omega_numerator(0, (), (), t) + sage: Omega(mu, 1, [1 - x*mu]) + 1 * (-x + 1)^-1 + sage: Omega(mu, 1, [1 - x/mu]) 1 - sage: Omega_numerator(+2, (), (), t) + sage: Omega(mu, 0, [1 - x*mu]) + 0 + sage: Omega(mu, L(1), []) 1 - sage: Omega_numerator(-2, (), (), t) + sage: Omega(mu, L(0), []) + 0 + sage: Omega(mu, 2, []) + 2 + sage: Omega(mu, 2*mu, []) + 2 + sage: Omega(mu, 2/mu, []) 0 - sage: Omega_factors_denominator(((x0,),), ()) - (-x0 + 1,) - sage: Omega_numerator(0, ((x0,),), (), t) - 1 - sage: Omega_numerator(+2, ((x0,),), (), t) - 1 - sage: Omega_numerator(-2, ((x0,),), (), t) - x0^2 + :: - sage: Omega_factors_denominator((), ((y0,),)) - () - sage: Omega_numerator(0, (), ((y0,),), t) - 1 - sage: Omega_numerator(+2, (), ((y0,),), t) - y0^2 + y0 + 1 - sage: Omega_numerator(-2, (), ((y0,),), t) + sage: Omega(mu, Factorization([(1/mu, 1), (1 - x*mu, -1), + ....: (1 - y/mu, -2)], unit=2)) + 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 + sage: Omega(mu, Factorization([(mu, -1), (1 - x*mu, -1), + ....: (1 - y/mu, -2)], unit=2)) + 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 + sage: Omega(mu, Factorization([(mu, -1), (1 - x, -1)])) 0 + sage: Omega(mu, Factorization([(2, -1)])) + 1 * 2^-1 :: - sage: L. = LaurentPolynomialRing(ZZ) - sage: Omega_numerator(2, ((X,),), ((Y,),), t) - -X*Y^2 - X*Y + Y^2 + Y + 1 + sage: Omega(mu, 1, [1 - x*mu, 1 - z, 1 - y/mu]) + 1 * (-z + 1)^-1 * (-x + 1)^-1 * (-x*y + 1)^-1 """ - from sage.arith.srange import srange + from sage.arith.misc import factor from sage.misc.misc_c import prod + from sage.rings.integer_ring import ZZ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing_univariate + from sage.structure.factorization import Factorization - x_flat = sum(x, tuple()) - y_flat = sum(y, tuple()) - n = len(x_flat) - m = len(y_flat) - xy = x_flat + y_flat - - import logging - logger = logging.getLogger(__name__) - logger.info('Omega_numerator: a=%s, n=%s, m=%s', a, n, m) + if op != operator.ge: + raise NotImplementedError('At the moment, only Omega_ge is implemented.') - if m == 0: - result = 1 - (prod(Omega_factors_denominator(x, y)) * - sum(HomogenousSymmetricFunction(j, xy) - for j in srange(-a)) - if a < 0 else 0) - elif n == 0: - result = sum(HomogenousSymmetricFunction(j, xy) - for j in srange(a+1)) - else: - result = Omega_numerator_P(a, x_flat, y_flat, t).subs({t: x_flat[-1]}) - L = t.parent() - result = L(result) + if denominator is None: + if isinstance(expression, Factorization): + numerator = expression.unit() * \ + prod(f**e for f, e in expression if e > 0) + denominator = tuple(f for f, e in expression if e < 0 + for _ in range(-e)) + else: + numerator = expression.numerator() + denominator = expression.denominator() + else: + numerator = expression + # at this point we have numerator/denominator - logger.info('Omega_numerator: %s terms', result.number_of_terms()) - return result + if isinstance(denominator, (list, tuple)): + factors_denominator = denominator + else: + if not isinstance(denominator, Factorization): + denominator = factor(denominator) + if not denominator.is_integral(): + raise ValueError('Factorization {} of the denominator ' + 'contains negative exponents.'.format(denominator)) + numerator *= denominator.unit() + factors_denominator = tuple(factor + for factor, exponent in denominator + for _ in range(exponent)) + # at this point we have numerator/factors_denominator + P = var.parent() + if isinstance(P, LaurentPolynomialRing_univariate) and P.gen() == var: + L = P + L0 = L.base_ring() + elif var in P.gens(): + var = repr(var) + L0 = LaurentPolynomialRing( + P.base_ring(), tuple(v for v in P.variable_names() if v != var)) + L = LaurentPolynomialRing(L0, var) + var = L.gen() + else: + raise ValueError('{} is not a variable.'.format(var)) -@cached_function -def Omega_factors_denominator(x, y): - r""" - Return the denominator of `\Omega_{\ge}` of the expression - specified by the input. + other_factors = [] + to_numerator = [] + decoded_factors = [] + for factor in factors_denominator: + factor = L(factor) + D = factor.dict() + if not D: + raise ZeroDivisionError('Denominator contains a factor 0.') + elif len(D) == 1: + exponent, coefficient = next(iteritems(D)) + if exponent == 0: + other_factors.append(L0(factor)) + else: + to_numerator.append(factor) + elif len(D) == 2: + if D.get(0, 0) != 1: + raise NotImplementedError('Factor {} is not normalized.'.format(factor)) + D.pop(0) + exponent, coefficient = next(iteritems(D)) + decoded_factors.append((-coefficient, exponent)) + else: + raise NotImplementedError('Cannot handle factor {}.'.format(factor)) + numerator = L(numerator) / prod(to_numerator) - To be more precise, this calculates + result_numerator, result_factors_denominator = \ + _Omega_(numerator.dict(), decoded_factors) + if result_numerator == 0: + return Factorization([], unit=result_numerator) - .. MATH:: + return Factorization([(result_numerator, 1)] + + list((f, -1) for f in other_factors) + + list((1-f, -1) for f in result_factors_denominator), + sort=Factorization_sort, + simplify=Factorization_simplify) - \Omega_{\ge} \frac{1}{ - (1 - x_1 \mu) \dots (1 - x_n \mu) - (1 - y_1 / \mu) \dots (1 - y_m / \mu) - and returns a factorization of its denominator. +def _Omega_(A, decoded_factors): + r""" + Helper function for :func:`Omega` which accesses the low level functions + and does the substituting. INPUT: - - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The - flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the - `y_1,...,y_m`. + - ``A`` -- a dictionary mapping `a` to `c` representing a summand + `c\mu^a` of the numerator. + + - ``decoded_factors`` -- a tuple or list of pairs `(z, e)` representing + a factor `1 - z \mu^e`. OUTPUT: - A factorization of the denominator as - a tuple of laurent polynomials. + A pair representing a quotient as follows: Its first component is the + numerator as a laurent polynomial, its second component a factorization + of the denominator as a tuple of laurent polynomials, where each + laurent polynomial `z` represents a factor `1 - z`. - EXAMPLES:: + TESTS: - sage: L. = LaurentPolynomialRing(ZZ) - sage: Omega_factors_denominator(((x0,),), ((y0,),)) - (-x0 + 1, -x0*y0 + 1) - sage: Omega_factors_denominator(((x0,),), ((y0,), (y1,))) - (-x0 + 1, -x0*y0 + 1, -x0*y1 + 1) - sage: Omega_factors_denominator(((x0,), (x1,)), ((y0,),)) - (-x0 + 1, -x1 + 1, -x0*y0 + 1, -x1*y0 + 1) - sage: Omega_factors_denominator(((x0,), (x1,), (x2,)), ((y0,),)) - (-x0 + 1, -x1 + 1, -x2 + 1, -x0*y0 + 1, -x1*y0 + 1, -x2*y0 + 1) - sage: Omega_factors_denominator(((x0,), (x1,)), ((y0,), (y1,))) - (-x0 + 1, -x1 + 1, -x0*y0 + 1, -x0*y1 + 1, -x1*y0 + 1, -x1*y1 + 1) + Extensive testing of this function is done in :func:`Omega`. :: - sage: B. = ZZ.extension(cyclotomic_polynomial(3)) - sage: L. = LaurentPolynomialRing(B) - sage: Omega_factors_denominator(((x, -x),), ((y,),)) - (-x^2 + 1, -x^2*y^2 + 1) - sage: Omega_factors_denominator(((x, -x),), ((y, zeta*y, zeta^2*y),)) - (-x^2 + 1, -x^6*y^6 + 1) - sage: Omega_factors_denominator(((x, -x),), ((y, -y),)) - (-x^2 + 1, -x^2*y^2 + 1, -x^2*y^2 + 1) - - TESTS:: + sage: _Omega_({0: 2, 1: 40, -1: -3}, []) + (42, ()) + sage: _Omega_({-1: 42}, []) + (0, ()) - sage: L. = LaurentPolynomialRing(ZZ) - sage: Omega_factors_denominator((), ()) - () - sage: Omega_factors_denominator(((x0,),), ()) - (-x0 + 1,) - sage: Omega_factors_denominator((), ((y0,),)) - () """ - import logging - logger = logging.getLogger(__name__) + if not decoded_factors: + return sum(c for a, c in iteritems(A) if a >= 0), tuple() - from sage.misc.misc_c import prod + # Below we sort to make the caching more efficient. Doing this here + # (in contrast to directly in Omega_higher) results in much cleaner + # code and prevents an additional substitution or passing of a permutation. + values, exponents = zip(*sorted(decoded_factors, key=lambda k: -k[1])) - result = tuple(prod(1 - xx for xx in gx) for gx in x) + \ - sum(((prod(1 - xx*yy for xx in gx for yy in gy),) - if len(gx) != len(gy) - else tuple(prod(1 - xx*yy for xx in gx) for yy in gy) - for gx in x for gy in y), - tuple()) + numerator = 0 + factors_denominator = None + rules = None + for a, c in iteritems(A): + n, fd = Omega_higher(a, exponents) + if factors_denominator is None: + factors_denominator = fd + else: + assert factors_denominator == fd + if rules is None: + rules = dict(zip(n.parent().gens(), values)) + numerator += c * n.subs(rules) - logger.info('Omega_denominator: %s factors', len(result)) - return result + if numerator == 0: + factors_denominator = tuple() + return numerator, tuple(f.subs(rules) for f in factors_denominator) @cached_function @@ -441,276 +438,279 @@ def de_power(expression): return numerator, factors_denominator -def Omega(var, expression, denominator=None, op=operator.ge, - Factorization_sort=False, Factorization_simplify=True): +def Omega_numerator(a, x, y, t): r""" - Return `\Omega_{\mathrm{op}}` of ``expression`` with respect to ``var``. + Return the numerator of `\Omega_{\ge}` of the expression + specified by the input. To be more precise, this calculates .. MATH:: - \Omega_{\mathrm{op}} \frac{n}{d_1 \dots d_n} + \Omega_{\ge} \frac{\mu^a}{ + (1 - x_1 \mu) \dots (1 - x_n \mu) + (1 - y_1 / \mu) \dots (1 - y_m / \mu) - for the numerator `n` and the factors `d_1`, ..., `d_n` of - the denominator, all of which are laurent polynomials in ``var`` - and returns a (partial) factorization of the result. + and returns its numerator. INPUT: - - ``var`` -- a variable or a representation string of a variable. - - - ``expression`` -- an element of the quotient field of some - laurent polynomials. If ``denominator`` is specified, then - this laurent polynomial is interpreted as the numerator of the - expression. + - ``a`` -- an integer. - - ``denominator`` -- a laurent polynomial or a - :class:`~sage.structure.factorization.Factorization` (consisting - of laurent polynomial factors) or a tuple/list of factors (laurent - polynomials). + - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The + flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the + `y_1,...,y_m`. - - ``op`` -- (default: ``operator.ge``) an operator. + - ``t`` -- a temporary laurent polynomial variable used for substituting. OUTPUT: - A (partial) :class:`~sage.structure.factorization.Factorization` - of the result whose factors are laurent polynomials. - - .. NOTE:: - - The numerator of the result may not be factored. + A laurent polynomial. EXAMPLES:: - sage: L. = LaurentPolynomialRing(ZZ) + sage: L. = LaurentPolynomialRing(ZZ) + sage: Omega_numerator(0, ((x0,),), ((y0,),), t) + 1 + sage: Omega_numerator(0, ((x0,), (x1,)), ((y0,),), t) + -x0*x1*y0 + 1 + sage: Omega_numerator(0, ((x0,),), ((y0,), (y1,)), t) + 1 + sage: Omega_numerator(0, ((x0,), (x1,), (x2,)), ((y0,),), t) + x0*x1*x2*y0^2 + x0*x1*x2*y0 - x0*x1*y0 - x0*x2*y0 - x1*x2*y0 + 1 + sage: Omega_numerator(0, ((x0,), (x1,)), ((y0,), (y1,)), t) + x0^2*x1*y0*y1 + x0*x1^2*y0*y1 - x0*x1*y0*y1 - x0*x1*y0 - x0*x1*y1 + 1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu]) - 1 * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: Omega_numerator(-2, ((x0,),), ((y0,),), t) + x0^2 + sage: Omega_numerator(-1, ((x0,),), ((y0,),), t) + x0 + sage: Omega_numerator(1, ((x0,),), ((y0,),), t) + -x0*y0 + y0 + 1 + sage: Omega_numerator(2, ((x0,),), ((y0,),), t) + -x0*y0^2 - x0*y0 + y0^2 + y0 + 1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu, 1 - z/mu]) - 1 * (-x + 1)^-1 * (-x*y + 1)^-1 * (-x*z + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu]) - (-x*y*z + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-x*z + 1)^-1 * (-y*z + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^2]) - 1 * (-x + 1)^-1 * (-x^2*y + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu]) - (x*y + 1) * (-x + 1)^-1 * (-x*y^2 + 1)^-1 + TESTS:: - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu^2]) - (-x^2*y*z - x*y^2*z + x*y*z + 1) * - (-x + 1)^-1 * (-y + 1)^-1 * (-x^2*z + 1)^-1 * (-y^2*z + 1)^-1 + sage: Omega_factors_denominator((), ()) + () + sage: Omega_numerator(0, (), (), t) + 1 + sage: Omega_numerator(+2, (), (), t) + 1 + sage: Omega_numerator(-2, (), (), t) + 0 - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^3]) - 1 * (-x + 1)^-1 * (-x^3*y + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^4]) - 1 * (-x + 1)^-1 * (-x^4*y + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu^3, 1 - y/mu]) - (x*y^2 + x*y + 1) * (-x + 1)^-1 * (-x*y^3 + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu^4, 1 - y/mu]) - (x*y^3 + x*y^2 + x*y + 1) * (-x + 1)^-1 * (-x*y^4 + 1)^-1 - - sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu, 1 - z/mu]) - (x*y*z + x*y + x*z + 1) * - (-x + 1)^-1 * (-x*y^2 + 1)^-1 * (-x*z^2 + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu^2, 1 - y*mu, 1 - z/mu]) - (-x*y*z^2 - x*y*z + x*z + 1) * - (-x + 1)^-1 * (-y + 1)^-1 * (-x*z^2 + 1)^-1 * (-y*z + 1)^-1 - - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z*mu, 1 - w/mu]) - (x*y*z*w^2 + x*y*z*w - x*y*w - x*z*w - y*z*w + 1) * - (-x + 1)^-1 * (-y + 1)^-1 * (-z + 1)^-1 * - (-x*w + 1)^-1 * (-y*w + 1)^-1 * (-z*w + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu, 1 - w/mu]) - (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1) * - (-x + 1)^-1 * (-y + 1)^-1 * - (-x*z + 1)^-1 * (-x*w + 1)^-1 * (-y*z + 1)^-1 * (-y*w + 1)^-1 - - sage: Omega(mu, mu^-2, [1 - x*mu, 1 - y/mu]) - x^2 * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, mu^-1, [1 - x*mu, 1 - y/mu]) - x * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, mu, [1 - x*mu, 1 - y/mu]) - (-x*y + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, mu^2, [1 - x*mu, 1 - y/mu]) - (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 - - TESTS:: - - sage: Omega(mu, 1, [1 - x*mu]) - 1 * (-x + 1)^-1 - sage: Omega(mu, 1, [1 - x/mu]) + sage: Omega_factors_denominator(((x0,),), ()) + (-x0 + 1,) + sage: Omega_numerator(0, ((x0,),), (), t) 1 - sage: Omega(mu, 0, [1 - x*mu]) - 0 - sage: Omega(mu, L(1), []) + sage: Omega_numerator(+2, ((x0,),), (), t) 1 - sage: Omega(mu, L(0), []) - 0 - sage: Omega(mu, 2, []) - 2 - sage: Omega(mu, 2*mu, []) - 2 - sage: Omega(mu, 2/mu, []) - 0 - - :: + sage: Omega_numerator(-2, ((x0,),), (), t) + x0^2 - sage: Omega(mu, Factorization([(1/mu, 1), (1 - x*mu, -1), - ....: (1 - y/mu, -2)], unit=2)) - 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 - sage: Omega(mu, Factorization([(mu, -1), (1 - x*mu, -1), - ....: (1 - y/mu, -2)], unit=2)) - 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 - sage: Omega(mu, Factorization([(mu, -1), (1 - x, -1)])) + sage: Omega_factors_denominator((), ((y0,),)) + () + sage: Omega_numerator(0, (), ((y0,),), t) + 1 + sage: Omega_numerator(+2, (), ((y0,),), t) + y0^2 + y0 + 1 + sage: Omega_numerator(-2, (), ((y0,),), t) 0 - sage: Omega(mu, Factorization([(2, -1)])) - 1 * 2^-1 :: - sage: Omega(mu, 1, [1 - x*mu, 1 - z, 1 - y/mu]) - 1 * (-z + 1)^-1 * (-x + 1)^-1 * (-x*y + 1)^-1 + sage: L. = LaurentPolynomialRing(ZZ) + sage: Omega_numerator(2, ((X,),), ((Y,),), t) + -X*Y^2 - X*Y + Y^2 + Y + 1 """ - from sage.arith.misc import factor + from sage.arith.srange import srange from sage.misc.misc_c import prod - from sage.rings.integer_ring import ZZ - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing_univariate - from sage.structure.factorization import Factorization - if op != operator.ge: - raise NotImplementedError('At the moment, only Omega_ge is implemented.') + x_flat = sum(x, tuple()) + y_flat = sum(y, tuple()) + n = len(x_flat) + m = len(y_flat) + xy = x_flat + y_flat - if denominator is None: - if isinstance(expression, Factorization): - numerator = expression.unit() * \ - prod(f**e for f, e in expression if e > 0) - denominator = tuple(f for f, e in expression if e < 0 - for _ in range(-e)) - else: - numerator = expression.numerator() - denominator = expression.denominator() - else: - numerator = expression - # at this point we have numerator/denominator + import logging + logger = logging.getLogger(__name__) + logger.info('Omega_numerator: a=%s, n=%s, m=%s', a, n, m) - if isinstance(denominator, (list, tuple)): - factors_denominator = denominator + if m == 0: + result = 1 - (prod(Omega_factors_denominator(x, y)) * + sum(HomogenousSymmetricFunction(j, xy) + for j in srange(-a)) + if a < 0 else 0) + elif n == 0: + result = sum(HomogenousSymmetricFunction(j, xy) + for j in srange(a+1)) else: - if not isinstance(denominator, Factorization): - denominator = factor(denominator) - if not denominator.is_integral(): - raise ValueError('Factorization {} of the denominator ' - 'contains negative exponents.'.format(denominator)) - numerator *= denominator.unit() - factors_denominator = tuple(factor - for factor, exponent in denominator - for _ in range(exponent)) - # at this point we have numerator/factors_denominator + result = Omega_numerator_P(a, x_flat, y_flat, t).subs({t: x_flat[-1]}) + L = t.parent() + result = L(result) - P = var.parent() - if isinstance(P, LaurentPolynomialRing_univariate) and P.gen() == var: - L = P - L0 = L.base_ring() - elif var in P.gens(): - var = repr(var) - L0 = LaurentPolynomialRing( - P.base_ring(), tuple(v for v in P.variable_names() if v != var)) - L = LaurentPolynomialRing(L0, var) - var = L.gen() - else: - raise ValueError('{} is not a variable.'.format(var)) + logger.info('Omega_numerator: %s terms', result.number_of_terms()) + return result - other_factors = [] - to_numerator = [] - decoded_factors = [] - for factor in factors_denominator: - factor = L(factor) - D = factor.dict() - if not D: - raise ZeroDivisionError('Denominator contains a factor 0.') - elif len(D) == 1: - exponent, coefficient = next(iteritems(D)) - if exponent == 0: - other_factors.append(L0(factor)) - else: - to_numerator.append(factor) - elif len(D) == 2: - if D.get(0, 0) != 1: - raise NotImplementedError('Factor {} is not normalized.'.format(factor)) - D.pop(0) - exponent, coefficient = next(iteritems(D)) - decoded_factors.append((-coefficient, exponent)) - else: - raise NotImplementedError('Cannot handle factor {}.'.format(factor)) - numerator = L(numerator) / prod(to_numerator) - result_numerator, result_factors_denominator = \ - _Omega_(numerator.dict(), decoded_factors) - if result_numerator == 0: - return Factorization([], unit=result_numerator) +def Omega_numerator_P(a, x, y, t): + import logging + logger = logging.getLogger(__name__) - return Factorization([(result_numerator, 1)] + - list((f, -1) for f in other_factors) + - list((1-f, -1) for f in result_factors_denominator), - sort=Factorization_sort, - simplify=Factorization_simplify) + from sage.arith.srange import srange + from sage.misc.misc_c import prod + n = len(x) + if n == 1: + x0 = t + result = x0**(-a) + \ + (prod(1 - x0*yy for yy in y) * + sum(HomogenousSymmetricFunction(j, y) * (1-x0**(j-a)) + for j in srange(a)) + if a > 0 else 0) + else: + Pprev = Omega_numerator_P(a, x[:n-1], y, t) + x2 = x[n-2] + logger.debug('Omega_numerator: P(%s): substituting...', n) + x1 = t + p1 = Pprev + p2 = Pprev.subs({t: x2}) + logger.debug('Omega_numerator: P(%s): preparing...', n) + dividend = x1 * (1-x2) * prod(1 - x2*yy for yy in y) * p1 - \ + x2 * (1-x1) * prod(1 - x1*yy for yy in y) * p2 + logger.debug('Omega_numerator: P(%s): dividing...', n) + q, r = dividend.quo_rem(x1 - x2) + assert r == 0 + result = q + logger.debug('Omega_numerator: P(%s) has %s terms', n, result.number_of_terms()) + return result -def _Omega_(A, decoded_factors): + +@cached_function +def Omega_factors_denominator(x, y): r""" - Helper function for :func:`Omega` which accesses the low level functions - and does the substituting. + Return the denominator of `\Omega_{\ge}` of the expression + specified by the input. - INPUT: + To be more precise, this calculates - - ``A`` -- a dictionary mapping `a` to `c` representing a summand - `c\mu^a` of the numerator. + .. MATH:: - - ``decoded_factors`` -- a tuple or list of pairs `(z, e)` representing - a factor `1 - z \mu^e`. + \Omega_{\ge} \frac{1}{ + (1 - x_1 \mu) \dots (1 - x_n \mu) + (1 - y_1 / \mu) \dots (1 - y_m / \mu) + + and returns a factorization of its denominator. + + INPUT: + + - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The + flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the + `y_1,...,y_m`. OUTPUT: - A pair representing a quotient as follows: Its first component is the - numerator as a laurent polynomial, its second component a factorization - of the denominator as a tuple of laurent polynomials, where each - laurent polynomial `z` represents a factor `1 - z`. + A factorization of the denominator as + a tuple of laurent polynomials. - TESTS: + EXAMPLES:: - Extensive testing of this function is done in :func:`Omega`. + sage: L. = LaurentPolynomialRing(ZZ) + sage: Omega_factors_denominator(((x0,),), ((y0,),)) + (-x0 + 1, -x0*y0 + 1) + sage: Omega_factors_denominator(((x0,),), ((y0,), (y1,))) + (-x0 + 1, -x0*y0 + 1, -x0*y1 + 1) + sage: Omega_factors_denominator(((x0,), (x1,)), ((y0,),)) + (-x0 + 1, -x1 + 1, -x0*y0 + 1, -x1*y0 + 1) + sage: Omega_factors_denominator(((x0,), (x1,), (x2,)), ((y0,),)) + (-x0 + 1, -x1 + 1, -x2 + 1, -x0*y0 + 1, -x1*y0 + 1, -x2*y0 + 1) + sage: Omega_factors_denominator(((x0,), (x1,)), ((y0,), (y1,))) + (-x0 + 1, -x1 + 1, -x0*y0 + 1, -x0*y1 + 1, -x1*y0 + 1, -x1*y1 + 1) :: - sage: _Omega_({0: 2, 1: 40, -1: -3}, []) - (42, ()) - sage: _Omega_({-1: 42}, []) - (0, ()) + sage: B. = ZZ.extension(cyclotomic_polynomial(3)) + sage: L. = LaurentPolynomialRing(B) + sage: Omega_factors_denominator(((x, -x),), ((y,),)) + (-x^2 + 1, -x^2*y^2 + 1) + sage: Omega_factors_denominator(((x, -x),), ((y, zeta*y, zeta^2*y),)) + (-x^2 + 1, -x^6*y^6 + 1) + sage: Omega_factors_denominator(((x, -x),), ((y, -y),)) + (-x^2 + 1, -x^2*y^2 + 1, -x^2*y^2 + 1) + TESTS:: + + sage: L. = LaurentPolynomialRing(ZZ) + sage: Omega_factors_denominator((), ()) + () + sage: Omega_factors_denominator(((x0,),), ()) + (-x0 + 1,) + sage: Omega_factors_denominator((), ((y0,),)) + () """ - if not decoded_factors: - return sum(c for a, c in iteritems(A) if a >= 0), tuple() + import logging + logger = logging.getLogger(__name__) - # Below we sort to make the caching more efficient. Doing this here - # (in contrast to directly in Omega_higher) results in much cleaner - # code and prevents an additional substitution or passing of a permutation. - values, exponents = zip(*sorted(decoded_factors, key=lambda k: -k[1])) + from sage.misc.misc_c import prod - numerator = 0 - factors_denominator = None - rules = None - for a, c in iteritems(A): - n, fd = Omega_higher(a, exponents) - if factors_denominator is None: - factors_denominator = fd - else: - assert factors_denominator == fd - if rules is None: - rules = dict(zip(n.parent().gens(), values)) - numerator += c * n.subs(rules) + result = tuple(prod(1 - xx for xx in gx) for gx in x) + \ + sum(((prod(1 - xx*yy for xx in gx for yy in gy),) + if len(gx) != len(gy) + else tuple(prod(1 - xx*yy for xx in gx) for yy in gy) + for gx in x for gy in y), + tuple()) - if numerator == 0: - factors_denominator = tuple() - return numerator, tuple(f.subs(rules) for f in factors_denominator) + logger.info('Omega_denominator: %s factors', len(result)) + return result + + +def partition(items, predicate=bool): + r""" + Split ``items`` into two parts by the given ``predicate``. + + INPUT: + + - ``item`` -- an iterator. + + OUTPUT: + + A pair of iterators; the first contains the elements not satisfying + the ``predicate``, the second the elements satisfying the ``predicate``. + + Source of the code: + `http://nedbatchelder.com/blog/201306/filter_a_list_into_two_parts.html`_ + + EXAMPLES: + + sage: E, O = partition(srange(10), is_odd) + sage: tuple(E), tuple(O) + ((0, 2, 4, 6, 8), (1, 3, 5, 7, 9)) + """ + from itertools import tee + a, b = tee((predicate(item), item) for item in items) + return ((item for pred, item in a if not pred), + (item for pred, item in b if pred)) + + +def HomogenousSymmetricFunction(j, x): + r""" + EXAMPLES:: + + sage: P = PolynomialRing(ZZ, 'X', 3) + sage: HomogenousSymmetricFunction(0, P.gens()) + 1 + sage: HomogenousSymmetricFunction(1, P.gens()) + X0 + X1 + X2 + sage: HomogenousSymmetricFunction(2, P.gens()) + X0^2 + X0*X1 + X1^2 + X0*X2 + X1*X2 + X2^2 + sage: HomogenousSymmetricFunction(3, P.gens()) + X0^3 + X0^2*X1 + X0*X1^2 + X1^3 + X0^2*X2 + + X0*X1*X2 + X1^2*X2 + X0*X2^2 + X1*X2^2 + X2^3 + """ + from sage.combinat.integer_vector import IntegerVectors + from sage.misc.misc_c import prod + + return sum(prod(xx**pp for xx, pp in zip(x, p)) + for p in IntegerVectors(j, length=len(x))) From 9fea56ff138193c75daab569bb26ad940444a283 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 13 Dec 2016 15:03:25 +0100 Subject: [PATCH 160/370] complete docstrings --- omega.py | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/omega.py b/omega.py index 111082c764a..163dfb8085c 100644 --- a/omega.py +++ b/omega.py @@ -1,4 +1,6 @@ - +r""" +MacMahon's Omega Operator +""" # ***************************************************************************** # Copyright (C) 2016 Daniel Krenn # @@ -48,6 +50,11 @@ def Omega(var, expression, denominator=None, op=operator.ge, - ``op`` -- (default: ``operator.ge``) an operator. + - ``Factorization_sort`` (default: ``False``) and + ``Factorization_simplify`` (default: ``True``) -- are passed on to + :class:`sage.structure.factorization.Factorization` when creating + the result. + OUTPUT: A (partial) :class:`~sage.structure.factorization.Factorization` @@ -264,7 +271,6 @@ def _Omega_(A, decoded_factors): (42, ()) sage: _Omega_({-1: 42}, []) (0, ()) - """ if not decoded_factors: return sum(c for a, c in iteritems(A) if a >= 0), tuple() @@ -556,6 +562,23 @@ def Omega_numerator(a, x, y, t): def Omega_numerator_P(a, x, y, t): + r""" + Helper function for :func:`Omega_numerator`. + + INPUT: + + - ``a`` -- an integer. + + - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The + flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the + `y_1,...,y_m`. + + - ``t`` -- a temporary laurent polynomial variable used for substituting. + + OUTPUT: + + A laurent polynomial. + """ import logging logger = logging.getLogger(__name__) @@ -674,6 +697,8 @@ def partition(items, predicate=bool): - ``item`` -- an iterator. + - ``predicate`` -- a function. + OUTPUT: A pair of iterators; the first contains the elements not satisfying @@ -696,6 +721,18 @@ def partition(items, predicate=bool): def HomogenousSymmetricFunction(j, x): r""" + Return a complete homogeneous symmetric polynomial. + + INPUT: + + - ``j`` -- the degree as a nonnegative integer. + + - ``x`` -- an iterable of variables. + + OUTPUT: + + A polynomial whose type is determined by the input ``x``. + EXAMPLES:: sage: P = PolynomialRing(ZZ, 'X', 3) From 58f4bce4130be9fbcd9ccd7c841e2f8210656ae2 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 13 Dec 2016 15:23:54 +0100 Subject: [PATCH 161/370] write some more docstrings --- generating_function_of_polyhedron.py | 53 ++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/generating_function_of_polyhedron.py b/generating_function_of_polyhedron.py index c99b810b1c4..c742e3ba3a7 100644 --- a/generating_function_of_polyhedron.py +++ b/generating_function_of_polyhedron.py @@ -20,6 +20,36 @@ def generating_function_of_polyhedron(polyhedron, split=False, Return the generating function of the integer points of the polyhedron's orthant with only nonnegative coordinates. + INPUT: + + - ``polyhedron`` -- an instance of + :class:`~sage.geometry.polyhedron.base.Polyhedron_base` + (see also :mod:`sage/geometry/polyhedron/constructor`). + + - ``split`` -- (default: ``False``) ``False`` computes the generating + function directly, whereas ``True`` splits the ``polyhedron`` + into several small disjoint polyhedra and adds the results. + ``split`` may also be a list of disjoint polyhedra. + + - ``result_as_tuple`` -- (default: ``None``) a boolean or ``None``. + + - ``indices`` -- (default: ``None``) a list or tuple. If this + is ``None``, this is automatically determined. + + - ``Factorization_sort`` (default: ``False``) and + ``Factorization_simplify`` (default: ``True``) -- are passed on to + :class:`sage.structure.factorization.Factorization` when creating + the result. + + - ``sort_factors`` -- (default: ``False``) a boolean. + + OUTPUT: + + The generating function as a (partial) + :class:`~sage.structure.factorization.Factorization` + of the result whose factors are laurent polynomials or + a tuple (:class:`Summandization`) of such elements. + EXAMPLES:: sage: P2 = ( @@ -495,6 +525,20 @@ def key(t): def pretty_inequality(ineq, indices=None): + r""" + Format the given inequality pretty. + + INPUT: + + - ``ineq`` -- a list or tuple. + + - ``indices`` -- (default: ``None``) a list or tuple. + + OUTPUT: + + A string. + + """ from sage.symbolic.ring import SR from sage.modules.free_module_element import vector @@ -509,6 +553,10 @@ def pretty_inequality(ineq, indices=None): class Summandization(tuple): + r""" + A class representing a tuple as sum. It is shown + as summands joined by a `+`. + """ def __repr__(self): return ' + '.join(repr(s) for s in self) @@ -517,6 +565,9 @@ def __repr__(self): def prepare_inequalities(inequalities, B): r""" + Split off (simple) inequalities which can be handled better + without passing them to Omega. + EXAMPLES:: sage: B = LaurentPolynomialRing(ZZ, 'y', 3) @@ -889,5 +940,3 @@ def _compositions_mod_(u, r): for j in srange(m): for a in _compositions_mod_(u[1:], r - j*v): yield (Z(j),) + a - - From 6c87355556d25ce1f8b28a0a4eeaf1ce2df4d240 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 09:27:06 +0100 Subject: [PATCH 162/370] move omega to src/sage/rings/polynomial to prepare for SageMath merging --- .gitignore | 1 - __init__.py | 0 generating_function_of_polyhedron.py | 942 ------------------ .../sage/rings/polynomial/omega.py | 0 4 files changed, 943 deletions(-) delete mode 100644 .gitignore delete mode 100644 __init__.py delete mode 100644 generating_function_of_polyhedron.py rename omega.py => src/sage/rings/polynomial/omega.py (100%) diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 0d20b6487c6..00000000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/generating_function_of_polyhedron.py b/generating_function_of_polyhedron.py deleted file mode 100644 index c742e3ba3a7..00000000000 --- a/generating_function_of_polyhedron.py +++ /dev/null @@ -1,942 +0,0 @@ - -# ***************************************************************************** -# Copyright (C) 2016 Daniel Krenn -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# http://www.gnu.org/licenses/ -# ***************************************************************************** - -from __future__ import print_function -from __future__ import absolute_import -from six import iteritems, itervalues - - -def generating_function_of_polyhedron(polyhedron, split=False, - result_as_tuple=None, **kwds): - r""" - Return the generating function of the integer points of - the polyhedron's orthant with only nonnegative coordinates. - - INPUT: - - - ``polyhedron`` -- an instance of - :class:`~sage.geometry.polyhedron.base.Polyhedron_base` - (see also :mod:`sage/geometry/polyhedron/constructor`). - - - ``split`` -- (default: ``False``) ``False`` computes the generating - function directly, whereas ``True`` splits the ``polyhedron`` - into several small disjoint polyhedra and adds the results. - ``split`` may also be a list of disjoint polyhedra. - - - ``result_as_tuple`` -- (default: ``None``) a boolean or ``None``. - - - ``indices`` -- (default: ``None``) a list or tuple. If this - is ``None``, this is automatically determined. - - - ``Factorization_sort`` (default: ``False``) and - ``Factorization_simplify`` (default: ``True``) -- are passed on to - :class:`sage.structure.factorization.Factorization` when creating - the result. - - - ``sort_factors`` -- (default: ``False``) a boolean. - - OUTPUT: - - The generating function as a (partial) - :class:`~sage.structure.factorization.Factorization` - of the result whose factors are laurent polynomials or - a tuple (:class:`Summandization`) of such elements. - - EXAMPLES:: - - sage: P2 = ( - ....: Polyhedron(ieqs=[(0, 0, 0, 1), (0, 0, 1, 0), (0, 1, 0, -1)]), - ....: Polyhedron(ieqs=[(0, -1, 0, 1), (0, 1, 0, 0), (0, 0, 1, 0)])) - sage: generating_function_of_polyhedron(P2[0], sort_factors=True) - 1 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 - sage: generating_function_of_polyhedron(P2[1], sort_factors=True) - 1 * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 - sage: (P2[0] & P2[1]).Hrepresentation() - (An equation (1, 0, -1) x + 0 == 0, - An inequality (1, 0, 0) x + 0 >= 0, - An inequality (0, 1, 0) x + 0 >= 0) - sage: generating_function_of_polyhedron(P2[0] & P2[1], sort_factors=True) - 1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 - - :: - - sage: P3 = ( - ....: Polyhedron( - ....: ieqs=[(0, 0, 0, 0, 1), (0, 0, 0, 1, 0), - ....: (0, 0, 1, 0, -1), (-1, 1, 0, -1, -1)]), - ....: Polyhedron( - ....: ieqs=[(0, 0, -1, 0, 1), (0, 1, 0, 0, -1), - ....: (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), (-1, 1, -1, -1, 0)]), - ....: Polyhedron( - ....: ieqs=[(1, -1, 0, 1, 1), (1, -1, 1, 1, 0), - ....: (0, 0, 0, 0, 1), (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), - ....: (1, 0, 1, 1, -1), (0, 1, 0, 0, 0), (1, 1, 1, 0, -1)]), - ....: Polyhedron( - ....: ieqs=[(0, 1, 0, -1, 0), (0, -1, 0, 0, 1), - ....: (-1, 0, -1, -1, 1), (0, 0, 1, 0, 0), (0, 0, 0, 1, 0)]), - ....: Polyhedron( - ....: ieqs=[(0, 1, 0, 0, 0), (0, 0, 1, 0, 0), - ....: (-1, -1, -1, 0, 1), (0, -1, 0, 1, 0)])) - sage: def intersect(I): - ....: I = iter(I) - ....: result = next(I) - ....: for i in I: - ....: result &= i - ....: return result - sage: for J in subsets(range(len(P3))): # TODO: check more results - ....: if not J: - ....: continue - ....: P = intersect([P3[j] for j in J]) - ....: print('{}: {}'.format(J, P.Hrepresentation())) - ....: print(generating_function_of_polyhedron(P, sort_factors=True)) - [0]: (An inequality (0, 0, 0, 1) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, -1) x + 0 >= 0, - An inequality (1, 0, -1, -1) x - 1 >= 0) - y0 * (-y0 + 1)^-1 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [1]: (An inequality (0, -1, 0, 1) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, -1, -1, 0) x - 1 >= 0, - An inequality (1, 0, 0, -1) x + 0 >= 0) - (-y0^2*y2*y3 - y0^2*y3 + y0*y3 + y0) * - (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y3 + 1)^-1 * - (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1]: (An equation (0, 1, 0, -1) x + 0 == 0, - An inequality (1, -1, -1, 0) x - 1 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0) - y0 * (-y0 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [2]: (An inequality (-1, 0, 1, 1) x + 1 >= 0, - An inequality (-1, 1, 1, 0) x + 1 >= 0, - An inequality (0, 0, 0, 1) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (0, 1, 1, -1) x + 1 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0, - An inequality (1, 1, 0, -1) x + 1 >= 0) - (y0^7*y1^6*y2^3*y3^5 + y0^7*y1^5*y2^4*y3^4 + y0^6*y1^7*y2^2*y3^5 - - y0^7*y1^5*y2^3*y3^4 + y0^6*y1^6*y2^3*y3^4 - y0^6*y1^6*y2^2*y3^5 - - 2*y0^6*y1^6*y2^2*y3^4 - 3*y0^6*y1^5*y2^3*y3^4 - y0^6*y1^5*y2^2*y3^5 - - y0^6*y1^5*y2^3*y3^3 - y0^6*y1^4*y2^4*y3^3 + y0^6*y1^5*y2^2*y3^4 - - 2*y0^5*y1^6*y2^2*y3^4 - 2*y0^6*y1^4*y2^3*y3^4 - y0^5*y1^6*y2*y3^5 + - y0^6*y1^5*y2^2*y3^3 + y0^6*y1^4*y2^3*y3^3 - y0^5*y1^5*y2^3*y3^3 - - y0^6*y1^3*y2^4*y3^3 + y0^6*y1^4*y2^2*y3^4 - y0^5*y1^5*y2^2*y3^4 + - y0^5*y1^5*y2*y3^5 + 3*y0^5*y1^5*y2^2*y3^3 + y0^6*y1^3*y2^3*y3^3 + - 2*y0^5*y1^5*y2*y3^4 - y0^4*y1^6*y2*y3^4 + 4*y0^5*y1^4*y2^2*y3^4 + - y0^5*y1^4*y2^3*y3^2 + 3*y0^5*y1^4*y2^2*y3^3 + 4*y0^5*y1^3*y2^3*y3^3 - - y0^5*y1^4*y2*y3^4 + 3*y0^4*y1^5*y2*y3^4 + y0^5*y1^3*y2^2*y3^4 - - y0^5*y1^4*y2^2*y3^2 + y0^5*y1^3*y2^3*y3^2 + y0^5*y1^2*y2^4*y3^2 - - y0^5*y1^4*y2*y3^3 + 2*y0^4*y1^5*y2*y3^3 - 2*y0^5*y1^3*y2^2*y3^3 + - 5*y0^4*y1^4*y2^2*y3^3 + y0^5*y1^2*y2^3*y3^3 - y0^5*y1^3*y2^2*y3^2 - - y0^5*y1^2*y2^3*y3^2 + 2*y0^4*y1^3*y2^3*y3^2 - 4*y0^4*y1^4*y2*y3^3 + - 2*y0^3*y1^5*y2*y3^3 - y0^5*y1^2*y2^2*y3^3 - y0^4*y1^3*y2^2*y3^3 + - y0^3*y1^5*y3^4 - y0^4*y1^3*y2*y3^4 - y0^4*y1^4*y2*y3^2 - - 5*y0^4*y1^3*y2^2*y3^2 + y0^3*y1^4*y2^2*y3^2 - y0^4*y1^2*y2^3*y3^2 - - 2*y0^4*y1^3*y2*y3^3 - y0^3*y1^4*y2*y3^3 - 3*y0^4*y1^2*y2^2*y3^3 - - y0^3*y1^4*y3^4 - y0^4*y1^2*y2^3*y3 + y0^4*y1^3*y2*y3^2 - - 3*y0^3*y1^4*y2*y3^2 - y0^4*y1^2*y2^2*y3^2 - 2*y0^3*y1^3*y2^2*y3^2 - - y0^4*y1*y2^3*y3^2 - 2*y0^3*y1^4*y3^3 + y0^4*y1^2*y2*y3^3 - - 5*y0^3*y1^3*y2*y3^3 + y0^4*y1^2*y2^2*y3 - y0^3*y1^3*y2^2*y3 + - y0^4*y1^2*y2*y3^2 - y0^3*y1^3*y2*y3^2 - y0^2*y1^4*y2*y3^2 + - y0^4*y1*y2^2*y3^2 - 4*y0^3*y1^2*y2^2*y3^2 + y0^3*y1^3*y3^3 - - 2*y0^2*y1^4*y3^3 + y0^3*y1^2*y2*y3^3 + y0^3*y1^3*y2*y3 - - y0^3*y1*y2^3*y3 + y0^3*y1^3*y3^2 + 5*y0^3*y1^2*y2*y3^2 - - 2*y0^2*y1^3*y2*y3^2 + y0^3*y1*y2^2*y3^2 + y0^2*y1^3*y3^3 + - y0^3*y1^2*y2*y3 + y0^2*y1^3*y2*y3 + 2*y0^3*y1*y2^2*y3 - - y0^2*y1^2*y2^2*y3 + 3*y0^2*y1^3*y3^2 + 4*y0^2*y1^2*y2*y3^2 + - y0^2*y1^2*y3^3 - y0^3*y1*y2*y3 + 4*y0^2*y1^2*y2*y3 + - 2*y0^2*y1*y2^2*y3 + y0^2*y1^2*y3^2 + y0*y1^3*y3^2 + - 2*y0^2*y1*y2*y3^2 + y0^2*y1*y2^2 - y0^2*y1^2*y3 - y0^2*y1*y2*y3 + - y0*y1^2*y2*y3 + y0^2*y2^2*y3 - y0^2*y1*y3^2 + y0*y1^2*y3^2 - - y0^2*y1*y2 - y0^2*y1*y3 - y0*y1^2*y3 - y0^2*y2*y3 - 2*y0*y1*y3^2 - - y0*y1*y2 - 3*y0*y1*y3 - 2*y0*y2*y3 - - y0*y2 + y0*y3 - y1*y3 + y0 + y3 + 1) * - (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y1*y3 + 1)^-1 * - (-y0*y1*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * - (-y0*y2*y3 + 1)^-1 * (-y0*y1^2*y3 + 1)^-1 * (-y0^2*y1*y2*y3 + 1)^-1 - [0, 2]: (An equation (1, 0, -1, -1) x - 1 == 0, - An inequality (-1, 1, 1, 0) x + 1 >= 0, - An inequality (1, 0, -1, 0) x - 1 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0) - y0 * (-y1 + 1)^-1 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [1, 2]: (An equation (1, -1, -1, 0) x - 1 == 0, - An inequality (0, -1, 0, 1) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, 0, -1) x + 0 >= 0, - An inequality (1, -1, 0, 0) x - 1 >= 0) - (-y0^2*y2*y3 + y0*y3 + y0) * - (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 2]: (An equation (0, 1, 0, -1) x + 0 == 0, - An equation (1, -1, -1, 0) x - 1 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, -1, 0, 0) x - 1 >= 0) - y0 * (-y0*y2 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - [3]: (An inequality (-1, 0, 0, 1) x + 0 >= 0, - An inequality (0, -1, -1, 1) x - 1 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, -1, 0) x + 0 >= 0) - (-y0*y1*y3^2 - y0*y3^2 + y0*y3 + y3) * - (-y3 + 1)^-1 * (-y0*y3 + 1)^-1 * - (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 3]: (An equation -1 == 0,) - 0 - [1, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, - An inequality (1, -1, -1, 0) x - 1 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0) - y0*y3 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 3]: (An equation -1 == 0,) - 0 - [2, 3]: (An equation (0, 1, 1, -1) x + 1 == 0, - An inequality (1, 0, -1, 0) x + 0 >= 0, - An inequality (-1, 1, 1, 0) x + 1 >= 0, - An inequality (0, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0) - (-y0*y1*y3^2 + y0*y3 + y3) * - (-y1*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 3]: (An equation -1 == 0,) - 0 - [1, 2, 3]: (An equation (1, 0, 0, -1) x + 0 == 0, - An equation (1, -1, -1, 0) x - 1 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, -1, 0, 0) x - 1 >= 0) - y0*y3 * (-y0*y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 1, 2, 3]: (An equation -1 == 0,) - 0 - [4]: (An inequality (-1, -1, 0, 1) x - 1 >= 0, - An inequality (-1, 0, 1, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0) - y3 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 4]: (An equation -1 == 0,) - 0 - [1, 4]: (An equation -1 == 0,) - 0 - [0, 1, 4]: (An equation -1 == 0,) - 0 - [2, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, - An inequality (-1, 0, 1, 0) x + 0 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0, - An inequality (0, 1, 0, 0) x + 0 >= 0) - y3 * (-y2 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 4]: (An equation -1 == 0,) - 0 - [1, 2, 4]: (An equation -1 == 0,) - 0 - [0, 1, 2, 4]: (An equation -1 == 0,) - 0 - [3, 4]: (An equation (1, 0, -1, 0) x + 0 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (-1, -1, 0, 1) x - 1 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0) - y3 * (-y3 + 1)^-1 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 3, 4]: (An equation -1 == 0,) - 0 - [1, 3, 4]: (An equation -1 == 0,) - 0 - [0, 1, 3, 4]: (An equation -1 == 0,) - 0 - [2, 3, 4]: (An equation (1, 1, 0, -1) x + 1 == 0, - An equation (1, 0, -1, 0) x + 0 == 0, - An inequality (0, 1, 0, 0) x + 0 >= 0, - An inequality (1, 0, 0, 0) x + 0 >= 0) - y3 * (-y1*y3 + 1)^-1 * (-y0*y2*y3 + 1)^-1 - [0, 2, 3, 4]: (An equation -1 == 0,) - 0 - [1, 2, 3, 4]: (An equation -1 == 0,) - 0 - [0, 1, 2, 3, 4]: (An equation -1 == 0,) - 0 - - TESTS:: - - sage: generating_function_of_polyhedron( - ....: Polyhedron(ieqs=[(0, 0, 1, 0, 0), (-1, 1, -1, 0, 0)]), - ....: sort_factors=True) - y0 * (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y3 + 1)^-1 * (-y0*y1 + 1)^-1 - sage: generating_function_of_polyhedron( - ....: Polyhedron(ieqs=[(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), - ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)]), - ....: sort_factors=True) - (-y0^2*y3 + y0*y3 + y0) * - (-y0 + 1)^-1 * (-y2 + 1)^-1 * (-y0*y3 + 1)^-1 * (-y0*y1*y3 + 1)^-1 - - sage: generating_function_of_polyhedron( - ....: Polyhedron(ieqs=[(0, 1, 0, -1, 0, 0), (0, 0, 0, 1, 0, 0)], - ....: eqns=[(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), - ....: (0, 1, -1, 0, 0, 0)]), - ....: sort_factors=True) - 1 * (-y0*y1*y3 + 1)^-1 * (-y0*y1*y2*y3*y4 + 1)^-1 - - :: - - sage: G = generating_function_of_polyhedron(P2[0], sort_factors=True) - sage: S = generating_function_of_polyhedron(P2[0], sort_factors=True, - ....: split=True) - sage: sum(S) == G.value() - True - - sage: G = generating_function_of_polyhedron(P2[1], sort_factors=True) - sage: S = generating_function_of_polyhedron(P2[1], sort_factors=True, - ....: split=True) - sage: sum(S) == G.value() - True - - sage: G = generating_function_of_polyhedron(P3[0], sort_factors=True) - sage: S = generating_function_of_polyhedron(P3[0], sort_factors=True, - ....: split=True) - sage: sum(S) == G.value() - True - """ - import logging - logger = logging.getLogger(__name__) - - from sage.combinat.permutation import Permutations - from sage.geometry.polyhedron.constructor import Polyhedron - - if result_as_tuple is None: - result_as_tuple = split - - if polyhedron.is_empty(): - from sage.structure.factorization import Factorization - result = Factorization([], unit=0) - if result_as_tuple: - return Summandization((result,)) - else: - return result - - logger.info('generating_function_of_polyhedron: %s', polyhedron) - - if split is False: - result = _generating_function_of_polyhedron_(polyhedron, **kwds) - if result_as_tuple: - return Summandization(result) - else: - if len(result) != 1: - raise ValueError("Cannot unpack result. " - "(Set 'result_as_tuple=True'.)") - return result[0] - - d = polyhedron.ambient_dim() - if d <= 1: - raise ValueError('Cannot do splitting with only ' - 'dimension {}.'.format(d)) - - if split is True: - split = iter( - (Polyhedron( - ieqs=[tuple(1 if i==b else (-1 if i==a or i==0 and a > b else 0) - for i in range(d+1)) - for a, b in zip(pi[:-1], pi[1:])]), - 'b{}'.format(pi[0]-1) + - ''.join((' <= ' if a < b else ' < ') + - 'b{}'.format(b-1) - for a, b in zip(pi[:-1], pi[1:]))) - for pi in Permutations(d)) - else: - split = iter((ph, ph.repr_pretty_Hrepresentation(prefix='b')) - for ph in split) - - result = [] - for split_polyhedron, pi_log in split: - logger.info('split polyhedron by %s', pi_log) - result.append(_generating_function_of_polyhedron_( - polyhedron & split_polyhedron, **kwds)) - if not result_as_tuple: - raise ValueError("Cannot unpack result." - "(Unset 'result_as_tuple=False'.)") - return Summandization(sum(result, ())) - - -def _generating_function_of_polyhedron_( - polyhedron, indices=None, **kwds): - r""" - Helper function for :func:`generating_function_of_polyhedron` which - does the actual computation of the generating function. - - TESTS:: - - sage: generating_function_of_polyhedron( # indirect doctest - ....: Polyhedron(ieqs=[(0, 1, 0, 0), (0, -1, 1, 0)], - ....: eqns=[(0, -1, -1, 2)]), - ....: result_as_tuple=True, sort_factors=True) - (-y0^2*y1^2*y2^2 + 1) * (-y1^2*y2 + 1)^-1 * - (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 + - (-y0^3*y1^3*y2^3 + y0*y1*y2) * (-y1^2*y2 + 1)^-1 * - (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 - """ - import logging - logger = logging.getLogger(__name__) - - logger.info('polyhedron: %s', - polyhedron.repr_pretty_Hrepresentation(prefix='b')) - - if polyhedron.is_empty(): - from sage.structure.factorization import Factorization - return (Factorization([], unit=0),) - - Hrepr = polyhedron.Hrepresentation() - - inequalities = tuple(tuple(entry) - for entry in Hrepr if entry.is_inequality()) - equations = tuple(tuple(entry) - for entry in Hrepr if entry.is_equation()) - if len(inequalities) + len(equations) != len(Hrepr): - raise ValueError('Cannot handle {}.'.format(polyhedron)) - - if not inequalities: - raise NotImplementedError('no inequality given') - - if indices is None: - indices = range(len(inequalities[0]) - 1) - - n = len(indices) + 1 - if any(len(e) != n for e in inequalities): - raise ValueError('Not all coefficient vectors of the inequalities ' - 'have the same length.') - if any(len(e) != n for e in equations): - raise ValueError('Not all coefficient vectors of the equations ' - 'have the same length.') - - logger.info('generating_function_of_polyhedron: ' - '%s inequalities', len(inequalities)) - - mods = generate_mods(equations) - logger.info('splitting by moduli %s', mods) - - return tuple(__generating_function_of_polyhedron__( - indices, inequalities, equations, mod, **kwds) for mod in mods) - - -def __generating_function_of_polyhedron__( - indices, inequalities, equations, mod, - Factorization_sort=False, Factorization_simplify=False, - sort_factors=False): - r""" - Helper function for :func:`generating_function_of_polyhedron` which - does the actual computation of the generating function. - - TESTS:: - - sage: __generating_function_of_polyhedron__( - ....: (0, 2), [(0, 1, 0)], [(1, -1, 2)], - ....: {0: (2, 1)}, sort_factors=True) - y0 * (-y0^2*y2 + 1)^-1 - sage: __generating_function_of_polyhedron__( - ....: srange(3), [(0, 1, 0, 0), (0, 0, 1, 0)], [(1, -1, 0, 2)], - ....: {0: (2, 1)}, sort_factors=True) - y0 * (-y1 + 1)^-1 * (-y0^2*y2 + 1)^-1 - sage: __generating_function_of_polyhedron__( - ....: srange(3), [(0, 1, 0, 0), (0, -1, 1, 0)], [(0, -1, -1, 2)], - ....: {0: (2, 1), 1: (2, 1)}, sort_factors=True) - (-y0^3*y1^3*y2^3 + y0*y1*y2) * - (-y1^2*y2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 * (-y0^2*y1^2*y2^2 + 1)^-1 - """ - import logging - logger = logging.getLogger(__name__) - - from omega import _Omega_ - from omega import partition - from sage.rings.integer_ring import ZZ - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - from sage.structure.factorization import Factorization - - B = LaurentPolynomialRing( - ZZ, - tuple('y{}'.format(k) for k in indices), - sparse=True) - - extra_factor_mod, rules_mod, inequalities, equations = \ - prepare_mod(mod, B, inequalities, equations) - - extra_factor_equations, rules_equations, indices_equations = \ - prepare_equations(equations, B) - - inequalities, extra_factor_inequalities, rules_inequalities = \ - prepare_inequalities(inequalities, B) - - numerator = B(1) - terms = B.gens() - L = B - for i, coeffs in enumerate(inequalities): - L = LaurentPolynomialRing(L, 'mu{}'.format(i), sparse=True) - l = L.gen() - logger.debug('generating_function_of_polyhedron: ' - '%s --> %s', l, pretty_inequality(coeffs)) - it_coeffs = iter(coeffs) - numerator *= l**next(it_coeffs) - assert numerator.parent() == L - terms = tuple(l**c * t for c, t in zip(it_coeffs, terms)) - assert all(y == t for y, t in - (zip(B.gens(), terms)[i] for i in indices_equations)) - terms = tuple(t for i, t in enumerate(terms) - if i not in indices_equations) - - logger.info('generating_function_of_polyhedron: ' - 'terms denominator %s', terms) - - def decode_factor(factor): - D = factor.dict() - assert len(D) == 1 - exponent, coefficient = next(iteritems(D)) - return coefficient, exponent - - while repr(numerator.parent().gen()).startswith('mu'): - logger.info('generating_function_of_polyhedron: ' - 'applying Omega[%s]...', numerator.parent().gen()) - logger.info('...on terms denominator %s', terms) - logger.info('...(numerator has %s)', numerator.number_of_terms()) - - decoded_factors, other_factors = \ - partition((decode_factor(factor) for factor in terms), - lambda factor: factor[1] == 0) - other_factors = tuple(factor[0] for factor in other_factors) - numerator, factors_denominator = \ - _Omega_(numerator.dict(), tuple(decoded_factors)) - terms = other_factors + factors_denominator - - numerator = \ - (((numerator.subs(rules_inequalities) * extra_factor_inequalities - ).subs(rules_equations) * extra_factor_equations - ).subs(rules_mod) * extra_factor_mod) - terms = tuple( - t.subs(rules_inequalities).subs(rules_equations).subs(rules_mod) - for t in terms) - - if sort_factors: - def key(t): - D = t.dict().popitem()[0] - return (-sum(abs(d) for d in D), D) - terms = sorted(terms, key=key, reverse=True) - return Factorization([(numerator, 1)] + - list((1-t, -1) for t in terms), - sort=Factorization_sort, - simplify=Factorization_simplify) - - -def pretty_inequality(ineq, indices=None): - r""" - Format the given inequality pretty. - - INPUT: - - - ``ineq`` -- a list or tuple. - - - ``indices`` -- (default: ``None``) a list or tuple. - - OUTPUT: - - A string. - - """ - from sage.symbolic.ring import SR - from sage.modules.free_module_element import vector - - if indices is None: - indices = range(len(ineq)-1) - vars = vector([1] + list(SR("b{}".format(i)) for i in indices)) - v = vector(ineq) - positive_part = vector([max(c, 0) for c in v]) - negative_part = - (v - positive_part) - assert v == positive_part - negative_part - return '{} >= {}'.format(positive_part*vars, negative_part*vars) - - -class Summandization(tuple): - r""" - A class representing a tuple as sum. It is shown - as summands joined by a `+`. - """ - def __repr__(self): - return ' + '.join(repr(s) for s in self) - - __str__ = __repr__ - - -def prepare_inequalities(inequalities, B): - r""" - Split off (simple) inequalities which can be handled better - without passing them to Omega. - - EXAMPLES:: - - sage: B = LaurentPolynomialRing(ZZ, 'y', 3) - sage: prepare_inequalities([(0, -1, 1, 0), (2, -1, -1, 1)], B) - ([(2, -2, -1, 1)], 1, {y2: y2, y1: y1, y0: y0*y1}) - sage: prepare_inequalities([(-1, -1, 1, 0), (2, -1, -1, 1)], B) - ([(1, -2, -1, 1)], y1, {y2: y2, y1: y1, y0: y0*y1}) - sage: prepare_inequalities([(2, -1, 1, 0), (2, -1, -1, 1)], B) - ([(4, -2, -1, 1)], y1^-2, {y2: y2, y1: y1, y0: y0*y1}) - - TESTS:: - - sage: B = LaurentPolynomialRing(ZZ, 'y', 3) - sage: prepare_inequalities([(1, 1, -1, 0), (1, -1, 0, 1), - ....: (2, -1, -1, 3)], B) - ([(-3, 2, 1, 3)], y0^-1*y2^-2, {y2: y2, y1: y0*y1*y2, y0: y0*y2}) - - sage: B = LaurentPolynomialRing(ZZ, 'y', 4) - sage: prepare_inequalities([(-1, 1, -1, 0, 0)], B) - ([], y0, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) - sage: prepare_inequalities([(0, 0, -1, 0, 1), (0, 0, 1, 0, 0), - ....: (0, 1, 0, 0, -1), (-1, 1, -1, 0, 0)], B) - ([(1, 1, 0, 0, -1)], y0, {y3: y3, y2: y2, y1: y0*y1*y3, y0: y0}) - sage: prepare_inequalities([(-2, 1, -1, 0, 0)], B) - ([], y0^2, {y3: y3, y2: y2, y1: y0*y1, y0: y0}) - - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-2, 0, -1, 0, 1), - ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y2^3*y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(0, -1, 1, 0, 0), (-3, 0, -1, 0, 1), - ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y2^2*y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-3, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y1^2*y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (0, -1, 0, 1, 0), (-2, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y1^3*y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-2, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (-3, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, -1, 1, 1)], - y1^2*y2^3*y3^3, - {y3: y3, y2: y2*y3, y1: y1, y0: y0*y1*y2*y3}) - sage: prepare_inequalities([(-3, -1, 1, 0, 0), (0, 0, -1, 0, 1), - ....: (-2, -1, 0, 1, 0), (0, 0, 0, -1, 1)], B) - ([(1, 0, 1, -1, 1)], - y1^3*y2^2*y3^3, - {y3: y3, y2: y2, y1: y1*y3, y0: y0*y1*y2*y3}) - """ - import logging - logger = logging.getLogger(__name__) - - from itertools import takewhile - from sage.graphs.digraph import DiGraph - from sage.matrix.constructor import matrix - from sage.modules.free_module_element import vector - from sage.rings.integer_ring import ZZ - - inequalities_filtered = [] - chain_links = {} - for coeffs in inequalities: - dim = len(coeffs) - if all(c >= 0 for c in coeffs): - logger.debug('generating_function_of_polyhedron: ' - 'skipping %s (all coefficients >= 0)', - pretty_inequality(coeffs)) - continue - constant = coeffs[0] - ones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == 1) - mones = tuple(i+1 for i, c in enumerate(coeffs[1:]) if c == -1) - absgetwo = tuple(i+1 for i, c in enumerate(coeffs[1:]) if abs(c) >= 2) - if len(ones) == 1 and not mones and not absgetwo: - if constant < 0: - # TODO: could be skipped... - inequalities_filtered.append(coeffs) - elif len(ones) == 1 and len(mones) == 1 and not absgetwo: - logger.debug('generating_function_of_polyhedron: ' - 'handling %s', - pretty_inequality(coeffs)) - chain_links[(mones[0], ones[0])] = constant - else: - inequalities_filtered.append(coeffs) - - G = DiGraph(chain_links, format='list_of_edges') - potential = {} - paths = {} - D = {} - inequalities_extra = [] - for i in range(dim): - D[(i, i)] = 1 - for v in G.topological_sort(): - NP = iter(sorted(((n, potential[n] + chain_links[(n, v)]) - for n in G.neighbor_in_iterator(v)), - key=lambda k: k[1])) - n, p = next(NP, (None, 0)) - potential[v] = p - D[(0, v)] = -p - paths[v] = paths.get(n, ()) + (v,) - for u in paths[v]: - D[(u, v)] = 1 - - for n, p in NP: - ell = len(tuple(takewhile(lambda u: u[0] == u[1], - zip(paths[n], paths[v])))) - coeffs = dim*[0] - for u in paths[v][ell:]: - coeffs[u] = 1 - for u in paths[n][ell:]: - coeffs[u] = -1 - coeffs[0] = p - potential[v] - inequalities_extra.append(tuple(coeffs)) - T = matrix(ZZ, dim, dim, D) - - inequalities = list(tuple(T*vector(ieq)) - for ieq in inequalities_filtered) + \ - inequalities_extra - - rules_pre = iter((y, B({tuple(row[1:]): 1})) - for y, row in zip((1,) + B.gens(), T.rows())) - factor = next(rules_pre)[1] - rules = dict(rules_pre) - - return inequalities, factor, rules - - -def prepare_equations_transformation(E): - r""" - TESTS:: - - sage: prepare_equations_transformation(matrix([(0, 1, 0, -2)])) - ([ 0 -1/2 0 1], (3,), (0, 1)) - sage: prepare_equations_transformation(matrix([(0, 1, -2, 0), (0, 2, 0, -3)])) - ( - [ 0 -1/2 1 0] - [ 0 -2/3 0 1], (2, 3), (0, 1) - ) - """ - indices_nonzero = tuple(i for i, col in enumerate(E.columns()) - if i > 0 and not col.is_zero()) - indices = [] - r = 0 - for i in reversed(indices_nonzero): - indices.append(i) - r1 = E.matrix_from_columns(indices).rank() - if r1 > r: - r = r1 - if len(indices) >= E.nrows(): - break - else: - indices = indices[:-1] - assert len(indices) == E.nrows() - indices = tuple(reversed(indices)) - indicesn = (0,) + tuple(i for i in indices_nonzero if i not in indices) - TE = E.matrix_from_columns(indices).inverse() * E - return TE, indices, indicesn - - -def prepare_equations(equations, B): - r""" - EXAMPLES:: - - sage: B = LaurentPolynomialRing(ZZ, 'y', 4) - sage: prepare_equations([(1, 1, 1, -1, 0)], B) - (y2, {y1: y1*y2, y0: y0*y2}, (2,)) - sage: prepare_equations([(0, 1, 0, -1, 0)], B) - (1, {y0: y0*y2}, (2,)) - sage: prepare_equations([(-1, 0, 1, -1, -1), (1, 1, 0, 1, 2)], B) - (y2^-1, {y1: y1*y2^2*y3^-1, y0: y0*y2*y3^-1}, (2, 3)) - - TESTS:: - - sage: B = LaurentPolynomialRing(ZZ, 'y', 4) - sage: prepare_equations([(0, 0, 1, 0, -1), (-1, 1, -1, -1, 0)], B) - (y2^-1, {y1: y1*y2^-1*y3, y0: y0*y2}, (2, 3)) - - sage: B = LaurentPolynomialRing(ZZ, 'y', 5) - sage: prepare_equations([(0, 0, 0, 1, 0, -1), (0, 1, 0, 0, -1, 0), - ....: (0, 1, -1, 0, 0, 0)], B) - (1, {y2: y2*y4, y0: y0*y1*y3}, (1, 3, 4)) - """ - from sage.matrix.constructor import matrix - from sage.misc.misc_c import prod - - E = matrix(equations) - if not E: - return 1, {}, () - - TE, indices, indicesn = prepare_equations_transformation(E) - - gens = (1,) + B.gens() - z = tuple(gens[i] for i in indices) - gens_cols = zip(gens, TE.columns()) - rules_pre = iter((y, y * prod(zz**(-c) for zz, c in zip(z, col))) - for y, col in (gens_cols[i] for i in indicesn)) - factor = next(rules_pre)[1] - rules = dict(rules_pre) - - return factor, rules, tuple(i-1 for i in indices) - - -def generate_mods(equations): - from sage.arith.misc import lcm - from sage.matrix.constructor import matrix - from sage.rings.integer_ring import ZZ - from sage.rings.rational_field import QQ - - TE, TEi, TEin = prepare_equations_transformation(matrix(equations)) - TEin = TEin[1:] - if TE.base_ring() == ZZ: - mods = [{}] - elif TE.base_ring() == QQ: - m = lcm([e.denominator() for e in TE.list()]) - if m == 1: - mods = [{}] - else: - cols = TE.columns() - assert all(cols[j][i] == 1 for i, j in enumerate(TEi)) - pre_mods = compositions_mod((tuple(ZZ(cc*m) for cc in cols[i]) - for i in TEin), - m, r=(-cc*m for cc in cols[0]), - multidimensional=True) - mods = tuple({i-1: (aa.modulus(), ZZ(aa)) - for i, aa in zip(TEin, a) if aa.modulus() > 1} - for a in pre_mods) - else: - raise TypeError('Equations over ZZ or QQ expected, but got ' - 'equations over {}.'.format(TE.base_ring())) - - return mods - - -def prepare_mod(mod, B, *vecs): - r""" - EXAMPLES:: - - sage: B = LaurentPolynomialRing(ZZ, 'y', 3) - sage: prepare_mod({0: (2, 1)}, B, [(1, -1, 0, 2)]) - (y0, {y2: y2, y1: y1, y0: y0^2}, ((0, -2, 0, 2),)) - sage: prepare_mod({0: (2, 1), 1: (2, 1)}, B, - ....: [(0, -1, -1, 2)], [(0, -1, 1, 0)]) - (y0*y1, {y2: y2, y1: y1^2, y0: y0^2}, - ((-2, -2, -2, 2),), ((0, -2, 2, 0),)) - """ - from sage.matrix.constructor import matrix - from sage.modules.free_module_element import vector - from sage.rings.integer_ring import ZZ - - if not mod: - return (1, {}) + vecs - - n = len(B.gens()) + 1 - - D = {(i, i): 1 for i in range(n)} - for i, mr in iteritems(mod): - D[(i+1, i+1)] = mr[0] - D[(i+1, 0)] = mr[1] - T = matrix(ZZ, n, n, D) - - rules_pre = iter((y, B({tuple(row[1:]): 1})) - for y, row in zip((1,) + B.gens(), T.columns())) - factor = next(rules_pre)[1] - rules = dict(rules_pre) - - vecs = tuple(tuple(tuple(vector(e)*T) for e in vec) for vec in vecs) - - return (factor, rules) + vecs - - -def compositions_mod(u, m, r=0, multidimensional=False): - r""" - Return an iterable of tuples `a` such that `a u^T \equiv r \mod m`. - - INPUT: - - - ``m`` -- the modulus as a positive integer. - - - ``multidimensional`` -- (default: ``False``) a boolean. - - If ``multidimensional=False``: - - - ``u`` -- the coefficients as a tuple. - - - ``r`` -- (default: `0`) - the remainder as a nonnegative integer. - - If ``multidimensional=True``: - - - ``u`` -- the coefficients as a tuple of tuples (read column-wise). - - - ``r`` -- (default: the zero vector) - the remainder as a tuple of nonnegative integers. - - OUTPUT: - - An iterable of tuples; all these tuples have the same size as ``u``. - - EXAMPLES:: - - sage: list(compositions_mod([1, 1], 2)) - [(0, 0), (1, 1)] - sage: list(compositions_mod([1, 2, 3], 6)) - [(0, 0, 0), (1, 1, 1), (2, 2, 0), (3, 0, 1), (4, 1, 0), (5, 2, 1)] - sage: list(compositions_mod([2, 2, 2], 6)) - [(0, 0, 0), (0, 1, 2), (0, 2, 1), (1, 0, 2), - (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0), (2, 2, 2)] - - :: - - sage: list(compositions_mod([(1, 0), (0, 1)], 2, - ....: multidimensional=True)) - [(0, 0)] - sage: list(compositions_mod([(1, 2), (2, 2), (3, 2)], 6, - ....: multidimensional=True)) - [(0, 0, 0), (1, 1, 1), (2, 2, 2)] - - TESTS:: - - sage: list(compositions_mod([1, 0], 2)) - [(0, 0)] - """ - from sage.modules.free_module_element import vector - from sage.rings.finite_rings.integer_mod_ring import Zmod - - Z = Zmod(m) - if not multidimensional: - u = tuple(vector([Z(uu)]) for uu in u) - r = vector([Z(r)]) - else: - u = tuple(vector(Z(uuu) for uuu in uu) for uu in u) - if r == 0: - r = vector(Z(0) for _ in range(len(u[0]))) - else: - r = vector(Z(rr) for rr in r) - - return _compositions_mod_(u, r) - - -def _compositions_mod_(u, r): - if not u: - if all(rr == 0 for rr in r): - yield () - return - - from itertools import product - from sage.arith.srange import srange - from sage.modules.free_module_element import vector - from sage.rings.finite_rings.integer_mod_ring import Zmod - - v = u[0] - m = max(vv.order() for vv in v) - Z = Zmod(m) - for j in srange(m): - for a in _compositions_mod_(u[1:], r - j*v): - yield (Z(j),) + a diff --git a/omega.py b/src/sage/rings/polynomial/omega.py similarity index 100% rename from omega.py rename to src/sage/rings/polynomial/omega.py From 954df40c09292f27f134e039875ffacea5d3d965 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:09:51 +0100 Subject: [PATCH 163/370] docbuild --- src/doc/en/reference/polynomial_rings/index.rst | 1 + src/sage/rings/polynomial/omega.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/doc/en/reference/polynomial_rings/index.rst b/src/doc/en/reference/polynomial_rings/index.rst index 4e40b497ed5..e21ca23e2c3 100644 --- a/src/doc/en/reference/polynomial_rings/index.rst +++ b/src/doc/en/reference/polynomial_rings/index.rst @@ -57,6 +57,7 @@ Laurent Polynomials sage/rings/polynomial/laurent_polynomial_ring sage/rings/polynomial/laurent_polynomial + sage/rings/polynomial/omega Infinite Polynomial Rings ------------------------- diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 163dfb8085c..f2c5111aeae 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -705,7 +705,8 @@ def partition(items, predicate=bool): the ``predicate``, the second the elements satisfying the ``predicate``. Source of the code: - `http://nedbatchelder.com/blog/201306/filter_a_list_into_two_parts.html`_ + `http://nedbatchelder.com/blog/201306/filter_a_list_into_two_parts.html + `_ EXAMPLES: From 41b1dcd686234482c0f3dd0ce3468feae498a0b2 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:17:34 +0100 Subject: [PATCH 164/370] lazy import Omega --- src/sage/rings/polynomial/all.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/rings/polynomial/all.py b/src/sage/rings/polynomial/all.py index b9129f0985d..086b0e4ba10 100644 --- a/src/sage/rings/polynomial/all.py +++ b/src/sage/rings/polynomial/all.py @@ -40,6 +40,7 @@ # Laurent Polynomial Rings from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing +lazy_import('sage.rings.polynomial.omega', 'Omega') # Infinite Polynomial Rings from sage.rings.polynomial.infinite_polynomial_ring import InfinitePolynomialRing From 58943d69e8a8c2a579769f30aafe2fe978315efd Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:18:36 +0100 Subject: [PATCH 165/370] rename Omega_higher --> Omega_ge --- src/sage/rings/polynomial/omega.py | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index f2c5111aeae..221e7b3dba6 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -276,7 +276,7 @@ def _Omega_(A, decoded_factors): return sum(c for a, c in iteritems(A) if a >= 0), tuple() # Below we sort to make the caching more efficient. Doing this here - # (in contrast to directly in Omega_higher) results in much cleaner + # (in contrast to directly in Omega_ge) results in much cleaner # code and prevents an additional substitution or passing of a permutation. values, exponents = zip(*sorted(decoded_factors, key=lambda k: -k[1])) @@ -284,7 +284,7 @@ def _Omega_(A, decoded_factors): factors_denominator = None rules = None for a, c in iteritems(A): - n, fd = Omega_higher(a, exponents) + n, fd = Omega_ge(a, exponents) if factors_denominator is None: factors_denominator = fd else: @@ -299,7 +299,7 @@ def _Omega_(A, decoded_factors): @cached_function -def Omega_higher(a, exponents): +def Omega_ge(a, exponents): r""" Return `\Omega_{\ge}` of the expression specified by the input. @@ -327,41 +327,41 @@ def Omega_higher(a, exponents): EXAMPLES:: - sage: Omega_higher(0, (1, -2)) + sage: Omega_ge(0, (1, -2)) (1, (z0, z0^2*z1)) - sage: Omega_higher(0, (1, -3)) + sage: Omega_ge(0, (1, -3)) (1, (z0, z0^3*z1)) - sage: Omega_higher(0, (1, -4)) + sage: Omega_ge(0, (1, -4)) (1, (z0, z0^4*z1)) - sage: Omega_higher(0, (2, -1)) + sage: Omega_ge(0, (2, -1)) (z0*z1 + 1, (z0, z0*z1^2)) - sage: Omega_higher(0, (3, -1)) + sage: Omega_ge(0, (3, -1)) (z0*z1^2 + z0*z1 + 1, (z0, z0*z1^3)) - sage: Omega_higher(0, (4, -1)) + sage: Omega_ge(0, (4, -1)) (z0*z1^3 + z0*z1^2 + z0*z1 + 1, (z0, z0*z1^4)) - sage: Omega_higher(0, (1, 1, -2)) + sage: Omega_ge(0, (1, 1, -2)) (-z0^2*z1*z2 - z0*z1^2*z2 + z0*z1*z2 + 1, (z0, z1, z0^2*z2, z1^2*z2)) - sage: Omega_higher(0, (2, -1, -1)) + sage: Omega_ge(0, (2, -1, -1)) (z0*z1*z2 + z0*z1 + z0*z2 + 1, (z0, z0*z1^2, z0*z2^2)) - sage: Omega_higher(0, (2, 1, -1)) + sage: Omega_ge(0, (2, 1, -1)) (-z0*z1*z2^2 - z0*z1*z2 + z0*z2 + 1, (z0, z1, z0*z2^2, z1*z2)) :: - sage: Omega_higher(0, (2, -2)) + sage: Omega_ge(0, (2, -2)) (-z0*z1 + 1, (z0, z0*z1, z0*z1)) - sage: Omega_higher(0, (2, -3)) + sage: Omega_ge(0, (2, -3)) (z0^2*z1 + 1, (z0, z0^3*z1^2)) - sage: Omega_higher(0, (3, 1, -3)) + sage: Omega_ge(0, (3, 1, -3)) (-z0^3*z1^3*z2^3 + 2*z0^2*z1^3*z2^2 - z0*z1^3*z2 + z0^2*z2^2 - 2*z0*z2 + 1, (z0, z1, z0*z2, z0*z2, z0*z2, z1^3*z2)) :: - sage: Omega_higher(0, (3, 6, -1)) + sage: Omega_ge(0, (3, 6, -1)) (-z0*z1*z2^8 - z0*z1*z2^7 - z0*z1*z2^6 - z0*z1*z2^5 - z0*z1*z2^4 + z1*z2^5 - z0*z1*z2^3 + z1*z2^4 - z0*z1*z2^2 + z1*z2^3 - z0*z1*z2 + z0*z2^2 + z1*z2^2 + z0*z2 + z1*z2 + 1, @@ -369,17 +369,17 @@ def Omega_higher(a, exponents): TESTS:: - sage: Omega_higher(0, (2, 2, 1, 1, 1, 1, 1, -1, -1))[0].number_of_terms() # long time + sage: Omega_ge(0, (2, 2, 1, 1, 1, 1, 1, -1, -1))[0].number_of_terms() # long time 27837 :: - sage: Omega_higher(1, (2,)) + sage: Omega_ge(1, (2,)) (1, (z0,)) """ import logging logger = logging.getLogger(__name__) - logger.info('Omega_higher: a=%s, exponents=%s', a, exponents) + logger.info('Omega_ge: a=%s, exponents=%s', a, exponents) from sage.arith.misc import lcm from sage.arith.srange import srange @@ -433,14 +433,14 @@ def de_power(expression): expression = subs_power(expression, var, abs(e)) return expression - logger.debug('Omega_higher: preparing denominator') + logger.debug('Omega_ge: preparing denominator') factors_denominator = tuple(de_power(1 - factor) for factor in Omega_factors_denominator(x, y)) - logger.debug('Omega_higher: preparing numerator') + logger.debug('Omega_ge: preparing numerator') numerator = de_power(Omega_numerator(a, x, y, t)) - logger.info('Omega_higher: completed') + logger.info('Omega_ge: completed') return numerator, factors_denominator From 49e75f4ca4e9a79edeefa8d9930847d1594c58cd Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:18:48 +0100 Subject: [PATCH 166/370] fix imports in doctests --- src/sage/rings/polynomial/omega.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 221e7b3dba6..93ee920663c 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -267,6 +267,7 @@ def _Omega_(A, decoded_factors): :: + sage: from sage.rings.polynomial.omega import _Omega_ sage: _Omega_({0: 2, 1: 40, -1: -3}, []) (42, ()) sage: _Omega_({-1: 42}, []) @@ -327,6 +328,7 @@ def Omega_ge(a, exponents): EXAMPLES:: + sage: from sage.rings.polynomial.omega import Omega_ge sage: Omega_ge(0, (1, -2)) (1, (z0, z0^2*z1)) sage: Omega_ge(0, (1, -3)) @@ -475,6 +477,8 @@ def Omega_numerator(a, x, y, t): EXAMPLES:: + sage: from sage.rings.polynomial.omega import Omega_numerator, Omega_factors_denominator + sage: L. = LaurentPolynomialRing(ZZ) sage: Omega_numerator(0, ((x0,),), ((y0,),), t) 1 @@ -578,6 +582,10 @@ def Omega_numerator_P(a, x, y, t): OUTPUT: A laurent polynomial. + + TESTS:: + + sage: from sage.rings.polynomial.omega import Omega_numerator_P """ import logging logger = logging.getLogger(__name__) @@ -640,6 +648,8 @@ def Omega_factors_denominator(x, y): EXAMPLES:: + sage: from sage.rings.polynomial.omega import Omega_factors_denominator + sage: L. = LaurentPolynomialRing(ZZ) sage: Omega_factors_denominator(((x0,),), ((y0,),)) (-x0 + 1, -x0*y0 + 1) @@ -710,6 +720,7 @@ def partition(items, predicate=bool): EXAMPLES: + sage: from sage.rings.polynomial.omega import partition sage: E, O = partition(srange(10), is_odd) sage: tuple(E), tuple(O) ((0, 2, 4, 6, 8), (1, 3, 5, 7, 9)) @@ -736,6 +747,7 @@ def HomogenousSymmetricFunction(j, x): EXAMPLES:: + sage: from sage.rings.polynomial.omega import HomogenousSymmetricFunction sage: P = PolynomialRing(ZZ, 'X', 3) sage: HomogenousSymmetricFunction(0, P.gens()) 1 From b122d0f486259f203cfb34a5668590aabca4051d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:19:38 +0100 Subject: [PATCH 167/370] rename to homogenous_symmetric_function --- src/sage/rings/polynomial/omega.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 93ee920663c..db03e579c0b 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -550,11 +550,11 @@ def Omega_numerator(a, x, y, t): if m == 0: result = 1 - (prod(Omega_factors_denominator(x, y)) * - sum(HomogenousSymmetricFunction(j, xy) + sum(homogenous_symmetric_function(j, xy) for j in srange(-a)) if a < 0 else 0) elif n == 0: - result = sum(HomogenousSymmetricFunction(j, xy) + result = sum(homogenous_symmetric_function(j, xy) for j in srange(a+1)) else: result = Omega_numerator_P(a, x_flat, y_flat, t).subs({t: x_flat[-1]}) @@ -598,7 +598,7 @@ def Omega_numerator_P(a, x, y, t): x0 = t result = x0**(-a) + \ (prod(1 - x0*yy for yy in y) * - sum(HomogenousSymmetricFunction(j, y) * (1-x0**(j-a)) + sum(homogenous_symmetric_function(j, y) * (1-x0**(j-a)) for j in srange(a)) if a > 0 else 0) else: @@ -731,7 +731,7 @@ def partition(items, predicate=bool): (item for pred, item in b if pred)) -def HomogenousSymmetricFunction(j, x): +def homogenous_symmetric_function(j, x): r""" Return a complete homogeneous symmetric polynomial. @@ -747,15 +747,15 @@ def HomogenousSymmetricFunction(j, x): EXAMPLES:: - sage: from sage.rings.polynomial.omega import HomogenousSymmetricFunction + sage: from sage.rings.polynomial.omega import homogenous_symmetric_function sage: P = PolynomialRing(ZZ, 'X', 3) - sage: HomogenousSymmetricFunction(0, P.gens()) + sage: homogenous_symmetric_function(0, P.gens()) 1 - sage: HomogenousSymmetricFunction(1, P.gens()) + sage: homogenous_symmetric_function(1, P.gens()) X0 + X1 + X2 - sage: HomogenousSymmetricFunction(2, P.gens()) + sage: homogenous_symmetric_function(2, P.gens()) X0^2 + X0*X1 + X1^2 + X0*X2 + X1*X2 + X2^2 - sage: HomogenousSymmetricFunction(3, P.gens()) + sage: homogenous_symmetric_function(3, P.gens()) X0^3 + X0^2*X1 + X0*X1^2 + X1^3 + X0^2*X2 + X0*X1*X2 + X1^2*X2 + X0*X2^2 + X1*X2^2 + X2^3 """ From 0b6dba8ec268b6edebdbbd234aad9eab71165994 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:28:33 +0100 Subject: [PATCH 168/370] name Omega_numerator_P private --- src/sage/rings/polynomial/omega.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index db03e579c0b..6bce77bf5b7 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -557,7 +557,7 @@ def Omega_numerator(a, x, y, t): result = sum(homogenous_symmetric_function(j, xy) for j in srange(a+1)) else: - result = Omega_numerator_P(a, x_flat, y_flat, t).subs({t: x_flat[-1]}) + result = _Omega_numerator_P_(a, x_flat, y_flat, t).subs({t: x_flat[-1]}) L = t.parent() result = L(result) @@ -565,7 +565,7 @@ def Omega_numerator(a, x, y, t): return result -def Omega_numerator_P(a, x, y, t): +def _Omega_numerator_P_(a, x, y, t): r""" Helper function for :func:`Omega_numerator`. @@ -585,7 +585,7 @@ def Omega_numerator_P(a, x, y, t): TESTS:: - sage: from sage.rings.polynomial.omega import Omega_numerator_P + sage: from sage.rings.polynomial.omega import _Omega_numerator_P_ """ import logging logger = logging.getLogger(__name__) @@ -602,7 +602,7 @@ def Omega_numerator_P(a, x, y, t): for j in srange(a)) if a > 0 else 0) else: - Pprev = Omega_numerator_P(a, x[:n-1], y, t) + Pprev = _Omega_numerator_P_(a, x[:n-1], y, t) x2 = x[n-2] logger.debug('Omega_numerator: P(%s): substituting...', n) x1 = t From 907d12e6a52f5c0d3f8b22805300a27f1f447827 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:28:51 +0100 Subject: [PATCH 169/370] docstring and tests for _Omega_numerator_P_ --- src/sage/rings/polynomial/omega.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 6bce77bf5b7..eed6937fe15 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -573,9 +573,7 @@ def _Omega_numerator_P_(a, x, y, t): - ``a`` -- an integer. - - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The - flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the - `y_1,...,y_m`. + - ``x`` and ``y`` -- a tuple of laurent polynomials. - ``t`` -- a temporary laurent polynomial variable used for substituting. @@ -586,6 +584,9 @@ def _Omega_numerator_P_(a, x, y, t): TESTS:: sage: from sage.rings.polynomial.omega import _Omega_numerator_P_ + sage: L. = LaurentPolynomialRing(ZZ) + sage: _Omega_numerator_P_(0, (x0, x1), (y0,), t).subs({t: x1}) + -x0*x1*y0 + 1 """ import logging logger = logging.getLogger(__name__) From 91ee1d0cd76e1c4d2943ab450fd5e7fd4fdedd6e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:29:11 +0100 Subject: [PATCH 170/370] add "helper function" comment to some docstrings --- src/sage/rings/polynomial/omega.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index eed6937fe15..8bc1cd195cc 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -461,6 +461,8 @@ def Omega_numerator(a, x, y, t): and returns its numerator. + This function is meant to be a helper function of :func:`Omega`. + INPUT: - ``a`` -- an integer. @@ -636,6 +638,8 @@ def Omega_factors_denominator(x, y): and returns a factorization of its denominator. + This function is meant to be a helper function of :func:`Omega`. + INPUT: - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The From c97bac42c3e7eb61c06cdbd01cf504023bc88310 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:35:36 +0100 Subject: [PATCH 171/370] fix doc output --- src/sage/rings/polynomial/omega.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 8bc1cd195cc..bfc53879539 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -309,7 +309,7 @@ def Omega_ge(a, exponents): .. MATH:: \Omega_{\ge} \frac{\mu^a}{ - (1 - z_1 \mu^{e_1}) \dots (1 - z_n \mu^{e_n}) + (1 - z_1 \mu^{e_1}) \dots (1 - z_n \mu^{e_n})} and returns its numerator and a factorization of its denominator. @@ -457,7 +457,7 @@ def Omega_numerator(a, x, y, t): \Omega_{\ge} \frac{\mu^a}{ (1 - x_1 \mu) \dots (1 - x_n \mu) - (1 - y_1 / \mu) \dots (1 - y_m / \mu) + (1 - y_1 / \mu) \dots (1 - y_m / \mu)} and returns its numerator. @@ -634,7 +634,7 @@ def Omega_factors_denominator(x, y): \Omega_{\ge} \frac{1}{ (1 - x_1 \mu) \dots (1 - x_n \mu) - (1 - y_1 / \mu) \dots (1 - y_m / \mu) + (1 - y_1 / \mu) \dots (1 - y_m / \mu)} and returns a factorization of its denominator. @@ -723,7 +723,7 @@ def partition(items, predicate=bool): `http://nedbatchelder.com/blog/201306/filter_a_list_into_two_parts.html `_ - EXAMPLES: + EXAMPLES:: sage: from sage.rings.polynomial.omega import partition sage: E, O = partition(srange(10), is_odd) From b085ca6d6cd3fd353b112f1402a557d03b4b1a50 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:53:34 +0100 Subject: [PATCH 172/370] module description --- src/sage/rings/polynomial/omega.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index bfc53879539..f76f72d8e27 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -1,5 +1,10 @@ r""" MacMahon's Omega Operator + +This module implements :func:`MacMahon's Omega Operator ` +[MacMahon1915]_, which takes a quotient of laurent polynomials and +removes all negative exponents in the corresponding power series. + """ # ***************************************************************************** # Copyright (C) 2016 Daniel Krenn From 4b1c37e34c2c5fa6264fd489e56e9e20cec3237d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 10:53:40 +0100 Subject: [PATCH 173/370] references --- src/sage/rings/polynomial/omega.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index f76f72d8e27..b9dca676fb4 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -5,6 +5,15 @@ [MacMahon1915]_, which takes a quotient of laurent polynomials and removes all negative exponents in the corresponding power series. +REFERENCES: + +.. [MacMahon1915] Percy A. MacMahon, *Combinatory Analysis*, + Cambridge University Press (1915--1916). + (Reprinted: Chelsea, New York, 1960) + +.. [APR2001] George E. Andrews, Peter Paule, Axel Riese, + *MacMahon's partition analysis: the Omega package*, + European J. Combin. 22 (2001), no. 7, 887--904. """ # ***************************************************************************** # Copyright (C) 2016 Daniel Krenn @@ -69,6 +78,12 @@ def Omega(var, expression, denominator=None, op=operator.ge, The numerator of the result may not be factored. + REFERENCES: + + - [MacMahon1915]_ + + - [APR2001]_ + EXAMPLES:: sage: L. = LaurentPolynomialRing(ZZ) From 79fe3b36ea31ccc8a836a88e9d09c280942172bf Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Fri, 16 Dec 2016 11:03:40 +0100 Subject: [PATCH 174/370] extend docstring at top of file --- src/sage/rings/polynomial/omega.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index b9dca676fb4..ca3261f589c 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -5,7 +5,9 @@ [MacMahon1915]_, which takes a quotient of laurent polynomials and removes all negative exponents in the corresponding power series. -REFERENCES: + +References +========== .. [MacMahon1915] Percy A. MacMahon, *Combinatory Analysis*, Cambridge University Press (1915--1916). @@ -14,7 +16,24 @@ .. [APR2001] George E. Andrews, Peter Paule, Axel Riese, *MacMahon's partition analysis: the Omega package*, European J. Combin. 22 (2001), no. 7, 887--904. + + +Various +======= + +AUTHORS: + +- Daniel Krenn (2016) + +ACKNOWLEDGEMENT: + +- Daniel Krenn is supported by the Austrian Science Fund (FWF): P 24644-N26. + + +Functions +========= """ + # ***************************************************************************** # Copyright (C) 2016 Daniel Krenn # From 87bcaac045dbb3f2452845b7cc8e7e5363583769 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 20:40:02 +0100 Subject: [PATCH 175/370] Trac #22066.1: rename Omega --> MacMahonOmega --- src/sage/rings/polynomial/all.py | 2 +- src/sage/rings/polynomial/omega.py | 68 +++++++++++++++--------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/sage/rings/polynomial/all.py b/src/sage/rings/polynomial/all.py index 086b0e4ba10..46ea5d73b67 100644 --- a/src/sage/rings/polynomial/all.py +++ b/src/sage/rings/polynomial/all.py @@ -40,7 +40,7 @@ # Laurent Polynomial Rings from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing -lazy_import('sage.rings.polynomial.omega', 'Omega') +lazy_import('sage.rings.polynomial.omega', 'MacMahonOmega') # Infinite Polynomial Rings from sage.rings.polynomial.infinite_polynomial_ring import InfinitePolynomialRing diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index ca3261f589c..cfed04aba56 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -52,7 +52,7 @@ from sage.misc.cachefunc import cached_function -def Omega(var, expression, denominator=None, op=operator.ge, +def MacMahonOmega(var, expression, denominator=None, op=operator.ge, Factorization_sort=False, Factorization_simplify=True): r""" Return `\Omega_{\mathrm{op}}` of ``expression`` with respect to ``var``. @@ -107,91 +107,91 @@ def Omega(var, expression, denominator=None, op=operator.ge, sage: L. = LaurentPolynomialRing(ZZ) - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - y/mu]) 1 * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu, 1 - z/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - y/mu, 1 - z/mu]) 1 * (-x + 1)^-1 * (-x*y + 1)^-1 * (-x*z + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu]) (-x*y*z + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-x*z + 1)^-1 * (-y*z + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^2]) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - y/mu^2]) 1 * (-x + 1)^-1 * (-x^2*y + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu^2, 1 - y/mu]) (x*y + 1) * (-x + 1)^-1 * (-x*y^2 + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu^2]) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu^2]) (-x^2*y*z - x*y^2*z + x*y*z + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-x^2*z + 1)^-1 * (-y^2*z + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^3]) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - y/mu^3]) 1 * (-x + 1)^-1 * (-x^3*y + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y/mu^4]) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - y/mu^4]) 1 * (-x + 1)^-1 * (-x^4*y + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu^3, 1 - y/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu^3, 1 - y/mu]) (x*y^2 + x*y + 1) * (-x + 1)^-1 * (-x*y^3 + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu^4, 1 - y/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu^4, 1 - y/mu]) (x*y^3 + x*y^2 + x*y + 1) * (-x + 1)^-1 * (-x*y^4 + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu^2, 1 - y/mu, 1 - z/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu^2, 1 - y/mu, 1 - z/mu]) (x*y*z + x*y + x*z + 1) * (-x + 1)^-1 * (-x*y^2 + 1)^-1 * (-x*z^2 + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu^2, 1 - y*mu, 1 - z/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu^2, 1 - y*mu, 1 - z/mu]) (-x*y*z^2 - x*y*z + x*z + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-x*z^2 + 1)^-1 * (-y*z + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z*mu, 1 - w/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z*mu, 1 - w/mu]) (x*y*z*w^2 + x*y*z*w - x*y*w - x*z*w - y*z*w + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-z + 1)^-1 * (-x*w + 1)^-1 * (-y*w + 1)^-1 * (-z*w + 1)^-1 - sage: Omega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu, 1 - w/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - y*mu, 1 - z/mu, 1 - w/mu]) (x^2*y*z*w + x*y^2*z*w - x*y*z*w - x*y*z - x*y*w + 1) * (-x + 1)^-1 * (-y + 1)^-1 * (-x*z + 1)^-1 * (-x*w + 1)^-1 * (-y*z + 1)^-1 * (-y*w + 1)^-1 - sage: Omega(mu, mu^-2, [1 - x*mu, 1 - y/mu]) + sage: MacMahonOmega(mu, mu^-2, [1 - x*mu, 1 - y/mu]) x^2 * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, mu^-1, [1 - x*mu, 1 - y/mu]) + sage: MacMahonOmega(mu, mu^-1, [1 - x*mu, 1 - y/mu]) x * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, mu, [1 - x*mu, 1 - y/mu]) + sage: MacMahonOmega(mu, mu, [1 - x*mu, 1 - y/mu]) (-x*y + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: Omega(mu, mu^2, [1 - x*mu, 1 - y/mu]) + sage: MacMahonOmega(mu, mu^2, [1 - x*mu, 1 - y/mu]) (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 TESTS:: - sage: Omega(mu, 1, [1 - x*mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu]) 1 * (-x + 1)^-1 - sage: Omega(mu, 1, [1 - x/mu]) + sage: MacMahonOmega(mu, 1, [1 - x/mu]) 1 - sage: Omega(mu, 0, [1 - x*mu]) + sage: MacMahonOmega(mu, 0, [1 - x*mu]) 0 - sage: Omega(mu, L(1), []) + sage: MacMahonOmega(mu, L(1), []) 1 - sage: Omega(mu, L(0), []) + sage: MacMahonOmega(mu, L(0), []) 0 - sage: Omega(mu, 2, []) + sage: MacMahonOmega(mu, 2, []) 2 - sage: Omega(mu, 2*mu, []) + sage: MacMahonOmega(mu, 2*mu, []) 2 - sage: Omega(mu, 2/mu, []) + sage: MacMahonOmega(mu, 2/mu, []) 0 :: - sage: Omega(mu, Factorization([(1/mu, 1), (1 - x*mu, -1), - ....: (1 - y/mu, -2)], unit=2)) + sage: MacMahonOmega(mu, Factorization([(1/mu, 1), (1 - x*mu, -1), + ....: (1 - y/mu, -2)], unit=2)) 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 - sage: Omega(mu, Factorization([(mu, -1), (1 - x*mu, -1), - ....: (1 - y/mu, -2)], unit=2)) + sage: MacMahonOmega(mu, Factorization([(mu, -1), (1 - x*mu, -1), + ....: (1 - y/mu, -2)], unit=2)) 2*x * (-x + 1)^-1 * (-x*y + 1)^-2 - sage: Omega(mu, Factorization([(mu, -1), (1 - x, -1)])) + sage: MacMahonOmega(mu, Factorization([(mu, -1), (1 - x, -1)])) 0 - sage: Omega(mu, Factorization([(2, -1)])) + sage: MacMahonOmega(mu, Factorization([(2, -1)])) 1 * 2^-1 :: - sage: Omega(mu, 1, [1 - x*mu, 1 - z, 1 - y/mu]) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - z, 1 - y/mu]) 1 * (-z + 1)^-1 * (-x + 1)^-1 * (-x*y + 1)^-1 """ from sage.arith.misc import factor From 300bd2c03a4f5bfe9cd604776baaef340296451c Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 20:41:42 +0100 Subject: [PATCH 176/370] Trac #22066.3: capitalize "Laurent polynomial" --- src/sage/rings/polynomial/omega.py | 42 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index cfed04aba56..0a57535ebaa 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -2,7 +2,7 @@ MacMahon's Omega Operator This module implements :func:`MacMahon's Omega Operator ` -[MacMahon1915]_, which takes a quotient of laurent polynomials and +[MacMahon1915]_, which takes a quotient of Laurent polynomials and removes all negative exponents in the corresponding power series. @@ -64,7 +64,7 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, \Omega_{\mathrm{op}} \frac{n}{d_1 \dots d_n} for the numerator `n` and the factors `d_1`, ..., `d_n` of - the denominator, all of which are laurent polynomials in ``var`` + the denominator, all of which are Laurent polynomials in ``var`` and returns a (partial) factorization of the result. INPUT: @@ -72,13 +72,13 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, - ``var`` -- a variable or a representation string of a variable. - ``expression`` -- an element of the quotient field of some - laurent polynomials. If ``denominator`` is specified, then - this laurent polynomial is interpreted as the numerator of the + Laurent polynomials. If ``denominator`` is specified, then + this Laurent polynomial is interpreted as the numerator of the expression. - - ``denominator`` -- a laurent polynomial or a + - ``denominator`` -- a Laurent polynomial or a :class:`~sage.structure.factorization.Factorization` (consisting - of laurent polynomial factors) or a tuple/list of factors (laurent + of Laurent polynomial factors) or a tuple/list of factors (Laurent polynomials). - ``op`` -- (default: ``operator.ge``) an operator. @@ -91,7 +91,7 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, OUTPUT: A (partial) :class:`~sage.structure.factorization.Factorization` - of the result whose factors are laurent polynomials. + of the result whose factors are Laurent polynomials. .. NOTE:: @@ -296,9 +296,9 @@ def _Omega_(A, decoded_factors): OUTPUT: A pair representing a quotient as follows: Its first component is the - numerator as a laurent polynomial, its second component a factorization - of the denominator as a tuple of laurent polynomials, where each - laurent polynomial `z` represents a factor `1 - z`. + numerator as a Laurent polynomial, its second component a factorization + of the denominator as a tuple of Laurent polynomials, where each + Laurent polynomial `z` represents a factor `1 - z`. TESTS: @@ -361,9 +361,9 @@ def Omega_ge(a, exponents): OUTPUT: A pair representing a quotient as follows: Its first component is the - numerator as a laurent polynomial, its second component a factorization - of the denominator as a tuple of laurent polynomials, where each - laurent polynomial `z` represents a factor `1 - z`. + numerator as a Laurent polynomial, its second component a factorization + of the denominator as a tuple of Laurent polynomials, where each + Laurent polynomial `z` represents a factor `1 - z`. EXAMPLES:: @@ -506,15 +506,15 @@ def Omega_numerator(a, x, y, t): - ``a`` -- an integer. - - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The + - ``x`` and ``y`` -- a tuple of tuples of Laurent polynomials. The flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the `y_1,...,y_m`. - - ``t`` -- a temporary laurent polynomial variable used for substituting. + - ``t`` -- a temporary Laurent polynomial variable used for substituting. OUTPUT: - A laurent polynomial. + A Laurent polynomial. EXAMPLES:: @@ -614,13 +614,13 @@ def _Omega_numerator_P_(a, x, y, t): - ``a`` -- an integer. - - ``x`` and ``y`` -- a tuple of laurent polynomials. + - ``x`` and ``y`` -- a tuple of Laurent polynomials. - - ``t`` -- a temporary laurent polynomial variable used for substituting. + - ``t`` -- a temporary Laurent polynomial variable used for substituting. OUTPUT: - A laurent polynomial. + A Laurent polynomial. TESTS:: @@ -681,14 +681,14 @@ def Omega_factors_denominator(x, y): INPUT: - - ``x`` and ``y`` -- a tuple of tuples of laurent polynomials. The + - ``x`` and ``y`` -- a tuple of tuples of Laurent polynomials. The flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the `y_1,...,y_m`. OUTPUT: A factorization of the denominator as - a tuple of laurent polynomials. + a tuple of Laurent polynomials. EXAMPLES:: From b807be1c9564c023a31de5b1ef47094ee6df260f Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 20:47:40 +0100 Subject: [PATCH 177/370] Trac #22066.5: use command form in long description of docstring --- src/sage/rings/polynomial/omega.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 0a57535ebaa..0fd4fce4fcb 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -57,7 +57,7 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, r""" Return `\Omega_{\mathrm{op}}` of ``expression`` with respect to ``var``. - To be more precise, this calculates + To be more precise, calculate .. MATH:: @@ -65,7 +65,7 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, for the numerator `n` and the factors `d_1`, ..., `d_n` of the denominator, all of which are Laurent polynomials in ``var`` - and returns a (partial) factorization of the result. + and return a (partial) factorization of the result. INPUT: @@ -343,14 +343,14 @@ def Omega_ge(a, exponents): r""" Return `\Omega_{\ge}` of the expression specified by the input. - To be more precise, this calculates + To be more precise, calculate .. MATH:: \Omega_{\ge} \frac{\mu^a}{ (1 - z_1 \mu^{e_1}) \dots (1 - z_n \mu^{e_n})} - and returns its numerator and a factorization of its denominator. + and return its numerator and a factorization of its denominator. INPUT: @@ -490,7 +490,7 @@ def Omega_numerator(a, x, y, t): Return the numerator of `\Omega_{\ge}` of the expression specified by the input. - To be more precise, this calculates + To be more precise, calculate .. MATH:: @@ -498,7 +498,7 @@ def Omega_numerator(a, x, y, t): (1 - x_1 \mu) \dots (1 - x_n \mu) (1 - y_1 / \mu) \dots (1 - y_m / \mu)} - and returns its numerator. + and return its numerator. This function is meant to be a helper function of :func:`Omega`. @@ -667,7 +667,7 @@ def Omega_factors_denominator(x, y): Return the denominator of `\Omega_{\ge}` of the expression specified by the input. - To be more precise, this calculates + To be more precise, calculate .. MATH:: @@ -675,7 +675,7 @@ def Omega_factors_denominator(x, y): (1 - x_1 \mu) \dots (1 - x_n \mu) (1 - y_1 / \mu) \dots (1 - y_m / \mu)} - and returns a factorization of its denominator. + and return a factorization of its denominator. This function is meant to be a helper function of :func:`Omega`. From fd49ddb067f9fcc47ba3da2ba9acdbe5b85b6f17 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 20:57:17 +0100 Subject: [PATCH 178/370] Trac #22066.8: rewrite imports of sage.rings.polynomial.laurent_polynomial_ring --- src/sage/rings/polynomial/omega.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 0fd4fce4fcb..2426dbf5d8a 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -197,8 +197,8 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, from sage.arith.misc import factor from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing_univariate + from sage.rings.polynomial.laurent_polynomial_ring \ + import LaurentPolynomialRing, LaurentPolynomialRing_univariate from sage.structure.factorization import Factorization if op != operator.ge: From c32bef0aebaeca2feaace22c1aabb882110b34d3 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 21:04:16 +0100 Subject: [PATCH 179/370] Trac #22066.9: document and test not implemented other operators than ge --- src/sage/rings/polynomial/omega.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 2426dbf5d8a..0ff0d962fb6 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -81,7 +81,9 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, of Laurent polynomial factors) or a tuple/list of factors (Laurent polynomials). - - ``op`` -- (default: ``operator.ge``) an operator. + - ``op`` -- (default: ``operator.ge``) an operator + + At the moment only ``operator.ge`` is implemented. - ``Factorization_sort`` (default: ``False``) and ``Factorization_simplify`` (default: ``True``) -- are passed on to @@ -193,6 +195,13 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - z, 1 - y/mu]) 1 * (-z + 1)^-1 * (-x + 1)^-1 * (-x*y + 1)^-1 + + :: + + sage: MacMahonOmega(mu, 1, [1 - x*mu], op=operator.lt) + Traceback (most recent call last): + ... + NotImplementedError: At the moment, only Omega_ge is implemented. """ from sage.arith.misc import factor from sage.misc.misc_c import prod From 286c9ae9a6f1b8043d8d6e086fb87c9be910b78e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 21:11:36 +0100 Subject: [PATCH 180/370] Trac #22066.10: test non-integral-Factorization input --- src/sage/rings/polynomial/omega.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 0ff0d962fb6..ced3f32647c 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -202,6 +202,12 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, Traceback (most recent call last): ... NotImplementedError: At the moment, only Omega_ge is implemented. + + sage: MacMahonOmega(mu, 1, Factorization([(1 - x*mu, -1)])) + Traceback (most recent call last): + ... + ValueError: Factorization (-mu*x + 1)^-1 of the denominator + contains negative exponents. """ from sage.arith.misc import factor from sage.misc.misc_c import prod From 21d9df0d79d097c5a5dd5cbbc9eb35a171ef12b5 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 21:15:05 +0100 Subject: [PATCH 181/370] Trac #22066.12: test non-variable input --- src/sage/rings/polynomial/omega.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index ced3f32647c..73337aa6501 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -208,6 +208,11 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, ... ValueError: Factorization (-mu*x + 1)^-1 of the denominator contains negative exponents. + + sage: MacMahonOmega(2*mu, 1, [1 - x*mu]) + Traceback (most recent call last): + ... + ValueError: 2*mu is not a variable. """ from sage.arith.misc import factor from sage.misc.misc_c import prod From bf230287e1ad772f84d89f60ed9de76b5abe072c Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 21:16:50 +0100 Subject: [PATCH 182/370] Trac #22066.13: test 0 in denominator --- src/sage/rings/polynomial/omega.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 73337aa6501..0c65a425851 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -213,6 +213,11 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, Traceback (most recent call last): ... ValueError: 2*mu is not a variable. + + sage: MacMahonOmega(mu, 1, Factorization([(0, 2)])) + Traceback (most recent call last): + ... + ZeroDivisionError: Denominator contains a factor 0. """ from sage.arith.misc import factor from sage.misc.misc_c import prod From d9514a4c1de022d0311b71cb07483986625f5a25 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 21:18:56 +0100 Subject: [PATCH 183/370] Trac #22066.14: test non-normalized input --- src/sage/rings/polynomial/omega.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 0c65a425851..d324ea0ec23 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -218,6 +218,11 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, Traceback (most recent call last): ... ZeroDivisionError: Denominator contains a factor 0. + + sage: MacMahonOmega(mu, 1, [2 - x*mu]) + Traceback (most recent call last): + ... + NotImplementedError: Factor 2 - x*mu is not normalized. """ from sage.arith.misc import factor from sage.misc.misc_c import prod From 10900a901758aab03fa6735bf3abc86ea5d88c1d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 21:19:20 +0100 Subject: [PATCH 184/370] Trac #22066.15: test non-binom input --- src/sage/rings/polynomial/omega.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index d324ea0ec23..a2a1215619f 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -223,6 +223,11 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, Traceback (most recent call last): ... NotImplementedError: Factor 2 - x*mu is not normalized. + + sage: MacMahonOmega(mu, 1, [1 - x*mu - mu^2]) + Traceback (most recent call last): + ... + NotImplementedError: Cannot handle factor 1 - x*mu - mu^2. """ from sage.arith.misc import factor from sage.misc.misc_c import prod From c0bf0b523d830454c89a0ac34f8c5306aa4fbe2c Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 21:41:40 +0100 Subject: [PATCH 185/370] Trac #22066.16: add non-trivial doctest in _Omega_ --- src/sage/rings/polynomial/omega.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index a2a1215619f..668e0bcec4a 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -339,9 +339,21 @@ def _Omega_(A, decoded_factors): Extensive testing of this function is done in :func:`Omega`. + :: + + sage: L. = LaurentPolynomialRing(ZZ) + sage: MacMahonOmega(mu, mu^-2, [1 - x*mu, 1 - y/mu]) + x^2 * (-x + 1)^-1 * (-x*y + 1)^-1 + + internally calls :: sage: from sage.rings.polynomial.omega import _Omega_ + sage: _Omega_({-2: 1}, [(x, 1), (y, -1)]) + (x^2, (x, x*y)) + + :: + sage: _Omega_({0: 2, 1: 40, -1: -3}, []) (42, ()) sage: _Omega_({-1: 42}, []) From e60311a696e75834f9b088945fabb63be66948d9 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 21:44:36 +0100 Subject: [PATCH 186/370] Trac #22066.17: document z_i in Omega_ge --- src/sage/rings/polynomial/omega.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 668e0bcec4a..216ee9b6797 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -398,6 +398,8 @@ def Omega_ge(a, exponents): (1 - z_1 \mu^{e_1}) \dots (1 - z_n \mu^{e_n})} and return its numerator and a factorization of its denominator. + Note that `z_1`, ..., `z_n` only appear in the output, but not in the + input. INPUT: From 80125f88e1ddc537a86685b3499969b27282a716 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 21:54:53 +0100 Subject: [PATCH 187/370] Trac #22066.18: state parent of output in Omega_ge --- src/sage/rings/polynomial/omega.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 216ee9b6797..8a4f91ccd3e 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -395,10 +395,10 @@ def Omega_ge(a, exponents): .. MATH:: \Omega_{\ge} \frac{\mu^a}{ - (1 - z_1 \mu^{e_1}) \dots (1 - z_n \mu^{e_n})} + (1 - z_0 \mu^{e_0}) \dots (1 - z_{n-1} \mu^{e_{n-1}})} and return its numerator and a factorization of its denominator. - Note that `z_1`, ..., `z_n` only appear in the output, but not in the + Note that `z_0`, ..., `z_{n-1}` only appear in the output, but not in the input. INPUT: @@ -414,6 +414,10 @@ def Omega_ge(a, exponents): of the denominator as a tuple of Laurent polynomials, where each Laurent polynomial `z` represents a factor `1 - z`. + The parents of these Laurent polynomials is always a + Laurent polynomial ring in `z_0`, ..., `z_{n-1}` over `\ZZ`, where + `n` is the length of ``exponents``. + EXAMPLES:: sage: from sage.rings.polynomial.omega import Omega_ge From 2a0f48e1f125fd61ab619ef14ec9caa0fecb454c Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 21:58:34 +0100 Subject: [PATCH 188/370] Trac #22066.19: use CyclotomicField instead of QQ.extension(...) --- src/sage/rings/polynomial/omega.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 8a4f91ccd3e..6e336a4d67f 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -477,18 +477,17 @@ def Omega_ge(a, exponents): from sage.arith.misc import lcm from sage.arith.srange import srange - from sage.misc.functional import cyclotomic_polynomial from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing - from sage.rings.rational_field import QQ + from sage.rings.number_field.number_field import CyclotomicField if not exponents or any(e == 0 for e in exponents): raise NotImplementedError rou = sorted(set(abs(e) for e in exponents) - set([1])) ellcm = lcm(rou) - B = QQ.extension(cyclotomic_polynomial(ellcm), 'zeta') + B = CyclotomicField(ellcm, 'zeta') zeta = B.gen() z_names = tuple('z{}'.format(i) for i in range(len(exponents))) L = LaurentPolynomialRing(B, ('t',) + z_names, len(z_names) + 1) From 8f6ec421104deddb3180dd2e41f6e376e2dfe851 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 22:02:13 +0100 Subject: [PATCH 189/370] Trac #22066.21: remove parameter value of subs_power as not needed --- src/sage/rings/polynomial/omega.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 6e336a4d67f..babecdea85a 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -502,9 +502,9 @@ def Omega_ge(a, exponents): x = tuple(v for e, v in exponents_and_values if e > 0) y = tuple(v for e, v in exponents_and_values if e < 0) - def subs_power(expression, var, exponent, value=None): + def subs_power(expression, var, exponent): r""" - Substitute ``var^exponent`` by ``value`` in ``expression``. + Substitute ``var^exponent`` by ``var`` in ``expression``. """ p = tuple(var.dict().popitem()[0]).index(1) def subs_e(e): @@ -514,9 +514,7 @@ def subs_e(e): return tuple(e) parent = expression.parent() result = parent({subs_e(e): c for e, c in iteritems(expression.dict())}) - if value is None: - return result - return result.subs({var: value}) + return result def de_power(expression): expression = Z(expression) From d874fd3b24b1f720fc2e55bdbe693b597f1a2d13 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 22:04:21 +0100 Subject: [PATCH 190/370] Trac #22066.22: comment hard to read line --- src/sage/rings/polynomial/omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index babecdea85a..d5439f74a7a 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -506,7 +506,7 @@ def subs_power(expression, var, exponent): r""" Substitute ``var^exponent`` by ``var`` in ``expression``. """ - p = tuple(var.dict().popitem()[0]).index(1) + p = tuple(var.dict().popitem()[0]).index(1) # var is the p-th generator def subs_e(e): e = list(e) assert e[p] % exponent == 0 From 001dccfeb5555fece330e0e0d2681b5208c21bf3 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 22:06:07 +0100 Subject: [PATCH 191/370] Trac #22066.23: make a note in docstring on assumptions in subs_power --- src/sage/rings/polynomial/omega.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index d5439f74a7a..35f1bebd1ac 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -505,6 +505,9 @@ def Omega_ge(a, exponents): def subs_power(expression, var, exponent): r""" Substitute ``var^exponent`` by ``var`` in ``expression``. + + It is assumed that ``var`` only occurs with exponents + divisible by ``exponent``. """ p = tuple(var.dict().popitem()[0]).index(1) # var is the p-th generator def subs_e(e): From 8ede01a667f9da18e43669e5e368323eaeeb0ff4 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Tue, 3 Jan 2017 22:09:03 +0100 Subject: [PATCH 192/370] Trac #22066.24: note in Omega_numerator on normalization --- src/sage/rings/polynomial/omega.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 35f1bebd1ac..1cbfb121786 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -569,6 +569,9 @@ def Omega_numerator(a, x, y, t): A Laurent polynomial. + The output is normalized such that the corresponding denominator + (:func:`Omega_factors_denominator`) has constant term `1`. + EXAMPLES:: sage: from sage.rings.polynomial.omega import Omega_numerator, Omega_factors_denominator From 4e19aa9d69ec55655e96268b22c0660a41031d40 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 17:51:45 +0100 Subject: [PATCH 193/370] Trac #22066.25: explain non-flat input in Omega_numerator --- src/sage/rings/polynomial/omega.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 1cbfb121786..226d516fe9e 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -559,9 +559,13 @@ def Omega_numerator(a, x, y, t): - ``a`` -- an integer. - - ``x`` and ``y`` -- a tuple of tuples of Laurent polynomials. The + - ``x`` and ``y`` -- a tuple of tuples of Laurent polynomials + + The flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the `y_1,...,y_m`. + The non-flatness of these parameters is to be interface-consistent + with :func:`Omega_factors_denominator`. - ``t`` -- a temporary Laurent polynomial variable used for substituting. From 20809918a955f4016ce1d6bd1c8add212b298535 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:02:46 +0100 Subject: [PATCH 194/370] Trac #22066.26: comment on caching of _Omega_Numerator_P_ --- src/sage/rings/polynomial/omega.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 226d516fe9e..60bdfa4a9cd 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -689,6 +689,15 @@ def _Omega_numerator_P_(a, x, y, t): sage: _Omega_numerator_P_(0, (x0, x1), (y0,), t).subs({t: x1}) -x0*x1*y0 + 1 """ + # This function takes Laurent polynomials as inputs. It would + # be possible to input only the sizes of ``x`` and ``y`` and + # perform a substitution afterwards; in this way caching of this + # function would make sense. However, the way it is now allows + # automatic collection and simplification of the summands, which + # makes it more efficient for higher powers at the input of + # :func:`Omega_ge`. + # Caching occurs in :func:`Omega_ge`. + import logging logger = logging.getLogger(__name__) From 70341542448e9aa5cdff7d856f58802069135ad6 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:13:35 +0100 Subject: [PATCH 195/370] Trac #22066.28: remove last component of x in _Omega_Numerator_P_ --- src/sage/rings/polynomial/omega.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 60bdfa4a9cd..9fcd17c5b70 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -658,7 +658,7 @@ def Omega_numerator(a, x, y, t): result = sum(homogenous_symmetric_function(j, xy) for j in srange(a+1)) else: - result = _Omega_numerator_P_(a, x_flat, y_flat, t).subs({t: x_flat[-1]}) + result = _Omega_numerator_P_(a, x_flat[:-1], y_flat, t).subs({t: x_flat[-1]}) L = t.parent() result = L(result) @@ -674,9 +674,15 @@ def _Omega_numerator_P_(a, x, y, t): - ``a`` -- an integer. - - ``x`` and ``y`` -- a tuple of Laurent polynomials. + - ``x`` and ``y`` -- a tuple of Laurent polynomials - - ``t`` -- a temporary Laurent polynomial variable used for substituting. + The tuple ``x`` here is the flattened ``x`` of :func:`Omega_numerator` + but without its last entry. + + - ``t`` -- a temporary Laurent polynomial variable + + In the (final) result, ``t`` has to be substituted by the last + entry of the flattened ``x`` of :func:`Omega_numerator`. OUTPUT: @@ -686,7 +692,7 @@ def _Omega_numerator_P_(a, x, y, t): sage: from sage.rings.polynomial.omega import _Omega_numerator_P_ sage: L. = LaurentPolynomialRing(ZZ) - sage: _Omega_numerator_P_(0, (x0, x1), (y0,), t).subs({t: x1}) + sage: _Omega_numerator_P_(0, (x0,), (y0,), t).subs({t: x1}) -x0*x1*y0 + 1 """ # This function takes Laurent polynomials as inputs. It would @@ -705,7 +711,7 @@ def _Omega_numerator_P_(a, x, y, t): from sage.misc.misc_c import prod n = len(x) - if n == 1: + if n == 0: x0 = t result = x0**(-a) + \ (prod(1 - x0*yy for yy in y) * @@ -714,7 +720,7 @@ def _Omega_numerator_P_(a, x, y, t): if a > 0 else 0) else: Pprev = _Omega_numerator_P_(a, x[:n-1], y, t) - x2 = x[n-2] + x2 = x[n-1] logger.debug('Omega_numerator: P(%s): substituting...', n) x1 = t p1 = Pprev From 7f41896038f4551b9f0e09199cc79405517a8365 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:15:10 +0100 Subject: [PATCH 196/370] Trac #22066.27: reference P of [APR2001] --- src/sage/rings/polynomial/omega.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 9fcd17c5b70..db35b2fa30f 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -670,6 +670,8 @@ def _Omega_numerator_P_(a, x, y, t): r""" Helper function for :func:`Omega_numerator`. + This is an implementation of the function `P` of [APR2001]_. + INPUT: - ``a`` -- an integer. From 033186711c9e7555909b2faf367ba473f94944f2 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:16:26 +0100 Subject: [PATCH 197/370] Trac #22066.29: document normalized output of denominator --- src/sage/rings/polynomial/omega.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index db35b2fa30f..10f22d6f62f 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -767,6 +767,8 @@ def Omega_factors_denominator(x, y): A factorization of the denominator as a tuple of Laurent polynomials. + The output is normalized such that it has constant term `1`. + EXAMPLES:: sage: from sage.rings.polynomial.omega import Omega_factors_denominator From da4c210e80f2b6f165e14805fe5bf5a770ddca7e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:18:55 +0100 Subject: [PATCH 198/370] Trac #22066.30: write down implicit assumptions on x and y in _Omega_Numerator_P_ --- src/sage/rings/polynomial/omega.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 10f22d6f62f..896ef7410a7 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -769,6 +769,13 @@ def Omega_factors_denominator(x, y): The output is normalized such that it has constant term `1`. + .. NOTE:: + + The implicit assumption is that the ``x`` and ``y`` are collected in + such a way that one entry of ``x`` corresponds to the orbit of + some ``x_j`` under multiplication by `d`th roots of unity and that + the output is collected in a corresponding way. + EXAMPLES:: sage: from sage.rings.polynomial.omega import Omega_factors_denominator From 61a7ad8e59c5b3bd13222eefd731d9f5cdceed1d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:19:55 +0100 Subject: [PATCH 199/370] Trac #22066.31: use ALGORITHM-block --- src/sage/rings/polynomial/omega.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 896ef7410a7..f2fc9e70166 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -844,6 +844,8 @@ def partition(items, predicate=bool): A pair of iterators; the first contains the elements not satisfying the ``predicate``, the second the elements satisfying the ``predicate``. + ALGORITHM: + Source of the code: `http://nedbatchelder.com/blog/201306/filter_a_list_into_two_parts.html `_ From 09fe59f352ff67e1ce8f38a750e5520805df6ff7 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:21:47 +0100 Subject: [PATCH 200/370] Trac #22066.32: provide link to definition of c.h.s. polynomials --- src/sage/rings/polynomial/omega.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index f2fc9e70166..f35cb94c1e4 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -865,7 +865,8 @@ def partition(items, predicate=bool): def homogenous_symmetric_function(j, x): r""" - Return a complete homogeneous symmetric polynomial. + Return a complete homogeneous symmetric polynomial + (:wikipedia:`Complete_homogeneous_symmetric_polynomial`). INPUT: From 278014d7c13fd84a99729bee307083c28a9e1697 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:24:10 +0100 Subject: [PATCH 201/370] Trac #22066.33: specify output-type more clearly --- src/sage/rings/polynomial/omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index f35cb94c1e4..a8726d4451a 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -876,7 +876,7 @@ def homogenous_symmetric_function(j, x): OUTPUT: - A polynomial whose type is determined by the input ``x``. + A polynomial of the common parent of all entries of ``x``. EXAMPLES:: From 6da446e5aa007066e183f61dc0ef7f9a5b06c36f Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:28:47 +0100 Subject: [PATCH 202/370] Trac #22066.6: document Factorization-input --- src/sage/rings/polynomial/omega.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index a8726d4451a..1e5db664648 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -72,7 +72,11 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, - ``var`` -- a variable or a representation string of a variable. - ``expression`` -- an element of the quotient field of some - Laurent polynomials. If ``denominator`` is specified, then + Laurent polynomials or a + :class:`~sage.structure.factorization.Factorization` + of Laurent polynomials + + If ``denominator`` is specified, then this Laurent polynomial is interpreted as the numerator of the expression. From f55b39f8fdd0dea1f2284b13cbcb8890c8c4f7ac Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:39:35 +0100 Subject: [PATCH 203/370] Trac #22066.7: test all input variants --- src/sage/rings/polynomial/omega.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 1e5db664648..97588366028 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -163,6 +163,29 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, sage: MacMahonOmega(mu, mu^2, [1 - x*mu, 1 - y/mu]) (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 + We demonstrate the different allowed input variants:: + + sage: MacMahonOmega(mu, + ....: Factorization([(mu, 2), (1 - x*mu, -1), (1 - y/mu, -1)])) + (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 + + sage: MacMahonOmega(mu, mu^2, + ....: Factorization([(1 - x*mu, 1), (1 - y/mu, 1)])) + (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 + + sage: MacMahonOmega(mu, mu^2, [1 - x*mu, 1 - y/mu]) + (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 + + sage: MacMahonOmega(mu, mu^2, (1 - x*mu)*(1 - y/mu)) + Traceback (most recent call last): + ... + TypeError: unable to factor n + + sage: MacMahonOmega(mu, mu^2 / ((1 - x*mu)*(1 - y/mu))) + Traceback (most recent call last): + ... + NotImplementedError: Factor y - mu is not normalized. + TESTS:: sage: MacMahonOmega(mu, 1, [1 - x*mu]) From 0408bce6c72df493b369548e2f478698107db8d8 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 18:47:01 +0100 Subject: [PATCH 204/370] Trac #22066.11: correct handling of unit of denominator --- src/sage/rings/polynomial/omega.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 97588366028..208f832cf74 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -255,6 +255,13 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, Traceback (most recent call last): ... NotImplementedError: Cannot handle factor 1 - x*mu - mu^2. + + :: + + sage: L. = LaurentPolynomialRing(QQ) + sage: MacMahonOmega(mu, 1/mu, + ....: Factorization([(1 - x*mu, 1), (1 - y/mu, 2)], unit=2)) + 1/2*x * (-x + 1)^-1 * (-x*y + 1)^-2 """ from sage.arith.misc import factor from sage.misc.misc_c import prod @@ -287,7 +294,7 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, if not denominator.is_integral(): raise ValueError('Factorization {} of the denominator ' 'contains negative exponents.'.format(denominator)) - numerator *= denominator.unit() + numerator *= ZZ(1) / denominator.unit() factors_denominator = tuple(factor for factor, exponent in denominator for _ in range(exponent)) From 97f51f7b37665eb99b7e49252a735ebb785fb337 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 19:00:15 +0100 Subject: [PATCH 205/370] Trac 22066.30: ReST-fixup --- src/sage/rings/polynomial/omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 208f832cf74..e79d3294031 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -807,7 +807,7 @@ def Omega_factors_denominator(x, y): The implicit assumption is that the ``x`` and ``y`` are collected in such a way that one entry of ``x`` corresponds to the orbit of - some ``x_j`` under multiplication by `d`th roots of unity and that + some ``x_j`` under multiplication by `d`-th roots of unity and that the output is collected in a corresponding way. EXAMPLES:: From 13f2fdd726fe6e9719edcb6628e9485f62c0a2a5 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Wed, 4 Jan 2017 19:04:09 +0100 Subject: [PATCH 206/370] Trac #22066.4: put biblography in references file --- src/doc/en/reference/references/index.rst | 8 ++++++++ src/sage/rings/polynomial/omega.py | 16 ++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index b81043df27b..d1f9e61049f 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -76,6 +76,10 @@ REFERENCES: .. [Ap1997] \T. Apostol, Modular functions and Dirichlet series in number theory, Springer, 1997 (2nd ed), section 3.7--3.9. +.. [APR2001] George E. Andrews, Peter Paule, Axel Riese, + *MacMahon's partition analysis: the Omega package*, + European J. Combin. 22 (2001), no. 7, 887--904. + .. [Ar2006] D. Armstrong. *Generalized noncrossing partitions and combinatorics of Coxeter groups*. Mem. Amer. Math. Soc., 2006. @@ -1066,6 +1070,10 @@ REFERENCES: Atoms, Journal of Algebraic Combinatorics, Vol. 29, (2009), No. 3, p.295-313. :arXiv:`0707.4267` +.. [Mac1915] Percy A. MacMahon, *Combinatory Analysis*, + Cambridge University Press (1915--1916). + (Reprinted: Chelsea, New York, 1960) + .. [MAR2009] \H. Molina-Abril and P. Réal, *Homology computation using spanning trees* in Progress in Pattern Recognition, Image Analysis, Computer Vision, and Applications, Lecture diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index e79d3294031..f02944195ca 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -2,22 +2,10 @@ MacMahon's Omega Operator This module implements :func:`MacMahon's Omega Operator ` -[MacMahon1915]_, which takes a quotient of Laurent polynomials and +[Mac1915]_, which takes a quotient of Laurent polynomials and removes all negative exponents in the corresponding power series. -References -========== - -.. [MacMahon1915] Percy A. MacMahon, *Combinatory Analysis*, - Cambridge University Press (1915--1916). - (Reprinted: Chelsea, New York, 1960) - -.. [APR2001] George E. Andrews, Peter Paule, Axel Riese, - *MacMahon's partition analysis: the Omega package*, - European J. Combin. 22 (2001), no. 7, 887--904. - - Various ======= @@ -105,7 +93,7 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, REFERENCES: - - [MacMahon1915]_ + - [Mac1915]_ - [APR2001]_ From 4a20e2115ff39927e9d72ab1438f65437b7a0271 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 5 Jan 2017 09:31:41 +0100 Subject: [PATCH 207/370] Trac #22066: remove periods when not full sentence (INPUT/OUTPUT blocks) --- src/sage/rings/polynomial/omega.py | 42 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index e79d3294031..579bc224cc1 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -69,7 +69,7 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, INPUT: - - ``var`` -- a variable or a representation string of a variable. + - ``var`` -- a variable or a representation string of a variable - ``expression`` -- an element of the quotient field of some Laurent polynomials or a @@ -83,7 +83,7 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, - ``denominator`` -- a Laurent polynomial or a :class:`~sage.structure.factorization.Factorization` (consisting of Laurent polynomial factors) or a tuple/list of factors (Laurent - polynomials). + polynomials) - ``op`` -- (default: ``operator.ge``) an operator @@ -92,12 +92,12 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, - ``Factorization_sort`` (default: ``False``) and ``Factorization_simplify`` (default: ``True``) -- are passed on to :class:`sage.structure.factorization.Factorization` when creating - the result. + the result OUTPUT: A (partial) :class:`~sage.structure.factorization.Factorization` - of the result whose factors are Laurent polynomials. + of the result whose factors are Laurent polynomials .. NOTE:: @@ -357,10 +357,10 @@ def _Omega_(A, decoded_factors): INPUT: - ``A`` -- a dictionary mapping `a` to `c` representing a summand - `c\mu^a` of the numerator. + `c\mu^a` of the numerator - ``decoded_factors`` -- a tuple or list of pairs `(z, e)` representing - a factor `1 - z \mu^e`. + a factor `1 - z \mu^e` OUTPUT: @@ -437,9 +437,9 @@ def Omega_ge(a, exponents): INPUT: - - ``a`` -- an integer. + - ``a`` -- an integer - - ``exponents`` -- a tuple of integers. + - ``exponents`` -- a tuple of integers OUTPUT: @@ -591,7 +591,7 @@ def Omega_numerator(a, x, y, t): INPUT: - - ``a`` -- an integer. + - ``a`` -- an integer - ``x`` and ``y`` -- a tuple of tuples of Laurent polynomials @@ -601,11 +601,11 @@ def Omega_numerator(a, x, y, t): The non-flatness of these parameters is to be interface-consistent with :func:`Omega_factors_denominator`. - - ``t`` -- a temporary Laurent polynomial variable used for substituting. + - ``t`` -- a temporary Laurent polynomial variable used for substituting OUTPUT: - A Laurent polynomial. + A Laurent polynomial The output is normalized such that the corresponding denominator (:func:`Omega_factors_denominator`) has constant term `1`. @@ -708,7 +708,7 @@ def _Omega_numerator_P_(a, x, y, t): INPUT: - - ``a`` -- an integer. + - ``a`` -- an integer - ``x`` and ``y`` -- a tuple of Laurent polynomials @@ -722,7 +722,7 @@ def _Omega_numerator_P_(a, x, y, t): OUTPUT: - A Laurent polynomial. + A Laurent polynomial TESTS:: @@ -792,14 +792,16 @@ def Omega_factors_denominator(x, y): INPUT: - - ``x`` and ``y`` -- a tuple of tuples of Laurent polynomials. The + - ``x`` and ``y`` -- a tuple of tuples of Laurent polynomials + + The flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the `y_1,...,y_m`. OUTPUT: A factorization of the denominator as - a tuple of Laurent polynomials. + a tuple of Laurent polynomials The output is normalized such that it has constant term `1`. @@ -869,9 +871,9 @@ def partition(items, predicate=bool): INPUT: - - ``item`` -- an iterator. + - ``item`` -- an iterator - - ``predicate`` -- a function. + - ``predicate`` -- a function OUTPUT: @@ -904,13 +906,13 @@ def homogenous_symmetric_function(j, x): INPUT: - - ``j`` -- the degree as a nonnegative integer. + - ``j`` -- the degree as a nonnegative integer - - ``x`` -- an iterable of variables. + - ``x`` -- an iterable of variables OUTPUT: - A polynomial of the common parent of all entries of ``x``. + A polynomial of the common parent of all entries of ``x`` EXAMPLES:: From 5250cd018eb909c9482873637658fbfcd6b5a498 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 5 Jan 2017 09:35:05 +0100 Subject: [PATCH 208/370] Trac #22066: extend title (insert "partition analysis") --- src/sage/rings/polynomial/omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 579bc224cc1..869e264cbfa 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -1,5 +1,5 @@ r""" -MacMahon's Omega Operator +MacMahon's Partition Analysis Omega Operator This module implements :func:`MacMahon's Omega Operator ` [MacMahon1915]_, which takes a quotient of Laurent polynomials and From 9354988ff128f0ce185888ee36074d9b371dc3cb Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 5 Jan 2017 09:37:00 +0100 Subject: [PATCH 209/370] Trac 22066: repair broken links --- src/sage/rings/polynomial/omega.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 869e264cbfa..82c4ec16dd8 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -1,7 +1,7 @@ r""" MacMahon's Partition Analysis Omega Operator -This module implements :func:`MacMahon's Omega Operator ` +This module implements :func:`MacMahon's Omega Operator ` [MacMahon1915]_, which takes a quotient of Laurent polynomials and removes all negative exponents in the corresponding power series. @@ -351,7 +351,7 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, def _Omega_(A, decoded_factors): r""" - Helper function for :func:`Omega` which accesses the low level functions + Helper function for :func:`MacMahonOmega` which accesses the low level functions and does the substituting. INPUT: @@ -371,7 +371,7 @@ def _Omega_(A, decoded_factors): TESTS: - Extensive testing of this function is done in :func:`Omega`. + Extensive testing of this function is done in :func:`MacMahonOmega`. :: @@ -587,7 +587,7 @@ def Omega_numerator(a, x, y, t): and return its numerator. - This function is meant to be a helper function of :func:`Omega`. + This function is meant to be a helper function of :func:`MacMahonOmega`. INPUT: @@ -788,7 +788,7 @@ def Omega_factors_denominator(x, y): and return a factorization of its denominator. - This function is meant to be a helper function of :func:`Omega`. + This function is meant to be a helper function of :func:`MacMahonOmega`. INPUT: From 2124040a0b9071ad803d446ccd20f0b554a572bf Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 5 Jan 2017 10:07:38 +0100 Subject: [PATCH 210/370] Trac #22066: insert example at top --- src/sage/rings/polynomial/omega.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 82c4ec16dd8..2dd8bb08fa7 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -6,6 +6,25 @@ removes all negative exponents in the corresponding power series. +Examples +======== + +In the following example, all negative exponents of `\mu` are removed. +The formula + +.. MATH:: + + \Omega_{\ge} \frac{1}{(1 - x\mu) (1 - y/\mu)} + = \frac{1}{(1 - x) (1 - xy)} + +can be calculated and verified by +:: + + sage: L. = LaurentPolynomialRing(ZZ) + sage: MacMahonOmega(mu, 1, [1 - x*mu, 1 - y/mu]) + 1 * (-x + 1)^-1 * (-x*y + 1)^-1 + + References ========== From b8314a3cc5fe3bd4f5a9e90498c32b363bbb99fe Mon Sep 17 00:00:00 2001 From: Clemens Heuberger Date: Thu, 5 Jan 2017 14:50:58 +0100 Subject: [PATCH 211/370] Trac #22066: Format Mac1915 --- src/doc/en/reference/references/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index d1f9e61049f..d7870be7a7d 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -1071,8 +1071,8 @@ REFERENCES: (2009), No. 3, p.295-313. :arXiv:`0707.4267` .. [Mac1915] Percy A. MacMahon, *Combinatory Analysis*, - Cambridge University Press (1915--1916). - (Reprinted: Chelsea, New York, 1960) + Cambridge University Press (1915--1916). + (Reprinted: Chelsea, New York, 1960). .. [MAR2009] \H. Molina-Abril and P. Réal, *Homology computation using spanning trees* in Progress in Pattern Recognition, Image From 2ce3ab16ce8f41a9961d95a440dd832a138202eb Mon Sep 17 00:00:00 2001 From: Clemens Heuberger Date: Thu, 5 Jan 2017 14:51:16 +0100 Subject: [PATCH 212/370] Trac #22066: minor rewording --- src/sage/rings/polynomial/omega.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 3c0533533f9..7007102fb4a 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -814,7 +814,7 @@ def Omega_factors_denominator(x, y): .. NOTE:: - The implicit assumption is that the ``x`` and ``y`` are collected in + The assumption is that the ``x`` and ``y`` are collected in such a way that one entry of ``x`` corresponds to the orbit of some ``x_j`` under multiplication by `d`-th roots of unity and that the output is collected in a corresponding way. From dc8ae5bc13cda24baa2342d5f078bb9867e44a11 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 5 Jan 2017 15:20:05 +0100 Subject: [PATCH 213/370] Trac #22066.2: rename to _Omega_numerator_ (to make it private) --- src/sage/rings/polynomial/omega.py | 52 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 3c0533533f9..611ec1ba4bb 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -573,13 +573,13 @@ def de_power(expression): for factor in Omega_factors_denominator(x, y)) logger.debug('Omega_ge: preparing numerator') - numerator = de_power(Omega_numerator(a, x, y, t)) + numerator = de_power(_Omega_numerator_(a, x, y, t)) logger.info('Omega_ge: completed') return numerator, factors_denominator -def Omega_numerator(a, x, y, t): +def _Omega_numerator_(a, x, y, t): r""" Return the numerator of `\Omega_{\ge}` of the expression specified by the input. @@ -619,62 +619,62 @@ def Omega_numerator(a, x, y, t): EXAMPLES:: - sage: from sage.rings.polynomial.omega import Omega_numerator, Omega_factors_denominator + sage: from sage.rings.polynomial.omega import _Omega_numerator_, Omega_factors_denominator sage: L. = LaurentPolynomialRing(ZZ) - sage: Omega_numerator(0, ((x0,),), ((y0,),), t) + sage: _Omega_numerator_(0, ((x0,),), ((y0,),), t) 1 - sage: Omega_numerator(0, ((x0,), (x1,)), ((y0,),), t) + sage: _Omega_numerator_(0, ((x0,), (x1,)), ((y0,),), t) -x0*x1*y0 + 1 - sage: Omega_numerator(0, ((x0,),), ((y0,), (y1,)), t) + sage: _Omega_numerator_(0, ((x0,),), ((y0,), (y1,)), t) 1 - sage: Omega_numerator(0, ((x0,), (x1,), (x2,)), ((y0,),), t) + sage: _Omega_numerator_(0, ((x0,), (x1,), (x2,)), ((y0,),), t) x0*x1*x2*y0^2 + x0*x1*x2*y0 - x0*x1*y0 - x0*x2*y0 - x1*x2*y0 + 1 - sage: Omega_numerator(0, ((x0,), (x1,)), ((y0,), (y1,)), t) + sage: _Omega_numerator_(0, ((x0,), (x1,)), ((y0,), (y1,)), t) x0^2*x1*y0*y1 + x0*x1^2*y0*y1 - x0*x1*y0*y1 - x0*x1*y0 - x0*x1*y1 + 1 - sage: Omega_numerator(-2, ((x0,),), ((y0,),), t) + sage: _Omega_numerator_(-2, ((x0,),), ((y0,),), t) x0^2 - sage: Omega_numerator(-1, ((x0,),), ((y0,),), t) + sage: _Omega_numerator_(-1, ((x0,),), ((y0,),), t) x0 - sage: Omega_numerator(1, ((x0,),), ((y0,),), t) + sage: _Omega_numerator_(1, ((x0,),), ((y0,),), t) -x0*y0 + y0 + 1 - sage: Omega_numerator(2, ((x0,),), ((y0,),), t) + sage: _Omega_numerator_(2, ((x0,),), ((y0,),), t) -x0*y0^2 - x0*y0 + y0^2 + y0 + 1 TESTS:: sage: Omega_factors_denominator((), ()) () - sage: Omega_numerator(0, (), (), t) + sage: _Omega_numerator_(0, (), (), t) 1 - sage: Omega_numerator(+2, (), (), t) + sage: _Omega_numerator_(+2, (), (), t) 1 - sage: Omega_numerator(-2, (), (), t) + sage: _Omega_numerator_(-2, (), (), t) 0 sage: Omega_factors_denominator(((x0,),), ()) (-x0 + 1,) - sage: Omega_numerator(0, ((x0,),), (), t) + sage: _Omega_numerator_(0, ((x0,),), (), t) 1 - sage: Omega_numerator(+2, ((x0,),), (), t) + sage: _Omega_numerator_(+2, ((x0,),), (), t) 1 - sage: Omega_numerator(-2, ((x0,),), (), t) + sage: _Omega_numerator_(-2, ((x0,),), (), t) x0^2 sage: Omega_factors_denominator((), ((y0,),)) () - sage: Omega_numerator(0, (), ((y0,),), t) + sage: _Omega_numerator_(0, (), ((y0,),), t) 1 - sage: Omega_numerator(+2, (), ((y0,),), t) + sage: _Omega_numerator_(+2, (), ((y0,),), t) y0^2 + y0 + 1 - sage: Omega_numerator(-2, (), ((y0,),), t) + sage: _Omega_numerator_(-2, (), ((y0,),), t) 0 :: sage: L. = LaurentPolynomialRing(ZZ) - sage: Omega_numerator(2, ((X,),), ((Y,),), t) + sage: _Omega_numerator_(2, ((X,),), ((Y,),), t) -X*Y^2 - X*Y + Y^2 + Y + 1 """ from sage.arith.srange import srange @@ -703,13 +703,13 @@ def Omega_numerator(a, x, y, t): L = t.parent() result = L(result) - logger.info('Omega_numerator: %s terms', result.number_of_terms()) + logger.info('_Omega_numerator_: %s terms', result.number_of_terms()) return result def _Omega_numerator_P_(a, x, y, t): r""" - Helper function for :func:`Omega_numerator`. + Helper function for :func:`_Omega_numerator_`. This is an implementation of the function `P` of [APR2001]_. @@ -719,13 +719,13 @@ def _Omega_numerator_P_(a, x, y, t): - ``x`` and ``y`` -- a tuple of Laurent polynomials - The tuple ``x`` here is the flattened ``x`` of :func:`Omega_numerator` + The tuple ``x`` here is the flattened ``x`` of :func:`_Omega_numerator_` but without its last entry. - ``t`` -- a temporary Laurent polynomial variable In the (final) result, ``t`` has to be substituted by the last - entry of the flattened ``x`` of :func:`Omega_numerator`. + entry of the flattened ``x`` of :func:`_Omega_numerator_`. OUTPUT: From 99acc6412b954add52306833433f695c3fc0c92e Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 5 Jan 2017 15:21:20 +0100 Subject: [PATCH 214/370] Trac #22066.2: rename to _Omega_factors_denominator_ (to make it private) --- src/sage/rings/polynomial/omega.py | 42 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 611ec1ba4bb..58ef47b66f4 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -570,7 +570,7 @@ def de_power(expression): logger.debug('Omega_ge: preparing denominator') factors_denominator = tuple(de_power(1 - factor) - for factor in Omega_factors_denominator(x, y)) + for factor in _Omega_factors_denominator_(x, y)) logger.debug('Omega_ge: preparing numerator') numerator = de_power(_Omega_numerator_(a, x, y, t)) @@ -606,7 +606,7 @@ def _Omega_numerator_(a, x, y, t): flattened ``x`` contains `x_1,...,x_n`, the flattened ``y`` the `y_1,...,y_m`. The non-flatness of these parameters is to be interface-consistent - with :func:`Omega_factors_denominator`. + with :func:`_Omega_factors_denominator_`. - ``t`` -- a temporary Laurent polynomial variable used for substituting @@ -615,11 +615,11 @@ def _Omega_numerator_(a, x, y, t): A Laurent polynomial The output is normalized such that the corresponding denominator - (:func:`Omega_factors_denominator`) has constant term `1`. + (:func:`_Omega_factors_denominator_`) has constant term `1`. EXAMPLES:: - sage: from sage.rings.polynomial.omega import _Omega_numerator_, Omega_factors_denominator + sage: from sage.rings.polynomial.omega import _Omega_numerator_, _Omega_factors_denominator_ sage: L. = LaurentPolynomialRing(ZZ) sage: _Omega_numerator_(0, ((x0,),), ((y0,),), t) @@ -644,7 +644,7 @@ def _Omega_numerator_(a, x, y, t): TESTS:: - sage: Omega_factors_denominator((), ()) + sage: _Omega_factors_denominator_((), ()) () sage: _Omega_numerator_(0, (), (), t) 1 @@ -653,7 +653,7 @@ def _Omega_numerator_(a, x, y, t): sage: _Omega_numerator_(-2, (), (), t) 0 - sage: Omega_factors_denominator(((x0,),), ()) + sage: _Omega_factors_denominator_(((x0,),), ()) (-x0 + 1,) sage: _Omega_numerator_(0, ((x0,),), (), t) 1 @@ -662,7 +662,7 @@ def _Omega_numerator_(a, x, y, t): sage: _Omega_numerator_(-2, ((x0,),), (), t) x0^2 - sage: Omega_factors_denominator((), ((y0,),)) + sage: _Omega_factors_denominator_((), ((y0,),)) () sage: _Omega_numerator_(0, (), ((y0,),), t) 1 @@ -691,7 +691,7 @@ def _Omega_numerator_(a, x, y, t): logger.info('Omega_numerator: a=%s, n=%s, m=%s', a, n, m) if m == 0: - result = 1 - (prod(Omega_factors_denominator(x, y)) * + result = 1 - (prod(_Omega_factors_denominator_(x, y)) * sum(homogenous_symmetric_function(j, xy) for j in srange(-a)) if a < 0 else 0) @@ -780,7 +780,7 @@ def _Omega_numerator_P_(a, x, y, t): @cached_function -def Omega_factors_denominator(x, y): +def _Omega_factors_denominator_(x, y): r""" Return the denominator of `\Omega_{\ge}` of the expression specified by the input. @@ -821,39 +821,39 @@ def Omega_factors_denominator(x, y): EXAMPLES:: - sage: from sage.rings.polynomial.omega import Omega_factors_denominator + sage: from sage.rings.polynomial.omega import _Omega_factors_denominator_ sage: L. = LaurentPolynomialRing(ZZ) - sage: Omega_factors_denominator(((x0,),), ((y0,),)) + sage: _Omega_factors_denominator_(((x0,),), ((y0,),)) (-x0 + 1, -x0*y0 + 1) - sage: Omega_factors_denominator(((x0,),), ((y0,), (y1,))) + sage: _Omega_factors_denominator_(((x0,),), ((y0,), (y1,))) (-x0 + 1, -x0*y0 + 1, -x0*y1 + 1) - sage: Omega_factors_denominator(((x0,), (x1,)), ((y0,),)) + sage: _Omega_factors_denominator_(((x0,), (x1,)), ((y0,),)) (-x0 + 1, -x1 + 1, -x0*y0 + 1, -x1*y0 + 1) - sage: Omega_factors_denominator(((x0,), (x1,), (x2,)), ((y0,),)) + sage: _Omega_factors_denominator_(((x0,), (x1,), (x2,)), ((y0,),)) (-x0 + 1, -x1 + 1, -x2 + 1, -x0*y0 + 1, -x1*y0 + 1, -x2*y0 + 1) - sage: Omega_factors_denominator(((x0,), (x1,)), ((y0,), (y1,))) + sage: _Omega_factors_denominator_(((x0,), (x1,)), ((y0,), (y1,))) (-x0 + 1, -x1 + 1, -x0*y0 + 1, -x0*y1 + 1, -x1*y0 + 1, -x1*y1 + 1) :: sage: B. = ZZ.extension(cyclotomic_polynomial(3)) sage: L. = LaurentPolynomialRing(B) - sage: Omega_factors_denominator(((x, -x),), ((y,),)) + sage: _Omega_factors_denominator_(((x, -x),), ((y,),)) (-x^2 + 1, -x^2*y^2 + 1) - sage: Omega_factors_denominator(((x, -x),), ((y, zeta*y, zeta^2*y),)) + sage: _Omega_factors_denominator_(((x, -x),), ((y, zeta*y, zeta^2*y),)) (-x^2 + 1, -x^6*y^6 + 1) - sage: Omega_factors_denominator(((x, -x),), ((y, -y),)) + sage: _Omega_factors_denominator_(((x, -x),), ((y, -y),)) (-x^2 + 1, -x^2*y^2 + 1, -x^2*y^2 + 1) TESTS:: sage: L. = LaurentPolynomialRing(ZZ) - sage: Omega_factors_denominator((), ()) + sage: _Omega_factors_denominator_((), ()) () - sage: Omega_factors_denominator(((x0,),), ()) + sage: _Omega_factors_denominator_(((x0,),), ()) (-x0 + 1,) - sage: Omega_factors_denominator((), ((y0,),)) + sage: _Omega_factors_denominator_((), ((y0,),)) () """ import logging From 0a6131964af621b38662ad58bfd0e831534024aa Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Thu, 5 Jan 2017 17:00:25 +0100 Subject: [PATCH 215/370] Trac #22066.34: remove quotient input from docs (full functionality only at follow-up ticket) --- src/sage/rings/polynomial/omega.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/sage/rings/polynomial/omega.py b/src/sage/rings/polynomial/omega.py index 58ef47b66f4..b7514b26582 100644 --- a/src/sage/rings/polynomial/omega.py +++ b/src/sage/rings/polynomial/omega.py @@ -78,14 +78,11 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, - ``var`` -- a variable or a representation string of a variable - - ``expression`` -- an element of the quotient field of some - Laurent polynomials or a + - ``expression`` -- a :class:`~sage.structure.factorization.Factorization` - of Laurent polynomials - - If ``denominator`` is specified, then - this Laurent polynomial is interpreted as the numerator of the - expression. + of Laurent polynomials or, if ``denominator`` is specified, + a Laurent polynomial interpreted as the numerator of the + expression - ``denominator`` -- a Laurent polynomial or a :class:`~sage.structure.factorization.Factorization` (consisting @@ -183,15 +180,11 @@ def MacMahonOmega(var, expression, denominator=None, op=operator.ge, sage: MacMahonOmega(mu, mu^2, [1 - x*mu, 1 - y/mu]) (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: MacMahonOmega(mu, mu^2, (1 - x*mu)*(1 - y/mu)) - Traceback (most recent call last): - ... - TypeError: unable to factor n + sage: MacMahonOmega(mu, mu^2, (1 - x*mu)*(1 - y/mu)) # not tested because not fully implemented + (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 - sage: MacMahonOmega(mu, mu^2 / ((1 - x*mu)*(1 - y/mu))) - Traceback (most recent call last): - ... - NotImplementedError: Factor y - mu is not normalized. + sage: MacMahonOmega(mu, mu^2 / ((1 - x*mu)*(1 - y/mu))) # not tested because not fully implemented + (-x*y^2 - x*y + y^2 + y + 1) * (-x + 1)^-1 * (-x*y + 1)^-1 TESTS:: From a1ee07ae43a4a8ebc70dcf61f9cae52a46e5b0f4 Mon Sep 17 00:00:00 2001 From: Frederic HAN Date: Sun, 8 Jan 2017 17:00:39 +0100 Subject: [PATCH 216/370] update from upstream 1.2.3-9 --- build/pkgs/giac/checksums.ini | 6 +++--- build/pkgs/giac/package-version.txt | 2 +- build/pkgs/giac/spkg-src | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/pkgs/giac/checksums.ini b/build/pkgs/giac/checksums.ini index b37931f635c..104406326a1 100644 --- a/build/pkgs/giac/checksums.ini +++ b/build/pkgs/giac/checksums.ini @@ -1,4 +1,4 @@ tarball=giac-VERSION.tar.bz2 -sha1=363cdc60bf5522339aa89082d77580b6f43a6c0c -md5=9af058745f57a374a0639633c98c4540 -cksum=2714101867 +sha1=347cabadc3abd405b8abff322c3c25c79dc6ab61 +md5=6ceda58aa27e70efbfc2e04d50d3ed22 +cksum=1481287904 diff --git a/build/pkgs/giac/package-version.txt b/build/pkgs/giac/package-version.txt index 635a2c2d3f8..bc8adb3c69c 100644 --- a/build/pkgs/giac/package-version.txt +++ b/build/pkgs/giac/package-version.txt @@ -1 +1 @@ -1.2.2.103 +1.2.3.9 diff --git a/build/pkgs/giac/spkg-src b/build/pkgs/giac/spkg-src index 561a5d429cf..2998fd1b18d 100755 --- a/build/pkgs/giac/spkg-src +++ b/build/pkgs/giac/spkg-src @@ -14,8 +14,8 @@ fi set -e # TODO on the next update: l71 switch from gz to bz2 as wished in #18826 -VERSION="1.2.2" -VERSIONREV="103" +VERSION="1.2.3" +VERSIONREV="9" # The upstream tarball name is: giac"$SOURCEORIG".tar.gz SOURCEORIG=_"$VERSION"-"$VERSIONREV" From 582718a844fe5e441b8a25b6410782abc098a469 Mon Sep 17 00:00:00 2001 From: Ben Hutz Date: Sat, 28 Jan 2017 07:21:40 -0600 Subject: [PATCH 217/370] 22268: fix copy for scheme points --- src/sage/schemes/generic/morphism.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index e07995d9f09..361c1243315 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -103,6 +103,7 @@ from sage.misc.constant_function import ConstantFunction from sage.categories.morphism import SetMorphism from sage.categories.morphism import Morphism +from copy import copy coercion_model = get_coercion_model() @@ -1804,11 +1805,14 @@ def __copy__(self): EXAMPLES:: - sage: P.=ProjectiveSpace(ZZ,1) - sage: Q=P(152,113) - sage: copy(Q) is Q + sage: P. = ProjectiveSpace(ZZ, 1) + sage: Q = P(152, 113) + sage: Q2 = copy(Q) + sage: Q2 is Q + False + sage: Q2._coords is Q._coords False - sage: copy(Q) == Q + sage: Q2 == Q True """ - return(self._codomain.point(self._coords, check=False)) + return(self._codomain.point(copy(self._coords), check=False)) From e78ff491e802135b9632854dff9d8ed1181f919d Mon Sep 17 00:00:00 2001 From: Andrey Novoseltsev Date: Sun, 5 Feb 2017 12:58:14 -0700 Subject: [PATCH 218/370] Add PPL representation to LatticePolytope --- src/sage/geometry/lattice_polytope.py | 48 ++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/src/sage/geometry/lattice_polytope.py b/src/sage/geometry/lattice_polytope.py index 1801de1453f..bd648a43b75 100644 --- a/src/sage/geometry/lattice_polytope.py +++ b/src/sage/geometry/lattice_polytope.py @@ -103,28 +103,29 @@ #***************************************************************************** from __future__ import print_function, absolute_import +from sage.arith.all import gcd, lcm from sage.combinat.posets.posets import FinitePoset +from sage.env import POLYTOPE_DATA_DIR from sage.geometry.hasse_diagram import Hasse_diagram_from_incidences from sage.geometry.point_collection import PointCollection, is_PointCollection from sage.geometry.toric_lattice import ToricLattice, is_ToricLattice from sage.graphs.graph import DiGraph, Graph from sage.groups.perm_gps.permgroup_element import PermutationGroupElement +from sage.libs.ppl import C_Polyhedron, Generator_System, Linear_Expression,\ + point as PPL_point from sage.matrix.constructor import matrix from sage.matrix.matrix import is_Matrix from sage.misc.all import cached_method, tmp_filename -from sage.env import POLYTOPE_DATA_DIR -from sage.modules.all import vector, span from sage.misc.superseded import deprecated_function_alias +from sage.modules.all import vector +from sage.numerical.mip import MixedIntegerLinearProgram from sage.plot.plot3d.index_face_set import IndexFaceSet from sage.plot.plot3d.all import line3d, point3d from sage.plot.plot3d.shapes2 import text3d from sage.rings.all import Integer, ZZ, QQ -from sage.arith.all import gcd, lcm from sage.sets.set import Set_generic from sage.structure.all import Sequence from sage.structure.sage_object import SageObject -from sage.numerical.mip import MixedIntegerLinearProgram - from copy import copy import collections @@ -908,6 +909,43 @@ def _palp(self, command, reduce_dimension=False): raise ValueError("\n".join(lines)) return result + @cached_method + def _PPL(self): + r""" + Return the Parma Polyhedra Library (PPL) representation of ``self``. + + OUTPUT: + + - :class:`~sage.libs.ppl.C_Polyhedron` + + EXAMPLES:: + + sage: o = lattice_polytope.cross_polytope(3) + sage: o._PPL() + A 3-dimensional polyhedron in QQ^3 + defined as the convex hull of 6 points + sage: o._PPL().minimized_generators() + Generator_System {point(-1/1, 0/1, 0/1), + point(0/1, -1/1, 0/1), + point(0/1, 0/1, -1/1), + point(0/1, 0/1, 1/1), + point(0/1, 1/1, 0/1), + point(1/1, 0/1, 0/1)} + sage: o._PPL().minimized_constraints() + Constraint_System {x0-x1-x2+1>=0, + x0+x1-x2+1>=0, + x0+x1+x2+1>=0, + x0-x1+x2+1>=0, + -x0-x1+x2+1>=0, + -x0-x1-x2+1>=0, + -x0+x1-x2+1>=0, + -x0+x1+x2+1>=0} + """ + P = C_Polyhedron(Generator_System( + [PPL_point(Linear_Expression(v, 0)) for v in self.vertices()])) + P.set_immutable() + return P + def _pullback(self, data): r""" Pull back given point(s) to the affine subspace spanned by this polytope. From 5c286e40f42a89de0b0d109de8fce58aae399f17 Mon Sep 17 00:00:00 2001 From: Andrey Novoseltsev Date: Sun, 5 Feb 2017 16:48:52 -0700 Subject: [PATCH 219/370] Use PPL for computing vertices of LatticePolytope --- src/sage/geometry/lattice_polytope.py | 93 +++++++++++---------------- 1 file changed, 36 insertions(+), 57 deletions(-) diff --git a/src/sage/geometry/lattice_polytope.py b/src/sage/geometry/lattice_polytope.py index bd648a43b75..746b509de9a 100644 --- a/src/sage/geometry/lattice_polytope.py +++ b/src/sage/geometry/lattice_polytope.py @@ -519,9 +519,19 @@ def __init__(self, points=None, compute_vertices=None, """ if ambient is None: self._ambient = self - self._vertices = points if compute_vertices: - self._compute_dim(compute_vertices=True) + P = C_Polyhedron(Generator_System( + [PPL_point(Linear_Expression(p, 0)) for p in points])) + P.set_immutable() + self._PPL.set_cache(P) + vertices = P.minimized_generators() + if len(vertices) != len(points): + M = points.module() + points = tuple(M(v.coefficients()) for v in vertices) + for p in points: + p.set_immutable() + points = PointCollection(points, M) + self._vertices = points self._ambient_vertex_indices = tuple(range(self.nvertices())) self._ambient_facet_indices = () else: @@ -655,32 +665,19 @@ def __setstate__(self, state): """ self.__dict__.update(state) - def _compute_dim(self, compute_vertices): + def _compute_dim(self): r""" - Compute the dimension of this polytope and its vertices, if necessary. - - If ``compute_vertices`` is ``True``, then ``self._vertices`` should - contain points whose convex hull will be computed and placed back into - ``self._vertices``. + Compute the dimension of this polytope. If the dimension of this polytope is not equal to its ambient dimension, auxiliary polytope will be created and stored for using PALP commands. TESTS:: - sage: p = LatticePolytope(([1], [2], [3]), compute_vertices=False) - sage: p.vertices() # wrong, since these were not vertices - M(1), - M(2), - M(3) - in 1-d lattice M + sage: p = LatticePolytope(([1], [2], [3])) sage: hasattr(p, "_dim") False - sage: p._compute_dim(compute_vertices=True) - sage: p.vertices() - M(1), - M(3) - in 1-d lattice M + sage: p._compute_dim() sage: p._dim 1 """ @@ -691,47 +688,29 @@ def _compute_dim(self, compute_vertices): if not points: # the empty lattice polytope self._dim = -1 return - if compute_vertices and len(points) != len(points.set()): - points = [] - for point in self._vertices: - if not point in points: - points.append(point) - # Still may not be vertices, but don't have repetitions. - self._vertices = PointCollection(points, N) p0 = points[0] points = [point - p0 for point in points] H = N.submodule(points) self._dim = H.rank() - if self._dim == 0: - self._vertices = PointCollection((p0, ), N) - elif self._dim == self.lattice_dim(): - if compute_vertices: - points = [N(_) for _ in read_palp_matrix(self.poly_x("v")).columns()] - for point in points: - point.set_immutable() - self._vertices = PointCollection(points, N) - else: - # Setup auxiliary polytope and maps - H = H.saturation() - H_points = [H.coordinates(point) for point in points] - H_polytope = LatticePolytope(H_points, compute_vertices=True) - self._sublattice = H - self._sublattice_polytope = H_polytope - self._embedding_matrix = H.basis_matrix().transpose() - self._shift_vector = p0 - if compute_vertices: - self._vertices = self._embed(H_polytope._vertices) - # In order to use facet normals obtained from subpolytopes, we - # need the following (see Trac #9188). - M = self._embedding_matrix - # Basis for the ambient space with spanned subspace in front - basis = M.columns() + M.integer_kernel().basis() - # Let's represent it as columns of a matrix - basis = matrix(basis).transpose() - # Absolute value helps to keep normals "inner" - self._dual_embedding_scale = abs(basis.det()) - dualbasis = matrix(ZZ, self._dual_embedding_scale * basis.inverse()) - self._dual_embedding_matrix = dualbasis.submatrix(0,0,M.ncols()) + # Setup auxiliary polytope and maps + H = H.saturation() + H_points = [H.coordinates(point) for point in points] + H_polytope = LatticePolytope(H_points, compute_vertices=True) + self._sublattice = H + self._sublattice_polytope = H_polytope + self._embedding_matrix = H.basis_matrix().transpose() + self._shift_vector = p0 + # In order to use facet normals obtained from subpolytopes, we + # need the following (see Trac #9188). + M = self._embedding_matrix + # Basis for the ambient space with spanned subspace in front + basis = M.columns() + M.integer_kernel().basis() + # Let's represent it as columns of a matrix + basis = matrix(basis).transpose() + # Absolute value helps to keep normals "inner" + self._dual_embedding_scale = abs(basis.det()) + dualbasis = matrix(ZZ, self._dual_embedding_scale * basis.inverse()) + self._dual_embedding_matrix = dualbasis.submatrix(0,0,M.ncols()) def _compute_facets(self): r""" @@ -1615,7 +1594,7 @@ def dim(self): 3 """ if not hasattr(self, "_dim"): - self._compute_dim(compute_vertices=False) + self._compute_dim() return self._dim def distances(self, point=None): From db3b54e20e98572a34918526aa0e8c28c83dea78 Mon Sep 17 00:00:00 2001 From: Andrey Novoseltsev Date: Sun, 5 Feb 2017 17:20:26 -0700 Subject: [PATCH 220/370] Fix doctests - mostly due to different order of vertices _embed and _pullback doctests mostly just show that they don't crash. set_palp_dimension crash has to be more explicit, otherwise it works. --- src/sage/geometry/lattice_polytope.py | 74 +++++++++++++------------- src/sage/geometry/polyhedron/base.py | 12 ++--- src/sage/schemes/toric/fano_variety.py | 32 +++++------ 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/sage/geometry/lattice_polytope.py b/src/sage/geometry/lattice_polytope.py index 746b509de9a..842d6d21f78 100644 --- a/src/sage/geometry/lattice_polytope.py +++ b/src/sage/geometry/lattice_polytope.py @@ -257,10 +257,10 @@ def LatticePolytope(data, compute_vertices=True, n=0, lattice=None): sage: p 2-d lattice polytope in 3-d lattice M sage: p.vertices() - M( 1, 0, 0), - M( 0, 1, 0), M(-1, 0, 0), - M( 0, -1, 0) + M( 0, -1, 0), + M( 1, 0, 0), + M( 0, 1, 0) in 3-d lattice M An empty lattice polytope can be considered as well:: @@ -781,7 +781,7 @@ def _embed(self, data): sage: m[1, 1] = 1 sage: p = o.affine_transform(m) sage: p._embed((0,0)) - M(1, 0, 0) + M(-1, 0, 0) """ if self.lattice_dim() == self.dim(): return data @@ -947,7 +947,7 @@ def _pullback(self, data): sage: m[1, 1] = 1 sage: p = o.affine_transform(m) sage: p._pullback((0, 0, 0)) - [-1, 0] + [1, 0] """ if self.lattice_dim() == self.dim(): return data @@ -4112,12 +4112,12 @@ class NefPartition(SageObject, sage: np.dual().Delta_polar() is np.nabla_polar() True sage: np.Delta(1).vertices() - N(0, 0, 1), - N(0, 0, -1) + N(0, 0, -1), + N(0, 0, 1) in 3-d lattice N sage: np.dual().nabla(1).vertices() - N(0, 0, 1), - N(0, 0, -1) + N(0, 0, -1), + N(0, 0, 1) in 3-d lattice N Instead of constructing nef-partitions directly, you can request all 2-part @@ -4342,10 +4342,10 @@ def Delta(self, i=None): N( 1, 1, -1) in 3-d lattice N sage: np.Delta(0).vertices() - N( 1, -1, 0), - N( 1, 0, 0), N(-1, -1, 0), - N(-1, 0, 0) + N(-1, 0, 0), + N( 1, 0, 0), + N( 1, -1, 0) in 3-d lattice N """ if i is None: @@ -4403,16 +4403,16 @@ def Deltas(self): N( 1, 1, -1) in 3-d lattice N sage: [Delta_i.vertices() for Delta_i in np.Deltas()] - [N( 1, -1, 0), - N( 1, 0, 0), - N(-1, -1, 0), - N(-1, 0, 0) - in 3-d lattice N, - N(0, 1, 1), - N(0, 0, 1), - N(0, 0, -1), - N(0, 1, -1) - in 3-d lattice N] + [N(-1, -1, 0), + N(-1, 0, 0), + N( 1, 0, 0), + N( 1, -1, 0) + in 3-d lattice N, + N(0, 0, -1), + N(0, 1, 1), + N(0, 0, 1), + N(0, 1, -1) + in 3-d lattice N] sage: np.nabla_polar().vertices() N( 1, -1, 0), N( 1, 0, 0), @@ -4541,9 +4541,9 @@ def nabla(self, i=None): M( 0, 0, -1) in 3-d lattice M sage: np.nabla(0).vertices() + M(-1, 0, 0), M( 1, 0, 0), - M( 0, 1, 0), - M(-1, 0, 0) + M( 0, 1, 0) in 3-d lattice M sage: np.nabla().vertices() M(-1, 0, 1), @@ -4619,14 +4619,14 @@ def nablas(self): M( 0, 0, -1) in 3-d lattice M sage: [nabla_i.vertices() for nabla_i in np.nablas()] - [M( 1, 0, 0), - M( 0, 1, 0), - M(-1, 0, 0) - in 3-d lattice M, - M(0, 0, 1), - M(0, -1, 0), - M(0, 0, -1) - in 3-d lattice M] + [M(-1, 0, 0), + M( 1, 0, 0), + M( 0, 1, 0) + in 3-d lattice M, + M(0, -1, 0), + M(0, 0, -1), + M(0, 0, 1) + in 3-d lattice M] """ try: return self._nablas @@ -5652,10 +5652,10 @@ def set_palp_dimension(d): EXAMPLES: - By default, it is not possible to create the 7-dimensional simplex with - vertices at the basis of the 8-dimensional space:: + Let's try to work with a 7-dimensional polytope:: - sage: LatticePolytope(identity_matrix(8)) + sage: p = lattice_polytope.cross_polytope(7) + sage: p._palp("poly.x -fv") Traceback (most recent call last): ... ValueError: Error executing 'poly.x -fv' for the given polytope! @@ -5665,8 +5665,8 @@ def set_palp_dimension(d): However, we can work with this polytope by changing PALP dimension to 11:: sage: lattice_polytope.set_palp_dimension(11) - sage: LatticePolytope(identity_matrix(8)) - 7-d lattice polytope in 8-d lattice M + sage: p._palp("poly.x -fv") + '7 14 Vertices of P...' Let's go back to default settings:: diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 73706e2a792..bf770370126 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4100,9 +4100,9 @@ def lattice_polytope(self, envelope=False): sage: lp.vertices() M(-1, 0), M( 0, -1), + M( 1, 1), M( 0, 1), - M( 1, 0), - M( 1, 1) + M( 1, 0) in 2-d lattice M """ if not self.is_compact(): @@ -4140,16 +4140,16 @@ def _integral_points_PALP(self): sage: Polyhedron(vertices=[(-1,-1),(1,0),(1,1),(0,1)])._integral_points_PALP() [M(-1, -1), M(0, 1), M(1, 0), M(1, 1), M(0, 0)] sage: Polyhedron(vertices=[(-1/2,-1/2),(1,0),(1,1),(0,1)]).lattice_polytope(True).points() - M( 0, -1), - M(-1, 0), M(-1, -1), + M(-1, 0), + M( 0, -1), + M( 1, 1), M( 0, 1), M( 1, 0), - M( 1, 1), M( 0, 0) in 2-d lattice M sage: Polyhedron(vertices=[(-1/2,-1/2),(1,0),(1,1),(0,1)])._integral_points_PALP() - [M(0, 1), M(1, 0), M(1, 1), M(0, 0)] + [M(1, 1), M(0, 1), M(1, 0), M(0, 0)] """ if not self.is_compact(): raise ValueError('Can only enumerate points in a compact polyhedron.') diff --git a/src/sage/schemes/toric/fano_variety.py b/src/sage/schemes/toric/fano_variety.py index 84a8872f5bb..f521b8d61a4 100644 --- a/src/sage/schemes/toric/fano_variety.py +++ b/src/sage/schemes/toric/fano_variety.py @@ -1494,10 +1494,10 @@ class NefCompleteIntersection(AlgebraicScheme_subscheme_toric): sage: X.nef_complete_intersection(np) Closed subscheme of 3-d CPR-Fano toric variety covered by 8 affine patches defined by: - a1*z0^2*z1 + a4*z0*z1*z3 + a3*z1*z3^2 - + a0*z0^2*z4 + a5*z0*z3*z4 + a2*z3^2*z4, - b0*z1*z2^2 + b1*z2^2*z4 + b4*z1*z2*z5 - + b5*z2*z4*z5 + b3*z1*z5^2 + b2*z4*z5^2 + a2*z0^2*z1 + a5*z0*z1*z3 + a1*z1*z3^2 + + a3*z0^2*z4 + a4*z0*z3*z4 + a0*z3^2*z4, + b1*z1*z2^2 + b2*z2^2*z4 + b5*z1*z2*z5 + + b4*z2*z4*z5 + b3*z1*z5^2 + b0*z4*z5^2 See :meth:`CPRFanoToricVariety_field.nef_complete_intersection` for a more elaborate example. @@ -1520,10 +1520,10 @@ def __init__(self, P_Delta, nef_partition, sage: NefCompleteIntersection(X, np) Closed subscheme of 3-d CPR-Fano toric variety covered by 8 affine patches defined by: - a1*z0^2*z1 + a4*z0*z1*z3 + a3*z1*z3^2 - + a0*z0^2*z4 + a5*z0*z3*z4 + a2*z3^2*z4, - b0*z1*z2^2 + b1*z2^2*z4 + b4*z1*z2*z5 - + b5*z2*z4*z5 + b3*z1*z5^2 + b2*z4*z5^2 + a2*z0^2*z1 + a5*z0*z1*z3 + a1*z1*z3^2 + + a3*z0^2*z4 + a4*z0*z3*z4 + a0*z3^2*z4, + b1*z1*z2^2 + b2*z2^2*z4 + b5*z1*z2*z5 + + b4*z2*z4*z5 + b3*z1*z5^2 + b0*z4*z5^2 """ if not is_CPRFanoToricVariety(P_Delta): raise TypeError("nef complete intersections can only be " @@ -1618,10 +1618,10 @@ def cohomology_class(self): sage: CI Closed subscheme of 3-d CPR-Fano toric variety covered by 8 affine patches defined by: - a1*z0^2*z1 + a4*z0*z1*z3 + a3*z1*z3^2 - + a0*z0^2*z4 + a5*z0*z3*z4 + a2*z3^2*z4, - b0*z1*z2^2 + b1*z2^2*z4 + b4*z1*z2*z5 - + b5*z2*z4*z5 + b3*z1*z5^2 + b2*z4*z5^2 + a2*z0^2*z1 + a5*z0*z1*z3 + a1*z1*z3^2 + + a3*z0^2*z4 + a4*z0*z3*z4 + a0*z3^2*z4, + b1*z1*z2^2 + b2*z2^2*z4 + b5*z1*z2*z5 + + b4*z2*z4*z5 + b3*z1*z5^2 + b0*z4*z5^2 sage: CI.cohomology_class() [2*z3*z4 + 4*z3*z5 + 2*z4*z5] """ @@ -1651,10 +1651,10 @@ def nef_partition(self): sage: CI Closed subscheme of 3-d CPR-Fano toric variety covered by 8 affine patches defined by: - a1*z0^2*z1 + a4*z0*z1*z3 + a3*z1*z3^2 - + a0*z0^2*z4 + a5*z0*z3*z4 + a2*z3^2*z4, - b0*z1*z2^2 + b1*z2^2*z4 + b4*z1*z2*z5 - + b5*z2*z4*z5 + b3*z1*z5^2 + b2*z4*z5^2 + a2*z0^2*z1 + a5*z0*z1*z3 + a1*z1*z3^2 + + a3*z0^2*z4 + a4*z0*z3*z4 + a0*z3^2*z4, + b1*z1*z2^2 + b2*z2^2*z4 + b5*z1*z2*z5 + + b4*z2*z4*z5 + b3*z1*z5^2 + b0*z4*z5^2 sage: CI.nef_partition() Nef-partition {0, 1, 3} U {2, 4, 5} sage: CI.nef_partition() is np From 0e82ba90050b621998c8eaf48d0bd2a72a0380c9 Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Mon, 6 Feb 2017 10:11:38 +0100 Subject: [PATCH 221/370] Fixed surrounding_bch_code() and BCH constructor. Other minor fixes (doc, imports). --- src/sage/coding/bch.py | 90 +++++++++++++++++------------ src/sage/coding/codes_catalog.py | 4 +- src/sage/coding/cyclic_code.py | 19 ++++-- src/sage/coding/decoders_catalog.py | 3 +- 4 files changed, 69 insertions(+), 47 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 7b906aa1e7a..73ffa609e39 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -35,16 +35,18 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from linear_code import AbstractLinearCode -from cyclic_code import CyclicCode -from grs import GeneralizedReedSolomonCode -from encoder import Encoder -from decoder import Decoder, DecodingError +from .linear_code import AbstractLinearCode +from .cyclic_code import CyclicCode +from .grs import GeneralizedReedSolomonCode +from .encoder import Encoder +from .decoder import Decoder, DecodingError from sage.modules.free_module_element import vector from sage.misc.misc_c import prod from sage.rings.integer import Integer from sage.categories.fields import Fields from sage.rings.integer_ring import ZZ +from sage.arith.all import gcd +from sage.rings.all import Zmod from copy import copy class BCHCode(CyclicCode): @@ -59,19 +61,22 @@ class BCHCode(CyclicCode): - ``designed_distance`` -- the resulting minimum distance of the code - - ``primitive_element`` -- (default: ``None``) the primitive element - to use when creating the set of roots for the generating polynomial - over the splitting field. It has to be of multiplicative order ``length`` over this - field. If the splitting field is not ``field``, it also have to be a polynomial in ``zx``, - where ``x`` is the degree of the extension field. For instance, - over ``GF(16)``, it has to be a polynomial in ``z4``. + - ``primitive_root`` -- (default: ``None``) the primitive root to use when + creating the set of roots for the generating polynomial over the splitting + field. It has to be of multiplicative order ``length`` over this field. + If the splitting field is not ``field``, it also has to be a polynomial in + ``zx``, where ``x`` is the degree of the extension field. + For instance, over ``GF(16)``, it has to be a polynomial in ``z4``. - - ``offset`` -- (default: ``0``) the first element to add in the defining set + - ``offset`` -- (default: ``0``) the first element in the defining set - - ``jump_size`` -- (default: ``1``) the jump size between two elements of the defining set + - ``jump_size`` -- (default: ``1``) the jump size between two elements of + the defining set. It must be coprime with the multiplicative order of + ``primitive_root``. - - ``b`` -- (default: ``0``) is exactly the same as ``offset``. It is only here - for retro-compatibility purposes with the old signature of `BCHCode` and will be removed soon. + - ``b`` -- (default: ``0``) is exactly the same as ``offset``. It is only + here for retro-compatibility purposes with the old signature of `BCHCode` + and will be removed soon. EXAMPLES:: @@ -85,12 +90,12 @@ class BCHCode(CyclicCode): as generator polynomial """ - def __init__(self, base_field, length, designed_distance, primitive_element = None, offset = 0, jump_size = 1, b = 0): + def __init__(self, base_field, length, designed_distance, primitive_root=None, offset=0, jump_size=1, b=0): """ TESTS: - ``designed_distance`` must be between 2 and ``length`` (inclusive), otherwise an exception - will be raised:: + ``designed_distance`` must be between 2 and ``length`` (inclusive), + otherwise an exception is raised:: sage: C = codes.BCHCode(GF(2), 15, 16) Traceback (most recent call last): @@ -106,17 +111,18 @@ def __init__(self, base_field, length, designed_distance, primitive_element = No offset = b if not base_field in Fields or not base_field.is_finite(): raise ValueError("base_field has to be a finite field") - elif not base_field.is_finite(): - raise ValueError("base_field has to be a finite field") + + q = base_field.cardinality() + s = Zmod(length)(q).multiplicative_order() + if gcd(jump_size, q ** s - 1) != 1: + raise ValueError("jump_size must be coprime with the order of " + "the multicative group of the splitting field") - D = [] - point = copy(offset) - for i in range(0, designed_distance - 1): - D.append(point) - point = (point + jump_size) % length + D = [ (offset + jump_size * i) % length + for i in range(designed_distance - 1) ] try: - super(BCHCode, self).__init__(field = base_field, length = length, D = D, primitive_element = primitive_element) + super(BCHCode, self).__init__(field = base_field, length = length, D = D, primitive_root = primitive_root) except ValueError, e: raise e self._default_decoder_name = "UnderlyingGRS" @@ -141,7 +147,7 @@ def __eq__(self, other): and self.length() == other.length() \ and self.jump_size() == other.jump_size() \ and self.offset() == self.offset()\ - and self.primitive_element() == self.primitive_element() + and self.primitive_root() == self.primitive_root() def _repr_(self): r""" @@ -196,6 +202,18 @@ def offset(self): """ return self._offset + def designed_distance(self): + r""" + Returns the designed distance of ``self``. + + EXAMPLES:: + + sage: C = codes.BCHCode(GF(2), 15, 4, offset = 1) + sage: C.designed_distance() + 4 + """ + return self._designed_distance + def bch_to_grs(self): r""" Returns the underlying GRS code from which ``self`` was derived. @@ -207,20 +225,18 @@ def bch_to_grs(self): [15, 13, 3] Generalized Reed-Solomon Code over Finite Field in z4 of size 2^4 """ l = self.jump_size() - alpha = self.primitive_element() b = self.offset() n = self.length() + designed_distance = self.designed_distance() + grs_dim = n - designed_distance + 1 - grs_dim = n - self.bch_bound(arithmetic = True) + 1 - evals = [] - pcm = [] - for i in range(1, n + 1): - evals.append(alpha ** (l * (i - 1))) - pcm.append(alpha ** (b * (i - 1))) - + alpha = self.primitive_root() + alpha_l = alpha ** l + alpha_b = alpha ** b + evals = [ alpha_l ** i for i in range(n) ] + pcm = [ alpha_b ** i for i in range(n) ] - multipliers_product = [1/prod([evals[i] - evals[h] for h in range(len(evals)) if h != i]) - for i in range(len(evals))] + multipliers_product = [1/prod([evals[i] - evals[h] for h in range(n) if h != i]) for i in range(n)] column_multipliers = [multipliers_product[i]/pcm[i] for i in range(n)] return GeneralizedReedSolomonCode(evals, grs_dim, column_multipliers) diff --git a/src/sage/coding/codes_catalog.py b/src/sage/coding/codes_catalog.py index 1782884d469..491ceff53f3 100644 --- a/src/sage/coding/codes_catalog.py +++ b/src/sage/coding/codes_catalog.py @@ -22,7 +22,8 @@ from sage.misc.lazy_import import lazy_import as _lazy_import from .linear_code import LinearCode -from .code_constructions import (BCHCode, BinaryGolayCode, +from .bch import BCHCode +from .code_constructions import (BinaryGolayCode, CyclicCodeFromGeneratingPolynomial, CyclicCodeFromCheckPolynomial, DuadicCodeEvenPair, @@ -38,7 +39,6 @@ RandomLinearCode, #deprecated ReedSolomonCode, TernaryGolayCode, ToricCode, WalshCode) - from .cyclic_code import CyclicCode from .grs import GeneralizedReedSolomonCode from .reed_muller_code import ReedMullerCode, BinaryReedMullerCode diff --git a/src/sage/coding/cyclic_code.py b/src/sage/coding/cyclic_code.py index 84fb030ad24..eca2e46096d 100644 --- a/src/sage/coding/cyclic_code.py +++ b/src/sage/coding/cyclic_code.py @@ -59,6 +59,8 @@ LinearCodeSyndromeDecoder, LinearCodeNearestNeighborDecoder) from .encoder import Encoder +from .decoder import Decoder +from copy import copy from sage.rings.integer import Integer from sage.arith.all import gcd from sage.modules.free_module_element import vector @@ -764,13 +766,18 @@ def surrounding_bch_code(self): EXAMPLES:: - sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) - sage: C.surrounding_bch_code() - [15, 12] BCH Code over Finite Field in a of size 2^4 with x^3 + a^2*x^2 + a*x + a^3 + a^2 + a + 1 as generator polynomial + sage: C = codes.CyclicCode(field=GF(2), length=63, D=[1, 7, 17]) + sage: C.dimension() + 45 + sage: CC = C.surrounding_bch_code() + sage: CC + [63, 51] BCH Code over Finite Field of size 2 with x^12 + x^10 + x^6 + x + 1 as generator polynomial + sage: all(r in CC for r in C.generator_matrix()) + True """ - from bch import BCHCode - delta, params = self.bch_bound(arithmetic = True, bch_parameters = True) - return BCHCode(self.base_field(), self.length(), delta, offset=params[0], jump_size=params[1]) + from .bch import BCHCode + delta, params = self.bch_bound(arithmetic = True) + return BCHCode(self.base_field(), self.length(), delta, offset=params[1], jump_size=params[0]) class CyclicCodePolynomialEncoder(Encoder): diff --git a/src/sage/coding/decoders_catalog.py b/src/sage/coding/decoders_catalog.py index 50eb4fa5170..6ff739cb783 100644 --- a/src/sage/coding/decoders_catalog.py +++ b/src/sage/coding/decoders_catalog.py @@ -9,8 +9,7 @@ - :class:`linear_code.LinearCodeNearestNeighborDecoder ` **Subfield subcode decoder** -- :class:`subfield_subcode.SubfieldSubcodeOriginalCodeDecoder ` +- :class:`subfield_subcode.SubfieldSubcodeOriginalCodeDecoder ` **Generalized Reed-Solomon code decoders** From c18043fc84006f05200e42cab2dd7f18b819ee30 Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Mon, 6 Feb 2017 11:30:21 +0100 Subject: [PATCH 222/370] Made all doctests pass. Shorter output for BCH codes. --- src/sage/coding/bch.py | 82 +++++++++++++++++----------------- src/sage/coding/cyclic_code.py | 62 ++++++++++++++++++------- 2 files changed, 85 insertions(+), 59 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 73ffa609e39..5b2dead48a7 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -82,12 +82,15 @@ class BCHCode(CyclicCode): sage: C = codes.BCHCode(GF(2), 15, 7, offset = 1) sage: C - [15, 5] BCH Code over Finite Field of size 2 with x^10 + x^8 + x^5 + x^4 + x^2 + x + 1 as generator polynomial + [15, 5] BCH Code over GF(2) with designed distance 7 + sage: C.generator_polynomial() + x^10 + x^8 + x^5 + x^4 + x^2 + x + 1 - sage: C = codes.BCHCode(GF(2), 15, 4, offset = 1, jump_size = 3) + sage: C = codes.BCHCode(GF(2), 15, 4, offset = 1, jump_size = 8) sage: C - [15, 7] BCH Code over Finite Field of size 2 with x^8 + x^7 + x^5 + x^4 + x^3 + x + 1 - as generator polynomial + [15, 7] BCH Code over GF(2) with designed distance 4 + sage: C.generator_polynomial() + x^8 + x^7 + x^6 + x^4 + 1 """ def __init__(self, base_field, length, designed_distance, primitive_root=None, offset=0, jump_size=1, b=0): @@ -111,7 +114,7 @@ def __init__(self, base_field, length, designed_distance, primitive_root=None, o offset = b if not base_field in Fields or not base_field.is_finite(): raise ValueError("base_field has to be a finite field") - + q = base_field.cardinality() s = Zmod(length)(q).multiplicative_order() if gcd(jump_size, q ** s - 1) != 1: @@ -157,11 +160,11 @@ def _repr_(self): sage: C = codes.BCHCode(GF(2), 15, 7, offset = 1) sage: C - [15, 5] BCH Code over Finite Field of size 2 with x^10 + x^8 + x^5 + x^4 + x^2 + x + 1 as generator polynomial + [15, 5] BCH Code over GF(2) with designed distance 7 """ - return "[%s, %s] BCH Code over %s with %s as generator polynomial"\ - % (self.length(), self.dimension(),\ - self.base_field(), self.generator_polynomial()) + return "[%s, %s] BCH Code over GF(%s) with designed distance %d"\ + % (self.length(), self.dimension(), + self.base_field().cardinality(), self.designed_distance()) def _latex_(self): r""" @@ -171,11 +174,11 @@ def _latex_(self): sage: C = codes.BCHCode(GF(2), 15, 7, offset = 1) sage: latex(C) - [15, 5] \textnormal{ BCH Code over } \Bold{F}_{2} \textnormal{ with } x^{10} + x^{8} + x^{5} + x^{4} + x^{2} + x + 1 \textnormal{ as generator polynomial} + [15, 5] \textnormal{ BCH Code over } \Bold{F}_{2} \textnormal{ with designed distance } 7 """ - return "[%s, %s] \\textnormal{ BCH Code over } %s \\textnormal{ with } %s \\textnormal{ as generator polynomial}"\ - % (self.length(), self.dimension(),\ - self.base_field()._latex_(), self.generator_polynomial()._latex_()) + return "[%s, %s] \\textnormal{ BCH Code over } %s \\textnormal{ with designed distance } %s"\ + % (self.length(), self.dimension(), + self.base_field()._latex_(), self.designed_distance()) def jump_size(self): r""" @@ -220,9 +223,9 @@ def bch_to_grs(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 2, jump_size = 2, offset = 1) + sage: C = codes.BCHCode(GF(2), 15, 3) sage: C.bch_to_grs() - [15, 13, 3] Generalized Reed-Solomon Code over Finite Field in z4 of size 2^4 + [15, 13, 3] Generalized Reed-Solomon Code over GF(16) """ l = self.jump_size() b = self.offset() @@ -264,7 +267,7 @@ def __init__(self, code, grs_decoder = "KeyEquationSyndrome", **kwargs): sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D - Decoder through the underlying GRS code of [15, 11] BCH Code over Finite Field in a of size 2^2 with x^4 + a*x^3 + a as generator polynomial + Decoder through the underlying GRS code of [15, 11] BCH Code over GF(4) with designed distance 3 """ self._grs_code = code.bch_to_grs() @@ -283,7 +286,7 @@ def _repr_(self): sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D - Decoder through the underlying GRS code of [15, 11] BCH Code over Finite Field in a of size 2^2 with x^4 + a*x^3 + a as generator polynomial + Decoder through the underlying GRS code of [15, 11] BCH Code over GF(4) with designed distance 3 """ return "Decoder through the underlying GRS code of %s" % self.code() @@ -296,7 +299,7 @@ def _latex_(self): sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: latex(D) - \textnormal{Decoder through the underlying GRS code of } [15, 11] \textnormal{ BCH Code over } \Bold{F}_{2^{2}} \textnormal{ with } x^{4} + a x^{3} + a \textnormal{ as generator polynomial} + \textnormal{Decoder through the underlying GRS code of } [15, 11] \textnormal{ BCH Code over } \Bold{F}_{2^{2}} \textnormal{ with designed distance } 3 """ return "\\textnormal{Decoder through the underlying GRS code of } %s" % (self.code()._latex_()) @@ -307,10 +310,10 @@ def grs_code(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 2, jump_size = 2, offset = 1) + sage: C = codes.BCHCode(GF(2), 15, 3) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D.grs_code() - [15, 13, 3] Generalized Reed-Solomon Code over Finite Field in z4 of size 2^4 + [15, 13, 3] Generalized Reed-Solomon Code over GF(16) """ return self._grs_code @@ -323,7 +326,7 @@ def grs_decoder(self): sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D.grs_decoder() - Key equation decoder for [15, 13, 3] Generalized Reed-Solomon Code over Finite Field in z4 of size 2^4 + Key equation decoder for [15, 13, 3] Generalized Reed-Solomon Code over GF(16) """ return self._grs_decoder @@ -333,25 +336,24 @@ def bch_word_to_grs(self, c): EXAMPLES:: - sage: F = GF(4, 'a') - sage: a = F.gen() - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: C = codes.BCHCode(GF(2), 15, 3) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) - sage: c = vector(F, [0, a, 1, a, 0, 1, 1, 1, a, 0, 0, a + 1, a, 0, 1]) - sage: D.bch_word_to_grs(c) - (0, z4^2 + z4, 1, z4^2 + z4, 0, 1, 1, 1, z4^2 + z4, 0, 0, z4^2 + z4 + 1, z4^2 + z4, 0, 1) + sage: c = C.random_element() + sage: y = D.bch_word_to_grs(c) + sage: y.parent() + Vector space of dimension 15 over Finite Field in z4 of size 2^4 + sage: y in D.grs_code() + True """ C = self.code() - if hasattr(self.code(), "_field_embedding"): - mapping = self.code()._field_embedding.embedding() - a = [mapping(i) for i in c] - return vector(a) - else: - return c + mapping = self.code().field_embedding().embedding() + a = [mapping(i) for i in c] + return vector(a) def grs_word_to_bch(self, c): r""" - Returns ``c`` converted as a codeword of :meth:`sage.coding.decoder.Decoder.code`. + Returns ``c`` converted as a codeword of + :meth:`sage.coding.decoder.Decoder.code`. EXAMPLES:: @@ -365,13 +367,9 @@ def grs_word_to_bch(self, c): (0, a, 1, a, 0, 1, 1, 1, a, 0, 0, a + 1, a, 0, 1) """ C = self.code() - if hasattr(self.code(), "_field_embedding"): - FE = C._field_embedding - a = [] - for i in c: - a.append(FE.cast_into_relative_field(i)) - return vector(a) - return c + FE = C.field_embedding() + a = map(FE.cast_into_relative_field, c) + return vector(a) def decode_to_code(self, y): r""" @@ -413,7 +411,7 @@ def decoding_radius(self): sage: D.decoding_radius() 1 """ - return (self.code().bch_bound(arithmetic = True) - 1) // 2 + return (self.code().bch_bound(arithmetic=True)[0] - 1) // 2 ####################### registration ############################### diff --git a/src/sage/coding/cyclic_code.py b/src/sage/coding/cyclic_code.py index eca2e46096d..b50415c1dc2 100644 --- a/src/sage/coding/cyclic_code.py +++ b/src/sage/coding/cyclic_code.py @@ -463,6 +463,7 @@ def __init__(self, generator_pol=None, length=None, code=None, check=True, D=Non g *= R([FE.cast_into_relative_field(coeff) for coeff in pol]) # we set class variables + self._field_embedding = FE self._primitive_root = alpha self._defining_set = sorted(pows) self._polynomial_ring = R @@ -562,6 +563,25 @@ def generator_polynomial(self): """ return self._generator_polynomial + def field_embedding(self): + r""" + Returns the base field embedding into the splitting field. + + EXAMPLES:: + + sage: F. = GF(2)[] + sage: n = 7 + sage: g = x ** 3 + x + 1 + sage: C = codes.CyclicCode(generator_pol = g, length = n) + sage: C.field_embedding() + Relative field extension between Finite Field in z3 of size 2^3 and Finite Field of size 2 + + """ + if not(hasattr(self, "_field_embedding")): + self.defining_set() + return self._field_embedding + + def defining_set(self, primitive_root=None): r""" Returns the set of powers of the root of ``self``'s generator polynomial @@ -579,7 +599,8 @@ def defining_set(self, primitive_root=None): [1, 2] If the defining set was provided by the user, it might have been expanded - at construction time. In this case, the expanded defining set will be returned:: + at construction time. In this case, the expanded defining set will be + returned:: sage: C = codes.CyclicCode(length = 13, field = F, D = [1, 2]) sage: C.defining_set() @@ -601,7 +622,7 @@ def defining_set(self, primitive_root=None): sage: C1.generator_polynomial() == g True - Another one, in the revert order:: + Another one, in a reversed order:: sage: F = GF(16, 'a') sage: n = 13 @@ -612,7 +633,8 @@ def defining_set(self, primitive_root=None): True """ if (hasattr(self, "_defining_set") and - (primitive_root is None or primitive_root == self._primitive_root)): + (primitive_root is None or + primitive_root == self._primitive_root)): return self._defining_set else: F = self.base_field() @@ -624,6 +646,8 @@ def defining_set(self, primitive_root=None): if primitive_root is None: Fsplit, F_to_Fsplit = F.extension(Integer(s), map=True) + FE = RelativeFiniteFieldExtension(Fsplit, F, + embedding=F_to_Fsplit) alpha = Fsplit.zeta(n) else: try: @@ -632,15 +656,18 @@ def defining_set(self, primitive_root=None): FE = RelativeFiniteFieldExtension(Fsplit, F) F_to_Fsplit = FE.embedding() except ValueError: - raise ValueError("primitive_root does not belong to the right splitting field") + raise ValueError("primitive_root does not belong to the " + "right splitting field") if alpha.multiplicative_order() != n: - raise ValueError("primitive_root must have multiplicative order n") - self._primitive_root = alpha + raise ValueError("primitive_root must have multiplicative " + "order equal to the code length") Rsplit = Fsplit['xx'] gsplit = Rsplit([F_to_Fsplit(coeff) for coeff in g]) roots = gsplit.roots(multiplicities=False) D = [root.log(alpha) for root in roots] + self._field_embedding = FE + self._primitive_root = alpha self._defining_set = sorted(D) return self._defining_set @@ -726,7 +753,8 @@ def parity_check_matrix(self): def bch_bound(self, arithmetic=False): r""" - Returns the BCH bound of ``self`` which is a bound on ``self``'s minimum distance. + Returns the BCH bound of ``self`` which is a bound on ``self`` + minimum distance. See :meth:`sage.coding.cyclic_code.bch_bound` for details. @@ -759,7 +787,6 @@ def bch_bound(self, arithmetic=False): """ return bch_bound(self.length(), self.defining_set(), arithmetic) - @cached_method def surrounding_bch_code(self): r""" Returns the surrounding BCH code of ``self``. @@ -771,13 +798,14 @@ def surrounding_bch_code(self): 45 sage: CC = C.surrounding_bch_code() sage: CC - [63, 51] BCH Code over Finite Field of size 2 with x^12 + x^10 + x^6 + x + 1 as generator polynomial + [63, 51] BCH Code over GF(2) with designed distance 3 sage: all(r in CC for r in C.generator_matrix()) True """ from .bch import BCHCode delta, params = self.bch_bound(arithmetic = True) - return BCHCode(self.base_field(), self.length(), delta, offset=params[1], jump_size=params[0]) + return BCHCode(self.base_field(), self.length(), delta, + offset=params[1], jump_size=params[0]) class CyclicCodePolynomialEncoder(Encoder): @@ -1174,7 +1202,7 @@ class CyclicCodeSurroundingBCHDecoder(Decoder): sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D - Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over Finite Field in a of size 2^4 with x^5 + (a^3 + a^2 + a)*x^4 + x^3 + (a^3 + 1)*x^2 + (a^2 + 1)*x + a^2 + a + 1 as generator polynomial + Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over GF(16) """ def __init__(self, code, **kwargs): r""" @@ -1184,7 +1212,7 @@ def __init__(self, code, **kwargs): sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D - Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over Finite Field in a of size 2^4 with x^5 + (a^3 + a^2 + a)*x^4 + x^3 + (a^3 + 1)*x^2 + (a^2 + 1)*x + a^2 + a + 1 as generator polynomial + Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over GF(16) """ self._bch_code = code.surrounding_bch_code() self._bch_decoder = self._bch_code.decoder(**kwargs) @@ -1218,7 +1246,7 @@ def _repr_(self): sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D - Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over Finite Field in a of size 2^4 with x^5 + (a^3 + a^2 + a)*x^4 + x^3 + (a^3 + 1)*x^2 + (a^2 + 1)*x + a^2 + a + 1 as generator polynomial + Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over GF(16) """ return "Decoder through the surrounding BCH code of the %s" % self.code() @@ -1231,7 +1259,7 @@ def _latex_(self): sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: latex(D) - \textnormal{Decoder through the surrounding BCH code of the }[15, 10] \textnormal{ Cyclic Code over } \Bold{F}_{2^{4}} \textnormal{ with } x^{5} + \left(a^{3} + a^{2} + a\right) x^{4} + x^{3} + \left(a^{3} + 1\right) x^{2} + \left(a^{2} + 1\right) x + a^{2} + a + 1 \textnormal{ as generator polynomial} + \textnormal{Decoder through the surrounding BCH code of the }[15, 10] \textnormal{ Cyclic Code over } \Bold{F}_{2^{4}} """ return "\\textnormal{Decoder through the surrounding BCH code of the }%s"\ % self.code()._latex_() @@ -1245,7 +1273,7 @@ def bch_code(self): sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D.bch_code() - [15, 12] BCH Code over Finite Field in a of size 2^4 with x^3 + a^2*x^2 + a*x + a^3 + a^2 + a + 1 as generator polynomial + [15, 12] BCH Code over GF(16) with designed distance 4 """ return self._bch_code @@ -1258,7 +1286,7 @@ def bch_decoder(self): sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D.bch_decoder() - Decoder through the underlying GRS code of [15, 12] BCH Code over Finite Field in a of size 2^4 with x^3 + a^2*x^2 + a*x + a^3 + a^2 + a + 1 as generator polynomial + Decoder through the underlying GRS code of [15, 12] BCH Code over GF(16) with designed distance 4 """ return self._bch_decoder @@ -1288,7 +1316,7 @@ def decoding_radius(self): sage: D.decoding_radius() 1 """ - return (self.code().bch_bound(arithmetic = True) - 1) // 2 + return (self.code().bch_bound(arithmetic=True)[0] - 1) // 2 ####################### registration ############################### From c9f6835ff9d5d3daaac23bba0061f74053804df9 Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Mon, 6 Feb 2017 13:20:44 +0100 Subject: [PATCH 223/370] Improved the doc of BCH codes. Cleaned the code. --- src/sage/coding/bch.py | 103 +++++++++------- src/sage/coding/cyclic_code.py | 219 ++++++++++++++++++--------------- 2 files changed, 178 insertions(+), 144 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 5b2dead48a7..3dcd375548b 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -1,13 +1,16 @@ r""" BCH Code -Let `F = GF(q)` and `\Phi` be the splitting field of -`x^{n} - 1` over`F`, with `n` a positive integer. -Let `\alpha` be an element of multiplicative order `n` in `\Phi`. +Let `F = GF(q)` and `\Phi` be the splitting field of `x^{n} - 1` over `F`, +with `n` a positive integer. Let also `\alpha` be an element of multiplicative +order `n` in `\Phi`. Finally, let `b, \delta, \ell` be integers such that +`0 \le b \leq n`, `2 \le \delta \leq n` and `\alpha^\ell` generates the +multiplicative group `\Phi^{\times}`. -A BCH code consists of all codewords `c(x) \in F_{n}[x]` such that -`c(\alpha^{a}) = 0`, for `a = b, b + l, b + 2\times l, \dots, b + (\delta - 2) \times l`, -with `b`, `\delta` integers such that `b < \delta` and `0 < \delta \leq n`. +A BCH code over `F` with designed distance `\delta` is a cyclic code whose +codewords `c(x) \in F[x]` satisfy `c(\alpha^{a}) = 0`, for all integers `a` in +the arithmetic sequence +`b, b + \ell, b + 2 \times \ell, \dots, b + (\delta - 2) \times \ell`. TESTS: @@ -25,30 +28,29 @@ Relative field extension between Finite Field in aa of size 2^4 and Finite Field in a of size 2^2 """ -#***************************************************************************** +# ***************************************************************************** # Copyright (C) 2016 David Lucas +# 2017 Julien Lavauzelle # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # http://www.gnu.org/licenses/ -#***************************************************************************** +# ***************************************************************************** -from .linear_code import AbstractLinearCode from .cyclic_code import CyclicCode from .grs import GeneralizedReedSolomonCode -from .encoder import Encoder from .decoder import Decoder, DecodingError from sage.modules.free_module_element import vector from sage.misc.misc_c import prod -from sage.rings.integer import Integer from sage.categories.fields import Fields from sage.rings.integer_ring import ZZ from sage.arith.all import gcd from sage.rings.all import Zmod from copy import copy + class BCHCode(CyclicCode): r""" Representation of a BCH code seen as a cyclic code. @@ -61,11 +63,11 @@ class BCHCode(CyclicCode): - ``designed_distance`` -- the resulting minimum distance of the code - - ``primitive_root`` -- (default: ``None``) the primitive root to use when - creating the set of roots for the generating polynomial over the splitting - field. It has to be of multiplicative order ``length`` over this field. - If the splitting field is not ``field``, it also has to be a polynomial in - ``zx``, where ``x`` is the degree of the extension field. + - ``primitive_root`` -- (default: ``None``) the primitive root to use when + creating the set of roots for the generating polynomial over the + splitting field. It has to be of multiplicative order ``length`` over + this field. If the splitting field is not ``field``, it also has to be a + polynomial in ``zx``, where ``x`` is the degree of the extension field. For instance, over ``GF(16)``, it has to be a polynomial in ``z4``. - ``offset`` -- (default: ``0``) the first element in the defining set @@ -93,7 +95,8 @@ class BCHCode(CyclicCode): x^8 + x^7 + x^6 + x^4 + 1 """ - def __init__(self, base_field, length, designed_distance, primitive_root=None, offset=0, jump_size=1, b=0): + def __init__(self, base_field, length, designed_distance, + primitive_root=None, offset=0, jump_size=1, b=0): """ TESTS: @@ -112,7 +115,7 @@ def __init__(self, base_field, length, designed_distance, primitive_root=None, o deprecation(20335, "codes.BCHCode(n, designed_distance, F, b=0) is now deprecated. Please use the new signature instead.") (length, designed_distance, base_field) = (base_field, length, designed_distance) offset = b - if not base_field in Fields or not base_field.is_finite(): + if base_field not in Fields or not base_field.is_finite(): raise ValueError("base_field has to be a finite field") q = base_field.cardinality() @@ -121,11 +124,12 @@ def __init__(self, base_field, length, designed_distance, primitive_root=None, o raise ValueError("jump_size must be coprime with the order of " "the multicative group of the splitting field") - D = [ (offset + jump_size * i) % length - for i in range(designed_distance - 1) ] + D = [(offset + jump_size * i) % length + for i in range(designed_distance - 1)] try: - super(BCHCode, self).__init__(field = base_field, length = length, D = D, primitive_root = primitive_root) + super(BCHCode, self).__init__(field=base_field, length=length, + D=D, primitive_root=primitive_root) except ValueError, e: raise e self._default_decoder_name = "UnderlyingGRS" @@ -146,11 +150,11 @@ def __eq__(self, other): sage: C1 == C2 True """ - return isinstance(other, BCHCode) \ - and self.length() == other.length() \ - and self.jump_size() == other.jump_size() \ - and self.offset() == self.offset()\ - and self.primitive_root() == self.primitive_root() + return (isinstance(other, BCHCode) and + self.length() == other.length() and + self.jump_size() == other.jump_size() and + self.offset() == self.offset() and + self.primitive_root() == self.primitive_root()) def _repr_(self): r""" @@ -176,13 +180,14 @@ def _latex_(self): sage: latex(C) [15, 5] \textnormal{ BCH Code over } \Bold{F}_{2} \textnormal{ with designed distance } 7 """ - return "[%s, %s] \\textnormal{ BCH Code over } %s \\textnormal{ with designed distance } %s"\ + return ("[%s, %s] \\textnormal{ BCH Code over } %s \\textnormal{ with designed distance } %s" % (self.length(), self.dimension(), - self.base_field()._latex_(), self.designed_distance()) + self.base_field()._latex_(), self.designed_distance())) def jump_size(self): r""" - Returns the jump size between two consecutive elements of the defining set of ``self``. + Returns the jump size between two consecutive elements of the defining + set of ``self``. EXAMPLES:: @@ -236,8 +241,8 @@ def bch_to_grs(self): alpha = self.primitive_root() alpha_l = alpha ** l alpha_b = alpha ** b - evals = [ alpha_l ** i for i in range(n) ] - pcm = [ alpha_b ** i for i in range(n) ] + evals = [alpha_l ** i for i in range(n)] + pcm = [alpha_b ** i for i in range(n)] multipliers_product = [1/prod([evals[i] - evals[h] for h in range(n) if h != i]) for i in range(n)] column_multipliers = [multipliers_product[i]/pcm[i] for i in range(n)] @@ -248,23 +253,25 @@ def bch_to_grs(self): class BCHUnderlyingGRSDecoder(Decoder): r""" A decoder which decodes through the underlying - :class:`sage.coding.grs.GeneralizedReedSolomonCode` code of the provided BCH code. + :class:`sage.coding.grs.GeneralizedReedSolomonCode` code of the provided + BCH code. INPUT: - ``code`` -- The associated code of this decoder. - - ``grs_decoder`` -- The string name of the decoder to use over the underlying GRS code + - ``grs_decoder`` -- The string name of the decoder to use over the + underlying GRS code - ``**kwargs`` -- All extra arguments are forwarded to the GRS decoder """ - def __init__(self, code, grs_decoder = "KeyEquationSyndrome", **kwargs): + def __init__(self, code, grs_decoder="KeyEquationSyndrome", **kwargs): r""" EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D Decoder through the underlying GRS code of [15, 11] BCH Code over GF(4) with designed distance 3 @@ -275,7 +282,8 @@ def __init__(self, code, grs_decoder = "KeyEquationSyndrome", **kwargs): self._decoder_type = copy(self._decoder_type) self._decoder_type.remove("dynamic") self._decoder_type = self._grs_decoder.decoder_type() - super(BCHUnderlyingGRSDecoder, self).__init__(code, code.ambient_space(), "Vector") + super(BCHUnderlyingGRSDecoder, self).__init__( + code, code.ambient_space(), "Vector") def _repr_(self): r""" @@ -283,7 +291,7 @@ def _repr_(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D Decoder through the underlying GRS code of [15, 11] BCH Code over GF(4) with designed distance 3 @@ -296,17 +304,18 @@ def _latex_(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: latex(D) \textnormal{Decoder through the underlying GRS code of } [15, 11] \textnormal{ BCH Code over } \Bold{F}_{2^{2}} \textnormal{ with designed distance } 3 """ - return "\\textnormal{Decoder through the underlying GRS code of } %s" % (self.code()._latex_()) + return ("\\textnormal{Decoder through the underlying GRS code of } %s" + % self.code()._latex_()) def grs_code(self): r""" - Returns the underlying GRS code of :meth:`sage.coding.decoder.Decoder.code`. - + Returns the underlying GRS code of + :meth:`sage.coding.decoder.Decoder.code`. EXAMPLES:: @@ -323,7 +332,7 @@ def grs_decoder(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D.grs_decoder() Key equation decoder for [15, 13, 3] Generalized Reed-Solomon Code over GF(16) @@ -345,7 +354,6 @@ def bch_word_to_grs(self, c): sage: y in D.grs_code() True """ - C = self.code() mapping = self.code().field_embedding().embedding() a = [mapping(i) for i in c] return vector(a) @@ -357,7 +365,7 @@ def grs_word_to_bch(self, c): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: Cgrs = D.grs_code() sage: Fgrs = Cgrs.base_field() @@ -373,13 +381,13 @@ def grs_word_to_bch(self, c): def decode_to_code(self, y): r""" - Decodes ``y`` to an element in :meth:`sage.coding.decoder.Decoder.code`. + Decodes ``y`` to a codeword in :meth:`sage.coding.decoder.Decoder.code`. EXAMPLES:: sage: F = GF(4, 'a') sage: a = F.gen() - sage: C = codes.BCHCode(F, 15, 3, jump_size = 2, offset = 1) + sage: C = codes.BCHCode(F, 15, 3, jump_size=2, offset=1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: y = vector(F, [a, a + 1, 1, a + 1, 1, a, a + 1, a + 1, 0, 1, a + 1, 1, 1, 1, a]) sage: D.decode_to_code(y) @@ -406,13 +414,14 @@ def decoding_radius(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size = 2, offset = 1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D.decoding_radius() 1 """ return (self.code().bch_bound(arithmetic=True)[0] - 1) // 2 + ####################### registration ############################### BCHCode._registered_decoders["UnderlyingGRS"] = BCHUnderlyingGRSDecoder diff --git a/src/sage/coding/cyclic_code.py b/src/sage/coding/cyclic_code.py index b50415c1dc2..ded7f9dd144 100644 --- a/src/sage/coding/cyclic_code.py +++ b/src/sage/coding/cyclic_code.py @@ -44,7 +44,7 @@ Relative field extension between Finite Field in aa of size 2^4 and Finite Field in a of size 2^2 """ -#***************************************************************************** +# ***************************************************************************** # Copyright (C) 2015 David Lucas # 2016 Julien Lavauzelle # @@ -53,7 +53,7 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # http://www.gnu.org/licenses/ -#***************************************************************************** +# ***************************************************************************** from .linear_code import (AbstractLinearCode, LinearCodeSyndromeDecoder, @@ -75,24 +75,26 @@ def find_generator_polynomial(code, check=True): Returns a possible generator polynomial for ``code``. If the code is cyclic, the generator polynomial is the gcd of all the - polynomial forms of the codewords. Conversely, if this gcd exactly generates - the code ``code``, then ``code`` is cyclic. + polynomial forms of the codewords. Conversely, if this gcd exactly + generates the code ``code``, then ``code`` is cyclic. - If ``check`` is set to ``True``, then it also checks that the code is indeed - cyclic. Otherwise it doesn't. + If ``check`` is set to ``True``, then it also checks that the code is + indeed cyclic. Otherwise it doesn't. INPUT: - ``code`` -- a linear code + - ``check`` -- whether the cyclicity should be checked + OUTPUT: - - the generator polynomial (if the code is cyclic). + - the generator polynomial of ``code`` (if the code is cyclic). EXAMPLES:: sage: from sage.coding.cyclic_code import find_generator_polynomial - sage: C = codes.GeneralizedReedSolomonCode(GF(2^3, 'a').list()[1:2^3], 2^2) + sage: C = codes.GeneralizedReedSolomonCode(GF(8, 'a').list()[1:], 4) sage: find_generator_polynomial(C) x^3 + (a^2 + 1)*x^2 + a*x + a^2 + 1 """ @@ -142,12 +144,13 @@ def _to_complete_list(poly, length): def bch_bound(n, D, arithmetic=False): r""" - Returns the BCH bound obtained for a cyclic code of length ``n`` and defining set ``D``. + Returns the BCH bound obtained for a cyclic code of length ``n`` and + defining set ``D``. - Considering a cyclic code `C`, with defining set `D`, length `n`, and minimum + Consider a cyclic code `C`, with defining set `D`, length `n`, and minimum distance `d`. We have the following bound, called BCH bound, on `d`: - `d \geq \delta + 1`, where `\delta` is the length of the longest arithmetic sequence - (modulo `n`) of elements in `D`. + `d \geq \delta + 1`, where `\delta` is the length of the longest arithmetic + sequence (modulo `n`) of elements in `D`. That is, if `\exists c, \gcd(c,n) = 1` such that `\{l, l+c, \dots, l + (\delta - 1) \times c\} \subseteq D`, @@ -158,9 +161,11 @@ def bch_bound(n, D, arithmetic=False): .. NOTE:: - As this is a specific use case of the BCH bound, it is *not* available if the global namespace. - Call it by using ``sage.coding.cyclic_code.bch_bound``. You can also load it into the global - namespace by typing ``from sage.coding.cyclic_code import bch_bound``. + As this is a specific use case of the BCH bound, it is *not* available + in the global namespace. + Call it by using ``sage.coding.cyclic_code.bch_bound``. You can also + load it into the global namespace by typing + ``from sage.coding.cyclic_code import bch_bound``. INPUT: @@ -174,7 +179,8 @@ def bch_bound(n, D, arithmetic=False): OUTPUT: - ``(delta + 1, (l, c))`` -- such that ``delta + 1`` is the BCH bound, and - ``l, c`` are the parameters of the largest arithmetic sequence (see below) + ``l, c`` are the parameters of the longest arithmetic sequence + (see below) EXAMPLES:: @@ -207,7 +213,8 @@ def longest_streak(step): try: isD[d] = 1 except IndexError: - raise ValueError("%s must contains integers between 0 and %s" % (D, n - 1)) + raise ValueError("%s must contains integers between 0 and %s" % + (D, n - 1)) if 0 not in isD: return (n + 1, (1, 0)) @@ -215,7 +222,8 @@ def longest_streak(step): one_len, offset = longest_streak(1) return (one_len + 1, (1, offset)) else: - longest_streak_list = [(longest_streak(step), step) for step in range(1, n // 2 + 1) + longest_streak_list = [(longest_streak(step), step) + for step in range(1, n // 2 + 1) if gcd(step, n) == 1] (max_len, offset), step = max(longest_streak_list) return (max_len + 1, (step, offset)) @@ -225,18 +233,19 @@ class CyclicCode(AbstractLinearCode): r""" Representation of a cyclic code. - We propose three different ways to create a new CyclicCode, either by providing: + We propose three different ways to create a new CyclicCode, either by + providing: - the generator polynomial and the length (1) - - an existing linear code. In that case, a generator polynomial will be computed - from the provided linear code's parameters (2) + - an existing linear code. In that case, a generator polynomial will be + computed from the provided linear code's parameters (2) - (a subset of) the defining set of the cyclic code (3) - For now, only single-root cyclic codes are implemented. That is, only cyclic - codes such that its length `n` and field order `q` are coprimes. + For now, only single-root cyclic codes are implemented. That is, only + cyclic codes such that its length `n` and field order `q` are coprimes. - Depending on which behaviour you want, you need to specify the names of the arguments to - CyclicCode. See EXAMPLES section below for details. + Depending on which behaviour you want, you need to specify the names of the + arguments to CyclicCode. See EXAMPLES section below for details. INPUT: @@ -263,8 +272,8 @@ class CyclicCode(AbstractLinearCode): the splitting field which contains the roots of the generator polynomial. It has to be of multiplicative order ``length`` over this field. If the splitting field is not ``field``, it also have to be a polynomial - in ``zx``, where ``x`` is the degree of the extension over the prime field. - For instance, over ``GF(16)``, it has to be a polynomial in ``z4``. + in ``zx``, where ``x`` is the degree of the extension over the prime + field. For instance, over ``GF(16)``, it must be a polynomial in ``z4``. EXAMPLES: @@ -282,7 +291,7 @@ class CyclicCode(AbstractLinearCode): extract a generator polynomial (see :meth:`find_generator_polynomial` for details):: - sage: C = codes.GeneralizedReedSolomonCode(GF(2 ** 3, 'a').list()[1:2 ** 3], 2 ** 2) + sage: C = codes.GeneralizedReedSolomonCode(GF(8, 'a').list()[1:], 4) sage: Cc = codes.CyclicCode(code = C) sage: Cc [7, 4] Cyclic Code over GF(8) @@ -300,7 +309,8 @@ class CyclicCode(AbstractLinearCode): _registered_encoders = {} _registered_decoders = {} - def __init__(self, generator_pol=None, length=None, code=None, check=True, D=None, field=None, primitive_root=None): + def __init__(self, generator_pol=None, length=None, code=None, check=True, + D=None, field=None, primitive_root=None): r""" TESTS: @@ -320,7 +330,7 @@ def __init__(self, generator_pol=None, length=None, code=None, check=True, D=Non sage: F. = RR[] sage: n = 7 sage: g = x ** 3 + x + 1 - sage: C = codes.CyclicCode(generator_pol = g, length = n) + sage: C = codes.CyclicCode(generator_pol=g, length=n) Traceback (most recent call last): ... ValueError: The generator polynomial must be defined over a finite field. @@ -331,7 +341,7 @@ def __init__(self, generator_pol=None, length=None, code=None, check=True, D=Non sage: F. = GF(2)[] sage: n = 7 sage: g = x ** 2 + x + 1 - sage: C = codes.CyclicCode(generator_pol = g, length = n) + sage: C = codes.CyclicCode(generator_pol=g, length=n) Traceback (most recent call last): ... ValueError: Provided polynomial must divide x^n - 1, where n is the provided length. @@ -341,7 +351,7 @@ def __init__(self, generator_pol=None, length=None, code=None, check=True, D=Non sage: G = matrix(GF(2), [[1, 1, 1], [0, 1, 1]]) sage: C = codes.LinearCode(G) - sage: Cc = codes.CyclicCode(code = C) + sage: Cc = codes.CyclicCode(code=C) Traceback (most recent call last): ... ValueError: The code is not cyclic. @@ -354,17 +364,17 @@ def __init__(self, generator_pol=None, length=None, code=None, check=True, D=Non sage: n = 15 sage: Dset = [1, 2, 4, 8] sage: alpha = GF(3).one() - sage: Cc = codes.CyclicCode(D = Dset, field = F, length = n, primitive_root = alpha) + sage: Cc = codes.CyclicCode(D=Dset, field=F, length=n, primitive_root=alpha) Traceback (most recent call last): ... ValueError: primitive_root must belong to an extension of the base field. sage: alpha = GF(16).one() - sage: Cc = codes.CyclicCode(D = Dset, field = F, length = n, primitive_root = alpha) + sage: Cc = codes.CyclicCode(D=Dset, field=F, length=n, primitive_root=alpha) Traceback (most recent call last): ... ValueError: primitive_root must be a primitive n-th root of unity. sage: alpha = GF(32).gen() - sage: Cc = codes.CyclicCode(D = Dset, field = F, length = n, primitive_root = alpha) + sage: Cc = codes.CyclicCode(D=Dset, field=F, length=n, primitive_root=alpha) Traceback (most recent call last): ... ValueError: primitive_root must be a primitive n-th root of unity. @@ -413,7 +423,8 @@ def __init__(self, generator_pol=None, length=None, code=None, check=True, D=Non self._polynomial_ring = g.parent() self._generator_polynomial = g self._dimension = code.dimension() - super(CyclicCode, self).__init__(code.base_ring(), n, "Vector", "Syndrome") + super(CyclicCode, self).__init__(code.base_ring(), n, + "Vector", "Syndrome") # Case (3) : a defining set, a length and a field are provided elif (D is not None and length is not None and field is not None and @@ -472,18 +483,24 @@ def __init__(self, generator_pol=None, length=None, code=None, check=True, D=Non super(CyclicCode, self).__init__(F, n, "Vector", "SurroundingBCH") else: - raise AttributeError("You must provide either a code, or a list of powers and the length and the field, or a generator polynomial and the code length") + raise AttributeError("You must provide either a code, or a list " + "of powers and the length and the field, or " + "a generator polynomial and the code length") def __contains__(self, word): r""" Returns ``True`` if ``word`` belongs to ``self``, ``False`` otherwise. + INPUT: + + - ``word`` -- the word to test + EXAMPLES:: sage: F. = GF(2)[] sage: n = 7 sage: g = x ** 3 + x + 1 - sage: C = codes.CyclicCode(generator_pol = g, length = n) + sage: C = codes.CyclicCode(generator_pol=g, length=n) sage: c = vector(GF(2), (1, 1, 1, 0, 0, 1, 0)) sage: c in C True @@ -496,13 +513,17 @@ def __eq__(self, other): r""" Tests equality between CyclicCode objects. + INPUT: + + - ``other`` -- the code to test + EXAMPLES:: sage: F. = GF(2)[] sage: n = 7 sage: g = x ** 3 + x + 1 - sage: C1 = codes.CyclicCode(generator_pol = g, length = n) - sage: C2 = codes.CyclicCode(generator_pol = g, length = n) + sage: C1 = codes.CyclicCode(generator_pol=g, length=n) + sage: C2 = codes.CyclicCode(generator_pol=g, length=n) sage: C1 == C2 True """ @@ -523,7 +544,7 @@ def _repr_(self): sage: F. = GF(2)[] sage: n = 7 sage: g = x ** 3 + x + 1 - sage: C = codes.CyclicCode(generator_pol = g, length = n) + sage: C = codes.CyclicCode(generator_pol=g, length=n) sage: C [7, 4] Cyclic Code over GF(2) """ @@ -540,7 +561,7 @@ def _latex_(self): sage: F. = GF(2)[] sage: n = 7 sage: g = x ** 3 + x + 1 - sage: C = codes.CyclicCode(generator_pol = g, length = n) + sage: C = codes.CyclicCode(generator_pol=g, length=n) sage: latex(C) [7, 4] \textnormal{ Cyclic Code over } \Bold{F}_{2} """ @@ -557,7 +578,7 @@ def generator_polynomial(self): sage: F. = GF(2)[] sage: n = 7 sage: g = x ** 3 + x + 1 - sage: C = codes.CyclicCode(generator_pol = g, length = n) + sage: C = codes.CyclicCode(generator_pol=g, length=n) sage: C.generator_polynomial() x^3 + x + 1 """ @@ -572,21 +593,25 @@ def field_embedding(self): sage: F. = GF(2)[] sage: n = 7 sage: g = x ** 3 + x + 1 - sage: C = codes.CyclicCode(generator_pol = g, length = n) + sage: C = codes.CyclicCode(generator_pol=g, length=n) sage: C.field_embedding() Relative field extension between Finite Field in z3 of size 2^3 and Finite Field of size 2 - """ if not(hasattr(self, "_field_embedding")): self.defining_set() return self._field_embedding - - + def defining_set(self, primitive_root=None): r""" - Returns the set of powers of the root of ``self``'s generator polynomial - over the extension field. It depends on the choice of the primitive - root of the splitting field. + Returns the set of exponents of the roots of ``self``'s generator + polynomial over the extension field. Of course, it depends on the + choice of the primitive root of the splitting field. + + + INPUT: + + - ``primitive_root`` (optional) -- a primitive root of the extension + field EXAMPLES: @@ -594,41 +619,40 @@ def defining_set(self, primitive_root=None): sage: F = GF(16, 'a') sage: n = 15 - sage: C = codes.CyclicCode(length = n, field = F, D = [1,2]) + sage: C = codes.CyclicCode(length=n, field=F, D=[1,2]) sage: C.defining_set() [1, 2] - If the defining set was provided by the user, it might have been expanded - at construction time. In this case, the expanded defining set will be - returned:: + If the defining set was provided by the user, it might have been + expanded at construction time. In this case, the expanded defining set + will be returned:: - sage: C = codes.CyclicCode(length = 13, field = F, D = [1, 2]) + sage: C = codes.CyclicCode(length=13, field=F, D=[1, 2]) sage: C.defining_set() [1, 2, 3, 5, 6, 9] If a generator polynomial was passed at construction time, the defining set is computed using this polynomial:: - sage: F. = GF(8, 'a')[] + sage: R. = F[] sage: n = 7 sage: g = x ** 3 + x + 1 - sage: C = codes.CyclicCode(generator_pol = g, length = n) + sage: C = codes.CyclicCode(generator_pol=g, length=n) sage: C.defining_set() [1, 2, 4] Both operations give the same result:: - sage: C1 = codes.CyclicCode(length = n, field = GF(8, 'a'), D = [1, 2, 4]) + sage: C1 = codes.CyclicCode(length=n, field=F, D=[1, 2, 4]) sage: C1.generator_polynomial() == g True Another one, in a reversed order:: - sage: F = GF(16, 'a') sage: n = 13 - sage: C1 = codes.CyclicCode(length = n, field = F, D = [1, 2]) + sage: C1 = codes.CyclicCode(length=n, field=F, D=[1, 2]) sage: g = C1.generator_polynomial() - sage: C2 = codes.CyclicCode(generator_pol = g, length = n) + sage: C2 = codes.CyclicCode(generator_pol=g, length=n) sage: C1.defining_set() == C2.defining_set() True """ @@ -684,7 +708,7 @@ def primitive_root(self): sage: F. = GF(2)[] sage: n = 7 sage: g = x ** 3 + x + 1 - sage: C = codes.CyclicCode(generator_pol = g, length = n) + sage: C = codes.CyclicCode(generator_pol=g, length=n) sage: C.primitive_root() z3 @@ -706,9 +730,8 @@ def check_polynomial(self): r""" Returns the check polynomial of ``self``. - Let `C` be a cyclic code of length `n` and `g` its - generator polynomial. - The following: `h = \frac{x^n - 1}{g(x)}` is called `C`'s + Let `C` be a cyclic code of length `n` and `g` its generator + polynomial. The following: `h = \frac{x^n - 1}{g(x)}` is called `C`'s check polynomial. EXAMPLES:: @@ -803,7 +826,7 @@ def surrounding_bch_code(self): True """ from .bch import BCHCode - delta, params = self.bch_bound(arithmetic = True) + delta, params = self.bch_bound(arithmetic=True) return BCHCode(self.base_field(), self.length(), delta, offset=params[1], jump_size=params[0]) @@ -898,7 +921,8 @@ def _latex_(self): sage: latex(E) \textnormal{Polynomial-style encoder for }[7, 4] \textnormal{ Cyclic Code over } \Bold{F}_{2} """ - return "\\textnormal{Polynomial-style encoder for }%s" % self.code()._latex_() + return ("\\textnormal{Polynomial-style encoder for }%s" % + self.code()._latex_()) def encode(self, p): r""" @@ -988,7 +1012,8 @@ class CyclicCodeVectorEncoder(Encoder): This codeword can be seen as a polynomial over `F[x]`, as follows: `P_m = \Sigma_{i=0}^{k-1} m_i \times x^i`. - To encode `m`, this encoder does the following multiplication: `P_m \times g`. + To encode `m`, this encoder does the following multiplication: + `P_m \times g`. INPUT: @@ -1071,7 +1096,8 @@ def _latex_(self): sage: latex(E) \textnormal{Vector-style encoder for }[7, 4] \textnormal{ Cyclic Code over } \Bold{F}_{2} """ - return "\\textnormal{Vector-style encoder for }%s" % self.code()._latex_() + return ("\\textnormal{Vector-style encoder for }%s" % + self.code()._latex_()) def encode(self, m): r""" @@ -1079,11 +1105,11 @@ def encode(self, m): INPUT: - - ``m`` -- A element from ``self``'s message space + - ``m`` -- an element from ``self``'s message space OUTPUT: - - A codeword in associated code of ``self`` + - A codeword in the associated code of ``self`` EXAMPLES:: @@ -1181,15 +1207,10 @@ def message_space(self): return self.code().base_ring() ** self.code().dimension() - - - - - - class CyclicCodeSurroundingBCHDecoder(Decoder): r""" - A decoder which decodes through the surrounding BCH code of the cyclic code. + A decoder which decodes through the surrounding BCH code of the cyclic + code. INPUT: @@ -1199,7 +1220,7 @@ class CyclicCodeSurroundingBCHDecoder(Decoder): EXAMPLES:: - sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: C = codes.CyclicCode(field=GF(16), length=15, D=[14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over GF(16) @@ -1209,7 +1230,7 @@ def __init__(self, code, **kwargs): EXAMPLES:: - sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: C = codes.CyclicCode(field=GF(16), length=15, D=[14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over GF(16) @@ -1219,7 +1240,8 @@ def __init__(self, code, **kwargs): self._decoder_type = copy(self._decoder_type) self._decoder_type.remove("dynamic") self._decoder_type = self._bch_decoder.decoder_type() - super(CyclicCodeSurroundingBCHDecoder, self).__init__(code, code.ambient_space(), "Vector") + super(CyclicCodeSurroundingBCHDecoder, self).__init__( + code, code.ambient_space(), "Vector") def __eq__(self, other): r""" @@ -1227,15 +1249,15 @@ def __eq__(self, other): EXAMPLES:: - sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: C = codes.CyclicCode(field=GF(16), length=15, D=[14, 1, 2, 11, 12]) sage: D1 = C.decoder() sage: D2 = C.decoder() sage: D1 == D2 True """ - return isinstance(other, CyclicCodeSurroundingBCHDecoder) \ - and self.code() == other.code()\ - and self.bch_decoder() == other.bch_decoder() + return (isinstance(other, CyclicCodeSurroundingBCHDecoder) and + self.code() == other.code() and + self.bch_decoder() == other.bch_decoder()) def _repr_(self): r""" @@ -1243,12 +1265,13 @@ def _repr_(self): EXAMPLES:: - sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: C = codes.CyclicCode(field=GF(16), length=15, D=[14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D Decoder through the surrounding BCH code of the [15, 10] Cyclic Code over GF(16) """ - return "Decoder through the surrounding BCH code of the %s" % self.code() + return ("Decoder through the surrounding BCH code of the %s" % + self.code()) def _latex_(self): r""" @@ -1256,21 +1279,22 @@ def _latex_(self): EXAMPLES:: - sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: C = codes.CyclicCode(field=GF(16), length=15, D=[14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: latex(D) \textnormal{Decoder through the surrounding BCH code of the }[15, 10] \textnormal{ Cyclic Code over } \Bold{F}_{2^{4}} """ - return "\\textnormal{Decoder through the surrounding BCH code of the }%s"\ - % self.code()._latex_() + return ("\\textnormal{Decoder through the surrounding BCH code of " + "the }%s" % self.code()._latex_()) def bch_code(self): r""" - Returns the surrounding BCH code of :meth:`sage.coding.encoder.Encoder.code`. + Returns the surrounding BCH code of + :meth:`sage.coding.encoder.Encoder.code`. EXAMPLES:: - sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: C = codes.CyclicCode(field=GF(16), length=15, D=[14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D.bch_code() [15, 12] BCH Code over GF(16) with designed distance 4 @@ -1283,7 +1307,7 @@ def bch_decoder(self): EXAMPLES:: - sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: C = codes.CyclicCode(field=GF(16), length=15, D=[14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D.bch_decoder() Decoder through the underlying GRS code of [15, 12] BCH Code over GF(16) with designed distance 4 @@ -1296,10 +1320,11 @@ def decode_to_code(self, y): EXAMPLES:: - sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) - sage: a = GF(16, 'a').gen() + sage: F = GF(16, 'a') + sage: C = codes.CyclicCode(field=F, length=15, D=[14, 1, 2, 11, 12]) + sage: a = F.gen() sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) - sage: y = vector(GF(16, 'a'), [0, a^3, a^3 + a^2 + a, 1, a^2 + 1, a^3 + a^2 + 1, a^3 + a^2 + a, a^3 + a^2 + a, a^2 + a, a^2 + 1, a^2 + a + 1, a^3 + 1, a^2, a^3 + a, a^3 + a]) + sage: y = vector(F, [0, a^3, a^3 + a^2 + a, 1, a^2 + 1, a^3 + a^2 + 1, a^3 + a^2 + a, a^3 + a^2 + a, a^2 + a, a^2 + 1, a^2 + a + 1, a^3 + 1, a^2, a^3 + a, a^3 + a]) sage: D.decode_to_code(y) in C True """ @@ -1311,7 +1336,7 @@ def decoding_radius(self): EXAMPLES:: - sage: C = codes.CyclicCode(field = GF(16, 'a'), length = 15, D = [14, 1, 2, 11, 12]) + sage: C = codes.CyclicCode(field=GF(16), length=15, D=[14, 1, 2, 11, 12]) sage: D = codes.decoders.CyclicCodeSurroundingBCHDecoder(C) sage: D.decoding_radius() 1 From b6973a70f084b8bd9f1134ecc09e821572c77caa Mon Sep 17 00:00:00 2001 From: Ben Hutz Date: Mon, 6 Feb 2017 10:19:05 -0600 Subject: [PATCH 224/370] 22268: use tuple for point coords and map polys --- src/sage/schemes/generic/morphism.py | 8 ++--- .../schemes/projective/projective_morphism.py | 32 ++++++++++++------- .../schemes/projective/projective_point.py | 9 +++--- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index 361c1243315..efcdc467e4a 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -956,7 +956,7 @@ def __init__(self, parent, polys, check=True): except (TypeError, AttributeError): raise TypeError("polys (=%s) must be elements of %s"%(polys, source_ring)) polys = Sequence(polys) - self._polys = polys + self._polys = tuple(polys) SchemeMorphism.__init__(self, parent) def defining_polynomials(self): @@ -974,7 +974,7 @@ def defining_polynomials(self): sage: A. = AffineSpace(R) sage: H = A.Hom(A) sage: H([x^3+y, 1-x-y]).defining_polynomials() - [x^3 + y, -x - y + 1] + (x^3 + y, -x - y + 1) """ return self._polys @@ -1810,9 +1810,7 @@ def __copy__(self): sage: Q2 = copy(Q) sage: Q2 is Q False - sage: Q2._coords is Q._coords - False sage: Q2 == Q True """ - return(self._codomain.point(copy(self._coords), check=False)) + return(self._codomain.point(self._coords, check=False)) diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index d0e12c506a5..6a87e20f126 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -582,10 +582,11 @@ def scale_by(self, t): if isinstance(R, QuotientRing_generic): phi = R._internal_coerce_map_from(self.domain().ambient_space().coordinate_ring()) for i in range(self.codomain().ambient_space().dimension_relative() + 1): - self._polys[i] = phi(self._polys[i] * t).lift() + new_polys = [phi(u*t).lift() for u in self] else: for i in range(self.codomain().ambient_space().dimension_relative() + 1): - self._polys[i] = R(self._polys[i] * t) + new_polys = [R(u*t) for u in self] + self._polys = tuple(new_polys) def normalize_coordinates(self): """ @@ -1438,7 +1439,7 @@ def is_morphism(self): """ R = self.coordinate_ring() - F = self._polys + F = list(self._polys) defpolys = list(self.domain().defining_polynomials()) if R.base_ring().is_field(): F.extend(defpolys) @@ -1536,7 +1537,7 @@ def resultant(self, normalize=False): pass #Otherwise, use Macaulay R = F[0].parent() - res = R.macaulay_resultant(F._polys) + res = R.macaulay_resultant(list(F._polys)) return res #Coercion here is not necessary as it is already done in Macaulay Resultant @cached_method @@ -2286,8 +2287,10 @@ def _multipliermod(self, P, n, p, k): R = self(Q, False) g = gcd(R._coords) R.scale_by(1 / g) + R_list = list(R) for index in range(N + 1): - R._coords[index] = R._coords[index] % (p ** k) + R_list[index] = R_list[index] % (p ** k) + R._coords = tuple(R_list) index = N while R[index] % p == 0: index -= 1 @@ -3833,13 +3836,15 @@ def lift_to_rational_periodic(self, points_modp, B=None): S = newT.nth_iterate(fp, n, normalize = False).change_ring(QQ, check = False) T.scale_by(1 / T[qindex]) S.scale_by(1 / S[qindex]) + newS = list(S) for i in range(N + 1): - S._coords[i] = S._coords[i] - T._coords[i] - if S[i] % (p ** k) != 0 and i != N: + newS[i] = S[i] - T[i] + if newS[i] % (p ** k) != 0 and i != N: bad = 1 break if bad == 1: break + S = PS.point(newS, False) S.scale_by(-1 / p ** k) vecs = [Zmod(p ** k)(S._coords[iS]) for iS in range(N + 1)] vecs.pop(qindex) @@ -3848,11 +3853,13 @@ def lift_to_rational_periodic(self, points_modp, B=None): [newS.append(QQ(newvecs[i])) for i in range(qindex)] newS.append(0) [newS.append(QQ(newvecs[i])) for i in range(qindex, N)] - S = PS.point(newS, False) #don't check for [0,...,0] for i in range(N + 1): - S._coords[i] = S._coords[i] % (p ** k) + newS[i] = newS[i] % (p ** k) + S = PS.point(newS, False) #don't check for [0,...,0] + newT = list(T) for i in range(N + 1): - T._coords[i] += S._coords[i] * (p ** k) + newT[i] += S[i] * (p ** k) + T = PS.point(newT, False) T.normalize_coordinates() #Hensel gives us 2k for the newprecision k = min(2 * k, L) @@ -3866,12 +3873,13 @@ def lift_to_rational_periodic(self, points_modp, B=None): if shifts is None: shifts = xmrange([p for i in range(N)]) for shift in shifts: - newT = T.change_ring(RQ, check = False) + newT = [RQ(t) for t in T] #T.change_ring(RQ, check = False) shiftindex = 0 for i in range(N + 1): if i != qindex: - newT._coords[i] = newT[i] + shift[shiftindex] * p ** k + newT[i] = newT[i] + shift[shiftindex] * p ** k shiftindex += 1 + newT = fp.domain().point(newT, check=False) TT = fp.nth_iterate(newT, n, normalize = False) if TT == newT: if first == 0: diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py index 24ac26c5896..4240edaae6d 100644 --- a/src/sage/schemes/projective/projective_point.py +++ b/src/sage/schemes/projective/projective_point.py @@ -165,7 +165,7 @@ def __init__(self, X, v, check=True): X.extended_codomain()._check_satisfies_equations(v) - self._coords = v + self._coords = tuple(v) def __eq__(self, right): """ @@ -454,10 +454,11 @@ def scale_by(self,t): R = self.codomain().base_ring() if isinstance(R, QuotientRing_generic): for i in range(self.codomain().ambient_space().dimension_relative()+1): - self._coords[i] = R(self._coords[i].lift()*t) + new_coords = [R(u.lift()*t) for u in self] else: for i in range(self.codomain().ambient_space().dimension_relative()+1): - self._coords[i] = R(self._coords[i]*t) + new_coords = [R(u*t) for u in self] + self._coords = tuple(new_coords) def normalize_coordinates(self): """ @@ -1602,7 +1603,7 @@ def __init__(self, X, v, check=True): X.extended_codomain()._check_satisfies_equations(v) - self._coords = v + self._coords = tuple(v) def __hash__(self): """ From b2ee7cd96be91c116b089891e00367fa3cd8cf8f Mon Sep 17 00:00:00 2001 From: Ben Hutz Date: Mon, 6 Feb 2017 17:00:24 -0600 Subject: [PATCH 225/370] 22268: another doctest fix --- src/sage/schemes/elliptic_curves/ell_number_field.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py index b2f33d21dd3..a8a8005925f 100644 --- a/src/sage/schemes/elliptic_curves/ell_number_field.py +++ b/src/sage/schemes/elliptic_curves/ell_number_field.py @@ -2192,7 +2192,8 @@ def torsion_points(self): sage: K. = NumberField(x^4 + x^3 + 11*x^2 + 41*x + 101) sage: EK = E.base_extend(K) sage: EK.torsion_points() # long time (1s on sage.math, 2014) - [(16 : 60 : 1), + [(0 : 1 : 0), + (16 : 60 : 1), (5 : 5 : 1), (5 : -6 : 1), (16 : -61 : 1), @@ -2215,8 +2216,7 @@ def torsion_points(self): (10/121*t^3 + 49/121*t^2 + 168/121*t + 73/121 : -32/121*t^3 - 60/121*t^2 + 261/121*t + 686/121 : 1), (5/121*t^3 - 14/121*t^2 - 158/121*t - 453/121 : 49/121*t^3 + 129/121*t^2 + 315/121*t + 86/121 : 1), (-9/121*t^3 - 21/121*t^2 - 127/121*t - 377/121 : 7/121*t^3 - 24/121*t^2 - 197/121*t - 137/121 : 1), - (-3/55*t^3 - 7/55*t^2 - 2/55*t - 133/55 : -6/55*t^3 - 3/55*t^2 - 25/11*t - 211/55 : 1), - (0 : 1 : 0)] + (-3/55*t^3 - 7/55*t^2 - 2/55*t - 133/55 : -6/55*t^3 - 3/55*t^2 - 25/11*t - 211/55 : 1)] :: From 9f5ab317dc4040e4fe1d5065972f09a942943fd6 Mon Sep 17 00:00:00 2001 From: Ben Hutz Date: Mon, 6 Feb 2017 17:07:52 -0600 Subject: [PATCH 226/370] 22268: general clean-up --- src/sage/schemes/generic/morphism.py | 1 - .../schemes/projective/projective_morphism.py | 48 +++++++++---------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index 9d9e651fee4..21f29a2c91f 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -103,7 +103,6 @@ from sage.misc.constant_function import ConstantFunction from sage.categories.morphism import SetMorphism from sage.categories.morphism import Morphism -from copy import copy from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme coercion_model = get_coercion_model() diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index 148fd5ff57d..f479bd889c1 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -3800,12 +3800,12 @@ def lift_to_rational_periodic(self, points_modp, B=None): R = RealField() #compute the maximum p-adic precision needed to conclusively determine #if the rational point exists - L = R((R(2 ** (N / 2 + 1) * sqrt(N + 1) * B ** 2).log()) / R(p).log() + 1).trunc() + L = R((R(2 ** (N/2 + 1) * sqrt(N+1) * B**2).log()) / R(p).log() + 1).trunc() points = [] for i in range(len(points_modp)): #[point mod p, period, current p-adic precision] - points.append([points_modp[i][0].change_ring(QQ, check = False), points_modp[i][1], 1]) + points.append([points_modp[i][0].change_ring(QQ, check=False), points_modp[i][1], 1]) good_points = [] #shifts is used in non-Hensel lifting shifts = None @@ -3823,30 +3823,30 @@ def lift_to_rational_periodic(self, points_modp, B=None): bad = 0 #stop where we reach the needed precision or the point is bad while k < L and bad == 0: - l = self._multipliermod(T, n, p, 2 * k) + l = self._multipliermod(T, n, p, 2*k) l -= l.parent().one() #f^n(x) - x - lp = l.change_ring(Zmod(p ** k)) + lp = l.change_ring(Zmod(p**k)) ldet = lp.determinant() # if the matrix is invertible then we can Hensel lift if ldet % p != 0: - RQ = ZZ.quo(p ** (2 * k)) + RQ = ZZ.quo(p**(2*k)) T.clear_denominators() - newT = T.change_ring(RQ, check = False) - fp = self.change_ring(RQ, check = False) - S = newT.nth_iterate(fp, n, normalize = False).change_ring(QQ, check = False) + newT = T.change_ring(RQ, check=False) + fp = self.change_ring(RQ, check=False) + S = newT.nth_iterate(fp, n, normalize=False).change_ring(QQ, check=False) T.scale_by(1 / T[qindex]) S.scale_by(1 / S[qindex]) newS = list(S) for i in range(N + 1): newS[i] = S[i] - T[i] - if newS[i] % (p ** k) != 0 and i != N: + if newS[i] % (p**k) != 0 and i != N: bad = 1 break if bad == 1: break S = PS.point(newS, False) - S.scale_by(-1 / p ** k) - vecs = [Zmod(p ** k)(S._coords[iS]) for iS in range(N + 1)] + S.scale_by(-1 / p**k) + vecs = [Zmod(p**k)(S._coords[iS]) for iS in range(N + 1)] vecs.pop(qindex) newvecs = list((lp.inverse()) * vector(vecs)) #l.inverse should be mod p^k!! newS = [] @@ -3854,22 +3854,22 @@ def lift_to_rational_periodic(self, points_modp, B=None): newS.append(0) [newS.append(QQ(newvecs[i])) for i in range(qindex, N)] for i in range(N + 1): - newS[i] = newS[i] % (p ** k) + newS[i] = newS[i] % (p**k) S = PS.point(newS, False) #don't check for [0,...,0] newT = list(T) for i in range(N + 1): - newT[i] += S[i] * (p ** k) + newT[i] += S[i] * (p**k) T = PS.point(newT, False) T.normalize_coordinates() #Hensel gives us 2k for the newprecision - k = min(2 * k, L) + k = min(2*k, L) else: #we are unable to Hensel Lift so must try all possible lifts #to the next precision (k+1) first = 0 newq = [] - RQ = Zmod(p ** (k + 1)) - fp = self.change_ring(RQ, check = False) + RQ = Zmod(p**(k+1)) + fp = self.change_ring(RQ, check=False) if shifts is None: shifts = xmrange([p for i in range(N)]) for shift in shifts: @@ -3877,18 +3877,18 @@ def lift_to_rational_periodic(self, points_modp, B=None): shiftindex = 0 for i in range(N + 1): if i != qindex: - newT[i] = newT[i] + shift[shiftindex] * p ** k + newT[i] = newT[i] + shift[shiftindex] * p**k shiftindex += 1 newT = fp.domain().point(newT, check=False) - TT = fp.nth_iterate(newT, n, normalize = False) + TT = fp.nth_iterate(newT, n, normalize=False) if TT == newT: if first == 0: - newq.append(newT.change_ring(QQ, check = False)) + newq.append(newT.change_ring(QQ, check=False)) newq.append(n) newq.append(k + 1) first = 1 else: - points.append([newT.change_ring(QQ, check = False), n, k + 1]) + points.append([newT.change_ring(QQ, check=False), n, k+1]) if newq == []: bad = 1 break @@ -3903,8 +3903,8 @@ def lift_to_rational_periodic(self, points_modp, B=None): T.clear_denominators() for i in range(N + 1): M[0, i] = T[i] - M[i + 1, i] = p ** L - M[N + 1, N] = p ** L + M[i+1, i] = p**L + M[N+1, N] = p**L M = M.LLL() Q = [] [Q.append(M[1, i]) for i in range(N + 1)] @@ -3922,10 +3922,10 @@ def lift_to_rational_periodic(self, points_modp, B=None): newP = copy(P) k = 1 done = False - while done == False and k <= n: + while not done and k <= n: newP = self(newP) if newP == P: - if ([P, k] in good_points) == False: + if not ([P, k] in good_points): good_points.append([newP, k]) done = True k += 1 From f7b7280f2699c0b5bc771d6831b29dc94b2b8f9b Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Tue, 7 Feb 2017 11:25:49 +0100 Subject: [PATCH 227/370] Add tests and fixed minor bugs. --- src/sage/coding/bch.py | 74 +++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 3dcd375548b..bd2eeb5d8ec 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -4,7 +4,7 @@ Let `F = GF(q)` and `\Phi` be the splitting field of `x^{n} - 1` over `F`, with `n` a positive integer. Let also `\alpha` be an element of multiplicative order `n` in `\Phi`. Finally, let `b, \delta, \ell` be integers such that -`0 \le b \leq n`, `2 \le \delta \leq n` and `\alpha^\ell` generates the +`0 \le b \le n`, `1 \le \delta \le n` and `\alpha^\ell` generates the multiplicative group `\Phi^{\times}`. A BCH code over `F` with designed distance `\delta` is a cyclic code whose @@ -70,7 +70,7 @@ class BCHCode(CyclicCode): polynomial in ``zx``, where ``x`` is the degree of the extension field. For instance, over ``GF(16)``, it has to be a polynomial in ``z4``. - - ``offset`` -- (default: ``0``) the first element in the defining set + - ``offset`` -- (default: ``1``) the first element in the defining set - ``jump_size`` -- (default: ``1``) the jump size between two elements of the defining set. It must be coprime with the multiplicative order of @@ -80,23 +80,41 @@ class BCHCode(CyclicCode): here for retro-compatibility purposes with the old signature of `BCHCode` and will be removed soon. - EXAMPLES:: + EXAMPLES: - sage: C = codes.BCHCode(GF(2), 15, 7, offset = 1) + As explained below, BCH codes can be built through various parameters:: + + sage: C = codes.BCHCode(GF(2), 15, 7, offset=1) sage: C [15, 5] BCH Code over GF(2) with designed distance 7 sage: C.generator_polynomial() x^10 + x^8 + x^5 + x^4 + x^2 + x + 1 - sage: C = codes.BCHCode(GF(2), 15, 4, offset = 1, jump_size = 8) + sage: C = codes.BCHCode(GF(2), 15, 4, offset=1, jump_size=8) sage: C [15, 7] BCH Code over GF(2) with designed distance 4 sage: C.generator_polynomial() x^8 + x^7 + x^6 + x^4 + 1 + + BCH codes are cyclic, and can be interfaced into the CyclicCode class. + The smallest GRS code which contains a given BCH code can also be computed, + and these two codes may be equal:: + + sage: C = codes.BCHCode(GF(16), 15, 7) + sage: R = C.bch_to_grs() + sage: codes.CyclicCode(code=R) == codes.CyclicCode(code=C) + True + + The `\delta = 1` case (trivial full code) also works:: + + sage: C = codes.BCHCode(GF(16), 15, 15) + sage: C.dimension() == 1 + True + """ def __init__(self, base_field, length, designed_distance, - primitive_root=None, offset=0, jump_size=1, b=0): + primitive_root=None, offset=1, jump_size=1, b=0): """ TESTS: @@ -106,10 +124,10 @@ def __init__(self, base_field, length, designed_distance, sage: C = codes.BCHCode(GF(2), 15, 16) Traceback (most recent call last): ... - ValueError: designed_distance must belong to [2, n] + ValueError: designed_distance must belong to [1, n] """ - if not (designed_distance <= length and designed_distance > 1): - raise ValueError("designed_distance must belong to [2, n]") + if not (designed_distance <= length and designed_distance > 0): + raise ValueError("designed_distance must belong to [1, n]") if base_field in ZZ and designed_distance in Fields: from sage.misc.superseded import deprecation deprecation(20335, "codes.BCHCode(n, designed_distance, F, b=0) is now deprecated. Please use the new signature instead.") @@ -153,8 +171,8 @@ def __eq__(self, other): return (isinstance(other, BCHCode) and self.length() == other.length() and self.jump_size() == other.jump_size() and - self.offset() == self.offset() and - self.primitive_root() == self.primitive_root()) + self.offset() == other.offset() and + self.primitive_root() == other.primitive_root()) def _repr_(self): r""" @@ -162,13 +180,13 @@ def _repr_(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 7, offset = 1) + sage: C = codes.BCHCode(GF(2), 15, 7) sage: C [15, 5] BCH Code over GF(2) with designed distance 7 """ - return "[%s, %s] BCH Code over GF(%s) with designed distance %d"\ + return ("[%s, %s] BCH Code over GF(%s) with designed distance %d" % (self.length(), self.dimension(), - self.base_field().cardinality(), self.designed_distance()) + self.base_field().cardinality(), self.designed_distance())) def _latex_(self): r""" @@ -176,7 +194,7 @@ def _latex_(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 7, offset = 1) + sage: C = codes.BCHCode(GF(2), 15, 7) sage: latex(C) [15, 5] \textnormal{ BCH Code over } \Bold{F}_{2} \textnormal{ with designed distance } 7 """ @@ -216,7 +234,7 @@ def designed_distance(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(2), 15, 4, offset = 1) + sage: C = codes.BCHCode(GF(2), 15, 4) sage: C.designed_distance() 4 """ @@ -229,8 +247,11 @@ def bch_to_grs(self): EXAMPLES:: sage: C = codes.BCHCode(GF(2), 15, 3) - sage: C.bch_to_grs() - [15, 13, 3] Generalized Reed-Solomon Code over GF(16) + sage: RS = C.bch_to_grs() + sage: RS + [15, 13, 3] Reed-Solomon Code over GF(16) + sage: C.generator_matrix() * RS.parity_check_matrix().transpose() == 0 + True """ l = self.jump_size() b = self.offset() @@ -271,12 +292,11 @@ def __init__(self, code, grs_decoder="KeyEquationSyndrome", **kwargs): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D Decoder through the underlying GRS code of [15, 11] BCH Code over GF(4) with designed distance 3 """ - self._grs_code = code.bch_to_grs() self._grs_decoder = self._grs_code.decoder(grs_decoder, **kwargs) self._decoder_type = copy(self._decoder_type) @@ -291,7 +311,7 @@ def _repr_(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D Decoder through the underlying GRS code of [15, 11] BCH Code over GF(4) with designed distance 3 @@ -304,7 +324,7 @@ def _latex_(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: latex(D) \textnormal{Decoder through the underlying GRS code of } [15, 11] \textnormal{ BCH Code over } \Bold{F}_{2^{2}} \textnormal{ with designed distance } 3 @@ -322,7 +342,7 @@ def grs_code(self): sage: C = codes.BCHCode(GF(2), 15, 3) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D.grs_code() - [15, 13, 3] Generalized Reed-Solomon Code over GF(16) + [15, 13, 3] Reed-Solomon Code over GF(16) """ return self._grs_code @@ -332,7 +352,7 @@ def grs_decoder(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D.grs_decoder() Key equation decoder for [15, 13, 3] Generalized Reed-Solomon Code over GF(16) @@ -365,7 +385,7 @@ def grs_word_to_bch(self, c): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: Cgrs = D.grs_code() sage: Fgrs = Cgrs.base_field() @@ -387,7 +407,7 @@ def decode_to_code(self, y): sage: F = GF(4, 'a') sage: a = F.gen() - sage: C = codes.BCHCode(F, 15, 3, jump_size=2, offset=1) + sage: C = codes.BCHCode(F, 15, 3, jump_size=2) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: y = vector(F, [a, a + 1, 1, a + 1, 1, a, a + 1, a + 1, 0, 1, a + 1, 1, 1, 1, a]) sage: D.decode_to_code(y) @@ -414,7 +434,7 @@ def decoding_radius(self): EXAMPLES:: - sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2, offset=1) + sage: C = codes.BCHCode(GF(4, 'a'), 15, 3, jump_size=2) sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C) sage: D.decoding_radius() 1 From d4ab8f72f622525cd2edfb9cb74023bf3ddcf558 Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Tue, 7 Feb 2017 13:05:00 +0100 Subject: [PATCH 228/370] Fixed doc --- src/sage/coding/bch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index bd2eeb5d8ec..37ef47decd4 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -118,7 +118,7 @@ def __init__(self, base_field, length, designed_distance, """ TESTS: - ``designed_distance`` must be between 2 and ``length`` (inclusive), + ``designed_distance`` must be between 1 and ``length`` (inclusive), otherwise an exception is raised:: sage: C = codes.BCHCode(GF(2), 15, 16) From 5064ef3d7bd8b6e33c7f27eaf1627d9c585f59fa Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Tue, 7 Feb 2017 13:08:54 +0100 Subject: [PATCH 229/370] Last fix, I hope --- src/sage/coding/bch.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 37ef47decd4..04f3c706d76 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -105,12 +105,13 @@ class BCHCode(CyclicCode): sage: codes.CyclicCode(code=R) == codes.CyclicCode(code=C) True - The `\delta = 1` case (trivial full code) also works:: - + The `\delta = 15` case (trivial full code) also works:: + sage: C = codes.BCHCode(GF(16), 15, 1) + sage: C.dimension() + 15 sage: C = codes.BCHCode(GF(16), 15, 15) - sage: C.dimension() == 1 - True - + sage: C.dimension() + 1 """ def __init__(self, base_field, length, designed_distance, From 32f9cc08aa000b6c9c1c4d77f3fd67f492ea7d2b Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Tue, 7 Feb 2017 13:17:50 +0100 Subject: [PATCH 230/370] Last fix, finally --- src/sage/coding/bch.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 04f3c706d76..1f65bb9b69c 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -105,10 +105,15 @@ class BCHCode(CyclicCode): sage: codes.CyclicCode(code=R) == codes.CyclicCode(code=C) True - The `\delta = 15` case (trivial full code) also works:: + The `\delta = 15, 1` cases (trivial codes) also work:: + sage: C = codes.BCHCode(GF(16), 15, 1) sage: C.dimension() 15 + sage: C.defining_set() + [] + sage: C.generator_polynomial() + 1 sage: C = codes.BCHCode(GF(16), 15, 15) sage: C.dimension() 1 From 8d476b67a6a4e308d20ff365836c35a0a4199d6d Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Tue, 7 Feb 2017 14:31:36 +0100 Subject: [PATCH 231/370] Lazy imports of BCH decoders --- src/sage/coding/decoders_catalog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/coding/decoders_catalog.py b/src/sage/coding/decoders_catalog.py index abca33f93cb..2f11a94f5e0 100644 --- a/src/sage/coding/decoders_catalog.py +++ b/src/sage/coding/decoders_catalog.py @@ -54,6 +54,8 @@ from sage.misc.lazy_import import lazy_import as _lazy_import +_lazy_import('sage.coding.bch', 'BCHUnderlyingGRSDecoder') +_lazy_import('sage.coding.cyclic_code', 'CyclicCodeSurroundingBCHDecoder') _lazy_import('sage.coding.extended_code', 'ExtendedCodeOriginalCodeDecoder') _lazy_import('sage.coding.grs', ['GRSBerlekampWelchDecoder', 'GRSErrorErasureDecoder', From ff8e4ec07cdd839197d8c8bb41f98df4f1d449df Mon Sep 17 00:00:00 2001 From: Frederic HAN Date: Tue, 7 Feb 2017 16:11:12 +0100 Subject: [PATCH 232/370] updtate giac to 1.2.3.25 and configure with --disable-png --- build/pkgs/giac/checksums.ini | 6 +++--- build/pkgs/giac/dependencies | 2 +- build/pkgs/giac/package-version.txt | 2 +- build/pkgs/giac/spkg-install | 4 ++-- build/pkgs/giac/spkg-src | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/pkgs/giac/checksums.ini b/build/pkgs/giac/checksums.ini index 104406326a1..dce20348030 100644 --- a/build/pkgs/giac/checksums.ini +++ b/build/pkgs/giac/checksums.ini @@ -1,4 +1,4 @@ tarball=giac-VERSION.tar.bz2 -sha1=347cabadc3abd405b8abff322c3c25c79dc6ab61 -md5=6ceda58aa27e70efbfc2e04d50d3ed22 -cksum=1481287904 +sha1=8b94822f2b4a56c1d03813c92092204da4b087e1 +md5=aa481a59f17da298012d7c4cf0d58ab1 +cksum=1552927328 diff --git a/build/pkgs/giac/dependencies b/build/pkgs/giac/dependencies index 028266b4dbd..94b0bc460c6 100644 --- a/build/pkgs/giac/dependencies +++ b/build/pkgs/giac/dependencies @@ -1,4 +1,4 @@ -readline $(MP_LIBRARY) mpfr mpfi ntl gsl pari libpng +readline $(MP_LIBRARY) mpfr mpfi ntl gsl pari ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/giac/package-version.txt b/build/pkgs/giac/package-version.txt index bc8adb3c69c..79c520e207d 100644 --- a/build/pkgs/giac/package-version.txt +++ b/build/pkgs/giac/package-version.txt @@ -1 +1 @@ -1.2.3.9 +1.2.3.25 diff --git a/build/pkgs/giac/spkg-install b/build/pkgs/giac/spkg-install index dbae34651e9..d2a81cb729f 100755 --- a/build/pkgs/giac/spkg-install +++ b/build/pkgs/giac/spkg-install @@ -38,7 +38,7 @@ echo "Configuring giac..." # --disable-ao (avoid libao deps) # --disable-lapack (avoid lapack and blas deps because they could be from the base system) - +# --disable-png (avoid conflicts with system libpng12 and sage libpng16) # On OS X (10.12) the built in intl is broken DISABLENLS="" if [ "$UNAME" = "Darwin" ]; then @@ -46,7 +46,7 @@ if [ "$UNAME" = "Darwin" ]; then DISABLENLS="--disable-nls" fi -./configure --prefix="$SAGE_LOCAL" --disable-gui --disable-ao --disable-lapack "$DISABLENLS" +./configure --prefix="$SAGE_LOCAL" --disable-gui --disable-png --disable-ao --disable-lapack "$DISABLENLS" if [ $? -ne 0 ]; then exit 1 diff --git a/build/pkgs/giac/spkg-src b/build/pkgs/giac/spkg-src index 2998fd1b18d..82979e608fd 100755 --- a/build/pkgs/giac/spkg-src +++ b/build/pkgs/giac/spkg-src @@ -15,7 +15,7 @@ set -e # TODO on the next update: l71 switch from gz to bz2 as wished in #18826 VERSION="1.2.3" -VERSIONREV="9" +VERSIONREV="25" # The upstream tarball name is: giac"$SOURCEORIG".tar.gz SOURCEORIG=_"$VERSION"-"$VERSIONREV" From d48aec7fb761dc71b73650efbd4192166a08db1a Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Tue, 7 Feb 2017 16:46:37 +0100 Subject: [PATCH 233/370] Improved decoders and associated doctests for cyclic and BCH codes. --- src/sage/coding/bch.py | 37 +++++++++++++++++++-------- src/sage/coding/code_constructions.py | 2 +- src/sage/coding/cyclic_code.py | 6 ++--- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 1f65bb9b69c..1710b9fe52d 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -305,9 +305,7 @@ def __init__(self, code, grs_decoder="KeyEquationSyndrome", **kwargs): """ self._grs_code = code.bch_to_grs() self._grs_decoder = self._grs_code.decoder(grs_decoder, **kwargs) - self._decoder_type = copy(self._decoder_type) - self._decoder_type.remove("dynamic") - self._decoder_type = self._grs_decoder.decoder_type() + self._decoder_type = copy(self._grs_decoder.decoder_type()) super(BCHUnderlyingGRSDecoder, self).__init__( code, code.ambient_space(), "Vector") @@ -381,7 +379,7 @@ def bch_word_to_grs(self, c): True """ mapping = self.code().field_embedding().embedding() - a = [mapping(i) for i in c] + a = map(mapping, c) return vector(a) def grs_word_to_bch(self, c): @@ -420,17 +418,36 @@ def decode_to_code(self, y): (a, a + 1, 1, a + 1, 1, a, a + 1, a + 1, 0, 1, a + 1, 1, 1, 1, a) sage: D.decode_to_code(y) in C True + + We check it still works when, while list-decoding, the GRS decoder output words which + does not lie in the BCH code:: + + sage: C = codes.BCHCode(GF(2), 31, 15) + sage: C + [31, 6] BCH Code over GF(2) with designed distance 15 + sage: D = codes.decoders.BCHUnderlyingGRSDecoder(C, "GuruswamiSudan", tau=8) + sage: Dgrs = D.grs_decoder() + sage: c = vector(GF(2), [1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0]) + sage: y = vector(GF(2), [1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0]) + sage: print (c in C and (c-y).hamming_weight() == 8) + True + sage: Dgrs.decode_to_code(y) + [(1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0), (1, z5^3 + z5^2 + z5 + 1, z5^4 + z5^2 + z5, z5^4 + z5^3 + z5^2 + 1, 0, 0, z5^4 + z5 + 1, 1, z5^4 + z5^2 + z5, 0, 1, z5^4 + z5, 1, 0, 1, 1, 1, 0, 0, z5^4 + z5^3 + 1, 1, 0, 1, 1, 1, 1, z5^4 + z5^3 + z5 + 1, 1, 1, 0, 0)] + sage: D.decode_to_code(y) == [c] + True """ D = self.grs_decoder() ygrs = self.bch_word_to_grs(y) - try: - cgrs = D.decode_to_code(ygrs) - except DecodingError, e: - raise e + cgrs = D.decode_to_code(ygrs) if "list-decoder" in D.decoder_type(): l = [] for c in cgrs: - l.append(self.grs_word_to_bch(c)) + try: + c_bch = self.grs_word_to_bch(c) + if c_bch in self.code(): + l.append(c_bch) + except ValueError, e: + pass return l return self.grs_word_to_bch(cgrs) @@ -445,7 +462,7 @@ def decoding_radius(self): sage: D.decoding_radius() 1 """ - return (self.code().bch_bound(arithmetic=True)[0] - 1) // 2 + return self.grs_decoder().decoding_radius() ####################### registration ############################### diff --git a/src/sage/coding/code_constructions.py b/src/sage/coding/code_constructions.py index a63f520cf76..35ff2362c47 100644 --- a/src/sage/coding/code_constructions.py +++ b/src/sage/coding/code_constructions.py @@ -5,7 +5,7 @@ of special (or random) linear codes and wraps them in a :class:`sage.coding.linear_code.LinearCode` object. These constructions are therefore not rich objects such as -:class:`sage.coding.grs.GeneralizedReedSolomonCodes`. +:class:`sage.coding.grs.GeneralizedReedSolomonCode`. For deprecation reasons, this file also contains some constructions for which Sage now does have rich representations. diff --git a/src/sage/coding/cyclic_code.py b/src/sage/coding/cyclic_code.py index ded7f9dd144..17d54f3e8ca 100644 --- a/src/sage/coding/cyclic_code.py +++ b/src/sage/coding/cyclic_code.py @@ -1237,9 +1237,7 @@ def __init__(self, code, **kwargs): """ self._bch_code = code.surrounding_bch_code() self._bch_decoder = self._bch_code.decoder(**kwargs) - self._decoder_type = copy(self._decoder_type) - self._decoder_type.remove("dynamic") - self._decoder_type = self._bch_decoder.decoder_type() + self._decoder_type = copy(self._bch_decoder.decoder_type()) super(CyclicCodeSurroundingBCHDecoder, self).__init__( code, code.ambient_space(), "Vector") @@ -1341,7 +1339,7 @@ def decoding_radius(self): sage: D.decoding_radius() 1 """ - return (self.code().bch_bound(arithmetic=True)[0] - 1) // 2 + return self._bch_decoder.decoding_radius() ####################### registration ############################### From 99234ce72f96874130c8c175177c2dff2bcb1edc Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Tue, 7 Feb 2017 23:45:32 +0100 Subject: [PATCH 234/370] Improved the doc for the underlying GRS code of a BCH code --- src/sage/coding/bch.py | 59 ++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 1710b9fe52d..0c42bf1690e 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -61,14 +61,14 @@ class BCHCode(CyclicCode): - ``length`` -- the length of the code - - ``designed_distance`` -- the resulting minimum distance of the code + - ``designed_distance`` -- the designed minimum distance of the code - ``primitive_root`` -- (default: ``None``) the primitive root to use when creating the set of roots for the generating polynomial over the splitting field. It has to be of multiplicative order ``length`` over this field. If the splitting field is not ``field``, it also has to be a polynomial in ``zx``, where ``x`` is the degree of the extension field. - For instance, over ``GF(16)``, it has to be a polynomial in ``z4``. + For instance, over `GF(16)`, it has to be a polynomial in ``z4``. - ``offset`` -- (default: ``1``) the first element in the defining set @@ -77,12 +77,12 @@ class BCHCode(CyclicCode): ``primitive_root``. - ``b`` -- (default: ``0``) is exactly the same as ``offset``. It is only - here for retro-compatibility purposes with the old signature of `BCHCode` - and will be removed soon. + here for retro-compatibility purposes with the old signature of + :meth:`codes.BCHCode` and will be removed soon. EXAMPLES: - As explained below, BCH codes can be built through various parameters:: + As explained above, BCH codes can be built through various parameters:: sage: C = codes.BCHCode(GF(2), 15, 7, offset=1) sage: C @@ -151,11 +151,8 @@ def __init__(self, base_field, length, designed_distance, D = [(offset + jump_size * i) % length for i in range(designed_distance - 1)] - try: - super(BCHCode, self).__init__(field=base_field, length=length, - D=D, primitive_root=primitive_root) - except ValueError, e: - raise e + super(BCHCode, self).__init__(field=base_field, length=length, + D=D, primitive_root=primitive_root) self._default_decoder_name = "UnderlyingGRS" self._jump_size = jump_size self._offset = offset @@ -338,8 +335,39 @@ def _latex_(self): def grs_code(self): r""" - Returns the underlying GRS code of - :meth:`sage.coding.decoder.Decoder.code`. + Returns the underlying GRS code of :meth:`sage.coding.decoder.Decoder.code`. + + .. NOTE:: + + Let us explain what is the underlying GRS code of a BCH code of + length `n` over `F` with parameters `b, \delta, \ell`. Let + `c \in F^n` and `\alpha` a primitive root of the splitting field. + We know: + + .. MATH:: + + \begin{aligned} + c \in \mathrm{BCH} &\iff \forall j \in \{0,\dots,\delta-2\},\, \sum_{i=0}^{n-1} c_i (\alpha^{b + \ell j})^i \\ + & \iff H c = 0 \text{ where } H = A \times D \text{ with: } \\ + A = &\, \begin{pmatrix} + 1 & \dots & 1 \\ + ~ & ~ & ~ \\ + (\alpha^{0 \times \ell})^{\delta-2} & \dots & (\alpha^{(n-1) \ell})^{\delta-2} + \end{pmatrix} \quad \text{ and } \quad + D = \begin{pmatrix} + 1 & 0 & \dots & 0 \\ + 0 & \alpha^b & ~ & ~ \\ + \dots & & \dots & 0 \\ + 0 & \dots & 0 & \alpha^{b(n-1)} \end{pmatrix} + \end{aligned} + + Said differently `c` is orthogonal to the GRS code of dimension + `\delta - 1` with evaluation points + `\{1 = \alpha^{0 \times \ell}, \dots, \alpha^{(n-1) \ell} \}` + and associated multipliers + `\{1 = \alpha^{0 \times b}, \dots, \alpha^{(n-1) b} \}`. + The underlying GRS code (a GRS code which contains the BCH code) + can be deduced from it by duality. EXAMPLES:: @@ -384,8 +412,7 @@ def bch_word_to_grs(self, c): def grs_word_to_bch(self, c): r""" - Returns ``c`` converted as a codeword of - :meth:`sage.coding.decoder.Decoder.code`. + Returns ``c`` converted as a codeword of :meth:`sage.coding.decoder.Decoder.code`. EXAMPLES:: @@ -419,8 +446,8 @@ def decode_to_code(self, y): sage: D.decode_to_code(y) in C True - We check it still works when, while list-decoding, the GRS decoder output words which - does not lie in the BCH code:: + We check that it still works when, while list-decoding, the GRS decoder + output some words which do not lie in the BCH code:: sage: C = codes.BCHCode(GF(2), 31, 15) sage: C From bf2c3bbf44824e38c0374026cd8e7536b7b99291 Mon Sep 17 00:00:00 2001 From: Julien Lavauzelle Date: Wed, 8 Feb 2017 10:18:37 +0100 Subject: [PATCH 235/370] Made maths cleaner --- src/sage/coding/bch.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/sage/coding/bch.py b/src/sage/coding/bch.py index 0c42bf1690e..037adc622b1 100644 --- a/src/sage/coding/bch.py +++ b/src/sage/coding/bch.py @@ -344,30 +344,38 @@ def grs_code(self): `c \in F^n` and `\alpha` a primitive root of the splitting field. We know: + + .. MATH:: + + \begin{aligned} + c \in \mathrm{BCH} &\iff \sum_{i=0}^{n-1} c_i (\alpha^{b + \ell j})^i =0, \quad j=0,\dots,\delta-2\\ + & \iff H c = 0 + \end{aligned} + + + where `H = A \times D` with: + .. MATH:: \begin{aligned} - c \in \mathrm{BCH} &\iff \forall j \in \{0,\dots,\delta-2\},\, \sum_{i=0}^{n-1} c_i (\alpha^{b + \ell j})^i \\ - & \iff H c = 0 \text{ where } H = A \times D \text{ with: } \\ A = &\, \begin{pmatrix} 1 & \dots & 1 \\ ~ & ~ & ~ \\ (\alpha^{0 \times \ell})^{\delta-2} & \dots & (\alpha^{(n-1) \ell})^{\delta-2} - \end{pmatrix} \quad \text{ and } \quad - D = \begin{pmatrix} + \end{pmatrix}\\ + D =&\, \begin{pmatrix} 1 & 0 & \dots & 0 \\ 0 & \alpha^b & ~ & ~ \\ \dots & & \dots & 0 \\ 0 & \dots & 0 & \alpha^{b(n-1)} \end{pmatrix} \end{aligned} - Said differently `c` is orthogonal to the GRS code of dimension + The BCH code is orthogonal to the GRS code `C'` of dimension `\delta - 1` with evaluation points `\{1 = \alpha^{0 \times \ell}, \dots, \alpha^{(n-1) \ell} \}` and associated multipliers `\{1 = \alpha^{0 \times b}, \dots, \alpha^{(n-1) b} \}`. - The underlying GRS code (a GRS code which contains the BCH code) - can be deduced from it by duality. + The underlying GRS code is the dual code of `C'`. EXAMPLES:: From 0361f4129f1021cb518f418e8b35978a6dba0e96 Mon Sep 17 00:00:00 2001 From: paulmasson Date: Fri, 17 Feb 2017 16:38:24 -0800 Subject: [PATCH 236/370] Modify default lighting --- src/ext/threejs/threejs_template.html | 41 ++++++++++++++------------- src/sage/plot/plot3d/base.pyx | 7 +++-- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/ext/threejs/threejs_template.html b/src/ext/threejs/threejs_template.html index bf356f80723..2912cb0be52 100644 --- a/src/ext/threejs/threejs_template.html +++ b/src/ext/threejs/threejs_template.html @@ -31,15 +31,6 @@ // will be replaced with an option set in Python by the user var animate = false; // options.animate; - var lights = SAGE_LIGHTS; - for ( var i=0 ; i < lights.length ; i++ ) { - var light = new THREE.DirectionalLight( 0xdddddd, 1 ); - light.position.set( lights[i].x, lights[i].y, lights[i].z ); - scene.add( light ); - } - - scene.add( new THREE.AmbientLight( 0x404040, 1 ) ); - var b = SAGE_BOUNDS; // bounds if ( b[0].x === b[1].x ) { @@ -70,8 +61,6 @@ var yMid = ( b[0].y + b[1].y ) / 2; var zMid = ( b[0].z + b[1].z ) / 2; - scene.position.set( -a[0]*xMid, -a[1]*yMid, -a[2]*zMid ); - var box = new THREE.Geometry(); box.vertices.push( new THREE.Vector3( a[0]*b[0].x, a[1]*b[0].y, a[2]*b[0].z ) ); box.vertices.push( new THREE.Vector3( a[0]*b[1].x, a[1]*b[1].y, a[2]*b[1].z ) ); @@ -105,10 +94,6 @@ addLabel( ( b[1].z ).toFixed(d), a[0]*b[1].x, a[1]*b[0].y-offset, a[2]*b[1].z ); } - var texts = SAGE_TEXTS; - for ( var i=0 ; i < texts.length ; i++ ) - addLabel( texts[i].text, texts[i].x, texts[i].y, texts[i].z ); - function addLabel( text, x, y, z ) { var fontsize = 14; @@ -136,11 +121,24 @@ var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 1000 ); camera.up.set( 0, 0, 1 ); - var cameraOut = Math.max( a[0]*xRange, a[1]*yRange, a[2]*zRange ); - camera.position.set( cameraOut, cameraOut, cameraOut ); - camera.lookAt( scene.position ); + camera.position.set( a[0]*(xMid+xRange), a[1]*(yMid+yRange), a[2]*(zMid+zRange) ); + + var lights = SAGE_LIGHTS; + for ( var i=0 ; i < lights.length ; i++ ) { + var light = new THREE.DirectionalLight( 0xdddddd, 1 ); + light.position.set( a[0]*lights[i].x, a[1]*lights[i].y, a[2]*lights[i].z ); + if ( lights[i].parent === 'camera' ) { + light.target.position.set( a[0]*xMid, a[1]*yMid, a[2]*zMid ); + scene.add( light.target ); + camera.add( light ); + } else scene.add( light ); + } + scene.add( camera ); + + scene.add( new THREE.AmbientLight( 0x404040, 1 ) ); var controls = new THREE.OrbitControls( camera, renderer.domElement ); + controls.target.set( a[0]*xMid, a[1]*yMid, a[2]*zMid ); controls.addEventListener( 'change', function() { if ( !animate ) render(); } ); window.addEventListener( 'resize', function() { @@ -151,7 +149,11 @@ if ( !animate ) render(); } ); - + + var texts = SAGE_TEXTS; + for ( var i=0 ; i < texts.length ; i++ ) + addLabel( texts[i].text, texts[i].x, texts[i].y, texts[i].z ); + var points = SAGE_POINTS; for ( var i=0 ; i < points.length ; i++ ) addPoint( points[i] ); @@ -252,6 +254,7 @@ } render(); + controls.update(); if ( !animate ) render(); diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx index 95e13c15bb9..6440d93eb94 100644 --- a/src/sage/plot/plot3d/base.pyx +++ b/src/sage/plot/plot3d/base.pyx @@ -371,12 +371,13 @@ cdef class Graphics3d(SageObject): if not options['frame']: options['axes_labels'] = False - lights = "[{x:0, y:0, z:10}, {x:0, y:0, z:-10}]" - b = self.bounding_box() bounds = "[{{x:{}, y:{}, z:{}}}, {{x:{}, y:{}, z:{}}}]".format( b[0][0], b[0][1], b[0][2], b[1][0], b[1][1], b[1][2]) + lights = '[{"x":10, "y":0, "z":0, "parent":"camera"}, \ + {"x":-10, "y":0, "z":0, "parent":"camera"}]' + import json points, lines, texts = [], [], [] if not hasattr(self, 'all'): @@ -414,8 +415,8 @@ cdef class Graphics3d(SageObject): f.close() html = html.replace('SAGE_OPTIONS', json.dumps(options)) - html = html.replace('SAGE_LIGHTS', lights) html = html.replace('SAGE_BOUNDS', bounds) + html = html.replace('SAGE_LIGHTS', lights) html = html.replace('SAGE_TEXTS', str(texts)) html = html.replace('SAGE_POINTS', str(points)) html = html.replace('SAGE_LINES', str(lines)) From b9669295447be7d5b81ed8a012692ffa119922d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jori=20M=C3=A4ntysalo?= Date: Sat, 18 Feb 2017 11:56:48 +0200 Subject: [PATCH 237/370] EXAMPLE:: -> EXAMPLES:: --- .../finite_dimensional_algebra_morphism.py | 2 +- src/sage/algebras/group_algebra.py | 2 +- .../free_algebra_element_letterplace.pyx | 18 +- .../letterplace/free_algebra_letterplace.pyx | 32 +- src/sage/arith/misc.py | 2 +- src/sage/calculus/transforms/fft.pyx | 12 +- src/sage/categories/additive_magmas.py | 2 +- src/sage/categories/category.py | 2 +- src/sage/categories/coxeter_groups.py | 2 +- src/sage/categories/functor.pyx | 4 +- src/sage/categories/map.pyx | 18 +- src/sage/categories/pushout.py | 32 +- src/sage/categories/rings.py | 10 +- src/sage/coding/binary_code.pyx | 70 ++-- .../coding/codecan/autgroup_can_label.pyx | 2 +- src/sage/coding/linear_code.py | 2 +- src/sage/coding/source_coding/huffman.py | 2 +- src/sage/combinat/binary_tree.py | 2 +- src/sage/combinat/core.py | 2 +- src/sage/combinat/crystals/tensor_product.py | 2 +- src/sage/combinat/debruijn_sequence.pyx | 8 +- src/sage/combinat/degree_sequences.pyx | 6 +- src/sage/combinat/designs/bibd.py | 10 +- src/sage/combinat/designs/block_design.py | 2 +- src/sage/combinat/designs/covering_design.py | 2 +- src/sage/combinat/designs/database.py | 48 +-- src/sage/combinat/designs/ext_rep.py | 2 +- .../designs/group_divisible_designs.py | 10 +- .../combinat/designs/incidence_structures.py | 14 +- .../combinat/designs/orthogonal_arrays.py | 10 +- .../orthogonal_arrays_build_recursive.py | 4 +- .../orthogonal_arrays_find_recursive.pyx | 8 +- src/sage/combinat/designs/resolvable_bibd.py | 8 +- .../designs/steiner_quadruple_systems.py | 14 +- .../combinat/designs/subhypergraph_search.pyx | 4 +- src/sage/combinat/dlx.py | 2 +- src/sage/combinat/finite_state_machine.py | 14 +- .../finite_state_machine_generators.py | 4 +- src/sage/combinat/free_module.py | 2 +- src/sage/combinat/matrices/hadamard_matrix.py | 4 +- src/sage/combinat/matrices/latin.py | 6 +- src/sage/combinat/ordered_tree.py | 4 +- src/sage/combinat/partition.py | 6 +- src/sage/combinat/partition_tuple.py | 16 +- src/sage/combinat/perfect_matching.py | 2 +- src/sage/combinat/permutation.py | 4 +- src/sage/combinat/rooted_tree.py | 2 +- src/sage/combinat/shuffle.py | 4 +- src/sage/combinat/subword_complex.py | 4 +- src/sage/combinat/tableau.py | 2 +- src/sage/combinat/tableau_tuple.py | 2 +- src/sage/combinat/words/finite_word.py | 2 +- src/sage/combinat/words/words.py | 2 +- src/sage/crypto/boolean_function.pyx | 46 +-- src/sage/crypto/lfsr.py | 2 +- src/sage/crypto/lwe.py | 36 +- .../crypto/mq/mpolynomialsystemgenerator.py | 20 +- src/sage/crypto/mq/sbox.py | 40 +- src/sage/crypto/mq/sr.py | 102 +++--- src/sage/crypto/stream_cipher.py | 10 +- src/sage/data_structures/bitset.pyx | 2 +- src/sage/databases/stein_watkins.py | 2 +- src/sage/doctest/fixtures.py | 16 +- src/sage/dynamics/interval_exchanges/iet.py | 2 +- .../dynamics/interval_exchanges/labelled.py | 12 +- .../dynamics/interval_exchanges/reduced.py | 4 +- src/sage/finance/time_series.pyx | 4 +- src/sage/functions/piecewise.py | 2 +- src/sage/functions/piecewise_old.py | 16 +- src/sage/games/sudoku.py | 16 +- src/sage/geometry/fan_isomorphism.py | 2 +- src/sage/geometry/lattice_polytope.py | 2 +- src/sage/geometry/polyhedron/base.py | 4 +- src/sage/geometry/polyhedron/parent.py | 2 +- src/sage/geometry/polyhedron/plot.py | 4 +- src/sage/geometry/pseudolines.py | 10 +- .../triangulation/point_configuration.py | 2 +- src/sage/graphs/base/c_graph.pyx | 64 ++-- src/sage/graphs/base/dense_graph.pyx | 30 +- src/sage/graphs/base/graph_backends.pyx | 12 +- src/sage/graphs/base/sparse_graph.pyx | 36 +- src/sage/graphs/base/static_dense_graph.pyx | 2 +- .../graphs/base/static_sparse_backend.pyx | 20 +- src/sage/graphs/base/static_sparse_graph.pyx | 6 +- src/sage/graphs/bipartite_graph.py | 20 +- src/sage/graphs/comparability.pyx | 4 +- src/sage/graphs/convexity_properties.pyx | 8 +- src/sage/graphs/digraph_generators.py | 14 +- src/sage/graphs/distances_all_pairs.pyx | 8 +- src/sage/graphs/generators/degree_sequence.py | 4 +- src/sage/graphs/generators/families.py | 14 +- src/sage/graphs/generators/intersection.py | 2 +- src/sage/graphs/generators/random.py | 6 +- src/sage/graphs/generators/smallgraphs.py | 34 +- src/sage/graphs/generators/world_map.py | 2 +- src/sage/graphs/generic_graph.py | 10 +- src/sage/graphs/generic_graph_pyx.pyx | 20 +- src/sage/graphs/graph_coloring.py | 4 +- src/sage/graphs/graph_database.py | 20 +- .../graph_decompositions/fast_digraph.pyx | 2 +- .../graphs/graph_decompositions/rankwidth.pyx | 6 +- src/sage/graphs/graph_generators_pyx.pyx | 2 +- src/sage/graphs/graph_input.py | 18 +- src/sage/graphs/graph_list.py | 10 +- src/sage/graphs/graph_plot.py | 10 +- src/sage/graphs/hypergraph_generators.py | 2 +- src/sage/graphs/isgci.py | 28 +- src/sage/graphs/partial_cube.py | 4 +- src/sage/graphs/pq_trees.py | 20 +- src/sage/graphs/print_graphs.py | 10 +- src/sage/graphs/schnyder.py | 2 +- src/sage/graphs/strongly_regular_db.pyx | 40 +- src/sage/groups/abelian_gps/abelian_group.py | 12 +- .../abelian_gps/abelian_group_element.py | 2 +- src/sage/groups/abelian_gps/element_base.py | 2 +- src/sage/groups/abelian_gps/values.py | 2 +- .../additive_abelian_group.py | 20 +- .../additive_abelian_wrapper.py | 18 +- src/sage/groups/group.pyx | 2 +- src/sage/groups/matrix_gps/group_element.pyx | 2 +- src/sage/groups/old.pyx | 2 +- .../perm_gps/partn_ref/refinement_graphs.pyx | 2 +- .../perm_gps/partn_ref/refinement_lists.pyx | 2 +- .../partn_ref/refinement_matrices.pyx | 4 +- .../perm_gps/partn_ref/refinement_python.pyx | 42 +-- src/sage/groups/perm_gps/permgroup.py | 6 +- .../groups/perm_gps/permgroup_element.pyx | 6 +- src/sage/groups/perm_gps/permgroup_named.py | 2 +- src/sage/homology/simplicial_complex.py | 2 +- src/sage/interfaces/expect.py | 10 +- src/sage/interfaces/genus2reduction.py | 2 +- src/sage/interfaces/giac.py | 2 +- src/sage/interfaces/macaulay2.py | 4 +- src/sage/interfaces/magma.py | 16 +- src/sage/interfaces/maple.py | 2 +- src/sage/interfaces/mwrank.py | 4 +- src/sage/interfaces/qepcad.py | 12 +- src/sage/interfaces/sage0.py | 2 +- src/sage/interfaces/singular.py | 26 +- src/sage/lfunctions/dokchitser.py | 2 +- src/sage/libs/cypari2/gen.pyx | 4 +- src/sage/libs/cypari2/handle_error.pyx | 2 +- src/sage/libs/cypari2/pari_instance.pyx | 2 +- src/sage/libs/ecl.pyx | 4 +- src/sage/libs/eclib/interface.py | 6 +- src/sage/libs/eclib/mwrank.pyx | 8 +- src/sage/libs/flint/nmod_poly_linkage.pxi | 36 +- src/sage/libs/gap/element.pyx | 2 +- src/sage/libs/giac.py | 6 +- src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi | 2 +- src/sage/libs/ntl/ntl_mat_GF2.pyx | 8 +- src/sage/libs/ntl/ntl_mat_GF2E.pyx | 6 +- src/sage/libs/pynac/pynac.pyx | 2 +- src/sage/libs/ratpoints.pyx | 2 +- src/sage/libs/singular/function.pyx | 60 +-- src/sage/libs/singular/function_factory.py | 4 +- src/sage/libs/singular/groebner_strategy.pyx | 24 +- src/sage/libs/singular/option.pyx | 38 +- src/sage/libs/singular/polynomial.pyx | 20 +- src/sage/libs/singular/ring.pyx | 2 +- src/sage/libs/singular/standard_options.py | 6 +- src/sage/manifolds/coord_func.py | 2 +- .../differentiable/levi_civita_connection.py | 4 +- src/sage/manifolds/differentiable/manifold.py | 6 +- .../differentiable/manifold_homset.py | 2 +- src/sage/manifolds/differentiable/metric.py | 2 +- .../manifolds/differentiable/scalarfield.py | 2 +- .../differentiable/vectorfield_module.py | 6 +- src/sage/manifolds/manifold_homset.py | 4 +- src/sage/manifolds/scalarfield.py | 2 +- src/sage/manifolds/scalarfield_algebra.py | 2 +- src/sage/manifolds/structure.py | 4 +- src/sage/manifolds/utilities.py | 2 +- src/sage/matrix/matrix0.pyx | 2 +- src/sage/matrix/matrix2.pyx | 20 +- src/sage/matrix/matrix_dense.pyx | 2 +- src/sage/matrix/matrix_gf2e_dense.pyx | 56 +-- src/sage/matrix/matrix_gfpn_dense.pyx | 20 +- src/sage/matrix/matrix_integer_dense.pyx | 10 +- src/sage/matrix/matrix_integer_sparse.pyx | 4 +- src/sage/matrix/matrix_mod2_dense.pyx | 52 +-- src/sage/matrix/matrix_modn_dense_double.pyx | 6 +- .../matrix/matrix_modn_dense_template.pxi | 24 +- src/sage/matrix/matrix_modn_sparse.pyx | 8 +- src/sage/matrix/matrix_mpolynomial_dense.pyx | 2 +- src/sage/matrix/matrix_rational_dense.pyx | 2 +- src/sage/matrix/matrix_rational_sparse.pyx | 2 +- src/sage/matrix/matrix_space.py | 2 +- src/sage/matrix/matrix_sparse.pyx | 2 +- src/sage/matrix/operation_table.py | 12 +- src/sage/matrix/special.py | 2 +- src/sage/matrix/strassen.pyx | 2 +- src/sage/misc/benchmark.py | 2 +- src/sage/misc/cachefunc.pyx | 14 +- src/sage/misc/explain_pickle.py | 2 +- src/sage/misc/function_mangling.pyx | 4 +- src/sage/misc/messaging.py | 2 +- src/sage/misc/method_decorator.py | 2 +- src/sage/misc/misc.py | 12 +- src/sage/misc/object_multiplexer.py | 8 +- src/sage/misc/package.py | 6 +- src/sage/misc/profiler.py | 2 +- src/sage/misc/rest_index_of_methods.py | 8 +- src/sage/misc/sageinspect.py | 2 +- src/sage/modular/abvar/constructor.py | 2 +- src/sage/modular/abvar/homology.py | 4 +- src/sage/modular/abvar/torsion_subgroup.py | 2 +- .../modular/arithgroup/arithgroup_element.pyx | 8 +- .../modular/arithgroup/arithgroup_generic.py | 26 +- .../modular/arithgroup/arithgroup_perm.py | 12 +- src/sage/modular/arithgroup/congroup_gamma.py | 12 +- .../modular/arithgroup/congroup_gamma0.py | 6 +- .../modular/arithgroup/congroup_gamma1.py | 8 +- .../modular/arithgroup/congroup_gammaH.py | 20 +- .../modular/arithgroup/congroup_generic.py | 24 +- src/sage/modular/arithgroup/congroup_sl2z.py | 4 +- src/sage/modular/btquotients/btquotient.py | 2 +- src/sage/modular/buzzard.py | 2 +- src/sage/modular/cusps.py | 2 +- src/sage/modular/cusps_nf.py | 2 +- src/sage/modular/dirichlet.py | 8 +- src/sage/modular/etaproducts.py | 22 +- src/sage/modular/hecke/algebra.py | 24 +- src/sage/modular/hecke/ambient_module.py | 40 +- src/sage/modular/hecke/element.py | 4 +- src/sage/modular/hecke/hecke_operator.py | 18 +- src/sage/modular/hecke/homspace.py | 2 +- src/sage/modular/hecke/module.py | 64 ++-- src/sage/modular/hecke/morphism.py | 4 +- src/sage/modular/hecke/submodule.py | 2 +- src/sage/modular/local_comp/liftings.py | 8 +- src/sage/modular/local_comp/local_comp.py | 46 +-- src/sage/modular/local_comp/smoothchar.py | 80 ++-- src/sage/modular/local_comp/type_space.py | 40 +- src/sage/modular/modform/ambient.py | 2 +- src/sage/modular/modform/ambient_R.py | 4 +- src/sage/modular/modform/ambient_g0.py | 2 +- src/sage/modular/modform/ambient_g1.py | 4 +- .../modular/modform/cuspidal_submodule.py | 12 +- src/sage/modular/modform/eis_series.py | 2 +- .../modular/modform/eisenstein_submodule.py | 8 +- src/sage/modular/modform/element.py | 8 +- src/sage/modular/modform/find_generators.py | 16 +- src/sage/modular/modform/space.py | 4 +- src/sage/modular/modsym/boundary.py | 2 +- src/sage/modular/modsym/element.py | 26 +- src/sage/modular/modsym/g1list.py | 14 +- src/sage/modular/modsym/ghlist.py | 12 +- src/sage/modular/modsym/manin_symbol.pyx | 2 +- src/sage/modular/modsym/manin_symbol_list.py | 34 +- src/sage/modular/modsym/relation_matrix.py | 10 +- src/sage/modular/modsym/space.py | 26 +- src/sage/modular/overconvergent/genus0.py | 46 +-- .../modular/overconvergent/hecke_series.py | 2 +- .../modular/overconvergent/weightspace.py | 28 +- src/sage/modular/pollack_stevens/dist.pyx | 6 +- .../modular/pollack_stevens/distributions.py | 14 +- src/sage/modular/pollack_stevens/manin_map.py | 2 +- src/sage/modular/pollack_stevens/modsym.py | 2 +- .../modular/pollack_stevens/padic_lseries.py | 6 +- src/sage/modular/pollack_stevens/sigma0.py | 40 +- src/sage/modular/pollack_stevens/space.py | 2 +- src/sage/modular/quatalg/brandt.py | 2 +- src/sage/modular/ssmod/ssmod.py | 4 +- src/sage/modules/fg_pid/fgp_module.py | 6 +- src/sage/modules/finite_submodule_iter.pyx | 4 +- src/sage/modules/free_module.py | 8 +- src/sage/modules/free_module_homspace.py | 2 +- src/sage/modules/free_module_integer.py | 12 +- src/sage/modules/free_module_morphism.py | 2 +- src/sage/modules/matrix_morphism.py | 2 +- src/sage/modules/vector_double_dense.pyx | 12 +- src/sage/modules/vector_mod2_dense.pyx | 30 +- src/sage/modules/vector_space_homspace.py | 2 +- src/sage/modules/vector_space_morphism.py | 4 +- src/sage/numerical/backends/coin_backend.pyx | 72 ++-- src/sage/numerical/backends/cplex_backend.pyx | 66 ++-- .../numerical/backends/cvxopt_backend.pyx | 56 +-- .../numerical/backends/cvxopt_sdp_backend.pyx | 44 +-- .../numerical/backends/generic_backend.pyx | 88 ++--- .../backends/generic_sdp_backend.pyx | 44 +-- src/sage/numerical/backends/glpk_backend.pyx | 114 +++--- .../numerical/backends/glpk_exact_backend.pyx | 8 +- .../numerical/backends/glpk_graph_backend.pyx | 52 +-- .../numerical/backends/gurobi_backend.pyx | 60 +-- .../backends/interactivelp_backend.pyx | 76 ++-- src/sage/numerical/backends/ppl_backend.pyx | 54 +-- src/sage/numerical/linear_functions.pyx | 20 +- .../numerical/linear_tensor_constraints.py | 6 +- src/sage/numerical/linear_tensor_element.pyx | 12 +- src/sage/numerical/mip.pyx | 82 ++--- src/sage/numerical/sdp.pyx | 34 +- src/sage/parallel/map_reduce.py | 16 +- src/sage/plot/animate.py | 4 +- src/sage/plot/graphics.py | 2 +- src/sage/plot/plot3d/index_face_set.pyx | 4 +- src/sage/plot/plot3d/parametric_surface.pyx | 4 +- src/sage/plot/plot3d/plot3d.py | 10 +- .../probability/probability_distribution.pyx | 36 +- .../quadratic_forms/quadratic_form__mass.py | 4 +- .../quadratic_form__mass__Siegel_densities.py | 2 +- src/sage/rings/asymptotic/growth_group.py | 2 +- src/sage/rings/complex_arb.pyx | 6 +- src/sage/rings/complex_double.pyx | 6 +- src/sage/rings/complex_number.pyx | 4 +- src/sage/rings/finite_rings/element_base.pyx | 4 +- .../rings/finite_rings/element_givaro.pyx | 12 +- .../rings/finite_rings/element_pari_ffelt.pyx | 52 +-- .../rings/finite_rings/finite_field_base.pyx | 4 +- .../finite_rings/finite_field_pari_ffelt.py | 8 +- src/sage/rings/finite_rings/integer_mod.pyx | 2 +- .../rings/finite_rings/integer_mod_ring.py | 2 +- src/sage/rings/fraction_field.py | 2 +- src/sage/rings/ideal.py | 14 +- src/sage/rings/ideal_monoid.py | 8 +- src/sage/rings/infinity.py | 6 +- src/sage/rings/integer.pyx | 10 +- src/sage/rings/integer_ring.pyx | 4 +- src/sage/rings/number_field/class_group.py | 18 +- src/sage/rings/number_field/galois_group.py | 40 +- src/sage/rings/number_field/maps.py | 40 +- src/sage/rings/number_field/number_field.py | 16 +- .../number_field/number_field_element.pyx | 46 +-- .../number_field_element_quadratic.pyx | 20 +- .../rings/number_field/number_field_ideal.py | 24 +- .../number_field/number_field_ideal_rel.py | 10 +- .../rings/number_field/number_field_rel.py | 14 +- src/sage/rings/number_field/order.py | 8 +- src/sage/rings/padics/CR_template.pxi | 2 +- src/sage/rings/padics/generic_nodes.py | 4 +- .../rings/padics/padic_extension_generic.py | 2 +- .../rings/padics/padic_generic_element.pyx | 2 +- src/sage/rings/pari_ring.py | 4 +- .../polynomial/infinite_polynomial_ring.py | 4 +- .../rings/polynomial/multi_polynomial.pyx | 2 +- .../polynomial/multi_polynomial_element.py | 12 +- .../polynomial/multi_polynomial_ideal.py | 64 ++-- .../multi_polynomial_libsingular.pyx | 2 +- .../rings/polynomial/multi_polynomial_ring.py | 6 +- .../multi_polynomial_ring_generic.pyx | 4 +- .../polynomial/multi_polynomial_sequence.py | 54 +-- .../polynomial_padic_capped_relative_dense.py | 2 +- src/sage/rings/polynomial/pbori.pyx | 342 +++++++++--------- src/sage/rings/polynomial/plural.pyx | 6 +- .../rings/polynomial/polynomial_element.pyx | 16 +- src/sage/rings/polynomial/polynomial_gf2x.pyx | 14 +- .../polynomial_integer_dense_flint.pyx | 2 +- .../polynomial/polynomial_modn_dense_ntl.pyx | 2 +- .../polynomial/polynomial_quotient_ring.py | 2 +- .../polynomial/polynomial_rational_flint.pyx | 6 +- src/sage/rings/polynomial/polynomial_ring.py | 2 +- .../polynomial_ring_homomorphism.pyx | 2 +- .../rings/polynomial/polynomial_template.pxi | 52 +-- .../polynomial/polynomial_zmod_flint.pyx | 10 +- .../rings/polynomial/polynomial_zz_pex.pyx | 14 +- src/sage/rings/polynomial/symmetric_ideal.py | 2 +- src/sage/rings/polynomial/term_order.py | 100 ++--- src/sage/rings/polynomial/toy_d_basis.py | 12 +- src/sage/rings/polynomial/toy_variety.py | 12 +- src/sage/rings/power_series_poly.pyx | 4 +- src/sage/rings/power_series_ring.py | 4 +- src/sage/rings/power_series_ring_element.pyx | 2 +- src/sage/rings/qqbar.py | 186 +++++----- src/sage/rings/quotient_ring.py | 4 +- src/sage/rings/quotient_ring_element.py | 10 +- src/sage/rings/rational.pyx | 4 +- src/sage/rings/real_arb.pyx | 2 +- src/sage/rings/real_double.pyx | 6 +- src/sage/rings/real_mpfi.pyx | 2 +- src/sage/rings/real_mpfr.pyx | 10 +- src/sage/rings/ring.pyx | 2 +- src/sage/sat/boolean_polynomials.py | 2 +- src/sage/sat/converters/polybori.py | 22 +- .../solvers/cryptominisat/cryptominisat.pyx | 16 +- .../sat/solvers/cryptominisat/solverconf.pyx | 16 +- src/sage/sat/solvers/dimacs.py | 16 +- src/sage/sat/solvers/sat_lp.py | 10 +- src/sage/sat/solvers/satsolver.pyx | 24 +- src/sage/schemes/curves/affine_curve.py | 6 +- src/sage/schemes/curves/projective_curve.py | 10 +- src/sage/schemes/elliptic_curves/BSD.py | 6 +- src/sage/schemes/elliptic_curves/cm.py | 4 +- .../elliptic_curves/descent_two_isogeny.pyx | 8 +- .../elliptic_curves/ell_finite_field.py | 2 +- .../elliptic_curves/ell_number_field.py | 4 +- .../elliptic_curves/ell_padic_field.py | 2 +- src/sage/schemes/elliptic_curves/ell_point.py | 20 +- .../elliptic_curves/ell_rational_field.py | 4 +- src/sage/schemes/elliptic_curves/ell_wp.py | 2 +- .../schemes/elliptic_curves/formal_group.py | 6 +- src/sage/schemes/elliptic_curves/heegner.py | 4 +- src/sage/schemes/elliptic_curves/height.py | 4 +- src/sage/schemes/elliptic_curves/kraus.py | 4 +- .../elliptic_curves/period_lattice_region.pyx | 2 +- .../elliptic_curves/weierstrass_morphism.py | 2 +- src/sage/schemes/generic/homset.py | 2 +- src/sage/schemes/generic/spec.py | 2 +- .../hyperelliptic_generic.py | 6 +- .../hyperelliptic_curves/monsky_washnitzer.py | 8 +- .../schemes/plane_quartics/quartic_generic.py | 2 +- .../projective/endPN_automorphism_group.py | 2 +- src/sage/schemes/toric/variety.py | 2 +- .../discrete_gaussian_integer.pyx | 2 +- .../discrete_gaussian_lattice.py | 22 +- .../discrete_gaussian_polynomial.py | 10 +- src/sage/structure/coerce.pyx | 2 +- src/sage/structure/element.pyx | 4 +- src/sage/structure/factory.pyx | 2 +- src/sage/structure/formal_sum.py | 2 +- src/sage/structure/list_clone.pyx | 4 +- src/sage/structure/mutability.pyx | 2 +- src/sage/structure/parent.pyx | 2 +- src/sage/structure/sage_object.pyx | 2 +- src/sage/structure/sequence.py | 2 +- src/sage/symbolic/expression.pyx | 2 +- src/sage/symbolic/expression_conversions.py | 2 +- src/sage/tensor/modules/comp.py | 32 +- .../tensor/modules/ext_pow_free_module.py | 2 +- .../tensor/modules/finite_rank_free_module.py | 4 +- src/sage/tensor/modules/format_utilities.py | 2 +- .../tensor/modules/free_module_alt_form.py | 2 +- .../modules/free_module_automorphism.py | 2 +- src/sage/tensor/modules/free_module_basis.py | 2 +- src/sage/tensor/modules/free_module_homset.py | 2 +- .../modules/free_module_linear_group.py | 6 +- .../tensor/modules/free_module_morphism.py | 4 +- src/sage/tensor/modules/free_module_tensor.py | 16 +- src/sage/tensor/modules/tensor_free_module.py | 4 +- src/sage/tests/benchmark.py | 2 +- 429 files changed, 2861 insertions(+), 2861 deletions(-) diff --git a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_morphism.py b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_morphism.py index 1c5fce454a9..c122f0bfc02 100644 --- a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_morphism.py +++ b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_morphism.py @@ -172,7 +172,7 @@ def inverse_image(self, I): -- ``FiniteDimensionalAlgebraIdeal``, the inverse image of `I` under ``self``. - EXAMPLE:: + EXAMPLES:: sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) sage: I = A.maximal_ideal() diff --git a/src/sage/algebras/group_algebra.py b/src/sage/algebras/group_algebra.py index e44bef4aba2..d275ee18d0f 100644 --- a/src/sage/algebras/group_algebra.py +++ b/src/sage/algebras/group_algebra.py @@ -551,7 +551,7 @@ def random_element(self, n=2): multiplying a random element of the base ring by a random element of the group. - EXAMPLE:: + EXAMPLES:: sage: GroupAlgebra(DihedralGroup(6), QQ).random_element() -1/95*() - 1/2*(1,4)(2,5)(3,6) diff --git a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx index 0cdc3ca9940..8d8d61182d0 100644 --- a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx +++ b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx @@ -135,7 +135,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): """ Iterates over the pairs "tuple of exponents, coefficient". - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(GF(3), implementation='letterplace') sage: p = x*y-z^2 @@ -314,7 +314,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): Generators may have a positive integral degree weight. All elements must be weighted homogeneous. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: ((x+y+z)^3).degree() @@ -330,7 +330,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): """ Return the commutative polynomial that is used internally to represent this free algebra element. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: ((x+y-z)^2).letterplace_polynomial() @@ -350,7 +350,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): """ The leading monomial of this free algebra element. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: ((2*x+3*y-4*z)^2*(5*y+6*z)).lm() @@ -367,7 +367,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): The leading term (monomial times coefficient) of this free algebra element. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: ((2*x+3*y-4*z)^2*(5*y+6*z)).lt() @@ -384,7 +384,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): The leading coefficient of this free algebra element, as element of the base ring. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: ((2*x+3*y-4*z)^2*(5*y+6*z)).lc() @@ -421,7 +421,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): A free algebra element `p` divides another one `q` if there are free algebra elements `s` and `t` such that `spt = q`. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace', degrees=[2,1,3]) sage: ((2*x*y+z)^2*z).lm() @@ -657,7 +657,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): the argument is a twosided Groebner basis up to the degree of this element. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: I = F*[x*y+y*z,x^2+x*y-y*x-y^2]*F @@ -729,7 +729,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): The normal form is computed by reduction with respect to a Groebnerbasis of `I` with degree bound `deg(x)`. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: I = F*[x*y+y*z,x^2+x*y-y*x-y^2]*F diff --git a/src/sage/algebras/letterplace/free_algebra_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_letterplace.pyx index 478836f320d..c6583b1b7c6 100644 --- a/src/sage/algebras/letterplace/free_algebra_letterplace.pyx +++ b/src/sage/algebras/letterplace/free_algebra_letterplace.pyx @@ -188,7 +188,7 @@ cdef class FreeAlgebra_letterplace(Algebra): as soon as the restriction to homogeneous elements is lifted in Singular's "Letterplace algebras". - EXAMPLE:: + EXAMPLES:: sage: K. = GF(25) sage: F. = FreeAlgebra(K, implementation='letterplace') @@ -311,7 +311,7 @@ cdef class FreeAlgebra_letterplace(Algebra): """ Return the number of generators. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: F.ngens() @@ -331,7 +331,7 @@ cdef class FreeAlgebra_letterplace(Algebra): Generator number `i`. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: F.1 is F.1 # indirect doctest @@ -358,7 +358,7 @@ cdef class FreeAlgebra_letterplace(Algebra): Return the commutative ring that is used to emulate the non-commutative multiplication out to the current degree. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: F.current_ring() @@ -381,7 +381,7 @@ cdef class FreeAlgebra_letterplace(Algebra): This commutative ring is used as a unique key of the free algebra. - EXAMPLE:: + EXAMPLES:: sage: K. = GF(25) sage: F. = FreeAlgebra(K, implementation='letterplace') @@ -398,7 +398,7 @@ cdef class FreeAlgebra_letterplace(Algebra): """ Return the term order that is used for the commutative version of this free algebra. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: F.term_order_of_block() @@ -418,7 +418,7 @@ cdef class FreeAlgebra_letterplace(Algebra): """ Tell whether this algebra is commutative, i.e., whether the generator number is one. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: F.is_commutative() @@ -449,7 +449,7 @@ cdef class FreeAlgebra_letterplace(Algebra): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: F # indirect doctest @@ -469,7 +469,7 @@ cdef class FreeAlgebra_letterplace(Algebra): """ Representation of this free algebra in LaTeX. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace', degrees=[1,2,3]) sage: latex(F) @@ -553,7 +553,7 @@ cdef class FreeAlgebra_letterplace(Algebra): """ Return the class :class:`~sage.algebras.letterplace.letterplace_ideal.LetterplaceIdeal`. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: I = [x*y+y*z,x^2+x*y-y*x-y^2]*F @@ -570,7 +570,7 @@ cdef class FreeAlgebra_letterplace(Algebra): """ Return the monoid of ideals of this free algebra. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(GF(2), implementation='letterplace') sage: F.ideal_monoid() @@ -588,7 +588,7 @@ cdef class FreeAlgebra_letterplace(Algebra): """ This auxiliary method is used for the string representation of elements of this free algebra. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(GF(2), implementation='letterplace') sage: x*y*x*z # indirect doctest @@ -635,7 +635,7 @@ cdef class FreeAlgebra_letterplace(Algebra): """ This auxiliary method is used for the representation of elements of this free algebra as a latex string. - EXAMPLE:: + EXAMPLES:: sage: K. = GF(25) sage: F. = FreeAlgebra(K, implementation='letterplace', degrees=[1,2,3]) @@ -679,7 +679,7 @@ cdef class FreeAlgebra_letterplace(Algebra): An ideal such that reduction of a letterplace polynomial by that ideal corresponds to reduction of an element of degree at most ``d`` by ``g``. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: I = F*[x*y+y*z,x^2+x*y-y*x-y^2]*F @@ -769,7 +769,7 @@ cdef class FreeAlgebra_letterplace(Algebra): """ Return an element. - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(QQ, implementation='letterplace') sage: F.an_element() # indirect doctest @@ -859,7 +859,7 @@ cdef class FreeAlgebra_letterplace(Algebra): as an expression in the algebra (provided that the coefficients are numerical). - EXAMPLE:: + EXAMPLES:: sage: F. = FreeAlgebra(ZZ, implementation='letterplace', degrees=[4,2,3]) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 22f884637d9..ca7ee0c324a 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2295,7 +2295,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds): a symbolic computation will not factor the integer, because it is considered as an element of a larger symbolic ring. - EXAMPLE:: + EXAMPLES:: sage: f(n)=n^2 sage: is_prime(f(3)) diff --git a/src/sage/calculus/transforms/fft.pyx b/src/sage/calculus/transforms/fft.pyx index b154fb8596f..45657ce0add 100644 --- a/src/sage/calculus/transforms/fft.pyx +++ b/src/sage/calculus/transforms/fft.pyx @@ -115,7 +115,7 @@ cdef class FastFourierTransform_complex(FastFourierTransform_base): """ Frees allocated memory. - EXAMPLE:: + EXAMPLES:: sage: a = FastFourierTransform(128) sage: del a @@ -129,7 +129,7 @@ cdef class FastFourierTransform_complex(FastFourierTransform_base): OUTPUT: The size of the array. - EXAMPLE:: + EXAMPLES:: sage: a = FastFourierTransform(48) sage: len(a) @@ -148,7 +148,7 @@ cdef class FastFourierTransform_complex(FastFourierTransform_base): - ``i`` -- An integer peresenting the index. - ``xy`` -- An object to store as `i`-th element of the array ``self[i]``. - EXAMPLE:: + EXAMPLES:: sage: I = CC(I) sage: a = FastFourierTransform(4) @@ -238,7 +238,7 @@ cdef class FastFourierTransform_complex(FastFourierTransform_base): This method should not be called directly. See :meth:`plot` for the details. - EXAMPLE:: + EXAMPLES:: sage: a = FastFourierTransform(4) sage: a._plot_polar(0,2) @@ -276,7 +276,7 @@ cdef class FastFourierTransform_complex(FastFourierTransform_base): This method should not be called directly. See :meth:`plot` for the details. - EXAMPLE:: + EXAMPLES:: sage: a = FastFourierTransform(4) sage: a._plot_rect(0,3) @@ -312,7 +312,7 @@ cdef class FastFourierTransform_complex(FastFourierTransform_base): - A plot of the array. - EXAMPLE:: + EXAMPLES:: sage: a = FastFourierTransform(16) sage: for i in range(16): a[i] = (random(),random()) diff --git a/src/sage/categories/additive_magmas.py b/src/sage/categories/additive_magmas.py index a1b0504ac0d..4c064e53e59 100644 --- a/src/sage/categories/additive_magmas.py +++ b/src/sage/categories/additive_magmas.py @@ -950,7 +950,7 @@ def zero(self): r""" Returns the zero of this group - EXAMPLE:: + EXAMPLES:: sage: GF(8,'x').cartesian_product(GF(5)).zero() (0, 0) diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py index c2d71d8ed4f..1addb7d0436 100644 --- a/src/sage/categories/category.py +++ b/src/sage/categories/category.py @@ -3016,7 +3016,7 @@ def _subcategory_hook_(self, category): and only if it is a sub-category of all super categories of this join category. - EXAMPLE:: + EXAMPLES:: sage: cat = Category.join([Rings(), VectorSpaces(QuotientFields().Metric())]) sage: QQ['x'].category().is_subcategory(cat) # indirect doctest diff --git a/src/sage/categories/coxeter_groups.py b/src/sage/categories/coxeter_groups.py index 82d7f70b864..a921908454c 100644 --- a/src/sage/categories/coxeter_groups.py +++ b/src/sage/categories/coxeter_groups.py @@ -1318,7 +1318,7 @@ def apply_simple_projection(self, i, side = 'right', length_increasing = True): See :meth:`CoxeterGroups.ParentMethods.simple_projections` for the definition of the simple projections. - EXAMPLE:: + EXAMPLES:: sage: W=CoxeterGroups().example() sage: w=W.an_element() diff --git a/src/sage/categories/functor.pyx b/src/sage/categories/functor.pyx index 68d5e858845..c06714cef63 100644 --- a/src/sage/categories/functor.pyx +++ b/src/sage/categories/functor.pyx @@ -387,7 +387,7 @@ cdef class Functor(SageObject): """ The domain of self - EXAMPLE:: + EXAMPLES:: sage: F = ForgetfulFunctor(FiniteFields(),Fields()) sage: F.domain() @@ -400,7 +400,7 @@ cdef class Functor(SageObject): """ The codomain of self - EXAMPLE:: + EXAMPLES:: sage: F = ForgetfulFunctor(FiniteFields(),Fields()) sage: F.codomain() diff --git a/src/sage/categories/map.pyx b/src/sage/categories/map.pyx index 5b8b229bd8f..5099b1ede3a 100644 --- a/src/sage/categories/map.pyx +++ b/src/sage/categories/map.pyx @@ -59,7 +59,7 @@ def is_Map(x): """ Auxiliary function: Is the argument a map? - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: f = R.hom([x+y, x-y], R) @@ -489,7 +489,7 @@ cdef class Map(Element): By default, the string ``"Generic"`` is returned. Subclasses may overload this method. - EXAMPLE:: + EXAMPLES:: sage: from sage.categories.map import Map sage: f = Map(Hom(QQ, ZZ, Rings())) @@ -513,7 +513,7 @@ cdef class Map(Element): By default, the empty string is returned. Subclasses may overload this method. - EXAMPLE:: + EXAMPLES:: sage: from sage.categories.map import Map sage: f = Map(Hom(QQ, ZZ, Rings())) @@ -1323,7 +1323,7 @@ cdef class Section(Map): Call methods are not implemented for the base class ``Section``. - EXAMPLE:: + EXAMPLES:: sage: from sage.categories.map import Section sage: R. = ZZ[] @@ -1442,7 +1442,7 @@ cdef class FormalCompositeMap(Map): When calling a composite with additional arguments, these arguments are *only* passed to the second underlying map. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: S. = QQ[] @@ -1813,7 +1813,7 @@ cdef class FormalCompositeMap(Map): f_1 \circ f_0`, then ``self.first()`` returns `f_0`. We have ``self == self.then() * self.first()``. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: S. = QQ[] @@ -1837,7 +1837,7 @@ cdef class FormalCompositeMap(Map): f_{n-1} \circ \cdots \circ f_1`. We have ``self == self.then() * self.first()``. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: S. = QQ[] @@ -1858,7 +1858,7 @@ cdef class FormalCompositeMap(Map): It raises ``NotImplementedError`` if it can't be determined. - EXAMPLE:: + EXAMPLES:: sage: V1 = QQ^2 sage: V2 = QQ^3 @@ -1904,7 +1904,7 @@ cdef class FormalCompositeMap(Map): It raises ``NotImplementedError`` if it can't be determined. - EXAMPLE:: + EXAMPLES:: sage: from sage.categories.map import FormalCompositeMap sage: V3 = QQ^3 diff --git a/src/sage/categories/pushout.py b/src/sage/categories/pushout.py index 125e1ec6a44..32d0728b502 100644 --- a/src/sage/categories/pushout.py +++ b/src/sage/categories/pushout.py @@ -262,7 +262,7 @@ def expand(self): The default is to return the list only containing ``self``. - EXAMPLE:: + EXAMPLES:: sage: F = QQ.construction()[0] sage: F.expand() @@ -721,7 +721,7 @@ class PolynomialFunctor(ConstructionFunctor): """ Construction functor for univariate polynomial rings. - EXAMPLE:: + EXAMPLES:: sage: P = ZZ['t'].construction()[0] sage: P(GF(3)) @@ -852,7 +852,7 @@ def merge(self, other): this does the same as the default implementation, that returns ``None`` unless the to-be-merged functors coincide. - EXAMPLE:: + EXAMPLES:: sage: P = ZZ['x'].construction()[0] sage: Q = ZZ['y','x'].construction()[0] @@ -1506,7 +1506,7 @@ def merge(self, other): Merging is only happening if both functors are matrix functors of the same dimension. The result is sparse if and only if both given functors are sparse. - EXAMPLE:: + EXAMPLES:: sage: F1 = MatrixSpace(ZZ,2,2).construction()[0] sage: F2 = MatrixSpace(ZZ,2,3).construction()[0] @@ -1641,7 +1641,7 @@ def merge(self, other): Two Laurent polynomial construction functors merge if the variable names coincide. The result is multivariate if one of the arguments is multivariate. - EXAMPLE:: + EXAMPLES:: sage: from sage.categories.pushout import LaurentPolynomialFunctor sage: F1 = LaurentPolynomialFunctor('t') @@ -1664,7 +1664,7 @@ class VectorFunctor(ConstructionFunctor): """ A construction functor for free modules over commutative rings. - EXAMPLE:: + EXAMPLES:: sage: F = (ZZ^3).construction()[0] sage: F @@ -2014,7 +2014,7 @@ def merge(self, other): """ Two Subspace Functors are merged into a construction functor of the sum of two subspaces. - EXAMPLE:: + EXAMPLES:: sage: M = GF(5)^3 sage: S1 = M.submodule([(1,2,3),(4,5,6)]) @@ -2074,7 +2074,7 @@ class FractionField(ConstructionFunctor): """ Construction functor for fraction fields. - EXAMPLE:: + EXAMPLES:: sage: F = QQ.construction()[0] sage: F @@ -2325,7 +2325,7 @@ def merge(self, other): the set precision, and if the completion is at a finite prime, merging does not decrease the capped precision. - EXAMPLE:: + EXAMPLES:: sage: R1. = Zp(5,prec=20)[] sage: R2 = Qp(5,prec=40) @@ -2419,7 +2419,7 @@ def commutes(self,other): """ Completion commutes with fraction fields. - EXAMPLE:: + EXAMPLES:: sage: F1 = Qp(5).construction()[0] sage: F2 = QQ.construction()[0] @@ -2464,7 +2464,7 @@ class QuotientFunctor(ConstructionFunctor): The functor keeps track of variable names. - EXAMPLE:: + EXAMPLES:: sage: P. = ZZ[] sage: Q = P.quo([x^2+y^2]*P) @@ -2600,7 +2600,7 @@ def merge(self, other): """ Two quotient functors with coinciding names are merged by taking the gcd of their moduli. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: Q1 = P.quo([(x^2+1)^2*(x^2-3)]) @@ -2643,7 +2643,7 @@ class AlgebraicExtensionFunctor(ConstructionFunctor): """ Algebraic extension (univariate polynomial ring modulo principal ideal). - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3+x^2+1) sage: F = K.construction()[0] @@ -3041,7 +3041,7 @@ class AlgebraicClosureFunctor(ConstructionFunctor): """ Algebraic Closure. - EXAMPLE:: + EXAMPLES:: sage: F = CDF.construction()[0] sage: F(QQ) @@ -3981,7 +3981,7 @@ def construction_tower(R): of a construction functor and an object to which the construction functor is to be applied. The first pair is formed by ``None`` and the given object. - EXAMPLE:: + EXAMPLES:: sage: from sage.categories.pushout import construction_tower sage: construction_tower(MatrixSpace(FractionField(QQ['t']),2)) @@ -4013,7 +4013,7 @@ def expand_tower(tower): A new construction tower with all the construction functors expanded. - EXAMPLE:: + EXAMPLES:: sage: from sage.categories.pushout import construction_tower, expand_tower sage: construction_tower(QQ['x,y,z']) diff --git a/src/sage/categories/rings.py b/src/sage/categories/rings.py index 484b8f6b202..2081d70cfde 100644 --- a/src/sage/categories/rings.py +++ b/src/sage/categories/rings.py @@ -324,7 +324,7 @@ def ideal_monoid(self): from that class, such as matrix algebras. See :trac:`7797`. - EXAMPLE:: + EXAMPLES:: sage: MS = MatrixSpace(QQ,2,2) sage: isinstance(MS,Ring) @@ -412,7 +412,7 @@ def ideal(self, *args, **kwds): whether the resulting ideal is twosided, a left ideal or a right ideal. - EXAMPLE:: + EXAMPLES:: sage: MS = MatrixSpace(QQ,2,2) sage: isinstance(MS,Ring) @@ -614,7 +614,7 @@ def quo(self, I, names=None): This is a synonym for :meth:`quotient`. - EXAMPLE:: + EXAMPLES:: sage: MS = MatrixSpace(QQ,2) sage: I = MS*MS.gens()*MS @@ -656,7 +656,7 @@ def quotient_ring(self, I, names=None): This is a synonyme for :meth:`quotient`. - EXAMPLE:: + EXAMPLES:: sage: MS = MatrixSpace(QQ,2) sage: I = MS*MS.gens()*MS @@ -694,7 +694,7 @@ def __truediv__(self, I): the construction of a quotient ring using division syntax is not supported. - EXAMPLE:: + EXAMPLES:: sage: MS = MatrixSpace(QQ,2) sage: I = MS*MS.gens()*MS diff --git a/src/sage/coding/binary_code.pyx b/src/sage/coding/binary_code.pyx index 1c2c6e7d1d1..673988055f1 100644 --- a/src/sage/coding/binary_code.pyx +++ b/src/sage/coding/binary_code.pyx @@ -695,7 +695,7 @@ cdef class BinaryCode: """ Minimal, but optimized, binary code object. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -852,7 +852,7 @@ cdef class BinaryCode: Returns the generator matrix of the BinaryCode, i.e. the code is the rowspace of B.matrix(). - EXAMPLE:: + EXAMPLES:: sage: M = Matrix(GF(2), [[1,1,1,1,0,0],[0,0,1,1,1,1]]) sage: from sage.coding.binary_code import * @@ -981,7 +981,7 @@ cdef class BinaryCode: """ String representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1007,7 +1007,7 @@ cdef class BinaryCode: coefficients of the basis given by self.matrix(). This function returns a string representation of that word. - EXAMPLE:: + EXAMPLES:: sage: from sage.coding.binary_code import * sage: M = Matrix(GF(2), [[1,1,1,1]]) @@ -1032,7 +1032,7 @@ cdef class BinaryCode: as integers, which represent linear combinations of the rows of the generator matrix of the code. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1068,7 +1068,7 @@ cdef class BinaryCode: - word_gamma -- permutation sending i |--> word_gamma[i] acting on the words. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1120,7 +1120,7 @@ cdef class BinaryCode: - labeling -- a list permutation of the columns - EXAMPLE:: + EXAMPLES:: sage: from sage.coding.binary_code import * sage: B = BinaryCode(codes.GolayCode(GF(2)).generator_matrix()) @@ -1193,7 +1193,7 @@ cdef class BinaryCode: Put the code in binary form, which is defined by an identity matrix on the left, augmented by a matrix of data. - EXAMPLE:: + EXAMPLES:: sage: from sage.coding.binary_code import * sage: M = Matrix(GF(2), [[1,1,1,1,0,0],[0,0,1,1,1,1]]) @@ -1304,7 +1304,7 @@ cdef class OrbitPartition: """ Return a string representation of the orbit partition. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1341,7 +1341,7 @@ cdef class OrbitPartition: """ Returns the root of word. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1369,7 +1369,7 @@ cdef class OrbitPartition: """ Join the cells containing x and y. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1415,7 +1415,7 @@ cdef class OrbitPartition: """ Returns the root of col. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1443,7 +1443,7 @@ cdef class OrbitPartition: """ Join the cells containing x and y. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1491,7 +1491,7 @@ cdef class OrbitPartition: then after merge_perm, a and b will be in the same cell. Returns 0 if nothing was done, otherwise returns 1. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1667,7 +1667,7 @@ cdef class PartitionStack: """ Prints all data for self. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1789,7 +1789,7 @@ cdef class PartitionStack: """ Return a string representation of self. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1813,7 +1813,7 @@ cdef class PartitionStack: """ Gives a string representing the partition at level k: - EXAMPLE:: + EXAMPLES:: sage: from sage.coding.binary_code import * sage: P = PartitionStack(2, 6); P @@ -1844,7 +1844,7 @@ cdef class PartitionStack: """ Returns whether the partition at level k is discrete. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1884,7 +1884,7 @@ cdef class PartitionStack: """ Returns the number of cells in the partition at level k. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -1922,7 +1922,7 @@ cdef class PartitionStack: Lemma 2.25 in Brendan McKay's Practical Graph Isomorphism paper (see sage/graphs/graph_isom.pyx. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2204,7 +2204,7 @@ cdef class PartitionStack: """ For debugging only. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2233,7 +2233,7 @@ cdef class PartitionStack: """ Do one round of bubble sort on ents. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2268,7 +2268,7 @@ cdef class PartitionStack: """ Do one round of bubble sort on ents. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2370,7 +2370,7 @@ cdef class PartitionStack: column. See the 'flag' attribute of the PartitionStack object: If vertex&flag is not zero, it is a word. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2428,7 +2428,7 @@ cdef class PartitionStack: Returns the number of words in the cell specified by wd_ptr that have a 1 in the col-th column. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2469,7 +2469,7 @@ cdef class PartitionStack: Returns the number of columns in the cell specified by col_ptr that are 1 in wd. - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2519,7 +2519,7 @@ cdef class PartitionStack: - k -- at what level of refinement the partition of interest lies - degrees -- the counts to sort by - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2591,7 +2591,7 @@ cdef class PartitionStack: - k -- at what level of refinement the partition of interest lies - degrees -- the counts to sort by - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2655,7 +2655,7 @@ cdef class PartitionStack: def _refine(self, k, alpha, CG): """ - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2792,7 +2792,7 @@ cdef class PartitionStack: def _clear(self, k): """ - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2885,7 +2885,7 @@ cdef class PartitionStack: def print_basis(self): """ - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2919,7 +2919,7 @@ cdef class PartitionStack: def _find_basis(self): """ - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -2970,7 +2970,7 @@ cdef class PartitionStack: def _get_permutation(self, other): """ - EXAMPLE:: + EXAMPLES:: sage: import sage.coding.binary_code sage: from sage.coding.binary_code import * @@ -3803,7 +3803,7 @@ cdef class BinaryCodeClassifier: pivots to the front so that the generator matrix is of the form: the identity matrix augmented to the right by arbitrary data. - EXAMPLE:: + EXAMPLES:: sage: from sage.coding.binary_code import * sage: BC = BinaryCodeClassifier() @@ -3858,7 +3858,7 @@ cdef class BinaryCodeClassifier: ensures that all doubly-even canonically augmented children are generated. - EXAMPLE:: + EXAMPLES:: sage: from sage.coding.binary_code import * sage: BC = BinaryCodeClassifier() diff --git a/src/sage/coding/codecan/autgroup_can_label.pyx b/src/sage/coding/codecan/autgroup_can_label.pyx index bf652bd3b12..75cc1d0960f 100644 --- a/src/sage/coding/codecan/autgroup_can_label.pyx +++ b/src/sage/coding/codecan/autgroup_can_label.pyx @@ -111,7 +111,7 @@ def _cyclic_shift(n, p): Note that the domain of a ``Permutation`` is ``range(1, n+1)``. - EXAMPLE:: + EXAMPLES:: sage: from sage.coding.codecan.autgroup_can_label import _cyclic_shift sage: p = _cyclic_shift(10, [2,7,4,1]); p diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py index 4b284802762..1b852401c7f 100644 --- a/src/sage/coding/linear_code.py +++ b/src/sage/coding/linear_code.py @@ -1499,7 +1499,7 @@ def is_projective(self): `C` are linearly independent (cf. definition 3 from [BS2011]_ or 9.8.1 from [BH12]). - EXAMPLE:: + EXAMPLES:: sage: C = codes.GolayCode(GF(2), False) sage: C.is_projective() diff --git a/src/sage/coding/source_coding/huffman.py b/src/sage/coding/source_coding/huffman.py index baf4dafd807..5f6b34fa821 100644 --- a/src/sage/coding/source_coding/huffman.py +++ b/src/sage/coding/source_coding/huffman.py @@ -301,7 +301,7 @@ def _build_code(self, dic): are not necessarily integers, but can be real numbers. In general, we refer to ``dic`` as a weight table. - EXAMPLE:: + EXAMPLES:: sage: from sage.coding.source_coding.huffman import Huffman, frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" diff --git a/src/sage/combinat/binary_tree.py b/src/sage/combinat/binary_tree.py index b49b8b4a102..fe98dd48bf1 100644 --- a/src/sage/combinat/binary_tree.py +++ b/src/sage/combinat/binary_tree.py @@ -4450,7 +4450,7 @@ def _an_element_(self): """ Return a labelled binary tree. - EXAMPLE:: + EXAMPLES:: sage: LabelledBinaryTrees().an_element() # indirect doctest toto[42[3[., .], 3[., .]], 5[None[., .], None[., .]]] diff --git a/src/sage/combinat/core.py b/src/sage/combinat/core.py index 99b27c21cb1..bec0ab41cea 100644 --- a/src/sage/combinat/core.py +++ b/src/sage/combinat/core.py @@ -362,7 +362,7 @@ def _transposition_to_reduced_word(self, t): - a list of integers in `\{0,1,\ldots,k-1\}` representing a reduced word for the transposition `t` - EXAMPLE:: + EXAMPLES:: sage: c = Core([],4) sage: c._transposition_to_reduced_word([2, 5]) diff --git a/src/sage/combinat/crystals/tensor_product.py b/src/sage/combinat/crystals/tensor_product.py index 4aef2ec48f4..ced31522363 100644 --- a/src/sage/combinat/crystals/tensor_product.py +++ b/src/sage/combinat/crystals/tensor_product.py @@ -1928,7 +1928,7 @@ def module_generator(self, shape): crystal of given shape. The module generator is the unique tableau with equal shape and content. - EXAMPLE:: + EXAMPLES:: sage: T = crystals.Tableaux(['D',3], shape = [1,1]) sage: T.module_generator([1,1]) diff --git a/src/sage/combinat/debruijn_sequence.pyx b/src/sage/combinat/debruijn_sequence.pyx index 72df19cf16a..c495ba55296 100644 --- a/src/sage/combinat/debruijn_sequence.pyx +++ b/src/sage/combinat/debruijn_sequence.pyx @@ -121,7 +121,7 @@ def is_debruijn_sequence(seq, k, n): - ``n,k`` -- Integers. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.debruijn_sequence import is_debruijn_sequence sage: s = DeBruijnSequences(2, 3).an_element() @@ -296,7 +296,7 @@ class DeBruijnSequences(UniqueRepresentation, Parent): """ Provides a string representation of the object's parameter. - EXAMPLE:: + EXAMPLES:: sage: repr(DeBruijnSequences(4, 50)) 'De Bruijn sequences with arity 4 and substring length 50' @@ -315,7 +315,7 @@ class DeBruijnSequences(UniqueRepresentation, Parent): Frank Ruskey. This program is based on a Ruby implementation by Jonas Elfström, which is based on the C program by Joe Sadawa. - EXAMPLE:: + EXAMPLES:: sage: DeBruijnSequences(2, 3).an_element() [0, 0, 0, 1, 0, 1, 1, 1] @@ -344,7 +344,7 @@ class DeBruijnSequences(UniqueRepresentation, Parent): Returns the number of distinct De Bruijn sequences for the object's parameters. - EXAMPLE:: + EXAMPLES:: sage: DeBruijnSequences(2, 5).cardinality() 2048 diff --git a/src/sage/combinat/degree_sequences.pyx b/src/sage/combinat/degree_sequences.pyx index 02f8a8d18d9..c8dab199994 100644 --- a/src/sage/combinat/degree_sequences.pyx +++ b/src/sage/combinat/degree_sequences.pyx @@ -284,7 +284,7 @@ class DegreeSequences: information, please refer to the documentation of the :mod:`DegreeSequence` module. - EXAMPLE:: + EXAMPLES:: sage: DegreeSequences(8) Degree sequences on 8 elements @@ -309,7 +309,7 @@ class DegreeSequences: Checks whether a given integer sequence is the degree sequence of a graph on `n` elements - EXAMPLE:: + EXAMPLES:: sage: [3,3,2,2,2,2,2,2] in DegreeSequences(8) True @@ -389,7 +389,7 @@ class DegreeSequences: TODO: THIS SHOULD BE UPDATED AS SOON AS THE YIELD KEYWORD APPEARS IN CYTHON. See comment in the class' documentation. - EXAMPLE:: + EXAMPLES:: sage: DS = DegreeSequences(6) sage: all(seq in DS for seq in DS) diff --git a/src/sage/combinat/designs/bibd.py b/src/sage/combinat/designs/bibd.py index 8e7a17e8add..ae6adc36560 100644 --- a/src/sage/combinat/designs/bibd.py +++ b/src/sage/combinat/designs/bibd.py @@ -738,7 +738,7 @@ def _relabel_bibd(B,n,p=None): - ``p`` (optional) -- the point that will be labeled with n-1. - EXAMPLE:: + EXAMPLES:: sage: designs.balanced_incomplete_block_design(40,4).blocks() # indirect doctest [[0, 1, 2, 12], [0, 3, 6, 9], [0, 4, 8, 10], @@ -912,7 +912,7 @@ def _get_t_u(v): - ``v`` (integer) - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.bibd import _get_t_u sage: _get_t_u(20) @@ -1255,7 +1255,7 @@ def __init__(self, points, blocks, K=None, lambd=1, check=True, copy=True,**kwds r""" Constructor - EXAMPLE:: + EXAMPLES:: sage: designs.balanced_incomplete_block_design(13,3) # indirect doctest (13,3,1)-Balanced Incomplete Block Design @@ -1322,7 +1322,7 @@ def __init__(self, points, blocks, k=None, lambd=1, check=True, copy=True,**kwds r""" Constructor - EXAMPLE:: + EXAMPLES:: sage: b=designs.balanced_incomplete_block_design(9,3); b (9,3,1)-Balanced Incomplete Block Design @@ -1340,7 +1340,7 @@ def __repr__(self): r""" A string to describe self - EXAMPLE:: + EXAMPLES:: sage: b=designs.balanced_incomplete_block_design(9,3); b (9,3,1)-Balanced Incomplete Block Design diff --git a/src/sage/combinat/designs/block_design.py b/src/sage/combinat/designs/block_design.py index cfa672d5757..4cc61234833 100644 --- a/src/sage/combinat/designs/block_design.py +++ b/src/sage/combinat/designs/block_design.py @@ -895,7 +895,7 @@ def CremonaRichmondConfiguration(): For more information, see the :wikipedia:`Cremona-Richmond_configuration`. - EXAMPLE:: + EXAMPLES:: sage: H = designs.CremonaRichmondConfiguration(); H Incidence structure with 15 points and 15 blocks diff --git a/src/sage/combinat/designs/covering_design.py b/src/sage/combinat/designs/covering_design.py index 79d18f7b347..fe4f1a466c9 100644 --- a/src/sage/combinat/designs/covering_design.py +++ b/src/sage/combinat/designs/covering_design.py @@ -98,7 +98,7 @@ def trivial_covering_design(v,k,t): `(v,k,t)` covering design - EXAMPLE:: + EXAMPLES:: sage: C = trivial_covering_design(8,3,1) sage: print(C) diff --git a/src/sage/combinat/designs/database.py b/src/sage/combinat/designs/database.py index 93e83448adc..51366d14b2b 100644 --- a/src/sage/combinat/designs/database.py +++ b/src/sage/combinat/designs/database.py @@ -1731,7 +1731,7 @@ def OA_520_plus_x(x): This construction is used in :func:`OA(10,520) `, :func:`OA(12,522) `, and :func:`OA(14,524) `. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array sage: from sage.combinat.designs.database import OA_520_plus_x @@ -2066,7 +2066,7 @@ def QDM_19_6_1_1_1(): Given in the Handbook III.3.49 [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import QDM_19_6_1_1_1 sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix @@ -2100,7 +2100,7 @@ def QDM_21_5_1_1_1(): Given in the Handbook III.3.51 [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import QDM_21_5_1_1_1 sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix @@ -2147,7 +2147,7 @@ def QDM_21_6_1_1_5(): Given in the Handbook III.3.53 [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import QDM_21_6_1_1_5 sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix @@ -2187,7 +2187,7 @@ def QDM_25_6_1_1_5(): Given in the Handbook III.3.55 [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import QDM_25_6_1_1_5 sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix @@ -2232,7 +2232,7 @@ def QDM_33_6_1_1_1(): Given in the Handbook III.3.57 [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import QDM_33_6_1_1_1 sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix @@ -2275,7 +2275,7 @@ def QDM_37_6_1_1_1(): Given in the Handbook III.3.60 [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import QDM_37_6_1_1_1 sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix @@ -2313,7 +2313,7 @@ def QDM_35_7_1_1_7(): As explained in the Handbook III.3.63 [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import QDM_35_7_1_1_7 sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix @@ -2350,7 +2350,7 @@ def QDM_45_7_1_1_9(): As explained in the Handbook III.3.71 [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import QDM_45_7_1_1_9 sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix @@ -2387,7 +2387,7 @@ def QDM_54_7_1_1_8(): As explained in the Handbook III.3.74 [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import QDM_54_7_1_1_8 sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix @@ -2424,7 +2424,7 @@ def QDM_57_9_1_1_8(): Construction shared by Julian R. Abel - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import QDM_57_9_1_1_8 sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix @@ -4142,7 +4142,7 @@ def BIBD_45_9_8(from_code=False): - ``from_code`` (boolean) -- whether to build the design from hardcoded data (default) or from the code object (much longer). - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_45_9_8 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4213,7 +4213,7 @@ def BIBD_66_6_1(): This BIBD was obtained from La Jolla covering repository (https://www.ccrwest.org/cover.html) where it is attributed to Colin Barker. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_66_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4236,7 +4236,7 @@ def BIBD_76_6_1(): This BIBD was obtained from La Jolla covering repository (https://www.ccrwest.org/cover.html) where it is attributed to Colin Barker. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_76_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4259,7 +4259,7 @@ def BIBD_96_6_1(): This BIBD was obtained from La Jolla covering repository (https://www.ccrwest.org/cover.html) where it is attributed to Colin Barker. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_96_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4280,7 +4280,7 @@ def BIBD_106_6_1(): This constructions appears in II.3.32 from [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_106_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4303,7 +4303,7 @@ def BIBD_111_6_1(): This constructions appears in II.3.32 from [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_111_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4330,7 +4330,7 @@ def BIBD_126_6_1(): This constructions appears in VI.16.92 from [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_126_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4357,7 +4357,7 @@ def BIBD_136_6_1(): This constructions appears in II.3.32 from [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_136_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4385,7 +4385,7 @@ def BIBD_141_6_1(): This constructions appears in II.3.32 from [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_141_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4416,7 +4416,7 @@ def BIBD_171_6_1(): This constructions appears in II.3.32 from [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_171_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4456,7 +4456,7 @@ def HigmanSimsDesign(): blocks `A\in W_a` and `B\in W_b` whose intersection has cardinality 2. This construction, due to M.Smith, can be found in [KY04]_ or in 10.A.(v) of [BvL84]_. - EXAMPLE:: + EXAMPLES:: sage: H = designs.HigmanSimsDesign(); H # optional - gap_packages Incidence structure with 176 points and 176 blocks @@ -4505,7 +4505,7 @@ def BIBD_196_6_1(): This constructions appears in II.3.32 from [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_196_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign @@ -4537,7 +4537,7 @@ def BIBD_201_6_1(): This constructions appears in II.3.32 from [DesignHandbook]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.database import BIBD_201_6_1 sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign diff --git a/src/sage/combinat/designs/ext_rep.py b/src/sage/combinat/designs/ext_rep.py index 17930329a8e..d5a204f0b34 100644 --- a/src/sage/combinat/designs/ext_rep.py +++ b/src/sage/combinat/designs/ext_rep.py @@ -473,7 +473,7 @@ def dump_to_tmpfile(s): """ Utility function to dump a string to a temporary file. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs import ext_rep sage: file_loc = ext_rep.dump_to_tmpfile("boo") diff --git a/src/sage/combinat/designs/group_divisible_designs.py b/src/sage/combinat/designs/group_divisible_designs.py index 96afcbf3104..c68ae3c398f 100644 --- a/src/sage/combinat/designs/group_divisible_designs.py +++ b/src/sage/combinat/designs/group_divisible_designs.py @@ -159,7 +159,7 @@ def GDD_4_2(q,existence=False,check=True): guys), you may want to disable it whenever you want speed. Set to ``True`` by default. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.group_divisible_designs import GDD_4_2 sage: GDD_4_2(7,existence=True) @@ -248,7 +248,7 @@ class GroupDivisibleDesign(IncidenceStructure): modified in place (each block is sorted, and the whole list is sorted). Your ``blocks`` object will become the instance's internal data. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.group_divisible_designs import GroupDivisibleDesign sage: TD = designs.transversal_design(4,10) @@ -268,7 +268,7 @@ def __init__(self, points, groups, blocks, G=None, K=None, lambd=1, check=True, r""" Constructor function - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.group_divisible_designs import GroupDivisibleDesign sage: TD = designs.transversal_design(4,10) @@ -305,7 +305,7 @@ def groups(self): r""" Return the groups of the Group-Divisible Design. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.group_divisible_designs import GroupDivisibleDesign sage: TD = designs.transversal_design(4,10) @@ -340,7 +340,7 @@ def __repr__(self): r""" Returns a string that describes self - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.group_divisible_designs import GroupDivisibleDesign sage: TD = designs.transversal_design(4,10) diff --git a/src/sage/combinat/designs/incidence_structures.py b/src/sage/combinat/designs/incidence_structures.py index 001d2181017..1fcf7c0d00a 100644 --- a/src/sage/combinat/designs/incidence_structures.py +++ b/src/sage/combinat/designs/incidence_structures.py @@ -395,7 +395,7 @@ def canonical_label(self): `\{0,...,n-1\}` such that isomorphic incidence structures are relabelled to equal objects. - EXAMPLE:: + EXAMPLES:: sage: fano1 = designs.balanced_incomplete_block_design(7,3) sage: fano2 = designs.projective_plane(2) @@ -429,7 +429,7 @@ def is_isomorphic(self, other, certificate=False): insomorphism from ``self`` to ``other`` instead of a boolean answer. - EXAMPLE:: + EXAMPLES:: sage: fano1 = designs.balanced_incomplete_block_design(7,3) sage: fano2 = designs.projective_plane(2) @@ -564,7 +564,7 @@ def copy(self): r""" Return a copy of the incidence structure. - EXAMPLE:: + EXAMPLES:: sage: IS = IncidenceStructure([[1,2,3,"e"]],name="Test") sage: IS @@ -1167,7 +1167,7 @@ def incidence_graph(self,labels=False): elements of :meth:`ground_set` mix :func:`Set` and non-:func:`Set ` objects. - EXAMPLE:: + EXAMPLES:: sage: BD = IncidenceStructure(7, [[0,1,2],[0,3,4],[0,5,6],[1,3,5],[1,4,6],[2,3,6],[2,4,5]]) sage: BD.incidence_graph() @@ -1363,7 +1363,7 @@ def __hash__(self): This object is mutable because of .relabel() - EXAMPLE:: + EXAMPLES:: sage: TD=designs.transversal_design(5,5) sage: hash(TD) @@ -1401,7 +1401,7 @@ def packing(self, solver=None, verbose=0): - ``verbose`` -- integer (default: ``0``). Sets the level of verbosity. Set to 0 by default, which means quiet. - EXAMPLE:: + EXAMPLES:: sage; IncidenceStructure([[1,2],[3,"A"],[2,3]]).packing() [[1, 2], [3, 'A']] @@ -1662,7 +1662,7 @@ def is_generalized_quadrangle(self, verbose=False, parameters=False): case, `s` and `t` are the integers defined above if they exist (each can be set to ``False`` otherwise). - EXAMPLE:: + EXAMPLES:: sage: h = designs.CremonaRichmondConfiguration() sage: h.is_generalized_quadrangle() diff --git a/src/sage/combinat/designs/orthogonal_arrays.py b/src/sage/combinat/designs/orthogonal_arrays.py index dbcdda68add..8e705557f0d 100644 --- a/src/sage/combinat/designs/orthogonal_arrays.py +++ b/src/sage/combinat/designs/orthogonal_arrays.py @@ -1029,7 +1029,7 @@ def largest_available_k(n,t=2): - ``t`` -- (integer; default: 2) -- strength of the array - EXAMPLE:: + EXAMPLES:: sage: designs.orthogonal_arrays.largest_available_k(0) +Infinity @@ -1622,7 +1622,7 @@ def OA_n_times_2_pow_c_from_matrix(k,c,G,A,Y,check=True): - :func:`~sage.combinat.designs.database.OA_11_640` - :func:`~sage.combinat.designs.database.OA_15_896` - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.orthogonal_arrays import OA_n_times_2_pow_c_from_matrix sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array @@ -2120,7 +2120,7 @@ def explain_construction(k,n,t=2): - ``k,n,t`` (integers) -- parameters of the orthogonal array. - EXAMPLE:: + EXAMPLES:: sage: designs.orthogonal_arrays.explain_construction(9,565) "Wilson's construction n=23.24+13 with master design OA(9+1,23)" @@ -2189,7 +2189,7 @@ def exists(k,n,t=2): :meth:`is_available` - EXAMPLE:: + EXAMPLES:: sage: designs.orthogonal_arrays.exists(3,6) # indirect doctest True @@ -2213,7 +2213,7 @@ def is_available(k,n,t=2): :meth:`exists` - EXAMPLE:: + EXAMPLES:: sage: designs.orthogonal_arrays.is_available(3,6) # indirect doctest True diff --git a/src/sage/combinat/designs/orthogonal_arrays_build_recursive.py b/src/sage/combinat/designs/orthogonal_arrays_build_recursive.py index 4c0c4d32a12..8a006c2fbbe 100644 --- a/src/sage/combinat/designs/orthogonal_arrays_build_recursive.py +++ b/src/sage/combinat/designs/orthogonal_arrays_build_recursive.py @@ -771,7 +771,7 @@ def thwart_lemma_4_1(k,n,m,explain_construction=False): - :func:`~sage.combinat.designs.orthogonal_arrays_find_recursive.find_thwart_lemma_4_1` - EXAMPLE:: + EXAMPLES:: sage: print(designs.orthogonal_arrays.explain_construction(10,408)) Lemma 4.1 with n=13,m=28 from: @@ -947,7 +947,7 @@ def three_factor_product(k,n1,n2,n3,check=False,explain_construction=False): - :func:`~sage.combinat.designs.orthogonal_arrays_find_recursive.find_three_factor_product` - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array sage: from sage.combinat.designs.orthogonal_arrays_build_recursive import three_factor_product diff --git a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx index 6027f120d0d..3b64c6c52e4 100644 --- a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +++ b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx @@ -465,7 +465,7 @@ cpdef find_q_x(int k,int n): :func:`~sage.combinat.designs.orthogonal_arrays_build_recursive.construction_q_x` - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.orthogonal_arrays_find_recursive import find_q_x sage: find_q_x(10,9) @@ -720,7 +720,7 @@ cpdef find_brouwer_separable_design(int k,int n): documentation of :func:`~sage.combinat.designs.orthogonal_arrays_build_recursive.brouwer_separable_design`. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.orthogonal_arrays_find_recursive import find_brouwer_separable_design sage: find_brouwer_separable_design(5,13)[1] @@ -820,7 +820,7 @@ def int_as_sum(int value, list S, int k_max): - ``k_max`` (integer) - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.orthogonal_arrays_find_recursive import int_as_sum sage: D = int_as_sum(21,[5,12],100) @@ -895,7 +895,7 @@ cpdef find_brouwer_van_rees_with_one_truncated_column(int k,int n): - ``k,n`` (integers) - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.orthogonal_arrays_find_recursive import find_brouwer_van_rees_with_one_truncated_column sage: find_brouwer_van_rees_with_one_truncated_column(5,53)[1] diff --git a/src/sage/combinat/designs/resolvable_bibd.py b/src/sage/combinat/designs/resolvable_bibd.py index db69d6a84d5..0c3df910b5d 100644 --- a/src/sage/combinat/designs/resolvable_bibd.py +++ b/src/sage/combinat/designs/resolvable_bibd.py @@ -81,7 +81,7 @@ def resolvable_balanced_incomplete_block_design(v,k,existence=False): - :meth:`IncidenceStructure.is_resolvable` - :func:`~sage.combinat.designs.bibd.balanced_incomplete_block_design` - EXAMPLE:: + EXAMPLES:: sage: KTS15 = designs.resolvable_balanced_incomplete_block_design(15,3); KTS15 (15,3,1)-Balanced Incomplete Block Design @@ -377,7 +377,7 @@ def v_4_1_rbibd(v,existence=False): that `v=3q+1\equiv 1\pmod{3}` where `q` is a prime power (see VII.7.5.a from [BJL99]_). - EXAMPLE:: + EXAMPLES:: sage: rBIBD = designs.resolvable_balanced_incomplete_block_design(28,4) sage: rBIBD.is_resolvable() @@ -435,7 +435,7 @@ def PBD_4_7(v,check=True, existence=False): This construction of PBD is used by the construction of Kirkman Triple Systems. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.resolvable_bibd import PBD_4_7 sage: PBD_4_7(22) @@ -695,7 +695,7 @@ def PBD_4_7_from_Y(gdd,check=True): guys), you may want to disable it whenever you want speed. Set to ``True`` by default. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.resolvable_bibd import PBD_4_7_from_Y sage: PBD_4_7_from_Y(designs.transversal_design(7,8)) diff --git a/src/sage/combinat/designs/steiner_quadruple_systems.py b/src/sage/combinat/designs/steiner_quadruple_systems.py index ab326fc5a7f..2c64f3a9b83 100644 --- a/src/sage/combinat/designs/steiner_quadruple_systems.py +++ b/src/sage/combinat/designs/steiner_quadruple_systems.py @@ -480,7 +480,7 @@ def relabel_system(B): - ``B`` -- a list of 4-uples on `0,...,n-1`. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.steiner_quadruple_systems import relabel_system sage: SQS8 = designs.steiner_quadruple_system(8) @@ -514,7 +514,7 @@ def P(alpha, m): For more information on this system, see [Hanani60]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.steiner_quadruple_systems import P sage: P(3,4) @@ -555,7 +555,7 @@ def _missing_pair(n,l): r""" Return the smallest `(x,x+1)` that is not contained in `l`. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.steiner_quadruple_systems import _missing_pair sage: _missing_pair(6, [(0,1), (4,5)]) @@ -576,7 +576,7 @@ def barP(eps, m): For more information on this system, see [Hanani60]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.steiner_quadruple_systems import barP sage: barP(3,4) @@ -591,7 +591,7 @@ def barP_system(m): For more information on this system, see [Hanani60]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.steiner_quadruple_systems import barP_system sage: barP_system(3) @@ -769,7 +769,7 @@ def _SQS14(): Obtained from the La Jolla Covering Repository. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.steiner_quadruple_systems import _SQS14 sage: sqs14 = IncidenceStructure(_SQS14()) @@ -802,7 +802,7 @@ def _SQS38(): Obtained from the La Jolla Covering Repository. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.steiner_quadruple_systems import _SQS38 sage: sqs38 = IncidenceStructure(_SQS38()) diff --git a/src/sage/combinat/designs/subhypergraph_search.pyx b/src/sage/combinat/designs/subhypergraph_search.pyx index 68833c97775..5ab84fac088 100644 --- a/src/sage/combinat/designs/subhypergraph_search.pyx +++ b/src/sage/combinat/designs/subhypergraph_search.pyx @@ -347,7 +347,7 @@ cdef class SubHypergraphSearch: r""" See the documentation's class. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.designs.subhypergraph_search import SubHypergraphSearch sage: g1 = IncidenceStructure(graphs.PetersenGraph().edges(labels=False)) @@ -441,7 +441,7 @@ cdef class SubHypergraphSearch: This function is called when an instance of :class:`SubHypergraphSearch` is created. - EXAMPLE:: + EXAMPLES:: sage: d = designs.projective_plane(3) sage: d.isomorphic_substructures_iterator(d).relabel_heuristic() diff --git a/src/sage/combinat/dlx.py b/src/sage/combinat/dlx.py index 812b1c6b2b6..2e29040d7b5 100644 --- a/src/sage/combinat/dlx.py +++ b/src/sage/combinat/dlx.py @@ -130,7 +130,7 @@ def __eq__(self, other): - ``other`` - a DLX matrix - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.dlx import * sage: M = DLXMatrix([[1,[1]]]) diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py index 416a0b79f33..7cf09b4ea6d 100644 --- a/src/sage/combinat/finite_state_machine.py +++ b/src/sage/combinat/finite_state_machine.py @@ -1439,7 +1439,7 @@ def __lt__(self, other): True or False. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.finite_state_machine import FSMState sage: FSMState(0) < FSMState(1) @@ -2280,7 +2280,7 @@ def __lt__(self, other): True or False. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.finite_state_machine import FSMTransition sage: FSMTransition(0,1,0,0) < FSMTransition(1,0,0,0) @@ -3406,7 +3406,7 @@ def _copy_from_other_(self, other, memo=None, empty=False): Nothing. - EXAMPLE:: + EXAMPLES:: sage: A = Automaton([(0, 0, 0)], ....: initial_states=[0], @@ -3513,7 +3513,7 @@ def induced_sub_finite_state_machine(self, states): the given states and (deep copies) of all transitions of ``self`` between these states. - EXAMPLE:: + EXAMPLES:: sage: FSM = FiniteStateMachine([(0, 1, 0), (0, 2, 0), ....: (1, 2, 0), (2, 0, 0)]) @@ -4316,7 +4316,7 @@ def format_transition_label_reversed(self, word): right-most position. Therefore, the labels have to be reversed. - EXAMPLE:: + EXAMPLES:: sage: T = Transducer([(0, 0, 0, [1, 2, 3])]) sage: T.format_transition_label_reversed([1, 2, 3]) @@ -9396,7 +9396,7 @@ def merged_transitions(self): A finite state machine with merged transitions. If no mergers occur, return ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.finite_state_machine import duplicate_transition_add_input sage: T = Transducer([[1, 2, 1/4, 1], [1, -2, 1/4, 1], [1, -2, 1/2, 1], @@ -9468,7 +9468,7 @@ def markov_chain_simplification(self): Simplified version of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.finite_state_machine import duplicate_transition_add_input sage: T = Transducer([[1, 2, 1/4, 0], [1, -2, 1/4, 0], [1, -2, 1/2, 0], diff --git a/src/sage/combinat/finite_state_machine_generators.py b/src/sage/combinat/finite_state_machine_generators.py index 22c5ec6af9a..ee8c6455f64 100644 --- a/src/sage/combinat/finite_state_machine_generators.py +++ b/src/sage/combinat/finite_state_machine_generators.py @@ -1020,7 +1020,7 @@ def GrayCode(self): Cf. the :wikipedia:`Gray_code` for a description of the Gray code. - EXAMPLE:: + EXAMPLES:: sage: G = transducers.GrayCode() sage: G @@ -1093,7 +1093,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, A ``RecursionRule`` if the equation is of the first form described above and a dictionary ``{r: [t]}`` otherwise. - EXAMPLE:: + EXAMPLES:: sage: var('n') n diff --git a/src/sage/combinat/free_module.py b/src/sage/combinat/free_module.py index 08a476fbb75..dcc49e11b28 100644 --- a/src/sage/combinat/free_module.py +++ b/src/sage/combinat/free_module.py @@ -2466,7 +2466,7 @@ def cartesian_projection(self, i): - ``i`` -- an integer - EXAMPLE:: + EXAMPLES:: sage: F = CombinatorialFreeModule(ZZ, [4,5]); F.__custom_name = "F" sage: G = CombinatorialFreeModule(ZZ, [4,6]); G.__custom_name = "G" diff --git a/src/sage/combinat/matrices/hadamard_matrix.py b/src/sage/combinat/matrices/hadamard_matrix.py index 4c98fe2aec4..64f8b1d1003 100644 --- a/src/sage/combinat/matrices/hadamard_matrix.py +++ b/src/sage/combinat/matrices/hadamard_matrix.py @@ -239,7 +239,7 @@ def is_hadamard_matrix(M, normalized=False, skew=False, verbose=False): - ``verbose`` (boolean) -- whether to be verbose when the matrix is not Hadamard. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.matrices.hadamard_matrix import is_hadamard_matrix sage: h = matrix.hadamard(12) @@ -768,7 +768,7 @@ def _helper_payley_matrix(n, zero_position=True): :func:`rshcd_from_close_prime_powers` - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.matrices.hadamard_matrix import _helper_payley_matrix sage: _helper_payley_matrix(5) diff --git a/src/sage/combinat/matrices/latin.py b/src/sage/combinat/matrices/latin.py index ba9e474311f..02ce5790cd7 100644 --- a/src/sage/combinat/matrices/latin.py +++ b/src/sage/combinat/matrices/latin.py @@ -441,7 +441,7 @@ def actual_row_col_sym_sizes(self): right of self, and that the used symbols are in the range {0, 1, ..., m} (no holes in that list). - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.matrices.latin import * sage: B = back_circulant(3) @@ -503,7 +503,7 @@ def nr_distinct_symbols(self): Returns the number of distinct symbols in the partial latin square self. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.matrices.latin import * sage: back_circulant(5).nr_distinct_symbols() @@ -2533,7 +2533,7 @@ def tau_to_bitrade(t1, t2, t3): convert them to an explicit latin bitrade (T1, T2). The result is unique up to isotopism. - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.matrices.latin import * sage: T1 = back_circulant(5) diff --git a/src/sage/combinat/ordered_tree.py b/src/sage/combinat/ordered_tree.py index 7d52717516c..53ae2f6a190 100644 --- a/src/sage/combinat/ordered_tree.py +++ b/src/sage/combinat/ordered_tree.py @@ -1406,7 +1406,7 @@ def cardinality(self): """ Return the cardinality of ``self``. - EXAMPLE:: + EXAMPLES:: sage: LabelledOrderedTrees().cardinality() +Infinity @@ -1417,7 +1417,7 @@ def _an_element_(self): """ Return a labelled ordered tree. - EXAMPLE:: + EXAMPLES:: sage: LabelledOrderedTrees().an_element() # indirect doctest toto[3[], 42[3[], 3[]], 5[None[]]] diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index 98d82745b47..db9f00f1abb 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -802,7 +802,7 @@ def level(self): This method exists only for compatibility with :class:`PartitionTuples`. - EXAMPLE:: + EXAMPLES:: sage: Partition([4,3,2]).level() 1 @@ -1249,7 +1249,7 @@ def standard_tableaux(self): """ Return the :class:`standard tableaux` of this shape. - EXAMPLE:: + EXAMPLES:: sage: Partition([3,2,2,1]).standard_tableaux() Standard tableaux of shape [3, 2, 2, 1] @@ -2197,7 +2197,7 @@ def initial_column_tableau(self): entered in order from top to bottom and then left to right down the columns of ``self``. - EXAMPLE:: + EXAMPLES:: sage: Partition([3,2]).initial_column_tableau() [[1, 3, 5], [2, 4]] diff --git a/src/sage/combinat/partition_tuple.py b/src/sage/combinat/partition_tuple.py index b61add3daf5..d8047833ae1 100644 --- a/src/sage/combinat/partition_tuple.py +++ b/src/sage/combinat/partition_tuple.py @@ -483,7 +483,7 @@ def __len__(self): The length is also known as the level. - EXAMPLE:: + EXAMPLES:: sage: len( PartitionTuple([[2,1],[3,2],[1,1,1]]) ) 3 @@ -744,7 +744,7 @@ def components(self): the \"components\" of partition tuples of level 1 (partitions) and for higher levels. - EXAMPLE:: + EXAMPLES:: sage: for t in PartitionTuple([[2,1],[3,2],[3]]).components(): ....: print('%s\n' % t.ferrers_diagram()) @@ -847,7 +847,7 @@ def standard_tableaux(self): Return the :class:`standard tableau tuples` of this shape. - EXAMPLE:: + EXAMPLES:: sage: PartitionTuple([[],[3,2,2,1],[2,2,1],[3]]).standard_tableaux() Standard tableau tuples of shape ([], [3, 2, 2, 1], [2, 2, 1], [3]) @@ -1044,7 +1044,7 @@ def initial_tableau(self): entered in order from left to right along the rows of each component, where the components are ordered from left to right. - EXAMPLE:: + EXAMPLES:: sage: PartitionTuple([ [2,1],[3,2] ]).initial_tableau() ([[1, 2], [3]], [[4, 5, 6], [7, 8]]) @@ -1063,7 +1063,7 @@ def initial_column_tableau(self): to right, down the columns of each component, starting from the rightmost component and working to the left. - EXAMPLE:: + EXAMPLES:: sage: PartitionTuple([ [3,1],[3,2] ]).initial_column_tableau() ([[6, 8, 9], [7]], [[1, 3, 5], [2, 4]]) @@ -1446,7 +1446,7 @@ def young_subgroup(self): Return the corresponding Young, or parabolic, subgroup of the symmetric group. - EXAMPLE:: + EXAMPLES:: sage: PartitionTuple([[2,1],[4,2],[1]]).young_subgroup() Permutation Group with generators [(), (8,9), (6,7), (5,6), (4,5), (1,2)] @@ -1465,7 +1465,7 @@ def young_subgroup_generators(self): Return an indexing set for the generators of the corresponding Young subgroup. - EXAMPLE:: + EXAMPLES:: sage: PartitionTuple([[2,1],[4,2],[1]]).young_subgroup_generators() [1, 4, 5, 6, 8] @@ -1933,7 +1933,7 @@ def __init__(self): r""" Initializes the class. - EXAMPLE:: + EXAMPLES:: sage: TestSuite( PartitionTuples() ).run() """ diff --git a/src/sage/combinat/perfect_matching.py b/src/sage/combinat/perfect_matching.py index 7ca8e1df026..e2ee0812161 100644 --- a/src/sage/combinat/perfect_matching.py +++ b/src/sage/combinat/perfect_matching.py @@ -343,7 +343,7 @@ def conjugate_by_permutation(self, p): Returns the conjugate of the perfect matching ``self`` by the permutation ``p`` of the ground set. - EXAMPLE:: + EXAMPLES:: sage: m = PerfectMatching([(1,4),(2,6),(3,5)]) sage: m.conjugate_by_permutation(Permutation([4,1,5,6,3,2])) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index d839be39c7a..eaecd9def40 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -1520,7 +1520,7 @@ def _to_inversion_vector_divide_and_conquer(self): (This implementation is the best choice for ``size > 410`` approximately.) - EXAMPLE:: + EXAMPLES:: sage: p = Permutation([5,9,1,8,2,6,4,7,3]) sage: p._to_inversion_vector_divide_and_conquer() @@ -4697,7 +4697,7 @@ def hyperoctahedral_double_coset_type(self): semi-lengths of the cycles of this graph (see Chapter VII of [Mcd]_ for more details, particularly Section VII.2). - EXAMPLE:: + EXAMPLES:: sage: Permutation([3, 4, 6, 1, 5, 7, 2, 8]).hyperoctahedral_double_coset_type() [3, 1] diff --git a/src/sage/combinat/rooted_tree.py b/src/sage/combinat/rooted_tree.py index a32fc1735c4..6987d74d99c 100644 --- a/src/sage/combinat/rooted_tree.py +++ b/src/sage/combinat/rooted_tree.py @@ -975,7 +975,7 @@ def _an_element_(self): """ Return a labelled tree. - EXAMPLE:: + EXAMPLES:: sage: LabelledRootedTrees().an_element() # indirect doctest alpha[3[], 5[None[]], 42[3[], 3[]]] diff --git a/src/sage/combinat/shuffle.py b/src/sage/combinat/shuffle.py index 83c17ca82ce..926dc4c3a10 100644 --- a/src/sage/combinat/shuffle.py +++ b/src/sage/combinat/shuffle.py @@ -19,7 +19,7 @@ The shuffle product has been introduced by S. Eilenberg and S. Mac Lane in 1953 [EilLan53]_. -EXAMPLE:: +EXAMPLES:: sage: from sage.combinat.shuffle import ShuffleProduct sage: list(ShuffleProduct([1,2], ["a", "b", "c"])) @@ -71,7 +71,7 @@ class SetShuffleProduct(SageObject): sage: from sage.combinat.shuffle import SetShuffleProduct sage: TestSuite(SetShuffleProduct).run() - EXAMPLE:: + EXAMPLES:: sage: from sage.combinat.shuffle import SetShuffleProduct sage: sorted(SetShuffleProduct({(1,), (2,3)}, {(4,5), (6,)})) diff --git a/src/sage/combinat/subword_complex.py b/src/sage/combinat/subword_complex.py index 2886745f19e..1151fa28220 100644 --- a/src/sage/combinat/subword_complex.py +++ b/src/sage/combinat/subword_complex.py @@ -472,7 +472,7 @@ def upper_root_configuration(self): r""" Return the positive roots of the root configuration of ``self``. - EXAMPLE:: + EXAMPLES:: sage: W = ReflectionGroup(['A',2]) # optional - gap3 sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 @@ -1163,7 +1163,7 @@ def __eq__(self, other): - ``other`` -- another subword complex. - EXAMPLE:: + EXAMPLES:: sage: W = ReflectionGroup(['A',2]) # optional - gap3 sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 diff --git a/src/sage/combinat/tableau.py b/src/sage/combinat/tableau.py index fcb6b7c8ab4..e2f84aa6123 100644 --- a/src/sage/combinat/tableau.py +++ b/src/sage/combinat/tableau.py @@ -803,7 +803,7 @@ def level(self): This function exists mainly for compatibility with :class:`TableauTuple`. - EXAMPLE:: + EXAMPLES:: sage: Tableau([[1,2,3],[4,5]]).level() 1 diff --git a/src/sage/combinat/tableau_tuple.py b/src/sage/combinat/tableau_tuple.py index 056e38a0505..146549c2877 100644 --- a/src/sage/combinat/tableau_tuple.py +++ b/src/sage/combinat/tableau_tuple.py @@ -1895,7 +1895,7 @@ class TableauTuples(UniqueRepresentation, Parent): sage: t.category() Category of elements of Tableau tuples of level 3 - .. SEE ALSO:: + .. SEEALSO:: - :class:`Tableau` - :class:`StandardTableau` diff --git a/src/sage/combinat/words/finite_word.py b/src/sage/combinat/words/finite_word.py index 18c17470fc5..e8a8e22ecad 100644 --- a/src/sage/combinat/words/finite_word.py +++ b/src/sage/combinat/words/finite_word.py @@ -5171,7 +5171,7 @@ def charge(self, check=True): is found in the same manner from the remaining letters. In the following example, `w1, w2, w3` are the charge subwords of `w`. - EXAMPLE:: + EXAMPLES:: sage: w = Word([5,2,3,4,4,1,1,1,2,2,3]) sage: w1 = Word([5, 2, 4, 1, 3]) diff --git a/src/sage/combinat/words/words.py b/src/sage/combinat/words/words.py index ceb518d5da0..1a15b8413ac 100644 --- a/src/sage/combinat/words/words.py +++ b/src/sage/combinat/words/words.py @@ -1095,7 +1095,7 @@ def random_element(self, length=None, *args, **kwds): - all other argument are transmitted to the random generator of the alphabet - EXAMPLE:: + EXAMPLES:: sage: W = FiniteWords(5) sage: W.random_element() # random diff --git a/src/sage/crypto/boolean_function.pyx b/src/sage/crypto/boolean_function.pyx index f4b40f959ef..cd01f0217f5 100644 --- a/src/sage/crypto/boolean_function.pyx +++ b/src/sage/crypto/boolean_function.pyx @@ -348,7 +348,7 @@ cdef class BooleanFunction(SageObject): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: BooleanFunction(4) #indirect doctest @@ -363,7 +363,7 @@ cdef class BooleanFunction(SageObject): """ Return the complement Boolean function of `self`. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B=BooleanFunction([0, 1, 1, 0, 1, 0, 0, 0]) @@ -378,7 +378,7 @@ cdef class BooleanFunction(SageObject): """ Return the element wise sum of `self`and `other` which must have the same number of variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: A=BooleanFunction([0, 1, 0, 1, 1, 0, 0, 1]) @@ -409,7 +409,7 @@ cdef class BooleanFunction(SageObject): """ Return the elementwise multiplication of `self`and `other` which must have the same number of variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: A=BooleanFunction([0, 1, 0, 1, 1, 0, 0, 1]) @@ -440,7 +440,7 @@ cdef class BooleanFunction(SageObject): """ Return the concatenation of `self` and `other` which must have the same number of variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: A=BooleanFunction([0, 1, 0, 1]) @@ -519,7 +519,7 @@ cdef class BooleanFunction(SageObject): """ The number of variables of this function. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: BooleanFunction(4).nvariables() @@ -537,7 +537,7 @@ cdef class BooleanFunction(SageObject): - 'int' : we return a tuple of 0 or 1 values - 'hex' : we return a string representing the truth_table in hexadecimal - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: R. = BooleanPolynomialRing(3) @@ -578,7 +578,7 @@ cdef class BooleanFunction(SageObject): """ Return the number of different input values. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: len(BooleanFunction(4)) @@ -617,7 +617,7 @@ cdef class BooleanFunction(SageObject): - a list - then all elements are evaluated as Booleans - an integer - then we consider its binary representation - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction([0,1,0,0]) @@ -646,7 +646,7 @@ cdef class BooleanFunction(SageObject): """ Iterate through the value of the function. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction([0,1,1,0,1,0,1,0]) @@ -660,7 +660,7 @@ cdef class BooleanFunction(SageObject): """ Return the cached Walsh Hadamard transform. *Unsafe*, no check. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction(3) @@ -676,7 +676,7 @@ cdef class BooleanFunction(SageObject): .. MATH:: W(j) = \sum_{i\in\{0,1\}^n} (-1)^{f(i)\oplus i \cdot j} - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: R. = GF(2^3,'a')[] @@ -768,7 +768,7 @@ cdef class BooleanFunction(SageObject): to the linear functions, or the number of output ones need to change to obtain a linear function. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction(5) @@ -787,7 +787,7 @@ cdef class BooleanFunction(SageObject): """ Return True if the function is bent. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction("0113077C165E76A8") @@ -1051,7 +1051,7 @@ cdef class BooleanFunction(SageObject): """ Set a value of the function. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B=BooleanFunction([0,0,1,1]) @@ -1074,7 +1074,7 @@ cdef class BooleanFunction(SageObject): """ Return the value of the function for the given input. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B=BooleanFunction([0,1,1,1]) @@ -1087,7 +1087,7 @@ cdef class BooleanFunction(SageObject): """ Clear cached values. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction([0,1,1,0]) @@ -1107,7 +1107,7 @@ cdef class BooleanFunction(SageObject): def __reduce__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction([0,1,1,0]) @@ -1120,7 +1120,7 @@ def unpickle_BooleanFunction(bool_list): """ Specific function to unpickle Boolean functions. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction([0,1,1,0]) @@ -1137,7 +1137,7 @@ cdef class BooleanFunctionIterator: """ Iterator through the values of a Boolean function. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction(3) @@ -1152,7 +1152,7 @@ cdef class BooleanFunctionIterator: """ Iterator through the values of a Boolean function. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction(1) @@ -1165,7 +1165,7 @@ cdef class BooleanFunctionIterator: """ Next value. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction(1) @@ -1187,7 +1187,7 @@ def random_boolean_function(n): """ Returns a random Boolean function with `n` variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.boolean_function import random_boolean_function sage: B = random_boolean_function(9) diff --git a/src/sage/crypto/lfsr.py b/src/sage/crypto/lfsr.py index 6d1a9caa15f..b91dd0195d1 100644 --- a/src/sage/crypto/lfsr.py +++ b/src/sage/crypto/lfsr.py @@ -272,7 +272,7 @@ def lfsr_connection_polynomial(s): This implements the algorithm in section 3 of J. L. Massey's article [M]_. - EXAMPLE:: + EXAMPLES:: sage: F = GF(2) sage: F diff --git a/src/sage/crypto/lwe.py b/src/sage/crypto/lwe.py index 8d104f7c89d..b28b6054c50 100644 --- a/src/sage/crypto/lwe.py +++ b/src/sage/crypto/lwe.py @@ -110,7 +110,7 @@ class UniformSampler(SageObject): """ Uniform sampling in a range of integers. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import UniformSampler sage: sampler = UniformSampler(-2, 2); sampler @@ -131,7 +131,7 @@ def __init__(self, lower_bound, upper_bound): - ``lower_bound`` - integer - ``upper_bound`` - integer - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import UniformSampler sage: UniformSampler(-2, 2) @@ -146,7 +146,7 @@ def __call__(self): """ Return a new sample. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import UniformSampler sage: sampler = UniformSampler(-12, 12) @@ -157,7 +157,7 @@ def __call__(self): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import UniformSampler sage: UniformSampler(-2, 2) @@ -170,7 +170,7 @@ class UniformPolynomialSampler(SageObject): """ Uniform sampler for polynomials. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import UniformPolynomialSampler sage: UniformPolynomialSampler(ZZ['x'], 8, -2, 2)() @@ -192,7 +192,7 @@ def __init__(self, P, n, lower_bound, upper_bound): - ``lower_bound`` - integer - ``upper_bound`` - integer - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import UniformPolynomialSampler sage: UniformPolynomialSampler(ZZ['x'], 10, -10, 10) @@ -210,7 +210,7 @@ def __call__(self): """ Return a new sample. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import UniformPolynomialSampler sage: sampler = UniformPolynomialSampler(ZZ['x'], 8, -12, 12) @@ -223,7 +223,7 @@ def __call__(self): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import UniformPolynomialSampler sage: UniformPolynomialSampler(ZZ['x'], 8, -3, 3) @@ -320,7 +320,7 @@ def __init__(self, n, q, D, secret_dist='uniform', m=None): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_integer import DiscreteGaussianDistributionIntegerSampler sage: from sage.crypto.lwe import LWE @@ -339,7 +339,7 @@ def _repr_(self): def __call__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import DiscreteGaussianDistributionIntegerSampler, LWE sage: LWE(10, 401, DiscreteGaussianDistributionIntegerSampler(3))() @@ -520,7 +520,7 @@ def __init__(self, N, q, D, poly=None, secret_dist='uniform', m=None): - ``m`` - number of allowed samples or ``None`` if no such limit exists (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import RingLWE sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler @@ -556,7 +556,7 @@ def __init__(self, N, q, D, poly=None, secret_dist='uniform', m=None): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import DiscreteGaussianDistributionPolynomialSampler, RingLWE sage: D = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], n=8, sigma=3.0) @@ -571,7 +571,7 @@ def _repr_(self): def __call__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import DiscreteGaussianDistributionPolynomialSampler, RingLWE sage: N = 16 @@ -645,7 +645,7 @@ def __init__(self, ringlwe): - ``ringlwe`` - an instance of a :class:`RingLWE` - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import DiscreteGaussianDistributionPolynomialSampler, RingLWE, RingLWEConverter sage: D = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], euler_phi(16), 5) @@ -661,7 +661,7 @@ def __init__(self, ringlwe): def __call__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import DiscreteGaussianDistributionPolynomialSampler, RingLWE, RingLWEConverter sage: D = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], euler_phi(16), 5) @@ -682,7 +682,7 @@ def __call__(self): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import DiscreteGaussianDistributionPolynomialSampler, RingLWE, RingLWEConverter sage: D = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], euler_phi(20), 5) @@ -714,7 +714,7 @@ def samples(m, n, lwe, seed=None, balanced=False, **kwds): representations of finite field elements (default: ``False``) - ``**kwds`` - passed through to LWE constructor - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import samples, Regev sage: samples(2, 20, Regev, seed=1337) @@ -765,7 +765,7 @@ def balance_sample(s, q=None): - ``s`` - sample of the form (a,c) where a is a vector and c is a scalar - ``q`` - modulus (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.lwe import balance_sample, samples, Regev sage: list(map(balance_sample, samples(10, 5, Regev))) diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py index dfbb5e06d3b..dc3b51ed5d6 100644 --- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py +++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py @@ -14,7 +14,7 @@ class MPolynomialSystemGenerator(SageObject): def __getattr__(self, attr): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.mpolynomialsystemgenerator import MPolynomialSystemGenerator sage: msg = MPolynomialSystemGenerator() @@ -42,7 +42,7 @@ def varformatstr(self, name): INPUT: name -- string - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.mpolynomialsystemgenerator import MPolynomialSystemGenerator sage: msg = MPolynomialSystemGenerator() @@ -64,7 +64,7 @@ def varstrs(self, name, round): name -- string round -- integer index - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.mpolynomialsystemgenerator import MPolynomialSystemGenerator sage: msg = MPolynomialSystemGenerator() @@ -84,7 +84,7 @@ def vars(self, name, round): name -- string round -- integer index - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.mpolynomialsystemgenerator import MPolynomialSystemGenerator sage: msg = MPolynomialSystemGenerator() @@ -99,7 +99,7 @@ def ring(self): """ Return the ring in which the system is defined. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.mpolynomialsystemgenerator import MPolynomialSystemGenerator sage: msg = MPolynomialSystemGenerator() @@ -115,7 +115,7 @@ def block_order(self): Return a block term ordering for the equation systems generated by self. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.mpolynomialsystemgenerator import MPolynomialSystemGenerator sage: msg = MPolynomialSystemGenerator() @@ -134,7 +134,7 @@ def __call__(self, P, K): P -- plaintext (vector, list) K -- key (vector, list) - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.mpolynomialsystemgenerator import MPolynomialSystemGenerator sage: msg = MPolynomialSystemGenerator() @@ -149,7 +149,7 @@ def sbox(self): """ Return SBox object for self. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.mpolynomialsystemgenerator import MPolynomialSystemGenerator sage: msg = MPolynomialSystemGenerator() @@ -170,7 +170,7 @@ def polynomial_system(self, P=None, K=None): P -- plaintext (vector, list) K -- key (vector, list) - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.mpolynomialsystemgenerator import MPolynomialSystemGenerator sage: msg = MPolynomialSystemGenerator() @@ -186,7 +186,7 @@ def random_element(self): Return random element. Usually this is a list of elements in the base field of length 'blocksize'. - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.mpolynomialsystemgenerator import MPolynomialSystemGenerator sage: msg = MPolynomialSystemGenerator() diff --git a/src/sage/crypto/mq/sbox.py b/src/sage/crypto/mq/sbox.py index 303585a382c..17c1f9d3c37 100644 --- a/src/sage/crypto/mq/sbox.py +++ b/src/sage/crypto/mq/sbox.py @@ -145,7 +145,7 @@ def __init__(self, *args, **kwargs): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: mq.SBox(7,6,0,4,2,5,1,3) #indirect doctest (7, 6, 0, 4, 2, 5, 1, 3) @@ -156,7 +156,7 @@ def __len__(self): """ Return the length of input bit strings. - EXAMPLE:: + EXAMPLES:: sage: len(mq.SBox(7,6,0,4,2,5,1,3)) 3 @@ -168,7 +168,7 @@ def __eq__(self, other): S-boxes are considered to be equal if all construction parameters match. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: loads(dumps(S)) == S @@ -181,7 +181,7 @@ def __ne__(self, other): S-boxes are considered to be equal if all construction parameters match. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S != S @@ -200,7 +200,7 @@ def to_bits(self, x, n=None): - ``n`` - bit length (optional) - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S.to_bits(6) @@ -231,7 +231,7 @@ def from_bits(self, x, n=None): - ``n`` - bit length (optional) - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S.from_bits( [1,1,0]) @@ -256,7 +256,7 @@ def _rpad(self,x, n=None): """ Right pads ``x`` such that ``len(x) == n``. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S._rpad([1,1]) @@ -280,7 +280,7 @@ def __call__(self, X): `\GF{2^n}`. As a last resort this function tries to convert ``X`` to an integer. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox([7,6,0,4,2,5,1,3]) sage: S(7) @@ -364,7 +364,7 @@ def __getitem__(self, X): """ See :meth:`SBox.__call__`. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox([7,6,0,4,2,5,1,3]) sage: S[7] @@ -376,7 +376,7 @@ def is_permutation(self): r""" Return ``True`` if this S-Box is a permutation. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S.is_permutation() @@ -392,7 +392,7 @@ def is_permutation(self): def __iter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: [e for e in S] @@ -415,7 +415,7 @@ def difference_distribution_matrix(self): See [He2002]_ for an introduction to differential cryptanalysis. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S.difference_distribution_matrix() @@ -451,7 +451,7 @@ def maximal_difference_probability_absolute(self): Equivalently, this is equal to the differential uniformity of this S-Box. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S.maximal_difference_probability_absolute() @@ -471,7 +471,7 @@ def maximal_difference_probability(self): highest probability in the range between 0.0 and 1.0 indicating 0\% or 100\% respectively. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S.maximal_difference_probability() @@ -492,7 +492,7 @@ def linear_approximation_matrix(self): See [He2002]_ for an introduction to linear cryptanalysis. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S.linear_approximation_matrix() @@ -543,7 +543,7 @@ def maximal_linear_bias_absolute(self): approximation with the highest bias is true or false minus `2^{n-1}`. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S.maximal_linear_bias_absolute() @@ -558,7 +558,7 @@ def maximal_linear_bias_relative(self): Return maximal bias of all linear approximations of this S-box. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S.maximal_linear_bias_relative() @@ -571,7 +571,7 @@ def ring(self): Create, return and cache a polynomial ring for S-box polynomials. - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: S.ring() @@ -600,7 +600,7 @@ def solutions(self, X=None, Y=None): - ``Y`` - output variables (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox([7,6,0,4,2,5,1,3]) sage: F = S.polynomials() @@ -774,7 +774,7 @@ def interpolation_polynomial(self, k=None): - ``k`` - an instance of `\GF{2^m}` (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: S = mq.SBox(7,6,0,4,2,5,1,3) sage: f = S.interpolation_polynomial() diff --git a/src/sage/crypto/mq/sr.py b/src/sage/crypto/mq/sr.py index 15ce89b3930..cbe18f38a5c 100644 --- a/src/sage/crypto/mq/sr.py +++ b/src/sage/crypto/mq/sr.py @@ -482,7 +482,7 @@ def new_generator(self, **kwds): - ``**kwds`` - see the ``SR`` constructor for accepted parameters - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2,1,1,4); sr SR(2,1,1,4) @@ -538,7 +538,7 @@ def new_generator(self, **kwds): def __getattr__(self, attr): """ - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 2, 1, 4, gf2=True) sage: sr.Mstar @@ -608,7 +608,7 @@ def base_ring(self): Return the base field of self as determined by ``self.e``. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(10, 2, 2, 4) sage: sr.base_ring().polynomial() @@ -635,7 +635,7 @@ def __cmp__(self, other): Two generators are considered equal if they agree on all parameters passed to them during construction. - EXAMPLE:: + EXAMPLES:: sage: sr1 = mq.SR(2, 2, 2, 4) sage: sr2 = mq.SR(2, 2, 2, 4) @@ -665,7 +665,7 @@ def sub_bytes(self, d): - ``d`` - state array or something coercible to a state array - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 1, 2, 8, gf2=True) sage: k = sr.base_ring() @@ -764,7 +764,7 @@ def sbox_constant(self): performed. That is ``0x63`` if ``e == 8`` or ``0x6`` if ``e == 4``. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(10, 1, 1, 8) sage: sr.sbox_constant() @@ -787,7 +787,7 @@ def sbox(self, inversion_only=False): - ``inversion_only`` - do not include the `\GF{2}` affine map when computing the S-Box (default: ``False``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1,2,2,4, allow_zero_inversions=True) sage: S = sr.sbox(); S @@ -969,7 +969,7 @@ def add_round_key(self, d, key): state array - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(10, 4, 4, 4) sage: D = sr.random_state_array() @@ -1034,7 +1034,7 @@ def is_state_array(self, d): Return ``True`` if ``d`` is a state array, i.e. has the correct dimensions and base field. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 2, 4, 8) sage: k = sr.base_ring() @@ -1058,7 +1058,7 @@ def random_state_array(self, *args, **kwds): Return a random element in ``MatrixSpace(self.base_ring(), self.r, self.c)``. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 2, 2, 4) sage: sr.random_state_array() @@ -1072,7 +1072,7 @@ def random_vector(self, *args, **kwds): Return a random vector as it might appear in the algebraic expression of self. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 2, 2, 4) sage: sr.random_vector() @@ -1111,7 +1111,7 @@ def random_element(self, elem_type = "vector", *args, **kwds): (default: ``'vector'``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR() sage: sr.random_element() @@ -1399,7 +1399,7 @@ def hex_str(self, M, typ="matrix"): or 'vector' (default: ``'matrix'``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 2, 2, 4) sage: k = sr.base_ring() @@ -1431,7 +1431,7 @@ def hex_str_matrix(self, M): - ``M`` - an AES state array - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 2, 2, 4) sage: k = sr.base_ring() @@ -1462,7 +1462,7 @@ def hex_str_vector(self, M): - ``M`` - an AES state array - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 2, 2, 4) sage: k = sr.base_ring() @@ -1497,7 +1497,7 @@ def _insert_matrix_into_matrix(self, dst, src, row, col): - ``col`` - offset columns - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(10, 4, 4, 4) sage: a = sr.k.gen() @@ -1538,7 +1538,7 @@ def varformatstr(self, name, n=None, rc=None, e=None): - ``e`` - exponent of base field (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 2, 2, 4) sage: sr.varformatstr('x') @@ -1573,7 +1573,7 @@ def varstr(self, name, nr, rc, e): - ``rc`` - row*column index in state array - ``e`` - exponent of base field - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(10, 1, 2, 4) sage: sr.varstr('x', 2, 1, 1) @@ -1593,7 +1593,7 @@ def varstrs(self, name, nr, rc = None, e = None): - ``rc`` - number of rows * number of columns in the state array (default: ``None``) - ``e`` - exponent of base field (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(10, 1, 2, 4) sage: sr.varstrs('x', 2) @@ -1623,7 +1623,7 @@ def vars(self, name, nr, rc=None, e=None): - ``rc`` - number of rounds * number of columns in the state array (default: ``None``) - ``e`` - exponent of base field (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(10, 1, 2, 4) sage: sr.vars('x', 2) @@ -1638,7 +1638,7 @@ def variable_dict(self): Return a dictionary to access variables in ``self.R`` by their names. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1,1,1,4) sage: sr.variable_dict() @@ -1704,7 +1704,7 @@ def block_order(self): """ Return a block order for self where each round is a block. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 1, 1, 4) sage: sr.block_order() @@ -1768,7 +1768,7 @@ def ring(self, order=None, reverse_variables=None): `r=2` and `c=2` then refers to the *most* significant bit of the entry in the position (1,0) in the state array matrix. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 1, 1, 4) sage: P = sr.ring(order='block') @@ -1848,7 +1848,7 @@ def round_polynomials(self, i, plaintext=None, ciphertext=None): OUTPUT: tuple - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 4) sage: k = sr.base_ring() @@ -1909,7 +1909,7 @@ def key_schedule_polynomials(self, i): - ``i`` - round (`0 \leq i \leq n`) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 4, gf2=True, polybori=False) @@ -2013,7 +2013,7 @@ def polynomial_system(self, P=None, K=None, C=None): - ``K`` - vector, list, or tuple (default: ``None``) - ``C`` - vector, list, or tuple (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 4, gf2=True, polybori=True) sage: P = sr.vector([0, 0, 1, 0]) @@ -2156,7 +2156,7 @@ def vector(self, d=None): - ``d`` - values for vector, must be understood by ``self.phi`` (default:``None``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR() sage: sr @@ -2183,7 +2183,7 @@ def is_vector(self, d): """ Return ``True`` if ``d`` can be used as a vector for ``self``. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR() sage: sr @@ -2211,7 +2211,7 @@ def phi(self, l): - ``l`` - element to perform `\phi` on. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 1, 2, 4) sage: k = sr.base_ring() @@ -2246,7 +2246,7 @@ def antiphi(self, l): - ``l`` -- a vector in the sense of :meth:`is_vector` - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR() sage: A = sr.random_state_array() @@ -2274,7 +2274,7 @@ def shift_rows_matrix(self): """ Return the ``ShiftRows`` matrix. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 2, 2, 4) sage: s = sr.random_state_array() @@ -2312,7 +2312,7 @@ def lin_matrix(self, length = None): - ``length`` - length of state space (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 4) sage: sr.lin_matrix() @@ -2349,7 +2349,7 @@ def mix_columns_matrix(self): """ Return the ``MixColumns`` matrix. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 2, 2, 4) sage: s = sr.random_state_array() @@ -2364,7 +2364,7 @@ def D(b): Return the `e x e` matrix `D` with `b^i` along the diagonal. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 2, 1, 4) sage: sr.mix_columns_matrix() # indirect doctest @@ -2441,7 +2441,7 @@ def inversion_polynomials(self, xi, wi, length): - ``length`` - length of both lists - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 8) sage: R = sr.ring() @@ -2470,7 +2470,7 @@ def field_polynomials(self, name, i, l=None): - ``i`` - round number - ``l`` - r\*c (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(3, 1, 1, 8) sage: sr.field_polynomials('x', 2) @@ -2500,7 +2500,7 @@ def __init__(self, n=1, r=1, c=1, e=4, star=False, **kwargs): Small Scale Variants of the AES polynomial system constructor over `\GF{2}`. See help for SR. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(gf2=True) sage: sr @@ -2520,7 +2520,7 @@ def vector(self, d=None): - ``d`` - values for vector (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(gf2=True) sage: sr @@ -2566,7 +2566,7 @@ def is_vector(self, d): - ``d`` - matrix - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(gf2=True) sage: sr @@ -2598,7 +2598,7 @@ def phi(self, l, diffusion_matrix=False): transformed to a matrix which performs the same operation over `\GF{2}` as ``l`` over `\GF{2^n}` (default: ``False``). - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(2, 1, 2, 4, gf2=True) sage: k = sr.base_ring() @@ -2652,7 +2652,7 @@ def antiphi(self, l): - ``l`` - a vector in the sense of ``self.is_vector`` - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(gf2=True) sage: A = sr.random_state_array() @@ -2686,7 +2686,7 @@ def shift_rows_matrix(self): """ Return the ``ShiftRows`` matrix. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 2, 2, 4, gf2=True) sage: s = sr.random_state_array() @@ -2711,7 +2711,7 @@ def mix_columns_matrix(self): """ Return the ``MixColumns`` matrix. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 2, 2, 4, gf2=True) sage: s = sr.random_state_array() @@ -2760,7 +2760,7 @@ def lin_matrix(self, length=None): - ``length`` - length of state space (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 4, gf2=True) sage: sr.lin_matrix() @@ -2810,7 +2810,7 @@ def _mul_matrix(self, x): - ``x`` - an element in self.base_ring() - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(gf2=True) sage: a = sr.k.gen() @@ -2838,7 +2838,7 @@ def _square_matrix(self): Return a matrix of dimension self.e x self.e which performs the squaring operation over `GF(2^n)` on vectors of length e. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(gf2=True) sage: a = sr.k.gen() @@ -3163,7 +3163,7 @@ def inversion_polynomials(self, xi, wi, length): - ``length`` - length of both lists - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 8, gf2=True) sage: xi = sr.vars('x', 1) @@ -3195,7 +3195,7 @@ def field_polynomials(self, name, i, l=None): - ``i`` - round number - ``l`` - length of variable list (default: ``None`` = r\*c) - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(3, 1, 1, 8, gf2=True, polybori=False) sage: sr.field_polynomials('x', 2) @@ -3314,7 +3314,7 @@ class AllowZeroInversionsContext: """ def __init__(self, sr): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.sr import AllowZeroInversionsContext sage: sr = mq.SR(1,2,2,4) @@ -3325,7 +3325,7 @@ def __init__(self, sr): self.sr = sr def __enter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.sr import AllowZeroInversionsContext sage: sr = mq.SR(1,2,2,4) @@ -3342,7 +3342,7 @@ def __enter__(self): self.sr._allow_zero_inversions = True def __exit__(self, typ, value, tb): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.crypto.mq.sr import AllowZeroInversionsContext sage: sr = mq.SR(1,2,2,4) diff --git a/src/sage/crypto/stream_cipher.py b/src/sage/crypto/stream_cipher.py index 337b2aef5f6..0d7b011809b 100644 --- a/src/sage/crypto/stream_cipher.py +++ b/src/sage/crypto/stream_cipher.py @@ -76,7 +76,7 @@ def __call__(self, M, mode = "ECB"): - ``mode`` - ignored (default: 'ECB') - EXAMPLE:: + EXAMPLES:: sage: k = GF(2) sage: P. = PolynomialRing( k ) @@ -121,7 +121,7 @@ def connection_polynomial(self): """ The connection polynomial defining the LFSR of the cipher. - EXAMPLE:: + EXAMPLES:: sage: k = GF(2) sage: P. = PolynomialRing( k ) @@ -136,7 +136,7 @@ def initial_state(self): """ The initial state of the LFSR cipher. - EXAMPLE:: + EXAMPLES:: sage: k = GF(2) sage: P. = PolynomialRing( k ) @@ -186,7 +186,7 @@ def keystream_cipher(self): """ The LFSR cipher generating the output key stream. - EXAMPLE:: + EXAMPLES:: sage: FF = FiniteField(2) sage: P. = PolynomialRing(FF) @@ -206,7 +206,7 @@ def decimating_cipher(self): """ The LFSR cipher generating the decimating key stream. - EXAMPLE:: + EXAMPLES:: sage: FF = FiniteField(2) sage: P. = PolynomialRing(FF) diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx index bfb3a93e3d4..35bf6256d7f 100644 --- a/src/sage/data_structures/bitset.pyx +++ b/src/sage/data_structures/bitset.pyx @@ -1300,7 +1300,7 @@ cdef class Bitset(FrozenBitset): """ Raise an error, since mutable ``Bitset``s are not hashable. - EXAMPLE:: + EXAMPLES:: sage: hash(Bitset('110')) Traceback (most recent call last): diff --git a/src/sage/databases/stein_watkins.py b/src/sage/databases/stein_watkins.py index 67b7fe904b7..3bf373a1d14 100644 --- a/src/sage/databases/stein_watkins.py +++ b/src/sage/databases/stein_watkins.py @@ -279,7 +279,7 @@ def iter_levels(self): Iterate through the curve classes, but grouped into lists by level. - EXAMPLE:: + EXAMPLES:: sage: d = SteinWatkinsAllData(1) sage: E = d.iter_levels() diff --git a/src/sage/doctest/fixtures.py b/src/sage/doctest/fixtures.py index 3f1dec91dd7..498e18f49ee 100644 --- a/src/sage/doctest/fixtures.py +++ b/src/sage/doctest/fixtures.py @@ -71,7 +71,7 @@ def reproducible_repr(val): returns but for certain cases with more guarantees to ensure exactly the same result for semantically equivalent objects. - EXAMPLE:: + EXAMPLES:: sage: from sage.doctest.fixtures import reproducible_repr sage: print(reproducible_repr(set(["a", "c", "b", "d"]))) @@ -132,7 +132,7 @@ def __init__(self, delegate, prefix=" ", reads=True): - ``reads`` -- (default: ``True``) whether to trace read access as well. - EXAMPLE:: + EXAMPLES:: sage: class Foo(object): ....: def f(self, *args): @@ -164,7 +164,7 @@ def get(self, name): function to report arguments and return value. Otherwise an attribute read access is reported. - EXAMPLE:: + EXAMPLES:: sage: class Foo(object): ....: def f(self, *args): @@ -206,7 +206,7 @@ def set(self, name, val): The name and new value are also reported in the output. - EXAMPLE:: + EXAMPLES:: sage: class Foo(object): ....: pass @@ -245,7 +245,7 @@ def __init__(self, delegate, **kwds): - ``reads`` -- (default: ``True``) whether to trace read access as well. - EXAMPLE:: + EXAMPLES:: sage: class Foo(object): ....: def f(self, *args): @@ -279,7 +279,7 @@ def __getattribute__(self, name): function to report arguments and return value. Otherwise an attribute read access is reported. - EXAMPLE:: + EXAMPLES:: sage: class Foo(object): ....: def f(self, *args): @@ -305,7 +305,7 @@ def __setattr__(self, name, val): The name and new value are also reported in the output. - EXAMPLE:: + EXAMPLES:: sage: class Foo(object): ....: pass @@ -342,7 +342,7 @@ def trace_method(obj, meth, **kwds): whether to trace read access as well. - EXAMPLE:: + EXAMPLES:: sage: class Foo(object): ....: def f(self, arg=None): diff --git a/src/sage/dynamics/interval_exchanges/iet.py b/src/sage/dynamics/interval_exchanges/iet.py index b28e9e4da38..c6c62bb580e 100644 --- a/src/sage/dynamics/interval_exchanges/iet.py +++ b/src/sage/dynamics/interval_exchanges/iet.py @@ -589,7 +589,7 @@ def singularities(self): list -- two lists of positive numbers which corresponds to extremities of subintervals - EXAMPLE:: + EXAMPLES:: sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1/2,3/2]) sage: t.singularities() diff --git a/src/sage/dynamics/interval_exchanges/labelled.py b/src/sage/dynamics/interval_exchanges/labelled.py index 22c58ee61f1..758b4887b7b 100644 --- a/src/sage/dynamics/interval_exchanges/labelled.py +++ b/src/sage/dynamics/interval_exchanges/labelled.py @@ -1942,7 +1942,7 @@ def reduced(self): permutation -- the associated reduced permutation - EXAMPLE:: + EXAMPLES:: sage: p = iet.GeneralizedPermutation('a a','b b c c',flips='a') sage: q = iet.GeneralizedPermutation('a a','b b c c',flips='a',reduced=True) @@ -2210,7 +2210,7 @@ def is_full(self): boolean -- ``True`` if the path is full and ``False`` else - EXAMPLE:: + EXAMPLES:: sage: p = iet.Permutation('a b c','c b a') sage: r = p.rauzy_diagram() @@ -2235,7 +2235,7 @@ def edge_to_interval_substitution(self, p=None, edge_type=None): WordMorphism -- the WordMorphism corresponding to the edge - EXAMPLE:: + EXAMPLES:: sage: p = iet.Permutation('a b c','c b a') sage: r = p.rauzy_diagram() @@ -2265,7 +2265,7 @@ def edge_to_orbit_substitution(self, p=None, edge_type=None): WordMorphism -- the word morphism corresponding to the edge - EXAMPLE:: + EXAMPLES:: sage: p = iet.Permutation('a b c','c b a') sage: r = p.rauzy_diagram() @@ -2301,7 +2301,7 @@ def full_loop_iterator(self, start=None, max_length=1): iterator -- iterator over full loops - EXAMPLE:: + EXAMPLES:: sage: p = iet.Permutation('a b','b a') sage: r = p.rauzy_diagram() @@ -2340,7 +2340,7 @@ def full_nloop_iterator(self, start=None, length=1): iterator -- an iterator over the full loops of given length - EXAMPLE:: + EXAMPLES:: sage: p = iet.Permutation('a b','b a') sage: d = p.rauzy_diagram() diff --git a/src/sage/dynamics/interval_exchanges/reduced.py b/src/sage/dynamics/interval_exchanges/reduced.py index ca0a6f26ad4..faa0d976baa 100644 --- a/src/sage/dynamics/interval_exchanges/reduced.py +++ b/src/sage/dynamics/interval_exchanges/reduced.py @@ -712,7 +712,7 @@ def rauzy_move_relabel(self, winner, side='right'): r""" Returns the relabelization obtained from this move. - EXAMPLE:: + EXAMPLES:: sage: p = iet.Permutation('a b c d','d c b a') sage: q = p.reduced() @@ -1238,7 +1238,7 @@ def right_rauzy_move(self, winner): r""" Performs a Rauzy move on the right. - EXAMPLE:: + EXAMPLES:: sage: p = iet.Permutation('a b c','c b a',reduced=True,flips='c') sage: p.right_rauzy_move('top') diff --git a/src/sage/finance/time_series.pyx b/src/sage/finance/time_series.pyx index 8cb54613ba1..75d6dd1aa54 100644 --- a/src/sage/finance/time_series.pyx +++ b/src/sage/finance/time_series.pyx @@ -1514,7 +1514,7 @@ cdef class TimeSeries: A time series. - EXAMPLE:: + EXAMPLES:: sage: v = finance.TimeSeries([13,8,15,4,4,12,11,7,14,12]) sage: v.autocorrelation() @@ -1548,7 +1548,7 @@ cdef class TimeSeries: A double. - EXAMPLE:: + EXAMPLES:: sage: v = finance.TimeSeries([1,1,1,2,3]); v [1.0000, 1.0000, 1.0000, 2.0000, 3.0000] diff --git a/src/sage/functions/piecewise.py b/src/sage/functions/piecewise.py index bffa81616d6..ae50c0dbfe9 100644 --- a/src/sage/functions/piecewise.py +++ b/src/sage/functions/piecewise.py @@ -1154,7 +1154,7 @@ def fourier_series_partial_sum(cls, self, parameters, variable, N, L): as a string. - EXAMPLE:: + EXAMPLES:: sage: f(x) = x^2 sage: f = piecewise([[(-1,1),f]]) diff --git a/src/sage/functions/piecewise_old.py b/src/sage/functions/piecewise_old.py index db6b36cae68..723d6ae94c3 100644 --- a/src/sage/functions/piecewise_old.py +++ b/src/sage/functions/piecewise_old.py @@ -1283,7 +1283,7 @@ def fourier_series_partial_sum(self,N,L): as a string. - EXAMPLE:: + EXAMPLES:: sage: f(x) = x^2 sage: f = Piecewise([[(-1,1),f]]) @@ -1311,7 +1311,7 @@ def fourier_series_partial_sum_cesaro(self,N,L): as a string. This is a "smoother" partial sum - the Gibbs phenomenon is mollified. - EXAMPLE:: + EXAMPLES:: sage: f(x) = x^2 sage: f = Piecewise([[(-1,1),f]]) @@ -1339,7 +1339,7 @@ def fourier_series_partial_sum_hann(self,N,L): as a string, where `H_N(x) = (1+\cos(\pi x/N))/2`. This is a "smoother" partial sum - the Gibbs phenomenon is mollified. - EXAMPLE:: + EXAMPLES:: sage: f(x) = x^2 sage: f = Piecewise([[(-1,1),f]]) @@ -1368,7 +1368,7 @@ def fourier_series_partial_sum_filtered(self,N,L,F): of length `N` consisting of real numbers. This can be used to plot FS solutions to the heat and wave PDEs. - EXAMPLE:: + EXAMPLES:: sage: f(x) = x^2 sage: f = Piecewise([[(-1,1),f]]) @@ -1394,7 +1394,7 @@ def plot_fourier_series_partial_sum(self,N,L,xmin,xmax, **kwds): over xmin x xmin. - EXAMPLE:: + EXAMPLES:: sage: f1(x) = -2 sage: f2(x) = 1 @@ -1427,7 +1427,7 @@ def plot_fourier_series_partial_sum_cesaro(self,N,L,xmin,xmax, **kwds): over xmin x xmin. This is a "smoother" partial sum - the Gibbs phenomenon is mollified. - EXAMPLE:: + EXAMPLES:: sage: f1(x) = -2 sage: f2(x) = 1 @@ -1460,7 +1460,7 @@ def plot_fourier_series_partial_sum_hann(self,N,L,xmin,xmax, **kwds): over xmin x xmin, where H_N(x) = (0.5)+(0.5)\*cos(x\*pi/N) is the N-th Hann filter. - EXAMPLE:: + EXAMPLES:: sage: f1(x) = -2 sage: f2(x) = 1 @@ -1494,7 +1494,7 @@ def plot_fourier_series_partial_sum_filtered(self,N,L,F,xmin,xmax, **kwds): list of length `N` consisting of real numbers. This can be used to plot FS solutions to the heat and wave PDEs. - EXAMPLE:: + EXAMPLES:: sage: f1(x) = -2 sage: f2(x) = 1 diff --git a/src/sage/games/sudoku.py b/src/sage/games/sudoku.py index c4f07c940b8..66ba578e48c 100644 --- a/src/sage/games/sudoku.py +++ b/src/sage/games/sudoku.py @@ -102,7 +102,7 @@ class Sudoku(SageObject): - verify_input - default = ``True``, use ``False`` if you know the input is valid - EXAMPLE:: + EXAMPLES:: sage: a = Sudoku('5...8..49...5...3..673....115..........2.8..........187....415..3...2...49..5...3') sage: print(a) @@ -249,7 +249,7 @@ def _repr_(self): See the docstring for :func:`to_ascii` for more information on the format. - EXAMPLE:: + EXAMPLES:: sage: s = Sudoku('.4..32....14..3.') sage: s._repr_() @@ -262,7 +262,7 @@ def _latex_(self): r"""nodetex Returns a `\LaTeX` representation of a Sudoku puzzle as an array environment. - EXAMPLE:: + EXAMPLES:: sage: s = Sudoku('.4..32....14..3.') sage: s._latex_() @@ -278,7 +278,7 @@ def _matrix_(self, R=None): The base ring will be `\ZZ` if ``None`` is provided, and it is an error to specify any other base ring. - EXAMPLE:: + EXAMPLES:: sage: k = Sudoku('.4..32....14..3.') sage: matrix(k) # indirect doctest @@ -311,7 +311,7 @@ def to_string(self): ``11 = b``, etc. This scheme limits puzzles to at most 36 symbols. - EXAMPLE:: + EXAMPLES:: sage: b = matrix(ZZ, 9, 9, [ [0,0,0,0,1,0,9,0,0], [8,0,0,4,0,0,0,0,0], [2,0,0,0,0,0,0,0,0], [0,7,0,0,3,0,0,0,0], [0,0,0,0,0,0,2,0,4], [0,0,0,0,0,0,0,5,8], [0,6,0,0,0,0,1,3,0], [7,0,0,2,0,0,0,0,0], [0,0,0,8,0,0,0,0,0] ]) sage: Sudoku(b).to_string() @@ -355,7 +355,7 @@ def to_list(self): r""" Constructs a list representing a Sudoku puzzle, in row-major order. - EXAMPLE:: + EXAMPLES:: sage: s = Sudoku('1.......2.9.4...5...6...7...5.9.3.......7.......85..4.7.....6...3...9.8...2.....1') sage: s.to_list() @@ -403,7 +403,7 @@ def to_ascii(self): Constructs an ASCII-art version of a Sudoku puzzle. This is a modified version of the ASCII version of a subdivided matrix. - EXAMPLE:: + EXAMPLES:: sage: s = Sudoku('.4..32....14..3.') sage: print(s.to_ascii()) @@ -432,7 +432,7 @@ def to_latex(self): r""" Creates a string of `\LaTeX` code representing a Sudoku puzzle or solution. - EXAMPLE:: + EXAMPLES:: sage: s = Sudoku('.4..32....14..3.') sage: print(s.to_latex()) diff --git a/src/sage/geometry/fan_isomorphism.py b/src/sage/geometry/fan_isomorphism.py index 656163d9b2c..5c15b239b0e 100644 --- a/src/sage/geometry/fan_isomorphism.py +++ b/src/sage/geometry/fan_isomorphism.py @@ -207,7 +207,7 @@ def find_isomorphism(fan1, fan2, check=False): A fan isomorphism. If the fans are not isomorphic, a :class:`FanNotIsomorphicError` is raised. - EXAMPLE:: + EXAMPLES:: sage: rays = ((1, 1), (0, 1), (-1, -1), (3, 1)) sage: cones = [(0,1), (1,2), (2,3), (3,0)] diff --git a/src/sage/geometry/lattice_polytope.py b/src/sage/geometry/lattice_polytope.py index 53c73c42c8a..91496a4a22c 100644 --- a/src/sage/geometry/lattice_polytope.py +++ b/src/sage/geometry/lattice_polytope.py @@ -4377,7 +4377,7 @@ def Delta_polar(self): See :class:`nef-partition ` class documentation for definitions and notation. - EXAMPLE:: + EXAMPLES:: sage: o = lattice_polytope.cross_polytope(3) sage: np = o.nef_partitions()[0] diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 2cb1a18e80e..37f4bab6b55 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -888,7 +888,7 @@ def write_cdd_Hrepresentation(self, filename): :meth:`cdd_Hrepresentation` -- return the H-representation of the polyhedron as a string. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.temporary_file import tmp_filename sage: filename = tmp_filename(ext='.ext') @@ -950,7 +950,7 @@ def write_cdd_Vrepresentation(self, filename): :meth:`cdd_Vrepresentation` -- return the V-representation of the polyhedron as a string. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.temporary_file import tmp_filename sage: filename = tmp_filename(ext='.ext') diff --git a/src/sage/geometry/polyhedron/parent.py b/src/sage/geometry/polyhedron/parent.py index 09055eb8f1b..b08d8e970a3 100644 --- a/src/sage/geometry/polyhedron/parent.py +++ b/src/sage/geometry/polyhedron/parent.py @@ -545,7 +545,7 @@ def _coerce_map_from_(self, X): Boolean. - EXAMPLE:: + EXAMPLES:: sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(QQ,3).has_coerce_map_from( Polyhedra(ZZ,3) ) # indirect doctest diff --git a/src/sage/geometry/polyhedron/plot.py b/src/sage/geometry/polyhedron/plot.py index a50eb16cdb5..9bea2fb3ef2 100644 --- a/src/sage/geometry/polyhedron/plot.py +++ b/src/sage/geometry/polyhedron/plot.py @@ -716,7 +716,7 @@ def show(self, *args, **kwds): Deprecated method to show the projection as a graphics object. Use ``Projection.plot()`` instead. - EXAMPLE:: + EXAMPLES:: sage: P8 = polytopes.hypercube(4) sage: P8.schlegel_projection([2,5,11,17]).show() @@ -1515,7 +1515,7 @@ def _tikz_2d_in_3d(self, view, angle, scale, edge_color, facet_color, - LatexExpr -- containing the TikZ picture. - EXAMPLE:: + EXAMPLES:: sage: P = Polyhedron(vertices=[[-1, -1, 2],[-1, 2, -1],[2, -1, -1]]) sage: P diff --git a/src/sage/geometry/pseudolines.py b/src/sage/geometry/pseudolines.py index 0f9fdf0b605..ea8f58b7c93 100644 --- a/src/sage/geometry/pseudolines.py +++ b/src/sage/geometry/pseudolines.py @@ -308,7 +308,7 @@ def transpositions(self): See the :mod:`pseudolines module `'s documentation for more information on this encoding. - EXAMPLE:: + EXAMPLES:: sage: from sage.geometry.pseudolines import PseudolineArrangement sage: permutations = [[3, 2, 1], [3, 2, 0], [3, 1, 0], [2, 1, 0]] @@ -365,7 +365,7 @@ def permutations(self): See the :mod:`pseudolines module `'s documentation for more information on this encoding. - EXAMPLE:: + EXAMPLES:: sage: from sage.geometry.pseudolines import PseudolineArrangement sage: permutations = [[3, 2, 1], [3, 2, 0], [3, 1, 0], [2, 1, 0]] @@ -382,7 +382,7 @@ def felsner_matrix(self): See the :mod:`pseudolines module `'s documentation for more information on this encoding. - EXAMPLE:: + EXAMPLES:: sage: from sage.geometry.pseudolines import PseudolineArrangement sage: permutations = [[3, 2, 1], [3, 2, 0], [3, 1, 0], [2, 1, 0]] @@ -412,7 +412,7 @@ def show(self, **args): particular, to tune the dimensions, use the ``figsize`` argument (example below). - EXAMPLE:: + EXAMPLES:: sage: from sage.geometry.pseudolines import PseudolineArrangement sage: permutations = [[3, 2, 1], [3, 2, 0], [3, 1, 0], [2, 1, 0]] @@ -470,7 +470,7 @@ def __repr__(self): r""" A short txt description of the pseudoline arrangement. - EXAMPLE:: + EXAMPLES:: sage: from sage.geometry.pseudolines import PseudolineArrangement sage: permutations = [[3, 2, 1], [3, 2, 0], [3, 1, 0], [2, 1, 0]] diff --git a/src/sage/geometry/triangulation/point_configuration.py b/src/sage/geometry/triangulation/point_configuration.py index 6a67d425458..bdafadbeade 100644 --- a/src/sage/geometry/triangulation/point_configuration.py +++ b/src/sage/geometry/triangulation/point_configuration.py @@ -1525,7 +1525,7 @@ def positive_circuits(self, *negative): A tuple of all circuits with `C_-` = ``negative``. - EXAMPLE:: + EXAMPLES:: sage: p = PointConfiguration([(1,0,0),(0,1,0),(0,0,1),(-2,0,-1),(-2,-1,0),(-3,-1,-1),(1,1,1),(-1,0,0),(0,0,0)]) sage: p.positive_circuits(8) diff --git a/src/sage/graphs/base/c_graph.pyx b/src/sage/graphs/base/c_graph.pyx index be72dd8a2b9..ca0a46da045 100644 --- a/src/sage/graphs/base/c_graph.pyx +++ b/src/sage/graphs/base/c_graph.pyx @@ -593,7 +593,7 @@ cdef class CGraph: - A list of all vertices in this graph. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: S = SparseGraph(nverts=4, extra_vertices=4) @@ -767,7 +767,7 @@ cdef class CGraph: - :meth:`add_arc ` -- ``add_arc`` method for dense graphs. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.c_graph import CGraph sage: G = CGraph() @@ -802,7 +802,7 @@ cdef class CGraph: - :meth:`has_arc ` -- ``has_arc`` method for dense graphs. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.c_graph import CGraph sage: G = CGraph() @@ -837,7 +837,7 @@ cdef class CGraph: - :meth:`del_all_arcs ` -- ``del_all_arcs`` method for dense graphs. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.c_graph import CGraph sage: G = CGraph() @@ -950,7 +950,7 @@ cdef class CGraph: - :meth:`all_arcs ` -- ``all_arcs`` method for sparse graphs. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.c_graph import CGraph sage: G = CGraph() @@ -983,7 +983,7 @@ cdef class CGraph: - :meth:`in_neighbors ` -- ``in_neighbors`` method for dense graphs. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.c_graph import CGraph sage: G = CGraph() @@ -1016,7 +1016,7 @@ cdef class CGraph: - :meth:`out_neighbors ` -- ``out_neighbors`` implementation for dense graphs. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.c_graph import CGraph sage: G = CGraph() @@ -1039,7 +1039,7 @@ cdef class CGraph: - The number of in-neighbors of ``v``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: SparseGraph(7)._in_degree(3) @@ -1071,7 +1071,7 @@ cdef class CGraph: - The number of out-neighbors of ``v``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: SparseGraph(7)._out_degree(3) @@ -1097,7 +1097,7 @@ cdef class CGraph: - The order of this graph. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: SparseGraph(7)._num_verts() @@ -1121,7 +1121,7 @@ cdef class CGraph: - The size of this graph. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: SparseGraph(7)._num_arcs() @@ -1292,7 +1292,7 @@ cdef class CGraphBackend(GenericGraphBackend): - ``True`` if ``v`` is a vertex of this graph; ``False`` otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraphBackend sage: B = SparseGraphBackend(7) @@ -1333,7 +1333,7 @@ cdef class CGraphBackend(GenericGraphBackend): - The degree of vertex ``v``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraphBackend sage: B = SparseGraphBackend(7) @@ -1468,7 +1468,7 @@ cdef class CGraphBackend(GenericGraphBackend): - ``v`` -- a vertex of the graph. - EXAMPLE:: + EXAMPLES:: sage: D = DiGraph( { 0: [1,2,3], 1: [0,2], 2: [3], 3: [4], 4: [0,5], 5: [1] } ) @@ -1495,7 +1495,7 @@ cdef class CGraphBackend(GenericGraphBackend): - ``v`` -- a vertex of the graph. - EXAMPLE:: + EXAMPLES:: sage: D = DiGraph( { 0: [1,2,3], 1: [0,2], 2: [3], 3: [4], 4: [0,5], 5: [1] } ) @@ -1531,7 +1531,7 @@ cdef class CGraphBackend(GenericGraphBackend): - :meth:`has_vertex` -- returns whether or not this graph has a specific vertex. - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: D.add_vertex(10) @@ -1583,7 +1583,7 @@ cdef class CGraphBackend(GenericGraphBackend): - :meth:`add_vertex` -- add a vertex to this graph. - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.sparse_graph.SparseGraphBackend(1) sage: D.add_vertices([1,2,3]) @@ -1637,7 +1637,7 @@ cdef class CGraphBackend(GenericGraphBackend): - :meth:`del_vertices` -- delete a bunch of vertices from this graph. - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: D.del_vertex(0) @@ -1682,7 +1682,7 @@ cdef class CGraphBackend(GenericGraphBackend): - :meth:`del_vertex` -- delete a vertex of this graph. - EXAMPLE:: + EXAMPLES:: sage: import sage.graphs.base.dense_graph sage: D = sage.graphs.base.dense_graph.DenseGraphBackend(9) @@ -1727,7 +1727,7 @@ cdef class CGraphBackend(GenericGraphBackend): - :meth:`iterator_verts` -- returns an iterator over a given set of vertices. - EXAMPLE:: + EXAMPLES:: sage: P = Graph(graphs.PetersenGraph(), implementation="c_graph") sage: list(P._backend.iterator_nbrs(0)) @@ -1759,7 +1759,7 @@ cdef class CGraphBackend(GenericGraphBackend): - :meth:`iterator_out_nbrs` -- returns an iterator over the out-neighbors of a vertex. - EXAMPLE:: + EXAMPLES:: sage: P = DiGraph(graphs.PetersenGraph().to_directed(), implementation="c_graph") sage: list(P._backend.iterator_in_nbrs(0)) @@ -1797,7 +1797,7 @@ cdef class CGraphBackend(GenericGraphBackend): - :meth:`iterator_in_nbrs` -- returns an iterator over the in-neighbors of a vertex. - EXAMPLE:: + EXAMPLES:: sage: P = DiGraph(graphs.PetersenGraph().to_directed(), implementation="c_graph") sage: list(P._backend.iterator_out_nbrs(0)) @@ -1832,7 +1832,7 @@ cdef class CGraphBackend(GenericGraphBackend): - :meth:`iterator_nbrs` -- returns an iterator over the neighbors of a vertex. - EXAMPLE:: + EXAMPLES:: sage: P = Graph(graphs.PetersenGraph(), implementation="c_graph") sage: list(P._backend.iterator_verts(P)) @@ -1884,7 +1884,7 @@ cdef class CGraphBackend(GenericGraphBackend): - If ``new`` is a boolean, set the self-loop permission of this graph according to the boolean value of ``new``. - EXAMPLE:: + EXAMPLES:: sage: G = Graph(implementation='c_graph') sage: G._backend.loops() @@ -1919,7 +1919,7 @@ cdef class CGraphBackend(GenericGraphBackend): - :meth:`num_verts` -- return the order of this graph. - EXAMPLE:: + EXAMPLES:: sage: G = Graph(graphs.PetersenGraph(), implementation="c_graph") sage: G._backend.num_edges(False) @@ -2020,7 +2020,7 @@ cdef class CGraphBackend(GenericGraphBackend): - :meth:`num_edges` -- return the number of (directed) edges in this graph. - EXAMPLE:: + EXAMPLES:: sage: G = Graph(graphs.PetersenGraph(), implementation="c_graph") sage: G._backend.num_verts() @@ -2086,7 +2086,7 @@ cdef class CGraphBackend(GenericGraphBackend): - A list of vertices in the shortest path from ``x`` to ``y``. - EXAMPLE:: + EXAMPLES:: sage: G = Graph(graphs.PetersenGraph(), implementation="c_graph") sage: G.shortest_path(0, 1) @@ -2217,7 +2217,7 @@ cdef class CGraphBackend(GenericGraphBackend): - A list of vertices in the shortest path from ``x`` to ``y``. - EXAMPLE:: + EXAMPLES:: sage: G = Graph(graphs.PetersenGraph(), implementation="c_graph") sage: for (u,v) in G.edges(labels=None): @@ -2937,7 +2937,7 @@ cdef class Search_iterator: the graph to be traversed. For undirected graphs, we consider both the in- and out-neighbors. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.PetersenGraph() sage: list(g.breadth_first_search(0)) @@ -2984,7 +2984,7 @@ cdef class Search_iterator: relevant to digraphs. If ``graph`` is a digraph, ignore all orientations and consider the graph as undirected. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.PetersenGraph() sage: list(g.breadth_first_search(0)) @@ -3041,7 +3041,7 @@ cdef class Search_iterator: r""" Return an iterator object over a traversal of a graph. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.PetersenGraph() sage: g.breadth_first_search(0) @@ -3053,7 +3053,7 @@ cdef class Search_iterator: r""" Return the next vertex in a traversal of a graph. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.PetersenGraph() sage: g.breadth_first_search(0) diff --git a/src/sage/graphs/base/dense_graph.pyx b/src/sage/graphs/base/dense_graph.pyx index d896eacab27..f3d706885e4 100644 --- a/src/sage/graphs/base/dense_graph.pyx +++ b/src/sage/graphs/base/dense_graph.pyx @@ -156,7 +156,7 @@ cdef class DenseGraph(CGraph): O( (nverts + extra_vertices)^2 ). - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.dense_graph import DenseGraph sage: D = DenseGraph(nverts = 10, extra_vertices = 10) @@ -313,7 +313,7 @@ cdef class DenseGraph(CGraph): - ``u, v`` -- non-negative integers, must be in self - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.dense_graph import DenseGraph sage: G = DenseGraph(5) @@ -355,7 +355,7 @@ cdef class DenseGraph(CGraph): INPUT: u, v -- integers - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.dense_graph import DenseGraph sage: G = DenseGraph(5) @@ -399,7 +399,7 @@ cdef class DenseGraph(CGraph): The naming of this function is for consistency with ``SparseGraph``. Of course, there can be at most one arc for a ``DenseGraph``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.dense_graph import DenseGraph sage: G = DenseGraph(5) @@ -423,7 +423,7 @@ cdef class DenseGraph(CGraph): Assumes that the graph has no loop. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.dense_graph import DenseGraph sage: G = DenseGraph(5) @@ -674,7 +674,7 @@ cdef class DenseGraphBackend(CGraphBackend): """ Initialize a dense graph with n vertices. - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: D.add_edge(0,1,None,False) @@ -701,7 +701,7 @@ cdef class DenseGraphBackend(CGraphBackend): NOTE: The input ``l`` is for consistency with other backends. - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: D.add_edge(0,1,None,False) @@ -731,7 +731,7 @@ cdef class DenseGraphBackend(CGraphBackend): ``(u,v)`` or ``(u,v,l)`` - ``directed`` - if False, add ``(v,u)`` as well as ``(u,v)`` - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: D.add_edges([(0,1), (2,3), (4,5), (5,6)], False) @@ -759,7 +759,7 @@ cdef class DenseGraphBackend(CGraphBackend): NOTE: The input ``l`` is for consistency with other backends. - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: D.add_edges([(0,1), (2,3), (4,5), (5,6)], False) @@ -800,7 +800,7 @@ cdef class DenseGraphBackend(CGraphBackend): - ``u,v`` - the vertices of the edge - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: D.add_edges([(0,1), (2,3,7), (4,5), (5,6)], False) @@ -841,7 +841,7 @@ cdef class DenseGraphBackend(CGraphBackend): - ``u,v`` - the vertices of the edge - ``l`` - the edge label (ignored) - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: D.add_edges([(0,1), (2,3), (4,5), (5,6)], False) @@ -864,7 +864,7 @@ cdef class DenseGraphBackend(CGraphBackend): - ``vertices`` - a list of vertex labels - ``labels`` - boolean, whether to return labels as well - EXAMPLE:: + EXAMPLES:: sage: G = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: G.add_edge(1,2,None,False) @@ -902,7 +902,7 @@ cdef class DenseGraphBackend(CGraphBackend): - ``vertices`` - a list of vertex labels - ``labels`` - boolean, whether to return labels as well - EXAMPLE:: + EXAMPLES:: sage: G = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: G.add_edge(1,2,None,True) @@ -939,7 +939,7 @@ cdef class DenseGraphBackend(CGraphBackend): - ``vertices`` - a list of vertex labels - ``labels`` - boolean, whether to return labels as well - EXAMPLE:: + EXAMPLES:: sage: G = sage.graphs.base.dense_graph.DenseGraphBackend(9) sage: G.add_edge(1,2,None,True) @@ -1003,7 +1003,7 @@ cdef class DenseGraphBackend(CGraphBackend): - ``l`` - the edge label - ``directed`` - if False, also set ``(v,u)`` with label ``l`` - EXAMPLE:: + EXAMPLES:: sage: import sage.graphs.base.dense_graph sage: G = sage.graphs.base.dense_graph.DenseGraphBackend(9) diff --git a/src/sage/graphs/base/graph_backends.pyx b/src/sage/graphs/base/graph_backends.pyx index 588acdd15d6..ff1d02900a2 100644 --- a/src/sage/graphs/base/graph_backends.pyx +++ b/src/sage/graphs/base/graph_backends.pyx @@ -738,7 +738,7 @@ def unpickle_graph_backend(directed,vertices,edges,kwds): This function builds a :class:`Graph` or :class:`DiGraph` from its data, and returns the ``_backend`` attribute of this object. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.graph_backends import unpickle_graph_backend sage: b = unpickle_graph_backend(0,[0,1,2,3],[(0,3,'label'),(0,0,1)],{'loops':True}) @@ -772,7 +772,7 @@ class NetworkXGraphDeprecated(SageObject): """ Issue deprecation warnings for the old networkx XGraph formats - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.graph_backends import NetworkXGraphDeprecated sage: NetworkXGraphDeprecated() @@ -839,7 +839,7 @@ class NetworkXDiGraphDeprecated(SageObject): """ Issue deprecation warnings for the old networkx XDiGraph formats - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.graph_backends import NetworkXDiGraphDeprecated sage: NetworkXDiGraphDeprecated() @@ -936,7 +936,7 @@ class NetworkXGraphBackend(GenericGraphBackend): r""" Fix the deprecated class if necessary. - EXAMPLE:: + EXAMPLES:: sage: sage.structure.sage_object.unpickle_all() # indirect random """ @@ -1319,7 +1319,7 @@ class NetworkXGraphBackend(GenericGraphBackend): Iterate over the incoming edges incident to a sequence of vertices. Special case, only for internal use. - EXAMPLE:: + EXAMPLES:: sage: g = DiGraph(graphs.PetersenGraph(), implementation="networkx")._backend doctest:...: DeprecationWarning: The 'implementation' keyword is deprecated, and the graphs has been stored as a 'c_graph' @@ -1361,7 +1361,7 @@ class NetworkXGraphBackend(GenericGraphBackend): Iterate over the outbound edges incident to a sequence of vertices. Special case, only for internal use. - EXAMPLE:: + EXAMPLES:: sage: g = DiGraph(graphs.PetersenGraph(), implementation="networkx")._backend doctest:...: DeprecationWarning: The 'implementation' keyword is deprecated, and the graphs has been stored as a 'c_graph' diff --git a/src/sage/graphs/base/sparse_graph.pyx b/src/sage/graphs/base/sparse_graph.pyx index b141e1b4914..bb6c3330804 100644 --- a/src/sage/graphs/base/sparse_graph.pyx +++ b/src/sage/graphs/base/sparse_graph.pyx @@ -249,7 +249,7 @@ cdef class SparseGraph(CGraph): O( (nverts + extra_vertices)*expected_degree + num_arcs ). - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: S = SparseGraph(nverts = 10, expected_degree = 3, extra_vertices = 10) @@ -446,7 +446,7 @@ cdef class SparseGraph(CGraph): - ``u, v`` -- non-negative integers, must be in self - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: G = SparseGraph(5) @@ -495,7 +495,7 @@ cdef class SparseGraph(CGraph): INPUT: - ``u, v`` - integers - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: G = SparseGraph(5) @@ -626,7 +626,7 @@ cdef class SparseGraph(CGraph): INPUT: - ``u, v`` - integers - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: G = SparseGraph(5) @@ -979,7 +979,7 @@ cdef class SparseGraph(CGraph): - ``u, v`` - non-negative integers, must be in self - ``l`` - a positive integer label, or zero for no label - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: G = SparseGraph(5) @@ -1042,7 +1042,7 @@ cdef class SparseGraph(CGraph): - positive integer - indicates that there is a label on ``(u, v)``. - 0 - either the arc ``(u, v)`` is unlabeled, or there is no arc at all. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: G = SparseGraph(5) @@ -1122,7 +1122,7 @@ cdef class SparseGraph(CGraph): Gives the labels of all arcs ``(u, v)``. An unlabeled arc is interpreted as having label 0. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: G = SparseGraph(5) @@ -1218,7 +1218,7 @@ cdef class SparseGraph(CGraph): - ``u, v`` - non-negative integers, must be in self - ``l`` - a positive integer label, or zero for no label - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: G = SparseGraph(5) @@ -1285,7 +1285,7 @@ cdef class SparseGraph(CGraph): - ``u, v`` -- non-negative integers, must be in self - ``l`` -- a positive integer label, or zero for no label - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: G = SparseGraph(5) @@ -1446,7 +1446,7 @@ cdef class SparseGraphBackend(CGraphBackend): - ``l`` - the edge label - ``directed`` - if False, also add ``(v,u)`` - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: D.add_edge(0,1,None,False) @@ -1502,7 +1502,7 @@ cdef class SparseGraphBackend(CGraphBackend): ``(u,v)`` or ``(u,v,l)`` - ``directed`` - if False, add ``(v,u)`` as well as ``(u,v)`` - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: D.add_edges([(0,1), (2,3), (4,5), (5,6)], False) @@ -1532,7 +1532,7 @@ cdef class SparseGraphBackend(CGraphBackend): - ``l`` - the edge label - ``directed`` - if False, also delete ``(v,u,l)`` - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: D.add_edges([(0,1), (2,3), (4,5), (5,6)], False) @@ -1612,7 +1612,7 @@ cdef class SparseGraphBackend(CGraphBackend): - ``u,v`` - the vertices of the edge - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: D.add_edges([(0,1,1), (2,3,2), (4,5,3), (5,6,2)], False) @@ -1648,7 +1648,7 @@ cdef class SparseGraphBackend(CGraphBackend): - ``u,v`` - the vertices of the edge - ``l`` - the edge label, or ``None`` - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: D.add_edges([(0,1), (2,3), (4,5), (5,6)], False) @@ -1677,7 +1677,7 @@ cdef class SparseGraphBackend(CGraphBackend): - ``vertices`` - a list of vertex labels - ``labels`` - boolean, whether to return labels as well - EXAMPLE:: + EXAMPLES:: sage: G = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: G.add_edge(1,2,3,False) @@ -1765,7 +1765,7 @@ cdef class SparseGraphBackend(CGraphBackend): - ``vertices`` - a list of vertex labels - ``labels`` - boolean, whether to return labels as well - EXAMPLE:: + EXAMPLES:: sage: G = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: G.add_edge(1,2,3,True) @@ -1818,7 +1818,7 @@ cdef class SparseGraphBackend(CGraphBackend): - ``vertices`` - a list of vertex labels - ``labels`` - boolean, whether to return labels as well - EXAMPLE:: + EXAMPLES:: sage: G = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: G.add_edge(1,2,3,True) @@ -1900,7 +1900,7 @@ cdef class SparseGraphBackend(CGraphBackend): - ``l`` - the edge label - ``directed`` - if False, also set ``(v,u)`` with label ``l`` - EXAMPLE:: + EXAMPLES:: sage: G = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: G.add_edge(1,2,None,True) diff --git a/src/sage/graphs/base/static_dense_graph.pyx b/src/sage/graphs/base/static_dense_graph.pyx index 248e6ba4560..963d25970f2 100644 --- a/src/sage/graphs/base/static_dense_graph.pyx +++ b/src/sage/graphs/base/static_dense_graph.pyx @@ -238,7 +238,7 @@ def triangles_count(G): - ``G``-- a simple graph - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.static_dense_graph import triangles_count sage: triangles_count(graphs.PetersenGraph()) diff --git a/src/sage/graphs/base/static_sparse_backend.pyx b/src/sage/graphs/base/static_sparse_backend.pyx index 1885bf648b1..14cb56632a9 100644 --- a/src/sage/graphs/base/static_sparse_backend.pyx +++ b/src/sage/graphs/base/static_sparse_backend.pyx @@ -347,7 +347,7 @@ cdef class StaticSparseBackend(CGraphBackend): A graph :mod:`backend ` for static sparse graphs. - EXAMPLE:: + EXAMPLES:: sage: D = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: D.add_edge(0,1,None,False) @@ -881,7 +881,7 @@ cdef class StaticSparseBackend(CGraphBackend): - ``directed`` -- boolean; whether to take into account the orientation of this graph in counting the degree of ``v``. - EXAMPLE:: + EXAMPLES:: sage: g = Graph(graphs.PetersenGraph(), data_structure="static_sparse") sage: g.degree(0) @@ -923,7 +923,7 @@ cdef class StaticSparseBackend(CGraphBackend): - ``v`` -- a vertex - EXAMPLE:: + EXAMPLES:: sage: g = DiGraph(graphs.PetersenGraph(), data_structure="static_sparse") sage: g.in_degree(0) @@ -949,7 +949,7 @@ cdef class StaticSparseBackend(CGraphBackend): - ``v`` -- a vertex - EXAMPLE:: + EXAMPLES:: sage: g = DiGraph(graphs.PetersenGraph(), data_structure="static_sparse") sage: g.out_degree(0) @@ -972,7 +972,7 @@ cdef class StaticSparseBackend(CGraphBackend): - ``v`` -- a vertex - EXAMPLE:: + EXAMPLES:: sage: g = Graph(graphs.PetersenGraph(), data_structure="static_sparse") sage: g.neighbors(0) @@ -997,7 +997,7 @@ cdef class StaticSparseBackend(CGraphBackend): - ``v`` -- a vertex - EXAMPLE:: + EXAMPLES:: sage: g = DiGraph(graphs.PetersenGraph(), data_structure="static_sparse") sage: g.neighbors_out(0) @@ -1022,7 +1022,7 @@ cdef class StaticSparseBackend(CGraphBackend): - ``v`` -- a vertex - EXAMPLE:: + EXAMPLES:: sage: g = DiGraph(graphs.PetersenGraph(), data_structure="static_sparse") sage: g.neighbors_in(0) @@ -1047,7 +1047,7 @@ cdef class StaticSparseBackend(CGraphBackend): r""" Addition of vertices is not available on an immutable graph. - EXAMPLE:: + EXAMPLES:: sage: g = DiGraph(graphs.PetersenGraph(), data_structure="static_sparse") sage: g.add_vertex(1) @@ -1065,7 +1065,7 @@ cdef class StaticSparseBackend(CGraphBackend): r""" Removal of vertices is not available on an immutable graph. - EXAMPLE:: + EXAMPLES:: sage: g = DiGraph(graphs.PetersenGraph(), data_structure="static_sparse") sage: g.delete_vertex(1) @@ -1091,7 +1091,7 @@ def _run_it_on_static_instead(f): such a method will never work on an immutable graph. But it can help find new bugs, from time to time. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.static_sparse_backend import _run_it_on_static_instead sage: @_run_it_on_static_instead diff --git a/src/sage/graphs/base/static_sparse_graph.pyx b/src/sage/graphs/base/static_sparse_graph.pyx index e5d7450d8ce..c8c10a382a1 100644 --- a/src/sage/graphs/base/static_sparse_graph.pyx +++ b/src/sage/graphs/base/static_sparse_graph.pyx @@ -579,7 +579,7 @@ def tarjan_strongly_connected_components(G): For more information, see the :wikipedia:`Wikipedia article on Tarjan's algorithm `. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.static_sparse_graph import tarjan_strongly_connected_components sage: tarjan_strongly_connected_components(digraphs.Path(3)) @@ -719,7 +719,7 @@ def strongly_connected_components_digraph(G): to each vertex ``v`` the number of the SCC of ``v``, as it appears in ``g_scc``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.static_sparse_graph import strongly_connected_components_digraph sage: strongly_connected_components_digraph(digraphs.Path(3)) @@ -795,7 +795,7 @@ def triangles_count(G): - `G`-- a graph - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.base.static_sparse_graph import triangles_count sage: triangles_count(graphs.PetersenGraph()) diff --git a/src/sage/graphs/bipartite_graph.py b/src/sage/graphs/bipartite_graph.py index 64fb20087fe..19268186c0e 100644 --- a/src/sage/graphs/bipartite_graph.py +++ b/src/sage/graphs/bipartite_graph.py @@ -256,7 +256,7 @@ def __init__(self, data=None, partition=None, check=True, *args, **kwds): Create a bipartite graph. See documentation ``BipartiteGraph?`` for detailed information. - EXAMPLE:: + EXAMPLES:: sage: P = graphs.PetersenGraph() sage: partition = [list(range(5)), list(range(5,10))] @@ -411,7 +411,7 @@ def __repr__(self): r""" Returns a short string representation of self. - EXAMPLE:: + EXAMPLES:: sage: B = BipartiteGraph(graphs.CycleGraph(16)) sage: B @@ -829,7 +829,7 @@ def bipartition(self): r""" Returns the underlying bipartition of the bipartite graph. - EXAMPLE:: + EXAMPLES:: sage: B = BipartiteGraph(graphs.CycleGraph(4)) sage: B.bipartition() @@ -842,7 +842,7 @@ def project_left(self): Projects ``self`` onto left vertices. Edges are 2-paths in the original. - EXAMPLE:: + EXAMPLES:: sage: B = BipartiteGraph(graphs.CycleGraph(20)) sage: G = B.project_left() @@ -861,7 +861,7 @@ def project_right(self): Projects ``self`` onto right vertices. Edges are 2-paths in the original. - EXAMPLE:: + EXAMPLES:: sage: B = BipartiteGraph(graphs.CycleGraph(20)) sage: G = B.project_right() @@ -879,7 +879,7 @@ def plot(self, *args, **kwds): r""" Overrides Graph's plot function, to illustrate the bipartite nature. - EXAMPLE:: + EXAMPLES:: sage: B = BipartiteGraph(graphs.CycleGraph(20)) sage: B.plot() @@ -932,7 +932,7 @@ def matching_polynomial(self, algorithm="Godsil", name=None): - ``name`` - optional string for the variable name in the polynomial. - EXAMPLE:: + EXAMPLES:: sage: BipartiteGraph(graphs.CubeGraph(3)).matching_polynomial() x^8 - 12*x^6 + 42*x^4 - 44*x^2 + 9 @@ -994,7 +994,7 @@ def load_afile(self, fname): http://www.inference.phy.cam.ac.uk/mackay/codes/data.html for examples and definition of the format. - EXAMPLE:: + EXAMPLES:: sage: file_name = os.path.join(SAGE_TMP, 'deleteme.alist.txt') sage: fi = open(file_name, 'w') @@ -1082,7 +1082,7 @@ def save_afile(self, fname): http://www.inference.phy.cam.ac.uk/mackay/codes/data.html for examples and definition of the format. - EXAMPLE:: + EXAMPLES:: sage: M = Matrix([(1,1,1,0,0,0,0), (1,0,0,1,1,0,0), ....: (0,1,0,1,0,1,0), (1,1,0,1,0,0,1)]) @@ -1165,7 +1165,7 @@ def __edge2idx(self, v1, v2, left, right): Returns (row index, column index) for the given pair of vertices. - EXAMPLE:: + EXAMPLES:: sage: P = graphs.PetersenGraph() sage: partition = [list(range(5)), list(range(5,10))] diff --git a/src/sage/graphs/comparability.pyx b/src/sage/graphs/comparability.pyx index 6c96c6d9fa4..f969a28fe55 100644 --- a/src/sage/graphs/comparability.pyx +++ b/src/sage/graphs/comparability.pyx @@ -517,7 +517,7 @@ def is_comparability(g, algorithm = "greedy", certificate = False, check = True) yes-certificates are indeed transitive. As it is very quick compared to the rest of the operation, it is enabled by default. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.comparability import is_comparability sage: g = graphs.PetersenGraph() @@ -711,7 +711,7 @@ def is_transitive(g, certificate = False): or yield a pair of vertices `uv` such that there exists a `uv`-path in `G` but `uv\not\in G`. - EXAMPLE:: + EXAMPLES:: sage: digraphs.Circuit(4).is_transitive() False diff --git a/src/sage/graphs/convexity_properties.pyx b/src/sage/graphs/convexity_properties.pyx index f11df7a7b03..44a3e61490a 100644 --- a/src/sage/graphs/convexity_properties.pyx +++ b/src/sage/graphs/convexity_properties.pyx @@ -110,7 +110,7 @@ cdef class ConvexityProperties: code. Trying to optimize may well lead to lost in efficiency on many instances. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.convexity_properties import ConvexityProperties sage: g = graphs.PetersenGraph() @@ -132,7 +132,7 @@ cdef class ConvexityProperties: r""" Constructor - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.convexity_properties import ConvexityProperties sage: g = graphs.PetersenGraph() @@ -213,7 +213,7 @@ cdef class ConvexityProperties: r""" Destructor - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.convexity_properties import ConvexityProperties sage: g = graphs.PetersenGraph() @@ -308,7 +308,7 @@ cdef class ConvexityProperties: * ``vertices`` -- A list of vertices. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.convexity_properties import ConvexityProperties sage: g = graphs.PetersenGraph() diff --git a/src/sage/graphs/digraph_generators.py b/src/sage/graphs/digraph_generators.py index 783ce234199..9dd924e0a31 100644 --- a/src/sage/graphs/digraph_generators.py +++ b/src/sage/graphs/digraph_generators.py @@ -601,7 +601,7 @@ def Circulant(self,n,integers): - ``integers`` -- the list of integers such that there is an edge from `i` to `j` if and only if ``(j-i)%n in integers``. - EXAMPLE:: + EXAMPLES:: sage: digraphs.Circulant(13,[3,5,7]) Circulant graph ([3, 5, 7]): Digraph on 13 vertices @@ -730,7 +730,7 @@ def GeneralizedDeBruijn(self, n, d): checks whether a (di)graph is circulant, and/or returns all possible sets of parameters. - EXAMPLE:: + EXAMPLES:: sage: GB = digraphs.GeneralizedDeBruijn(8, 2) sage: GB.is_isomorphic(digraphs.DeBruijn(2, 3), certificate = True) @@ -991,7 +991,7 @@ def RandomDirectedGN(self, n, kernel=lambda x:x, seed=None): - ``seed`` - for the random number generator - EXAMPLE:: + EXAMPLES:: sage: D = digraphs.RandomDirectedGN(25) sage: D.edges(labels=False) @@ -1027,7 +1027,7 @@ def RandomDirectedGNC(self, n, seed=None): - ``seed`` - for the random number generator - EXAMPLE:: + EXAMPLES:: sage: D = digraphs.RandomDirectedGNC(25) sage: D.edges(labels=False) @@ -1071,7 +1071,7 @@ def RandomDirectedGNP(self, n, p, loops = False, seed = None): PLOTTING: When plotting, this graph will use the default spring-layout algorithm, unless a position dictionary is specified. - EXAMPLE:: + EXAMPLES:: sage: set_random_seed(0) sage: D = digraphs.RandomDirectedGNP(10, .2) @@ -1105,7 +1105,7 @@ def RandomDirectedGNM(self, n, m, loops = False): PLOTTING: When plotting, this graph will use the default spring-layout algorithm, unless a position dictionary is specified. - EXAMPLE:: + EXAMPLES:: sage: D = digraphs.RandomDirectedGNM(10, 5) sage: D.num_verts() @@ -1238,7 +1238,7 @@ def RandomDirectedGNR(self, n, p, seed=None): - ``seed`` - for the random number generator. - EXAMPLE:: + EXAMPLES:: sage: D = digraphs.RandomDirectedGNR(25, .2) sage: D.edges(labels=False) diff --git a/src/sage/graphs/distances_all_pairs.pyx b/src/sage/graphs/distances_all_pairs.pyx index 6ecb15a2ae2..e69578c3d02 100644 --- a/src/sage/graphs/distances_all_pairs.pyx +++ b/src/sage/graphs/distances_all_pairs.pyx @@ -339,7 +339,7 @@ def shortest_path_all_pairs(G): The integer corresponding to a vertex is its index in the list ``G.vertices()``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.distances_all_pairs import shortest_path_all_pairs sage: g = graphs.PetersenGraph() @@ -419,7 +419,7 @@ def distances_all_pairs(G): This function returns a double dictionary ``D`` of vertices, in which the distance between vertices ``u`` and ``v`` is ``D[u][v]``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.distances_all_pairs import distances_all_pairs sage: g = graphs.PetersenGraph() @@ -630,7 +630,7 @@ def distances_and_predecessors_all_pairs(G): ``G.vertices()``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.distances_all_pairs import distances_and_predecessors_all_pairs sage: g = graphs.PetersenGraph() @@ -823,7 +823,7 @@ def eccentricity(G, algorithm="standard"): ``'standard'`` which performs a BFS from each vertex and ``'bounds'`` which uses the fast algorithm proposed in [TK13]_ for undirected graphs. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.distances_all_pairs import eccentricity sage: g = graphs.PetersenGraph() diff --git a/src/sage/graphs/generators/degree_sequence.py b/src/sage/graphs/generators/degree_sequence.py index 249f749a21c..32a4f03769e 100644 --- a/src/sage/graphs/generators/degree_sequence.py +++ b/src/sage/graphs/generators/degree_sequence.py @@ -190,7 +190,7 @@ def DegreeSequenceTree(deg_sequence): entry corresponding to the expected degree of a different vertex. - EXAMPLE:: + EXAMPLES:: sage: G = graphs.DegreeSequenceTree([3,1,3,3,1,1,1,2,1]) sage: G.show() # long time @@ -215,7 +215,7 @@ def DegreeSequenceExpected(deg_sequence, seed=None): - ``seed`` - for the random number generator. - EXAMPLE:: + EXAMPLES:: sage: G = graphs.DegreeSequenceExpected([1,2,3,2,3]) sage: G.edges(labels=False) diff --git a/src/sage/graphs/generators/families.py b/src/sage/graphs/generators/families.py index 43f35854f8f..bb08381f557 100644 --- a/src/sage/graphs/generators/families.py +++ b/src/sage/graphs/generators/families.py @@ -89,7 +89,7 @@ def KneserGraph(n,k): For example, the Petersen Graph can be defined as the Kneser Graph with parameters `5,2`. - EXAMPLE:: + EXAMPLES:: sage: KG=graphs.KneserGraph(5,2) sage: print(KG.vertices()) @@ -718,7 +718,7 @@ def GoethalsSeidelGraph(k,r): - :func:`~sage.graphs.strongly_regular_db.is_goethals_seidel` - EXAMPLE:: + EXAMPLES:: sage: graphs.GoethalsSeidelGraph(3,3) Graph on 28 vertices @@ -766,7 +766,7 @@ def DorogovtsevGoltsevMendesGraph(n): Construct the n-th generation of the Dorogovtsev-Goltsev-Mendes graph. - EXAMPLE:: + EXAMPLES:: sage: G = graphs.DorogovtsevGoltsevMendesGraph(8) sage: G.size() @@ -1553,7 +1553,7 @@ def OddGraph(n): For example, the Petersen Graph can be defined as the Odd Graph with parameter `3`. - EXAMPLE:: + EXAMPLES:: sage: OG=graphs.OddGraph(3) sage: print(OG.vertices()) @@ -1967,7 +1967,7 @@ def line_graph_forbidden_subgraphs(): The graphs are returned in the ordering given by the Wikipedia drawing, read from left to right and from top to bottom. - EXAMPLE:: + EXAMPLES:: sage: graphs.line_graph_forbidden_subgraphs() [Claw graph: Graph on 4 vertices, @@ -2057,7 +2057,7 @@ def petersen_family(generate=False): `\Delta-Y` transformations. When set to ``False`` (default) a hardcoded version of the graphs (with a prettier layout) is returned. - EXAMPLE:: + EXAMPLES:: sage: graphs.petersen_family() [Petersen graph: Graph on 10 vertices, @@ -2377,7 +2377,7 @@ def RingedTree(k, vertex_labels = True): - ``vertex_labels`` (boolean) -- whether to label vertices as binary words (default) or as integers. - EXAMPLE:: + EXAMPLES:: sage: G = graphs.RingedTree(5) sage: P = G.plot(vertex_labels=False, vertex_size=10) diff --git a/src/sage/graphs/generators/intersection.py b/src/sage/graphs/generators/intersection.py index 8a89241f2c7..785b75d45c5 100644 --- a/src/sage/graphs/generators/intersection.py +++ b/src/sage/graphs/generators/intersection.py @@ -518,7 +518,7 @@ def IntersectionGraph(S): The elements of `S` must be finite, hashable, and the elements of any `s\in S` must be hashable too. - EXAMPLE:: + EXAMPLES:: sage: graphs.IntersectionGraph([(1,2,3),(3,4,5),(5,6,7)]) Intersection Graph: Graph on 3 vertices diff --git a/src/sage/graphs/generators/random.py b/src/sage/graphs/generators/random.py index 5f7ed118e1e..383f49a6a39 100644 --- a/src/sage/graphs/generators/random.py +++ b/src/sage/graphs/generators/random.py @@ -193,7 +193,7 @@ def RandomBipartite(n1, n2, p): - ``p`` : Probability for an edge to exist - EXAMPLE:: + EXAMPLES:: sage: g=graphs.RandomBipartite(5,2,0.5) sage: g.vertices() @@ -549,7 +549,7 @@ def RandomTree(n): - ``n`` - number of vertices in the tree - EXAMPLE:: + EXAMPLES:: sage: G = graphs.RandomTree(10) sage: G.is_tree() @@ -710,7 +710,7 @@ def RandomShell(constructor, seed=None): - ``seed`` - for the random number generator - EXAMPLE:: + EXAMPLES:: sage: G = graphs.RandomShell([(10,20,0.8),(20,40,0.8)]) sage: G.edges(labels=False) diff --git a/src/sage/graphs/generators/smallgraphs.py b/src/sage/graphs/generators/smallgraphs.py index 4a9a9784c94..677c0d047fd 100644 --- a/src/sage/graphs/generators/smallgraphs.py +++ b/src/sage/graphs/generators/smallgraphs.py @@ -624,7 +624,7 @@ def SuzukiGraph(): It takes approximately 50 seconds to build this graph. Do not be too impatient. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.SuzukiGraph(); g # optional database_gap internet # not tested Suzuki graph: Graph on 1782 vertices @@ -1401,7 +1401,7 @@ def BrouwerHaemersGraph(): on Andries Brouwer's website `_. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.BrouwerHaemersGraph() sage: g @@ -1568,7 +1568,7 @@ def GossetGraph(): has with 56 vertices and degree 27. For more information, see the :wikipedia:`Gosset_graph`. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.GossetGraph(); g Gosset Graph: Graph on 56 vertices @@ -1967,7 +1967,7 @@ def DesarguesGraph(): PLOTTING: The layout chosen is the same as on the cover of [1]. - EXAMPLE:: + EXAMPLES:: sage: D = graphs.DesarguesGraph() sage: L = graphs.LCFGraph(20,[5,-5,9,-9],5) @@ -2446,7 +2446,7 @@ def F26AGraph(): The F26A graph is a symmetric bipartite cubic graph with 26 vertices and 39 edges. For more information, see the :wikipedia:`F26A_graph`. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.F26AGraph(); g F26A Graph: Graph on 26 vertices @@ -2519,7 +2519,7 @@ def FolkmanGraph(): See the :wikipedia:`Wikipedia page on the Folkman Graph `. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.FolkmanGraph() sage: g.order() @@ -2556,7 +2556,7 @@ def FosterGraph(): See the :wikipedia:`Wikipedia page on the Foster Graph `. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.FosterGraph() sage: g.order() @@ -3412,7 +3412,7 @@ def Klein3RegularGraph(): :meth:`~sage.graphs.graph_generators.GraphGenerators.Klein7RegularGraph`. For more information, see the :wikipedia:`Klein_graphs`. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.Klein3RegularGraph(); g Klein 3-regular Graph: Graph on 56 vertices @@ -3445,7 +3445,7 @@ def Klein7RegularGraph(): :meth:`~sage.graphs.graph_generators.GraphGenerators.Klein3RegularGraph`. For more information, see the :wikipedia:`Klein_graphs`. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.Klein7RegularGraph(); g Klein 7-regular Graph: Graph on 24 vertices @@ -4036,7 +4036,7 @@ def PerkelGraph(): `(6,5,2;1,1,3)`. For more information, see the :wikipedia:`Perkel_graph` or http://www.win.tue.nl/~aeb/graphs/Perkel.html. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.PerkelGraph(); g Perkel Graph: Graph on 57 vertices @@ -4062,7 +4062,7 @@ def RobertsonGraph(): See the :wikipedia:`Wikipedia page on the Robertson Graph `. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.RobertsonGraph() sage: g.order() @@ -4244,7 +4244,7 @@ def SylvesterGraph(): * :meth:`~sage.graphs.graph_generators.GraphGenerators.HoffmanSingletonGraph`. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.SylvesterGraph(); g Sylvester Graph: Graph on 36 vertices @@ -4283,7 +4283,7 @@ def SimsGewirtzGraph(): * :meth:`~sage.graphs.graph_generators.GraphGenerators.HigmanSimsGraph`. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.SimsGewirtzGraph(); g Sims-Gewirtz Graph: Graph on 56 vertices @@ -4450,7 +4450,7 @@ def TruncatedIcosidodecahedralGraph(): and 180 edges. For more information, see the :wikipedia:`Truncated_icosidodecahedron`. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.TruncatedIcosidodecahedralGraph(); g Truncated Icosidodecahedron: Graph on 120 vertices @@ -4469,7 +4469,7 @@ def TruncatedTetrahedralGraph(): The truncated tetrahedron is an Archimedean solid with 12 vertices and 18 edges. For more information, see the :wikipedia:`Truncated_tetrahedron`. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.TruncatedTetrahedralGraph(); g Truncated Tetrahedron: Graph on 12 vertices @@ -4807,7 +4807,7 @@ def MathonStronglyRegularGraph(t): - ``t`` (integer) -- the number of the graph, from 0 to 2. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.generators.smallgraphs import MathonStronglyRegularGraph sage: G = MathonStronglyRegularGraph(0) # long time @@ -4840,7 +4840,7 @@ def JankoKharaghaniGraph(v): - ``v`` (integer) -- one of 936 or 1800. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.JankoKharaghaniGraph(936) # long time sage: g.is_strongly_regular(parameters=True) # long time diff --git a/src/sage/graphs/generators/world_map.py b/src/sage/graphs/generators/world_map.py index 364e7c583d4..861afb3b310 100644 --- a/src/sage/graphs/generators/world_map.py +++ b/src/sage/graphs/generators/world_map.py @@ -30,7 +30,7 @@ def WorldMap(): equal to a dictionary containing the GPS coordinates of each country's capital city. - EXAMPLE:: + EXAMPLES:: sage: g=graphs.WorldMap() sage: g.has_edge("France","Italy") diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index fb816153f0f..f9729416599 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -362,7 +362,7 @@ def __setstate__(self,state): Also converts old NetworkX backends into a more recent one. - EXAMPLE:: + EXAMPLES:: sage: sage.structure.sage_object.unpickle_all() # indirect random """ @@ -538,7 +538,7 @@ def __hash__(self): Only immutable graphs are hashable. The resulting value is cached. - EXAMPLE:: + EXAMPLES:: sage: G = graphs.PetersenGraph() sage: {G:1}[G] @@ -1163,7 +1163,7 @@ def export_to_file(self, filename, format=None, **kwds): This functions uses the ``write_*`` functions defined in NetworkX (see http://networkx.lanl.gov/reference/readwrite.html). - EXAMPLE:: + EXAMPLES:: sage: g = graphs.PetersenGraph() sage: filename = tmp_filename(ext=".pajek") @@ -10098,7 +10098,7 @@ def merge_vertices(self,vertices): - ``vertices`` -- the set of vertices to be merged - EXAMPLE:: + EXAMPLES:: sage: g=graphs.CycleGraph(3) sage: g.merge_vertices([0,1]) @@ -19054,7 +19054,7 @@ def _keys_for_vertices(self): is a string not starting with a number, as required by dot2tex. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.Grid2dGraph(5,5) sage: g._keys_for_vertices() diff --git a/src/sage/graphs/generic_graph_pyx.pyx b/src/sage/graphs/generic_graph_pyx.pyx index b7a875b7bd7..cd50d2e7bd9 100644 --- a/src/sage/graphs/generic_graph_pyx.pyx +++ b/src/sage/graphs/generic_graph_pyx.pyx @@ -324,7 +324,7 @@ def int_to_binary_string(n): - ``n`` (integer) - EXAMPLE:: + EXAMPLES:: sage: sage.graphs.generic_graph_pyx.int_to_binary_string(389) '110000101' @@ -352,7 +352,7 @@ def binary_string_to_graph6(x): - ``x`` -- a binary string. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.generic_graph_pyx import binary_string_to_graph6 sage: binary_string_to_graph6('110111010110110010111000001100000001000000001') @@ -383,7 +383,7 @@ def small_integer_to_graph6(n): - ``n`` (integer) - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.generic_graph_pyx import small_integer_to_graph6 sage: small_integer_to_graph6(13) @@ -410,7 +410,7 @@ def length_and_string_from_graph6(s): - ``s`` -- a graph6 string describing an binary vector (and encoding its length). - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.generic_graph_pyx import length_and_string_from_graph6 sage: length_and_string_from_graph6('~??~?????_@?CG??B??@OG?C?G???GO??W@a???CO???OACC?OA?P@G??O??????G??C????c?G?CC?_?@???C_??_?C????PO?C_??AA?OOAHCA___?CC?A?CAOGO??????A??G?GR?C?_o`???g???A_C?OG??O?G_IA????_QO@EG???O??C?_?C@?G???@?_??AC?AO?a???O?????A?_Dw?H???__O@AAOAACd?_C??G?G@??GO?_???O@?_O??W??@P???AG??B?????G??GG???A??@?aC_G@A??O??_?A?????O@Z?_@M????GQ@_G@?C?') @@ -444,7 +444,7 @@ def binary_string_from_graph6(s, n): - ``n`` -- the length of the binary string encoded by ``s``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.generic_graph_pyx import binary_string_from_graph6 sage: binary_string_from_graph6('?????_@?CG??B??@OG?C?G???GO??W@a???CO???OACC?OA?P@G??O??????G??C????c?G?CC?_?@???C_??_?C????PO?C_??AA?OOAHCA___?CC?A?CAOGO??????A??G?GR?C?_o`???g???A_C?OG??O?G_IA????_QO@EG???O??C?_?C@?G???@?_??AC?AO?a???O?????A?_Dw?H???__O@AAOAACd?_C??G?G@??GO?_???O@?_O??W??@P???AG??B?????G??GG???A??@?aC_G@A??O??_?A?????O@Z?_@M????GQ@_G@?C?', 63) @@ -474,7 +474,7 @@ def binary_string_from_dig6(s, n): - ``n`` -- the length of the binary string encoded by ``s``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.generic_graph_pyx import binary_string_from_dig6 sage: binary_string_from_dig6('?????_@?CG??B??@OG?C?G???GO??W@a???CO???OACC?OA?P@G??O??????G??C????c?G?CC?_?@???C_??_?C????PO?C_??AA?OOAHCA___?CC?A?CAOGO??????A??G?GR?C?_o`???g???A_C?OG??O?G_IA????_QO@EG???O??C?_?C@?G???@?_??AC?AO?a???O?????A?_Dw?H???__O@AAOAACd?_C??G?G@??GO?_???O@?_O??W??@P???AG??B?????G??GG???A??@?aC_G@A??O??_?A?????O@Z?_@M????GQ@_G@?C?', 63) @@ -529,7 +529,7 @@ cdef class SubgraphSearch: input : `G` and `H` are both graphs or both digraphs and that `H` has order at least 2. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.PetersenGraph() sage: g.subgraph_search(graphs.CycleGraph(5)) @@ -671,7 +671,7 @@ cdef class SubgraphSearch: This method initializes all the C values. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.PetersenGraph() sage: g.subgraph_search(graphs.CycleGraph(5)) @@ -758,7 +758,7 @@ cdef class SubgraphSearch: Returns the next isomorphic subgraph if any, and raises a ``StopIteration`` otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.generic_graph_pyx import SubgraphSearch sage: g = graphs.PathGraph(5) @@ -1389,7 +1389,7 @@ def transitive_reduction_acyclic(G): - ``G`` -- an acyclic digraph. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.generic_graph_pyx import transitive_reduction_acyclic sage: G = posets.BooleanLattice(4).hasse_diagram() diff --git a/src/sage/graphs/graph_coloring.py b/src/sage/graphs/graph_coloring.py index b386f3de3a0..00406290a07 100644 --- a/src/sage/graphs/graph_coloring.py +++ b/src/sage/graphs/graph_coloring.py @@ -394,7 +394,7 @@ class :class:`MixedIntegerLinearProgram - If ``k`` is set and ``value_only=True``, test whether the graph is `k`-colorable, and return ``True`` or ``False`` accordingly. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_coloring import vertex_coloring sage: g = graphs.PetersenGraph() @@ -981,7 +981,7 @@ class :class:`MixedIntegerLinearProgram can sometimes be much faster, and it is a bad idea to compute the whole coloring if you do not need it ! - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_coloring import edge_coloring sage: g = graphs.PetersenGraph() diff --git a/src/sage/graphs/graph_database.py b/src/sage/graphs/graph_database.py index 8dad82b00c4..e9a4ec8b499 100644 --- a/src/sage/graphs/graph_database.py +++ b/src/sage/graphs/graph_database.py @@ -64,7 +64,7 @@ def degseq_to_data(degree_sequence): (max-min) integer data type, as used for faster access in the underlying database. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_database import degseq_to_data sage: degseq_to_data([2,2,3,1]) @@ -81,7 +81,7 @@ def data_to_degseq(data, graph6=None): graphs with no edges, so that the correct number of zeros will be returned. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_database import data_to_degseq sage: data_to_degseq(3221) @@ -102,7 +102,7 @@ def graph6_to_plot(graph6): Constructs a graph from a graph6 string and returns a Graphics object with arguments preset for show function. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_database import graph6_to_plot sage: type(graph6_to_plot('D??')) @@ -128,7 +128,7 @@ def subgraphs_to_query(subgraphs, db): own because it doesn't set any display columns in the query string, causing a failure to fetch the data when run. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_database import subgraphs_to_query sage: gd = GraphDatabase() @@ -202,7 +202,7 @@ def graph_db_info(tablename=None): table - EXAMPLE:: + EXAMPLES:: sage: graph_db_info().keys() ['graph_data', 'degrees', 'spectrum', 'misc', 'aut_grp'] @@ -484,7 +484,7 @@ def query_iterator(self): """ Returns an iterator over the results list of the GraphQuery. - EXAMPLE:: + EXAMPLES:: sage: Q = GraphQuery(display_cols=['graph6'],num_vertices=7, diameter=5) sage: for g in Q: @@ -708,7 +708,7 @@ def __init__(self): University). [Online] Available: http://artsci.drake.edu/grout/graphs/ - EXAMPLE:: + EXAMPLES:: sage: G = GraphDatabase() sage: G.get_skeleton() @@ -893,7 +893,7 @@ def _gen_interact_func(self, display, **kwds): parameters and results. This is a helper method for the interactive_query method and should not be called directly. - EXAMPLE:: + EXAMPLES:: sage: D = GraphDatabase() sage: D.interactive_query(display_cols=['graph6','num_vertices','degree_sequence'],num_edges=['<=',5],max_degree=3) @@ -927,7 +927,7 @@ def query(self, query_dict=None, display_cols=None, **kwds): Creates a GraphQuery on this database. For full class details, type GraphQuery? and press shift+enter. - EXAMPLE:: + EXAMPLES:: sage: D = GraphDatabase() sage: q = D.query(display_cols=['graph6','num_vertices','degree_sequence'],num_edges=['<=',5]) @@ -1056,7 +1056,7 @@ def interactive_query(self, display_cols, **kwds): Generates an interact shell (in the notebook only) that allows the user to manipulate query parameters and see the updated results. - EXAMPLE:: + EXAMPLES:: sage: D = GraphDatabase() sage: D.interactive_query(display_cols=['graph6','num_vertices','degree_sequence'],num_edges=5,max_degree=3) diff --git a/src/sage/graphs/graph_decompositions/fast_digraph.pyx b/src/sage/graphs/graph_decompositions/fast_digraph.pyx index 38c30da75bc..99b2eb7c35f 100644 --- a/src/sage/graphs/graph_decompositions/fast_digraph.pyx +++ b/src/sage/graphs/graph_decompositions/fast_digraph.pyx @@ -121,7 +121,7 @@ def test_popcount(): """ Correction test for popcount32. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_decompositions.fast_digraph import test_popcount sage: test_popcount() # not tested diff --git a/src/sage/graphs/graph_decompositions/rankwidth.pyx b/src/sage/graphs/graph_decompositions/rankwidth.pyx index ec22a9282a1..24294393b5e 100644 --- a/src/sage/graphs/graph_decompositions/rankwidth.pyx +++ b/src/sage/graphs/graph_decompositions/rankwidth.pyx @@ -75,7 +75,7 @@ from the smaller of the two and its complement. it to us, what we need is some information on the hardware you run to know where it comes from ! -EXAMPLE:: +EXAMPLES:: sage: g = graphs.PetersenGraph() sage: g.rank_decomposition() @@ -150,7 +150,7 @@ def rank_decomposition(G, verbose = False): numerical value and ``decomposition_tree`` is a ternary tree describing the decomposition (cf. the module's documentation). - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_decompositions.rankwidth import rank_decomposition sage: g = graphs.PetersenGraph() @@ -298,7 +298,7 @@ def mkgraph(int num_vertices): (This function is for internal use) - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_decompositions.rankwidth import rank_decomposition sage: g = graphs.PetersenGraph() diff --git a/src/sage/graphs/graph_generators_pyx.pyx b/src/sage/graphs/graph_generators_pyx.pyx index 3e73d05b121..dc3fa223b4c 100644 --- a/src/sage/graphs/graph_generators_pyx.pyx +++ b/src/sage/graphs/graph_generators_pyx.pyx @@ -41,7 +41,7 @@ def RandomGNP(n, p, directed = False, loops = False): .. [2] \E. N. Gilbert. Random Graphs, Ann. Math. Stat., 30, 1141 (1959). - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_generators_pyx import RandomGNP sage: set_random_seed(0) diff --git a/src/sage/graphs/graph_input.py b/src/sage/graphs/graph_input.py index 54ded7ad1b2..bf29d0f04aa 100644 --- a/src/sage/graphs/graph_input.py +++ b/src/sage/graphs/graph_input.py @@ -33,7 +33,7 @@ def from_graph6(G, g6_string): - ``g6_string`` -- a graph6 string - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_input import from_graph6 sage: g = Graph() @@ -74,7 +74,7 @@ def from_sparse6(G, g6_string): - ``g6_string`` -- a sparse6 string - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_input import from_sparse6 sage: g = Graph() @@ -126,7 +126,7 @@ def from_dig6(G, dig6_string): - ``dig6_string`` -- a dig6 string - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_input import from_dig6 sage: g = DiGraph() @@ -166,7 +166,7 @@ def from_seidel_adjacency_matrix(G, M): - ``M`` -- a Seidel adjacency matrix - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_input import from_seidel_adjacency_matrix sage: g = Graph() @@ -219,7 +219,7 @@ def from_adjacency_matrix(G, M, loops=False, multiedges=False, weighted=False): - ``loops``, ``multiedges``, ``weighted`` (booleans) -- whether to consider the graph as having loops, multiple edges, or weights. Set to ``False`` by default. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_input import from_adjacency_matrix sage: g = Graph() @@ -300,7 +300,7 @@ def from_incidence_matrix(G, M, loops=False, multiedges=False, weighted=False): - ``loops``, ``multiedges``, ``weighted`` (booleans) -- whether to consider the graph as having loops, multiple edges, or weights. Set to ``False`` by default. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_input import from_incidence_matrix sage: g = Graph() @@ -362,7 +362,7 @@ def from_oriented_incidence_matrix(G, M, loops=False, multiedges=False, weighted - ``loops``, ``multiedges``, ``weighted`` (booleans) -- whether to consider the graph as having loops, multiple edges, or weights. Set to ``False`` by default. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_input import from_oriented_incidence_matrix sage: g = DiGraph() @@ -411,7 +411,7 @@ def from_dict_of_dicts(G, M, loops=False, multiedges=False, weighted=False, conv - ``convert_empty_dict_labels_to_None`` (boolean) -- whether to adjust for empty dicts instead of None in NetworkX default edge labels. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_input import from_dict_of_dicts sage: g = Graph() @@ -480,7 +480,7 @@ def from_dict_of_lists(G, D, loops=False, multiedges=False, weighted=False): - ``loops``, ``multiedges``, ``weighted`` (booleans) -- whether to consider the graph as having loops, multiple edges, or weights. Set to ``False`` by default. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_input import from_dict_of_lists sage: g = Graph() diff --git a/src/sage/graphs/graph_list.py b/src/sage/graphs/graph_list.py index 21472cc31dd..e1229d553e5 100644 --- a/src/sage/graphs/graph_list.py +++ b/src/sage/graphs/graph_list.py @@ -29,7 +29,7 @@ def from_whatever(data): file stream, or whatever. - EXAMPLE:: + EXAMPLES:: sage: l = ['N@@?N@UGAGG?gGlKCMO',':P_`cBaC_ACd`C_@BC`ABDHaEH_@BF_@CHIK_@BCEHKL_BIKM_BFGHI'] sage: graphs_list.from_whatever(l) @@ -80,7 +80,7 @@ def from_graph6(data): file stream. - EXAMPLE:: + EXAMPLES:: sage: l = ['N@@?N@UGAGG?gGlKCMO','XsGGWOW?CC?C@HQKHqOjYKC_uHWGX?P?~TqIKA`OA@SAOEcEA??'] sage: graphs_list.from_graph6(l) @@ -126,7 +126,7 @@ def from_sparse6(data): file stream. - EXAMPLE:: + EXAMPLES:: sage: l = [':P_`cBaC_ACd`C_@BC`ABDHaEH_@BF_@CHIK_@BCEHKL_BIKM_BFGHI',':f`??KO?B_OOSCGE_?OWONDBO?GOJBDO?_SSJdApcOIG`?og_UKEbg?_SKFq@[CCBA`p?oYMFp@gw]Qaa@xEMHDb@hMCBCbQ@ECHEcAKKQKFPOwo[PIDQ{KIHEcQPOkVKEW_WMNKqPWwcRKOOWSKIGCqhWt??___WMJFCahWzEBa`xOu[MpPPKqYNoOOOKHHDBPs|??__gWMKEcAHKgTLErqA?A@a@G{kVLErs?GDBA@XCs\\NggWSOJIDbHh@?A@aF'] sage: graphs_list.from_sparse6(l) @@ -180,7 +180,7 @@ def to_graph6(list, file = None, output_list=False): output is a list of strings (ignored if file gets specified) - EXAMPLE:: + EXAMPLES:: sage: l = [graphs.DodecahedralGraph(), graphs.PetersenGraph()] sage: graphs_list.to_graph6(l) @@ -219,7 +219,7 @@ def to_sparse6(list, file = None, output_list=False): output is a list of strings (ignored if file gets specified) - EXAMPLE:: + EXAMPLES:: sage: l = [graphs.DodecahedralGraph(), graphs.PetersenGraph()] sage: graphs_list.to_sparse6(l) diff --git a/src/sage/graphs/graph_plot.py b/src/sage/graphs/graph_plot.py index 272c2f643e3..0b9be504352 100644 --- a/src/sage/graphs/graph_plot.py +++ b/src/sage/graphs/graph_plot.py @@ -226,7 +226,7 @@ def __init__(self, graph, options): as some functions to set parameters for vertices and edges. This constructor assumes default options are set. Defaults are shown in the example below. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_plot import GraphPlot sage: options = { @@ -804,7 +804,7 @@ def _polar_hack_for_multidigraph(self, A, B, VR): segment from A to B (xy tuples) and circles centered at A and B, both with radius VR. Returns a tuple of xy tuples representing the two points. - EXAMPLE:: + EXAMPLES:: sage: d = DiGraph({}, loops=True, multiedges=True, sparse=True) sage: d.add_edges([(0,0,'a'),(0,0,'b'),(0,1,'c'),(0,1,'d'), @@ -856,7 +856,7 @@ def show(self, **kwds): - Any options not used by plot will be passed on to the :meth:`~sage.plot.graphics.Graphics.show` method. - EXAMPLE:: + EXAMPLES:: sage: C = graphs.CubeGraph(8) sage: P = C.graphplot(vertex_labels=False, vertex_size=0, graph_border=True) @@ -1369,7 +1369,7 @@ def _circle_embedding(g, vertices, center=(0, 0), radius=1, shift=0): circle by an angle of `\alpha 2\pi/n` (where `n` is the number of vertices set on the circle). - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_plot import _circle_embedding sage: g = graphs.CycleGraph(5) @@ -1399,7 +1399,7 @@ def _line_embedding(g, vertices, first=(0, 0), last=(0, 1)): is the pair ``first`` and the position of ``vertices[-1]`` is ``last``. The vertices are evenly spaced. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.graph_plot import _line_embedding sage: g = graphs.PathGraph(5) diff --git a/src/sage/graphs/hypergraph_generators.py b/src/sage/graphs/hypergraph_generators.py index 5bc4b4e8f82..d131b56a1c8 100644 --- a/src/sage/graphs/hypergraph_generators.py +++ b/src/sage/graphs/hypergraph_generators.py @@ -165,7 +165,7 @@ def CompleteUniform(self, n, k): - ``k,n`` -- nonnegative integers with `k\leq n` - EXAMPLE:: + EXAMPLES:: sage: h = hypergraphs.CompleteUniform(5,2); h Incidence structure with 5 points and 10 blocks diff --git a/src/sage/graphs/isgci.py b/src/sage/graphs/isgci.py index fc5e19a3340..688aa882143 100644 --- a/src/sage/graphs/isgci.py +++ b/src/sage/graphs/isgci.py @@ -424,7 +424,7 @@ def __init__(self, name, gc_id, recognition_function = None): return boolan answers to the question : *does ``g`` belong to the class represented by ``gc_id`` ?* - EXAMPLE:: + EXAMPLES:: sage: graph_classes.Chordal # indirect doctest Chordal graphs @@ -439,7 +439,7 @@ def _repr_(self): r""" Returns a short description of the class - EXAMPLE:: + EXAMPLES:: sage: graph_classes.Chordal # indirect doctest Chordal graphs @@ -450,7 +450,7 @@ def __hash__(self): r""" Returns the class' ID hash - EXAMPLE:: + EXAMPLES:: sage: hash(graph_classes.Chordal) == hash(graph_classes.Chordal) True @@ -461,7 +461,7 @@ def __le__(self, other): r""" <= operator - EXAMPLE:: + EXAMPLES:: sage: graph_classes.Chordal <= graph_classes.Tree Unknown @@ -472,7 +472,7 @@ def __ge__(self, other): r""" >= operator - EXAMPLE:: + EXAMPLES:: sage: graph_classes.Chordal >= graph_classes.Tree True @@ -488,7 +488,7 @@ def __eq__(self, other): r""" == operator - EXAMPLE:: + EXAMPLES:: sage: graph_classes.Chordal == graph_classes.Tree Unknown @@ -499,7 +499,7 @@ def __lt__(self, other): r""" >, !=, and < operators - EXAMPLE:: + EXAMPLES:: sage: graph_classes.Chordal > graph_classes.Tree Traceback (most recent call last): @@ -606,7 +606,7 @@ def description(self): r""" Prints the information of ISGCI about the current class. - EXAMPLE:: + EXAMPLES:: sage: graph_classes.Chordal.description() Class of graphs : Chordal @@ -800,7 +800,7 @@ def _download_db(self): r""" Downloads the current version of the ISGCI db - EXAMPLE:: + EXAMPLES:: sage: graph_classes._download_db() # Not tested -- requires internet """ @@ -834,7 +834,7 @@ def _parse_db(self, directory): - ``directory`` -- the name of the directory containing the latest version of the database. - EXAMPLE:: + EXAMPLES:: sage: from sage.env import GRAPHS_DATA_DIR sage: graph_classes._parse_db(GRAPHS_DATA_DIR) @@ -884,7 +884,7 @@ def update_db(self): sufficient, the XML file are saved instead in the user's directory (in the SAGE_DB folder). - EXAMPLE:: + EXAMPLES:: sage: graph_classes.update_db() # Not tested -- requires internet """ @@ -915,7 +915,7 @@ def _get_ISGCI(self): This method returns the data contained in the most recent ISGCI database present on the computer. See :meth:`update_db` to update the latter. - EXAMPLE:: + EXAMPLES:: sage: graph_classes._get_ISGCI() # long time (4s on sage.math, 2012) """ @@ -945,7 +945,7 @@ def show_all(self): r""" Prints all graph classes stored in ISGCI - EXAMPLE:: + EXAMPLES:: sage: graph_classes.show_all() id | name | type | smallgraph @@ -1010,7 +1010,7 @@ def _XML_to_dict(root): A dictionary representing the XML data. - EXAMPLE:: + EXAMPLES:: sage: graph_classes.Perfect.description() # indirect doctest Class of graphs : Perfect diff --git a/src/sage/graphs/partial_cube.py b/src/sage/graphs/partial_cube.py index eb253a46d8b..e8d14267723 100644 --- a/src/sage/graphs/partial_cube.py +++ b/src/sage/graphs/partial_cube.py @@ -115,7 +115,7 @@ def breadth_first_level_search(G, start): - ``start`` -- vertex or list of vertices from which to start the traversal. - EXAMPLE:: + EXAMPLES:: sage: H = digraphs.DeBruijn(3,2) sage: list(sage.graphs.partial_cube.breadth_first_level_search(H, '00')) @@ -166,7 +166,7 @@ def depth_first_traversal(G, start): if the algorithm is progressing via the edge ``vw``, or ``False`` if the algorithm is backtracking via the edge ``wv``. - EXAMPLE:: + EXAMPLES:: sage: H = digraphs.DeBruijn(3,2) sage: t = list(sage.graphs.partial_cube.depth_first_traversal(H, '00')) diff --git a/src/sage/graphs/pq_trees.py b/src/sage/graphs/pq_trees.py index ca412dc04cc..a24cbc984fd 100644 --- a/src/sage/graphs/pq_trees.py +++ b/src/sage/graphs/pq_trees.py @@ -210,7 +210,7 @@ def __init__(self, seq): r""" Construction of a PQ-Tree - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.pq_trees import P, Q sage: p = Q([[1,2], [2,3], P([[2,4], [2,8], [2,9]])]) @@ -234,7 +234,7 @@ def reverse(self): r""" Recursively reverses ``self`` and its children - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.pq_trees import P, Q sage: p = Q([[1,2], [2,3], P([[2,4], [2,8], [2,9]])]) @@ -259,7 +259,7 @@ def __contains__(self, v): - ``v`` -- an element of the ground set - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.pq_trees import P, Q sage: p = Q([[1,2], [2,3], P([[2,4], [2,8], [2,9]])]) @@ -274,7 +274,7 @@ def __iter__(self): r""" Iterates over the children of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.pq_trees import P, Q sage: p = Q([[1,2], [2,3], P([[2,4], [2,8], [2,9]])]) @@ -291,7 +291,7 @@ def number_of_children(self): r""" Returns the number of children of ``self`` - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.pq_trees import P, Q sage: p = Q([[1,2], [2,3], P([[2,4], [2,8], [2,9]])]) @@ -305,7 +305,7 @@ def ordering(self): Returns the current ordering given by listing the leaves from left to right. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.pq_trees import P, Q sage: p = Q([[1,2], [2,3], P([[2,4], [2,8], [2,9]])]) @@ -325,7 +325,7 @@ def __repr__(self): r""" Succintly represents ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.pq_trees import P, Q sage: p = Q([[1,2], [2,3], P([[2,4], [2,8], [2,9]])]) @@ -430,7 +430,7 @@ def flatten(self): method recursively "flattens" trees having only on PQ-tree child, and returns it. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.pq_trees import P, Q sage: p = Q([P([[2,4], [2,8], [2,9]])]) @@ -678,7 +678,7 @@ def cardinality(self): :meth:`orderings` -- iterate over all admissible orderings - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.pq_trees import P, Q sage: p = P([[0,3], [1,2], [2,3], [2,4], [4,0],[2,8], [2,9]]) @@ -1015,7 +1015,7 @@ def cardinality(self): :meth:`orderings` -- iterate over all admissible orderings - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.pq_trees import P, Q sage: q = Q([[0,3], [1,2], [2,3], [2,4], [4,0],[2,8], [2,9]]) diff --git a/src/sage/graphs/print_graphs.py b/src/sage/graphs/print_graphs.py index dd4099693b8..e7fc2f067ce 100644 --- a/src/sage/graphs/print_graphs.py +++ b/src/sage/graphs/print_graphs.py @@ -23,7 +23,7 @@ def print_header_ps(s): """ Give the header for a postscript file. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.print_graphs import print_header_ps sage: print(print_header_ps('')) @@ -41,7 +41,7 @@ def print_header_eps(s, xmin, ymin, xmax, ymax): """ Give the header for an encapsulated postscript file. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.print_graphs import print_header_eps sage: print(print_header_eps('',0,0,1,1)) @@ -59,7 +59,7 @@ def print_functions(s): """ Define edge and point drawing functions. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.print_graphs import print_functions sage: print(print_functions('')) @@ -98,7 +98,7 @@ def print_graph_ps(vert_ls, edge_iter, pos_dict): """ Give postscript text for drawing a graph. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.print_graphs import print_graph_ps sage: P = graphs.PetersenGraph() @@ -152,7 +152,7 @@ def print_graph_eps(vert_ls, edge_iter, pos_dict): """ Give postscript text for drawing a graph. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.print_graphs import print_graph_eps sage: P = graphs.PetersenGraph() diff --git a/src/sage/graphs/schnyder.py b/src/sage/graphs/schnyder.py index 42540fb315c..3d6dfe5f2e0 100644 --- a/src/sage/graphs/schnyder.py +++ b/src/sage/graphs/schnyder.py @@ -571,7 +571,7 @@ def __init__(self, parent=None, children=None, label=None): - ``children`` -- a list of TreeNode children of ``self`` - ``label`` -- the associated realizer vertex label - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.schnyder import TreeNode sage: tn = TreeNode(label=5) diff --git a/src/sage/graphs/strongly_regular_db.pyx b/src/sage/graphs/strongly_regular_db.pyx index cb1053d2fbc..c480038d977 100644 --- a/src/sage/graphs/strongly_regular_db.pyx +++ b/src/sage/graphs/strongly_regular_db.pyx @@ -1841,7 +1841,7 @@ def SRG_100_44_18_20(): This graph is built as a Cayley graph, using the construction for `\Delta_1` with group `H_3` presented in Table 8.1 of [JK03]_ - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_100_44_18_20 sage: G = SRG_100_44_18_20() # long time @@ -1868,7 +1868,7 @@ def SRG_100_45_20_20(): This graph is built as a Cayley graph, using the construction for `\Gamma_3` with group `H_3` presented in Table 8.1 of [JK03]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_100_45_20_20 sage: G = SRG_100_45_20_20() # long time @@ -1891,7 +1891,7 @@ def SRG_105_32_4_12(): the point `b` is on the line `A`, and `a \neq b`, `A \neq B`. See Theorem 2.7 in [GS70]_, and [Co06]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_105_32_4_12 sage: G = SRG_105_32_4_12(); G @@ -1931,7 +1931,7 @@ def SRG_120_77_52_44(): points. We then build the intersection graph of blocks with intersection size 3. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_120_77_52_44 sage: G = SRG_120_77_52_44() # optional - gap_packages @@ -1952,7 +1952,7 @@ def SRG_144_39_6_12(): (among 2 such orbits) of the group `PGL_3(3)` acting on the (right) cosets of a subgroup of order 39. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_144_39_6_12 sage: G = SRG_144_39_6_12() @@ -1983,7 +1983,7 @@ def SRG_176_49_12_14(): 'polarity with all universal points'). The graph is then built by making two vertices `u,v` adjacent whenever `v\in \sigma(u)`. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_176_49_12_14 sage: G = SRG_176_49_12_14() # optional - gap_packages # long time @@ -2024,7 +2024,7 @@ def SRG_176_105_68_54(): points. We then build the intersection graph of blocks with intersection size 3. Known as S.7 in [Hu75]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_176_105_68_54 sage: G = SRG_176_105_68_54() # optional - gap_packages @@ -2048,7 +2048,7 @@ def SRG_210_99_48_45(): found a megring of them, explicitly described in [KPRWZ10]_, resulting in this graph. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_210_99_48_45 sage: g=SRG_210_99_48_45() @@ -2104,7 +2104,7 @@ def SRG_243_110_37_60(): A strongly regular graph with the same parameters is also obtained from the database of 2-weight codes. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_243_110_37_60 sage: G = SRG_243_110_37_60() @@ -2132,7 +2132,7 @@ def SRG_253_140_87_65(): a `2-(23,7,21)` design. We then build the intersection graph of blocks with intersection size 3. Known as S.6 in [Hu75]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_253_140_87_65 sage: G = SRG_253_140_87_65() # optional - gap_packages @@ -2191,7 +2191,7 @@ def SRG_220_84_38_28(): :func:`~sage.combinat.designs.database.BIBD_45_9_8`. This construction appears in VII.11.2 from [DesignHandbook]_ - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_220_84_38_28 sage: g=SRG_220_84_38_28() @@ -2214,7 +2214,7 @@ def SRG_276_140_58_84(): :meth:`~Graph.seidel_switching` on a set of 28 disjoint 5-cliques, which exist by cf. [HT96]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_276_140_58_84 sage: g=SRG_276_140_58_84() # long time # optional - gap_packages @@ -2249,7 +2249,7 @@ def SRG_280_135_70_60(): This graph is built from the action of `J_2` on a `3.PGL(2,9)` subgroup it contains. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_280_135_70_60 sage: g=SRG_280_135_70_60() # long time # optional - gap_packages @@ -2284,7 +2284,7 @@ def SRG_280_117_44_52(): set to be adjacent if the cross-intersection of their respective partitions does not contain exactly 7 nonempty sets. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_280_117_44_52 sage: g=SRG_280_117_44_52() @@ -2329,7 +2329,7 @@ def strongly_regular_from_two_weight_code(L): - ``L`` -- a two-weight linear code, or its generating matrix. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import strongly_regular_from_two_weight_code sage: x=("100022021001111", @@ -2373,7 +2373,7 @@ def SRG_416_100_36_20(): ` induced on the neighbors of a vertex. Known as S.14 in [Hu75]_. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_416_100_36_20 sage: g = SRG_416_100_36_20() # optional - gap_packages # long time @@ -2395,7 +2395,7 @@ def SRG_560_208_72_80(): This graph is obtained as the union of 4 orbits of sets of cardinality 2 (among the 13 that exists) of the group `Sz(8)`. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_560_208_72_80 sage: g = SRG_560_208_72_80() # optional - database_gap # not tested (~2s) @@ -2443,7 +2443,7 @@ def strongly_regular_from_two_intersection_set(M): The implementation does not check that `S` is actually a 2-intersection set. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import strongly_regular_from_two_intersection_set sage: S=Matrix([(0,0,1),(0,1,0)] + map(lambda x: (1,x^2,x), GF(4,'b'))) @@ -2625,7 +2625,7 @@ def SRG_1288_792_476_504(): :func:`strongly_regular_from_two_weight_code` -- build a strongly regular graph from a two-weight code. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import SRG_1288_792_476_504 sage: G = SRG_1288_792_476_504() # long time @@ -3174,7 +3174,7 @@ def _check_database(): The function also outputs some statistics on the database. - EXAMPLE:: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import _check_database sage: _check_database() # long time diff --git a/src/sage/groups/abelian_gps/abelian_group.py b/src/sage/groups/abelian_gps/abelian_group.py index c49b3baf353..9d70af9bab9 100644 --- a/src/sage/groups/abelian_gps/abelian_group.py +++ b/src/sage/groups/abelian_gps/abelian_group.py @@ -252,7 +252,7 @@ def word_problem(words, g, verbose = False): (non-deterministic) algorithms for the word problem. Essentially, this function is a wrapper for the GAP function 'Factorization'. - EXAMPLE:: + EXAMPLES:: sage: G. = AbelianGroup(3,[2,3,4]); G Multiplicative Abelian group isomorphic to C2 x C3 x C4 @@ -629,7 +629,7 @@ def __ge__(left, right): """ Test whether ``right`` is a subgroup of ``left`` - EXAMPLE:: + EXAMPLES:: sage: G. = AbelianGroup(2) sage: H. = AbelianGroup(1) @@ -642,7 +642,7 @@ def __lt__(left, right): """ Test whether ``left`` is a strict subgroup of ``right`` - EXAMPLE:: + EXAMPLES:: sage: G. = AbelianGroup(2) sage: H. = AbelianGroup(1) @@ -655,7 +655,7 @@ def __gt__(left, right): """ Test whether ``right`` is a strict subgroup of ``left`` - EXAMPLE:: + EXAMPLES:: sage: G. = AbelianGroup(2) sage: H. = AbelianGroup(1) @@ -1395,7 +1395,7 @@ def subgroup_reduced(self,elts, verbose=False): An error will be raised if the elements given are not linearly independent over QQ. - EXAMPLE:: + EXAMPLES:: sage: G = AbelianGroup([4,4]) sage: G.subgroup( [ G([1,0]), G([1,2]) ]) @@ -1711,7 +1711,7 @@ def gen(self, n): """ Return the nth generator of this subgroup. - EXAMPLE:: + EXAMPLES:: sage: G. = AbelianGroup(2) sage: A = G.subgroup([a]) diff --git a/src/sage/groups/abelian_gps/abelian_group_element.py b/src/sage/groups/abelian_gps/abelian_group_element.py index c36fb722856..75d3c18a14f 100644 --- a/src/sage/groups/abelian_gps/abelian_group_element.py +++ b/src/sage/groups/abelian_gps/abelian_group_element.py @@ -149,7 +149,7 @@ def word_problem(self, words): Don't use E (or other GAP-reserved letters) as a generator name. - EXAMPLE:: + EXAMPLES:: sage: G = AbelianGroup(2,[2,3], names="xy") sage: x,y = G.gens() diff --git a/src/sage/groups/abelian_gps/element_base.py b/src/sage/groups/abelian_gps/element_base.py index 409164fbca9..e22efcf5e3d 100644 --- a/src/sage/groups/abelian_gps/element_base.py +++ b/src/sage/groups/abelian_gps/element_base.py @@ -286,7 +286,7 @@ def inverse(self): """ Returns the inverse element. - EXAMPLE:: + EXAMPLES:: sage: G. = AbelianGroup([0,5]) sage: a.inverse() diff --git a/src/sage/groups/abelian_gps/values.py b/src/sage/groups/abelian_gps/values.py index 32b2ab77687..a3ba73ad158 100644 --- a/src/sage/groups/abelian_gps/values.py +++ b/src/sage/groups/abelian_gps/values.py @@ -335,7 +335,7 @@ def inverse(self): """ Return the inverse element. - EXAMPLE:: + EXAMPLES:: sage: G. = AbelianGroupWithValues([2,-1], [0,4]) sage: a.inverse() diff --git a/src/sage/groups/additive_abelian/additive_abelian_group.py b/src/sage/groups/additive_abelian/additive_abelian_group.py index 0427a95d255..9709371375f 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_group.py +++ b/src/sage/groups/additive_abelian/additive_abelian_group.py @@ -28,7 +28,7 @@ def AdditiveAbelianGroup(invs, remember_generators = True): The abelian group `\bigoplus_i \ZZ / n_i \ZZ`, where `n_i` are the invariants. - EXAMPLE:: + EXAMPLES:: sage: AdditiveAbelianGroup([0, 2, 4]) Additive abelian group isomorphic to Z + Z/2 + Z/4 @@ -184,7 +184,7 @@ def _repr_(self): this group (represented as a quotient `G/H` of free abelian groups) to `G`, using the Hermite normal form of the matrix of relations. - EXAMPLE:: + EXAMPLES:: sage: G = AdditiveAbelianGroup([2,3]) sage: repr(G.gen(0)) # indirect doctest @@ -217,7 +217,7 @@ class AdditiveAbelianGroup_class(FGP_Module_class, AbelianGroup): def __init__(self, cover, relations): r""" - EXAMPLE:: + EXAMPLES:: sage: G = AdditiveAbelianGroup([0]); G # indirect doctest Additive abelian group isomorphic to Z @@ -244,7 +244,7 @@ def _latex_(self): r""" Returns a Latex representation of the group, using the invariants. - EXAMPLE:: + EXAMPLES:: sage: G=AdditiveAbelianGroup([66, 77, 0, 0]) sage: G._latex_() @@ -273,7 +273,7 @@ def short_name(self): r""" Return a name for the isomorphism class of this group. - EXAMPLE:: + EXAMPLES:: sage: AdditiveAbelianGroup([0, 2,4]).short_name() 'Z + Z/2 + Z/4' @@ -362,7 +362,7 @@ def is_multiplicative(self): r""" Return False since this is an additive group. - EXAMPLE:: + EXAMPLES:: sage: AdditiveAbelianGroup([0]).is_multiplicative() False @@ -408,7 +408,7 @@ def __init__(self, cover, rels, gens): r""" Standard initialisation function - EXAMPLE:: + EXAMPLES:: sage: AdditiveAbelianGroup([3]) # indirect doctest Additive abelian group isomorphic to Z/3 @@ -421,7 +421,7 @@ def gens(self): Return the specified generators for self (as a tuple). Compare ``self.smithform_gens()``. - EXAMPLE:: + EXAMPLES:: sage: G = AdditiveAbelianGroup([2,3]) sage: G.gens() @@ -435,7 +435,7 @@ def identity(self): r""" Return the identity (zero) element of this group. - EXAMPLE:: + EXAMPLES:: sage: G = AdditiveAbelianGroup([2, 3]) sage: G.identity() @@ -447,7 +447,7 @@ def permutation_group(self): r""" Return the permutation group attached to this group. - EXAMPLE:: + EXAMPLES:: sage: G = AdditiveAbelianGroup([2, 3]) sage: G.permutation_group() diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index 44a8236c76b..cca84ce8adc 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -60,7 +60,7 @@ class UnwrappingMorphism(Morphism): """ def __init__(self, domain): r""" - EXAMPLE:: + EXAMPLES:: sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) sage: F = QQbar.coerce_map_from(G); F @@ -117,7 +117,7 @@ def element(self): r""" Return the underlying object that this element wraps. - EXAMPLE:: + EXAMPLES:: sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) sage: T; type(T) @@ -135,7 +135,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) sage: repr(T) # indirect doctest @@ -153,7 +153,7 @@ class AdditiveAbelianGroupWrapper(addgp.AdditiveAbelianGroup_fixed_gens): def __init__(self, universe, gens, invariants): r""" - EXAMPLE:: + EXAMPLES:: sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # indirect doctest Additive abelian group isomorphic to Z + Z embedded in Algebraic Field @@ -170,7 +170,7 @@ def universe(self): r""" The ambient group in which this abelian group lives. - EXAMPLE:: + EXAMPLES:: sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) sage: G.universe() @@ -186,7 +186,7 @@ def generator_orders(self): ``self.invariants()``, which returns the orders of a minimal set of generators. - EXAMPLE:: + EXAMPLES:: sage: V = Zmod(6)**2 sage: G = AdditiveAbelianGroupWrapper(V, [2*V.0, 3*V.1], [3, 2]) @@ -199,7 +199,7 @@ def generator_orders(self): def _repr_(self): r""" - EXAMPLE:: + EXAMPLES:: sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) sage: repr(G) # indirect doctest @@ -213,7 +213,7 @@ def _discrete_exp(self, v): generators of this group, compute the element of the ambient group with those exponents in terms of the generators of self. - EXAMPLE:: + EXAMPLES:: sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), -1], [0, 0]) sage: v = G._discrete_exp([3, 5]); v @@ -232,7 +232,7 @@ def _discrete_log(self,x): Given an element of the ambient group, attempt to express it in terms of the generators of self. - EXAMPLE:: + EXAMPLES:: sage: V = Zmod(8)**2; G = AdditiveAbelianGroupWrapper(V, [[2,2],[4,0]], [4, 2]) sage: G._discrete_log(V([6, 2])) diff --git a/src/sage/groups/group.pyx b/src/sage/groups/group.pyx index fd224fad4b4..c6ad8181ae2 100644 --- a/src/sage/groups/group.pyx +++ b/src/sage/groups/group.pyx @@ -142,7 +142,7 @@ cdef class Group(Parent): (Note for developers: Derived classes should override is_abelian, not is_commutative.) - EXAMPLE:: + EXAMPLES:: sage: SL(2, 7).is_commutative() False diff --git a/src/sage/groups/matrix_gps/group_element.pyx b/src/sage/groups/matrix_gps/group_element.pyx index 917d8487577..49eb3dc34ce 100644 --- a/src/sage/groups/matrix_gps/group_element.pyx +++ b/src/sage/groups/matrix_gps/group_element.pyx @@ -680,7 +680,7 @@ cdef class MatrixGroupElement_gap(ElementLibGAP): problem (the GAP functions ``EpimorphismFromFreeGroup`` and ``PreImagesRepresentative``). - EXAMPLE:: + EXAMPLES:: sage: G = GL(2,5); G General Linear Group of degree 2 over Finite Field of size 5 diff --git a/src/sage/groups/old.pyx b/src/sage/groups/old.pyx index 6d5797e154f..31e77750763 100644 --- a/src/sage/groups/old.pyx +++ b/src/sage/groups/old.pyx @@ -120,7 +120,7 @@ cdef class Group(sage.structure.parent_gens.ParentWithGens): (Note for developers: Derived classes should override is_abelian, not is_commutative.) - EXAMPLE:: + EXAMPLES:: sage: SL(2, 7).is_commutative() False diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx index 373d9a3f90d..1fc970a8eec 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx @@ -738,7 +738,7 @@ def all_labeled_graphs(n): classifying isomorphism types (naive approach), and more importantly in benchmarking the search algorithm. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_graphs import all_labeled_graphs sage: st = sage.groups.perm_gps.partn_ref.refinement_graphs.search_tree diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx index 0121ed3d5a1..39d20a93eba 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx @@ -25,7 +25,7 @@ def is_isomorphic(self, other): Return the bijection as a permutation if two lists are isomorphic, return False otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_lists import is_isomorphic sage: is_isomorphic([0,0,1],[1,0,0]) diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx index 2a0a005c2b3..4cbde327dae 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx @@ -94,7 +94,7 @@ cdef class MatrixStruct: """ Display the matrix, and associated data. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_matrices import MatrixStruct sage: M = MatrixStruct(Matrix(GF(5), [[0,1,1,4,4],[0,4,4,1,1]])) @@ -181,7 +181,7 @@ cdef class MatrixStruct: For more examples, see self.run(). - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_matrices import MatrixStruct diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx index 2d0b9ce6ed4..38b5c7f5a97 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx @@ -44,7 +44,7 @@ cdef class PythonPartitionStack: """ Initialize a PartitionStack. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) # implicit doctest @@ -56,7 +56,7 @@ cdef class PythonPartitionStack: """ Deallocate the PartitionStack. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -69,7 +69,7 @@ cdef class PythonPartitionStack: """ Returns a string representing the stack. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -83,7 +83,7 @@ cdef class PythonPartitionStack: """ Prints a representation of the stack. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -101,7 +101,7 @@ cdef class PythonPartitionStack: """ Returns whether the deepest partition consists only of singleton cells. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -119,7 +119,7 @@ cdef class PythonPartitionStack: """ Returns the number of cells in the deepest partition. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -134,7 +134,7 @@ cdef class PythonPartitionStack: Makes sure that the first element of the segment of entries i with start <= i <= end is minimal. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -152,7 +152,7 @@ cdef class PythonPartitionStack: def __copy__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -173,7 +173,7 @@ cdef class PythonPartitionStack: Sets the current partition to the first shallower one, i.e. forgets about boundaries between cells that are new to the current level. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -195,7 +195,7 @@ cdef class PythonPartitionStack: """ Returns the entries array as a Python list of ints. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -212,7 +212,7 @@ cdef class PythonPartitionStack: """ Sets the ith entry of the entries array to entry. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -228,7 +228,7 @@ cdef class PythonPartitionStack: """ Gets the ith entry of the entries array. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -242,7 +242,7 @@ cdef class PythonPartitionStack: """ Return the levels array as a Python list of ints. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -258,7 +258,7 @@ cdef class PythonPartitionStack: """ Sets the ith entry of the levels array to entry. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -276,7 +276,7 @@ cdef class PythonPartitionStack: """ Gets the ith entry of the levels array. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -291,7 +291,7 @@ cdef class PythonPartitionStack: Returns the depth of the deepest partition in the stack, setting it to new if new is not None. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -308,7 +308,7 @@ cdef class PythonPartitionStack: Returns the degree of the partition stack, setting it to new if new is not None. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -324,7 +324,7 @@ cdef class PythonPartitionStack: """ Return the partition at level k, as a Python list of lists. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack sage: P = PythonPartitionStack(7) @@ -355,7 +355,7 @@ class PythonObjectWrapper: """ Initialize a PythonObjectWrapper. - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonObjectWrapper sage: def acae(a,b): @@ -443,7 +443,7 @@ def aut_gp_and_can_lab_python(S, partition, n, base -- boolean; whether to return a base for the automorphism group order -- boolean; whether to return the order of the automorphism group - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import aut_gp_and_can_lab_python sage: def acae(a,b): @@ -525,7 +525,7 @@ def double_coset_python(S1, S2, partition1, ordering2, n, int compare_structures(list, list, object, object) (see double_coset.pyx for more documentation) - EXAMPLE:: + EXAMPLES:: sage: from sage.groups.perm_gps.partn_ref.refinement_python import double_coset_python sage: def acae(a,b): diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py index fbe87dd0056..6ced9c0b499 100644 --- a/src/sage/groups/perm_gps/permgroup.py +++ b/src/sage/groups/perm_gps/permgroup.py @@ -602,7 +602,7 @@ def _element_class(self): it may be overridden in derived subclasses (most importantly ``sage.rings.number_field.galois_group.GaloisGroup_v2``). - EXAMPLE:: + EXAMPLES:: sage: AlternatingGroup(17)._element_class() @@ -1094,7 +1094,7 @@ def representative_action(self,x,y): - ``x,y`` -- two elements of the domain. - EXAMPLE:: + EXAMPLES:: sage: G = groups.permutation.Cyclic(14) sage: g = G.representative_action(1,10) @@ -3316,7 +3316,7 @@ def minimal_generating_set(self): r""" Return a minimal generating set - EXAMPLE:: + EXAMPLES:: sage: g = graphs.CompleteGraph(4) sage: g.relabel(['a','b','c','d']) diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index 6bfc09a8c63..e3d0d77afc9 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -608,7 +608,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): OUTPUT: a permutation group element - EXAMPLE:: + EXAMPLES:: sage: G = PermutationGroup([[(1,2,3),(4,5)]],5) sage: g = G.gen(0) @@ -671,7 +671,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): Alternately, if i is a list, tuple or string, returns the result of self acting on i. - EXAMPLE:: + EXAMPLES:: sage: G = PermutationGroup(['(1,2,3)(4,5)']) sage: G @@ -1443,7 +1443,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): functions "EpimorphismFromFreeGroup" and "PreImagesRepresentative". - EXAMPLE:: + EXAMPLES:: sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]], canonicalize=False) sage: g1, g2 = G.gens() diff --git a/src/sage/groups/perm_gps/permgroup_named.py b/src/sage/groups/perm_gps/permgroup_named.py index 9c70c704eeb..f31a0e64e52 100644 --- a/src/sage/groups/perm_gps/permgroup_named.py +++ b/src/sage/groups/perm_gps/permgroup_named.py @@ -624,7 +624,7 @@ def _element_class(self): r""" Return the class to be used for creating elements of this group. - EXAMPLE:: + EXAMPLES:: sage: SymmetricGroup(17)._element_class() diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index a0959eeab79..21cb0c94d84 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -1213,7 +1213,7 @@ def __call__(self, simplex): If ``simplex`` is a simplex in this complex, return it. Otherwise, raise a ``ValueError``. - EXAMPLE:: + EXAMPLES:: sage: K = SimplicialComplex([(0,1,2), (0,2,3)]) sage: K(Simplex((1,2))) diff --git a/src/sage/interfaces/expect.py b/src/sage/interfaces/expect.py index c86a9bdddba..20587250f29 100644 --- a/src/sage/interfaces/expect.py +++ b/src/sage/interfaces/expect.py @@ -332,7 +332,7 @@ def pid(self): :meth:`quit`, a new sub-process with a new PID is automatically started. - EXAMPLE:: + EXAMPLES:: sage: pid = gap.pid() sage: gap.eval('quit;') @@ -1173,7 +1173,7 @@ def _crash_msg(self): r""" Show a message if the interface crashed. - EXAMPLE:: + EXAMPLES:: sage: singular._crash_msg() Singular crashed -- automatically restarting. @@ -1448,7 +1448,7 @@ def __init__(self, interface, silent=False, stdout=None): - ``stdout`` - optional parameter for alternative stdout device (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.expect import StdOutContext sage: with StdOutContext(Gp()) as g: @@ -1461,7 +1461,7 @@ def __init__(self, interface, silent=False, stdout=None): def __enter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.expect import StdOutContext sage: with StdOutContext(singular): @@ -1482,7 +1482,7 @@ def __enter__(self): def __exit__(self, typ, value, tb): r""" - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.expect import StdOutContext sage: with StdOutContext(gap): diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py index 3102c2eff11..9d529282584 100644 --- a/src/sage/interfaces/genus2reduction.py +++ b/src/sage/interfaces/genus2reduction.py @@ -290,7 +290,7 @@ class Genus2reduction(SageObject): sage: factor(genus2reduction(x^3 + x + 1, x^5 + 2*x^4 + 2*x^3 + x^2 - x - 1).conductor) 5^6 - EXAMPLE:: + EXAMPLES:: sage: genus2reduction(0, x^6 + 3*x^3 + 63) Reduction data about this proper smooth genus 2 curve: diff --git a/src/sage/interfaces/giac.py b/src/sage/interfaces/giac.py index 0652cc7adb2..33129869219 100644 --- a/src/sage/interfaces/giac.py +++ b/src/sage/interfaces/giac.py @@ -1013,7 +1013,7 @@ def _sage_(self): therefore only very simple expressions will convert successfully. Warning: List conversion is slow. - EXAMPLE:: + EXAMPLES:: sage: m = giac('x^2 + 5*y') sage: m.sage() diff --git a/src/sage/interfaces/macaulay2.py b/src/sage/interfaces/macaulay2.py index a1da51705b0..9eca0e66436 100644 --- a/src/sage/interfaces/macaulay2.py +++ b/src/sage/interfaces/macaulay2.py @@ -735,7 +735,7 @@ def __floordiv__(self, x): """ Quotient of division of self by other. This is denoted //. - EXAMPLE:: + EXAMPLES:: sage: R. = GF(7)[] @@ -770,7 +770,7 @@ def __mod__(self, x): """ Remainder of division of self by other. This is denoted %. - EXAMPLE:: + EXAMPLES:: sage: R. = GF(7)[] diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py index 9c2145a3a0a..de49c9926ea 100644 --- a/src/sage/interfaces/magma.py +++ b/src/sage/interfaces/magma.py @@ -2569,7 +2569,7 @@ def __floordiv__(self, x): Quotient of division of self by other. This is denoted // ("div" in magma). - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: magma(5)//magma(2) # optional - magma @@ -2814,7 +2814,7 @@ def __init__(self, verbosity=1, style='magma'): 'sage' only the current degree and the number of pairs in the queue is printed (default: "magma"). - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: I = sage.rings.ideal.Cyclic(P) @@ -2885,7 +2885,7 @@ def __init__(self, verbosity=1, style='magma'): def write(self, s): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: I = sage.rings.ideal.Katsura(P) @@ -2950,7 +2950,7 @@ def write(self, s): def flush(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.magma import MagmaGBLogPrettyPrinter sage: logs = MagmaGBLogPrettyPrinter() @@ -2971,7 +2971,7 @@ def __init__(self, magma=None): - ``magma`` - (default: ``magma_default``) - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.magma import MagmaGBDefaultContext sage: magma.SetVerbose('Groebner',1) # optional - magma @@ -2986,7 +2986,7 @@ def __init__(self, magma=None): def __enter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.magma import MagmaGBDefaultContext sage: magma.SetVerbose('Groebner',1) # optional - magma @@ -2998,7 +2998,7 @@ def __enter__(self): def __exit__(self, typ, value, tb): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.magma import MagmaGBDefaultContext sage: magma.SetVerbose('Groebner',1) # optional - magma @@ -3014,7 +3014,7 @@ def magma_gb_standard_options(func): """ Decorator to force default options for Magma. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(127)) sage: J = sage.rings.ideal.Cyclic(P).homogenize() diff --git a/src/sage/interfaces/maple.py b/src/sage/interfaces/maple.py index fd205e32467..2ea89a8992a 100644 --- a/src/sage/interfaces/maple.py +++ b/src/sage/interfaces/maple.py @@ -1120,7 +1120,7 @@ def _sage_(self): This currently does not implement a parser for the Maple output language, therefore only very simple expressions will convert successfully. - EXAMPLE:: + EXAMPLES:: sage: m = maple('x^2 + 5*y') # optional - maple sage: m.sage() # optional - maple diff --git a/src/sage/interfaces/mwrank.py b/src/sage/interfaces/mwrank.py index 9d9bd6cbcaa..4417b592763 100644 --- a/src/sage/interfaces/mwrank.py +++ b/src/sage/interfaces/mwrank.py @@ -326,7 +326,7 @@ def console(self): """ Start the mwrank console. - EXAMPLE:: + EXAMPLES:: sage: mwrank.console() # not tested: expects console input Program mwrank: ... @@ -355,7 +355,7 @@ def mwrank_console(): """ Start the mwrank console. - EXAMPLE:: + EXAMPLES:: sage: mwrank_console() # not tested: expects console input Program mwrank: ... diff --git a/src/sage/interfaces/qepcad.py b/src/sage/interfaces/qepcad.py index 9ca8855acee..b6252c2781c 100644 --- a/src/sage/interfaces/qepcad.py +++ b/src/sage/interfaces/qepcad.py @@ -2092,7 +2092,7 @@ def exists(self, v, formula): methods of ``qepcad_formula``, a symbolic equality or inequality, or a polynomial $p$ (meaning $p = 0$). - EXAMPLE:: + EXAMPLES:: sage: var('a,b') (a, b) @@ -2119,7 +2119,7 @@ def forall(self, v, formula): methods of ``qepcad_formula``, a symbolic equality or inequality, or a polynomial $p$ (meaning $p = 0$). - EXAMPLE:: + EXAMPLES:: sage: var('a,b') (a, b) @@ -2147,7 +2147,7 @@ def infinitely_many(self, v, formula): methods of ``qepcad_formula``, a symbolic equality or inequality, or a polynomial $p$ (meaning $p = 0$). - EXAMPLE:: + EXAMPLES:: sage: var('a,b') (a, b) @@ -2173,7 +2173,7 @@ def all_but_finitely_many(self, v, formula): methods of ``qepcad_formula``, a symbolic equality or inequality, or a polynomial $p$ (meaning $p = 0$). - EXAMPLE:: + EXAMPLES:: sage: var('a,b') (a, b) @@ -2200,7 +2200,7 @@ def connected_subset(self, v, formula, allow_multi=False): methods of ``qepcad_formula``, a symbolic equality or inequality, or a polynomial $p$ (meaning $p = 0$). - EXAMPLE:: + EXAMPLES:: sage: var('a,b') (a, b) @@ -2230,7 +2230,7 @@ def exactly_k(self, k, v, formula, allow_multi=False): methods of ``qepcad_formula``, a symbolic equality or inequality, or a polynomial $p$ (meaning $p = 0$). - EXAMPLE:: + EXAMPLES:: sage: var('a,b') (a, b) diff --git a/src/sage/interfaces/sage0.py b/src/sage/interfaces/sage0.py index 742836d8a3f..f886030e392 100644 --- a/src/sage/interfaces/sage0.py +++ b/src/sage/interfaces/sage0.py @@ -446,7 +446,7 @@ def _sage_(self): """ Return local copy of self. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py index 5420c48fc11..2af7bc10781 100644 --- a/src/sage/interfaces/singular.py +++ b/src/sage/interfaces/singular.py @@ -213,7 +213,7 @@ ``normal.lib`` library before calling the ``genus`` command, or you'll get an error message. -EXAMPLE:: +EXAMPLES:: sage: singular.lib('normal.lib') sage: R = singular.ring(0,'(x,y)','dp') @@ -1291,7 +1291,7 @@ def __repr__(self): r""" Return string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: r = singular.ring(0,'(x,y)','dp') sage: singular(0) @@ -1485,7 +1485,7 @@ def sage_global_ring(self): """ Return the current basering in Singular as a polynomial ring or quotient ring. - EXAMPLE:: + EXAMPLES:: sage: singular.eval('ring r1 = (9,x),(a,b,c,d,e,f),(M((1,2,3,0)),wp(2,3),lp)') '' @@ -2153,7 +2153,7 @@ def attrib(self, name, value=None): resolution withDim - value of type int is the dimension (see dim) withMult - value of type int is the multiplicity (see mult) - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ) sage: I = Ideal([z^2, y*z, y^2, x*z, x*y, x^2]) @@ -2188,7 +2188,7 @@ def _sage_doc_(self): This function is an automatically generated pexpect wrapper around the Singular function '%s'. -EXAMPLE:: +EXAMPLES:: sage: groebner = singular.groebner sage: P. = PolynomialRing(QQ) @@ -2278,7 +2278,7 @@ def generate_docstring_dictionary(): Generate global dictionaries which hold the docstrings for Singular functions. - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.singular import generate_docstring_dictionary sage: generate_docstring_dictionary() @@ -2327,7 +2327,7 @@ def get_docstring(name): - ``name`` - a Singular function name - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.singular import get_docstring sage: 'groebner' in get_docstring('groebner') @@ -2429,7 +2429,7 @@ def __init__(self, verbosity=1): - ``verbosity`` - how much information should be printed (between 0 and 3) - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.singular import SingularGBLogPrettyPrinter sage: s0 = SingularGBLogPrettyPrinter(verbosity=0) @@ -2454,7 +2454,7 @@ def __init__(self, verbosity=1): def write(self, s): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.singular import SingularGBLogPrettyPrinter sage: s3 = SingularGBLogPrettyPrinter(verbosity=3) @@ -2553,7 +2553,7 @@ def write(self, s): def flush(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.singular import SingularGBLogPrettyPrinter sage: s3 = SingularGBLogPrettyPrinter(verbosity=3) @@ -2580,7 +2580,7 @@ def __init__(self, singular=None): - ``singular`` - Singular instance (default: default instance) - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.singular import SingularGBDefaultContext sage: P. = PolynomialRing(QQ,3, order='lex') @@ -2623,7 +2623,7 @@ def __init__(self, singular=None): def __enter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.singular import SingularGBDefaultContext sage: P. = PolynomialRing(QQ,3, order='lex') @@ -2661,7 +2661,7 @@ def __enter__(self): def __exit__(self, typ, value, tb): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.interfaces.singular import SingularGBDefaultContext sage: P. = PolynomialRing(QQ,3, order='lex') diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py index 7ce0bbc6f0a..f80d5a54766 100644 --- a/src/sage/lfunctions/dokchitser.py +++ b/src/sage/lfunctions/dokchitser.py @@ -579,7 +579,7 @@ def set_coeff_growth(self, coefgrow): function of n that defines a coefgrow function. - EXAMPLE:: + EXAMPLES:: sage: L = Dokchitser(conductor=1, gammaV=[0,1], weight=12, eps=1) sage: pari_precode = 'tau(n)=(5*sigma(n,3)+7*sigma(n,5))*n/12 - 35*sum(k=1,n-1,(6*k-4*(n-k))*sigma(k,3)*sigma(n-k,5))' diff --git a/src/sage/libs/cypari2/gen.pyx b/src/sage/libs/cypari2/gen.pyx index aa5d8e3d08a..eef6ed944de 100644 --- a/src/sage/libs/cypari2/gen.pyx +++ b/src/sage/libs/cypari2/gen.pyx @@ -2573,7 +2573,7 @@ cdef class Gen(Gen_auto): OUTPUT: int (a Python int) - EXAMPLE:: + EXAMPLES:: sage: pari('1').sizebyte() 12 # 32-bit @@ -4347,7 +4347,7 @@ cdef class Gen(Gen_auto): r""" Show the internal structure of self (like the ``\x`` command in gp). - EXAMPLE:: + EXAMPLES:: sage: pari('[1/2, 1.0*I]').debug() # random addresses [&=0000000004c5f010] VEC(lg=3):2200000000000003 0000000004c5eff8 0000000004c5efb0 diff --git a/src/sage/libs/cypari2/handle_error.pyx b/src/sage/libs/cypari2/handle_error.pyx index 47cb07f7061..ac589f2a82d 100644 --- a/src/sage/libs/cypari2/handle_error.pyx +++ b/src/sage/libs/cypari2/handle_error.pyx @@ -55,7 +55,7 @@ class PariError(RuntimeError): """ Return the message output by PARI when this error occurred. - EXAMPLE:: + EXAMPLES:: sage: try: ....: pari('pi()') diff --git a/src/sage/libs/cypari2/pari_instance.pyx b/src/sage/libs/cypari2/pari_instance.pyx index e306f10855f..d30fba62b3e 100644 --- a/src/sage/libs/cypari2/pari_instance.pyx +++ b/src/sage/libs/cypari2/pari_instance.pyx @@ -619,7 +619,7 @@ cdef class Pari(Pari_auto): (available memory address, think of this as the stack pointer), ``bot`` (bottom of stack). - EXAMPLE:: + EXAMPLES:: sage: pari.debugstack() # random top = 0x60b2c60 diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx index 1fafb6cd7b9..ab7530c2840 100644 --- a/src/sage/libs/ecl.pyx +++ b/src/sage/libs/ecl.pyx @@ -384,7 +384,7 @@ def shutdown_ecl(): that no ECL objects exist at a particular time. Hence, destroying ECL is a risky proposition. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.ecl import * sage: shutdown_ecl() @@ -404,7 +404,7 @@ def print_objects(): small integers do not get linked in. This routine prints the values currently stored. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.ecl import * sage: a=EclObject("hello") diff --git a/src/sage/libs/eclib/interface.py b/src/sage/libs/eclib/interface.py index 40e9c6fc638..ad8767e1c96 100644 --- a/src/sage/libs/eclib/interface.py +++ b/src/sage/libs/eclib/interface.py @@ -770,7 +770,7 @@ class mwrank_MordellWeil(SageObject): rank; useful if an upper bound for the rank is already known). - EXAMPLE:: + EXAMPLES:: sage: E = mwrank_EllipticCurve([1,0,1,4,-6]) sage: EQ = mwrank_MordellWeil(E) @@ -894,7 +894,7 @@ def __init__(self, curve, verbose=True, pp=1, maxr=999): See the docstring of this class for full documentation. - EXAMPLE:: + EXAMPLES:: sage: E = mwrank_EllipticCurve([1,0,1,4,-6]) sage: EQ = mwrank_MordellWeil(E) @@ -935,7 +935,7 @@ def __repr__(self): (string) String representation of this Mordell-Weil subgroup. - EXAMPLE:: + EXAMPLES:: sage: E = mwrank_EllipticCurve([0,0,1,-7,6]) sage: EQ = mwrank_MordellWeil(E, verbose=False) diff --git a/src/sage/libs/eclib/mwrank.pyx b/src/sage/libs/eclib/mwrank.pyx index aeacdfebae5..3d6f9f781b8 100644 --- a/src/sage/libs/eclib/mwrank.pyx +++ b/src/sage/libs/eclib/mwrank.pyx @@ -87,7 +87,7 @@ def get_precision(): (int) The current precision in decimal digits. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.eclib.mwrank import get_precision sage: get_precision() @@ -107,7 +107,7 @@ def set_precision(n): None. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.eclib.mwrank import set_precision sage: set_precision(50) @@ -508,7 +508,7 @@ cdef class _mw: rank; useful if an upper bound for the rank is already known). - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.eclib.mwrank import _mw sage: from sage.libs.eclib.mwrank import _Curvedata @@ -909,7 +909,7 @@ cdef class _mw: None. The effect of the search is to update the list of generators. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.eclib.mwrank import _Curvedata sage: from sage.libs.eclib.mwrank import _mw diff --git a/src/sage/libs/flint/nmod_poly_linkage.pxi b/src/sage/libs/flint/nmod_poly_linkage.pxi index 5f07613b523..248efa73b0e 100644 --- a/src/sage/libs/flint/nmod_poly_linkage.pxi +++ b/src/sage/libs/flint/nmod_poly_linkage.pxi @@ -35,7 +35,7 @@ cdef inline int celement_delete(nmod_poly_t e, unsigned long n): cdef inline int celement_construct(nmod_poly_t e, unsigned long n): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] @@ -45,7 +45,7 @@ cdef inline int celement_construct(nmod_poly_t e, unsigned long n): cdef inline int celement_destruct(nmod_poly_t e, unsigned long n): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: del x @@ -57,7 +57,7 @@ cdef inline int celement_destruct(nmod_poly_t e, unsigned long n): cdef inline int celement_gen(nmod_poly_t e, long i, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] @@ -71,7 +71,7 @@ cdef object celement_repr(nmod_poly_t e, unsigned long n): cdef inline int celement_set(nmod_poly_t res, nmod_poly_t a, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: y = copy(x) @@ -104,7 +104,7 @@ cdef inline int celement_set(nmod_poly_t res, nmod_poly_t a, unsigned long n) ex cdef inline int celement_set_si(nmod_poly_t res, long i, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: P(32003) @@ -133,7 +133,7 @@ cdef inline long celement_get_si(nmod_poly_t res, unsigned long n) except -2: cdef inline bint celement_is_zero(nmod_poly_t a, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: P(1).is_zero() @@ -151,7 +151,7 @@ cdef inline bint celement_is_zero(nmod_poly_t a, unsigned long n) except -2: cdef inline bint celement_is_one(nmod_poly_t a, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: P(1).is_one() @@ -170,7 +170,7 @@ cdef inline bint celement_is_one(nmod_poly_t a, unsigned long n) except -2: cdef inline bint celement_equal(nmod_poly_t a, nmod_poly_t b, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: (3*2)*x == 3*(2*x) @@ -192,7 +192,7 @@ cdef inline bint celement_equal(nmod_poly_t a, nmod_poly_t b, unsigned long n) e cdef inline int celement_cmp(nmod_poly_t l, nmod_poly_t r, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: x > x @@ -249,7 +249,7 @@ cdef inline int celement_cmp(nmod_poly_t l, nmod_poly_t r, unsigned long n) exce cdef long celement_len(nmod_poly_t a, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: (x + 1).degree() @@ -271,7 +271,7 @@ cdef long celement_len(nmod_poly_t a, unsigned long n) except -2: cdef inline int celement_add(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: x + 1 @@ -285,7 +285,7 @@ cdef inline int celement_add(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsi cdef inline int celement_sub(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: x - 1 @@ -299,7 +299,7 @@ cdef inline int celement_sub(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsi cdef inline int celement_neg(nmod_poly_t res, nmod_poly_t a, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: -(x + 2) @@ -327,7 +327,7 @@ cdef inline int celement_mul_scalar(nmod_poly_t res, nmod_poly_t p, cdef inline int celement_mul(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: (x + 1) * (x + 2) @@ -344,7 +344,7 @@ cdef inline int celement_div(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsi cdef inline int celement_floordiv(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: (x + 1) // (x + 2) @@ -370,7 +370,7 @@ cdef inline int celement_floordiv(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, cdef inline int celement_mod(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: f = 24998*x^2 + 29761*x + 2252 @@ -532,7 +532,7 @@ cdef inline int celement_pow(nmod_poly_t res, nmod_poly_t x, long e, nmod_poly_t cdef inline int celement_gcd(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: f = P.random_element(degree=4); f @@ -582,7 +582,7 @@ cdef inline int celement_gcd(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsi cdef inline int celement_xgcd(nmod_poly_t res, nmod_poly_t s, nmod_poly_t t, nmod_poly_t a, nmod_poly_t b, unsigned long n) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: f = P.random_element(degree=4); f diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx index 4c7eca4d129..ee5bcde8b2f 100644 --- a/src/sage/libs/gap/element.pyx +++ b/src/sage/libs/gap/element.pyx @@ -2535,7 +2535,7 @@ cdef class GapElement_Record(GapElement): first time the string is encountered, a new integer is returned(!) - EXAMPLE:: + EXAMPLES:: sage: rec = libgap.eval('rec(first:=123, second:=456)') sage: rec.record_name_to_index('first') # random output diff --git a/src/sage/libs/giac.py b/src/sage/libs/giac.py index 4baa4233fce..ffcdec029a1 100644 --- a/src/sage/libs/giac.py +++ b/src/sage/libs/giac.py @@ -49,7 +49,7 @@ class GiacSettingsDefaultContext: def __enter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.giac import GiacSettingsDefaultContext # optional - giacpy_sage sage: from giacpy_sage import giacsettings # optional - giacpy_sage @@ -71,7 +71,7 @@ def __enter__(self): def __exit__(self, typ, value, tb): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.giac import GiacSettingsDefaultContext # optional - giacpy_sage sage: from giacpy_sage import giacsettings # optional - giacpy_sage @@ -96,7 +96,7 @@ def local_giacsettings(func): """ Decorator to preserve Giac's proba_epsilon and threads settings. - EXAMPLE:: + EXAMPLES:: sage: def testf(a,b): # optional - giacpy_sage ....: giacsettings.proba_epsilon = a/100 diff --git a/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi b/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi index 9b03edc7cfd..b7cded870e6 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi +++ b/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi @@ -290,7 +290,7 @@ cdef inline int celement_inv(ZZ_pEX_c* res, ZZ_pEX_c* a, cparent parent) except cdef inline int celement_pow(ZZ_pEX_c* res, ZZ_pEX_c* x, long e, ZZ_pEX_c *modulus, cparent parent) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: K. = GF(next_prime(2**60)**3) sage: P. = PolynomialRing(K,implementation='NTL') diff --git a/src/sage/libs/ntl/ntl_mat_GF2.pyx b/src/sage/libs/ntl/ntl_mat_GF2.pyx index 55bc396c82a..76ce8c72473 100644 --- a/src/sage/libs/ntl/ntl_mat_GF2.pyx +++ b/src/sage/libs/ntl/ntl_mat_GF2.pyx @@ -134,7 +134,7 @@ cdef class ntl_mat_GF2(object): """ Return the string representation of this matrix. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),4,4) sage: B = ntl.mat_GF2(A); B # indirect doctest @@ -378,7 +378,7 @@ cdef class ntl_mat_GF2(object): def __getitem__(self, ij): """ - EXAMPLE:: + EXAMPLES:: sage: A = ntl.mat_GF2(3,3,range(9)) sage: A[0,0] @@ -650,7 +650,7 @@ cdef class ntl_mat_GF2(object): then, the rows of X are computed as basis of A's row space. X is in row echelon form. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),10,10) sage: Abar = ntl.mat_GF2(A) sage: A.image() @@ -688,7 +688,7 @@ cdef class ntl_mat_GF2(object): Computes a basis for the kernel of the map x -> x*A. where x is a row vector. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),10,10) sage: Abar = ntl.mat_GF2(A) diff --git a/src/sage/libs/ntl/ntl_mat_GF2E.pyx b/src/sage/libs/ntl/ntl_mat_GF2E.pyx index 7bd6a1d78de..728de5721bc 100644 --- a/src/sage/libs/ntl/ntl_mat_GF2E.pyx +++ b/src/sage/libs/ntl/ntl_mat_GF2E.pyx @@ -160,7 +160,7 @@ cdef class ntl_mat_GF2E(object): def __reduce__(self): """ - EXAMPLE:: + EXAMPLES:: sage: k. = GF(2^4) sage: ctx = ntl.GF2EContext(k) @@ -610,7 +610,7 @@ cdef class ntl_mat_GF2E(object): The rows of X are computed as basis of A's row space. X is is row echelon form. - EXAMPLE:: + EXAMPLES:: sage: ctx = ntl.GF2EContext([1,1,0,1,1,0,0,0,1]) sage: m = ntl.mat_GF2E(ctx, 3,3,[0..24]) @@ -632,7 +632,7 @@ cdef class ntl_mat_GF2E(object): Computes a basis for the kernel of the map ``x -> x*A``, where ``x`` is a row vector. - EXAMPLE:: + EXAMPLES:: sage: ctx = ntl.GF2EContext([1,1,0,1,1,0,0,0,1]) sage: m = ntl.mat_GF2E(ctx, 3,3,[0..24]) diff --git a/src/sage/libs/pynac/pynac.pyx b/src/sage/libs/pynac/pynac.pyx index 1e2e490e54f..8582f5e994a 100644 --- a/src/sage/libs/pynac/pynac.pyx +++ b/src/sage/libs/pynac/pynac.pyx @@ -255,7 +255,7 @@ def get_fn_serial(): Return the overall size of the Pynac function registry which corresponds to the last serial value plus one. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.pynac.pynac import get_fn_serial sage: from sage.symbolic.function import get_sfunction_from_serial diff --git a/src/sage/libs/ratpoints.pyx b/src/sage/libs/ratpoints.pyx index 0fc8c4f57a9..8928dce2ec5 100644 --- a/src/sage/libs/ratpoints.pyx +++ b/src/sage/libs/ratpoints.pyx @@ -57,7 +57,7 @@ def ratpoints(list coeffs, long H, verbose=False, long max=0, `y^2 = a_n x^n + \cdots + a_1 x z^{n-1} + a_0 z^n` while if n is odd, it is `y^2 = a_n x^n z + \cdots + a_1 x z^n + a_0 z^{n+1}`. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.ratpoints import ratpoints sage: for x,y,z in ratpoints([1..6], 200): diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx index da3cdbb364c..2813a6f6df9 100644 --- a/src/sage/libs/singular/function.pyx +++ b/src/sage/libs/singular/function.pyx @@ -138,7 +138,7 @@ cdef class RingWrap: """ def __repr__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: P. = PolynomialRing(QQ) @@ -160,7 +160,7 @@ cdef class RingWrap: """ Get number of generators. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: P. = PolynomialRing(QQ) @@ -176,7 +176,7 @@ cdef class RingWrap: """ Get names of variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: P. = PolynomialRing(QQ) @@ -192,7 +192,7 @@ cdef class RingWrap: """ Get number of parameters. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: P. = PolynomialRing(QQ) @@ -208,7 +208,7 @@ cdef class RingWrap: """ Get Singular string defining monomial ordering. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: P. = PolynomialRing(QQ) @@ -226,7 +226,7 @@ cdef class RingWrap: """ Get parameter names. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: P. = PolynomialRing(QQ) @@ -242,7 +242,7 @@ cdef class RingWrap: """ Get characteristic. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: P. = PolynomialRing(QQ) @@ -258,7 +258,7 @@ cdef class RingWrap: """ Determine whether a given ring is commutative. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: P. = PolynomialRing(QQ) @@ -274,7 +274,7 @@ cdef class RingWrap: """ Use Singular output. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: P. = PolynomialRing(QQ) @@ -296,7 +296,7 @@ cdef class Resolution: """ def __init__(self, base_ring): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: mres = singular_function("mres") @@ -311,7 +311,7 @@ cdef class Resolution: self.base_ring = base_ring def __repr__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: mres = singular_function("mres") @@ -326,7 +326,7 @@ cdef class Resolution: return "" def __dealloc__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: mres = singular_function("mres") @@ -373,7 +373,7 @@ def is_sage_wrapper_for_singular_ring(ring): """ Check whether wrapped ring arises from Singular or Singular/Plural. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import is_sage_wrapper_for_singular_ring sage: P. = QQ[] @@ -406,7 +406,7 @@ def is_singular_poly_wrapper(p): """ Checks if p is some data type corresponding to some singular ``poly``. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import is_singular_poly_wrapper sage: A. = FreeAlgebra(QQ, 3) @@ -422,7 +422,7 @@ def all_singular_poly_wrapper(s): Tests for a sequence ``s``, whether it consists of singular polynomials. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import all_singular_poly_wrapper sage: P. = QQ[] @@ -465,7 +465,7 @@ def all_vectors(s): Checks if a sequence ``s`` consists of free module elements over a singular ring. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import all_vectors sage: P. = QQ[] @@ -502,7 +502,7 @@ cdef class Converter(SageObject): - ``attributes`` - an optional dictionary of Singular attributes (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import Converter sage: P. = PolynomialRing(GF(127)) @@ -601,7 +601,7 @@ cdef class Converter(SageObject): """ Return the ring in which the arguments of this list live. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import Converter sage: P. = PolynomialRing(GF(127)) @@ -612,7 +612,7 @@ cdef class Converter(SageObject): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import Converter sage: P. = PolynomialRing(GF(127)) @@ -628,7 +628,7 @@ cdef class Converter(SageObject): def __len__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import Converter sage: P. = PolynomialRing(GF(127)) @@ -1045,7 +1045,7 @@ cdef class LibraryCallHandler(BaseCallHandler): """ def __init__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import LibraryCallHandler sage: LibraryCallHandler() @@ -1086,7 +1086,7 @@ cdef class KernelCallHandler(BaseCallHandler): """ def __init__(self, cmd_n, arity): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import KernelCallHandler sage: KernelCallHandler(0,0) @@ -1174,7 +1174,7 @@ cdef class SingularFunction(SageObject): - ``name`` - the name of the function - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import SingularFunction sage: SingularFunction('foobar') @@ -1203,7 +1203,7 @@ cdef class SingularFunction(SageObject): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import SingularFunction sage: SingularFunction('foobar') # indirect doctest @@ -1231,7 +1231,7 @@ cdef class SingularFunction(SageObject): If this is not possible, then a dummy ring, univariate polynomial ring over ``QQ``, is used. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: size = singular_function('size') @@ -1324,7 +1324,7 @@ cdef class SingularFunction(SageObject): def _sage_doc_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: groebner = singular_function('groebner') @@ -1438,7 +1438,7 @@ The Singular documentation for '%s' is given below. def __reduce__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: groebner = singular_function('groebner') @@ -1449,7 +1449,7 @@ The Singular documentation for '%s' is given below. def __richcmp__(self, other, op): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: groebner = singular_function('groebner') @@ -1812,7 +1812,7 @@ def lib(name): - ``name`` -- a Singular library name - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import singular_function sage: from sage.libs.singular.function import lib as singular_lib @@ -1847,7 +1847,7 @@ def list_of_functions(packages=False): - ``packages`` -- include local functions in packages. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.function import list_of_functions sage: 'groebner' in list_of_functions() diff --git a/src/sage/libs/singular/function_factory.py b/src/sage/libs/singular/function_factory.py index ea489b0d1dc..cc7ac9c6cac 100644 --- a/src/sage/libs/singular/function_factory.py +++ b/src/sage/libs/singular/function_factory.py @@ -21,7 +21,7 @@ class SingularFunctionFactory(object): """ def __getattr__(self, name): """ - EXAMPLE:: + EXAMPLES:: sage: import sage.libs.singular.function_factory sage: groebner = sage.libs.singular.function_factory.ff.groebner @@ -48,7 +48,7 @@ def __getattr__(self, name): def trait_names(self): """ - EXAMPLE:: + EXAMPLES:: sage: import sage.libs.singular.function_factory sage: "groebner" in sage.libs.singular.function_factory.ff.trait_names() diff --git a/src/sage/libs/singular/groebner_strategy.pyx b/src/sage/libs/singular/groebner_strategy.pyx index 92485a040a9..a060bffb193 100644 --- a/src/sage/libs/singular/groebner_strategy.pyx +++ b/src/sage/libs/singular/groebner_strategy.pyx @@ -192,7 +192,7 @@ cdef class GroebnerStrategy(SageObject): """ Return the ideal this strategy object is defined for. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(32003)) @@ -207,7 +207,7 @@ cdef class GroebnerStrategy(SageObject): """ Return the ring this strategy object is defined over. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(32003)) @@ -220,7 +220,7 @@ cdef class GroebnerStrategy(SageObject): def __richcmp__(self, other, op): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(19)) @@ -242,7 +242,7 @@ cdef class GroebnerStrategy(SageObject): def __reduce__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(32003)) @@ -258,7 +258,7 @@ cdef class GroebnerStrategy(SageObject): Compute the normal form of ``p`` with respect to the generators of this object. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(QQ) @@ -426,7 +426,7 @@ cdef class NCGroebnerStrategy(SageObject): """ Return the ideal this strategy object is defined for. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) @@ -443,7 +443,7 @@ cdef class NCGroebnerStrategy(SageObject): """ Return the ring this strategy object is defined over. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) @@ -457,7 +457,7 @@ cdef class NCGroebnerStrategy(SageObject): def __richcmp__(self, other, op): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) @@ -480,7 +480,7 @@ cdef class NCGroebnerStrategy(SageObject): def __reduce__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) @@ -497,7 +497,7 @@ cdef class NCGroebnerStrategy(SageObject): Compute the normal form of ``p`` with respect to the generators of this object. - EXAMPLE:: + EXAMPLES:: sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) @@ -525,7 +525,7 @@ cdef class NCGroebnerStrategy(SageObject): def unpickle_NCGroebnerStrategy0(I): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) @@ -539,7 +539,7 @@ def unpickle_NCGroebnerStrategy0(I): def unpickle_GroebnerStrategy0(I): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(32003)) diff --git a/src/sage/libs/singular/option.pyx b/src/sage/libs/singular/option.pyx index 431c1e87756..72360a4a169 100644 --- a/src/sage/libs/singular/option.pyx +++ b/src/sage/libs/singular/option.pyx @@ -150,7 +150,7 @@ cdef class LibSingularOptions_abstract: - ``**kwds`` - all keyword parameters are immediately applied. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import LibSingularOptions sage: opt = LibSingularOptions(redTail=False) @@ -171,7 +171,7 @@ cdef class LibSingularOptions_abstract: def __getitem__(self, name): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt sage: opt['red_tail'] @@ -200,7 +200,7 @@ cdef class LibSingularOptions_abstract: def __setitem__(self, name, value): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt, opt_ctx sage: opt['redTail'] @@ -230,7 +230,7 @@ cdef class LibSingularOptions_abstract: def __int__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt sage: hex(int(opt)) @@ -242,7 +242,7 @@ cdef class LibSingularOptions_abstract: """ Return a triple of integers that allow reconstruction of the options. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt sage: opt['deg_bound'] @@ -267,7 +267,7 @@ cdef class LibSingularOptions_abstract: def load(self, value=None): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt as sopt sage: bck = sopt.save(); hex(bck[0]), bck[1], bck[2] @@ -289,7 +289,7 @@ cdef class LibSingularOptions_abstract: def __repr__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt as sopt sage: sopt @@ -382,7 +382,7 @@ cdef class LibSingularOptions(LibSingularOptions_abstract): ordering and its multiplicity is lower than ``mult_bound``. Reset this bound by setting ``mult_bound`` to 0. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import LibSingularOptions sage: libsingular_options = LibSingularOptions() @@ -416,7 +416,7 @@ cdef class LibSingularOptions(LibSingularOptions_abstract): """ Create a new option interface. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import LibSingularOptions sage: libsingular_options = LibSingularOptions() @@ -446,7 +446,7 @@ cdef class LibSingularOptions(LibSingularOptions_abstract): """ Reset libSingular's default options. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt sage: opt['red_tail'] @@ -500,7 +500,7 @@ cdef class LibSingularVerboseOptions(LibSingularOptions_abstract): - ``cancelunit`` - avoids to divide polynomials by non-constant units in ``std`` in the local case. Should usually not be used. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import LibSingularVerboseOptions sage: libsingular_verbose = LibSingularVerboseOptions() @@ -511,7 +511,7 @@ cdef class LibSingularVerboseOptions(LibSingularOptions_abstract): """ Create a new option interface. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import LibSingularVerboseOptions sage: libsingular_verb_options = LibSingularVerboseOptions() @@ -541,7 +541,7 @@ cdef class LibSingularVerboseOptions(LibSingularOptions_abstract): """ Return to libSingular's default verbosity options - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt_verb sage: opt_verb['not_warn_sb'] @@ -563,7 +563,7 @@ cdef class LibSingularOptionsContext: This object localizes changes to options. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt, opt_ctx sage: opt @@ -591,7 +591,7 @@ cdef class LibSingularOptionsContext: """ Create a new context. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import LibSingularOptionsContext, opt sage: LibSingularOptionsContext(opt) @@ -605,7 +605,7 @@ cdef class LibSingularOptionsContext: def __enter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt, opt_ctx sage: opt['redTail'] @@ -625,7 +625,7 @@ cdef class LibSingularOptionsContext: """ Return a new option context where ``**kwds`` are applied. - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt, opt_ctx sage: opt['redTail'] @@ -639,7 +639,7 @@ cdef class LibSingularOptionsContext: def __exit__(self, typ, value, tb): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt, opt_ctx sage: opt['redTail'] @@ -656,7 +656,7 @@ cdef class LibSingularOptionsContext: def __repr__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.option import opt_ctx sage: opt_ctx diff --git a/src/sage/libs/singular/polynomial.pyx b/src/sage/libs/singular/polynomial.pyx index 2ac94d1f89a..eff9e678a49 100644 --- a/src/sage/libs/singular/polynomial.pyx +++ b/src/sage/libs/singular/polynomial.pyx @@ -55,7 +55,7 @@ cdef int singular_polynomial_add(poly **ret, poly *p, poly *q, ring *r): - ``q`` - a Singular polynomial - ``r`` - a Singular ring - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: x + y # indirect doctest @@ -81,7 +81,7 @@ cdef int singular_polynomial_sub(poly **ret, poly *p, poly *q, ring *r): - ``q`` - a Singular polynomial - ``r`` - a Singular ring - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: x - y # indirect doctest @@ -107,7 +107,7 @@ cdef int singular_polynomial_rmul(poly **ret, poly *p, RingElement n, ring *r): - ``n`` - a Sage coefficient - ``r`` - a Singular ring - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: 2*x # indirect doctest @@ -137,7 +137,7 @@ cdef int singular_polynomial_call(poly **ret, poly *p, ring *r, list args, poly - ``(*get_element)`` - a function to turn a Sage element into a Singular element. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: x(0,0,0) # indirect doctest @@ -286,7 +286,7 @@ cdef int singular_polynomial_mul(poly** ret, poly *p, poly *q, ring *r) except - - ``q`` - a Singular polynomial - ``r`` - a Singular ring - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: x*y # indirect doctest @@ -316,7 +316,7 @@ cdef int singular_polynomial_div_coeff(poly** ret, poly *p, poly *q, ring *r) ex - ``q`` - a constant Singular polynomial - ``r`` - a Singular ring - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: x/2 # indirect doctest @@ -350,7 +350,7 @@ cdef int singular_polynomial_pow(poly **ret, poly *p, unsigned long exp, ring *r - ``exp`` - integer - ``r`` - a Singular ring - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: f = 3*x*y + 5/2*z @@ -390,7 +390,7 @@ cdef int singular_polynomial_neg(poly **ret, poly *p, ring *r): - ``p`` - a Singular polynomial - ``r`` - a Singular ring - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: f = 3*x*y + 5/2*z @@ -412,7 +412,7 @@ cdef object singular_polynomial_str(poly *p, ring *r): - ``p`` - a Singular polynomial - ``r`` - a Singular ring - EXAMPLE:: + EXAMPLES:: sage: P. = ZZ[] sage: str(x) # indirect doctest @@ -436,7 +436,7 @@ cdef object singular_polynomial_latex(poly *p, ring *r, object base, object late - ``p`` - a Singular polynomial - ``r`` - a Singular ring - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: latex(x) # indirect doctest diff --git a/src/sage/libs/singular/ring.pyx b/src/sage/libs/singular/ring.pyx index 7a696975e01..4a6e167f228 100644 --- a/src/sage/libs/singular/ring.pyx +++ b/src/sage/libs/singular/ring.pyx @@ -516,7 +516,7 @@ cdef ring *singular_ring_reference(ring *existing_ring) except NULL: calling this function `n` times, you need to call :func:`singular_ring_delete` `n+1` times to actually deallocate the ring. - EXAMPLE:: + EXAMPLES:: sage: import gc sage: _ = gc.collect() diff --git a/src/sage/libs/singular/standard_options.py b/src/sage/libs/singular/standard_options.py index 0424d70f3d4..d12f245de44 100644 --- a/src/sage/libs/singular/standard_options.py +++ b/src/sage/libs/singular/standard_options.py @@ -9,7 +9,7 @@ class LibSingularGBDefaultContext: def __init__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.standard_options import LibSingularGBDefaultContext sage: from sage.libs.singular.option import opt @@ -34,7 +34,7 @@ def __init__(self): def __enter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.standard_options import LibSingularGBDefaultContext sage: from sage.libs.singular.option import opt @@ -71,7 +71,7 @@ def __enter__(self): def __exit__(self, typ, value, tb): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.libs.singular.standard_options import LibSingularGBDefaultContext sage: from sage.libs.singular.option import opt diff --git a/src/sage/manifolds/coord_func.py b/src/sage/manifolds/coord_func.py index 38141602baa..be1b31fb9bd 100644 --- a/src/sage/manifolds/coord_func.py +++ b/src/sage/manifolds/coord_func.py @@ -94,7 +94,7 @@ def chart(self): - a :class:`~sage.manifolds.chart.Chart` - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M', structure='topological') sage: X. = M.chart() diff --git a/src/sage/manifolds/differentiable/levi_civita_connection.py b/src/sage/manifolds/differentiable/levi_civita_connection.py index 9a2bec13ca4..981b15e4603 100644 --- a/src/sage/manifolds/differentiable/levi_civita_connection.py +++ b/src/sage/manifolds/differentiable/levi_civita_connection.py @@ -295,7 +295,7 @@ def restrict(self, subdomain): - instance of :class:`LeviCivitaConnection` representing the restriction. - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M') sage: X. = M.chart() @@ -562,7 +562,7 @@ def torsion(self): - the torsion tensor `T`, as a vanishing instance of :class:`~sage.manifolds.differentiable.tensorfield.TensorField` - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M') sage: X. = M.chart() diff --git a/src/sage/manifolds/differentiable/manifold.py b/src/sage/manifolds/differentiable/manifold.py index 59e05cbb46a..b9114ba9681 100644 --- a/src/sage/manifolds/differentiable/manifold.py +++ b/src/sage/manifolds/differentiable/manifold.py @@ -952,7 +952,7 @@ def diff_mapping(self, codomain, coord_functions=None, chart1=None, Use :meth:`diff_map` instead. - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M'); X. = M.chart() sage: N = Manifold(2, 'N'); Y. = N.chart() @@ -2716,7 +2716,7 @@ def riemann_metric(self, name, latex_name=None, dest_map=None): Use :meth:`riemannian_metric` instead. - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(3, 'M') sage: g = M.riemann_metric('g') @@ -2808,7 +2808,7 @@ def lorentz_metric(self, name, signature='positive', latex_name=None, Use :meth:`lorentzian_metric` instead. - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(4, 'M') sage: g = M.lorentz_metric('g') diff --git a/src/sage/manifolds/differentiable/manifold_homset.py b/src/sage/manifolds/differentiable/manifold_homset.py index b689fbe1c35..ec9506a5c01 100644 --- a/src/sage/manifolds/differentiable/manifold_homset.py +++ b/src/sage/manifolds/differentiable/manifold_homset.py @@ -183,7 +183,7 @@ def _coerce_map_from_(self, other): r""" Determine whether coercion to ``self`` exists from other parent. - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M') sage: X. = M.chart() diff --git a/src/sage/manifolds/differentiable/metric.py b/src/sage/manifolds/differentiable/metric.py index c687d4e6ec6..e7e8f4ff549 100644 --- a/src/sage/manifolds/differentiable/metric.py +++ b/src/sage/manifolds/differentiable/metric.py @@ -2139,7 +2139,7 @@ def set(self, symbiform): :class:`~sage.manifolds.differentiable.tensorfield_paral.TensorFieldParal` representing a field of symmetric bilinear forms - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M') sage: X. = M.chart() diff --git a/src/sage/manifolds/differentiable/scalarfield.py b/src/sage/manifolds/differentiable/scalarfield.py index 30c3298609b..6b822df7e42 100644 --- a/src/sage/manifolds/differentiable/scalarfield.py +++ b/src/sage/manifolds/differentiable/scalarfield.py @@ -688,7 +688,7 @@ def tensor_type(self): - always `(0, 0)` - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M') sage: c_xy. = M.chart() diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py index 7cfbd7a36ec..13976baba78 100644 --- a/src/sage/manifolds/differentiable/vectorfield_module.py +++ b/src/sage/manifolds/differentiable/vectorfield_module.py @@ -582,7 +582,7 @@ def dual(self): r""" Return the dual module. - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M') sage: XM = M.vector_field_module() @@ -609,7 +609,7 @@ def general_linear_group(self): :class:`~sage.manifolds.differentiable.automorphismfield_group.AutomorphismFieldGroup` representing `\mathrm{GL}(\mathcal{X}(U,\Phi))` - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M') sage: XM = M.vector_field_module() @@ -1548,7 +1548,7 @@ def general_linear_group(self): :class:`~sage.manifolds.differentiable.automorphismfield_group.AutomorphismFieldParalGroup` representing `\mathrm{GL}(\mathcal{X}(U,\Phi))` - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M') sage: X. = M.chart() # makes M parallelizable diff --git a/src/sage/manifolds/manifold_homset.py b/src/sage/manifolds/manifold_homset.py index e86426a0cd0..835364e0df1 100644 --- a/src/sage/manifolds/manifold_homset.py +++ b/src/sage/manifolds/manifold_homset.py @@ -187,7 +187,7 @@ def _latex_(self): r""" LaTeX representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M', structure='topological') sage: X. = M.chart() @@ -274,7 +274,7 @@ def _an_element_(self): - a :class:`~sage.manifolds.continuous_map.ContinuousMap` - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M', structure='topological') sage: X. = M.chart() diff --git a/src/sage/manifolds/scalarfield.py b/src/sage/manifolds/scalarfield.py index d9e2de7572b..ed9c9770da1 100644 --- a/src/sage/manifolds/scalarfield.py +++ b/src/sage/manifolds/scalarfield.py @@ -1077,7 +1077,7 @@ def function_chart(self, chart=None, from_chart=None): Use :meth:`coord_function` instead. - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M', structure='topological') sage: c_xy. = M.chart() diff --git a/src/sage/manifolds/scalarfield_algebra.py b/src/sage/manifolds/scalarfield_algebra.py index f9b917ee68e..b7978c4a785 100644 --- a/src/sage/manifolds/scalarfield_algebra.py +++ b/src/sage/manifolds/scalarfield_algebra.py @@ -561,7 +561,7 @@ def zero(self): This is nothing but the constant scalar field `0` on the manifold, where `0` is the zero element of the base field. - EXAMPLE:: + EXAMPLES:: sage: M = Manifold(2, 'M', structure='topological') sage: X. = M.chart() diff --git a/src/sage/manifolds/structure.py b/src/sage/manifolds/structure.py index 97f7cdc3c76..bd2d11cf60f 100644 --- a/src/sage/manifolds/structure.py +++ b/src/sage/manifolds/structure.py @@ -97,7 +97,7 @@ def subcategory(self, cat): Return the subcategory of ``cat`` corresponding to the structure of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.manifolds.structure import DifferentialStructure sage: from sage.categories.manifolds import Manifolds @@ -121,7 +121,7 @@ def subcategory(self, cat): Return the subcategory of ``cat`` corresponding to the structure of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.manifolds.structure import DifferentialStructure sage: from sage.categories.manifolds import Manifolds diff --git a/src/sage/manifolds/utilities.py b/src/sage/manifolds/utilities.py index 00f0c8ab6a3..424463e96b4 100644 --- a/src/sage/manifolds/utilities.py +++ b/src/sage/manifolds/utilities.py @@ -614,7 +614,7 @@ def _latex_(self): r""" LaTeX representation of the object. - EXAMPLE:: + EXAMPLES:: sage: var('x y z') (x, y, z) diff --git a/src/sage/matrix/matrix0.pyx b/src/sage/matrix/matrix0.pyx index 961a4f04a44..c53fcb62878 100644 --- a/src/sage/matrix/matrix0.pyx +++ b/src/sage/matrix/matrix0.pyx @@ -4277,7 +4277,7 @@ cdef class Matrix(sage.structure.element.Matrix): It is safe to change the resulting list (unless you give the option copy=False). - EXAMPLE:: + EXAMPLES:: sage: M = Matrix(CC, [[1,0],[0,1]], sparse=True) sage: M._nonzero_positions_by_row() diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 259ce011cf6..d6d795a19cf 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -7779,7 +7779,7 @@ cdef class Matrix(matrix1.Matrix): Before a subdivision is set, the only valid arguments are (0,0) which returns self. - EXAMPLE:: + EXAMPLES:: sage: M = matrix(3, 4, range(12)) sage: M.subdivide(1,2); M @@ -7892,7 +7892,7 @@ cdef class Matrix(matrix1.Matrix): preserved in ``self``, but if the two sets of row subdivisions are incompatible, they are removed. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(QQ, 3, 4, range(12)) sage: B = matrix(QQ, 3, 6, range(18)) @@ -7937,7 +7937,7 @@ cdef class Matrix(matrix1.Matrix): preserved in ``self``, but if the two sets of solumn subdivisions are incompatible, they are removed. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(QQ, 3, 2, range(6)) sage: B = matrix(QQ, 4, 2, range(8)) @@ -8558,7 +8558,7 @@ cdef class Matrix(matrix1.Matrix): Bitmap image as an instance of :class:`~sage.repl.image.Image`. - EXAMPLE:: + EXAMPLES:: sage: M = random_matrix(CC, 5, 7) sage: for i in range(5): M[i,i] = 0 @@ -10818,7 +10818,7 @@ cdef class Matrix(matrix1.Matrix): be similar. The main difference is that it "discovers" the dimension of the subspace as quickly as possible. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(QQ, [[5,4,2,1],[0,1,-1,-1],[-1,-1,3,0],[1,1,-1,2]]) sage: v = vector(QQ, [0,1,0,0]) @@ -14410,7 +14410,7 @@ cdef class Matrix(matrix1.Matrix): r""" Returns the transpose of a matrix. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(QQ, 5, range(25)) sage: A.T @@ -14427,7 +14427,7 @@ cdef class Matrix(matrix1.Matrix): r""" Returns the conjugate matrix. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(QQbar, [[ -3, 5 - 3*I, 7 - 4*I], ....: [7 + 3*I, -1 + 6*I, 3 + 5*I], @@ -14445,7 +14445,7 @@ cdef class Matrix(matrix1.Matrix): r""" Returns the conjugate-transpose (Hermitian) matrix. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(QQbar, [[ -3, 5 - 3*I, 7 - 4*I], ....: [7 + 3*I, -1 + 6*I, 3 + 5*I], @@ -14500,7 +14500,7 @@ def _smith_diag(d): If any of the d's is a unit, it replaces it with 1 (but no other attempt is made to pick "good" representatives of ideals). - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix2 import _smith_diag sage: OE = EquationOrder(x^2 - x + 2, 'w') @@ -14680,7 +14680,7 @@ def _smith_onestep(m): determinant 1, and the zeroth row and column of b have no nonzero entries except b[0,0]. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix2 import _smith_onestep sage: OE. = EquationOrder(x^2 - x + 2) diff --git a/src/sage/matrix/matrix_dense.pyx b/src/sage/matrix/matrix_dense.pyx index 279752e42fa..bf357c4ee23 100644 --- a/src/sage/matrix/matrix_dense.pyx +++ b/src/sage/matrix/matrix_dense.pyx @@ -243,7 +243,7 @@ cdef class Matrix_dense(matrix.Matrix): proper input. More thorough documentation is provided there. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(ZZ, 2, range(6), sparse=False) sage: B = matrix(ZZ, 2, [1,0,2,0,3,0], sparse=False) diff --git a/src/sage/matrix/matrix_gf2e_dense.pyx b/src/sage/matrix/matrix_gf2e_dense.pyx index 61f79c8ae7c..5de99b56482 100644 --- a/src/sage/matrix/matrix_gf2e_dense.pyx +++ b/src/sage/matrix/matrix_gf2e_dense.pyx @@ -30,7 +30,7 @@ The M4RIE library offers two matrix representations: See http://m4ri.sagemath.org for more details on the M4RIE library. -EXAMPLE:: +EXAMPLES:: sage: K. = GF(2^8) sage: A = random_matrix(K, 3,4) @@ -108,7 +108,7 @@ cdef class M4RIE_finite_field: def __cinit__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gf2e_dense import M4RIE_finite_field sage: K = M4RIE_finite_field(); K @@ -118,7 +118,7 @@ cdef class M4RIE_finite_field: def __dealloc__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gf2e_dense import M4RIE_finite_field sage: K = M4RIE_finite_field() @@ -220,7 +220,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``copy`` - ignored, elements are always copied - ``coerce`` - ignored, elements are always coerced - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: l = [K.random_element() for _ in range(3*4)]; l @@ -280,7 +280,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``j`` - column index - ``value`` - a finite field element (not checked but assumed) - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: A = Matrix(K,3,4,[K.random_element() for _ in range(3*4)]); A @@ -304,7 +304,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``i`` - row index - ``j`` - column index - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: A = random_matrix(K,3,4) @@ -328,7 +328,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``right`` - a matrix - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: A = random_matrix(K,3,4); A @@ -356,7 +356,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): cpdef _sub_(self, right): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gf2e_dense import Matrix_gf2e_dense sage: K. = GF(2^4) @@ -676,7 +676,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): def __neg__(self): """ - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: A = random_matrix(K, 3, 4); A @@ -693,7 +693,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): cpdef int _cmp_(self, right) except -2: """ - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: A = random_matrix(K,3,4) @@ -710,7 +710,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): def __copy__(self): """ - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: m,n = 3, 4 @@ -738,7 +738,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): def _list(self): """ - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: m,n = 3, 4 @@ -773,7 +773,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - None, the matrix is modified in-place - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: A = Matrix(K,3,3) @@ -882,7 +882,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): guarantee is given that the matrix is *not* reduced if ``False`` (default: ``True``) - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: m,n = 3, 5 @@ -964,7 +964,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): def _pivots(self): """ - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^8) sage: A = random_matrix(K, 15, 15) @@ -989,7 +989,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): def __invert__(self): """ - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^3) sage: A = random_matrix(K,3,3); A @@ -1025,7 +1025,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``multiple`` - finite field element to scale by - ``start_col`` - only start at this column index. - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^3) sage: A = random_matrix(K,3,3); A @@ -1058,7 +1058,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``multiple`` - finite field element - ``start_col`` - only start at this column index - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^3) sage: A = random_matrix(K,3,3); A @@ -1085,7 +1085,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``row1`` - row index - ``row2`` - row index - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^3) sage: A = random_matrix(K,3,3) @@ -1111,7 +1111,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``col1`` - column index - ``col2`` - column index - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^3) sage: A = random_matrix(K,3,3) @@ -1150,7 +1150,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``right`` - a matrix - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: MS = MatrixSpace(K,3,3) @@ -1224,7 +1224,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``other`` - a matrix - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: A = random_matrix(K,2,2); A @@ -1355,7 +1355,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): """ Return the rank of this matrix (cached). - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: A = random_matrix(K, 1000, 1000) @@ -1380,7 +1380,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): def __hash__(self): """ - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^4) sage: A = random_matrix(K, 1000, 1000) @@ -1393,7 +1393,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): def __reduce__(self): """ - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^8) sage: A = random_matrix(K,70,70) @@ -1434,7 +1434,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): returns a tuple of matrices `C` whose entry `C_i[x,y]` is the coefficient of `c_i` in `A[x,y]` if this matrix is `A`. - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^2) sage: A = random_matrix(K, 5, 5); A @@ -1526,7 +1526,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): - ``C`` - a list of matrices over GF(2) - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^2) sage: A = matrix(K, 5, 5) @@ -1612,7 +1612,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): def unpickle_matrix_gf2e_dense_v0(Matrix_mod2_dense a, base_ring, nrows, ncols): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = GF(2^2) sage: A = random_matrix(K,10,10) diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx index 655f6b04107..6f8d432fa8c 100644 --- a/src/sage/matrix/matrix_gfpn_dense.pyx +++ b/src/sage/matrix/matrix_gfpn_dense.pyx @@ -80,7 +80,7 @@ cdef class FieldConverter_class: for elements of prime and non-prime fields; see :class:`PrimeFieldConverter_class`. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gfpn_dense import FieldConverter_class # optional: meataxe sage: F. = GF(125) @@ -105,7 +105,7 @@ cdef class FieldConverter_class: A finite *non-prime* field. This assumption is not tested. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gfpn_dense import FieldConverter_class # optional: meataxe sage: F. = GF(125) @@ -125,7 +125,7 @@ cdef class FieldConverter_class: """ Fetch a python int into the field. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gfpn_dense import FieldConverter_class # optional: meataxe sage: F. = GF(125) @@ -141,7 +141,7 @@ cdef class FieldConverter_class: """ Represent a field element by a python int. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gfpn_dense import FieldConverter_class # optional: meataxe sage: F. = GF(125) @@ -163,7 +163,7 @@ cdef class PrimeFieldConverter_class(FieldConverter_class): have a common interface for elements of prime and non-prime fields; see :class:`FieldConverter_class`. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gfpn_dense import PrimeFieldConverter_class # optional: meataxe sage: F = GF(5) @@ -184,7 +184,7 @@ cdef class PrimeFieldConverter_class(FieldConverter_class): A finite *prime* field. This assumption is not tested. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gfpn_dense import PrimeFieldConverter_class # optional: meataxe sage: F = GF(5) @@ -204,7 +204,7 @@ cdef class PrimeFieldConverter_class(FieldConverter_class): """ Fetch a python int into the field. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gfpn_dense import PrimeFieldConverter_class # optional: meataxe sage: F = GF(5) @@ -220,7 +220,7 @@ cdef class PrimeFieldConverter_class(FieldConverter_class): """ Represent a field element by a python int. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_gfpn_dense import PrimeFieldConverter_class # optional: meataxe sage: F = GF(5) @@ -239,7 +239,7 @@ cdef FieldConverter_class FieldConverter(field): Return a :class:`FieldConverter_class` or :class:`PrimeFieldConverter_class` instance, depending whether the field is prime or not. - EXAMPLE:: + EXAMPLES:: sage: MS = MatrixSpace(GF(5^3,'y'),2) sage: A = MS.random_element() @@ -675,7 +675,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): - ``nonzero`` (optional bool, default ``False``) -- If true, all inserted marks are non-zero. - EXAMPLE:: + EXAMPLES:: sage: MS = MatrixSpace(GF(27,'z'),6,6) sage: M = MS.random_element() # indirect doctest diff --git a/src/sage/matrix/matrix_integer_dense.pyx b/src/sage/matrix/matrix_integer_dense.pyx index 8a35f304ad7..8ec3936ee85 100644 --- a/src/sage/matrix/matrix_integer_dense.pyx +++ b/src/sage/matrix/matrix_integer_dense.pyx @@ -276,7 +276,7 @@ cdef class Matrix_integer_dense(Matrix_dense): # dense or sparse """ Frees all the memory allocated for this matrix. - EXAMPLE:: + EXAMPLES:: sage: a = Matrix(ZZ,2,[1,2,3,4]) sage: del a @@ -843,7 +843,7 @@ cdef class Matrix_integer_dense(Matrix_dense): # dense or sparse def _multiply_classical(self, Matrix_integer_dense right): """ - EXAMPLE:: + EXAMPLES:: sage: n = 3 sage: a = MatrixSpace(ZZ,n,n)(range(n^2)) @@ -1339,7 +1339,7 @@ cdef class Matrix_integer_dense(Matrix_dense): # dense or sparse OUTPUT: A nonnegative integer. - EXAMPLE:: + EXAMPLES:: sage: a = Mat(ZZ,3)(range(9)) sage: a.height() @@ -2576,7 +2576,7 @@ cdef class Matrix_integer_dense(Matrix_dense): # dense or sparse r""" ntl.mat_ZZ representation of self. - EXAMPLE:: + EXAMPLES:: sage: a = MatrixSpace(ZZ,200).random_element(x=-2, y=2) # -2 to 2 sage: A = a._ntl_() @@ -5262,7 +5262,7 @@ cdef class Matrix_integer_dense(Matrix_dense): # dense or sparse None) - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(ZZ,3,3) sage: As = singular(A); As diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx index 3fba5fab11c..dba6f9ac643 100644 --- a/src/sage/matrix/matrix_integer_sparse.pyx +++ b/src/sage/matrix/matrix_integer_sparse.pyx @@ -272,7 +272,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): It is safe to change the resulting list (unless you give the option copy=False). - EXAMPLE:: + EXAMPLES:: sage: M = Matrix(ZZ, [[0,0,0,1,0,0,0,0],[0,1,0,0,0,0,1,0]], sparse=True); M [0 0 0 1 0 0 0 0] @@ -304,7 +304,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): It is safe to change the resulting list (unless you give the option copy=False). - EXAMPLE:: + EXAMPLES:: sage: M = Matrix(ZZ, [[0,0,0,1,0,0,0,0],[0,1,0,0,0,0,1,0]], sparse=True); M [0 0 0 1 0 0 0 0] diff --git a/src/sage/matrix/matrix_mod2_dense.pyx b/src/sage/matrix/matrix_mod2_dense.pyx index 59f6e43ec25..c2f76236f45 100644 --- a/src/sage/matrix/matrix_mod2_dense.pyx +++ b/src/sage/matrix/matrix_mod2_dense.pyx @@ -277,7 +277,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse `a_i` are the flattened entries in a matrix (by row, then by column). - EXAMPLE:: + EXAMPLES:: sage: B = random_matrix(GF(2),3,3) sage: B.set_immutable() @@ -431,7 +431,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse - ``minus_one`` - Ignored. Only for compatibility with generic matrices. - EXAMPLE:: + EXAMPLES:: sage: B = random_matrix(GF(2),3,3) sage: B # indirect doctest @@ -686,7 +686,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse - k -- parameter `k` for the Gray Code table size. If `k=0` a suitable value is chosen by the function. (`0<= k <= 16`, default: 0) - EXAMPLE:: + EXAMPLES:: sage: A = Matrix(GF(2), 4, 3, [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1] ) sage: B = Matrix(GF(2), 3, 4, [0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0] ) @@ -756,7 +756,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse the other routines fall back to this implementation in that case anyway. - EXAMPLE:: + EXAMPLES:: sage: A = Matrix(GF(2), 4, 3, [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1] ) sage: B = Matrix(GF(2), 3, 4, [0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0] ) @@ -820,7 +820,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse - ``cutoff`` - matrix dimension where M4RM should be used instead of Strassen (default: let M4RI decide) - EXAMPLE:: + EXAMPLES:: sage: A = Matrix(GF(2), 4, 3, [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1] ) sage: B = Matrix(GF(2), 3, 4, [0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0] ) @@ -896,7 +896,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse If ``self`` is not invertible a ``ZeroDivisionError`` is raised. - EXAMPLE:: + EXAMPLES:: sage: A = Matrix(GF(2),3,3, [0, 0, 1, 0, 1, 1, 1, 0, 1]) sage: MS = A.parent() @@ -980,7 +980,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse Returns list of the elements of ``self`` in row major ordering. - EXAMPLE:: + EXAMPLES:: sage: A = Matrix(GF(2),2,2,[1,0,1,1]) sage: A @@ -1032,7 +1032,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse 3/4 * log_2( min(nrows, ncols) ) as suggested in the M4RI paper. - reduced -- return reduced row echelon form (default:True) - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2), 10, 10) sage: B = A.__copy__(); B.echelonize() # fastest @@ -1142,7 +1142,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse Returns the pivot columns of ``self`` if ``self`` is in row echelon form. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(GF(2),5,5,[0,1,0,1,0,0,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0,1]) sage: E = A.echelon_form() @@ -1272,7 +1272,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse cdef rescale_row_c(self, Py_ssize_t row, multiple, Py_ssize_t start_col): """ - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),3,3); A [0 1 0] @@ -1290,7 +1290,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col): """ - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),3,3); A [0 1 0] @@ -1306,7 +1306,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse cdef swap_rows_c(self, Py_ssize_t row1, Py_ssize_t row2): """ - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),3,3); A [0 1 0] @@ -1321,7 +1321,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse cdef swap_columns_c(self, Py_ssize_t col1, Py_ssize_t col2): """ - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),3,3); A [0 1 0] @@ -1357,7 +1357,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse Returns a string of self in ``Magma`` form. Does not return ``Magma`` object but string. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),3,3) sage: A._magma_init_(magma) # optional - magma @@ -1402,7 +1402,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse """ Returns transpose of self and leaves self untouched. - EXAMPLE:: + EXAMPLES:: sage: A = Matrix(GF(2),3,5,[1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0]) sage: A @@ -1459,7 +1459,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse (i,j) if ``self`` and ``right`` are exchanged for the comparison. - EXAMPLE:: + EXAMPLES:: sage: A = MatrixSpace(GF(2),3,3).one() sage: B = copy(MatrixSpace(GF(2),3,3).one()) @@ -1483,7 +1483,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse r""" Augments ``self`` with ``right``. - EXAMPLE:: + EXAMPLES:: sage: MS = MatrixSpace(GF(2),3,3) sage: A = MS([0, 1, 0, 1, 1, 0, 1, 1, 1]); A @@ -1601,7 +1601,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse r""" Stack ``self`` on top of ``bottom``. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(GF(2),2,2,[1,0,0,1]) sage: B = matrix(GF(2),2,2,[0,1,1,0]) @@ -1746,7 +1746,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse """ Serialize ``self``. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),10,10) sage: f,s = A.__reduce__() @@ -1822,7 +1822,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse - approx -- return floating point approximation (default: False) - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),1000,1000) sage: d = A.density(); d @@ -1856,7 +1856,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse - ``algorithm`` - either "ple" or "m4ri" - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2), 1000, 1000) sage: A.rank() @@ -2021,7 +2021,7 @@ def unpickle_matrix_mod2_dense_v1(r, c, data, size): - s -- a string - size -- length of the string s - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(2),100,101) sage: _,(r,c,s,s2) = A.__reduce__() @@ -2071,7 +2071,7 @@ def from_png(filename): - filename -- a string - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_mod2_dense import from_png, to_png sage: A = random_matrix(GF(2),10,10) @@ -2115,7 +2115,7 @@ def to_png(Matrix_mod2_dense A, filename): - ``A`` - a matrix over GF(2) - ``filename`` - a string for a file in a writable position - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_mod2_dense import from_png, to_png sage: A = random_matrix(GF(2),10,10) @@ -2161,7 +2161,7 @@ def pluq(Matrix_mod2_dense A, algorithm="standard", int param=0): - param -- either k for 'mmpf' is chosen or matrix multiplication cutoff for 'standard' (default: 0) - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_mod2_dense import pluq sage: A = random_matrix(GF(2),4,4); A @@ -2224,7 +2224,7 @@ def ple(Matrix_mod2_dense A, algorithm="standard", int param=0): - param -- either k for 'mmpf' is chosen or matrix multiplication cutoff for 'standard' (default: 0) - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.matrix_mod2_dense import ple sage: A = random_matrix(GF(2),4,4); A diff --git a/src/sage/matrix/matrix_modn_dense_double.pyx b/src/sage/matrix/matrix_modn_dense_double.pyx index baef45cbe3d..15c35cbb71e 100644 --- a/src/sage/matrix/matrix_modn_dense_double.pyx +++ b/src/sage/matrix/matrix_modn_dense_double.pyx @@ -68,7 +68,7 @@ cdef class Matrix_modn_dense_double(Matrix_modn_dense_template): r""" Set the (i,j) entry of self to the int value. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(3016963), 4, 4); A [ 220081 2824836 765701 2282256] @@ -108,7 +108,7 @@ cdef class Matrix_modn_dense_double(Matrix_modn_dense_template): Assumes that `x` is in the base ring. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(3016963), 4, 4); A [ 220081 2824836 765701 2282256] @@ -154,7 +154,7 @@ cdef class Matrix_modn_dense_double(Matrix_modn_dense_template): :class:`sage.rings.finite_rings.integer_mod.IntegerMod_int64` object, depending on the modulus. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(3016963), 4, 4); A [ 220081 2824836 765701 2282256] diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi index 695dddb3a5e..eb93a49ac48 100644 --- a/src/sage/matrix/matrix_modn_dense_template.pxi +++ b/src/sage/matrix/matrix_modn_dense_template.pxi @@ -524,7 +524,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): def __hash__(self): """ - EXAMPLE:: + EXAMPLES:: sage: B = random_matrix(GF(127),3,3) sage: B.set_immutable() @@ -832,7 +832,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): def __copy__(self): """ - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(127), 100, 100) sage: copy(A) == A @@ -1316,7 +1316,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): - ``algorithm`` - 'generic', 'linbox' or 'all' (default: linbox) - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(19), 10, 10); A [ 3 1 8 10 5 16 18 9 6 1] @@ -1493,7 +1493,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): default, unless you first type ``proof.linear_algebra(False)``. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(17), 10, 10); A [ 2 14 0 15 11 10 16 2 9 4] @@ -1643,7 +1643,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): - ``var`` - a variable name - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(19), 10, 10); A [ 3 1 8 10 5 16 18 9 6 1] @@ -2032,7 +2032,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): """ Transforms self in place to its Hessenberg form. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(17), 10, 10, density=0.1); A [ 0 0 0 0 12 0 0 0 0 0] @@ -2129,7 +2129,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): ints, where the constant term of the characteristic polynomial is the 0th coefficient of the vector. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(17), 10, 10, density=0.1); A [ 0 0 0 0 12 0 0 0 0 0] @@ -2449,7 +2449,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): - ``multiple`` - finite field element - ``start_col`` - integer - EXAMPLE:: + EXAMPLES:: sage: A = matrix(GF(19), 4, 4, range(16)); A [ 0 1 2 3] @@ -2537,7 +2537,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): Add ``multiple`` times ``self[row_from]`` to ``self[row_to]`` statting in column ``start_col``. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(37), 10, 10); A [24 15 7 27 32 34 16 32 25 23] @@ -2598,7 +2598,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): Add ``multiple`` times ``self[row_from]`` to ``self[row_to]`` statting in column ``start_col``. - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(37), 10, 10); A [24 15 7 27 32 34 16 32 25 23] @@ -2918,7 +2918,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): - ``ncols`` - integer - EXAMPLE:: + EXAMPLES:: sage: A = matrix(GF(127), 4, 4, range(16)) sage: A @@ -2960,7 +2960,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): """ Test whether this matrix is zero. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(GF(7), 10, 10, range(100)) sage: A == 0 # indirect doctest diff --git a/src/sage/matrix/matrix_modn_sparse.pyx b/src/sage/matrix/matrix_modn_sparse.pyx index 0039533e203..fb1b6e07b3c 100644 --- a/src/sage/matrix/matrix_modn_sparse.pyx +++ b/src/sage/matrix/matrix_modn_sparse.pyx @@ -540,7 +540,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): It is safe to change the resulting list (unless you give the option copy=False). - EXAMPLE:: + EXAMPLES:: sage: M = Matrix(GF(7), [[0,0,0,1,0,0,0,0],[0,1,0,0,0,0,1,0]], sparse=True); M [0 0 0 1 0 0 0 0] [0 1 0 0 0 0 1 0] @@ -596,7 +596,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): """ Return the transpose of self. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(GF(127),3,3,[0,1,0,2,0,0,3,0,0],sparse=True) sage: A @@ -640,7 +640,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): - ``rows`` - list or tuple of row indices - EXAMPLE:: + EXAMPLES:: sage: M = MatrixSpace(GF(127),3,3,sparse=True) sage: A = M(range(9)); A @@ -747,7 +747,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): False) - EXAMPLE:: + EXAMPLES:: sage: A = random_matrix(GF(127),200,200,density=0.01,sparse=True) sage: r1 = A.rank(gauss=False) diff --git a/src/sage/matrix/matrix_mpolynomial_dense.pyx b/src/sage/matrix/matrix_mpolynomial_dense.pyx index 9e11e96fef6..26b923b84e0 100644 --- a/src/sage/matrix/matrix_mpolynomial_dense.pyx +++ b/src/sage/matrix/matrix_mpolynomial_dense.pyx @@ -238,7 +238,7 @@ cdef class Matrix_mpolynomial_dense(Matrix_generic_dense): The performed column swaps can be accessed via :meth:`swapped_columns`. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: C = random_matrix(R, 2, 2, terms=2) diff --git a/src/sage/matrix/matrix_rational_dense.pyx b/src/sage/matrix/matrix_rational_dense.pyx index 5abf74b3575..ae58dfad960 100644 --- a/src/sage/matrix/matrix_rational_dense.pyx +++ b/src/sage/matrix/matrix_rational_dense.pyx @@ -2684,7 +2684,7 @@ cdef class Matrix_rational_dense(Matrix_dense): For details on input parameters, see :meth:`sage.matrix.matrix_integer_dense.Matrix_integer_dense.LLL`. - EXAMPLE:: + EXAMPLES:: sage: A = Matrix(QQ, 3, 3, [1/n for n in range(1, 10)]) sage: A.LLL() diff --git a/src/sage/matrix/matrix_rational_sparse.pyx b/src/sage/matrix/matrix_rational_sparse.pyx index 85fc7a84eaa..c4c34c26ad6 100644 --- a/src/sage/matrix/matrix_rational_sparse.pyx +++ b/src/sage/matrix/matrix_rational_sparse.pyx @@ -333,7 +333,7 @@ cdef class Matrix_rational_sparse(Matrix_sparse): It is safe to change the resulting list (unless you give the option copy=False). - EXAMPLE:: + EXAMPLES:: sage: M = Matrix(QQ, [[0,0,0,1,0,0,0,0],[0,1,0,0,0,0,1,0]], sparse=True); M [0 0 0 1 0 0 0 0] diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index 68a56d4c050..a329edd52c4 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -387,7 +387,7 @@ def _copy_zero(self): Is it faster to copy a zero matrix or is it faster to create a new matrix from scratch? - EXAMPLE:: + EXAMPLES:: sage: MS = MatrixSpace(GF(2),20,20) sage: MS._copy_zero diff --git a/src/sage/matrix/matrix_sparse.pyx b/src/sage/matrix/matrix_sparse.pyx index 6147f2b8fdf..bb0ed441f8f 100644 --- a/src/sage/matrix/matrix_sparse.pyx +++ b/src/sage/matrix/matrix_sparse.pyx @@ -493,7 +493,7 @@ cdef class Matrix_sparse(matrix.Matrix): proper input. More thorough documentation is provided there. - EXAMPLE:: + EXAMPLES:: sage: A = matrix(ZZ, 2, range(6), sparse=True) sage: B = matrix(ZZ, 2, [1,0,2,0,3,0], sparse=True) diff --git a/src/sage/matrix/operation_table.py b/src/sage/matrix/operation_table.py index 16fbcddd58f..7e4c198c33a 100644 --- a/src/sage/matrix/operation_table.py +++ b/src/sage/matrix/operation_table.py @@ -559,7 +559,7 @@ def __getitem__(self, pair): This uses the table as a look-up device. If you want to use the operation, then use the operation. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.operation_table import OperationTable sage: G=DiCyclicGroup(3) @@ -648,7 +648,7 @@ def _repr_(self): r""" Returns a printable version of the operation table. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.operation_table import OperationTable sage: R=Integers(5) @@ -674,7 +674,7 @@ def set_print_symbols(self, ascii, latex): - ``latex`` - a string to represent an operation in LaTeX math mode. Note the need for double-backslashes to escape properly. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.operation_table import OperationTable sage: G=AlternatingGroup(3) @@ -776,7 +776,7 @@ def table(self): to the order of the elements in the headings of the table and the order of the output of the :meth:`list` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.operation_table import OperationTable sage: C=CyclicPermutationGroup(3) @@ -916,7 +916,7 @@ def _ascii_table(self): r""" Returns a string that is an ASCII version of the table. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.operation_table import OperationTable sage: R=Integers(5) @@ -1008,7 +1008,7 @@ def _latex_(self): Returns a `LaTeX` version of the operation table as a string, using a `LaTeX` ``array`` environment. - EXAMPLE:: + EXAMPLES:: sage: from sage.matrix.operation_table import OperationTable sage: R=Integers(2) diff --git a/src/sage/matrix/special.py b/src/sage/matrix/special.py index 33bc6a71b9e..b5d55a395ea 100644 --- a/src/sage/matrix/special.py +++ b/src/sage/matrix/special.py @@ -2058,7 +2058,7 @@ def jordan_block(eigenvalue, size, sparse=False): - ``sparse`` - (default: False) - if True, return a sparse matrix - EXAMPLE:: + EXAMPLES:: sage: jordan_block(5, 3) [5 1 0] diff --git a/src/sage/matrix/strassen.pyx b/src/sage/matrix/strassen.pyx index 55297e42880..2f0d4411d0b 100644 --- a/src/sage/matrix/strassen.pyx +++ b/src/sage/matrix/strassen.pyx @@ -262,7 +262,7 @@ def strassen_echelon(MatrixWindow A, cutoff): OUTPUT: The list of pivot columns - EXAMPLE:: + EXAMPLES:: sage: A = matrix(QQ, 7, [5, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 3, 1, 0, -1, 0, 0, -1, 0, 1, 2, -1, 1, 0, -1, 0, 1, 3, -1, 1, 0, 0, -2, 0, 2, 0, 1, 0, 0, -1, 0, 1, 0, 1]) sage: B = A.__copy__(); B._echelon_strassen(1); B diff --git a/src/sage/misc/benchmark.py b/src/sage/misc/benchmark.py index 735579ca340..f71be08d27c 100644 --- a/src/sage/misc/benchmark.py +++ b/src/sage/misc/benchmark.py @@ -21,7 +21,7 @@ def benchmark(n=-1): list -- summary of timings for each benchmark. int -- if n == -1, also return the total time - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.benchmark import * sage: _ = benchmark() diff --git a/src/sage/misc/cachefunc.pyx b/src/sage/misc/cachefunc.pyx index 77c3ae87280..5ce4098f9ed 100644 --- a/src/sage/misc/cachefunc.pyx +++ b/src/sage/misc/cachefunc.pyx @@ -996,7 +996,7 @@ cdef class CachedFunction(object): This was implemented in :trac:`11115`. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: I = P*[x,y] @@ -1691,7 +1691,7 @@ class CachedMethodPickle(object): thing that ``self`` does before disappearing is to call the :class:`CachedMethodCaller` and return the result. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: I = P*[a,b] @@ -1767,7 +1767,7 @@ cdef class CachedMethodCaller(CachedFunction): :class:`CachedMethodCallerNoArgs` for methods that do not take arguments. - EXAMPLE:: + EXAMPLES:: sage: class A: ....: @cached_method @@ -2237,7 +2237,7 @@ cdef class CachedMethodCallerNoArgs(CachedFunction): after a lengthy computation, then ``@cached_method`` should not be used. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: I = P*[a,b] @@ -2368,7 +2368,7 @@ cdef class CachedMethodCallerNoArgs(CachedFunction): """ Call the cached method without using the cache. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: I = P*[a,b] @@ -2386,7 +2386,7 @@ cdef class CachedMethodCallerNoArgs(CachedFunction): """ Call the cached method. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: I = P*[a,b] @@ -2469,7 +2469,7 @@ cdef class CachedMethodCallerNoArgs(CachedFunction): Recall that a cached method without arguments can not cache the return value ``None``. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: I = P*[x,y] diff --git a/src/sage/misc/explain_pickle.py b/src/sage/misc/explain_pickle.py index 7ad189c3ba5..449039a9e9c 100644 --- a/src/sage/misc/explain_pickle.py +++ b/src/sage/misc/explain_pickle.py @@ -3027,7 +3027,7 @@ def __repr__(self): r""" Print a TestGlobalFunnyName. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.explain_pickle import * sage: v = TestGlobalFunnyName() diff --git a/src/sage/misc/function_mangling.pyx b/src/sage/misc/function_mangling.pyx index 08934d53d88..fd0667dac60 100644 --- a/src/sage/misc/function_mangling.pyx +++ b/src/sage/misc/function_mangling.pyx @@ -201,7 +201,7 @@ cdef class ArgumentFixer: in all cases. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.function_mangling import ArgumentFixer sage: def sum3(a,b,c=3,*args,**kwargs): @@ -269,7 +269,7 @@ cdef class ArgumentFixer: The names `n_1, ..., n_m` are given in alphabetical order. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.function_mangling import ArgumentFixer sage: def do_something(a,b,c=3,*args,**kwargs): diff --git a/src/sage/misc/messaging.py b/src/sage/misc/messaging.py index 77920d7862c..05600b9f0a1 100644 --- a/src/sage/misc/messaging.py +++ b/src/sage/misc/messaging.py @@ -54,7 +54,7 @@ def pushover(message, **kwds): - ``token`` - your application's API token (default: Sage's default App token) - EXAMPLE:: + EXAMPLES:: sage: import sage.misc.messaging sage: sage.misc.messaging.pushover("Hi, how are you?", user="XXX") # not tested diff --git a/src/sage/misc/method_decorator.py b/src/sage/misc/method_decorator.py index 7404847f581..1bbba037d69 100644 --- a/src/sage/misc/method_decorator.py +++ b/src/sage/misc/method_decorator.py @@ -11,7 +11,7 @@ class MethodDecorator(SageObject): def __init__(self, f): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.method_decorator import MethodDecorator sage: class Foo: diff --git a/src/sage/misc/misc.py b/src/sage/misc/misc.py index 5508ed4abc9..b414f435a61 100644 --- a/src/sage/misc/misc.py +++ b/src/sage/misc/misc.py @@ -338,7 +338,7 @@ def __init__(self, t): Create a new CPU time object which also keeps track of subprocesses. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.misc import GlobalCputime sage: ct = GlobalCputime(0.0); ct @@ -350,7 +350,7 @@ def __init__(self, t): def __repr__(self): """ - EXAMPLE:: + EXAMPLES:: sage: cputime(subprocesses=True) # indirect doctest, output random 0.2347431 @@ -359,7 +359,7 @@ def __repr__(self): def __add__(self, other): """ - EXAMPLE:: + EXAMPLES:: sage: t = cputime(subprocesses=True) sage: P = PolynomialRing(QQ,7,'x') @@ -375,7 +375,7 @@ def __add__(self, other): def __sub__(self, other): """ - EXAMPLE:: + EXAMPLES:: sage: t = cputime(subprocesses=True) sage: P = PolynomialRing(QQ,7,'x') @@ -391,7 +391,7 @@ def __sub__(self, other): def __float__(self): """ - EXAMPLE:: + EXAMPLES:: sage: t = cputime(subprocesses=True) sage: float(t) #output somewhat random @@ -456,7 +456,7 @@ def verbose(mesg="", t=0, level=1, caller_name=None): OUTPUT: possibly prints a message to stdout; also returns cputime() - EXAMPLE:: + EXAMPLES:: sage: set_verbose(1) sage: t = cputime() diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py index 3c1ed5463d8..55c53741169 100644 --- a/src/sage/misc/object_multiplexer.py +++ b/src/sage/misc/object_multiplexer.py @@ -28,7 +28,7 @@ class MultiplexFunction: """ def __init__(self, multiplexer, name): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.object_multiplexer import Multiplex, MultiplexFunction sage: m = Multiplex(1,1/2) @@ -41,7 +41,7 @@ def __init__(self, multiplexer, name): def __call__(self, *args, **kwds): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.object_multiplexer import Multiplex, MultiplexFunction sage: m = Multiplex(1,1/2) @@ -65,7 +65,7 @@ class Multiplex: """ def __init__(self, *args): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.object_multiplexer import Multiplex sage: m = Multiplex(1,1/2) @@ -76,7 +76,7 @@ def __init__(self, *args): def __getattr__(self, name): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.object_multiplexer import Multiplex sage: m = Multiplex(1,1/2) diff --git a/src/sage/misc/package.py b/src/sage/misc/package.py index 29092a98724..30ff8e516c0 100644 --- a/src/sage/misc/package.py +++ b/src/sage/misc/package.py @@ -369,7 +369,7 @@ def standard_packages(): Run ``sage -i package_name`` from a shell to install a given package or ``sage -f package_name`` to re-install it. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.package import standard_packages sage: installed, not_installed = standard_packages() @@ -397,7 +397,7 @@ def optional_packages(): Run ``sage -i package_name`` from a shell to install a given package or ``sage -f package_name`` to re-install it. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.package import optional_packages sage: installed, not_installed = optional_packages() @@ -434,7 +434,7 @@ def experimental_packages(): Run ``sage -i package_name`` from a shell to install a given package or ``sage -f package_name`` to re-install it. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.package import experimental_packages sage: installed, not_installed = experimental_packages() diff --git a/src/sage/misc/profiler.py b/src/sage/misc/profiler.py index ffa8cd7f1c7..f7d795fa1f3 100644 --- a/src/sage/misc/profiler.py +++ b/src/sage/misc/profiler.py @@ -27,7 +27,7 @@ class Profiler: It's probably not a good idea to use this class in an inner loop :-) - EXAMPLE:: + EXAMPLES:: sage: def f(): # not tested ....: p = Profiler() # not tested diff --git a/src/sage/misc/rest_index_of_methods.py b/src/sage/misc/rest_index_of_methods.py index cad41d4f1bb..f46260b18b8 100644 --- a/src/sage/misc/rest_index_of_methods.py +++ b/src/sage/misc/rest_index_of_methods.py @@ -46,7 +46,7 @@ def gen_rest_table_index(list_of_entries, names=None, sort=True, only_local_func cells. This can cause trouble if the first sentence in the documentation of a function contains the '@' character. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.rest_index_of_methods import gen_rest_table_index sage: print(gen_rest_table_index([graphs.PetersenGraph])) @@ -211,7 +211,7 @@ def list_of_subfunctions(root, only_local_functions=True): ``dict`` associates to every function/method the name under which it appears in ``root``. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.rest_index_of_methods import list_of_subfunctions sage: l = list_of_subfunctions(Graph)[0] @@ -273,7 +273,7 @@ def gen_thematic_rest_table_index(root,additional_categories=None,only_local_fun filtered out. This can be useful to disable for making indexes of e.g. catalog modules such as :mod:`sage.coding.codes_catalog`. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.rest_index_of_methods import gen_thematic_rest_table_index, list_of_subfunctions sage: l = list_of_subfunctions(Graph)[0] @@ -305,7 +305,7 @@ def doc_index(name): - ``name`` -- a string, which will become the title of the index in which this function/method will appear. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.rest_index_of_methods import doc_index sage: @doc_index("Wouhouuuuu") diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index 73eb990f2c9..744a67aa39e 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -755,7 +755,7 @@ def _grep_first_pair_of_parentheses(s): count. If no matching pair of parentheses can be found, a ``SyntaxError`` is raised. - EXAMPLE:: + EXAMPLES:: sage: from sage.misc.sageinspect import _grep_first_pair_of_parentheses sage: code = 'def foo(a="\'):", b=4):\n return' diff --git a/src/sage/modular/abvar/constructor.py b/src/sage/modular/abvar/constructor.py index af7c0f08bfc..75db7603880 100644 --- a/src/sage/modular/abvar/constructor.py +++ b/src/sage/modular/abvar/constructor.py @@ -36,7 +36,7 @@ def _get(key): - ``key`` - hashable - EXAMPLE:: + EXAMPLES:: sage: sage.modular.abvar.constructor._saved('a', J0(37)) Abelian variety J0(37) of dimension 2 diff --git a/src/sage/modular/abvar/homology.py b/src/sage/modular/abvar/homology.py index 436e4613ac0..0dd1944a2fc 100644 --- a/src/sage/modular/abvar/homology.py +++ b/src/sage/modular/abvar/homology.py @@ -123,7 +123,7 @@ def __cmp__(self, other): r""" Compare self to other. - EXAMPLE:: + EXAMPLES:: sage: J0(37).integral_homology() == J0(41).integral_homology() False @@ -615,7 +615,7 @@ def __cmp__(self, other): r""" Compare self to other. - EXAMPLE:: + EXAMPLES:: sage: J0(37).homology().decomposition() # indirect doctest [ diff --git a/src/sage/modular/abvar/torsion_subgroup.py b/src/sage/modular/abvar/torsion_subgroup.py index e86700e68ae..52807771a2f 100644 --- a/src/sage/modular/abvar/torsion_subgroup.py +++ b/src/sage/modular/abvar/torsion_subgroup.py @@ -151,7 +151,7 @@ def __cmp__(self, other): Otherwise, the generic behavior for finite abelian variety subgroups is used. - EXAMPLE:: + EXAMPLES:: sage: G = J0(11).rational_torsion_subgroup(); H = J0(13).rational_torsion_subgroup() sage: G == G diff --git a/src/sage/modular/arithgroup/arithgroup_element.pyx b/src/sage/modular/arithgroup/arithgroup_element.pyx index 1cb789c55f9..7cae7d26067 100644 --- a/src/sage/modular/arithgroup/arithgroup_element.pyx +++ b/src/sage/modular/arithgroup/arithgroup_element.pyx @@ -103,7 +103,7 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement): r""" For unpickling objects pickled with the old ArithmeticSubgroupElement class. - EXAMPLE:: + EXAMPLES:: sage: si = unpickle_newobj(sage.modular.arithgroup.arithgroup_element.ArithmeticSubgroupElement, ()) sage: x = matrix(ZZ,2,[1,1,0,1]) @@ -400,7 +400,7 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement): r""" Fetch entries by direct indexing. - EXAMPLE:: + EXAMPLES:: sage: SL2Z([3,2,1,1])[0,0] 3 """ @@ -410,7 +410,7 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement): r""" Return a hash value. - EXAMPLE:: + EXAMPLES:: sage: hash(SL2Z.0) -4 @@ -421,7 +421,7 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement): r""" Used for pickling. - EXAMPLE:: + EXAMPLES:: sage: (SL2Z.1).__reduce__() (Modular Group SL(2,Z), ( diff --git a/src/sage/modular/arithgroup/arithgroup_generic.py b/src/sage/modular/arithgroup/arithgroup_generic.py index 62e02473dd3..be4a56bff24 100644 --- a/src/sage/modular/arithgroup/arithgroup_generic.py +++ b/src/sage/modular/arithgroup/arithgroup_generic.py @@ -33,7 +33,7 @@ def is_ArithmeticSubgroup(x): r""" Return True if x is of type ArithmeticSubgroup. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.arithgroup.all import is_ArithmeticSubgroup sage: is_ArithmeticSubgroup(GL(2, GF(7))) @@ -59,7 +59,7 @@ def __init__(self): r""" Standard init routine. - EXAMPLE:: + EXAMPLES:: sage: G = Gamma1(7) sage: G.category() # indirect doctest @@ -180,7 +180,7 @@ def _contains_sl2(self, a,b,c,d): determinant 1, is an element of self. This must be overridden by all subclasses. - EXAMPLE:: + EXAMPLES:: sage: G = sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup() sage: 1 in G @@ -210,7 +210,7 @@ def is_parent_of(self, x): Check whether this group is a valid parent for the element x. Required by Sage's testing framework. - EXAMPLE:: + EXAMPLES:: sage: Gamma(3).is_parent_of(ZZ(1)) False @@ -622,7 +622,7 @@ def to_even_subgroup(self): r""" Return the smallest even subgroup of `SL(2, \ZZ)` containing self. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup().to_even_subgroup() Traceback (most recent call last): @@ -756,7 +756,7 @@ def are_equivalent(self, x, y, trans = False): If trans = False, returns True or False. If trans = True, then return either False or an element of self mapping x onto y. - EXAMPLE:: + EXAMPLES:: sage: Gamma0(7).are_equivalent(Cusp(1/3), Cusp(0), trans=True) [ 3 -1] @@ -882,7 +882,7 @@ def generalised_level(self): generalised level. See the paper by Kiming, Schuett and Verrill for more examples. - EXAMPLE:: + EXAMPLES:: sage: Gamma0(18).generalised_level() 18 @@ -910,7 +910,7 @@ def projective_index(self): This is equal to the degree of the natural map from the modular curve of self to the `j`-line. - EXAMPLE:: + EXAMPLES:: sage: Gamma0(5).projective_index() 6 @@ -927,7 +927,7 @@ def is_congruence(self): r""" Return True if self is a congruence subgroup. - EXAMPLE:: + EXAMPLES:: sage: Gamma0(5).is_congruence() True @@ -969,7 +969,7 @@ def farey_symbol(self): :mod:`~sage.modular.arithgroup.farey_symbol` module for more information. - EXAMPLE:: + EXAMPLES:: sage: Gamma1(4).farey_symbol() FareySymbol(Congruence Subgroup Gamma1(4)) @@ -996,7 +996,7 @@ def generators(self, algorithm="farey"): slow for general subgroups, and the list of generators will be far from minimal (indeed it may contain repetitions). - EXAMPLE:: + EXAMPLES:: sage: Gamma(2).generators() [ @@ -1125,7 +1125,7 @@ def dimension_modular_forms(self, k=2): than the degree of the canonical divisor). Otherwise a NotImplementedError is raised. - EXAMPLE:: + EXAMPLES:: sage: Gamma1(31).dimension_modular_forms(2) 55 @@ -1181,7 +1181,7 @@ def dimension_cusp_forms(self, k=2): the degree of the canonical divisor). Otherwise a NotImplementedError is raised. - EXAMPLE:: + EXAMPLES:: sage: Gamma1(31).dimension_cusp_forms(2) 26 diff --git a/src/sage/modular/arithgroup/arithgroup_perm.py b/src/sage/modular/arithgroup/arithgroup_perm.py index 9cc7ba023f6..17e9d7cd85c 100644 --- a/src/sage/modular/arithgroup/arithgroup_perm.py +++ b/src/sage/modular/arithgroup/arithgroup_perm.py @@ -648,7 +648,7 @@ def perm_group(self): (parabolic element) and `r` (parabolic element) on right cosets (the action is on the right). - EXAMPLE:: + EXAMPLES:: sage: import sage.modular.arithgroup.arithgroup_perm as ap sage: ap.HsuExample10().perm_group() @@ -1073,7 +1073,7 @@ def permutation_action(self, x): Given an element ``x`` of `{\rm SL}_2(\ZZ)`, compute the permutation of the cosets of self given by right multiplication by ``x``. - EXAMPLE:: + EXAMPLES:: sage: import sage.modular.arithgroup.arithgroup_perm as ap sage: ap.HsuExample10().permutation_action(SL2Z([32, -21, -67, 44])) @@ -1283,7 +1283,7 @@ def congruence_closure(self): If you just want to know if the subgroup is congruence or not, it is *much* faster to use :meth:`~is_congruence`. - EXAMPLE:: + EXAMPLES:: sage: Gamma1(3).as_permutation_group().congruence_closure() Congruence subgroup of SL(2,Z) of level 3, preimage of: @@ -2404,7 +2404,7 @@ def to_even_subgroup(self, relabel=True): Return the subgroup generated by self and ``-Id``. Since self is even, this is just self. Provided for compatibility. - EXAMPLE:: + EXAMPLES:: sage: G = Gamma0(4).as_permutation_group() sage: H = G.to_even_subgroup() @@ -2602,7 +2602,7 @@ def HsuExample10(): r""" An example of an index 10 arithmetic subgroup studied by Tim Hsu. - EXAMPLE:: + EXAMPLES:: sage: import sage.modular.arithgroup.arithgroup_perm as ap sage: ap.HsuExample10() @@ -2621,7 +2621,7 @@ def HsuExample18(): r""" An example of an index 18 arithmetic subgroup studied by Tim Hsu. - EXAMPLE:: + EXAMPLES:: sage: import sage.modular.arithgroup.arithgroup_perm as ap sage: ap.HsuExample18() diff --git a/src/sage/modular/arithgroup/congroup_gamma.py b/src/sage/modular/arithgroup/congroup_gamma.py index 3fea37547d3..f5b07925a31 100644 --- a/src/sage/modular/arithgroup/congroup_gamma.py +++ b/src/sage/modular/arithgroup/congroup_gamma.py @@ -177,7 +177,7 @@ def nirregcusps(self): r""" Return the number of irregular cusps of self. For principal congruence subgroups this is always 0. - EXAMPLE:: + EXAMPLES:: sage: Gamma(17).nirregcusps() 0 @@ -189,7 +189,7 @@ def _find_cusps(self): Calculate the reduced representatives of the equivalence classes of cusps for this group. Adapted from code by Ron Evans. - EXAMPLE:: + EXAMPLES:: sage: Gamma(8).cusps() # indirect doctest [0, 1/4, 1/3, 3/8, 1/2, 2/3, 3/4, 1, 4/3, 3/2, 5/3, 2, 7/3, 5/2, 8/3, 3, 7/2, 11/3, 4, 14/3, 5, 6, 7, Infinity] @@ -252,7 +252,7 @@ def are_equivalent(self, x, y, trans=False): ALGORITHM: The cusps `u_1 / v_1` and `u_2 / v_2` are equivalent modulo `\Gamma(N)` if and only if `(u_1, v_1) = \pm (u_2, v_2) \bmod N`. - EXAMPLE:: + EXAMPLES:: sage: Gamma(7).are_equivalent(Cusp(2/3), Cusp(5/4)) True @@ -271,7 +271,7 @@ def nu3(self): subgroup. Since this subgroup is `\Gamma(N)` for `N \ge 2`, there are no such points, so we return 0. - EXAMPLE:: + EXAMPLES:: sage: Gamma(89).nu3() 0 @@ -286,7 +286,7 @@ def image_mod_n(self): Return the image of this group modulo `N`, as a subgroup of `SL(2, \ZZ / N\ZZ)`. This is just the trivial subgroup. - EXAMPLE:: + EXAMPLES:: sage: Gamma(3).image_mod_n() Matrix group over Ring of integers modulo 3 with 1 generators ( @@ -324,7 +324,7 @@ def _lift_pair(U,V,N): reasonably gracefully if ``(U, V, N)`` are not coprime, but only after wasting quite a lot of cycles! - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.arithgroup.congroup_gamma import _lift_pair sage: _lift_pair(2,4,7) diff --git a/src/sage/modular/arithgroup/congroup_gamma0.py b/src/sage/modular/arithgroup/congroup_gamma0.py index d9fa1bfb9f6..44fa2165c0d 100644 --- a/src/sage/modular/arithgroup/congroup_gamma0.py +++ b/src/sage/modular/arithgroup/congroup_gamma0.py @@ -343,7 +343,7 @@ def generators(self, algorithm="farey"): based on Todd-Coxeter enumeration will be used. This tends to return far larger sets of generators. - EXAMPLE:: + EXAMPLES:: sage: Gamma0(3).generators() [ @@ -494,7 +494,7 @@ def nu2(self): 0 if `N` is divisible by 4 or any prime congruent to -1 mod 4, and otherwise `2^d` where d is the number of odd primes dividing `N`. - EXAMPLE:: + EXAMPLES:: sage: Gamma0(2).nu2() 1 @@ -519,7 +519,7 @@ def nu3(self): 0 if `N` is divisible by 9 or any prime congruent to -1 mod 3, and otherwise `2^d` where d is the number of primes other than 3 dividing `N`. - EXAMPLE:: + EXAMPLES:: sage: Gamma0(2).nu3() 0 diff --git a/src/sage/modular/arithgroup/congroup_gamma1.py b/src/sage/modular/arithgroup/congroup_gamma1.py index f545a4e852e..b666e15d33e 100644 --- a/src/sage/modular/arithgroup/congroup_gamma1.py +++ b/src/sage/modular/arithgroup/congroup_gamma1.py @@ -207,7 +207,7 @@ def generators(self, algorithm="farey"): based on Todd-Coxeter enumeration will be used. This tends to return far larger sets of generators. - EXAMPLE:: + EXAMPLES:: sage: Gamma1(3).generators() [ @@ -262,7 +262,7 @@ def nu2(self): Calculate the number of orbits of elliptic points of order 2 for this subgroup `\Gamma_1(N)`. This is known to be 0 if N > 2. - EXAMPLE:: + EXAMPLES:: sage: Gamma1(2).nu2() 1 @@ -280,7 +280,7 @@ def nu3(self): Calculate the number of orbits of elliptic points of order 3 for this subgroup `\Gamma_1(N)`. This is known to be 0 if N > 3. - EXAMPLE:: + EXAMPLES:: sage: Gamma1(2).nu3() 0 @@ -319,7 +319,7 @@ def index(self): N^2 \prod_{\substack{p \mid N \\ \text{$p$ prime}}} \left( 1 - \frac{1}{p^2}\right). - EXAMPLE:: + EXAMPLES:: sage: Gamma1(180).index() 20736 diff --git a/src/sage/modular/arithgroup/congroup_gammaH.py b/src/sage/modular/arithgroup/congroup_gammaH.py index f96ac36ada5..ba5b0b54f15 100644 --- a/src/sage/modular/arithgroup/congroup_gammaH.py +++ b/src/sage/modular/arithgroup/congroup_gammaH.py @@ -290,7 +290,7 @@ def to_even_subgroup(self): r""" Return the smallest even subgroup of `SL(2, \ZZ)` containing self. - EXAMPLE:: + EXAMPLES:: sage: GammaH(11, [4]).to_even_subgroup() Congruence Subgroup Gamma0(11) @@ -448,7 +448,7 @@ def generators(self, algorithm="farey"): based on Todd-Coxeter enumeration will be used. This tends to return far larger sets of generators. - EXAMPLE:: + EXAMPLES:: sage: GammaH(7, [2]).generators() [ @@ -950,7 +950,7 @@ def gamma0_coset_reps(self): Return a set of coset representatives for self \\ Gamma0(N), where N is the level of self. - EXAMPLE:: + EXAMPLES:: sage: GammaH(108, [1,-1]).gamma0_coset_reps() [ @@ -1039,7 +1039,7 @@ def index(self): r""" Return the index of self in SL2Z. - EXAMPLE:: + EXAMPLES:: sage: [G.index() for G in Gamma0(40).gamma_h_subgroups()] [72, 144, 144, 144, 144, 288, 288, 288, 288, 144, 288, 288, 576, 576, 144, 288, 288, 576, 576, 144, 288, 288, 576, 576, 288, 576, 1152] @@ -1052,7 +1052,7 @@ def nu2(self): Return the number of orbits of elliptic points of order 2 for this group. - EXAMPLE:: + EXAMPLES:: sage: [H.nu2() for n in [1..10] for H in Gamma0(n).gamma_h_subgroups()] [1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0] @@ -1078,7 +1078,7 @@ def nu3(self): Return the number of orbits of elliptic points of order 3 for this group. - EXAMPLE:: + EXAMPLES:: sage: [H.nu3() for n in [1..10] for H in Gamma0(n).gamma_h_subgroups()] [1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] @@ -1105,7 +1105,7 @@ def ncusps(self): r""" Return the number of orbits of cusps (regular or otherwise) for this subgroup. - EXAMPLE:: + EXAMPLES:: sage: GammaH(33,[2]).ncusps() 8 @@ -1220,7 +1220,7 @@ def image_mod_n(self): r""" Return the image of this group in `SL(2, \ZZ / N\ZZ)`. - EXAMPLE:: + EXAMPLES:: sage: Gamma0(3).image_mod_n() Matrix group over Ring of integers modulo 3 with 2 generators ( @@ -1248,7 +1248,7 @@ def _list_subgroup(N, gens): the elements of the subgroup of `(\ZZ / N\ZZ)^\times` generated by the elements of ``gens``. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.arithgroup.congroup_gammaH._list_subgroup(11, [3]) [1, 3, 4, 5, 9] @@ -1271,7 +1271,7 @@ def _GammaH_coset_helper(N, H): r""" Return a list of coset representatives for H in (Z / NZ)^*. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.arithgroup.congroup_gammaH import _GammaH_coset_helper sage: _GammaH_coset_helper(108, [1, 107]) diff --git a/src/sage/modular/arithgroup/congroup_generic.py b/src/sage/modular/arithgroup/congroup_generic.py index d0b56fd94c4..5439bab7f9e 100644 --- a/src/sage/modular/arithgroup/congroup_generic.py +++ b/src/sage/modular/arithgroup/congroup_generic.py @@ -161,7 +161,7 @@ def _an_element_(self): r""" Return an element of self (mainly for use by the test suite). - EXAMPLE:: + EXAMPLES:: sage: Gamma(3).an_element() # indirect doctest [-2 -3] @@ -174,7 +174,7 @@ def is_congruence(self): r""" Return True, since this is a congruence subgroup. - EXAMPLE:: + EXAMPLES:: sage: Gamma0(7).is_congruence() True @@ -201,7 +201,7 @@ def level(self): def __cmp__(self, other): r""" - EXAMPLE:: + EXAMPLES:: sage: CongruenceSubgroup(3,[ [1,1,0,1] ]) == Gamma1(3) True @@ -279,7 +279,7 @@ def __reduce__(self): r""" Data defining self (for pickling). - EXAMPLE:: + EXAMPLES:: sage: G = CongruenceSubgroup(5, [[0,-1,1,0]]) sage: G.__reduce__() @@ -295,7 +295,7 @@ def _contains_sl2(self, a,b,c,d): r""" Test whether ``[a,b;c,d]`` is an element of self. - EXAMPLE:: + EXAMPLES:: sage: G = MatrixGroup([matrix(Zmod(2), 2, [1,1,1,0])]) sage: H = sage.modular.arithgroup.congroup_generic.CongruenceSubgroupFromGroup(G) @@ -330,7 +330,7 @@ def to_even_subgroup(self): r""" Return the smallest even subgroup of `SL(2, \ZZ)` containing self. - EXAMPLE:: + EXAMPLES:: sage: G = Gamma(3) sage: G.to_even_subgroup() @@ -351,7 +351,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.arithgroup.congroup_generic.CongruenceSubgroupFromGroup(MatrixGroup([matrix(Zmod(2), 2, [1,1,1,0])]))._repr_() 'Congruence subgroup of SL(2,Z) of level 2, preimage of:\n Matrix group over Ring of integers modulo 2 with 1 generators (\n[1 1]\n[1 0]\n)' @@ -364,7 +364,7 @@ def index(self): the index in `SL(2, \ZZ / N\ZZ)` of the image of this group modulo `\Gamma(N)`. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.arithgroup.congroup_generic.CongruenceSubgroupFromGroup(MatrixGroup([matrix(Zmod(2), 2, [1,1,1,0])])).index() 2 @@ -375,7 +375,7 @@ def image_mod_n(self): r""" Return the subgroup of `SL(2, \ZZ / N\ZZ)` of which this is the preimage, where `N` is the level of self. - EXAMPLE:: + EXAMPLES:: sage: G = MatrixGroup([matrix(Zmod(2), 2, [1,1,1,0])]) sage: H = sage.modular.arithgroup.congroup_generic.CongruenceSubgroupFromGroup(G); H.image_mod_n() @@ -401,7 +401,7 @@ def image_mod_n(self): r""" Raise an error: all derived subclasses should override this function. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.arithgroup.congroup_generic.CongruenceSubgroup(5).image_mod_n() Traceback (most recent call last): @@ -414,7 +414,7 @@ def __init__(self,*args, **kwds): r""" Bypass the init function of the CongruenceSubgroupFromGroup class. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.arithgroup.congroup_generic.CongruenceSubgroup(5) # indirect doctest Generic congruence subgroup of level 5 @@ -535,7 +535,7 @@ def _minimize_level(G): returns an integer `N`, representing the trivial subgroup of `SL(2, \ZZ / N\ZZ)`. - EXAMPLE:: + EXAMPLES:: sage: M = MatrixSpace(Zmod(9), 2, 2) sage: G = MatrixGroup([M(x) for x in [[1,1,0,1],[1,3,0,1],[1,0,3,1],[4,0,0,7]]]); G diff --git a/src/sage/modular/arithgroup/congroup_sl2z.py b/src/sage/modular/arithgroup/congroup_sl2z.py index 94b8806a108..a4ed774813b 100644 --- a/src/sage/modular/arithgroup/congroup_sl2z.py +++ b/src/sage/modular/arithgroup/congroup_sl2z.py @@ -97,7 +97,7 @@ def _element_constructor_(self, x, check=True): coerced into a 2x2 integer matrix. If check=True (the default), check that x really has determinant 1. - EXAMPLE:: + EXAMPLES:: sage: SL2Z([1,0,0,1]) # indirect doctest [1 0] @@ -117,7 +117,7 @@ def _contains_sl2(self,a,b,c,d): r""" Test whether [a,b,c,d] is an element of self, where a,b,c,d are integers with `ad-bc=1`. In other words, always return True. - EXAMPLE:: + EXAMPLES:: sage: [8,7,9,8] in SL2Z # indirect doctest True diff --git a/src/sage/modular/btquotients/btquotient.py b/src/sage/modular/btquotients/btquotient.py index 024b1889d6b..35008eda095 100644 --- a/src/sage/modular/btquotients/btquotient.py +++ b/src/sage/modular/btquotients/btquotient.py @@ -3771,7 +3771,7 @@ def harmonic_cocycles(self, k, prec=None, basis_matrix=None, base_field=None): OUTPUT: A space of harmonic cocycles - EXAMPLE:: + EXAMPLES:: sage: X = BruhatTitsQuotient(31,7) sage: H = X.harmonic_cocycles(2,prec=10) diff --git a/src/sage/modular/buzzard.py b/src/sage/modular/buzzard.py index 5624860de9e..eeba4064bd0 100644 --- a/src/sage/modular/buzzard.py +++ b/src/sage/modular/buzzard.py @@ -30,7 +30,7 @@ def gp(): r""" Return a copy of the GP interpreter with the appropriate files loaded. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.buzzard.gp() PARI/GP interpreter diff --git a/src/sage/modular/cusps.py b/src/sage/modular/cusps.py index 14b7e0e9691..df2bcc241a0 100644 --- a/src/sage/modular/cusps.py +++ b/src/sage/modular/cusps.py @@ -163,7 +163,7 @@ def zero(self): The existence of this method is assumed by some parts of Sage's coercion model. - EXAMPLE:: + EXAMPLES:: sage: Cusps.zero() 0 diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py index 74568fbb911..6edd3c5d15e 100644 --- a/src/sage/modular/cusps_nf.py +++ b/src/sage/modular/cusps_nf.py @@ -362,7 +362,7 @@ def zero(self): It is not intended that the returned cusp is an additive neutral element. - EXAMPLE:: + EXAMPLES:: sage: k. = NumberField(x^2 + 5) sage: kCusps = NFCusps(k) diff --git a/src/sage/modular/dirichlet.py b/src/sage/modular/dirichlet.py index 30a5d0d12d1..81f1f7653a9 100644 --- a/src/sage/modular/dirichlet.py +++ b/src/sage/modular/dirichlet.py @@ -88,7 +88,7 @@ def trivial_character(N, base_ring=rings.RationalField()): Return the trivial character of the given modulus, with values in the given base ring. - EXAMPLE:: + EXAMPLES:: sage: t = trivial_character(7) sage: [t(x) for x in [0..20]] @@ -347,7 +347,7 @@ def change_ring(self, R): base ring of ``self``, or a ring homomorphism with the base ring of ``self`` as its domain - EXAMPLE:: + EXAMPLES:: sage: e = DirichletGroup(7, QQ).0 sage: f = e.change_ring(QuadraticField(3, 'a')) @@ -470,7 +470,7 @@ def __copy__(self): """ Return a (shallow) copy of this Dirichlet character. - EXAMPLE:: + EXAMPLES:: sage: G. = DirichletGroup(11) sage: b = copy(a) @@ -1512,7 +1512,7 @@ def level(self): """ Synonym for modulus. - EXAMPLE:: + EXAMPLES:: sage: e = DirichletGroup(100, QQ).0 sage: e.level() diff --git a/src/sage/modular/etaproducts.py b/src/sage/modular/etaproducts.py index d348fa32fc2..15025a39d15 100644 --- a/src/sage/modular/etaproducts.py +++ b/src/sage/modular/etaproducts.py @@ -101,7 +101,7 @@ def __reduce__(self): r""" Return the data used to construct self. Used for pickling. - EXAMPLE:: + EXAMPLES:: sage: EtaGroup(13).__reduce__() (, (13,)) @@ -114,7 +114,7 @@ def __cmp__(self, other): type; otherwise compare by level. EtaGroups of the same level compare as identical. - EXAMPLE:: + EXAMPLES:: sage: EtaGroup(12) == 12 False @@ -132,7 +132,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: EtaGroup(12)._repr_() 'Group of eta products on X_0(12)' @@ -143,7 +143,7 @@ def one(self): r""" Return the identity element of ``self``. - EXAMPLE:: + EXAMPLES:: sage: EtaGroup(12).one() Eta product of level 12 : 1 @@ -156,7 +156,7 @@ def __call__(self, dict): exponents from the given dictionary. See the docstring for the EtaProduct() factory function for how dict is used. - EXAMPLE:: + EXAMPLES:: sage: EtaGroup(2).__call__({1:24, 2:-24}) Eta product of level 2 : (eta_1)^24 (eta_2)^-24 @@ -185,7 +185,7 @@ def basis(self, reduce=True): whether or not to apply LLL-reduction to the calculated basis - EXAMPLE:: + EXAMPLES:: sage: EtaGroup(5).basis() [Eta product of level 5 : (eta_1)^6 (eta_5)^-6] @@ -359,7 +359,7 @@ def __init__(self, parent, rdict): Create an eta product object. Usually called implicitly via EtaGroup_class.__call__ or the EtaProduct factory function. - EXAMPLE:: + EXAMPLES:: sage: EtaGroupElement(EtaGroup(8), {1:24, 2:-24}) Eta product of level 8 : (eta_1)^24 (eta_2)^-24 @@ -725,7 +725,7 @@ def __init__(self, N, width, label = None): with `\mathrm{lcm}(r,d) = N`. The cusp doesn't store zeta, so we store an arbitrary label instead. - EXAMPLE:: + EXAMPLES:: sage: CuspFamily(8, 4) (c_{4}) @@ -774,7 +774,7 @@ def sage_cusp(self): Return the corresponding element of `\mathbb{P}^1(\QQ)`. - EXAMPLE:: + EXAMPLES:: sage: CuspFamily(10, 1).sage_cusp() # not implemented Infinity @@ -785,7 +785,7 @@ def _repr_(self): r""" Return a string representation of self. - EXAMPLE:: + EXAMPLES:: sage: CuspFamily(16, 4, "1")._repr_() '(c_{4,1})' @@ -962,7 +962,7 @@ def _eta_relations_helper(eta1, eta2, degree, qexp_terms, labels, verbose): as then 1 will be in the ideal. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.etaproducts import _eta_relations_helper sage: r,s = EtaGroup(4).basis() diff --git a/src/sage/modular/hecke/algebra.py b/src/sage/modular/hecke/algebra.py index 0251b2cabff..ee4bae7e3c4 100644 --- a/src/sage/modular/hecke/algebra.py +++ b/src/sage/modular/hecke/algebra.py @@ -198,7 +198,7 @@ def __init__(self, M): - ``M`` - a Hecke module - EXAMPLE:: + EXAMPLES:: sage: CuspForms(1, 12).hecke_algebra() # indirect doctest Full Hecke algebra acting on Cuspidal subspace of dimension 1 of Modular Forms space of dimension 2 for Modular Group SL(2,Z) of weight 12 over Rational Field @@ -213,7 +213,7 @@ def _an_element_impl(self): r""" Return an element of this algebra. Used by the coercion machinery. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(1, 12).hecke_algebra().an_element() # indirect doctest Hecke operator T_2 on Cuspidal subspace of dimension 1 of Modular Forms space of dimension 2 for Modular Group SL(2,Z) of weight 12 over Rational Field @@ -335,7 +335,7 @@ def _coerce_impl(self, x): anemic; and elements that coerce into the base ring of self. Bare matrices do *not* coerce implicitly into self. - EXAMPLE:: + EXAMPLES:: sage: C = CuspForms(3, 12) sage: A = C.anemic_hecke_algebra() @@ -418,7 +418,7 @@ def level(self): Return the level of this Hecke algebra, which is (by definition) the level of the Hecke module on which it acts. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(37).hecke_algebra().level() 37 @@ -442,7 +442,7 @@ def rank(self): The rank of this Hecke algebra as a module over its base ring. Not implemented at present. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(Gamma1(3), 3).hecke_algebra().rank() Traceback (most recent call last): @@ -456,7 +456,7 @@ def basis(self): Return a basis for this Hecke algebra as a free module over its base ring. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(Gamma1(3), 3).hecke_algebra().basis() [Hecke operator on Modular Symbols space of dimension 2 for Gamma_1(3) of weight 3 with sign 0 and over Rational Field defined by: @@ -509,7 +509,7 @@ def discriminant(self): *Conjectures about discriminants of Hecke algebras of prime level*, Springer LNCS 3076. - EXAMPLE:: + EXAMPLES:: sage: BrandtModule(3, 4).hecke_algebra().discriminant() 1 @@ -595,7 +595,7 @@ def diamond_bracket_matrix(self, d): r""" Return the matrix of the diamond bracket operator `\langle d \rangle`. - EXAMPLE:: + EXAMPLES:: sage: T = ModularSymbols(Gamma1(7), 4).hecke_algebra() sage: T.diamond_bracket_matrix(3) @@ -619,7 +619,7 @@ def diamond_bracket_operator(self, d): r""" Return the diamond bracket operator `\langle d \rangle`. - EXAMPLE:: + EXAMPLES:: sage: T = ModularSymbols(Gamma1(7), 4).hecke_algebra() sage: T.diamond_bracket_operator(3) @@ -645,7 +645,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: ModularForms(37).hecke_algebra()._repr_() 'Full Hecke algebra acting on Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(37) of weight 2 over Rational Field' @@ -687,7 +687,7 @@ def anemic_subalgebra(self): The subalgebra of self generated by the Hecke operators of index coprime to the level. - EXAMPLE:: + EXAMPLES:: sage: H = CuspForms(3, 12).hecke_algebra() sage: H.anemic_subalgebra() @@ -702,7 +702,7 @@ class HeckeAlgebra_anemic(HeckeAlgebra_base): """ def _repr_(self): r""" - EXAMPLE:: + EXAMPLES:: sage: H = CuspForms(3, 12).anemic_hecke_algebra()._repr_() """ diff --git a/src/sage/modular/hecke/ambient_module.py b/src/sage/modular/hecke/ambient_module.py index d24d1d22b1c..36fda4f6727 100644 --- a/src/sage/modular/hecke/ambient_module.py +++ b/src/sage/modular/hecke/ambient_module.py @@ -122,7 +122,7 @@ def _repr_(self): r""" String representation of self. Should be overridden by derived classes. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.hecke.ambient_module.AmbientHeckeModule(QQ, 3, 2, 4)._repr_() 'Generic ambient Hecke module of rank 3, level 2 and weight 4 over Rational Field' @@ -135,7 +135,7 @@ def _degeneracy_raising_matrix(self, codomain): Matrix of the degeneracy map (with t = 1) from self to codomain, whose level should be a multiple of the level of self. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.hecke.ambient_module.AmbientHeckeModule(QQ, 3, 2, 4)._degeneracy_raising_matrix(4) Traceback (most recent call last): @@ -148,7 +148,7 @@ def _degeneracy_lowering_matrix(self, codomain, t): """ Matrix of the degeneracy map of index t from self to codomain, whose level should be a divisor of the level of self. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.hecke.ambient_module.AmbientHeckeModule(QQ, 3, 2, 4)._degeneracy_lowering_matrix(2, 2) Traceback (most recent call last): @@ -162,7 +162,7 @@ def _hecke_image_of_ith_basis_element(self, n, i): Return the image under the Hecke operator T_n of the i-th basis element. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.hecke.ambient_module.AmbientHeckeModule(QQ, 3, 2, 4)._hecke_image_of_ith_basis_element(4, 2) Traceback (most recent call last): @@ -176,7 +176,7 @@ def _set_dual_free_module(self, V): Store the embedded dual module of this module. Since this module is an ambient module, this is not necessary. - EXAMPLE:: + EXAMPLES:: sage: ModularForms(11, 2)._set_dual_free_module(None) """ @@ -188,7 +188,7 @@ def ambient_hecke_module(self): Return the ambient space that contains this ambient space. This is, of course, just this space again. - EXAMPLE:: + EXAMPLES:: sage: M = ModularForms(11, 4); M.ambient_hecke_module() is M True @@ -224,7 +224,7 @@ def decomposition_matrix(self): next an echelonized basis for `D_1`, the next for `D_2`, etc. - EXAMPLE:: + EXAMPLES:: sage: S = ModularSymbols(37, 2) sage: S.decomposition_matrix() @@ -250,7 +250,7 @@ def decomposition_matrix_inverse(self): Returns the inverse of the matrix returned by decomposition_matrix(). - EXAMPLE:: + EXAMPLES:: sage: S = ModularSymbols(37, 2) sage: t = S.decomposition_matrix_inverse(); t @@ -436,7 +436,7 @@ def dual_free_module(self): module of the ambient space. As this space is ambient anyway, this just returns self.free_module(). - EXAMPLE:: + EXAMPLES:: sage: M = ModularForms(2,8); M.dual_free_module() Vector space of dimension 3 over Rational Field @@ -485,7 +485,7 @@ def free_module(self): Return the free module underlying this ambient Hecke module (the forgetful functor from Hecke modules to modules over the base ring) - EXAMPLE:: + EXAMPLES:: sage: ModularForms(59, 2).free_module() Vector space of dimension 6 over Rational Field @@ -512,7 +512,7 @@ def hecke_bound(self): TODO: Get rid of this dreadful bit of code. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(17, 4).hecke_bound() 15 @@ -534,7 +534,7 @@ def hecke_module_of_level(self, level): raises NotImplementedError, and should be overridden in derived classes. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.hecke.ambient_module.AmbientHeckeModule.hecke_module_of_level(ModularForms(2, 8),6) Traceback (most recent call last): @@ -636,7 +636,7 @@ def is_full_hecke_module(self, compute=True): all Hecke operators, even those that divide the level. This is always true for ambient Hecke modules, so return True. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(11, 4).is_full_hecke_module() True @@ -647,7 +647,7 @@ def is_new(self, p=None): r""" Return True if this module is entirely new. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(11, 4).is_new() False @@ -666,7 +666,7 @@ def is_old(self, p=None): r""" Return True if this module is entirely old. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(22).is_old() True @@ -686,7 +686,7 @@ def is_submodule(self, V): Returns True if and only if self is a submodule of V. Since this is an ambient space, this returns True if and only if V is equal to self. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(1, 4).is_submodule(ModularSymbols(11,4)) False @@ -705,7 +705,7 @@ def linear_combination_of_basis(self, v): construct the appropriate linear combination of the basis vectors of self. - EXAMPLE:: + EXAMPLES:: sage: ModularForms(3, 12).linear_combination_of_basis([1,0,0,0,1]) 2*q + 2049*q^2 + 177147*q^3 + 4196177*q^4 + 48830556*q^5 + O(q^6) @@ -922,7 +922,7 @@ def submodule(self, M, Mdual=None, check=True): Return the Hecke submodule of self generated by M, which may be a submodule of the free module of self, or a list of elements of self. - EXAMPLE:: + EXAMPLES:: sage: M = ModularForms(37, 2) sage: A = M.submodule([M.newforms()[0].element(), M.newforms()[1].element()]); A @@ -946,7 +946,7 @@ def _submodule_class(self): The class of submodules of this module. This is a separate method so it can be overridden in derived classes. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.hecke.ambient_module.AmbientHeckeModule._submodule_class(ModularForms(1, 24)) @@ -971,7 +971,7 @@ def submodule_from_nonembedded_module(self, V, Vdual=None, check=True): OUTPUT: Hecke submodule of self - EXAMPLE:: + EXAMPLES:: sage: V = QQ^8 sage: ModularForms(24, 2).submodule_from_nonembedded_module(V.submodule([0])) diff --git a/src/sage/modular/hecke/element.py b/src/sage/modular/hecke/element.py index 1c02c7eb425..790887f4895 100644 --- a/src/sage/modular/hecke/element.py +++ b/src/sage/modular/hecke/element.py @@ -254,7 +254,7 @@ def is_new(self, p=None): Return True if this element is p-new. If p is None, return True if the element is new. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(22, 2).0.is_new(2) False @@ -270,7 +270,7 @@ def is_old(self, p=None): Return True if this element is p-old. If p is None, return True if the element is old. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(22, 2).0.is_old(11) False diff --git a/src/sage/modular/hecke/hecke_operator.py b/src/sage/modular/hecke/hecke_operator.py index 5bf7bf0ecbf..3b61b41bc9a 100644 --- a/src/sage/modular/hecke/hecke_operator.py +++ b/src/sage/modular/hecke/hecke_operator.py @@ -82,7 +82,7 @@ def domain(self): The domain of this operator. This is the Hecke module associated to the parent Hecke algebra. - EXAMPLE:: + EXAMPLES:: sage: R = ModularForms(Gamma0(7), 4).hecke_algebra() sage: sage.modular.hecke.hecke_operator.HeckeAlgebraElement(R).domain() @@ -96,7 +96,7 @@ def codomain(self): The codomain of this operator. This is the Hecke module associated to the parent Hecke algebra. - EXAMPLE:: + EXAMPLES:: sage: R = ModularForms(Gamma0(7), 4).hecke_algebra() sage: sage.modular.hecke.hecke_operator.HeckeAlgebraElement(R).codomain() @@ -394,7 +394,7 @@ def trace(self): def __getitem__(self, ij): """ - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(1,12) sage: T = M.hecke_operator(2).matrix_form() @@ -488,7 +488,7 @@ def _latex_(self): r""" Latex representation of self (just prints the matrix) - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(1,12) sage: M.hecke_operator(2).matrix_form()._latex_() @@ -539,7 +539,7 @@ def __init__(self, parent, d): r""" Standard init function. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(Gamma1(5),6) sage: d = M.diamond_bracket_operator(2); d # indirect doctest @@ -566,7 +566,7 @@ def __init__(self, parent, d): def _repr_(self): r""" - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(Gamma1(5), 6).diamond_bracket_operator(2)._repr_() 'Diamond bracket operator <2> on Modular Symbols space of dimension 10 for Gamma_1(5) of weight 6 with sign 0 and over Rational Field' @@ -575,7 +575,7 @@ def _repr_(self): def _latex_(self): r""" - EXAMPLE:: + EXAMPLES:: sage: latex(ModularSymbols(Gamma1(5), 12).diamond_bracket_operator(2)) # indirect doctest \langle 2 \rangle @@ -649,7 +649,7 @@ def _repr_(self): r""" String representation of self - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(Gamma0(7), 4).hecke_operator(6)._repr_() 'Hecke operator T_6 on Modular Symbols space of dimension 4 for Gamma_0(7) of weight 4 with sign 0 over Rational Field' @@ -660,7 +660,7 @@ def _latex_(self): r""" LaTeX representation of self - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(Gamma0(7), 4).hecke_operator(6)._latex_() 'T_{6}' diff --git a/src/sage/modular/hecke/homspace.py b/src/sage/modular/hecke/homspace.py index 23569963dc9..98bac2151cc 100644 --- a/src/sage/modular/hecke/homspace.py +++ b/src/sage/modular/hecke/homspace.py @@ -46,7 +46,7 @@ def __init__(self, X, Y, category = None): Create the space of homomorphisms between X and Y, which must have the same base ring. - EXAMPLE:: + EXAMPLES:: sage: M = ModularForms(Gamma0(7), 4) sage: M.Hom(M) diff --git a/src/sage/modular/hecke/module.py b/src/sage/modular/hecke/module.py index 1d36f94be49..36b2a5805ad 100644 --- a/src/sage/modular/hecke/module.py +++ b/src/sage/modular/hecke/module.py @@ -68,7 +68,7 @@ def __init__(self, base_ring, level, category=None): r""" Create a Hecke module. Not intended to be called directly. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(Gamma0(17),2) # indirect doctest Cuspidal subspace of dimension 1 of Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(17) of weight 2 over Rational Field @@ -98,7 +98,7 @@ def __setstate__(self, state): r""" Ensure that the category is initialized correctly on unpickling. - EXAMPLE:: + EXAMPLES:: sage: loads(dumps(ModularSymbols(11))).category() # indirect doctest Category of Hecke modules over Rational Field @@ -112,7 +112,7 @@ def __hash__(self): r""" The hash is determined by the base ring and the level. - EXAMPLE:: + EXAMPLES:: sage: MS = sage.modular.hecke.module.HeckeModule_generic(QQ,1) sage: hash(MS) == hash((MS.base_ring(), MS.level())) @@ -125,7 +125,7 @@ def __cmp__(self, other): r""" Compare self to other. This must be overridden in all subclasses. - EXAMPLE:: + EXAMPLES:: sage: M = ModularForms(Gamma0(3)) sage: sage.modular.hecke.module.HeckeModule_generic.__cmp__(M, M) @@ -142,7 +142,7 @@ def _compute_hecke_matrix_prime_power(self, p, r, **kwds): All derived classes must override either this function or ``self.character()``. - EXAMPLE:: + EXAMPLES:: sage: M = ModularForms(SL2Z, 24) sage: M._compute_hecke_matrix_prime_power(3, 3) @@ -177,7 +177,7 @@ def _compute_hecke_matrix_general_product(self, F, **kwds): factorising n into prime powers and multiplying together the Hecke operators for each of these. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(Gamma0(3), 4) sage: M._compute_hecke_matrix_general_product(factor(10)) @@ -199,7 +199,7 @@ def _compute_dual_hecke_matrix(self, n): r""" Compute the matrix of the Hecke operator `T_n` acting on the dual of self. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(Gamma0(3), 4) sage: M._compute_dual_hecke_matrix(10) @@ -212,7 +212,7 @@ def _compute_hecke_matrix(self, n, **kwds): r""" Compute the matrix of the Hecke operator `T_n` acting on self. - EXAMPLE:: + EXAMPLES:: sage: M = EisensteinForms(DirichletGroup(3).0, 3) sage: M._compute_hecke_matrix(16) @@ -242,7 +242,7 @@ def _compute_hecke_matrix_prime(self, p, **kwds): Derived classes should overload this function, and they will inherit the machinery for calculating general Hecke operators. - EXAMPLE:: + EXAMPLES:: sage: M = EisensteinForms(DirichletGroup(3).0, 3) sage: sage.modular.hecke.module.HeckeModule_generic._compute_hecke_matrix_prime(M, 3) @@ -258,7 +258,7 @@ def _compute_diamond_matrix(self, d): in cases where this isn't self-evident (i.e. when this is not a space with fixed character). - EXAMPLE:: + EXAMPLES:: sage: M = EisensteinForms(Gamma1(5), 3) sage: sage.modular.hecke.module.HeckeModule_generic._compute_diamond_matrix(M, 2) @@ -321,7 +321,7 @@ def character(self): r""" The character of this space. As this is an abstract base class, return None. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.hecke.module.HeckeModule_generic(QQ, 10).character() is None True @@ -332,7 +332,7 @@ def dimension(self): r""" Synonym for rank. - EXAMPLE:: + EXAMPLES:: sage: M = sage.modular.hecke.module.HeckeModule_generic(QQ, 10).dimension() Traceback (most recent call last): @@ -670,7 +670,7 @@ def _hecke_image_of_ith_basis_vector(self, n, i): Return `T_n(e_i)`, where `e_i` is the `i`th basis vector of the ambient space. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(Gamma0(3))._hecke_image_of_ith_basis_vector(4, 0) 7*(1,0) @@ -684,7 +684,7 @@ def _element_eigenvalue(self, x, name='alpha'): r""" Return the dot product of self with the eigenvector returned by dual_eigenvector. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(11)[0] sage: M._element_eigenvalue(M.0) @@ -736,7 +736,7 @@ def _set_factor_number(self, i): For internal use. If this Hecke module was computed via a decomposition of another Hecke module, this method stores the index of this space in that decomposition. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(Gamma0(3))[0].factor_number() # indirect doctest 0 @@ -747,7 +747,7 @@ def ambient(self): r""" Synonym for ambient_hecke_module. Return the ambient module associated to this module. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(1, 12).ambient() Modular Forms space of dimension 2 for Modular Group SL(2,Z) of weight 12 over Rational Field @@ -758,7 +758,7 @@ def ambient_module(self): r""" Synonym for ambient_hecke_module. Return the ambient module associated to this module. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(1, 12).ambient_module() Modular Forms space of dimension 2 for Modular Group SL(2,Z) of weight 12 over Rational Field @@ -774,7 +774,7 @@ def ambient_hecke_module(self): Return the ambient module associated to this module. As this is an abstract base class, return NotImplementedError. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.hecke.module.HeckeModule_free_module(QQ, 10, 3).ambient_hecke_module() Traceback (most recent call last): @@ -889,7 +889,7 @@ def basis_matrix(self): Return the matrix of the basis vectors of self (as vectors in some ambient module) - EXAMPLE:: + EXAMPLES:: sage: CuspForms(1, 12).basis_matrix() [1 0] @@ -1068,7 +1068,7 @@ def degree(self): The degree of this Hecke module (i.e. the rank of the ambient free module) - EXAMPLE:: + EXAMPLES:: sage: CuspForms(1, 12).degree() 2 @@ -1120,7 +1120,7 @@ def dual_eigenvector(self, names='alpha', lift=True, nz=None): eigenvector for the dual action of Hecke operators on functionals. - EXAMPLE:: + EXAMPLES:: sage: SF = ModularSymbols(14).cuspidal_subspace().simple_factors() sage: sorted([u.dual_eigenvector() for u in SF]) @@ -1213,7 +1213,7 @@ def dual_hecke_matrix(self, n): The matrix of the `n^{th}` Hecke operator acting on the dual embedded representation of self. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(1, 24).dual_hecke_matrix(5) [ 79345647584250/2796203 50530996976060416/763363419] @@ -1367,7 +1367,7 @@ def gens(self): """ Return a tuple of basis elements of ``self``. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(23).gens() ((1,0), (1,17), (1,19), (1,20), (1,21)) @@ -1378,7 +1378,7 @@ def gen(self, n): r""" Return the nth basis vector of the space. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(23).gen(1) (1,17) @@ -1390,7 +1390,7 @@ def hecke_matrix(self, n): The matrix of the `n^{th}` Hecke operator acting on given basis. - EXAMPLE:: + EXAMPLES:: sage: C = CuspForms(1, 16) sage: C.hecke_matrix(3) @@ -1483,7 +1483,7 @@ def T(self, n): Returns the `n^{th}` Hecke operator `T_n`. This function is a synonym for :meth:`.hecke_operator`. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(11,2) sage: M.T(3) @@ -1504,7 +1504,7 @@ def hecke_polynomial(self, n, var='x'): OUTPUT: a polynomial - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(11,2).hecke_polynomial(3) x^3 - 2*x^2 - 7*x - 4 @@ -1517,7 +1517,7 @@ def is_simple(self): Hecke algebra. Raises NotImplementedError, as this is an abstract base class. - EXAMPLE:: + EXAMPLES:: sage: sage.modular.hecke.module.HeckeModule_free_module(QQ, 10, 3).is_simple() Traceback (most recent call last): @@ -1534,7 +1534,7 @@ def is_splittable(self): of several copies of the same simple module is not splittable in this sense. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(Gamma0(64)).cuspidal_subspace() sage: M.is_splittable() @@ -1573,7 +1573,7 @@ def is_splittable_anemic(self): of several copies of the same simple module is not splittable in this sense. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(Gamma0(64)).cuspidal_subspace() sage: M.is_splittable_anemic() @@ -1589,7 +1589,7 @@ def ngens(self): r""" Number of generators of self (equal to the rank). - EXAMPLE:: + EXAMPLES:: sage: ModularForms(1, 12).ngens() 2 @@ -1787,7 +1787,7 @@ def _dict_set(v, n, key, val): r""" Rough-and-ready implementation of a two-layer-deep dictionary. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.hecke.module import _dict_set sage: v = {} diff --git a/src/sage/modular/hecke/morphism.py b/src/sage/modular/hecke/morphism.py index bb0a7518b0e..b88d62dc680 100644 --- a/src/sage/modular/hecke/morphism.py +++ b/src/sage/modular/hecke/morphism.py @@ -69,7 +69,7 @@ class HeckeModuleMorphism_matrix(MatrixMorphism, HeckeModuleMorphism): -> B and G : B -> C are morphisms, the composition A -> C is G*F, but its matrix is F.matrix() * G.matrix(). - EXAMPLE:: + EXAMPLES:: sage: A = ModularForms(1, 4) sage: B = ModularForms(1, 16) @@ -97,7 +97,7 @@ def __init__(self, parent, A, name=''): - ``name`` - str (defaults to '') name of the morphism (used for printing) - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(6) sage: t = M.Hom(M)(matrix(QQ,3,3,srange(9)), name="spam"); t diff --git a/src/sage/modular/hecke/submodule.py b/src/sage/modular/hecke/submodule.py index 1528fe19beb..bf93a854103 100644 --- a/src/sage/modular/hecke/submodule.py +++ b/src/sage/modular/hecke/submodule.py @@ -889,7 +889,7 @@ def rank(self): r""" Return the rank of self as a free module over the base ring. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(6, 4).cuspidal_subspace().rank() 2 diff --git a/src/sage/modular/local_comp/liftings.py b/src/sage/modular/local_comp/liftings.py index a56a6ddd983..d5f59f97ffb 100644 --- a/src/sage/modular/local_comp/liftings.py +++ b/src/sage/modular/local_comp/liftings.py @@ -27,7 +27,7 @@ def lift_to_gamma1(g, m, n): The result is always a list of Sage integers (unlike ``lift_to_sl2z``, which tends to return Python ints). - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.liftings import lift_to_gamma1 sage: A = matrix(ZZ, 2, lift_to_gamma1([10, 11, 3, 11], 19, 5)); A @@ -97,7 +97,7 @@ def lift_gen_to_gamma1(m, n): This is a special case of :func:`~lift_to_gamma1`, and is coded as such. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.liftings import lift_gen_to_gamma1 sage: A = matrix(ZZ, 2, lift_gen_to_gamma1(9, 8)); A @@ -123,7 +123,7 @@ def lift_uniformiser_odd(p, u, n): This is required for the local components machinery in the "ramified" case (when the exponent of `p` dividing the level is odd). - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.liftings import lift_uniformiser_odd sage: lift_uniformiser_odd(3, 2, 11) @@ -146,7 +146,7 @@ def lift_ramified(g, p, u, n): then adds an appropriate multiple of the top row to the bottom row in order to get the bottom-left entry correct modulo `p^{u+1}`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.liftings import lift_ramified sage: lift_ramified([2,2,3,2], 3, 1, 1) diff --git a/src/sage/modular/local_comp/local_comp.py b/src/sage/modular/local_comp/local_comp.py index cd9dcea42f4..3a78b096d6e 100644 --- a/src/sage/modular/local_comp/local_comp.py +++ b/src/sage/modular/local_comp/local_comp.py @@ -67,7 +67,7 @@ def LocalComponent(f, p, twist_factor=None): This has the property that the *set* `\{\chi_1, \chi_2\}` also depends Galois-equivariantly on `f`. - EXAMPLE:: + EXAMPLES:: sage: Pi = LocalComponent(Newform('49a'), 7); Pi Smooth representation of GL_2(Q_7) with conductor 7^2 @@ -115,7 +115,7 @@ def __init__(self, newform, prime, twist_factor): r""" Standard initialisation function. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform('49a'), 7) # indirect doctest Smooth representation of GL_2(Q_7) with conductor 7^2 @@ -130,7 +130,7 @@ def species(self): The species of this local component, which is either 'Principal Series', 'Special' or 'Supercuspidal'. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.local_comp import LocalComponentBase sage: LocalComponentBase(Newform('50a'), 3, 0).species() @@ -148,7 +148,7 @@ def check_tempered(self): modular forms are *always* tempered, so this serves as a useful check on our computations. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.local_comp import LocalComponentBase sage: LocalComponentBase(Newform('50a'), 3, 0).check_tempered() @@ -162,7 +162,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform('50a'), 5)._repr_() 'Smooth representation of GL_2(Q_5) with conductor 5^2' @@ -173,7 +173,7 @@ def newform(self): r""" The newform of which this is a local component. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform('50a'), 5).newform() q - q^2 + q^3 + q^4 + O(q^6) @@ -184,7 +184,7 @@ def prime(self): r""" The prime at which this is a local component. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform('50a'), 5).prime() 5 @@ -196,7 +196,7 @@ def conductor(self): The smallest `r` such that this representation has a nonzero vector fixed by the subgroup `\begin{pmatrix} * & * \\ 0 & 1\end{pmatrix} \pmod{p^r}`. This is equal to the power of `p` dividing the level of the corresponding newform. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform('50a'), 5).conductor() 2 @@ -207,7 +207,7 @@ def coefficient_field(self): r""" The field `K` over which this representation is defined. This is the field generated by the Hecke eigenvalues of the corresponding newform (over whatever base ring the newform is created). - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newforms(50)[0], 3).coefficient_field() Rational Field @@ -230,7 +230,7 @@ def twist_factor(self): since otherwise the map sending `f` to its local component won't be Galois equivariant. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newforms(50)[0], 3).twist_factor() 0 @@ -277,7 +277,7 @@ def __eq__(self, other): r""" Comparison function. - EXAMPLE:: + EXAMPLES:: sage: Pi = LocalComponent(Newform("50a"), 5) sage: Pi == LocalComponent(Newform("50a"), 3) @@ -300,7 +300,7 @@ def __ne__(self, other): """ Return True if ``self != other``. - EXAMPLE:: + EXAMPLES:: sage: Pi = LocalComponent(Newform("50a"), 5) sage: Pi != LocalComponent(Newform("50a"), 3) @@ -329,7 +329,7 @@ def species(self): The species of this local component, which is either 'Principal Series', 'Special' or 'Supercuspidal'. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform('50a'), 3).species() 'Principal Series' @@ -343,7 +343,7 @@ def check_tempered(self): This follows from the Ramanujan--Petersson conjecture, as proved by Deligne. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform('49a'), 3).check_tempered() """ @@ -360,7 +360,7 @@ def characters(self): Return the two characters `(\chi_1, \chi_2)` such this representation `\pi_{f, p}` is equal to the principal series `\pi(\chi_1, \chi_2)`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.local_comp import PrincipalSeries sage: PrincipalSeries(Newform('50a'), 3, 0).characters() @@ -375,7 +375,7 @@ class UnramifiedPrincipalSeries(PrincipalSeries): An unramified principal series representation of `{\rm GL}_2(\QQ_p)` (corresponding to a form whose level is not divisible by `p`). - EXAMPLE:: + EXAMPLES:: sage: Pi = LocalComponent(Newform('50a'), 3) sage: Pi.conductor() @@ -445,7 +445,7 @@ class PrimitivePrincipalSeries(PrincipalSeries): A ramified principal series of the form `\pi(\chi_1, \chi_2)` where `\chi_1` is unramified but `\chi_2` is not. - EXAMPLE:: + EXAMPLES:: sage: Pi = LocalComponent(Newforms(Gamma1(13), 2, names='a')[0], 13) sage: type(Pi) @@ -457,7 +457,7 @@ def characters(self): r""" Return the two characters `(\chi_1, \chi_2)` such that the local component `\pi_{f, p}` is the induction of the character `\chi_1 \times \chi_2` of the Borel subgroup. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newforms(Gamma1(13), 2, names='a')[0], 13).characters() [ @@ -493,7 +493,7 @@ def species(self): The species of this local component, which is either 'Principal Series', 'Special' or 'Supercuspidal'. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform('37a'), 37).species() 'Special' @@ -544,7 +544,7 @@ def check_tempered(self): of modular forms are always tempered, this is a useful check on our calculations. - EXAMPLE:: + EXAMPLES:: sage: Pi = LocalComponent(Newforms(DirichletGroup(21)([-1, 1]), 3, names='j')[0], 7) sage: Pi.check_tempered() @@ -581,7 +581,7 @@ def species(self): The species of this local component, which is either 'Principal Series', 'Special' or 'Supercuspidal'. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform('49a'), 7).species() 'Supercuspidal' @@ -595,7 +595,7 @@ def type_space(self): describing the (homological) type space of this newform, which we know is dual to the type space of the local component. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform('49a'), 7).type_space() 6-dimensional type space at prime 7 of form q + q^2 - q^4 + O(q^6) @@ -742,7 +742,7 @@ def check_tempered(self): is not implemented in the odd-conductor case, a NotImplementedError will be raised for such representations. - EXAMPLE:: + EXAMPLES:: sage: LocalComponent(Newform("50a"), 5).check_tempered() sage: LocalComponent(Newform("27a"), 3).check_tempered() # not tested diff --git a/src/sage/modular/local_comp/smoothchar.py b/src/sage/modular/local_comp/smoothchar.py index 9df02b37187..c4db61408a5 100644 --- a/src/sage/modular/local_comp/smoothchar.py +++ b/src/sage/modular/local_comp/smoothchar.py @@ -108,7 +108,7 @@ def __cmp__(self, other): Compare self and other. Note that this only gets called when the parents of self and other are identical. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp, SmoothCharacterGroupUnramifiedQuadratic sage: SmoothCharacterGroupQp(7, Zmod(3)).character(1, [2, 1]) == SmoothCharacterGroupQp(7, ZZ).character(1, [-1, 1]) @@ -129,7 +129,7 @@ def multiplicative_order(self): r""" Return the order of this character as an element of the character group. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: K. = CyclotomicField(42) @@ -272,7 +272,7 @@ def restrict_to_Qp(self): Return the restriction of this character to `\QQ_p^\times`, embedded as a subfield of `F^\times`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupRamifiedQuadratic sage: SmoothCharacterGroupRamifiedQuadratic(3, 0, QQ).character(0, [2]).restrict_to_Qp() @@ -290,7 +290,7 @@ def galois_conjugate(self): Note that this is the Galois operation on the *domain*, not on the *codomain*. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: K. = CyclotomicField(3) @@ -434,7 +434,7 @@ def prime(self): r""" The residue characteristic of the underlying field. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupGeneric sage: SmoothCharacterGroupGeneric(3, QQ).prime() @@ -449,7 +449,7 @@ def change_ring(self, ring): different coefficient ring. To be implemented by all derived classes (since the generic base class can't know the parameters). - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupGeneric sage: SmoothCharacterGroupGeneric(3, QQ).change_ring(ZZ) @@ -466,7 +466,7 @@ def base_extend(self, ring): will be raised if there is no coercion map from the old coefficient ring to the new one. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: G = SmoothCharacterGroupQp(3, QQ) @@ -490,7 +490,7 @@ def _field_name(self): A string representing the name of the p-adic field of which this is the character group. To be overridden by derived subclasses. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupGeneric sage: SmoothCharacterGroupGeneric(3, QQ)._field_name() @@ -504,7 +504,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: SmoothCharacterGroupQp(7, QQ)._repr_() @@ -520,7 +520,7 @@ def ideal(self, level): field arithmetic, what is actually returned is an ideal in a number field. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupGeneric sage: SmoothCharacterGroupGeneric(3, QQ).ideal(3) @@ -540,7 +540,7 @@ def unit_gens(self, level): convention that the final generator `x_d` is a uniformiser (and `n_d = 0`). - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupGeneric sage: SmoothCharacterGroupGeneric(3, QQ).unit_gens(3) @@ -556,7 +556,7 @@ def exponents(self, level): The orders `n_1, \dots, n_d` of the generators `x_i` of `F^\times / (1 + \mathfrak{p}^c)^\times` returned by :meth:`unit_gens`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupGeneric sage: SmoothCharacterGroupGeneric(3, QQ).exponents(3) @@ -573,7 +573,7 @@ def subgroup_gens(self, level): generating the kernel of the reduction map to `(\mathcal{O}_F / \mathfrak{p}^{c-1})^\times`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupGeneric sage: SmoothCharacterGroupGeneric(3, QQ).subgroup_gens(3) @@ -595,7 +595,7 @@ def discrete_log(self, level): first attempt to canonically coerce `x` into ``self.number_field()``, and check that the result is not zero. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupGeneric sage: SmoothCharacterGroupGeneric(3, QQ).discrete_log(3) @@ -676,7 +676,7 @@ def _an_element_(self): r""" Return an element of this group. Required by the coercion machinery. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: K. = CyclotomicField(42) @@ -693,7 +693,7 @@ def _test_unitgens(self, **options): Test that the generators returned by ``unit_gens`` are consistent with the exponents returned by ``exponents``. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: SmoothCharacterGroupUnramifiedQuadratic(2, Zmod(8))._test_unitgens() @@ -730,7 +730,7 @@ def _test_subgroupgens(self, **options): r""" Test that the values returned by :meth:`~subgroup_gens` are valid. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: SmoothCharacterGroupQp(2, CC)._test_subgroupgens() @@ -822,7 +822,7 @@ def unit_gens(self, level): are no relations between them other than relations of the form `x_i^{n_i} = 1`. They need not, however, be in Smith normal form. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: SmoothCharacterGroupQp(7, QQ).unit_gens(3) @@ -839,7 +839,7 @@ def exponents(self, level): r""" Return the exponents of the generators returned by :meth:`unit_gens`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: SmoothCharacterGroupQp(7, QQ).exponents(3) @@ -858,7 +858,7 @@ def change_ring(self, ring): from self to the new group -- use :meth:`~SmoothCharacterGroupGeneric.base_extend` if you want this. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: SmoothCharacterGroupQp(7, Zmod(3)).change_ring(CC) @@ -872,7 +872,7 @@ def number_field(self): local field of which this is the character group). In this case, this is always the rational field. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: SmoothCharacterGroupQp(7, Zmod(3)).number_field() @@ -886,7 +886,7 @@ def ideal(self, level): approximate by using rational arithmetic, what is actually returned is an ideal of `\ZZ`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: SmoothCharacterGroupQp(7, Zmod(3)).ideal(2) @@ -899,7 +899,7 @@ def _field_name(self): Return a string representation of the field unit group of which this is the character group. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: SmoothCharacterGroupQp(7, Zmod(3))._field_name() @@ -912,7 +912,7 @@ def discrete_log(self, level, x): Express the class of `x` in `\QQ_p^\times / (1 + p^c)^\times` in terms of the generators returned by :meth:`unit_gens`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupQp sage: G = SmoothCharacterGroupQp(7, QQ) @@ -969,7 +969,7 @@ class SmoothCharacterGroupUnramifiedQuadratic(SmoothCharacterGroupGeneric): quadratic number field, defined by (the obvious lift to `\ZZ` of) the Conway polynomial modulo `p` of degree 2. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: G = SmoothCharacterGroupUnramifiedQuadratic(3, QQ); G @@ -984,7 +984,7 @@ def __init__(self, prime, base_ring, names='s'): r""" Standard initialisation function. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: G = SmoothCharacterGroupUnramifiedQuadratic(3, QQ, 'foo'); G @@ -1003,7 +1003,7 @@ def change_ring(self, ring): coercion map from self to the new group -- use :meth:`~SmoothCharacterGroupGeneric.base_extend` if you want this. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: SmoothCharacterGroupUnramifiedQuadratic(7, Zmod(3), names='foo').change_ring(CC) @@ -1023,7 +1023,7 @@ def _field_name(self): r""" A string representing the unit group of which this is the character group. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: SmoothCharacterGroupUnramifiedQuadratic(7, Zmod(3), 'a')._field_name() @@ -1082,7 +1082,7 @@ def unit_gens(self, c): ALGORITHM: Use Teichmueller lifts. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: SmoothCharacterGroupUnramifiedQuadratic(7, QQ).unit_gens(0) @@ -1135,7 +1135,7 @@ def exponents(self, c): The orders `n_1, \dots, n_d` of the generators `x_i` of `F^\times / (1 + \mathfrak{p}^c)^\times` returned by :meth:`unit_gens`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: SmoothCharacterGroupUnramifiedQuadratic(7, QQ).exponents(2) @@ -1158,7 +1158,7 @@ def subgroup_gens(self, level): generating the kernel of the reduction map to `(\mathcal{O}_F / \mathfrak{p}^{c-1})^\times`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: SmoothCharacterGroupUnramifiedQuadratic(7, QQ).subgroup_gens(1) @@ -1185,7 +1185,7 @@ def quotient_gen(self, level): where `c` is the given level. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: G = SmoothCharacterGroupUnramifiedQuadratic(7,QQ) @@ -1318,7 +1318,7 @@ def discrete_log(self, level, x): Express the class of `x` in `F^\times / (1 + \mathfrak{p}^c)^\times` in terms of the generators returned by ``self.unit_gens(level)``. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupUnramifiedQuadratic sage: G = SmoothCharacterGroupUnramifiedQuadratic(2, QQ) @@ -1371,7 +1371,7 @@ def __init__(self, prime, flag, base_ring, names='s'): extension `\QQ_p(\sqrt{dp})`, where `d` is `-1` (if `p = 3 \pmod 4`) or the smallest positive quadratic nonresidue mod `p` otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupRamifiedQuadratic sage: G1 = SmoothCharacterGroupRamifiedQuadratic(3, 0, QQ); G1 @@ -1413,7 +1413,7 @@ def change_ring(self, ring): coercion map from self to the new group -- use :meth:`~SmoothCharacterGroupGeneric.base_extend` if you want this. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupRamifiedQuadratic sage: SmoothCharacterGroupRamifiedQuadratic(7, 1, Zmod(3), names='foo').change_ring(CC) @@ -1425,7 +1425,7 @@ def _field_name(self): r""" A string representing the unit group of which this is the character group. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupRamifiedQuadratic sage: SmoothCharacterGroupRamifiedQuadratic(7, 0, Zmod(3), 'a')._field_name() @@ -1479,7 +1479,7 @@ def unit_gens(self, c): integers `n_i` are returned by :meth:`exponents`). We adopt the convention that the final generator `x_d` is a uniformiser. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupRamifiedQuadratic sage: G = SmoothCharacterGroupRamifiedQuadratic(5, 0, QQ) @@ -1513,7 +1513,7 @@ def exponents(self, c): Return the orders of the independent generators of the unit group returned by :meth:`~unit_gens`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupRamifiedQuadratic sage: G = SmoothCharacterGroupRamifiedQuadratic(5, 0, QQ) @@ -1543,7 +1543,7 @@ def subgroup_gens(self, level): generating the kernel of the reduction map to `(\mathcal{O}_F / \mathfrak{p}^{c-1})^\times`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupRamifiedQuadratic sage: G = SmoothCharacterGroupRamifiedQuadratic(3, 1, QQ) @@ -1561,7 +1561,7 @@ def discrete_log(self, level, x): r""" Solve the discrete log problem in the unit group. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.smoothchar import SmoothCharacterGroupRamifiedQuadratic sage: G = SmoothCharacterGroupRamifiedQuadratic(3, 1, QQ) diff --git a/src/sage/modular/local_comp/type_space.py b/src/sage/modular/local_comp/type_space.py index ecf9e57e321..4e1c4d24879 100644 --- a/src/sage/modular/local_comp/type_space.py +++ b/src/sage/modular/local_comp/type_space.py @@ -37,7 +37,7 @@ def example_type_space(example_no = 0): Quickly return an example of a type space. Used mainly to speed up doctesting. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space() # takes a while but caches stuff (21s on sage.math, 2012) @@ -157,7 +157,7 @@ class TypeSpace(SageObject): def __init__(self, f, p, base_extend=True): r""" - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space() # indirect doctest @@ -184,7 +184,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space()._repr_() @@ -196,7 +196,7 @@ def prime(self): r""" Return the prime `p`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space().prime() @@ -208,7 +208,7 @@ def form(self): r""" The newform of which this is the type space. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space().form() @@ -220,7 +220,7 @@ def conductor(self): r""" Exponent of `p` dividing the level of the form. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space().conductor() @@ -232,7 +232,7 @@ def character_conductor(self): r""" Exponent of `p` dividing the conductor of the character of the form. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space().character_conductor() @@ -245,7 +245,7 @@ def u(self): Largest integer `u` such that level of `f_\chi` = level of `f` for all Dirichlet characters `\chi` modulo `p^u`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space().u() @@ -261,7 +261,7 @@ def free_module(self): r""" Return the underlying vector space of this type space. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space().free_module() @@ -275,7 +275,7 @@ def eigensymbol_subspace(self): `f` and its Galois conjugates (as a subspace of the vector space returned by :meth:`~free_module`). - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: T = example_type_space(); T.eigensymbol_subspace() @@ -293,7 +293,7 @@ def tame_level(self): r""" The level away from `p`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space().tame_level() @@ -306,7 +306,7 @@ def group(self): Return a `\Gamma_H` group which is the level of all of the relevant twists of `f`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space().group() @@ -335,7 +335,7 @@ def is_minimal(self): The result is cached. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space().is_minimal() @@ -353,7 +353,7 @@ def minimal_twist(self): An error will be raised if `f` is already minimal. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import TypeSpace, example_type_space sage: T = example_type_space(1) @@ -439,7 +439,7 @@ def _second_gen_unramified(self): Calculate the action of the matrix [0, -1; 1, 0] on the type space, in the unramified (even level) case. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: T = example_type_space(2) @@ -472,7 +472,7 @@ def _rho_unramified(self, g): converted into an element of the matrix group `{\rm SL}_2(\ZZ / p^u \ZZ)`). - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: T = example_type_space(2) @@ -509,7 +509,7 @@ def _rho_ramified(self, g): For internal use (called by :meth:`~rho`). - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: T = example_type_space(3) @@ -604,7 +604,7 @@ def _discover_torus_action(self): Calculate and store the data necessary to extend the action of `S(K_0)` to `K_0`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: example_type_space(2).rho([2,0,0,1]) # indirect doctest @@ -629,7 +629,7 @@ def rho(self, g): r""" Calculate the action of the group element `g` on the type space. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: T = example_type_space(2) @@ -708,7 +708,7 @@ def _unif_ramified(self): Return the action of [0,-1,p,0], in the ramified (odd p-power level) case. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.local_comp.type_space import example_type_space sage: T = example_type_space(3) diff --git a/src/sage/modular/modform/ambient.py b/src/sage/modular/modform/ambient.py index 9ecbfaa5ff9..99eb5f62629 100644 --- a/src/sage/modular/modform/ambient.py +++ b/src/sage/modular/modform/ambient.py @@ -237,7 +237,7 @@ def _degeneracy_raising_matrix(self, M, t): to `f(q) \mapsto f(q^t)`. Here the level of M should be a multiple of the level of self, and t should divide the quotient. - EXAMPLE:: + EXAMPLES:: sage: ModularForms(22, 2)._degeneracy_raising_matrix(ModularForms(44, 2), 1) [ 1 0 -1 -2 0 0 0 0 0] diff --git a/src/sage/modular/modform/ambient_R.py b/src/sage/modular/modform/ambient_R.py index 298e1a11598..f16f5ae33ad 100644 --- a/src/sage/modular/modform/ambient_R.py +++ b/src/sage/modular/modform/ambient_R.py @@ -145,7 +145,7 @@ def cuspidal_submodule(self): r""" Return the cuspidal subspace of this space. - EXAMPLE:: + EXAMPLES:: sage: C = CuspForms(7, 4, base_ring=CyclotomicField(5)) # indirect doctest sage: type(C) @@ -158,7 +158,7 @@ def change_ring(self, R): r""" Return this modular forms space with the base ring changed to the ring R. - EXAMPLE:: + EXAMPLES:: sage: chi = DirichletGroup(109, CyclotomicField(3)).0 sage: M9 = ModularForms(chi, 2, base_ring = CyclotomicField(9)) diff --git a/src/sage/modular/modform/ambient_g0.py b/src/sage/modular/modform/ambient_g0.py index c775258813b..85d8623a373 100644 --- a/src/sage/modular/modform/ambient_g0.py +++ b/src/sage/modular/modform/ambient_g0.py @@ -91,7 +91,7 @@ def _compute_atkin_lehner_matrix(self, d): where d is a divisor of the level. This is only implemented in the (trivial) level 1 case. - EXAMPLE:: + EXAMPLES:: sage: ModularForms(1, 30).atkin_lehner_operator() Hecke module morphism Atkin-Lehner operator W_1 defined by the matrix diff --git a/src/sage/modular/modform/ambient_g1.py b/src/sage/modular/modform/ambient_g1.py index e996ea39911..2cbdd441f9e 100644 --- a/src/sage/modular/modform/ambient_g1.py +++ b/src/sage/modular/modform/ambient_g1.py @@ -121,7 +121,7 @@ def _compute_diamond_matrix(self, d): r""" Compute the matrix of the diamond operator on this space. - EXAMPLE:: + EXAMPLES:: sage: ModularForms(GammaH(9, [4]), 7)._compute_diamond_matrix(2) [-1 0 0 0 0 0 0 0] @@ -139,7 +139,7 @@ def _compute_hecke_matrix(self, n): r""" Compute the matrix of the Hecke operator T_n acting on this space. - EXAMPLE:: + EXAMPLES:: sage: ModularForms(Gamma1(7), 4).hecke_matrix(3) # indirect doctest [ 0 -42 133 0 0 0 0 0 0] diff --git a/src/sage/modular/modform/cuspidal_submodule.py b/src/sage/modular/modform/cuspidal_submodule.py index d0d28a603e9..d026f755ca0 100644 --- a/src/sage/modular/modform/cuspidal_submodule.py +++ b/src/sage/modular/modform/cuspidal_submodule.py @@ -96,7 +96,7 @@ def _compute_q_expansion_basis(self, prec): Compute a basis of q-expansions of self to the given precision. Not implemented in this abstract base class. - EXAMPLE:: + EXAMPLES:: sage: M = CuspForms(GammaH(11,[2]), 2) sage: sage.modular.modform.cuspidal_submodule.CuspidalSubmodule._compute_q_expansion_basis(M, 6) @@ -207,7 +207,7 @@ class CuspidalSubmodule_R(CuspidalSubmodule): """ def _compute_q_expansion_basis(self, prec): r""" - EXAMPLE:: + EXAMPLES:: sage: CuspForms(Gamma1(13), 2, base_ring=QuadraticField(-7, 'a')).q_expansion_basis() # indirect doctest [ @@ -247,7 +247,7 @@ def new_submodule(self, p=None): Return the new subspace of this space of cusp forms. This is computed using modular symbols. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(55).new_submodule() Modular Forms subspace of dimension 3 of Modular Forms space of dimension 8 for Congruence Subgroup Gamma0(55) of weight 2 over Rational Field @@ -296,7 +296,7 @@ def _compute_hecke_matrix(self, n): This is done directly using modular symbols, rather than using q-expansions as for spaces with fixed character. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(Gamma1(8), 4)._compute_hecke_matrix(2) [ 0 -16 32] @@ -314,7 +314,7 @@ def _compute_hecke_matrix(self, n): def _compute_diamond_matrix(self, d): r""" - EXAMPLE:: + EXAMPLES:: sage: CuspForms(Gamma1(5), 6).diamond_bracket_matrix(3) # indirect doctest [ -1 0 0] @@ -381,7 +381,7 @@ def _convert_matrix_from_modsyms(symbs, T): A pair `(T_e, ps)` with `T_e` the converted matrix and `ps` a list of pivot elements of the echelon basis. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(Gamma1(5), 6).diamond_bracket_matrix(3) # indirect doctest [ -1 0 0] diff --git a/src/sage/modular/modform/eis_series.py b/src/sage/modular/modform/eis_series.py index afc79fb957c..aef6b75a244 100644 --- a/src/sage/modular/modform/eis_series.py +++ b/src/sage/modular/modform/eis_series.py @@ -294,7 +294,7 @@ def __find_eisen_chars_gammaH(N, H, k): Find all triples `(\psi_1, \psi_2, t)` that give rise to an Eisenstein series of weight `k` on `\Gamma_H(N)`. - EXAMPLE:: + EXAMPLES:: sage: pars = sage.modular.modform.eis_series.__find_eisen_chars_gammaH(15, [2], 5) sage: [(x[0].values_on_gens(), x[1].values_on_gens(), x[2]) for x in pars] diff --git a/src/sage/modular/modform/eisenstein_submodule.py b/src/sage/modular/modform/eisenstein_submodule.py index 94148d8b12e..f2e516dfbaa 100644 --- a/src/sage/modular/modform/eisenstein_submodule.py +++ b/src/sage/modular/modform/eisenstein_submodule.py @@ -166,7 +166,7 @@ def new_submodule(self, p=None): r""" Return the new submodule of self. - EXAMPLE:: + EXAMPLES:: sage: e = EisensteinForms(Gamma0(225), 2).new_submodule(); e Modular Forms subspace of dimension 3 of Modular Forms space of dimension 42 for Congruence Subgroup Gamma0(225) of weight 2 over Rational Field @@ -312,7 +312,7 @@ def new_eisenstein_series(self): r""" Return a list of the Eisenstein series in this space that are new. - EXAMPLE:: + EXAMPLES:: sage: E = EisensteinForms(25, 4) sage: E.new_eisenstein_series() @@ -476,7 +476,7 @@ def _compute_hecke_matrix(self, n, bound=None): a_{i,j}(T_n* T_m)`. But we can't find the constant terms by this method, so an extra step is required. - EXAMPLE:: + EXAMPLES:: sage: EisensteinForms(Gamma1(6), 3).hecke_matrix(3) # indirect doctest [ 1 0 72 0] @@ -493,7 +493,7 @@ def _compute_diamond_matrix(self, d): Calculate the matrix of the diamond bracket operator on this space, using modular symbols. - EXAMPLE:: + EXAMPLES:: sage: E = EisensteinForms(Gamma1(7), 3) sage: E._compute_diamond_matrix(3) diff --git a/src/sage/modular/modform/element.py b/src/sage/modular/modform/element.py index 9395bfb73c9..0ce9a062938 100644 --- a/src/sage/modular/modform/element.py +++ b/src/sage/modular/modform/element.py @@ -997,7 +997,7 @@ def petersson_norm(self, embedding=0, prec=53): (default: 0) - ``prec`` (integer, default 53): precision in bits - EXAMPLE:: + EXAMPLES:: sage: CuspForms(1, 16).0.petersson_norm() verbose -1 (...: dokchitser.py, __call__) Warning: Loss of 2 decimal digits due to cancellation @@ -1360,7 +1360,7 @@ def atkin_lehner_eigenvalue(self, d=None): of this form is not either trivial or quadratic. If d is not given or is None, then d defaults to the level of self. - EXAMPLE:: + EXAMPLES:: sage: [x.atkin_lehner_eigenvalue() for x in ModularForms(53).newforms('a')] [1, -1] @@ -1665,7 +1665,7 @@ def atkin_lehner_eigenvalue(self, d=None): modular form (which is either 1 or -1), or None if this form is not an eigenvector for this operator. - EXAMPLE:: + EXAMPLES:: sage: CuspForms(1, 30).0.atkin_lehner_eigenvalue() 1 @@ -1888,7 +1888,7 @@ def atkin_lehner_eigenvalue(self, d=None): is attached to an elliptic curve, we can read this off from the root number of the curve if d is the level. - EXAMPLE:: + EXAMPLES:: sage: EllipticCurve('57a1').newform().atkin_lehner_eigenvalue() 1 diff --git a/src/sage/modular/modform/find_generators.py b/src/sage/modular/modform/find_generators.py index 8e36423bc74..abc1c1de8ba 100644 --- a/src/sage/modular/modform/find_generators.py +++ b/src/sage/modular/modform/find_generators.py @@ -133,7 +133,7 @@ def find_generators(*args): replaced by the :meth:`~ModularFormsRing.generators` method of ModularFormsRing objects. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modform.find_generators import find_generators sage: find_generators() @@ -149,7 +149,7 @@ def basis_for_modform_space(*args): replaced by the :meth:`~ModularFormsRing.q_expansion_basis` method of ModularFormsRing objects. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modform.find_generators import basis_for_modform_space sage: basis_for_modform_space() @@ -234,7 +234,7 @@ def group(self): r""" Return the congruence subgroup for which this is the ring of modular forms. - EXAMPLE:: + EXAMPLES:: sage: R = ModularFormsRing(Gamma1(13)) sage: R.group() is Gamma1(13) @@ -246,7 +246,7 @@ def base_ring(self): r""" Return the coefficient ring of this modular forms ring. - EXAMPLE:: + EXAMPLES:: sage: ModularFormsRing(Gamma1(13)).base_ring() Rational Field @@ -260,7 +260,7 @@ def __cmp__(self, other): Compare self to other. Rings are equal if and only if their groups and base rings are. - EXAMPLE:: + EXAMPLES:: sage: ModularFormsRing(3) == 3 False @@ -473,7 +473,7 @@ def gen_forms(self, maxweight=8, start_gens=[], start_weight=2): :meth:`generators`). If called with non-default values for these parameters, caching will be disabled. - EXAMPLE:: + EXAMPLES:: sage: A = ModularFormsRing(Gamma0(11), Zmod(5)).gen_forms(); A [1 + 12*q^2 + 12*q^3 + 12*q^4 + 12*q^5 + O(q^6), q - 2*q^2 - q^3 + 2*q^4 + q^5 + O(q^6), q - 9*q^4 - 10*q^5 + O(q^6)] @@ -504,7 +504,7 @@ def _find_generators(self, maxweight, start_gens, start_weight): a list of tuples, formatted as with ``start_gens``. - EXAMPLE:: + EXAMPLES:: sage: R = ModularFormsRing(Gamma1(4)) sage: R._find_generators(8, (), 2) @@ -675,7 +675,7 @@ def cuspidal_ideal_generators(self, maxweight=8, prec=None): Calculate generators for the ideal of cuspidal forms in this ring, as a module over the whole ring. - EXAMPLE:: + EXAMPLES:: sage: ModularFormsRing(Gamma0(3)).cuspidal_ideal_generators(maxweight=12) [(6, q - 6*q^2 + 9*q^3 + 4*q^4 + O(q^5), q - 6*q^2 + 9*q^3 + 4*q^4 + 6*q^5 + O(q^6))] diff --git a/src/sage/modular/modform/space.py b/src/sage/modular/modform/space.py index 88938851632..11e24856a54 100644 --- a/src/sage/modular/modform/space.py +++ b/src/sage/modular/modform/space.py @@ -1559,7 +1559,7 @@ def is_cuspidal(self): r""" Return True if this space is cuspidal. - EXAMPLE:: + EXAMPLES:: sage: M = ModularForms(Gamma0(11), 2).new_submodule() sage: M.is_cuspidal() @@ -1573,7 +1573,7 @@ def is_eisenstein(self): r""" Return True if this space is Eisenstein. - EXAMPLE:: + EXAMPLES:: sage: M = ModularForms(Gamma0(11), 2).new_submodule() sage: M.is_eisenstein() diff --git a/src/sage/modular/modsym/boundary.py b/src/sage/modular/modsym/boundary.py index e38aa6c06f4..ab46252d09f 100644 --- a/src/sage/modular/modsym/boundary.py +++ b/src/sage/modular/modsym/boundary.py @@ -341,7 +341,7 @@ def __init__(self, def __cmp__(self, other): """ - EXAMPLE:: + EXAMPLES:: sage: B2 = ModularSymbols(11, 2).boundary_space() sage: B4 = ModularSymbols(11, 4).boundary_space() diff --git a/src/sage/modular/modsym/element.py b/src/sage/modular/modsym/element.py index d4f4dcabbc1..8eac52b09ea 100644 --- a/src/sage/modular/modsym/element.py +++ b/src/sage/modular/modsym/element.py @@ -62,7 +62,7 @@ def set_modsym_print_mode(mode="manin"): OUTPUT: none - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(13, 8) sage: x = M.0 + M.1 + M.14 @@ -100,7 +100,7 @@ def __init__(self, parent, x, check=True): symbol in terms of a basis for the ambient space (not in terms of a basis for parent!) - EXAMPLE:: + EXAMPLES:: sage: S = ModularSymbols(11, sign=1).cuspidal_submodule() sage: S(vector([0,1])) @@ -123,7 +123,7 @@ def __init__(self, parent, x, check=True): def __cmp__(self, other): r""" Standard comparison function. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(11, 2) sage: M.0 == M.1 # indirect doctest @@ -143,7 +143,7 @@ def _repr_(self): modular symbols print mode setting controlled by the function ``set_modsym_print_mode``. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(13, 4) sage: set_modsym_print_mode('manin'); M.0._repr_() @@ -166,7 +166,7 @@ def _latex_(self): r""" LaTeX representation of self. The output will be determined by the print mode setting set using ``set_modsym_print_mode``. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(11, 2) sage: x = M.0 + M.2; x @@ -195,7 +195,7 @@ def _add_(self, right): r""" Sum of self and other. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(3, 12) sage: x = M.0; y = M.1; z = x + y; z # indirect doctest @@ -209,7 +209,7 @@ def _rmul_(self, other): r""" Right-multiply self by other. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(3, 12) sage: x = M.0; z = x*3; z # indirect doctest @@ -227,7 +227,7 @@ def _lmul_(self, left): r""" Left-multiply self by other. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(3, 12) sage: x = M.0; z = 3*x; z # indirect doctest @@ -245,7 +245,7 @@ def _neg_(self): r""" Multiply by -1. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(3, 12) sage: x = M.0; z = -x; z # indirect doctest @@ -259,7 +259,7 @@ def _sub_(self, other): r""" Subtract other from self. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(3, 12) sage: x = M.0; y = M.1; z = y-x; z # indirect doctest @@ -279,7 +279,7 @@ def list(self): r""" Return a list of the coordinates of self in terms of a basis for the ambient space. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(37, 2).0.list() [1, 0, 0, 0, 0] @@ -290,7 +290,7 @@ def manin_symbol_rep(self): """ Returns a representation of self as a formal sum of Manin symbols. - EXAMPLE:: + EXAMPLES:: sage: x = ModularSymbols(37, 4).0 sage: x.manin_symbol_rep() @@ -318,7 +318,7 @@ def modular_symbol_rep(self): Returns a representation of self as a formal sum of modular symbols. - EXAMPLE:: + EXAMPLES:: sage: x = ModularSymbols(37, 4).0 sage: x.modular_symbol_rep() diff --git a/src/sage/modular/modsym/g1list.py b/src/sage/modular/modsym/g1list.py index a9f2320abaf..29a4b74fee8 100644 --- a/src/sage/modular/modsym/g1list.py +++ b/src/sage/modular/modsym/g1list.py @@ -36,7 +36,7 @@ class G1list: """ def __init__(self, N): """ - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.g1list.G1list(6); L # indirect doctest List of coset representatives for Gamma_1(6) in SL_2(Z) @@ -49,7 +49,7 @@ def __cmp__(self, other): r""" Compare self to other. - EXAMPLE:: + EXAMPLES:: sage: L1 = sage.modular.modsym.g1list.G1list(6) sage: L2 = sage.modular.modsym.g1list.G1list(7) @@ -66,7 +66,7 @@ def __cmp__(self, other): def __getitem__(self, i): """ - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.g1list.G1list(19); L[100] # indirect doctest (5, 6) @@ -77,7 +77,7 @@ def __len__(self): """ Return the length of the underlying list. - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.g1list.G1list(24); len(L) # indirect doctest 384 @@ -88,7 +88,7 @@ def __repr__(self): """ String representation of self. - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.g1list.G1list(3); L.__repr__() 'List of coset representatives for Gamma_1(3) in SL_2(Z)' @@ -100,7 +100,7 @@ def list(self): Return a list of vectors representing the cosets. Do not change the returned list! - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.g1list.G1list(4); L.list() [(0, 1), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 1), (2, 3), (3, 0), (3, 1), (3, 2), (3, 3)] @@ -118,7 +118,7 @@ def normalize(self, u, v): This will only make sense if `{\rm gcd}(u, v, N) = 1`; otherwise the output will not be an element of self. - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.g1list.G1list(4); L.normalize(6, 1) (2, 1) diff --git a/src/sage/modular/modsym/ghlist.py b/src/sage/modular/modsym/ghlist.py index 35a0d11d6db..65b74d10db3 100644 --- a/src/sage/modular/modsym/ghlist.py +++ b/src/sage/modular/modsym/ghlist.py @@ -36,7 +36,7 @@ class GHlist: def __init__(self, group): """ - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.ghlist.GHlist(GammaH(8,[7])); L # indirect doctest List of coset representatives for Congruence Subgroup Gamma_H(8) with H generated by [7] @@ -52,7 +52,7 @@ def __init__(self, group): def __getitem__(self, i): """ - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.ghlist.GHlist(GammaH(8, [5])); L[5] # indirect doctest (1, 3) @@ -63,7 +63,7 @@ def __cmp__(self, other): r""" Compare self to other. - EXAMPLE:: + EXAMPLES:: sage: L1 = sage.modular.modsym.ghlist.GHlist(GammaH(18, [11])) sage: L2 = sage.modular.modsym.ghlist.GHlist(GammaH(18, [13])) @@ -81,7 +81,7 @@ def __len__(self): """ Return the length of the underlying list (the index of the group). - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.ghlist.GHlist(GammaH(24, [5])); len(L) # indirect doctest 192 @@ -92,7 +92,7 @@ def __repr__(self): """ String representation of self. - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.ghlist.GHlist(GammaH(11,[4])); L.__repr__() 'List of coset representatives for Congruence Subgroup Gamma_H(11) with H generated by [4]' @@ -104,7 +104,7 @@ def list(self): Return a list of vectors representing the cosets. Do not change the returned list! - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.ghlist.GHlist(GammaH(4,[])); L.list() [(0, 1), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 1), (2, 3), (3, 0), (3, 1), (3, 2), (3, 3)] diff --git a/src/sage/modular/modsym/manin_symbol.pyx b/src/sage/modular/modsym/manin_symbol.pyx index 8f4ee73d32d..be67254638d 100644 --- a/src/sage/modular/modsym/manin_symbol.pyx +++ b/src/sage/modular/modsym/manin_symbol.pyx @@ -275,7 +275,7 @@ cdef class ManinSymbol(Element): Not implemented for raw ManinSymbol objects, only for members of ManinSymbolLists. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.manin_symbol import ManinSymbol sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_gamma0 diff --git a/src/sage/modular/modsym/manin_symbol_list.py b/src/sage/modular/modsym/manin_symbol_list.py index 52fc4299b8d..37395cc387b 100644 --- a/src/sage/modular/modsym/manin_symbol_list.py +++ b/src/sage/modular/modsym/manin_symbol_list.py @@ -533,7 +533,7 @@ def apply_I(self, j): `j`'th symbol with `I`, and `s` is the parity of of the `j`'th symbol (a Python ``int``, either 1 or -1) - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_gamma0 sage: m = ManinSymbolList_gamma0(5,8) @@ -568,7 +568,7 @@ def apply_T(self, j): OUTPUT: see documentation for apply() - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_gamma0 sage: m = ManinSymbolList_gamma0(5,8) @@ -611,7 +611,7 @@ def apply_TT(self, j): OUTPUT: see documentation for apply() - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_gamma0 sage: m = ManinSymbolList_gamma0(5,8) @@ -663,7 +663,7 @@ def apply(self, j, m): `g = [a, b; c, d]` on a Manin symbol `[P(X,Y),(u,v)]` is `[P(aX+bY,cX+dY),(u,v)\*g]`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_gamma0 sage: m = ManinSymbolList_gamma0(5,8) @@ -695,7 +695,7 @@ def normalize(self, x): ``(i,u,v)`` -- (3-tuple of ints) another tuple defining the associated normalized ManinSymbol - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_gamma0 sage: m = ManinSymbolList_gamma0(5,8) @@ -725,7 +725,7 @@ class ManinSymbolList_gamma0(ManinSymbolList_group): - ``weight`` - (integer): the weight. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_gamma0 sage: m = ManinSymbolList_gamma0(5,2); m @@ -778,7 +778,7 @@ class ManinSymbolList_gamma1(ManinSymbolList_group): - ``weight`` - (integer): the weight. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_gamma1 sage: m = ManinSymbolList_gamma1(5,2); m @@ -835,7 +835,7 @@ class ManinSymbolList_gamma_h(ManinSymbolList_group): - ``weight`` - (integer): the weight. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_gamma_h sage: G = GammaH(117, [4]) @@ -861,7 +861,7 @@ def __init__(self, group, weight): r""" Constructor for Manin symbols for `\Gamma_H(N)`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_gamma_h sage: G = GammaH(117, [4]) @@ -905,7 +905,7 @@ class ManinSymbolList_character(ManinSymbolList): - ``weight`` -- (integer) the weight - EXAMPLE:: + EXAMPLES:: sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character @@ -959,7 +959,7 @@ def __repr__(self): """ Standard function returning string representation. - EXAMPLE:: + EXAMPLES:: sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character @@ -1045,7 +1045,7 @@ def apply_S(self, j): on the `j`'th symbol with `S`, and `s` is the parity of the `j`'th symbol. - EXAMPLE:: + EXAMPLES:: sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character @@ -1094,7 +1094,7 @@ def apply_I(self, j): on the `j`'th symbol with `I`, and `s` is the parity of of the `j`'th symbol. - EXAMPLE:: + EXAMPLES:: sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character @@ -1127,7 +1127,7 @@ def apply_T(self, j): sum `c_i*x_i` is the image of self under the right action of the matrix `T`. - EXAMPLE:: + EXAMPLES:: sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character @@ -1169,7 +1169,7 @@ def apply_TT(self, j): sum `c_i*x_i` is the image of self under the right action of the matrix `T^2`. - EXAMPLE:: + EXAMPLES:: sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character @@ -1204,7 +1204,7 @@ def character(self): The Dirichlet character of this Manin symbol list. - EXAMPLE:: + EXAMPLES:: sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character @@ -1233,7 +1233,7 @@ def index(self, x): base field). If there is no Manin symbol equivalent to ``x`` in the list, then ``(-1, 0)`` is returned. - EXAMPLE:: + EXAMPLES:: sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character diff --git a/src/sage/modular/modsym/relation_matrix.py b/src/sage/modular/modsym/relation_matrix.py index 7372694ba4a..43614b18c7a 100644 --- a/src/sage/modular/modsym/relation_matrix.py +++ b/src/sage/modular/modsym/relation_matrix.py @@ -145,7 +145,7 @@ def modI_relations(syms, sign): - ``rels`` - set of pairs of pairs (j, s), where if mod[i] = (j,s), then x_i = s\*x_j (mod S relations) - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.manin_symbol_list.ManinSymbolList_gamma1(4, 3) sage: sage.modular.modsym.relation_matrix.modI_relations(L, 1) @@ -214,7 +214,7 @@ def T_relation_matrix_wtk_g0(syms, mod, field, sparse): OUTPUT: A sparse matrix whose rows correspond to the reduction of the T relations modulo the S and I relations. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.relation_matrix import sparse_2term_quotient, T_relation_matrix_wtk_g0, modS_relations sage: L = sage.modular.modsym.manin_symbol_list.ManinSymbolList_gamma_h(GammaH(36, [17,19]), 2) @@ -284,7 +284,7 @@ def gens_to_basis_matrix(syms, relation_matrix, mod, field, sparse): - ``list`` - integers i, such that the Manin symbols `x_i` are a basis. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.modsym.relation_matrix import sparse_2term_quotient, T_relation_matrix_wtk_g0, gens_to_basis_matrix, modS_relations sage: L = sage.modular.modsym.manin_symbol_list.ManinSymbolList_gamma1(4, 3) @@ -420,7 +420,7 @@ def compute_presentation(syms, sign, field, sparse=None): symbols is a basis for the quotient by the relations. - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.manin_symbol_list.ManinSymbolList_gamma0(8,2) sage: sage.modular.modsym.relation_matrix.compute_presentation(L, 1, GF(9,'a'), True) @@ -473,7 +473,7 @@ def relation_matrix_wtk_g0(syms, sign, field, sparse): - mod is a set of 2-term relations as output by ``sparse_2term_quotient`` - EXAMPLE:: + EXAMPLES:: sage: L = sage.modular.modsym.manin_symbol_list.ManinSymbolList_gamma0(8,2) sage: A = sage.modular.modsym.relation_matrix.relation_matrix_wtk_g0(L, 0, GF(2), True); A diff --git a/src/sage/modular/modsym/space.py b/src/sage/modular/modsym/space.py index f2ea7dad4d0..02c5d024bdc 100644 --- a/src/sage/modular/modsym/space.py +++ b/src/sage/modular/modsym/space.py @@ -931,7 +931,7 @@ def _q_expansion_module(self, prec, algorithm='hecke'): further details. Note that this will not work if ``algorithm=eigen`` and the sign is 0. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(11, 2, base_ring=GF(4,'a')).cuspidal_submodule()._q_expansion_module(prec=4, algorithm="hecke") Vector space of degree 4 and dimension 1 over Finite Field in a of size 2^2 @@ -962,7 +962,7 @@ def _q_expansion_module(self, prec, algorithm='hecke'): def q_eigen_gens(f): r""" Temporary function for internal use. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(11, 4, base_ring=QuadraticField(-7,'b'),sign=1).cuspidal_submodule()._q_expansion_module(prec=5, algorithm="eigen") # indirect doctest Vector space of degree 5 and dimension 2 over Number Field in b with defining polynomial x^2 + 7 @@ -1001,7 +1001,7 @@ def _q_expansion_module_rational(self, prec): - ``prec`` (integer) - number of q-expansion terms to calculate. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(11, 4).cuspidal_submodule()._q_expansion_module_rational(5) Vector space of degree 5 and dimension 2 over Rational Field @@ -1026,7 +1026,7 @@ def q_eigen_gens(f): r""" Temporary function for internal use. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(13, 6).cuspidal_submodule()._q_expansion_module_rational(4) # indirect doctest Vector space of degree 4 and dimension 3 over Rational Field @@ -1244,7 +1244,7 @@ def _q_expansion_basis_eigen(self, prec, names): Return a basis of eigenforms corresponding to this space, which must be new, cuspidal and simple. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(17, 2,sign=1).cuspidal_submodule()._q_expansion_basis_eigen(2, "a") [q + O(q^2)] @@ -1396,7 +1396,7 @@ def hecke_module_of_level(self, level): r""" Alias for ``self.modular_symbols_of_level(level)``. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(11, 2).hecke_module_of_level(22) Modular Symbols space of dimension 7 for Gamma_0(22) of weight 2 with sign 0 over Rational Field @@ -1514,7 +1514,7 @@ def star_decomposition(self): Decompose self into subspaces which are eigenspaces for the star involution. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(Gamma1(19), 2).cuspidal_submodule().star_decomposition() [ @@ -1664,7 +1664,7 @@ def integral_hecke_matrix(self, n): is often (but not always) different from the matrix returned by ``self.hecke_matrix``, even if the latter has integral entries. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(6,4) sage: M.hecke_matrix(3) @@ -1785,7 +1785,7 @@ def _compute_sign_submodule(self, sign, compute_dual=True): OUTPUT: a submodule of self - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(Gamma1(11), 3)._compute_sign_submodule(-1) Modular Symbols subspace of dimension 10 of Modular Symbols space of dimension 20 for Gamma_1(11) of weight 3 with sign 0 and over Rational Field @@ -2379,7 +2379,7 @@ def __init__(self, modsym, A): - ``A`` - matrix of the associated period map - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(2, 8).cuspidal_submodule().integral_period_mapping() # indirect doctest Integral period mapping associated to Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 4 for Gamma_0(2) of weight 8 with sign 0 over Rational Field @@ -2405,7 +2405,7 @@ def __call__(self, x): r""" Evaluate this mapping at an element of the domain. - EXAMPLE:: + EXAMPLES:: sage: M = ModularSymbols(17, 2).cuspidal_submodule().integral_period_mapping() sage: M(vector([1,0,2])) @@ -2421,7 +2421,7 @@ def matrix(self): r""" Return the matrix of this period mapping. - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(11, 2).cuspidal_submodule().integral_period_mapping().matrix() [ 0 1/5] @@ -2435,7 +2435,7 @@ def domain(self): Return the domain of this mapping (which is the ambient space of the corresponding modular symbols space). - EXAMPLE:: + EXAMPLES:: sage: ModularSymbols(17, 2).cuspidal_submodule().integral_period_mapping().domain() Modular Symbols space of dimension 3 for Gamma_0(17) of weight 2 with sign 0 over Rational Field diff --git a/src/sage/modular/overconvergent/genus0.py b/src/sage/modular/overconvergent/genus0.py index e450a71724c..e8f5788f7d5 100644 --- a/src/sage/modular/overconvergent/genus0.py +++ b/src/sage/modular/overconvergent/genus0.py @@ -432,7 +432,7 @@ def _an_element_(self): r""" Return an element of this space (used by the coercion machinery). - EXAMPLE:: + EXAMPLES:: sage: OverconvergentModularForms(3, 2, 1/3, prec=4).an_element() # indirect doctest 3-adic overconvergent modular form of weight-character 2 with q-expansion 9*q + 216*q^2 + 2430*q^3 + O(q^4) @@ -445,7 +445,7 @@ def character(self): the character are unified into the concept of a weight-character, so this returns exactly the same thing as self.weight(). - EXAMPLE:: + EXAMPLES:: sage: OverconvergentModularForms(3, 0, 1/2).character() 0 @@ -462,7 +462,7 @@ def weight(self): the character are unified into the concept of a weight-character, so this returns exactly the same thing as self.character(). - EXAMPLE:: + EXAMPLES:: sage: OverconvergentModularForms(3, 0, 1/2).weight() 0 @@ -479,7 +479,7 @@ def normalising_factor(self): `r`-overconvergent disc in `X_0(p)`, where `f` is the standard uniformiser. - EXAMPLE:: + EXAMPLES:: sage: L. = Qp(7).extension(x^2 - 7) sage: OverconvergentModularForms(7, 0, 1/4, base_ring=L).normalising_factor() @@ -539,7 +539,7 @@ def gen(self, i): r""" Return the ith module generator of self. - EXAMPLE:: + EXAMPLES:: sage: M = OverconvergentModularForms(3, 2, 1/2, prec=4) sage: M.gen(0) @@ -579,7 +579,7 @@ def radius(self): r""" The radius of overconvergence of this space. - EXAMPLE:: + EXAMPLES:: sage: OverconvergentModularForms(3, 0, 1/3).radius() 1/3 @@ -610,7 +610,7 @@ def prec(self): Return the series precision of self. Note that this is different from the `p`-adic precision of the base ring. - EXAMPLE:: + EXAMPLES:: sage: OverconvergentModularForms(3, 0, 1/2).prec() 20 @@ -727,7 +727,7 @@ def zero(self): """ Return the zero of this space. - EXAMPLE:: + EXAMPLES:: sage: K. = Qp(13).extension(x^2-13); M = OverconvergentModularForms(13, 20, radius=1/2, base_ring=K) sage: K.zero() @@ -854,7 +854,7 @@ def hecke_operator(self, f, m): OverconvergentModularFormElement object; the return value will be of the same type. - EXAMPLE:: + EXAMPLES:: sage: M = OverconvergentModularForms(3, 0, 1/2) sage: f = M.1 @@ -886,7 +886,7 @@ def _convert_to_basis(self, qexp): space, to the maximum possible precision (which is the minimum of the `q`-adic precision of the `q`-expansion and the precision of self). - EXAMPLE:: + EXAMPLES:: sage: M = OverconvergentModularForms(2, 0, 1/2) sage: R. = QQ[[]] @@ -1165,7 +1165,7 @@ def _discover_recurrence_matrix(self, use_smithline=True): r""" Does hard work of calculating recurrence matrix, which is cached to avoid doing this every time. - EXAMPLE:: + EXAMPLES:: sage: o = OverconvergentModularForms(3,12,0) sage: o._discover_recurrence_matrix() == o.recurrence_matrix() @@ -1243,7 +1243,7 @@ class OverconvergentModularFormElement(ModuleElement): r""" A class representing an element of a space of overconvergent modular forms. - EXAMPLE:: + EXAMPLES:: sage: K. = Qp(5).extension(x^7 - 5); s = OverconvergentModularForms(5, 6, 1/21, base_ring=K).0 sage: s == loads(dumps(s)) @@ -1254,7 +1254,7 @@ def __init__(self, parent, gexp=None, qexp=None): r""" Create an element of this space. - EXAMPLE:: + EXAMPLES:: sage: OverconvergentModularForms(3, 2, 1/6,prec=5).an_element() # indirect doctest 3-adic overconvergent modular form of weight-character 2 with q-expansion 3*q + 72*q^2 + 810*q^3 + 6096*q^4 + O(q^5) @@ -1326,7 +1326,7 @@ def prec(self): form. (This is not the same as the `p`-adic precision of the coefficients.) - EXAMPLE:: + EXAMPLES:: sage: OverconvergentModularForms(5, 6, 1/3,prec=15).gen(1).prec() 15 @@ -1339,7 +1339,7 @@ def is_eigenform(self): unless this element was explicitly flagged as an eigenform, using the _notify_eigen function. - EXAMPLE:: + EXAMPLES:: sage: M = OverconvergentModularForms(3, 0, 1/2) sage: f = M.eigenfunctions(3)[1] @@ -1356,7 +1356,7 @@ def slope(self): `U_p`-eigenvalue. Raises an error unless this element was explicitly flagged as an eigenform, using the _notify_eigen function. - EXAMPLE:: + EXAMPLES:: sage: M = OverconvergentModularForms(3, 0, 1/2) sage: f = M.eigenfunctions(3)[1] @@ -1376,7 +1376,7 @@ def eigenvalue(self): this element was explicitly flagged as an eigenform, using the _notify_eigen function. - EXAMPLE:: + EXAMPLES:: sage: M = OverconvergentModularForms(3, 0, 1/2) sage: f = M.eigenfunctions(3)[1] @@ -1395,7 +1395,7 @@ def q_expansion(self, prec=None): r""" Return the `q`-expansion of self, to as high precision as it is known. - EXAMPLE:: + EXAMPLES:: sage: OverconvergentModularForms(3, 4, 1/2).gen(0).q_expansion() 1 - 120/13*q - 1080/13*q^2 - 120/13*q^3 - 8760/13*q^4 - 15120/13*q^5 - 1080/13*q^6 - 41280/13*q^7 - 5400*q^8 - 120/13*q^9 - 136080/13*q^10 - 159840/13*q^11 - 8760/13*q^12 - 263760/13*q^13 - 371520/13*q^14 - 15120/13*q^15 - 561720/13*q^16 - 45360*q^17 - 1080/13*q^18 - 823200/13*q^19 + O(q^20) @@ -1414,7 +1414,7 @@ def gexp(self): is `E_k^\ast \times F(g)`, where `g` is the appropriately normalised parameter of `X_0(p)`). - EXAMPLE:: + EXAMPLES:: sage: M = OverconvergentModularForms(3, 0, 1/2) sage: f = M.eigenfunctions(3)[1] @@ -1451,7 +1451,7 @@ def prime(self): r""" If this is a `p`-adic modular form, return `p`. - EXAMPLE:: + EXAMPLES:: sage: OverconvergentModularForms(2, 0, 1/2).an_element().prime() 2 @@ -1462,7 +1462,7 @@ def _notify_eigen(self, eigenvalue): """ Flags this element as an eigenform. It then remembers some extra data. - EXAMPLE:: + EXAMPLES:: sage: OverconvergentModularForms(3, 16, 1/3).eigenfunctions(4) # indirect doctest [...] @@ -1477,7 +1477,7 @@ def is_integral(self): are `p`-adically integral. This should always be the case with eigenfunctions, but sometimes if n is very large this breaks down for unknown reasons! - EXAMPLE:: + EXAMPLES:: sage: M = OverconvergentModularForms(2, 0, 1/3) sage: q = QQ[['q']].gen() @@ -1595,7 +1595,7 @@ def valuation_plot(self, rmax = None): modular form as it approaches the boundary of the overconvergent region. - EXAMPLE:: + EXAMPLES:: sage: o=OverconvergentModularForms(3, 0, 1/2) sage: f=o.eigenfunctions(4)[1] diff --git a/src/sage/modular/overconvergent/hecke_series.py b/src/sage/modular/overconvergent/hecke_series.py index acec842a31f..4922aa87dce 100644 --- a/src/sage/modular/overconvergent/hecke_series.py +++ b/src/sage/modular/overconvergent/hecke_series.py @@ -103,7 +103,7 @@ def compute_G(p, F): the power series `F(q) / F(q^p)`, to the same precision as `F` - EXAMPLE:: + EXAMPLES:: sage: E = sage.modular.overconvergent.hecke_series.eisenstein_series_qexp(2, 12, Zmod(9),normalization="constant") sage: sage.modular.overconvergent.hecke_series.compute_G(3, E) diff --git a/src/sage/modular/overconvergent/weightspace.py b/src/sage/modular/overconvergent/weightspace.py index 5bca264f33b..d569d89c833 100644 --- a/src/sage/modular/overconvergent/weightspace.py +++ b/src/sage/modular/overconvergent/weightspace.py @@ -129,7 +129,7 @@ def __init__(self, p, base_ring): r""" Initialisation function. - EXAMPLE:: + EXAMPLES:: sage: pAdicWeightSpace(17) Space of 17-adic weight-characters defined over '17-adic Field with capped relative precision 20' @@ -145,7 +145,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: pAdicWeightSpace(17)._repr_() "Space of 17-adic weight-characters defined over '17-adic Field with capped relative precision 20'" @@ -156,7 +156,7 @@ def __reduce__(self): r""" Used for pickling. - EXAMPLE:: + EXAMPLES:: sage: pAdicWeightSpace(3).__reduce__() (, (3, 3-adic Field with capped relative precision 20)) @@ -222,7 +222,7 @@ def prime(self): r""" Return the prime `p` such that this is a `p`-adic weight space. - EXAMPLE:: + EXAMPLES:: sage: pAdicWeightSpace(17).prime() 17 @@ -234,7 +234,7 @@ def base_extend(self, R): Extend scalars to the ring R. There must be a canonical coercion map from the present base ring to R. - EXAMPLE:: + EXAMPLES:: sage: W = pAdicWeightSpace(3, QQ) sage: W.base_extend(Qp(3)) @@ -272,7 +272,7 @@ def _coerce_in_wtchar(self, x): Convert in a weight-character whose parent is different from self (with has the prime, but possibly different base ring). - EXAMPLE:: + EXAMPLES:: sage: W1 = pAdicWeightSpace(23, Qp(3)) sage: W2 = pAdicWeightSpace(23, QQ) @@ -299,7 +299,7 @@ def __init__(self, parent): r""" Initialisation function. - EXAMPLE:: + EXAMPLES:: sage: pAdicWeightSpace(17)(0) 0 @@ -313,7 +313,7 @@ def base_extend(self, R): Extend scalars to the base ring R (which must have a canonical map from the current base ring) - EXAMPLE:: + EXAMPLES:: sage: w = pAdicWeightSpace(17, QQ)(3) sage: w.base_extend(Qp(17)) @@ -325,7 +325,7 @@ def is_even(self): r""" Return True if this weight-character sends -1 to +1. - EXAMPLE:: + EXAMPLES:: sage: pAdicWeightSpace(17)(0).is_even() True @@ -346,7 +346,7 @@ def pAdicEisensteinSeries(self, ring, prec=20): Calculate the q-expansion of the p-adic Eisenstein series of given weight-character, normalised so the constant term is 1. - EXAMPLE:: + EXAMPLES:: sage: kappa = pAdicWeightSpace(3)(3, DirichletGroup(3,QQ).0) sage: kappa.pAdicEisensteinSeries(QQ[['q']], 20) @@ -549,7 +549,7 @@ def k(self): If this character is `x \mapsto x^k \chi(x)` for an integer `k` and a Dirichlet character `\chi`, return `k`. - EXAMPLE:: + EXAMPLES:: sage: kappa = pAdicWeightSpace(29)(13, DirichletGroup(29, Qp(29)).0^14) sage: kappa.k() @@ -562,7 +562,7 @@ def chi(self): If this character is `x \mapsto x^k \chi(x)` for an integer `k` and a Dirichlet character `\chi`, return `\chi`. - EXAMPLE:: + EXAMPLES:: sage: kappa = pAdicWeightSpace(29)(13, DirichletGroup(29, Qp(29)).0^14) sage: kappa.chi() @@ -612,7 +612,7 @@ def teichmuller_type(self): type to correspond to the index of the component of weight space in which `\kappa` lies, so we return 1 if `\kappa` is odd and 0 otherwise. - EXAMPLE:: + EXAMPLES:: sage: pAdicWeightSpace(11)(2, DirichletGroup(11,QQ).0).teichmuller_type() 7 @@ -674,7 +674,7 @@ def __init__(self, parent, w, t): mapping 1 + p to w. Here w must be an element of a p-adic field, with finite precision. - EXAMPLE:: + EXAMPLES:: sage: pAdicWeightSpace(17)(1 + 17^2 + O(17^3), 11, False) [1 + 17^2 + O(17^3), 11] diff --git a/src/sage/modular/pollack_stevens/dist.pyx b/src/sage/modular/pollack_stevens/dist.pyx index 8d87832de04..7d5e3b914a7 100644 --- a/src/sage/modular/pollack_stevens/dist.pyx +++ b/src/sage/modular/pollack_stevens/dist.pyx @@ -721,7 +721,7 @@ cdef class Dist(ModuleElement): r""" Check that the precision of ``self`` is sensible. - EXAMPLE:: + EXAMPLES:: sage: D = sage.modular.pollack_stevens.distributions.Symk(2, base=Qp(5)) sage: v = D([1, 2, 3]) @@ -830,7 +830,7 @@ cdef class Dist_vector(Dist): r""" Used for pickling. - EXAMPLE:: + EXAMPLES:: sage: D = sage.modular.pollack_stevens.distributions.Symk(2) sage: x = D([2,3,4]) @@ -1612,7 +1612,7 @@ cdef class Dist_vector(Dist): # r""" # Used in pickling. -# EXAMPLE:: +# EXAMPLES:: # sage: D = OverconvergentDistributions(0, 5, 10) # sage: D([1,2,3,4]).__reduce__() diff --git a/src/sage/modular/pollack_stevens/distributions.py b/src/sage/modular/pollack_stevens/distributions.py index 7b607116197..00e3fb86553 100644 --- a/src/sage/modular/pollack_stevens/distributions.py +++ b/src/sage/modular/pollack_stevens/distributions.py @@ -162,7 +162,7 @@ class Symk_factory(UniqueFactory): on the left rather than the right. - ``dettwist`` (integer or None) -- power of determinant to twist by - EXAMPLE:: + EXAMPLES:: sage: D = Symk(4) sage: loads(dumps(D)) is D @@ -196,7 +196,7 @@ def create_key(self, k, base=None, character=None, adjuster=None, r""" Sanitize input. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.distributions import Symk sage: Symk(6) # indirect doctest @@ -215,7 +215,7 @@ def create_key(self, k, base=None, character=None, adjuster=None, def create_object(self, version, key): r""" - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.distributions import Symk sage: Symk(6) # indirect doctest @@ -348,7 +348,7 @@ def acting_matrix(self, g, M): Return the matrix for the action of `g` on ``self``, truncated to the first `M` moments. - EXAMPLE:: + EXAMPLES:: sage: V = Symk(3) sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 @@ -637,7 +637,7 @@ class Symk_class(OverconvergentDistributions_abstract): def __init__(self, k, base, character, adjuster, act_on_left, dettwist, act_padic, implementation): r""" - EXAMPLE:: + EXAMPLES:: sage: D = sage.modular.pollack_stevens.distributions.Symk(4); D Sym^4 Q^2 @@ -655,7 +655,7 @@ def _an_element_(self): r""" Return a representative element of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.distributions import Symk sage: D = Symk(3, base=QQ); D @@ -741,7 +741,7 @@ def base_extend(self, new_base_ring): r""" Extend scalars to a new base ring. - EXAMPLE:: + EXAMPLES:: sage: Symk(3).base_extend(Qp(3)) Sym^3 Q_3^2 diff --git a/src/sage/modular/pollack_stevens/manin_map.py b/src/sage/modular/pollack_stevens/manin_map.py index 0401c8dd424..9f4e98140bc 100644 --- a/src/sage/modular/pollack_stevens/manin_map.py +++ b/src/sage/modular/pollack_stevens/manin_map.py @@ -250,7 +250,7 @@ def extend_codomain(self, new_codomain, check=True): r""" Extend the codomain of self to new_codomain. There must be a valid conversion operation from the old to the new codomain. This is most often used for extension of scalars from `\QQ` to `\QQ_p`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.manin_map import ManinMap, M2Z sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations diff --git a/src/sage/modular/pollack_stevens/modsym.py b/src/sage/modular/pollack_stevens/modsym.py index dc7f7b1ccb0..7c0ea81dc6a 100644 --- a/src/sage/modular/pollack_stevens/modsym.py +++ b/src/sage/modular/pollack_stevens/modsym.py @@ -1570,7 +1570,7 @@ def padic_lseries(self,*args, **kwds): """ Return the `p`-adic L-series of this modular symbol. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('37a') sage: phi = E.pollack_stevens_modular_symbol() diff --git a/src/sage/modular/pollack_stevens/padic_lseries.py b/src/sage/modular/pollack_stevens/padic_lseries.py index 051effd8243..941ee36eb15 100644 --- a/src/sage/modular/pollack_stevens/padic_lseries.py +++ b/src/sage/modular/pollack_stevens/padic_lseries.py @@ -89,7 +89,7 @@ def __init__(self, symb, gamma=None, quadratic_twist=1, precision=None): r""" Initialize the class - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.padic_lseries import pAdicLseries sage: E = EllipticCurve('11a3') @@ -173,7 +173,7 @@ def __eq__(self, other): r""" Compare ``self`` and ``other``. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('11a') sage: L = E.padic_lseries(11,implementation="pollackstevens",precision=6) # long time @@ -192,7 +192,7 @@ def __ne__(self, other): r""" Compare ``self`` and ``other``. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('11a') sage: L = E.padic_lseries(11,implementation="pollackstevens",precision=6) # long time diff --git a/src/sage/modular/pollack_stevens/sigma0.py b/src/sage/modular/pollack_stevens/sigma0.py index 07dc201d913..ea74d2ba1cf 100644 --- a/src/sage/modular/pollack_stevens/sigma0.py +++ b/src/sage/modular/pollack_stevens/sigma0.py @@ -70,7 +70,7 @@ def __call__(self, x): This is used to allow for other conventions for the action of Sigma0 on the space of distributions. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import _default_adjuster sage: A = _default_adjuster() @@ -151,7 +151,7 @@ class Sigma0_factory(UniqueFactory): a 4-tuple of integers. This is supplied in order to support differing conventions for the action of `2 \times 2` matrices on distributions. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: Sigma0(3) @@ -160,7 +160,7 @@ class Sigma0_factory(UniqueFactory): def create_key(self, N, base_ring=ZZ, adjuster=None): r""" - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: Sigma0.create_key(3) @@ -183,7 +183,7 @@ def create_key(self, N, base_ring=ZZ, adjuster=None): def create_object(self, version, key): r""" - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: Sigma0(3) # indirect doctest @@ -219,7 +219,7 @@ class Sigma0Element(MonoidElement): """ def __init__(self, parent, mat): r""" - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: s = Sigma0(3)([1,4,3,3]) # indirect doctest @@ -230,7 +230,7 @@ def __init__(self, parent, mat): def __hash__(self): r""" - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: s = Sigma0(3)([1,4,3,3]) @@ -245,7 +245,7 @@ def det(self): r""" Return the determinant of this matrix, which is (by assumption) non-zero. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: s = Sigma0(3)([1,4,3,3]) @@ -258,7 +258,7 @@ def _mul_(self, other): r""" Return the product of two Sigma0 elements. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: s = Sigma0(3)([1,4,3,3]) @@ -277,7 +277,7 @@ def _richcmp_(self, other, op): r""" Compare two elements (of a common Sigma0 object). - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: s = Sigma0(3)([1,4,3,3]) @@ -298,7 +298,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: s = Sigma0(3)([1,4,3,3]) @@ -311,7 +311,7 @@ def matrix(self): r""" Return self as a matrix (forgetting the additional data that it is in Sigma0(N)). - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: s = Sigma0(3)([1,4,3,3]) @@ -329,7 +329,7 @@ def inverse(self): r""" Return the inverse of self. This will raise an error if the result is not in the monoid. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: s = Sigma0(3)([1,4,3,13]) @@ -389,7 +389,7 @@ def _richcmp_(self, other, op): r""" Required for pickling. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0, _Sigma0Embedding sage: S = Sigma0(3) @@ -404,7 +404,7 @@ class Sigma0_class(Parent): r""" The class representing the monoid `\Sigma_0(N)`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: S = Sigma0(5); S @@ -424,7 +424,7 @@ def __init__(self, N, base_ring, adjuster): Standard init function. For args documentation see the factory function. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: S = Sigma0(3) # indirect doctest @@ -442,7 +442,7 @@ def _an_element_(self): r""" Return an element of self. This is implemented in a rather dumb way. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: S = Sigma0(3) @@ -456,7 +456,7 @@ def level(self): r""" If this monoid is `\Sigma_0(N)`, return `N`. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: S = Sigma0(3) @@ -469,7 +469,7 @@ def base_ring(self): r""" Return the base ring. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: S = Sigma0(3) @@ -515,7 +515,7 @@ def _element_constructor_(self, x, check=True): - ``check`` (boolean, default True) -- if True, then check that this matrix actually satisfies the conditions. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: S = Sigma0(3) @@ -549,7 +549,7 @@ def _repr_(self): r""" String representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.modular.pollack_stevens.sigma0 import Sigma0 sage: S = Sigma0(3) diff --git a/src/sage/modular/pollack_stevens/space.py b/src/sage/modular/pollack_stevens/space.py index 623bea0d2ae..0c8751ef0d8 100644 --- a/src/sage/modular/pollack_stevens/space.py +++ b/src/sage/modular/pollack_stevens/space.py @@ -290,7 +290,7 @@ def _coerce_map_from_(self, other): r""" Used for comparison and coercion. - EXAMPLE:: + EXAMPLES:: sage: M1 = PollackStevensModularSymbols(Gamma0(11), coefficients=Symk(3)) sage: M2 = PollackStevensModularSymbols(Gamma0(11), coefficients=Symk(3,Qp(11))) diff --git a/src/sage/modular/quatalg/brandt.py b/src/sage/modular/quatalg/brandt.py index 3d8c6b29b0e..ac23ed83553 100644 --- a/src/sage/modular/quatalg/brandt.py +++ b/src/sage/modular/quatalg/brandt.py @@ -526,7 +526,7 @@ def character(self): Always trivial. - EXAMPLE:: + EXAMPLES:: sage: BrandtModule(11,5).character() Dirichlet character modulo 55 of conductor 1 mapping 12 |--> 1, 46 |--> 1 diff --git a/src/sage/modular/ssmod/ssmod.py b/src/sage/modular/ssmod/ssmod.py index 3a3684beba4..00a67f85f29 100644 --- a/src/sage/modular/ssmod/ssmod.py +++ b/src/sage/modular/ssmod/ssmod.py @@ -387,7 +387,7 @@ def __init__(self, prime=2, level=1, base_ring=rings.IntegerRing()): r""" Create a supersingular module. - EXAMPLE:: + EXAMPLES:: sage: SupersingularModule(3) Module of supersingular points on X_0(1)/F_3 over Integer Ring @@ -717,7 +717,7 @@ def upper_bound_on_elliptic_factors(self, p=None, ellmax=2): The prime p is replaced by the smallest prime that doesn't divide the level. - EXAMPLE:: + EXAMPLES:: sage: SupersingularModule(37).upper_bound_on_elliptic_factors() 2 diff --git a/src/sage/modules/fg_pid/fgp_module.py b/src/sage/modules/fg_pid/fgp_module.py index 80ca331f9c3..37ce98f22ec 100644 --- a/src/sage/modules/fg_pid/fgp_module.py +++ b/src/sage/modules/fg_pid/fgp_module.py @@ -622,7 +622,7 @@ def linear_combination_of_smith_form_gens(self, x): Compute a linear combination of the optimised generators of this module as returned by :meth:`.smith_form_gens`. - EXAMPLE:: + EXAMPLES:: sage: X = ZZ**2 / span([[3,0],[0,2]], ZZ) sage: X.linear_combination_of_smith_form_gens([1]) @@ -1358,7 +1358,7 @@ def _hom_general(self, im_gens, check=True): - ``im_gens`` - a Sequence object giving the images of ``self.gens()``, whose universe is some fixed fg R-module - EXAMPLE:: + EXAMPLES:: sage: class SillyModule(sage.modules.fg_pid.fgp_module.FGP_Module_class): ....: def gens(self): @@ -1399,7 +1399,7 @@ def _hom_from_smith(self, im_smith_gens, check=True): - ``im_gens`` -- a Sequence object giving the images of the Smith-form generators of self, whose universe is some fixed fg R-module - EXAMPLE:: + EXAMPLES:: sage: class SillyModule(sage.modules.fg_pid.fgp_module.FGP_Module_class): ....: def gens(self): diff --git a/src/sage/modules/finite_submodule_iter.pyx b/src/sage/modules/finite_submodule_iter.pyx index ef03fea8a54..a0db0eaeab2 100644 --- a/src/sage/modules/finite_submodule_iter.pyx +++ b/src/sage/modules/finite_submodule_iter.pyx @@ -182,7 +182,7 @@ cdef class FiniteZZsubmodule_iterator: def __iter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.modules.finite_submodule_iter import FiniteZZsubmodule_iterator sage: F. = FreeAlgebra(GF(3),3) @@ -441,7 +441,7 @@ cdef class FiniteFieldsubspace_projPoint_iterator: def __iter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.modules.finite_submodule_iter import FiniteFieldsubspace_projPoint_iterator sage: A = MatrixSpace(GF(3), 10,10).one() diff --git a/src/sage/modules/free_module.py b/src/sage/modules/free_module.py index a7a75a1485b..b248f562bfe 100644 --- a/src/sage/modules/free_module.py +++ b/src/sage/modules/free_module.py @@ -980,7 +980,7 @@ def _element_constructor_(self, x, coerce=True, copy=True, check=True): ``check=True``, to account for numerical instability issues. - EXAMPLE:: + EXAMPLES:: sage: M = ZZ^4 sage: M([1,-1,0,1]) #indirect doctest @@ -3500,7 +3500,7 @@ def subspaces(self, dim): - ``dim`` - int, dimension of subspaces to be generated - EXAMPLE:: + EXAMPLES:: sage: V = VectorSpace(GF(3), 5) sage: len(list(V.subspaces(0))) @@ -5107,7 +5107,7 @@ def _element_constructor_(self, e, *args, **kwds): """ Create an element of this vector space. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^4) sage: VS = k.vector_space() @@ -5270,7 +5270,7 @@ def construction(self): Returns the functorial construction of self, namely, the subspace of the ambient module spanned by the given basis. - EXAMPLE:: + EXAMPLES:: sage: M = ZZ^3 sage: W = M.span_of_basis([[1,2,3],[4,5,6]]); W diff --git a/src/sage/modules/free_module_homspace.py b/src/sage/modules/free_module_homspace.py index 17237f382cb..f380906e0bb 100644 --- a/src/sage/modules/free_module_homspace.py +++ b/src/sage/modules/free_module_homspace.py @@ -278,7 +278,7 @@ def identity(self): r""" Return identity morphism in an endomorphism ring. - EXAMPLE:: + EXAMPLES:: sage: V=FreeModule(ZZ,5) sage: H=V.Hom(V) diff --git a/src/sage/modules/free_module_integer.py b/src/sage/modules/free_module_integer.py index 1f57eb25fae..0e97a585b99 100644 --- a/src/sage/modules/free_module_integer.py +++ b/src/sage/modules/free_module_integer.py @@ -197,7 +197,7 @@ class FreeModule_submodule_with_basis_integer(FreeModule_submodule_with_basis_pi and BKZ reduced bases for this free module with respect to the standard Euclidean norm. - EXAMPLE:: + EXAMPLES:: sage: from sage.modules.free_module_integer import IntegerLattice sage: L = IntegerLattice(sage.crypto.gen_lattice(type='modular', m=10, seed=1337, dual=True)); L @@ -309,7 +309,7 @@ def reduced_basis(self): ``self``, where "best" is defined by the Euclidean norm of the first row vector. - EXAMPLE:: + EXAMPLES:: sage: from sage.modules.free_module_integer import IntegerLattice sage: L = IntegerLattice(random_matrix(ZZ, 10, 10), lll_reduce=False) @@ -503,7 +503,7 @@ def HKZ(self, *args, **kwds): An integer matrix which is a HKZ-reduced basis for this lattice. - EXAMPLE:: + EXAMPLES:: sage: from sage.modules.free_module_integer import IntegerLattice sage: L = sage.crypto.gen_lattice(type='random', n=1, m=40, q=2^60, seed=1337, lattice=True) @@ -524,7 +524,7 @@ def volume(self): An integer. - EXAMPLE:: + EXAMPLES:: sage: L = sage.crypto.gen_lattice(m=10, seed=1337, lattice=True) sage: L.volume() @@ -545,7 +545,7 @@ def discriminant(self): An integer. - EXAMPLE:: + EXAMPLES:: sage: L = sage.crypto.gen_lattice(m=10, seed=1337, lattice=True) sage: L.discriminant() @@ -651,7 +651,7 @@ def update_reduced_basis(self, w): Nothing is returned but the internal state is modified. - EXAMPLE:: + EXAMPLES:: sage: from sage.modules.free_module_integer import IntegerLattice sage: A = sage.crypto.gen_lattice(type='random', n=1, m=30, q=2^40, seed=42) diff --git a/src/sage/modules/free_module_morphism.py b/src/sage/modules/free_module_morphism.py index 71ea29df0e6..03f0c243a27 100644 --- a/src/sage/modules/free_module_morphism.py +++ b/src/sage/modules/free_module_morphism.py @@ -334,7 +334,7 @@ def lift(self, x): that the return value is a coset representative of the domain modulo the kernel of the morphism. - EXAMPLE:: + EXAMPLES:: sage: X = QQ**2 sage: V = X.span([[2, 0], [0, 8]], ZZ) diff --git a/src/sage/modules/matrix_morphism.py b/src/sage/modules/matrix_morphism.py index 553e1c77edf..367de21420d 100644 --- a/src/sage/modules/matrix_morphism.py +++ b/src/sage/modules/matrix_morphism.py @@ -1354,7 +1354,7 @@ def is_injective(self): """ Tell whether ``self`` is injective. - EXAMPLE:: + EXAMPLES:: sage: V1 = QQ^2 sage: V2 = QQ^3 diff --git a/src/sage/modules/vector_double_dense.pyx b/src/sage/modules/vector_double_dense.pyx index ef88217e798..cfe3df2f00a 100644 --- a/src/sage/modules/vector_double_dense.pyx +++ b/src/sage/modules/vector_double_dense.pyx @@ -139,7 +139,7 @@ cdef class Vector_double_dense(FreeModuleElement): """ Return a copy of the vector - EXAMPLE:: + EXAMPLES:: sage: a = vector(RDF, range(9)) sage: a == copy(a) @@ -220,7 +220,7 @@ cdef class Vector_double_dense(FreeModuleElement): """ Return the length of the vector. - EXAMPLE:: + EXAMPLES:: sage: v = vector(RDF, 5); v (0.0, 0.0, 0.0, 0.0, 0.0) @@ -362,7 +362,7 @@ cdef class Vector_double_dense(FreeModuleElement): """ Multiply a scalar and vector - EXAMPLE:: + EXAMPLES:: sage: v = vector(CDF, range(3)) sage: 3*v @@ -379,7 +379,7 @@ cdef class Vector_double_dense(FreeModuleElement): """ Multiply a scalar and vector - EXAMPLE:: + EXAMPLES:: sage: v = vector(CDF, range(3)) sage: v*3 @@ -678,7 +678,7 @@ cdef class Vector_double_dense(FreeModuleElement): """ Calculate the arithmetic mean of the vector. - EXAMPLE:: + EXAMPLES:: sage: v = vector(RDF, range(9)) sage: w = vector(CDF, [k+(9-k)*I for k in range(9)]) @@ -750,7 +750,7 @@ cdef class Vector_double_dense(FreeModuleElement): subtracted from the result to give 0.0 for a normal distribution. (Paragraph from the scipy.stats docstring.) - EXAMPLE:: + EXAMPLES:: sage: v = vector(RDF, range(9)) sage: w = vector(CDF, [k+(9-k)*I for k in range(9)]) diff --git a/src/sage/modules/vector_mod2_dense.pyx b/src/sage/modules/vector_mod2_dense.pyx index 9246fb47010..910a71bccdd 100644 --- a/src/sage/modules/vector_mod2_dense.pyx +++ b/src/sage/modules/vector_mod2_dense.pyx @@ -48,7 +48,7 @@ from sage.libs.m4ri cimport * cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): cdef _new_c(self): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),3) sage: VS([0,0,1]) @@ -63,7 +63,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): cdef bint is_dense_c(self): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),3) sage: VS([0,0,1]).is_dense() @@ -73,7 +73,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): cdef bint is_sparse_c(self): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),3) sage: VS([0,0,1]).is_sparse() @@ -83,7 +83,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): def __copy__(self): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),10^4) sage: v = VS.random_element() @@ -102,7 +102,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): cdef _init(self, Py_ssize_t degree, parent): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),3) sage: VS([0,0,1]) @@ -119,7 +119,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): def __cinit__(self, parent=None, x=None, coerce=True, copy=True): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),3) sage: VS((0,0,1/3)) @@ -134,7 +134,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): def __init__(self, parent, x, coerce=True, copy=True): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),3) sage: VS((0,0,1/3)) @@ -210,7 +210,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): def __dealloc__(self): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),10^3) sage: import gc @@ -283,7 +283,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): def __reduce__(self): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),10^4) sage: e = VS.random_element() @@ -294,7 +294,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): cpdef _add_(self, right): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),10) sage: e = VS([0,0,1,1,0,0,1,1,0,0]) @@ -309,7 +309,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): cpdef _sub_(self, right): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),10) sage: e = VS([0,0,1,1,0,0,1,1,0,0]) @@ -386,7 +386,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): cpdef _pairwise_product_(self, Vector right): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),10) sage: e = VS.random_element(); e @@ -439,7 +439,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): cpdef _neg_(self): """ - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),10) sage: e = VS.random_element() @@ -456,7 +456,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): - ``copy`` - always ``True`` - EXAMPLE:: + EXAMPLES:: sage: VS = VectorSpace(GF(2),10) sage: e = VS.random_element(); e @@ -477,7 +477,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): def unpickle_v0(parent, entries, degree, is_mutable): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.modules.vector_mod2_dense import unpickle_v0 sage: VS = VectorSpace(GF(2),10) diff --git a/src/sage/modules/vector_space_homspace.py b/src/sage/modules/vector_space_homspace.py index b023b9ceb6a..1dc3924457f 100644 --- a/src/sage/modules/vector_space_homspace.py +++ b/src/sage/modules/vector_space_homspace.py @@ -402,7 +402,7 @@ def _repr_(self): r""" Text representation of a space of vector space morphisms. - EXAMPLE:: + EXAMPLES:: sage: H = Hom(QQ^2, QQ^3) sage: H._repr_().split(' ') diff --git a/src/sage/modules/vector_space_morphism.py b/src/sage/modules/vector_space_morphism.py index 3906e38331f..22456847516 100644 --- a/src/sage/modules/vector_space_morphism.py +++ b/src/sage/modules/vector_space_morphism.py @@ -920,7 +920,7 @@ def _latex_(self): r""" A LaTeX representation of this vector space morphism. - EXAMPLE:: + EXAMPLES:: sage: H = Hom(QQ^3, QQ^2) sage: f = H(matrix(3, 2, range(6))) @@ -941,7 +941,7 @@ def _repr_(self): r""" A text representation of this vector space morphism. - EXAMPLE:: + EXAMPLES:: sage: H = Hom(QQ^3, QQ^2) sage: f = H(matrix(3, 2, range(6))) diff --git a/src/sage/numerical/backends/coin_backend.pyx b/src/sage/numerical/backends/coin_backend.pyx index b1305e81312..623d26931e9 100644 --- a/src/sage/numerical/backends/coin_backend.pyx +++ b/src/sage/numerical/backends/coin_backend.pyx @@ -44,7 +44,7 @@ cdef class CoinBackend(GenericBackend): """ Cython constructor - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -98,7 +98,7 @@ cdef class CoinBackend(GenericBackend): OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -184,7 +184,7 @@ cdef class CoinBackend(GenericBackend): OUTPUT: The index of the variable created last. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -261,7 +261,7 @@ cdef class CoinBackend(GenericBackend): * 0 Binary * -1 Real - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -294,7 +294,7 @@ cdef class CoinBackend(GenericBackend): * +1 => Maximization * -1 => Minimization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -317,7 +317,7 @@ cdef class CoinBackend(GenericBackend): - ``coeff`` (double) -- its coefficient or ``None`` for reading (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional -- cbc @@ -345,7 +345,7 @@ cdef class CoinBackend(GenericBackend): - ``d`` (double) -- the constant term in the linear function (set to `0` by default) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -383,7 +383,7 @@ cdef class CoinBackend(GenericBackend): - ``level`` (integer) -- From 0 (no verbosity) to 3. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -400,7 +400,7 @@ cdef class CoinBackend(GenericBackend): - ``i`` -- index of the constraint to remove - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='Coin') # optional - cbc sage: v = p.new_variable(nonnegative=True) # optional - cbc @@ -441,7 +441,7 @@ cdef class CoinBackend(GenericBackend): - ``constraints`` -- an interable containing the indices of the rows to remove - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='Coin') # optional - cbc sage: v = p.new_variable(nonnegative=True) # optional - cbc @@ -504,7 +504,7 @@ cdef class CoinBackend(GenericBackend): - ``name`` - an optional name for this row (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -554,7 +554,7 @@ cdef class CoinBackend(GenericBackend): associates their coefficient on the model of the ``add_linear_constraint`` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -599,7 +599,7 @@ cdef class CoinBackend(GenericBackend): to ``None`` if the constraint is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -635,7 +635,7 @@ cdef class CoinBackend(GenericBackend): to ``None`` if the variable is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -678,7 +678,7 @@ cdef class CoinBackend(GenericBackend): ``indices`` and ``coeffs`` are expected to be of the same length. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -716,7 +716,7 @@ cdef class CoinBackend(GenericBackend): the solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -786,7 +786,7 @@ cdef class CoinBackend(GenericBackend): Has no meaning unless ``solve`` or ``set_basis_status`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -813,7 +813,7 @@ cdef class CoinBackend(GenericBackend): Has no meaning unless ``solve`` or ``set_basis_status`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -852,7 +852,7 @@ cdef class CoinBackend(GenericBackend): r""" Returns the number of columns/variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -870,7 +870,7 @@ cdef class CoinBackend(GenericBackend): r""" Returns the number of rows/constraints. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -891,7 +891,7 @@ cdef class CoinBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -917,7 +917,7 @@ cdef class CoinBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -941,7 +941,7 @@ cdef class CoinBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -963,7 +963,7 @@ cdef class CoinBackend(GenericBackend): r""" Tests whether the problem is a maximization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -988,7 +988,7 @@ cdef class CoinBackend(GenericBackend): variable has not upper bound. When set to ``False`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -1032,7 +1032,7 @@ cdef class CoinBackend(GenericBackend): variable has not lower bound. When set to ``False`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -1072,7 +1072,7 @@ cdef class CoinBackend(GenericBackend): - ``filename`` (string) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -1094,7 +1094,7 @@ cdef class CoinBackend(GenericBackend): - ``filename`` (string) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -1117,7 +1117,7 @@ cdef class CoinBackend(GenericBackend): - ``name`` (``char *``) -- the problem's name. When set to ``NULL`` (default), the method returns the problem's name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -1142,7 +1142,7 @@ cdef class CoinBackend(GenericBackend): - ``index`` (integer) -- the row's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -1163,7 +1163,7 @@ cdef class CoinBackend(GenericBackend): - ``index`` (integer) -- the col's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -1181,7 +1181,7 @@ cdef class CoinBackend(GenericBackend): """ Returns a copy of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = MixedIntegerLinearProgram(solver = "Coin") # optional - cbc @@ -1232,7 +1232,7 @@ cdef class CoinBackend(GenericBackend): has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -1577,7 +1577,7 @@ cdef class CoinBackend(GenericBackend): Has no meaning unless ``solve`` or ``set_basis_status`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -1616,7 +1616,7 @@ cdef class CoinBackend(GenericBackend): Has no meaning unless ``solve`` or ``set_basis_status`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc @@ -1653,7 +1653,7 @@ cdef class CoinBackend(GenericBackend): Has no meaning unless ``solve`` or ``set_basis_status`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Coin") # optional - cbc diff --git a/src/sage/numerical/backends/cplex_backend.pyx b/src/sage/numerical/backends/cplex_backend.pyx index 2a7838bbaed..7da4a26b990 100644 --- a/src/sage/numerical/backends/cplex_backend.pyx +++ b/src/sage/numerical/backends/cplex_backend.pyx @@ -36,7 +36,7 @@ cdef class CPLEXBackend(GenericBackend): """ Constructor - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.mip import MixedIntegerLinearProgram # optional - CPLEX sage: p = MixedIntegerLinearProgram(solver="CPLEX") # optional - CPLEX @@ -83,7 +83,7 @@ cdef class CPLEXBackend(GenericBackend): OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -172,7 +172,7 @@ cdef class CPLEXBackend(GenericBackend): OUTPUT: The index of the variable created last. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -256,7 +256,7 @@ cdef class CPLEXBackend(GenericBackend): * 0 Binary * -1 Real - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -293,7 +293,7 @@ cdef class CPLEXBackend(GenericBackend): * +1 => Maximization * -1 => Minimization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -317,7 +317,7 @@ cdef class CPLEXBackend(GenericBackend): - ``coeff`` (double) -- its coefficient or ``None`` for reading (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional -- CPLEX @@ -352,7 +352,7 @@ cdef class CPLEXBackend(GenericBackend): - ``name`` (``char *``) -- the problem's name. When set to ``NULL`` (default), the method returns the problem's name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -390,7 +390,7 @@ cdef class CPLEXBackend(GenericBackend): - ``d`` (double) -- the constant term in the linear function (set to `0` by default) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -439,7 +439,7 @@ cdef class CPLEXBackend(GenericBackend): - ``level`` (integer) -- From 0 (no verbosity) to 3. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -463,7 +463,7 @@ cdef class CPLEXBackend(GenericBackend): - ``i`` -- index of the constraint to remove - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='CPLEX')# optional - CPLEX sage: var = p.new_variable(nonnegative=True) # optional - CPLEX @@ -498,7 +498,7 @@ cdef class CPLEXBackend(GenericBackend): - ``names`` - an optional list of names (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -577,7 +577,7 @@ cdef class CPLEXBackend(GenericBackend): - ``name`` - an optional name for this row (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -672,7 +672,7 @@ cdef class CPLEXBackend(GenericBackend): associates their coefficient on the model of the ``add_linear_constraint`` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -721,7 +721,7 @@ cdef class CPLEXBackend(GenericBackend): to ``None`` if the constraint is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -769,7 +769,7 @@ cdef class CPLEXBackend(GenericBackend): to ``None`` if the variable is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -816,7 +816,7 @@ cdef class CPLEXBackend(GenericBackend): ``indices`` and ``coeffs`` are expected to be of the same length. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -938,7 +938,7 @@ cdef class CPLEXBackend(GenericBackend): Has no meaning unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -984,7 +984,7 @@ cdef class CPLEXBackend(GenericBackend): ``CPLEX`` has already solved the model to optimality but continues to search for additional solutions. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="CPLEX") # optional - CPLEX sage: b = p.new_variable(binary=True) # optional - CPLEX @@ -1023,7 +1023,7 @@ cdef class CPLEXBackend(GenericBackend): Has no meaning unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="CPLEX") # optional - CPLEX sage: b = p.new_variable(binary=True) # optional - CPLEX @@ -1053,7 +1053,7 @@ cdef class CPLEXBackend(GenericBackend): Has no meaning unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1086,7 +1086,7 @@ cdef class CPLEXBackend(GenericBackend): r""" Returns the number of columns/variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1104,7 +1104,7 @@ cdef class CPLEXBackend(GenericBackend): r""" Returns the number of rows/constraints. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1125,7 +1125,7 @@ cdef class CPLEXBackend(GenericBackend): - ``index`` (integer) -- the row's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1158,7 +1158,7 @@ cdef class CPLEXBackend(GenericBackend): - ``index`` (integer) -- the col's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1191,7 +1191,7 @@ cdef class CPLEXBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1227,7 +1227,7 @@ cdef class CPLEXBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1262,7 +1262,7 @@ cdef class CPLEXBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1296,7 +1296,7 @@ cdef class CPLEXBackend(GenericBackend): r""" Tests whether the problem is a maximization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1321,7 +1321,7 @@ cdef class CPLEXBackend(GenericBackend): variable has not upper bound. When set to ``False`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1373,7 +1373,7 @@ cdef class CPLEXBackend(GenericBackend): variable has not lower bound. When set to ``False`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1421,7 +1421,7 @@ cdef class CPLEXBackend(GenericBackend): - ``filename`` (string) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1445,7 +1445,7 @@ cdef class CPLEXBackend(GenericBackend): - ``filename`` (string) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = get_solver(solver = "CPLEX") # optional - CPLEX @@ -1465,7 +1465,7 @@ cdef class CPLEXBackend(GenericBackend): r""" Returns a copy of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - CPLEX sage: p = MixedIntegerLinearProgram(solver = "CPLEX") # optional - CPLEX diff --git a/src/sage/numerical/backends/cvxopt_backend.pyx b/src/sage/numerical/backends/cvxopt_backend.pyx index 136db43d936..baa14191302 100644 --- a/src/sage/numerical/backends/cvxopt_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_backend.pyx @@ -30,7 +30,7 @@ cdef class CVXOPTBackend(GenericBackend): There is no support for integer variables. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="CVXOPT") @@ -66,7 +66,7 @@ cdef class CVXOPTBackend(GenericBackend): """ Cython constructor - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -105,7 +105,7 @@ cdef class CVXOPTBackend(GenericBackend): """ Returns a copy of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = MixedIntegerLinearProgram(solver = "CVXOPT") @@ -164,7 +164,7 @@ cdef class CVXOPTBackend(GenericBackend): OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -215,7 +215,7 @@ cdef class CVXOPTBackend(GenericBackend): """ Set the type of a variable. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "cvxopt") @@ -241,7 +241,7 @@ cdef class CVXOPTBackend(GenericBackend): * +1 => Maximization * -1 => Minimization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -267,7 +267,7 @@ cdef class CVXOPTBackend(GenericBackend): - ``coeff`` (double) -- its coefficient - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -295,7 +295,7 @@ cdef class CVXOPTBackend(GenericBackend): - ``d`` (double) -- the constant term in the linear function (set to `0` by default) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -338,7 +338,7 @@ cdef class CVXOPTBackend(GenericBackend): ``indices`` and ``coeffs`` are expected to be of the same length. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -381,7 +381,7 @@ cdef class CVXOPTBackend(GenericBackend): - ``name`` - an optional name for this row (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -418,7 +418,7 @@ cdef class CVXOPTBackend(GenericBackend): the solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver = "cvxopt", maximization=False) sage: x=p.new_variable(nonnegative=True) @@ -571,7 +571,7 @@ cdef class CVXOPTBackend(GenericBackend): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "cvxopt") @@ -603,7 +603,7 @@ cdef class CVXOPTBackend(GenericBackend): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -627,7 +627,7 @@ cdef class CVXOPTBackend(GenericBackend): """ Return the number of columns/variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -645,7 +645,7 @@ cdef class CVXOPTBackend(GenericBackend): """ Return the number of rows/constraints. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -664,7 +664,7 @@ cdef class CVXOPTBackend(GenericBackend): """ Test whether the problem is a maximization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -688,7 +688,7 @@ cdef class CVXOPTBackend(GenericBackend): - ``name`` (``char *``) -- the problem's name. When set to ``NULL`` (default), the method returns the problem's name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -718,7 +718,7 @@ cdef class CVXOPTBackend(GenericBackend): associates their coefficient on the model of the ``add_linear_constraint`` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -755,7 +755,7 @@ cdef class CVXOPTBackend(GenericBackend): to ``None`` if the constraint is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -783,7 +783,7 @@ cdef class CVXOPTBackend(GenericBackend): to ``None`` if the variable is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -806,7 +806,7 @@ cdef class CVXOPTBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -833,7 +833,7 @@ cdef class CVXOPTBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -860,7 +860,7 @@ cdef class CVXOPTBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -888,7 +888,7 @@ cdef class CVXOPTBackend(GenericBackend): - ``index`` (integer) -- the row's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -911,7 +911,7 @@ cdef class CVXOPTBackend(GenericBackend): - ``name`` (``char *``) -- its name. When set to ``NULL`` (default), the method returns the current name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -936,7 +936,7 @@ cdef class CVXOPTBackend(GenericBackend): variable has not upper bound. When set to ``None`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -965,7 +965,7 @@ cdef class CVXOPTBackend(GenericBackend): variable has not lower bound. When set to ``None`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver @@ -999,7 +999,7 @@ cdef class CVXOPTBackend(GenericBackend): The list of available parameters is available at :meth:`~sage.numerical.mip.MixedIntegerLinearProgram.solver_parameter`. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "CVXOPT") diff --git a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx index b65d4bc1df0..f8c07e26b2f 100644 --- a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx @@ -41,7 +41,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): """ Cython constructor - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -74,7 +74,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): """ Get a block of a matrix coefficient - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(solver="cvxopt") sage: x = p.new_variable() @@ -106,7 +106,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -152,7 +152,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): OUTPUT: The index of the variable created last. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -181,7 +181,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): * +1 => Maximization * -1 => Minimization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -207,7 +207,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): - ``coeff`` (double) -- its coefficient - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -235,7 +235,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): - ``d`` (double) -- the constant term in the linear function (set to `0` by default) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -264,7 +264,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): - ``name`` - an optional name for this row (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -307,7 +307,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): - ``names`` - an optional list of names (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -333,7 +333,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): the solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) sage: x = p.new_variable() @@ -436,7 +436,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) sage: x = p.new_variable() @@ -497,7 +497,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "cvxopt") @@ -531,7 +531,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): """ Return the number of columns/variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -549,7 +549,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): """ Return the number of rows/constraints. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -568,7 +568,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): """ Test whether the problem is a maximization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -592,7 +592,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): - ``name`` (``char *``) -- the problem's name. When set to ``NULL`` (default), the method returns the problem's name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -620,7 +620,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): associates their coefficient on the model of the ``add_linear_constraint`` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -657,7 +657,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): The matrix of the `i`-th dual variable - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') sage: x = p.new_variable() @@ -708,7 +708,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): The matrix of the slack of the `i`-th constraint - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') sage: x = p.new_variable() @@ -756,7 +756,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): - ``index`` (integer) -- the row's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -780,7 +780,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): - ``name`` (``char *``) -- its name. When set to ``NULL`` (default), the method returns the current name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") @@ -811,7 +811,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend): The list of available parameters is available at :meth:`~sage.numerical.sdp.SemidefiniteProgram.solver_parameter`. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "CVXOPT") diff --git a/src/sage/numerical/backends/generic_backend.pyx b/src/sage/numerical/backends/generic_backend.pyx index 613e7568fc9..7944e8a6154 100644 --- a/src/sage/numerical/backends/generic_backend.pyx +++ b/src/sage/numerical/backends/generic_backend.pyx @@ -69,7 +69,7 @@ cdef class GenericBackend: OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -123,7 +123,7 @@ cdef class GenericBackend: OUTPUT: The index of the variable created last. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -218,7 +218,7 @@ cdef class GenericBackend: * 0 Binary * -1 Continuous - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -243,7 +243,7 @@ cdef class GenericBackend: * +1 => Maximization * -1 => Minimization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -288,7 +288,7 @@ cdef class GenericBackend: - ``coeff`` (double) -- its coefficient - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -310,7 +310,7 @@ cdef class GenericBackend: - ``d`` (double) -- its coefficient. If `None` (default), return the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -336,7 +336,7 @@ cdef class GenericBackend: - ``d`` (double) -- the constant term in the linear function (set to `0` by default) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -367,7 +367,7 @@ cdef class GenericBackend: - ``level`` (integer) -- From 0 (no verbosity) to 3. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -383,7 +383,7 @@ cdef class GenericBackend: - ``i`` -- index of the constraint to remove. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver sage: v = p.new_variable(nonnegative=True) # optional - Nonexistent_LP_solver @@ -410,7 +410,7 @@ cdef class GenericBackend: - ``constraints`` -- an iterable containing the indices of the rows to remove. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -444,7 +444,7 @@ cdef class GenericBackend: - ``name`` -- string or ``None``. Optional name for this row. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -490,7 +490,7 @@ cdef class GenericBackend: - ``name`` -- string or ``None``. An optional name for all new rows. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -561,7 +561,7 @@ cdef class GenericBackend: ``indices`` and ``coeffs`` are expected to be of the same length. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -614,7 +614,7 @@ cdef class GenericBackend: - ``names`` - an optional list of names (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -674,7 +674,7 @@ cdef class GenericBackend: the solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -727,7 +727,7 @@ cdef class GenericBackend: Behavior is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -762,7 +762,7 @@ cdef class GenericBackend: Has no meaning unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver sage: b = p.new_variable(binary=True) # optional - Nonexistent_LP_solver @@ -797,7 +797,7 @@ cdef class GenericBackend: Has no meaning unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver sage: b = p.new_variable(binary=True) # optional - Nonexistent_LP_solver @@ -823,7 +823,7 @@ cdef class GenericBackend: Behavior is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -847,7 +847,7 @@ cdef class GenericBackend: """ Return the number of columns/variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -870,7 +870,7 @@ cdef class GenericBackend: """ Return the number of rows/constraints. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -887,7 +887,7 @@ cdef class GenericBackend: """ Test whether the problem is a maximization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -908,7 +908,7 @@ cdef class GenericBackend: - ``name`` (``char *``) -- the problem's name. When set to ``NULL`` (default), the method returns the problem's name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -927,7 +927,7 @@ cdef class GenericBackend: - ``filename`` (string) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -947,7 +947,7 @@ cdef class GenericBackend: - ``filename`` (string) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -963,7 +963,7 @@ cdef class GenericBackend: """ Returns a copy of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -980,7 +980,7 @@ cdef class GenericBackend: """ Returns a copy of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -999,7 +999,7 @@ cdef class GenericBackend: """ Return a deep copy of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1029,7 +1029,7 @@ cdef class GenericBackend: associates their coefficient on the model of the ``add_linear_constraint`` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1057,7 +1057,7 @@ cdef class GenericBackend: to ``None`` if the constraint is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1085,7 +1085,7 @@ cdef class GenericBackend: to ``None`` if the variable is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1107,7 +1107,7 @@ cdef class GenericBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1130,7 +1130,7 @@ cdef class GenericBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1152,7 +1152,7 @@ cdef class GenericBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1177,7 +1177,7 @@ cdef class GenericBackend: - ``index`` (integer) -- the row's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1199,7 +1199,7 @@ cdef class GenericBackend: - ``name`` (``char *``) -- its name. When set to ``NULL`` (default), the method returns the current name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1296,7 +1296,7 @@ cdef class GenericBackend: variable has not upper bound. When set to ``None`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1322,7 +1322,7 @@ cdef class GenericBackend: variable has not lower bound. When set to ``None`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1352,7 +1352,7 @@ cdef class GenericBackend: The list of available parameters is available at :meth:`~sage.numerical.mip.MixedIntegerLinearProgram.solver_parameter`. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1373,7 +1373,7 @@ cdef class GenericBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1403,7 +1403,7 @@ cdef class GenericBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1433,7 +1433,7 @@ cdef class GenericBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1463,7 +1463,7 @@ cdef class GenericBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -1567,7 +1567,7 @@ def default_mip_solver(solver = None): solver does not exist, or is not available, a ``ValueError`` exception is raised. - EXAMPLE:: + EXAMPLES:: sage: former_solver = default_mip_solver() sage: default_mip_solver("GLPK") diff --git a/src/sage/numerical/backends/generic_sdp_backend.pyx b/src/sage/numerical/backends/generic_sdp_backend.pyx index e135736ec47..7ceae78dbc2 100644 --- a/src/sage/numerical/backends/generic_sdp_backend.pyx +++ b/src/sage/numerical/backends/generic_sdp_backend.pyx @@ -71,7 +71,7 @@ cdef class GenericSDPBackend: OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -107,7 +107,7 @@ cdef class GenericSDPBackend: OUTPUT: The index of the variable created last. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -133,7 +133,7 @@ cdef class GenericSDPBackend: * +1 => Maximization * -1 => Minimization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -156,7 +156,7 @@ cdef class GenericSDPBackend: - ``coeff`` (double) -- its coefficient - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -181,7 +181,7 @@ cdef class GenericSDPBackend: - ``d`` (double) -- the constant term in the linear function (set to `0` by default) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -213,7 +213,7 @@ cdef class GenericSDPBackend: - ``name`` - an optional name for this row (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -245,7 +245,7 @@ cdef class GenericSDPBackend: - ``names`` - an optional list of names (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -269,7 +269,7 @@ cdef class GenericSDPBackend: the solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -293,7 +293,7 @@ cdef class GenericSDPBackend: Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -321,7 +321,7 @@ cdef class GenericSDPBackend: Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -345,7 +345,7 @@ cdef class GenericSDPBackend: """ Return the number of columns/variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -363,7 +363,7 @@ cdef class GenericSDPBackend: """ Return the number of rows/constraints. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -380,7 +380,7 @@ cdef class GenericSDPBackend: """ Test whether the problem is a maximization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -401,7 +401,7 @@ cdef class GenericSDPBackend: - ``name`` (``char *``) -- the problem's name. When set to ``NULL`` (default), the method returns the problem's name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -427,7 +427,7 @@ cdef class GenericSDPBackend: associates their coefficient on the model of the ``add_linear_constraint`` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -451,7 +451,7 @@ cdef class GenericSDPBackend: - ``index`` (integer) -- the row's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -473,7 +473,7 @@ cdef class GenericSDPBackend: - ``name`` (``char *``) -- its name. When set to ``NULL`` (default), the method returns the current name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -496,7 +496,7 @@ cdef class GenericSDPBackend: The matrix of the `i`-th dual variable - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(maximization = False,solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver sage: x = p.new_variable() # optional - Nonexistent_LP_solver @@ -542,7 +542,7 @@ cdef class GenericSDPBackend: The matrix of the slack of the `i`-th constraint - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(maximization = False,solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver sage: x = p.new_variable() # optional - Nonexistent_LP_solver @@ -594,7 +594,7 @@ cdef class GenericSDPBackend: The list of available parameters is available at :meth:`~sage.numerical.sdp.SemidefiniteProgram.solver_parameter`. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver @@ -632,7 +632,7 @@ def default_sdp_solver(solver = None): solver does not exist, or is not available, a ``ValueError`` exception is raised. - EXAMPLE:: + EXAMPLES:: sage: former_solver = default_sdp_solver() sage: default_sdp_solver("Cvxopt") @@ -690,7 +690,7 @@ cpdef GenericSDPBackend get_solver(solver = None): - :func:`default_sdp_solver` -- Returns/Sets the default SDP solver. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver sage: p = get_solver() diff --git a/src/sage/numerical/backends/glpk_backend.pyx b/src/sage/numerical/backends/glpk_backend.pyx index fcb3a175d67..89aa68a2053 100644 --- a/src/sage/numerical/backends/glpk_backend.pyx +++ b/src/sage/numerical/backends/glpk_backend.pyx @@ -48,7 +48,7 @@ cdef class GLPKBackend(GenericBackend): """ Constructor - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="GLPK") """ @@ -96,7 +96,7 @@ cdef class GLPKBackend(GenericBackend): OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -176,7 +176,7 @@ cdef class GLPKBackend(GenericBackend): OUTPUT: The index of the variable created last. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -247,7 +247,7 @@ cdef class GLPKBackend(GenericBackend): * 0 Binary * -1 Real - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -280,7 +280,7 @@ cdef class GLPKBackend(GenericBackend): * +1 => Maximization * -1 => Minimization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -306,7 +306,7 @@ cdef class GLPKBackend(GenericBackend): - ``coeff`` (double) -- its coefficient or ``None`` for reading (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -332,7 +332,7 @@ cdef class GLPKBackend(GenericBackend): - ``name`` (``char *``) -- the problem's name. When set to ``NULL`` (default), the method returns the problem's name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -365,7 +365,7 @@ cdef class GLPKBackend(GenericBackend): - ``d`` (double) -- the constant term in the linear function (set to `0` by default) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -392,7 +392,7 @@ cdef class GLPKBackend(GenericBackend): - ``level`` (integer) -- From 0 (no verbosity) to 3. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -420,7 +420,7 @@ cdef class GLPKBackend(GenericBackend): - ``i`` -- index of the constraint to remove - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: x, y = p['x'], p['y'] @@ -459,7 +459,7 @@ cdef class GLPKBackend(GenericBackend): - ``constraints`` -- an iterable containing the indices of the rows to remove. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: x, y = p['x'], p['y'] @@ -596,7 +596,7 @@ cdef class GLPKBackend(GenericBackend): - ``names`` - an optional list of names (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -644,7 +644,7 @@ cdef class GLPKBackend(GenericBackend): associates their coefficient on the model of the ``add_linear_constraint`` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -685,7 +685,7 @@ cdef class GLPKBackend(GenericBackend): to ``None`` if the constraint is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -722,7 +722,7 @@ cdef class GLPKBackend(GenericBackend): to ``None`` if the variable is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -767,7 +767,7 @@ cdef class GLPKBackend(GenericBackend): ``indices`` and ``coeffs`` are expected to be of the same length. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -810,7 +810,7 @@ cdef class GLPKBackend(GenericBackend): (If all variables are continuous, the algorithm reduces to solving the linear program by the simplex method.) - EXAMPLE:: + EXAMPLES:: sage: lp = MixedIntegerLinearProgram(solver = 'GLPK', maximization = False) sage: x, y = lp[0], lp[1] @@ -831,7 +831,7 @@ cdef class GLPKBackend(GenericBackend): the solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -857,7 +857,7 @@ cdef class GLPKBackend(GenericBackend): Thus, if you suspect that your system is infeasible, set the ``preprocessing`` option first. - EXAMPLE:: + EXAMPLES:: sage: lp = MixedIntegerLinearProgram(solver = "GLPK") sage: v = lp.new_variable(nonnegative=True) @@ -880,7 +880,7 @@ cdef class GLPKBackend(GenericBackend): If we switch to "simplex_only", the integrality constraints are ignored, and we get an optimal solution to the continuous relaxation. - EXAMPLE:: + EXAMPLES:: sage: lp = MixedIntegerLinearProgram(solver = 'GLPK', maximization = False) sage: x, y = lp[0], lp[1] @@ -905,7 +905,7 @@ cdef class GLPKBackend(GenericBackend): reconstructs rationals from doubles and also provides results as doubles. - EXAMPLE:: + EXAMPLES:: sage: lp.solver_parameter("simplex_or_intopt", "exact_simplex_only") # use exact simplex only sage: lp.solve() @@ -925,7 +925,7 @@ cdef class GLPKBackend(GenericBackend): Calculating the corresponding basic solution is left as an exercise. - EXAMPLE:: + EXAMPLES:: sage: lp.get_backend().get_row_stat(0) 1 @@ -937,7 +937,7 @@ cdef class GLPKBackend(GenericBackend): rational reconstruction done by ``glp_exact`` and the subsequent conversion to double-precision floating point numbers. - EXAMPLE:: + EXAMPLES:: sage: lp = MixedIntegerLinearProgram(solver = 'GLPK', maximization = True) sage: test = 2^53 - 43 @@ -1051,7 +1051,7 @@ cdef class GLPKBackend(GenericBackend): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1089,7 +1089,7 @@ cdef class GLPKBackend(GenericBackend): Has no meaning unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.CubeGraph(9) sage: p = MixedIntegerLinearProgram(solver="GLPK") @@ -1123,7 +1123,7 @@ cdef class GLPKBackend(GenericBackend): Has no meaning unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.CubeGraph(9) sage: p = MixedIntegerLinearProgram(solver="GLPK") @@ -1157,7 +1157,7 @@ cdef class GLPKBackend(GenericBackend): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1188,7 +1188,7 @@ cdef class GLPKBackend(GenericBackend): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: lp = get_solver(solver = "GLPK") @@ -1217,7 +1217,7 @@ cdef class GLPKBackend(GenericBackend): """ Return the number of columns/variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1234,7 +1234,7 @@ cdef class GLPKBackend(GenericBackend): """ Return the number of rows/constraints. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1255,7 +1255,7 @@ cdef class GLPKBackend(GenericBackend): - ``index`` (integer) -- the col's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1282,7 +1282,7 @@ cdef class GLPKBackend(GenericBackend): - ``index`` (integer) -- the row's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1308,7 +1308,7 @@ cdef class GLPKBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1331,7 +1331,7 @@ cdef class GLPKBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1353,7 +1353,7 @@ cdef class GLPKBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1374,7 +1374,7 @@ cdef class GLPKBackend(GenericBackend): """ Test whether the problem is a maximization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1399,7 +1399,7 @@ cdef class GLPKBackend(GenericBackend): variable has not upper bound. When set to ``False`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1489,7 +1489,7 @@ cdef class GLPKBackend(GenericBackend): variable has not lower bound. When set to ``False`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1576,7 +1576,7 @@ cdef class GLPKBackend(GenericBackend): - ``filename`` (string) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1598,7 +1598,7 @@ cdef class GLPKBackend(GenericBackend): - ``filename`` (string) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1616,7 +1616,7 @@ cdef class GLPKBackend(GenericBackend): """ Returns a copy of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = MixedIntegerLinearProgram(solver = "GLPK") @@ -1848,7 +1848,7 @@ cdef class GLPKBackend(GenericBackend): To date, no attempt has been made to expose the interior point methods. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -1868,7 +1868,7 @@ cdef class GLPKBackend(GenericBackend): but you can switch to the standard simplex algorithm through the ``glp_simplex_or_intopt`` parameter. - EXAMPLE:: + EXAMPLES:: sage: lp = MixedIntegerLinearProgram(solver = 'GLPK', maximization = False) sage: x, y = lp[0], lp[1] @@ -2094,7 +2094,7 @@ cdef class GLPKBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="GLPK") @@ -2124,7 +2124,7 @@ cdef class GLPKBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="GLPK") @@ -2155,7 +2155,7 @@ cdef class GLPKBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="GLPK") @@ -2186,7 +2186,7 @@ cdef class GLPKBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="GLPK") @@ -2228,7 +2228,7 @@ cdef class GLPKBackend(GenericBackend): for the lp using the simplex algorithm. In all other cases an error message is printed. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -2315,7 +2315,7 @@ cdef class GLPKBackend(GenericBackend): If the simplex algorithm has not been used for solving 0.0 will be returned. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: lp = get_solver(solver = "GLPK") @@ -2361,7 +2361,7 @@ cdef class GLPKBackend(GenericBackend): 0.0 will be returned. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK") @@ -2402,7 +2402,7 @@ cdef class GLPKBackend(GenericBackend): * GLP_NF = 4 non-basic free (unbounded) variable * GLP_NS = 5 non-basic fixed variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: lp = get_solver(solver = "GLPK") @@ -2446,7 +2446,7 @@ cdef class GLPKBackend(GenericBackend): * GLP_NF = 4 non-basic free (unbounded) variable * GLP_NS = 5 non-basic fixed variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: lp = get_solver(solver = "GLPK") @@ -2483,7 +2483,7 @@ cdef class GLPKBackend(GenericBackend): - ``stat`` -- The status to set to - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: lp = get_solver(solver = "GLPK") @@ -2518,7 +2518,7 @@ cdef class GLPKBackend(GenericBackend): - ``stat`` -- The status to set to - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: lp = get_solver(solver = "GLPK") @@ -2556,7 +2556,7 @@ cdef class GLPKBackend(GenericBackend): * GLP_ESING The basis matrix is singular within the working precision. * GLP_ECOND The basis matrix is ill-conditioned. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: lp = get_solver(solver = "GLPK") @@ -2616,7 +2616,7 @@ cdef class GLPKBackend(GenericBackend): Elements in ``indices`` have the same sense as index ``k``. All these variables are non-basic by definition. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: lp = get_solver(solver = "GLPK") @@ -2708,7 +2708,7 @@ cdef class GLPKBackend(GenericBackend): Elements in ``indices`` have the same sense as index `k`. All these variables are basic by definition. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: lp = get_solver(solver = "GLPK") diff --git a/src/sage/numerical/backends/glpk_exact_backend.pyx b/src/sage/numerical/backends/glpk_exact_backend.pyx index 98dd2dc9cda..3634346fae0 100644 --- a/src/sage/numerical/backends/glpk_exact_backend.pyx +++ b/src/sage/numerical/backends/glpk_exact_backend.pyx @@ -54,7 +54,7 @@ cdef class GLPKExactBackend(GLPKBackend): """ Constructor - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="GLPK/exact") """ @@ -91,7 +91,7 @@ cdef class GLPKExactBackend(GLPKBackend): OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK/exact") @@ -159,7 +159,7 @@ cdef class GLPKExactBackend(GLPKBackend): OUTPUT: The index of the variable created last. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK/exact") @@ -195,7 +195,7 @@ cdef class GLPKExactBackend(GLPKBackend): * 0 Binary * -1 Real - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "GLPK/exact") diff --git a/src/sage/numerical/backends/glpk_graph_backend.pyx b/src/sage/numerical/backends/glpk_graph_backend.pyx index 5fcee5f9792..91147450b24 100644 --- a/src/sage/numerical/backends/glpk_graph_backend.pyx +++ b/src/sage/numerical/backends/glpk_graph_backend.pyx @@ -189,7 +189,7 @@ cdef class GLPKGraphBackend(object): :class:`Graph`. See documentation of :class:`GLPKGraphBackend` for details. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -247,7 +247,7 @@ cdef class GLPKGraphBackend(object): If no ``name`` is passed as an argument, the new vertex name is returned. ``None`` otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -292,7 +292,7 @@ cdef class GLPKGraphBackend(object): This function is only used when importing a :class:`~sage.graphs.generic_graph.GenericGraph` object. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: g = graphs.PappusGraph() @@ -345,7 +345,7 @@ cdef class GLPKGraphBackend(object): Generated names of new vertices if there is at least one ``None`` value present in ``vertices``. ``None`` otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -394,7 +394,7 @@ cdef class GLPKGraphBackend(object): sink, or `1` to represent a source and `0` for a neutral vertex). This can either be an ``int`` or ``float`` value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -428,7 +428,7 @@ cdef class GLPKGraphBackend(object): to each vertex. For more information, see the documentation of :meth:`set_vertex_demand`. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -466,7 +466,7 @@ cdef class GLPKGraphBackend(object): * "es" -- The earliest start of task (cpp alg) * "ls" -- The latest start of task (cpp alg) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -508,7 +508,7 @@ cdef class GLPKGraphBackend(object): more information, see the documentation of :meth:`GLPKGraphBackend.get_vertex`. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -536,7 +536,7 @@ cdef class GLPKGraphBackend(object): If a vertex in the graph does not have a name / label it will appear as ``None`` in the resulting ``list``. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -575,7 +575,7 @@ cdef class GLPKGraphBackend(object): * ``cost`` -- The cost of transporting one unit through the edge - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -629,7 +629,7 @@ cdef class GLPKGraphBackend(object): triples of the form ``(u, v, params)`` where params is a ``dict`` as described in ``add_edge``. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -661,7 +661,7 @@ cdef class GLPKGraphBackend(object): This function is only used when importing a ``GenericGraph``. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: g = graphs.PappusGraph() @@ -735,7 +735,7 @@ cdef class GLPKGraphBackend(object): * ``cost`` -- The cost of transporting one unit through the edge * ``x`` -- The actual flow through the edge after solving - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -774,7 +774,7 @@ cdef class GLPKGraphBackend(object): A ``list`` of ``triples`` representing the edges of the graph. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -825,7 +825,7 @@ cdef class GLPKGraphBackend(object): - ``vert`` -- The name (as ``str``) of the vertex to delete. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -866,7 +866,7 @@ cdef class GLPKGraphBackend(object): - ``verts`` -- iterable container containing names (as ``str``) of the vertices to delete - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -920,7 +920,7 @@ cdef class GLPKGraphBackend(object): :meth:`delete_edges` - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -994,7 +994,7 @@ cdef class GLPKGraphBackend(object): :meth:`delete_edge` - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -1025,7 +1025,7 @@ cdef class GLPKGraphBackend(object): The index of the vertex or ``-1`` if the vertex is not found - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -1052,7 +1052,7 @@ cdef class GLPKGraphBackend(object): Zero if the operations was successful otherwise nonzero - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -1081,7 +1081,7 @@ cdef class GLPKGraphBackend(object): Zero if the operations was successful otherwise nonzero - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -1106,7 +1106,7 @@ cdef class GLPKGraphBackend(object): Zero if successful, otherwise nonzero - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -1138,7 +1138,7 @@ cdef class GLPKGraphBackend(object): the solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -1203,7 +1203,7 @@ cdef class GLPKGraphBackend(object): ``Zero`` if successful, otherwise ``non-zero`` - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -1259,7 +1259,7 @@ cdef class GLPKGraphBackend(object): solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -1325,7 +1325,7 @@ cdef class GLPKGraphBackend(object): The length of the critical path of the network - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() diff --git a/src/sage/numerical/backends/gurobi_backend.pyx b/src/sage/numerical/backends/gurobi_backend.pyx index 84e0b83af58..a0c92bbbd76 100644 --- a/src/sage/numerical/backends/gurobi_backend.pyx +++ b/src/sage/numerical/backends/gurobi_backend.pyx @@ -49,7 +49,7 @@ cdef class GurobiBackend(GenericBackend): """ Constructor - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="Gurobi") # optional - Gurobi """ @@ -112,7 +112,7 @@ cdef class GurobiBackend(GenericBackend): OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -212,7 +212,7 @@ cdef class GurobiBackend(GenericBackend): ``indices`` and ``coeffs`` are expected to be of the same length. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -241,7 +241,7 @@ cdef class GurobiBackend(GenericBackend): * 0 Binary * -1 Real - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -276,7 +276,7 @@ cdef class GurobiBackend(GenericBackend): * +1 => Maximization * -1 => Minimization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -307,7 +307,7 @@ cdef class GurobiBackend(GenericBackend): - ``coeff`` (double) -- its coefficient or ``None`` for reading (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -340,7 +340,7 @@ cdef class GurobiBackend(GenericBackend): - ``name`` (``char *``) -- the problem's name. When set to ``NULL`` (default), the method returns the problem's name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -382,7 +382,7 @@ cdef class GurobiBackend(GenericBackend): - ``d`` (double) -- the constant term in the linear function (set to `0` by default) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -425,7 +425,7 @@ cdef class GurobiBackend(GenericBackend): - ``level`` (integer) -- From 0 (no verbosity) to 3. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -448,7 +448,7 @@ cdef class GurobiBackend(GenericBackend): - ``i`` -- index of the constraint to remove - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='Gurobi')# optional - Gurobi sage: v = p.new_variable(nonnegative=True) # optional - Gurobi @@ -490,7 +490,7 @@ cdef class GurobiBackend(GenericBackend): - ``name`` - an optional name for this row (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -560,7 +560,7 @@ cdef class GurobiBackend(GenericBackend): associates their coefficient on the model of the ``add_linear_constraint`` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -611,7 +611,7 @@ cdef class GurobiBackend(GenericBackend): to ``None`` if the constraint is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -652,7 +652,7 @@ cdef class GurobiBackend(GenericBackend): to ``None`` if the variable is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -686,7 +686,7 @@ cdef class GurobiBackend(GenericBackend): the solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -721,7 +721,7 @@ cdef class GurobiBackend(GenericBackend): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -752,7 +752,7 @@ cdef class GurobiBackend(GenericBackend): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -781,7 +781,7 @@ cdef class GurobiBackend(GenericBackend): """ Return the number of columns/variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -800,7 +800,7 @@ cdef class GurobiBackend(GenericBackend): """ Return the number of rows/constraints. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -823,7 +823,7 @@ cdef class GurobiBackend(GenericBackend): - ``index`` (integer) -- the col's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -848,7 +848,7 @@ cdef class GurobiBackend(GenericBackend): - ``index`` (integer) -- the row's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -872,7 +872,7 @@ cdef class GurobiBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -897,7 +897,7 @@ cdef class GurobiBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -921,7 +921,7 @@ cdef class GurobiBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -944,7 +944,7 @@ cdef class GurobiBackend(GenericBackend): """ Test whether the problem is a maximization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -970,7 +970,7 @@ cdef class GurobiBackend(GenericBackend): variable has not upper bound. When set to ``False`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -1008,7 +1008,7 @@ cdef class GurobiBackend(GenericBackend): variable has not lower bound. When set to ``False`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -1044,7 +1044,7 @@ cdef class GurobiBackend(GenericBackend): - ``filename`` (string) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -1064,7 +1064,7 @@ cdef class GurobiBackend(GenericBackend): - ``filename`` (string) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = get_solver(solver = "Gurobi") # optional - Gurobi @@ -1162,7 +1162,7 @@ cdef class GurobiBackend(GenericBackend): """ Returns a copy of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver # optional - Gurobi sage: p = MixedIntegerLinearProgram(solver = "GUROBI") # optional - Gurobi diff --git a/src/sage/numerical/backends/interactivelp_backend.pyx b/src/sage/numerical/backends/interactivelp_backend.pyx index 05aec9caf11..d669f4ee4e6 100644 --- a/src/sage/numerical/backends/interactivelp_backend.pyx +++ b/src/sage/numerical/backends/interactivelp_backend.pyx @@ -36,7 +36,7 @@ cdef class InteractiveLPBackend: There is no support for integer variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -54,7 +54,7 @@ cdef class InteractiveLPBackend: """ Cython constructor - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -93,7 +93,7 @@ cdef class InteractiveLPBackend: """ Returns a copy of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = MixedIntegerLinearProgram(solver = "InteractiveLP") @@ -146,7 +146,7 @@ cdef class InteractiveLPBackend: The function raises an error if this pair of bounds cannot be represented by an `InteractiveLPProblem` variable type. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -213,7 +213,7 @@ cdef class InteractiveLPBackend: OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -278,7 +278,7 @@ cdef class InteractiveLPBackend: * 0 Binary * -1 Continuous - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -299,7 +299,7 @@ cdef class InteractiveLPBackend: """ Retrieve all problem data from the LP. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -325,7 +325,7 @@ cdef class InteractiveLPBackend: * +1 => Maximization * -1 => Minimization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -355,7 +355,7 @@ cdef class InteractiveLPBackend: - ``coeff`` (double) -- its coefficient - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -385,7 +385,7 @@ cdef class InteractiveLPBackend: - ``d`` (double) -- its coefficient. If `None` (default), return the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -414,7 +414,7 @@ cdef class InteractiveLPBackend: - ``d`` (real) -- the constant term in the linear function (set to `0` by default) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -461,7 +461,7 @@ cdef class InteractiveLPBackend: - ``level`` (integer) -- From 0 (no verbosity) to 3. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -477,7 +477,7 @@ cdef class InteractiveLPBackend: - ``i`` -- index of the constraint to remove. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="InteractiveLP") sage: v = p.new_variable(nonnegative=True) @@ -519,7 +519,7 @@ cdef class InteractiveLPBackend: - ``name`` -- string or ``None``. Optional name for this row. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -584,7 +584,7 @@ cdef class InteractiveLPBackend: ``indices`` and ``coeffs`` are expected to be of the same length. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -609,7 +609,7 @@ cdef class InteractiveLPBackend: the solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -646,7 +646,7 @@ cdef class InteractiveLPBackend: Behavior is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -677,7 +677,7 @@ cdef class InteractiveLPBackend: Behavior is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -701,7 +701,7 @@ cdef class InteractiveLPBackend: """ Return the number of columns/variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -718,7 +718,7 @@ cdef class InteractiveLPBackend: """ Return the number of rows/constraints. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -734,7 +734,7 @@ cdef class InteractiveLPBackend: """ Test whether the problem is a maximization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -755,7 +755,7 @@ cdef class InteractiveLPBackend: - ``name`` (``char *``) -- the problem's name. When set to ``NULL`` (default), the method returns the problem's name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -786,7 +786,7 @@ cdef class InteractiveLPBackend: associates their coefficient on the model of the ``add_linear_constraint`` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -819,7 +819,7 @@ cdef class InteractiveLPBackend: to ``None`` if the constraint is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -854,7 +854,7 @@ cdef class InteractiveLPBackend: to ``None`` if the variable is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -884,7 +884,7 @@ cdef class InteractiveLPBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -906,7 +906,7 @@ cdef class InteractiveLPBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -927,7 +927,7 @@ cdef class InteractiveLPBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -949,7 +949,7 @@ cdef class InteractiveLPBackend: - ``index`` (integer) -- the row's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -971,7 +971,7 @@ cdef class InteractiveLPBackend: - ``name`` (``char *``) -- its name. When set to ``NULL`` (default), the method returns the current name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -994,7 +994,7 @@ cdef class InteractiveLPBackend: variable has not upper bound. When set to ``None`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -1038,7 +1038,7 @@ cdef class InteractiveLPBackend: variable has no lower bound. When set to ``None`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") @@ -1081,7 +1081,7 @@ cdef class InteractiveLPBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="InteractiveLP") @@ -1111,7 +1111,7 @@ cdef class InteractiveLPBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="InteractiveLP") @@ -1141,7 +1141,7 @@ cdef class InteractiveLPBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="InteractiveLP") @@ -1171,7 +1171,7 @@ cdef class InteractiveLPBackend: - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="InteractiveLP") @@ -1196,7 +1196,7 @@ cdef class InteractiveLPBackend: """ Return a dictionary representing the current basis. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="InteractiveLP") @@ -1231,7 +1231,7 @@ cdef class InteractiveLPBackend: """ Return the :class:`InteractiveLPProblem` object associated with this backend. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="InteractiveLP") diff --git a/src/sage/numerical/backends/ppl_backend.pyx b/src/sage/numerical/backends/ppl_backend.pyx index 8214d8447f4..7908b27632c 100644 --- a/src/sage/numerical/backends/ppl_backend.pyx +++ b/src/sage/numerical/backends/ppl_backend.pyx @@ -59,7 +59,7 @@ cdef class PPLBackend(GenericBackend): """ Constructor - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver = "PPL") @@ -107,7 +107,7 @@ cdef class PPLBackend(GenericBackend): """ Returns a copy of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = MixedIntegerLinearProgram(solver = "PPL") @@ -140,7 +140,7 @@ cdef class PPLBackend(GenericBackend): """ Converting the matrix form of the MIP Problem to PPL MIP_Problem. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver="PPL") @@ -231,7 +231,7 @@ cdef class PPLBackend(GenericBackend): OUTPUT: The index of the newly created variable - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -302,7 +302,7 @@ cdef class PPLBackend(GenericBackend): OUTPUT: The index of the variable created last. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -354,7 +354,7 @@ cdef class PPLBackend(GenericBackend): * 0 Binary * -1 Continuous - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -404,7 +404,7 @@ cdef class PPLBackend(GenericBackend): * +1 => Maximization * -1 => Minimization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -430,7 +430,7 @@ cdef class PPLBackend(GenericBackend): - ``coeff`` (integer) -- its coefficient - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -493,7 +493,7 @@ cdef class PPLBackend(GenericBackend): """ Set the log (verbosity) level. Not Implemented. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -516,7 +516,7 @@ cdef class PPLBackend(GenericBackend): - ``name`` -- an optional name for this row (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="PPL") sage: x = p.new_variable(nonnegative=True) @@ -577,7 +577,7 @@ cdef class PPLBackend(GenericBackend): ``indices`` and ``coeffs`` are expected to be of the same length. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -614,7 +614,7 @@ cdef class PPLBackend(GenericBackend): - ``names`` -- an optional list of names (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -733,7 +733,7 @@ cdef class PPLBackend(GenericBackend): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -757,7 +757,7 @@ cdef class PPLBackend(GenericBackend): """ Return the number of columns/variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -774,7 +774,7 @@ cdef class PPLBackend(GenericBackend): """ Return the number of rows/constraints. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -790,7 +790,7 @@ cdef class PPLBackend(GenericBackend): """ Test whether the problem is a maximization - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -814,7 +814,7 @@ cdef class PPLBackend(GenericBackend): - ``name`` (``char *``) -- the problem's name. When set to ``NULL`` (default), the method returns the problem's name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -841,7 +841,7 @@ cdef class PPLBackend(GenericBackend): associates their coefficient on the model of the ``add_linear_constraint`` method. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -875,7 +875,7 @@ cdef class PPLBackend(GenericBackend): to ``None`` if the constraint is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -903,7 +903,7 @@ cdef class PPLBackend(GenericBackend): to ``None`` if the variable is not bounded in the corresponding direction, and is a real value otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -926,7 +926,7 @@ cdef class PPLBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -947,7 +947,7 @@ cdef class PPLBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -968,7 +968,7 @@ cdef class PPLBackend(GenericBackend): - ``index`` (integer) -- the variable's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -989,7 +989,7 @@ cdef class PPLBackend(GenericBackend): - ``index`` (integer) -- the row's id - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -1012,7 +1012,7 @@ cdef class PPLBackend(GenericBackend): - ``name`` (``char *``) -- its name. When set to ``NULL`` (default), the method returns the current name. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -1037,7 +1037,7 @@ cdef class PPLBackend(GenericBackend): variable has not upper bound. When set to ``None`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") @@ -1069,7 +1069,7 @@ cdef class PPLBackend(GenericBackend): variable has not lower bound. When set to ``None`` (default), the method returns the current value. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "PPL") diff --git a/src/sage/numerical/linear_functions.pyx b/src/sage/numerical/linear_functions.pyx index e921bbe30a8..72b30c1c8fd 100644 --- a/src/sage/numerical/linear_functions.pyx +++ b/src/sage/numerical/linear_functions.pyx @@ -838,7 +838,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): which are integers ). The key ``-1`` corresponds to the constant term. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram() sage: LF = p.linear_functions_parent() @@ -862,7 +862,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): A base ring element. The coefficient of ``x`` in the linear function. Pass ``-1`` for the constant term. - EXAMPLE:: + EXAMPLES:: sage: mip. = MixedIntegerLinearProgram() sage: lf = -8 * b[3] + b[0] - 5; lf @@ -911,7 +911,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): r""" Defining the + operator - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram() sage: LF = p.linear_functions_parent() @@ -928,7 +928,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): r""" Defining the - operator (opposite). - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram() sage: LF = p.linear_functions_parent() @@ -942,7 +942,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): r""" Defining the - operator (substraction). - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram() sage: LF = p.linear_functions_parent() @@ -961,7 +961,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): r""" Multiplication by scalars - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram() sage: LF = p.linear_functions_parent() @@ -1087,7 +1087,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): r""" Returns a string version of the linear function. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: LF = p.linear_functions_parent() @@ -1401,7 +1401,7 @@ cdef class LinearConstraint(LinearFunctionOrConstraint): are the entries of a chained less-or-equal (``<=``) inequality or a chained equality. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram() sage: b = p.new_variable() @@ -1417,7 +1417,7 @@ cdef class LinearConstraint(LinearFunctionOrConstraint): See :class:`LinearConstraint`. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram() sage: b = p.new_variable() @@ -1620,7 +1620,7 @@ cdef class LinearConstraint(LinearFunctionOrConstraint): String. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram() sage: b = p.new_variable() diff --git a/src/sage/numerical/linear_tensor_constraints.py b/src/sage/numerical/linear_tensor_constraints.py index 97d9222460c..b58e17ba636 100644 --- a/src/sage/numerical/linear_tensor_constraints.py +++ b/src/sage/numerical/linear_tensor_constraints.py @@ -141,7 +141,7 @@ class LinearTensorConstraint(Element): constraint is an equality. If ``False``, it is a ``<=`` inequality. - EXAMPLE:: + EXAMPLES:: sage: mip. = MixedIntegerLinearProgram() sage: (b[2]+2*b[3]) * vector([1,2]) <= b[8] * vector([2,3]) - 5 @@ -156,7 +156,7 @@ def __init__(self, parent, lhs, rhs, equality): See :class:`LinearTensorConstraint`. - EXAMPLE:: + EXAMPLES:: sage: mip. = MixedIntegerLinearProgram() sage: b[2] * vector([1,2]) + 2*b[3] <= 0 @@ -272,7 +272,7 @@ def _repr_(self): String. - EXAMPLE:: + EXAMPLES:: sage: mip. = MixedIntegerLinearProgram() sage: b[3] * vector([1,2]) <= (b[8] + 9) * vector([2,3]) diff --git a/src/sage/numerical/linear_tensor_element.pyx b/src/sage/numerical/linear_tensor_element.pyx index 2ab84b04c78..127e94ce5e5 100644 --- a/src/sage/numerical/linear_tensor_element.pyx +++ b/src/sage/numerical/linear_tensor_element.pyx @@ -115,7 +115,7 @@ cdef class LinearTensor(ModuleElement): elements) of the variable represented by the keys (which are integers). The key ``-1`` corresponds to the constant term. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram().linear_functions_parent().tensor(RDF^2) sage: lt = p({0:[1,2], 3:[4,5]}) @@ -139,7 +139,7 @@ cdef class LinearTensor(ModuleElement): A constant, that is, an element of the free module factor. The coefficient of ``x`` in the linear function. - EXAMPLE:: + EXAMPLES:: sage: mip. = MixedIntegerLinearProgram() sage: lt = vector([1,2]) * b[3] + vector([4,5]) * b[0] - 5; lt @@ -273,7 +273,7 @@ cdef class LinearTensor(ModuleElement): A :class:`LinearTensor`. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.linear_functions import LinearFunctionsParent sage: LT = LinearFunctionsParent(RDF).tensor(RDF^2) @@ -293,7 +293,7 @@ cdef class LinearTensor(ModuleElement): A :class:`LinearTensor`. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.linear_functions import LinearFunctionsParent sage: LT = LinearFunctionsParent(RDF).tensor(RDF^2) @@ -317,7 +317,7 @@ cdef class LinearTensor(ModuleElement): A :class:`LinearTensor`. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.linear_functions import LinearFunctionsParent sage: LT = LinearFunctionsParent(RDF).tensor(RDF^2) @@ -343,7 +343,7 @@ cdef class LinearTensor(ModuleElement): A :class:`LinearTensor`. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.linear_functions import LinearFunctionsParent sage: LT = LinearFunctionsParent(RDF).tensor(RDF^2) diff --git a/src/sage/numerical/mip.pyx b/src/sage/numerical/mip.pyx index 7dcd79ac7fa..9b7cf2cd51d 100644 --- a/src/sage/numerical/mip.pyx +++ b/src/sage/numerical/mip.pyx @@ -413,7 +413,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - :meth:`default_mip_solver` -- Returns/Sets the default MIP solver. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(maximization=True) @@ -534,7 +534,7 @@ cdef class MixedIntegerLinearProgram(SageObject): r""" Returns a short description of the ``MixedIntegerLinearProgram``. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -558,7 +558,7 @@ cdef class MixedIntegerLinearProgram(SageObject): r""" Returns a copy of the current ``MixedIntegerLinearProgram`` instance. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -604,7 +604,7 @@ cdef class MixedIntegerLinearProgram(SageObject): """ Return a deep copy of ``self``. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: b = p.new_variable() @@ -640,7 +640,7 @@ cdef class MixedIntegerLinearProgram(SageObject): See :meth:`new_variable` for a way to have separate :class:`MIPVariable`s each of which have their own key space. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: p.set_objective(p['x'] + p['z']) @@ -685,7 +685,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - ``name`` -- A string representing the name of the ``MixedIntegerLinearProgram``. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: p.set_problem_name("Test program") @@ -825,7 +825,7 @@ cdef class MixedIntegerLinearProgram(SageObject): """ Return the default :class:`MIPVariable` of `self`. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: p.default_variable() @@ -876,7 +876,7 @@ cdef class MixedIntegerLinearProgram(SageObject): in the backend if it does not exist, and most methods do not accept this variable as valid input. - EXAMPLE:: + EXAMPLES:: sage: mip = MixedIntegerLinearProgram(solver='GLPK') sage: mip.gen(0) @@ -892,7 +892,7 @@ cdef class MixedIntegerLinearProgram(SageObject): r""" Returns the number of constraints assigned so far. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: p.add_constraint(p[0] - p[2], min = 1, max = 4) @@ -913,7 +913,7 @@ cdef class MixedIntegerLinearProgram(SageObject): equations, by adding extra variables: `c^T x + y = M`, `0 <= y <= M-m`. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: p.add_constraint(p[0] - p[2], max = 4) @@ -1321,7 +1321,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - ``True`` -- Outputs the problem in Free MPS - ``False`` -- Outputs the problem in Fixed MPS - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="GLPK") sage: x = p.new_variable(nonnegative=True) @@ -1347,7 +1347,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - ``filename`` -- The file in which you want the problem to be written. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="GLPK") sage: x = p.new_variable(nonnegative=True) @@ -1384,7 +1384,7 @@ cdef class MixedIntegerLinearProgram(SageObject): While a variable may be declared as binary or integer, its value as returned by the solver is of type ``float``. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: x = p.new_variable(nonnegative=True) @@ -1870,7 +1870,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - ``i`` -- Index of the constraint to remove. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: x, y = p[0], p[1] @@ -1907,7 +1907,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - ``constraints`` -- an iterable containing the indices of the rows to remove. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: x, y = p[0], p[1] @@ -1974,7 +1974,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - ``ee`` -- An instance of ``MIPVariable`` or one of its elements. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: x = p.new_variable(nonnegative=True) @@ -2017,7 +2017,7 @@ cdef class MixedIntegerLinearProgram(SageObject): ``True`` if the variable ``e`` is binary; ``False`` otherwise. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -2039,7 +2039,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - ``ee`` -- An instance of ``MIPVariable`` or one of its elements. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: x = p.new_variable(nonnegative=True) @@ -2081,7 +2081,7 @@ cdef class MixedIntegerLinearProgram(SageObject): ``True`` if the variable ``e`` is an integer; ``False`` otherwise. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -2103,7 +2103,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - ``ee`` -- An instance of ``MIPVariable`` or one of its elements. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: x = p.new_variable(nonnegative=True) @@ -2147,7 +2147,7 @@ cdef class MixedIntegerLinearProgram(SageObject): ``True`` if the variable is real; ``False`` otherwise. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -2258,7 +2258,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - :meth:`get_min` -- get the minimum value of a variable. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -2298,7 +2298,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - ``max`` -- the maximum value the variable can take. When ``max=None``, the variable has no upper bound. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -2337,7 +2337,7 @@ cdef class MixedIntegerLinearProgram(SageObject): Minimum value of the variable, or ``None`` if the variable has no lower bound. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -2368,7 +2368,7 @@ cdef class MixedIntegerLinearProgram(SageObject): Maximum value of the variable, or ``None`` if the variable has no upper bound. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -2451,7 +2451,7 @@ cdef class MixedIntegerLinearProgram(SageObject): - ``value`` -- the parameter's value if it is to be defined, or ``None`` (default) to obtain its current value. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver = "GLPK") sage: p.solver_parameter("timelimit", 60) @@ -2536,7 +2536,7 @@ cdef class MixedIntegerLinearProgram(SageObject): Behaviour is undefined unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver="GLPK") sage: x, y = p[0], p[1] @@ -2565,7 +2565,7 @@ cdef class MixedIntegerLinearProgram(SageObject): Has no meaning unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.CubeGraph(9) sage: p = MixedIntegerLinearProgram(solver="GLPK") @@ -2599,7 +2599,7 @@ cdef class MixedIntegerLinearProgram(SageObject): Has no meaning unless ``solve`` has been called before. - EXAMPLE:: + EXAMPLES:: sage: g = graphs.CubeGraph(9) sage: p = MixedIntegerLinearProgram(solver="GLPK") @@ -2643,7 +2643,7 @@ cdef class MixedIntegerLinearProgram(SageObject): All variables must have 0 as lower bound and no upper bound. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(names=['m'], solver="GLPK") sage: x = p.new_variable(nonnegative=True) @@ -2768,7 +2768,7 @@ class MIPSolverException(RuntimeError): r""" Exception raised when the solver fails. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.mip import MIPSolverException sage: e = MIPSolverException("Error") @@ -2848,7 +2848,7 @@ cdef class MIPVariable(Element): For more informations, see the method ``MixedIntegerLinearProgram.new_variable``. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: p.new_variable(nonnegative=True) @@ -2866,7 +2866,7 @@ cdef class MIPVariable(Element): r""" Returns a copy of ``self``. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: pv = p.new_variable(nonnegative=True) @@ -2888,7 +2888,7 @@ cdef class MIPVariable(Element): r""" Returns a copy of ``self``. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: pv = p.new_variable(nonnegative=True) @@ -2912,7 +2912,7 @@ cdef class MIPVariable(Element): Returns the element asked, otherwise creates it. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -2947,7 +2947,7 @@ cdef class MIPVariable(Element): For this to make sense, ``mip`` should have been obtained as a copy of ``self.mip()``. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: pv = p.new_variable(nonnegative=True) @@ -3052,7 +3052,7 @@ cdef class MIPVariable(Element): r""" Returns a representation of self. - EXAMPLE:: + EXAMPLES:: sage: p=MixedIntegerLinearProgram(solver='GLPK') sage: v=p.new_variable() @@ -3065,7 +3065,7 @@ cdef class MIPVariable(Element): r""" Returns the keys already defined in the dictionary. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -3079,7 +3079,7 @@ cdef class MIPVariable(Element): r""" Returns the pairs (keys,value) contained in the dictionary. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -3093,7 +3093,7 @@ cdef class MIPVariable(Element): r""" Returns the symbolic variables associated to the current dictionary. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) @@ -3107,7 +3107,7 @@ cdef class MIPVariable(Element): r""" Returns the :class:`MixedIntegerLinearProgram` in which ``self`` is a variable. - EXAMPLE:: + EXAMPLES:: sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: v = p.new_variable(nonnegative=True) diff --git a/src/sage/numerical/sdp.pyx b/src/sage/numerical/sdp.pyx index abb78f0c543..bb6d27ba0f3 100644 --- a/src/sage/numerical/sdp.pyx +++ b/src/sage/numerical/sdp.pyx @@ -309,7 +309,7 @@ cdef class SemidefiniteProgram(SageObject): - :meth:`default_sdp_solver` -- Returns/Sets the default SDP solver. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(maximization=True) @@ -378,7 +378,7 @@ cdef class SemidefiniteProgram(SageObject): r""" Returns a short description of the ``SemidefiniteProgram``. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram() sage: x = p.new_variable() @@ -418,7 +418,7 @@ cdef class SemidefiniteProgram(SageObject): This method lets the user define LinearProgram without having to define independent dictionaries when it is not necessary for him. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram() sage: p.set_objective(p['x'] + p['z']) @@ -457,7 +457,7 @@ cdef class SemidefiniteProgram(SageObject): - ``name`` -- A string representing the name of the ``SemidefiniteProgram``. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram() sage: p.set_problem_name("Test program") @@ -488,7 +488,7 @@ cdef class SemidefiniteProgram(SageObject): - ``name`` -- string. Associates a name to the variable. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram() sage: x = p.new_variable() @@ -558,7 +558,7 @@ cdef class SemidefiniteProgram(SageObject): r""" Returns the number of constraints assigned so far. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(solver = "cvxopt") sage: x = p.new_variable() @@ -581,7 +581,7 @@ cdef class SemidefiniteProgram(SageObject): Returns the number of variables used so far. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram() sage: a = matrix([[1, 2.], [2., 3.]]) @@ -700,7 +700,7 @@ cdef class SemidefiniteProgram(SageObject): by its corresponding numerical value. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(solver = "cvxopt", maximization = False) sage: x = p.new_variable() @@ -1011,7 +1011,7 @@ cdef class SemidefiniteProgram(SageObject): The matrix of the slack of the `i`-th constraint - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram(maximization = False) sage: x = p.new_variable() @@ -1064,7 +1064,7 @@ cdef class SemidefiniteProgram(SageObject): - ``value`` -- the parameter's value if it is to be defined, or ``None`` (default) to obtain its current value. - EXAMPLE:: + EXAMPLES:: sage: p. = SemidefiniteProgram(solver = "cvxopt", maximization = False) sage: p.solver_parameter("show_progress", True) @@ -1157,7 +1157,7 @@ class SDPSolverException(RuntimeError): ``SDPSolverException`` is the exception raised when the solver fails. - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.sdp import SDPSolverException sage: SDPSolverException("Error") @@ -1221,7 +1221,7 @@ cdef class SDPVariable(Element): For more informations, see the method ``SemidefiniteProgram.new_variable``. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram() sage: p.new_variable() @@ -1239,7 +1239,7 @@ cdef class SDPVariable(Element): Returns the element asked, otherwise creates it. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram() sage: v = p.new_variable() @@ -1264,7 +1264,7 @@ cdef class SDPVariable(Element): r""" Returns a representation of self. - EXAMPLE:: + EXAMPLES:: sage: p=SemidefiniteProgram() sage: v=p.new_variable() @@ -1277,7 +1277,7 @@ cdef class SDPVariable(Element): r""" Returns the keys already defined in the dictionary. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram() sage: v = p.new_variable() @@ -1291,7 +1291,7 @@ cdef class SDPVariable(Element): r""" Returns the pairs (keys,value) contained in the dictionary. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram() sage: v = p.new_variable() @@ -1306,7 +1306,7 @@ cdef class SDPVariable(Element): r""" Returns the symbolic variables associated to the current dictionary. - EXAMPLE:: + EXAMPLES:: sage: p = SemidefiniteProgram() sage: v = p.new_variable() diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py index 56c516508b8..e909ef5888f 100644 --- a/src/sage/parallel/map_reduce.py +++ b/src/sage/parallel/map_reduce.py @@ -545,7 +545,7 @@ def proc_number(max_proc = None): - ``max_proc`` -- the maximum number of process used - EXAMPLE:: + EXAMPLES:: sage: from sage.parallel.map_reduce import proc_number sage: proc_number() # random @@ -1802,7 +1802,7 @@ class RESetMPExample(RESetMapReduce): This compute the generating series of permutations counted by their size upto size ``maxl``. - EXAMPLE:: + EXAMPLES:: sage: from sage.parallel.map_reduce import RESetMPExample sage: EX = RESetMPExample() @@ -1830,7 +1830,7 @@ def roots(self): r""" Return the empty permutation - EXAMPLE:: + EXAMPLES:: sage: from sage.parallel.map_reduce import RESetMPExample sage: RESetMPExample().roots() @@ -1850,7 +1850,7 @@ def children(self, l): the lists of ``len(l)`` inserted at all possible positions into ``l`` - EXAMPLE:: + EXAMPLES:: sage: from sage.parallel.map_reduce import RESetMPExample sage: RESetMPExample().children([1,0]) @@ -1871,7 +1871,7 @@ def map_function(self, l): ``x^len(l)``. - EXAMPLE:: + EXAMPLES:: sage: from sage.parallel.map_reduce import RESetMPExample sage: RESetMPExample().map_function([1,0]) @@ -1888,7 +1888,7 @@ class RESetParallelIterator(RESetMapReduce): a recursively enumerated sets for which the computations are done in parallel. - EXAMPLE:: + EXAMPLES:: sage: from sage.parallel.map_reduce import RESetParallelIterator sage: S = RESetParallelIterator( [[]], @@ -1904,7 +1904,7 @@ def map_function(self, z): OUTPUT: ``(z, )`` - EXAMPLE:: + EXAMPLES:: sage: from sage.parallel.map_reduce import RESetParallelIterator sage: S = RESetParallelIterator( [[]], @@ -1918,7 +1918,7 @@ def map_function(self, z): def __iter__(self): r""" - EXAMPLE:: + EXAMPLES:: sage: from sage.parallel.map_reduce import RESetParallelIterator sage: S = RESetParallelIterator( [[]], diff --git a/src/sage/plot/animate.py b/src/sage/plot/animate.py index 6f49b471b1d..9fbb39210ad 100644 --- a/src/sage/plot/animate.py +++ b/src/sage/plot/animate.py @@ -1506,7 +1506,7 @@ def _hex2bin(cls, h): even if they look like hex digits. This is used for chunk types. Other characters which are not hex digits are passed verbatim. - EXAMPLE:: + EXAMPLES:: sage: from sage.plot.animate import APngAssembler sage: h2b = APngAssembler._hex2bin @@ -1546,7 +1546,7 @@ def _testData(cls, name, asFile): - ``asFile``: Whether to return a binary string of the named data or the path of a file containing that data. - EXAMPLE:: + EXAMPLES:: sage: from sage.plot.animate import APngAssembler sage: APngAssembler._testData("input1", False) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index a1c236a8cd4..1b1d18a87bb 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -935,7 +935,7 @@ def __getitem__(self, i): """ Returns the ith graphics primitive object: - EXAMPLE:: + EXAMPLES:: sage: G = circle((1,1),2) + circle((2,2),5); print(G) Graphics object consisting of 2 graphics primitives diff --git a/src/sage/plot/plot3d/index_face_set.pyx b/src/sage/plot/plot3d/index_face_set.pyx index 6fc01a4e6d8..5814a44ff1a 100644 --- a/src/sage/plot/plot3d/index_face_set.pyx +++ b/src/sage/plot/plot3d/index_face_set.pyx @@ -746,7 +746,7 @@ cdef class IndexFaceSet(PrimitiveObject): which gives the coordinates of opposite corners of the bounding box. - EXAMPLE:: + EXAMPLES:: sage: x,y = var('x,y') sage: p = plot3d(sqrt(sin(x)*sin(y)), (x,0,2*pi),(y,0,2*pi)) @@ -1155,7 +1155,7 @@ cdef class IndexFaceSet(PrimitiveObject): Graphics3dGroup of stickers - EXAMPLE:: + EXAMPLES:: sage: from sage.plot.plot3d.shapes import Box sage: B = Box(.5,.4,.3, color='black') diff --git a/src/sage/plot/plot3d/parametric_surface.pyx b/src/sage/plot/plot3d/parametric_surface.pyx index cae20439e5b..510a2a28ab9 100644 --- a/src/sage/plot/plot3d/parametric_surface.pyx +++ b/src/sage/plot/plot3d/parametric_surface.pyx @@ -747,7 +747,7 @@ class MoebiusStrip(ParametricSurface): which helps determine the increment for the `v` range for the MoebiusStrip object. - EXAMPLE:: + EXAMPLES:: sage: from sage.plot.plot3d.parametric_surface import MoebiusStrip sage: N = MoebiusStrip(7,3,2) # two twists @@ -766,7 +766,7 @@ class MoebiusStrip(ParametricSurface): Return a tuple for `x,y,z` coordinates for the given ``u`` and ``v`` for this MoebiusStrip instance. - EXAMPLE:: + EXAMPLES:: sage: from sage.plot.plot3d.parametric_surface import MoebiusStrip sage: N = MoebiusStrip(7,3,2) # two twists diff --git a/src/sage/plot/plot3d/plot3d.py b/src/sage/plot/plot3d/plot3d.py index 8e676a3be20..19c2461f8e6 100644 --- a/src/sage/plot/plot3d/plot3d.py +++ b/src/sage/plot/plot3d/plot3d.py @@ -199,7 +199,7 @@ def to_cartesian(self, func, params=None): - ``params`` - The parameters of func. Corresponds to the dependent variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.plot.plot3d.plot3d import _ArbitraryCoordinates sage: x, y, z = var('x y z') @@ -414,7 +414,7 @@ def __init__(self, custom_trans, dep_var, indep_vars): def transform(self, **kwds): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.plot.plot3d.plot3d import _ArbitraryCoordinates sage: x, y, z = var('x y z') @@ -486,7 +486,7 @@ def transform(self, radius=None, azimuth=None, inclination=None): """ A spherical coordinates transform. - EXAMPLE:: + EXAMPLES:: sage: T = Spherical('radius', ['azimuth', 'inclination']) sage: T.transform(radius=var('r'), azimuth=var('theta'), inclination=var('phi')) @@ -599,7 +599,7 @@ def transform(self, radius=None, azimuth=None, elevation=None): """ A spherical elevation coordinates transform. - EXAMPLE:: + EXAMPLES:: sage: T = SphericalElevation('radius', ['azimuth', 'elevation']) sage: T.transform(radius=var('r'), azimuth=var('theta'), elevation=var('phi')) @@ -669,7 +669,7 @@ def transform(self, radius=None, azimuth=None, height=None): """ A cylindrical coordinates transform. - EXAMPLE:: + EXAMPLES:: sage: T = Cylindrical('height', ['azimuth', 'radius']) sage: T.transform(radius=var('r'), azimuth=var('theta'), height=var('z')) diff --git a/src/sage/probability/probability_distribution.pyx b/src/sage/probability/probability_distribution.pyx index 93f283d2151..bf36d833d09 100644 --- a/src/sage/probability/probability_distribution.pyx +++ b/src/sage/probability/probability_distribution.pyx @@ -110,7 +110,7 @@ cdef class ProbabilityDistribution: ``bins``, consisting of the normalised histogram of the random samples. The second list is the bins. - EXAMPLE:: + EXAMPLES:: sage: from sage.probability.probability_distribution import GeneralDiscreteDistribution sage: P = [0.3, 0.4, 0.3] @@ -244,7 +244,7 @@ cdef class SphericalDistribution(ProbabilityDistribution): """ Set the seed for the underlying random number generator. - EXAMPLE:: + EXAMPLES:: sage: T = SphericalDistribution(seed = 0) sage: T.set_seed(100) @@ -257,7 +257,7 @@ cdef class SphericalDistribution(ProbabilityDistribution): Set the gsl random number generator to be one of ``default``, ``luxury``, or ``taus``. - EXAMPLE:: + EXAMPLES:: sage: T = SphericalDistribution() sage: T.set_random_number_generator('default') @@ -287,7 +287,7 @@ cdef class SphericalDistribution(ProbabilityDistribution): """ Get a random sample from the probability distribution. - EXAMPLE:: + EXAMPLES:: sage: T = SphericalDistribution(seed = 0) sage: T.get_random_element() # rel tol 4e-16 @@ -305,7 +305,7 @@ cdef class SphericalDistribution(ProbabilityDistribution): """ This method resets the distribution. - EXAMPLE:: + EXAMPLES:: sage: T = SphericalDistribution(seed = 0) sage: [T.get_random_element() for _ in range(4)] # rel tol 4e-16 @@ -552,7 +552,7 @@ cdef class RealDistribution(ProbabilityDistribution): """ Set the seed for the underlying random number generator. - EXAMPLE:: + EXAMPLES:: sage: T = RealDistribution('gaussian', 1, rng = 'luxury', seed = 10) sage: T.set_seed(100) @@ -566,7 +566,7 @@ cdef class RealDistribution(ProbabilityDistribution): Set the gsl random number generator to be one of ``default``, ``luxury``, or ``taus``. - EXAMPLE:: + EXAMPLES:: sage: T = SphericalDistribution() sage: T.set_random_number_generator('default') @@ -597,7 +597,7 @@ cdef class RealDistribution(ProbabilityDistribution): """ Return the name of the current distribution. - EXAMPLE:: + EXAMPLES:: sage: T = RealDistribution('gaussian', 1) sage: str(T) @@ -612,7 +612,7 @@ cdef class RealDistribution(ProbabilityDistribution): """ Get a random sample from the probability distribution. - EXAMPLE:: + EXAMPLES:: sage: T = RealDistribution('gaussian', 1, seed = 0) sage: T.get_random_element() # rel tol 4e-16 @@ -783,7 +783,7 @@ cdef class RealDistribution(ProbabilityDistribution): """ This method resets the distribution. - EXAMPLE:: + EXAMPLES:: sage: T = RealDistribution('gaussian', 1, seed = 10) sage: [T.get_random_element() for _ in range(10)] # rel tol 4e-16 @@ -845,7 +845,7 @@ cdef class RealDistribution(ProbabilityDistribution): Evaluate the cumulative distribution function of the probability distribution at ``x``. - EXAMPLE:: + EXAMPLES:: sage: T = RealDistribution('uniform', [0, 2]) sage: T.cum_distribution_function(1) @@ -881,7 +881,7 @@ cdef class RealDistribution(ProbabilityDistribution): Evaluate the inverse of the cumulative distribution distribution function of the probability distribution at ``x``. - EXAMPLE:: + EXAMPLES:: sage: T = RealDistribution('uniform', [0, 2]) sage: T.cum_distribution_function_inv(.5) @@ -919,7 +919,7 @@ cdef class RealDistribution(ProbabilityDistribution): distribution. Parameters to ``sage.plot.plot.plot.plot`` can be passed through ``*args`` and ``**kwds``. - EXAMPLE:: + EXAMPLES:: sage: T = RealDistribution('uniform', [0, 2]) sage: P = T.plot() @@ -1007,7 +1007,7 @@ cdef class GeneralDiscreteDistribution(ProbabilityDistribution): Given a list of probabilities P construct an instance of a gsl discrete random variable generator. - EXAMPLE:: + EXAMPLES:: sage: P = [0.3, 0.4, 0.3] sage: X = GeneralDiscreteDistribution(P) @@ -1059,7 +1059,7 @@ cdef class GeneralDiscreteDistribution(ProbabilityDistribution): """ Set the seed to be used by the random number generator. - EXAMPLE:: + EXAMPLES:: sage: X = GeneralDiscreteDistribution([0.3, 0.4, 0.3]) sage: X.set_seed(1) @@ -1074,7 +1074,7 @@ cdef class GeneralDiscreteDistribution(ProbabilityDistribution): """ Set the random number generator to be used by gsl. - EXAMPLE:: + EXAMPLES:: sage: X = GeneralDiscreteDistribution([0.3, 0.4, 0.3]) sage: X.set_random_number_generator('taus') @@ -1100,7 +1100,7 @@ cdef class GeneralDiscreteDistribution(ProbabilityDistribution): """ Get a random sample from the probability distribution. - EXAMPLE:: + EXAMPLES:: sage: P = [0.3, 0.4, 0.3] sage: X = GeneralDiscreteDistribution(P) @@ -1116,7 +1116,7 @@ cdef class GeneralDiscreteDistribution(ProbabilityDistribution): """ This method resets the distribution. - EXAMPLE:: + EXAMPLES:: sage: T = GeneralDiscreteDistribution([0.1, 0.3, 0.6]) sage: T.set_seed(0) diff --git a/src/sage/quadratic_forms/quadratic_form__mass.py b/src/sage/quadratic_forms/quadratic_form__mass.py index 462c5100c61..c52ec478d1f 100644 --- a/src/sage/quadratic_forms/quadratic_form__mass.py +++ b/src/sage/quadratic_forms/quadratic_form__mass.py @@ -46,7 +46,7 @@ def shimura_mass__maximal(self,): a rational number - EXAMPLE:: + EXAMPLES:: sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1]) sage: Q.shimura_mass__maximal() @@ -71,7 +71,7 @@ def GHY_mass__maximal(self): a rational number - EXAMPLE:: + EXAMPLES:: sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1]) sage: Q.GHY_mass__maximal() diff --git a/src/sage/quadratic_forms/quadratic_form__mass__Siegel_densities.py b/src/sage/quadratic_forms/quadratic_form__mass__Siegel_densities.py index 24134281806..9ae1873a5f5 100644 --- a/src/sage/quadratic_forms/quadratic_form__mass__Siegel_densities.py +++ b/src/sage/quadratic_forms/quadratic_form__mass__Siegel_densities.py @@ -429,7 +429,7 @@ def mass_at_two_by_counting_mod_power(self, k): a rational number - EXAMPLE:: + EXAMPLES:: sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1]) sage: Q.mass_at_two_by_counting_mod_power(1) diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py index dcee39e5fdc..9f171d7afca 100644 --- a/src/sage/rings/asymptotic/growth_group.py +++ b/src/sage/rings/asymptotic/growth_group.py @@ -3000,7 +3000,7 @@ def _singularity_analysis_(self, var, zeta, precision): in `T=\frac{1}{1-\frac{z}{\zeta}}\to \infty` where this element is a growth element in `T`. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.asymptotic.growth_group import GrowthGroup sage: G = GrowthGroup('x^QQ') diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx index 9fc5c0fc007..ae1597a6eaa 100644 --- a/src/sage/rings/complex_arb.pyx +++ b/src/sage/rings/complex_arb.pyx @@ -366,7 +366,7 @@ class ComplexBallField(UniqueRepresentation, Field): r""" Return 1 as the only generator is the imaginary unit. - EXAMPLE:: + EXAMPLES:: sage: CBF.ngens() 1 @@ -377,7 +377,7 @@ class ComplexBallField(UniqueRepresentation, Field): r""" For i = 0, return the imaginary unit in this complex ball field. - EXAMPLE:: + EXAMPLES:: sage: CBF.0 1.000000000000000*I @@ -396,7 +396,7 @@ class ComplexBallField(UniqueRepresentation, Field): Return the tuple of generators of this complex ball field, i.e. ``(i,)``. - EXAMPLE:: + EXAMPLES:: sage: CBF.gens() (1.000000000000000*I,) diff --git a/src/sage/rings/complex_double.pyx b/src/sage/rings/complex_double.pyx index 17529945036..4de435bb3aa 100644 --- a/src/sage/rings/complex_double.pyx +++ b/src/sage/rings/complex_double.pyx @@ -106,7 +106,7 @@ def is_ComplexDoubleField(x): """ Return ``True`` if ``x`` is the complex double field. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.complex_double import is_ComplexDoubleField sage: is_ComplexDoubleField(CDF) @@ -133,7 +133,7 @@ cdef class ComplexDoubleField_class(sage.rings.ring.Field): r""" Construct field of complex double precision numbers. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.complex_double import ComplexDoubleField_class sage: CDF == ComplexDoubleField_class() @@ -2530,7 +2530,7 @@ def ComplexDoubleField(): """ Returns the field of double precision complex numbers. - EXAMPLE:: + EXAMPLES:: sage: ComplexDoubleField() Complex Double Field diff --git a/src/sage/rings/complex_number.pyx b/src/sage/rings/complex_number.pyx index ff4212f91c0..c0b0ed25b72 100644 --- a/src/sage/rings/complex_number.pyx +++ b/src/sage/rings/complex_number.pyx @@ -2373,7 +2373,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): INPUT: Type algdep? at the top level prompt. All additional parameters are passed onto the top-level algdep command. - EXAMPLE:: + EXAMPLES:: sage: C = ComplexField() sage: z = (1/2)*(1 + sqrt(3.0) *C.0); z @@ -2401,7 +2401,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): INPUT: Type algdep? at the top level prompt. All additional parameters are passed onto the top-level algdep command. - EXAMPLE:: + EXAMPLES:: sage: C = ComplexField() sage: z = (1/2)*(1 + sqrt(3.0) *C.0); z diff --git a/src/sage/rings/finite_rings/element_base.pyx b/src/sage/rings/finite_rings/element_base.pyx index c253b4035a5..dddbe8f6163 100644 --- a/src/sage/rings/finite_rings/element_base.pyx +++ b/src/sage/rings/finite_rings/element_base.pyx @@ -15,7 +15,7 @@ def is_FiniteFieldElement(x): """ Returns if x is a finite field element. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.finite_rings.element_base import is_FiniteFieldElement sage: is_FiniteFieldElement(1) @@ -485,7 +485,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): r""" Return the multiplicative order of this field element. - EXAMPLE:: + EXAMPLES:: sage: S. = GF(5^3); S Finite Field in a of size 5^3 diff --git a/src/sage/rings/finite_rings/element_givaro.pyx b/src/sage/rings/finite_rings/element_givaro.pyx index d5c3baa4932..00b29ad751e 100644 --- a/src/sage/rings/finite_rings/element_givaro.pyx +++ b/src/sage/rings/finite_rings/element_givaro.pyx @@ -804,7 +804,7 @@ cdef class FiniteField_givaro_iterator: def __init__(self, Cache_givaro cache): """ - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^4) sage: i = iter(k) # indirect doctest @@ -816,7 +816,7 @@ cdef class FiniteField_givaro_iterator: def __next__(self): """ - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^4) sage: i = iter(k) # indirect doctest @@ -836,7 +836,7 @@ cdef class FiniteField_givaro_iterator: def __repr__(self): """ - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^4) sage: i = iter(k) @@ -847,7 +847,7 @@ cdef class FiniteField_givaro_iterator: def __iter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: K. = GF(4) sage: K.list() # indirect doctest @@ -899,7 +899,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): def _repr_(FiniteField_givaroElement self): """ - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^4) sage: FOOBAR #indirect doctest @@ -1534,7 +1534,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): Return a string representation of self that MAGMA can understand. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^5) diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pyx b/src/sage/rings/finite_rings/element_pari_ffelt.pyx index 8a31c5a6229..d238cfab243 100644 --- a/src/sage/rings/finite_rings/element_pari_ffelt.pyx +++ b/src/sage/rings/finite_rings/element_pari_ffelt.pyx @@ -92,7 +92,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ An element of a finite field. - EXAMPLE:: + EXAMPLES:: sage: K = FiniteField(10007^10, 'a', impl='pari_ffelt') sage: a = K.gen(); a @@ -338,7 +338,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Return the string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: c^20 # indirect doctest @@ -352,7 +352,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): Return the hash of ``self``. This is by definition equal to the hash of ``self.polynomial()``. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^15, impl='pari_ffelt') sage: R = GF(3)['a']; aa = R.gen() @@ -458,7 +458,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Addition. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: a + a^2 # indirect doctest @@ -474,7 +474,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Subtraction. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: a - a # indirect doctest @@ -490,7 +490,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Multiplication. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: (a^12 + 1)*(a^15 - 1) # indirect doctest @@ -506,7 +506,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Division. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: (a - 1) / (a + 1) # indirect doctest @@ -524,7 +524,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Return ``True`` if ``self`` equals 0. - EXAMPLE:: + EXAMPLES:: sage: F. = FiniteField(5^3, impl='pari_ffelt') sage: a.is_zero() @@ -538,7 +538,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Return ``True`` if ``self`` equals 1. - EXAMPLE:: + EXAMPLES:: sage: F. = FiniteField(5^3, impl='pari_ffelt') sage: a.is_one() @@ -552,7 +552,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Return ``True`` if ``self`` is non-zero. - EXAMPLE:: + EXAMPLES:: sage: F. = FiniteField(5^3, impl='pari_ffelt') sage: a.is_unit() @@ -566,7 +566,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Unitary positive operator... - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: +a @@ -578,7 +578,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Negation. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: -a @@ -593,7 +593,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Return the multiplicative inverse of ``self``. - EXAMPLE:: + EXAMPLES:: sage: k. = FiniteField(3^2, impl='pari_ffelt') sage: ~a @@ -692,7 +692,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): - ``var`` -- string (default: 'x'): variable name to use. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(FiniteField(3)) sage: F. = FiniteField(3^2, modulus=x^2 + 1, impl='pari_ffelt') @@ -710,7 +710,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): - ``var`` -- string (default: 'x'): variable name to use. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(FiniteField(3)) sage: F. = FiniteField(3^2, modulus=x^2 + 1, impl='pari_ffelt') @@ -904,7 +904,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Returns the order of ``self`` in the multiplicative group. - EXAMPLE:: + EXAMPLES:: sage: a = FiniteField(5^3, 'a', impl='pari_ffelt').0 sage: a.multiplicative_order() @@ -924,7 +924,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): If ``self`` is an element of the prime field, return a lift of this element to an integer. - EXAMPLE:: + EXAMPLES:: sage: k = FiniteField(next_prime(10^10)^2, 'u', impl='pari_ffelt') sage: a = k(17)/k(19) @@ -945,7 +945,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Lift to a Sage integer, if possible. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: b = k(2) @@ -962,7 +962,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Lift to a python int, if possible. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: b = k(2) @@ -979,7 +979,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Lift to a python long, if possible. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: b = k(2) @@ -992,7 +992,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Lift to a python float, if possible. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: b = k(2) @@ -1009,7 +1009,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): - var -- ignored - EXAMPLE:: + EXAMPLES:: sage: k. = FiniteField(3^3, impl='pari_ffelt') sage: b = a**2 + 2*a + 1 @@ -1023,7 +1023,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Return a string representing ``self`` in PARI. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(3^17, impl='pari_ffelt') sage: a._pari_init_() @@ -1056,7 +1056,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): """ Return a string representing ``self`` in Magma. - EXAMPLE:: + EXAMPLES:: sage: GF(7)(3)._magma_init_(magma) # optional - magma 'GF(7)!3' @@ -1077,7 +1077,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): the multiplicative group, so a discrete logarithm must be computed. - EXAMPLE:: + EXAMPLES:: sage: F = FiniteField(2^3, 'a', impl='pari_ffelt') sage: a = F.multiplicative_generator() @@ -1122,7 +1122,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): def unpickle_FiniteFieldElement_pari_ffelt(parent, elem): """ - EXAMPLE:: + EXAMPLES:: sage: k. = GF(2^20, impl='pari_ffelt') sage: e = k.random_element() diff --git a/src/sage/rings/finite_rings/finite_field_base.pyx b/src/sage/rings/finite_rings/finite_field_base.pyx index ad9cffead02..750f4463b3b 100644 --- a/src/sage/rings/finite_rings/finite_field_base.pyx +++ b/src/sage/rings/finite_rings/finite_field_base.pyx @@ -67,7 +67,7 @@ cdef class FiniteFieldIterator: r""" Return the next element in the iterator. - EXAMPLE:: + EXAMPLES:: sage: k = iter(FiniteField(9, 'a', impl='pari_ffelt')) sage: next(k) # indirect doctest @@ -1312,7 +1312,7 @@ cdef class FiniteField(Field): coercion and pickling cannot work as one might expect. See below for an example. - EXAMPLE:: + EXAMPLES:: sage: F = GF(5).algebraic_closure() sage: F diff --git a/src/sage/rings/finite_rings/finite_field_pari_ffelt.py b/src/sage/rings/finite_rings/finite_field_pari_ffelt.py index 73fb1f878c1..7dfd548e1b2 100644 --- a/src/sage/rings/finite_rings/finite_field_pari_ffelt.py +++ b/src/sage/rings/finite_rings/finite_field_pari_ffelt.py @@ -104,7 +104,7 @@ def __init__(self, p, modulus, name=None): polynomial ``modulus``, with distinguished generator called ``name``. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.finite_rings.finite_field_pari_ffelt import FiniteField_pari_ffelt sage: R. = PolynomialRing(GF(3)) @@ -132,7 +132,7 @@ def __reduce__(self): """ For pickling. - EXAMPLE:: + EXAMPLES:: sage: k. = FiniteField(5^20, impl='pari_ffelt') sage: type(k) @@ -183,7 +183,7 @@ def characteristic(self): """ Return the characteristic of ``self``. - EXAMPLE:: + EXAMPLES:: sage: F = FiniteField(3^4, 'a', impl='pari_ffelt') sage: F.characteristic() @@ -196,7 +196,7 @@ def degree(self): """ Returns the degree of ``self`` over its prime field. - EXAMPLE:: + EXAMPLES:: sage: F = FiniteField(3^20, 'a', impl='pari_ffelt') sage: F.degree() diff --git a/src/sage/rings/finite_rings/integer_mod.pyx b/src/sage/rings/finite_rings/integer_mod.pyx index a38d7a4209e..0258b1206e3 100644 --- a/src/sage/rings/finite_rings/integer_mod.pyx +++ b/src/sage/rings/finite_rings/integer_mod.pyx @@ -352,7 +352,7 @@ cdef class IntegerMod_abstract(FiniteRingElement): Return the image of ``self`` under the map that sends the generators of the parent to ``im_gens``. - EXAMPLE:: + EXAMPLES:: sage: a = Mod(7, 10) sage: R = ZZ.quotient(5) diff --git a/src/sage/rings/finite_rings/integer_mod_ring.py b/src/sage/rings/finite_rings/integer_mod_ring.py index 70fc75fa81d..c9bd7ec561b 100644 --- a/src/sage/rings/finite_rings/integer_mod_ring.py +++ b/src/sage/rings/finite_rings/integer_mod_ring.py @@ -1543,7 +1543,7 @@ def degree(self): """ Return 1. - EXAMPLE:: + EXAMPLES:: sage: R = Integers(12345678900) sage: R.degree() diff --git a/src/sage/rings/fraction_field.py b/src/sage/rings/fraction_field.py index ac84e23b5a5..375525177ce 100644 --- a/src/sage/rings/fraction_field.py +++ b/src/sage/rings/fraction_field.py @@ -375,7 +375,7 @@ def is_finite(self): A fraction field is finite if and only if the associated integral domain is finite. - EXAMPLE:: + EXAMPLES:: sage: Frac(QQ['a','b','c']).is_finite() False diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py index 6fbf68e9867..2e76f10bd9e 100644 --- a/src/sage/rings/ideal.py +++ b/src/sage/rings/ideal.py @@ -268,7 +268,7 @@ def _repr_short(self): """ Represent the list of generators. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: P*[a^2,a*b+c,c^3] @@ -330,7 +330,7 @@ def __cmp__(self, other): - 0 if ``self`` and ``other`` have the same generators, 1 otherwise. - EXAMPLE:: + EXAMPLES:: sage: R = ZZ; I = ZZ*2; J = ZZ*(-2) sage: cmp(I,J) @@ -590,7 +590,7 @@ def gens(self): This is the set of generators provided during creation of this ideal. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ,2) sage: I = Ideal([x,y+1]); I @@ -609,7 +609,7 @@ def gen(self, i): """ Return the ``i``-th generator in the current basis of this ideal. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ,2) sage: I = Ideal([x,y+1]); I @@ -626,7 +626,7 @@ def ngens(self): """ Return the number of generators in the basis. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ,2) sage: I = Ideal([x,y+1]); I @@ -1020,7 +1020,7 @@ def __mul__(self, other): :class:`Ideal_generic` please overwrite :meth:`_mul_` and not :meth:`__mul__`. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: I = [x*y + y*z, x^2 + x*y - y*x - y^2] * P @@ -1063,7 +1063,7 @@ def __rmul__(self, other): """ Multiply ``self`` on the right with ``other``. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: I = [x*y+y*z,x^2+x*y-y*x-y^2]*P diff --git a/src/sage/rings/ideal_monoid.py b/src/sage/rings/ideal_monoid.py index 051cf79ae2a..62e99b76acf 100644 --- a/src/sage/rings/ideal_monoid.py +++ b/src/sage/rings/ideal_monoid.py @@ -12,7 +12,7 @@ def IdealMonoid(R): r""" Return the monoid of ideals in the ring ``R``. - EXAMPLE:: + EXAMPLES:: sage: R = QQ['x'] sage: sage.rings.ideal_monoid.IdealMonoid(R) @@ -68,7 +68,7 @@ def ring(self): r""" Return the ring of which this is the ideal monoid. - EXAMPLE:: + EXAMPLES:: sage: R = QuadraticField(-23, 'a') sage: M = sage.rings.ideal_monoid.IdealMonoid(R); M.ring() is R @@ -108,7 +108,7 @@ def _coerce_map_from_(self, x): r""" Used by coercion framework. - EXAMPLE:: + EXAMPLES:: sage: R = QuadraticField(-23, 'a') sage: M = R.ideal_monoid() @@ -130,7 +130,7 @@ def __cmp__(self, other): r""" Comparison function. - EXAMPLE:: + EXAMPLES:: sage: R = QuadraticField(-23, 'a') sage: M = R.ideal_monoid() diff --git a/src/sage/rings/infinity.py b/src/sage/rings/infinity.py index 65075da8d12..f0d7c94aeff 100644 --- a/src/sage/rings/infinity.py +++ b/src/sage/rings/infinity.py @@ -233,7 +233,7 @@ def __new__(cls, *args): """ This ensures uniqueness of these objects. - EXAMPLE:: + EXAMPLES:: sage: sage.rings.infinity.UnsignedInfinityRing_class() is sage.rings.infinity.UnsignedInfinityRing_class() True @@ -907,7 +907,7 @@ def _sympy_(self): """ Converts ``unsigned_infinity`` to sympy ``zoo``. - EXAMPLE:: + EXAMPLES:: sage: import sympy sage: sympy.sympify(unsigned_infinity) @@ -1593,7 +1593,7 @@ def _sympy_(self): Then you don't have to worry which ``oo`` you use, like in these examples: - EXAMPLE:: + EXAMPLES:: sage: import sympy sage: bool(oo == sympy.oo) # indirect doctest diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 666757187dc..7e7567d5a3a 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -3889,7 +3889,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): - ``p`` - an integer at least 2. - EXAMPLE:: + EXAMPLES:: sage: n = 60 sage: n.valuation(2) @@ -3928,7 +3928,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): - ``u_p(self)`` - ``self`` / `p^{v_p(\mathrm{self})}` - EXAMPLE:: + EXAMPLES:: sage: n = 60 sage: n.val_unit(2) @@ -5751,7 +5751,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): Returns the integer floor of the square root of self, or raises an ``ValueError`` if self is negative. - EXAMPLE:: + EXAMPLES:: sage: a = Integer(5) sage: a.isqrt() @@ -6221,7 +6221,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): """ Return the multiplicative inverse of self, as a rational number. - EXAMPLE:: + EXAMPLES:: sage: n = 10 sage: 1/n @@ -6334,7 +6334,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): """ Return the greatest common divisor of self and `n`. - EXAMPLE:: + EXAMPLES:: sage: gcd(-1,1) 1 diff --git a/src/sage/rings/integer_ring.pyx b/src/sage/rings/integer_ring.pyx index ea76b578bb4..1958a344349 100644 --- a/src/sage/rings/integer_ring.pyx +++ b/src/sage/rings/integer_ring.pyx @@ -864,7 +864,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): See :meth:`sage.structure.parent._repr_option` for details. - EXAMPLE:: + EXAMPLES:: sage: ZZ._repr_option('element_is_atomic') True @@ -1208,7 +1208,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): - an ``n``-th root of unity in `\ZZ`. - EXAMPLE:: + EXAMPLES:: sage: ZZ.zeta() -1 diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py index 9a758d912b7..eb68bf774a8 100644 --- a/src/sage/rings/number_field/class_group.py +++ b/src/sage/rings/number_field/class_group.py @@ -78,7 +78,7 @@ def __init__(self, parent, element, ideal=None): """ Returns the ideal class of this fractional ideal. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 + 23,'a'); G = K.class_group() sage: G(K.ideal(13, a + 4)) @@ -92,7 +92,7 @@ def _repr_(self): r""" Return string representation of this fractional ideal class. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 + 23,'a'); G = K.class_group() sage: G(K.ideal(13, a + 4))._repr_() @@ -108,7 +108,7 @@ def _mul_(self, other): r""" Multiplication of two (S-)ideal classes. - EXAMPLE:: + EXAMPLES:: sage: G = NumberField(x^2 + 23,'a').class_group(); G Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23 @@ -135,7 +135,7 @@ def _div_(self, other): r""" Division of two ideal classes. - EXAMPLE:: + EXAMPLES:: sage: G = NumberField(x^2 + 23,'a').class_group(); G Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23 @@ -154,7 +154,7 @@ def __pow__(self, n): r""" Raise this element to the power n. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 - 3*x + 8) sage: C=K.class_group() @@ -179,7 +179,7 @@ def inverse(self): r""" Return the multiplicative inverse of this ideal class. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 - 3*x + 8); G = K.class_group() sage: G(2, a).inverse() @@ -238,7 +238,7 @@ def ideal(self): r""" Return a representative ideal in this ideal class. - EXAMPLE:: + EXAMPLES:: sage: K.=QuadraticField(-23) sage: OK=K.ring_of_integers() @@ -259,7 +259,7 @@ def representative_prime(self, norm_bound=1000): ``norm_bound`` (positive integer) -- upper bound on the norm of primes tested. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2+31) sage: K.class_number() @@ -383,7 +383,7 @@ def _repr_(self): r""" Returns a string representation of the S-ideal class of this fractional ideal. - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(-14) sage: I = K.ideal(2,a) diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py index e39edce438e..069bad2cffc 100644 --- a/src/sage/rings/number_field/galois_group.py +++ b/src/sage/rings/number_field/galois_group.py @@ -202,7 +202,7 @@ def _element_class(self): Return the class to be used for creating elements of this group, which is GaloisGroupElement. - EXAMPLE:: + EXAMPLES:: sage: F. = CyclotomicField(7) sage: G = F.galois_group() @@ -255,7 +255,7 @@ def is_galois(self): r""" Return True if the underlying number field of self is actually Galois. - EXAMPLE:: + EXAMPLES:: sage: NumberField(x^3 - x + 1,'a').galois_group(names='b').is_galois() False @@ -270,7 +270,7 @@ def is_galois(self): def ngens(self): r""" Number of generators of self. - EXAMPLE:: + EXAMPLES:: sage: QuadraticField(-23, 'a').galois_group().ngens() 1 @@ -281,7 +281,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: G = QuadraticField(-23, 'a').galois_group() sage: G._repr_() @@ -299,7 +299,7 @@ def number_field(self): r""" The ambient number field. - EXAMPLE:: + EXAMPLES:: sage: K = NumberField(x^3 - x + 1, 'a') sage: K.galois_group(names='b').number_field() is K @@ -311,7 +311,7 @@ def splitting_field(self): r""" The Galois closure of the ambient number field. - EXAMPLE:: + EXAMPLES:: sage: K = NumberField(x^3 - x + 1, 'a') sage: K.galois_group(names='b').splitting_field() @@ -325,7 +325,7 @@ def list(self): r""" List of the elements of self. - EXAMPLE:: + EXAMPLES:: sage: NumberField(x^3 - 3*x + 1,'a').galois_group().list() [(), (1,2,3), (1,3,2)] @@ -372,7 +372,7 @@ def subgroup(self, elts): r""" Return the subgroup of self with the given elements. Mostly for internal use. - EXAMPLE:: + EXAMPLES:: sage: G = NumberField(x^3 - x - 1, 'a').galois_closure('b').galois_group() sage: G.subgroup([ G(1), G([(1,2,3),(4,5,6)]), G([(1,3,2),(4,6,5)]) ]) @@ -397,7 +397,7 @@ def decomposition_group(self, P): P can also be an infinite prime, i.e. an embedding into `\RR` or `\CC`. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^4 - 2*x^2 + 2,'b').galois_closure() sage: P = K.ideal([17, a^2]) @@ -440,7 +440,7 @@ def complex_conjugation(self, P=None): for a specified embedding P into the complex numbers. If P is not specified, use the "standard" embedding, whenever that is well-defined. - EXAMPLE:: + EXAMPLES:: sage: L. = CyclotomicField(7) sage: G = L.galois_group() @@ -482,7 +482,7 @@ def ramification_group(self, P, v): of elements s of self such that s acts trivially modulo P^(v+1). This is only defined for Galois fields. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 - 3,'a').galois_closure() sage: G=K.galois_group() @@ -504,7 +504,7 @@ def inertia_group(self, P): Return the inertia group of the prime P, i.e. the group of elements acting trivially modulo P. This is just the 0th ramification group of P. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 - 3,'a') sage: G = K.galois_group() @@ -523,7 +523,7 @@ def ramification_breaks(self, P): set of indices i such that the ramification group `G_{i+1} \ne G_{i}`. This is only defined for Galois fields. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^8 - 20*x^6 + 104*x^4 - 40*x^2 + 1156) sage: G = K.galois_group() @@ -592,7 +592,7 @@ def __init__(self, ambient, elts): Create a subgroup of a Galois group with the given elements. It is generally better to use the subgroup() method of the parent group. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.number_field.galois_group import GaloisGroup_subgroup sage: G = NumberField(x^3 - x - 1, 'a').galois_closure('b').galois_group() @@ -628,7 +628,7 @@ def fixed_field(self): Return the fixed field of this subgroup (as a subfield of the Galois closure of the number field associated to the ambient Galois group). - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField(x^4 + 1) sage: G = L.galois_group() @@ -652,7 +652,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: G = NumberField(x^3 - x - 1, 'a').galois_closure('b').galois_group() sage: H = G.subgroup([ G(1), G([(1,2,3),(4,5,6)]), G([(1,3,2),(4,6,5)])]) @@ -667,7 +667,7 @@ class GaloisGroupElement(PermutationGroupElement): be made to act on elements of the field (generally returning elements of its Galois closure). - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(-7); G = K.galois_group() sage: G[1] @@ -691,7 +691,7 @@ def as_hom(self): Return the homomorphism L -> L corresponding to self, where L is the Galois closure of the ambient number field. - EXAMPLE:: + EXAMPLES:: sage: G = QuadraticField(-7,'w').galois_group() sage: G[1].as_hom() @@ -729,7 +729,7 @@ def __call__(self, x): Return the action of self on an element x in the number field of self (or its Galois closure). - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(-7) sage: f = K.galois_group()[1] @@ -746,7 +746,7 @@ def ramification_degree(self, P): Return the greatest value of v such that s acts trivially modulo P^v. Should only be used if P is prime and s is in the decomposition group of P. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 - 3, 'a').galois_closure() sage: G = K.galois_group() diff --git a/src/sage/rings/number_field/maps.py b/src/sage/rings/number_field/maps.py index cc79c546b2d..3db906b1036 100644 --- a/src/sage/rings/number_field/maps.py +++ b/src/sage/rings/number_field/maps.py @@ -52,7 +52,7 @@ class NumberFieldIsomorphism(Map): A base class for various isomorphisms between number fields and vector spaces. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^4 + 3*x + 1) sage: V, fr, to = K.vector_space() @@ -61,7 +61,7 @@ class NumberFieldIsomorphism(Map): """ def _repr_type(self): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^4 + 3*x + 1) sage: V, fr, to = K.vector_space() @@ -72,7 +72,7 @@ def _repr_type(self): def is_injective(self): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^4 + 3*x + 1) sage: V, fr, to = K.vector_space() @@ -83,7 +83,7 @@ def is_injective(self): def is_surjective(self): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^4 + 3*x + 1) sage: V, fr, to = K.vector_space() @@ -182,7 +182,7 @@ class MapNumberFieldToVectorSpace(Map): A class for the isomorphism from an absolute number field to its underlying `\QQ`-vector space. - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField(x^3 - x + 1) sage: V, fr, to = L.vector_space() @@ -193,7 +193,7 @@ def __init__(self, K, V): r""" Standard initialisation function. - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField(x^3 - x + 1) sage: L.vector_space()[2] # indirect doctest @@ -205,7 +205,7 @@ def __init__(self, K, V): def _repr_type(self): r""" - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField([x^2 + 1, x^2 - 3]) sage: V, fr, to = L.relative_vector_space() @@ -216,7 +216,7 @@ def _repr_type(self): def _call_(self, x): r""" - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField(x^3 - x + 1) sage: V, _, to = L.vector_space() @@ -259,7 +259,7 @@ class MapRelativeVectorSpaceToRelativeNumberField(NumberFieldIsomorphism): def __init__(self, V, K): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField([x^2 + 1, x^2 - 2]) sage: V, _, to = K.relative_vector_space(); to # indirect doctest @@ -271,7 +271,7 @@ def __init__(self, V, K): def _call_(self, v): r""" - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField(x^4 + 3*x^2 + 1) sage: K = L.relativize(L.subfields(2)[0][1], 'a') @@ -293,7 +293,7 @@ def _call_(self, v): class MapRelativeNumberFieldToRelativeVectorSpace(NumberFieldIsomorphism): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField([x^3 - x + 1, x^2 + 23]) sage: V, fr, to = K.relative_vector_space() @@ -303,7 +303,7 @@ class MapRelativeNumberFieldToRelativeVectorSpace(NumberFieldIsomorphism): def __init__(self, K, V): r""" - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField(x^4 + 3*x^2 + 1) sage: K = L.relativize(L.subfields(2)[0][1], 'a') @@ -366,7 +366,7 @@ class NameChangeMap(NumberFieldIsomorphism): A map between two isomorphic number fields with the same defining polynomial but different variable names. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 - 3) sage: L. = K.change_names() @@ -384,7 +384,7 @@ class NameChangeMap(NumberFieldIsomorphism): """ def __init__(self, K, L): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField([x^2 - 3, x^2 + 7]) sage: L. = K.change_names() @@ -399,7 +399,7 @@ def __init__(self, K, L): def _repr_type(self): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 - 3) sage: L. = K.change_names() @@ -411,7 +411,7 @@ def _repr_type(self): def _call_(self, x): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField([x^2 - 3, x^2 + 7]) sage: L. = K.change_names() @@ -472,7 +472,7 @@ class MapRelativeToAbsoluteNumberField(NumberFieldIsomorphism): def __init__(self, R, A): r""" - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField([x^2 + 3, x^2 + 5]) sage: K. = L.absolute_field() @@ -487,7 +487,7 @@ def __init__(self, R, A): def _call_(self, x): r""" - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField([x^2 + 3, x^2 + 5]) sage: K. = L.absolute_field() @@ -505,7 +505,7 @@ class MapAbsoluteToRelativeNumberField(NumberFieldIsomorphism): """ def __init__(self, A, R): r""" - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField([x^2 + 3, x^2 + 5]) sage: K. = L.absolute_field() @@ -517,7 +517,7 @@ def __init__(self, A, R): def _call_(self, x): r""" - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField([x^2 + 3, x^2 + 5]) sage: K. = L.absolute_field() diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 716e74753cf..b4b99d45a53 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -1470,7 +1470,7 @@ def construction(self): r""" Construction of self - EXAMPLE:: + EXAMPLES:: sage: K.=NumberField(x^3+x^2+1,embedding=CC.gen()) sage: F,R = K.construction() @@ -2874,7 +2874,7 @@ def ideals_of_bdd_norm(self, bound): OUTPUT: A dict of all integral ideals I such that Norm(I) <= bound, keyed by norm. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 + 23) sage: d = K.ideals_of_bdd_norm(10) @@ -3647,7 +3647,7 @@ def _gap_init_(self): """ Create a gap object representing self and return its name - EXAMPLE:: + EXAMPLES:: sage: z = QQ['z'].0 sage: K. = NumberField(z^2 - 2) @@ -3870,7 +3870,7 @@ def S_units(self, S, proof=True): For more functionality see the S_unit_group() function. - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(-3) sage: K.unit_group() @@ -3933,7 +3933,7 @@ def _S_class_group_and_units(self, S, proof=True): where ``gen`` is a fractional ideal of self and ``order`` is its order in the `S`-class group. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2+5) sage: K._S_class_group_and_units(()) @@ -6400,7 +6400,7 @@ def zeta_coefficients(self, n): Compute the first n coefficients of the Dedekind zeta function of this field as a Dirichlet series. - EXAMPLE:: + EXAMPLES:: sage: x = QQ['x'].0 sage: NumberField(x^2+1, 'a').zeta_coefficients(10) @@ -6472,7 +6472,7 @@ def __init__(self, polynomial, name, latex_name=None, check=True, embedding=None """ Function to initialize an absolute number field. - EXAMPLE:: + EXAMPLES:: sage: K = NumberField(x^17 + 3, 'a'); K Number Field in a with defining polynomial x^17 + 3 @@ -6961,7 +6961,7 @@ def absolute_generator(self): only generates the field over its base field (not necessarily over `\QQ`). - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 - 17) sage: K.absolute_generator() diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index 46f9736be7d..5d354665dc5 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -106,7 +106,7 @@ def __create__NumberFieldElement_version0(parent, poly): """ Used in unpickling elements of number fields pickled under very old Sage versions. - EXAMPLE:: + EXAMPLES:: sage: k. = NumberField(x^3 - 2) sage: R. = QQ[] @@ -202,7 +202,7 @@ cdef class NumberFieldElement(FieldElement): r""" Return the number field of self. Only accessible from Cython. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 3) sage: a._number_field() # indirect doctest @@ -212,7 +212,7 @@ cdef class NumberFieldElement(FieldElement): def _number_field(self): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 3) sage: a._number_field() @@ -2201,7 +2201,7 @@ cdef class NumberFieldElement(FieldElement): cpdef _add_(self, right): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(2) sage: s + s # indirect doctest @@ -2336,7 +2336,7 @@ cdef class NumberFieldElement(FieldElement): cpdef _neg_(self): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 2) sage: -a # indirect doctest @@ -2350,7 +2350,7 @@ cdef class NumberFieldElement(FieldElement): def __copy__(self): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 2) sage: b = copy(a) @@ -2811,7 +2811,7 @@ cdef class NumberFieldElement(FieldElement): Return hash of this number field element, which is just the hash of the underlying polynomial. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 - 2) sage: hash(b^2 + 1) == hash((b^2 + 1).polynomial()) # indirect doctest @@ -3229,7 +3229,7 @@ cdef class NumberFieldElement(FieldElement): r""" Return the characteristic polynomial of this number field element. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 7) sage: a.charpoly() @@ -3901,7 +3901,7 @@ cdef class NumberFieldElement(FieldElement): Return the list of coefficients of self written in terms of a power basis. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 - x + 2); ((a + 1)/(a + 2)).list() [1/4, 1/2, -1/4] @@ -4295,7 +4295,7 @@ cdef class NumberFieldElement_absolute(NumberFieldElement): Return the list of coefficients of self written in terms of a power basis. - EXAMPLE:: + EXAMPLES:: sage: K. = CyclotomicField(3) sage: (2+3/5*z).list() @@ -4389,7 +4389,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement): """ def __init__(self, parent, f): r""" - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField([x^2 + 1, x^2 + 2]) sage: type(a) # indirect doctest @@ -4486,7 +4486,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement): def _repr_(self): r""" - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField([x^3 - x + 1, x^2 + 23]) sage: repr(a^4*b) # indirect doctest @@ -4678,7 +4678,7 @@ cdef class OrderElement_absolute(NumberFieldElement_absolute): """ def __init__(self, order, f): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 2) sage: O2 = K.order(2*a) @@ -4715,7 +4715,7 @@ cdef class OrderElement_absolute(NumberFieldElement_absolute): r""" Return the number field of self. Only accessible from Cython. - EXAMPLE:: + EXAMPLES:: sage: K = NumberField(x^3 - 17, 'a') sage: OK = K.ring_of_integers() @@ -4788,7 +4788,7 @@ cdef class OrderElement_absolute(NumberFieldElement_absolute): See :trac:`4190`. - EXAMPLE:: + EXAMPLES:: sage: K = NumberField(x^3 -x + 2, 'a') sage: OK = K.ring_of_integers() @@ -4816,7 +4816,7 @@ cdef class OrderElement_relative(NumberFieldElement_relative): """ def __init__(self, order, f): r""" - EXAMPLE:: + EXAMPLES:: sage: O = EquationOrder([x^2 + x + 1, x^3 - 2],'a,b') sage: type(O.1) # indirect doctest @@ -5043,7 +5043,7 @@ class CoordinateFunction: This class provides a callable object which expresses elements in terms of powers of a fixed field generator `\alpha`. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 + x + 3) sage: f = (a + 1).coordinates_in_terms_of_powers(); f @@ -5057,7 +5057,7 @@ class CoordinateFunction: """ def __init__(self, NumberFieldElement alpha, W, to_V): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 + x + 3) sage: f = (a + 1).coordinates_in_terms_of_powers(); f # indirect doctest @@ -5070,7 +5070,7 @@ class CoordinateFunction: def __repr__(self): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 + x + 3) sage: f = (a + 1).coordinates_in_terms_of_powers(); repr(f) # indirect doctest @@ -5080,7 +5080,7 @@ class CoordinateFunction: def alpha(self): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 2) sage: (a + 2).coordinates_in_terms_of_powers().alpha() @@ -5090,7 +5090,7 @@ class CoordinateFunction: def __call__(self, x): r""" - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 2) sage: f = (a + 2).coordinates_in_terms_of_powers() @@ -5118,7 +5118,7 @@ class CoordinateFunction: """ Test equality - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 2) sage: c = (a + 2).coordinates_in_terms_of_powers() @@ -5143,7 +5143,7 @@ class CoordinateFunction: """ Test inequality - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 2) sage: c = (a + 2).coordinates_in_terms_of_powers() diff --git a/src/sage/rings/number_field/number_field_element_quadratic.pyx b/src/sage/rings/number_field/number_field_element_quadratic.pyx index a23c8588dbd..f340d413da6 100644 --- a/src/sage/rings/number_field/number_field_element_quadratic.pyx +++ b/src/sage/rings/number_field/number_field_element_quadratic.pyx @@ -154,7 +154,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): """ Standard initialisation function. - EXAMPLE:: + EXAMPLES:: sage: F. = QuadraticField(-7) sage: c = a + 7 @@ -216,7 +216,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): Quickly creates a new initialized NumberFieldElement_quadratic with the same parent as self. - EXAMPLE:: + EXAMPLES:: sage: F. = CyclotomicField(3) sage: b + b # indirect doctest @@ -235,7 +235,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): Cython cdef method, it is not directly accessible by the user, but the function "_number_field" calls this one. - EXAMPLE:: + EXAMPLES:: sage: F. = QuadraticField(-7) sage: b._number_field() # indirect doctest @@ -288,7 +288,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): r""" Initialisation function. - EXAMPLE:: + EXAMPLES:: sage: QuadraticField(-3, 'a').gen() # indirect doctest a @@ -616,7 +616,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): r""" Returns true if self is `\sqrt{D}`. - EXAMPLE:: + EXAMPLES:: sage: F. = NumberField(x^2 - x + 7) sage: b.denominator() # indirect doctest @@ -2099,7 +2099,7 @@ cdef class OrderElement_quadratic(NumberFieldElement_quadratic): r""" Standard initialisation function. - EXAMPLE:: + EXAMPLES:: sage: OK. = EquationOrder(x^2 + 5) sage: v = OK.1 # indirect doctest @@ -2317,7 +2317,7 @@ cdef class Z_to_quadratic_field_element(Morphism): """ ``K`` is the target quadratic field - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(3) sage: phi = K.coerce_map_from(ZZ) # indirect doctest @@ -2375,7 +2375,7 @@ cdef class Z_to_quadratic_field_element(Morphism): r""" Evaluate at an integer ``x``. - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(3) sage: phi = K.coerce_map_from(ZZ) @@ -2438,7 +2438,7 @@ cdef class Q_to_quadratic_field_element(Morphism): """ ``K`` is the target quadratic field - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(3) sage: phi = K.coerce_map_from(QQ) # indirect doctest @@ -2502,7 +2502,7 @@ cdef class Q_to_quadratic_field_element(Morphism): r""" Evaluate at a rational ``x``. - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(3) sage: phi = K.coerce_map_from(QQ) diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py index c532042452c..80965e567e2 100644 --- a/src/sage/rings/number_field/number_field_ideal.py +++ b/src/sage/rings/number_field/number_field_ideal.py @@ -897,7 +897,7 @@ def intersection(self, other): r""" Return the intersection of self and other. - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(-11) sage: p = K.ideal((a + 1)/2); q = K.ideal((a + 3)/2) @@ -1410,7 +1410,7 @@ def decomposition_group(self): method of the ``GaloisGroup_v2`` class for further examples and doctests. - EXAMPLE:: + EXAMPLES:: sage: QuadraticField(-23, 'w').primes_above(7)[0].decomposition_group() Galois group of Number Field in w with defining polynomial x^2 + 23 @@ -1426,7 +1426,7 @@ def ramification_group(self, v): ramification_group method of the ``GaloisGroup`` class for further examples and doctests. - EXAMPLE:: + EXAMPLES:: sage: QuadraticField(-23, 'w').primes_above(23)[0].ramification_group(0) Galois group of Number Field in w with defining polynomial x^2 + 23 @@ -1444,7 +1444,7 @@ def inertia_group(self): ramification group of self. See the inertia_group method of the ``GaloisGroup_v2`` class for further examples and doctests. - EXAMPLE:: + EXAMPLES:: sage: QuadraticField(-23, 'w').primes_above(23)[0].inertia_group() Galois group of Number Field in w with defining polynomial x^2 + 23 @@ -1509,7 +1509,7 @@ def artin_symbol(self): See the ``artin_symbol`` method of the ``GaloisGroup_v2`` class for further documentation and examples. - EXAMPLE:: + EXAMPLES:: sage: QuadraticField(-23, 'w').primes_above(7)[0].artin_symbol() (1,2) @@ -3117,7 +3117,7 @@ def ray_class_number(self): Return the order of the ray class group modulo this ideal. This is a wrapper around Pari's :pari:`bnrclassno` function. - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(-23) sage: p = K.primes_above(3)[0] @@ -3167,7 +3167,7 @@ def __init__(self, K, M_OK_change, Q, I): """ Initialize this QuotientMap. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 4) sage: f = K.ideal(1 + a^2/2).residue_field().reduction_map(); f # indirect doctest @@ -3191,7 +3191,7 @@ def __call__(self, x): x -- an element of the field - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 4) sage: f = K.ideal(1 + a^2/2).residue_field().reduction_map() @@ -3206,7 +3206,7 @@ def __repr__(self): """ Return a string representation of this QuotientMap. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 4) sage: f = K.ideal(1 + a^2/2).residue_field().reduction_map() @@ -3224,7 +3224,7 @@ def __init__(self, OK, M_OK_map, Q, I): """ Initialize this LiftMap. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 4) sage: I = K.ideal(1 + a^2/2) @@ -3242,7 +3242,7 @@ def __call__(self, x): """ Apply this LiftMap to an element of the residue field. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 4) sage: R = K.ideal(1 + a^2/2).residue_field() @@ -3270,7 +3270,7 @@ def __repr__(self): """ Return a string representation of this QuotientMap. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 + 4) sage: R = K.ideal(1 + a^2/2).residue_field() diff --git a/src/sage/rings/number_field/number_field_ideal_rel.py b/src/sage/rings/number_field/number_field_ideal_rel.py index f373afd52b2..45ef0cdabca 100644 --- a/src/sage/rings/number_field/number_field_ideal_rel.py +++ b/src/sage/rings/number_field/number_field_ideal_rel.py @@ -113,7 +113,7 @@ def pari_rhnf(self): Return PARI's representation of this relative ideal in Hermite normal form. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField([x^2 + 23, x^2 - 7]) sage: I = K.ideal(2, (a + 2*b + 3)/2) @@ -256,7 +256,7 @@ def gens_reduced(self): return a single generator if one exists (i.e. if the ideal is principal), and otherwise two generators. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField([x^2 + 1, x^2 - 2]) sage: I = K.ideal((a + 1)*b/2 + 1) @@ -338,7 +338,7 @@ def is_zero(self): r""" Return True if this is the zero ideal. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField([x^2 + 3, x^3 + 4]) sage: K.ideal(17).is_zero() @@ -416,7 +416,7 @@ def norm(self): unimplemented, so that a user cannot mistake the absolute norm for the relative norm, or vice versa. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField([x^2 + 1, x^2 - 2]) sage: K.ideal(2).norm() @@ -712,7 +712,7 @@ def ramification_index(self): Either :meth:`~relative_ramification_index` or :meth:`~absolute_ramification_index` should be used instead. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField([x^2 + 1, x^2 - 2]) sage: K.ideal(2).ramification_index() diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py index 57986ce3bb0..a4001fb6746 100644 --- a/src/sage/rings/number_field/number_field_rel.py +++ b/src/sage/rings/number_field/number_field_rel.py @@ -675,7 +675,7 @@ def degree(self): not implemented, so that a user cannot mistake the absolute degree for the relative degree, or vice versa. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberFieldTower([x^2 - 17, x^3 - 2]) sage: K.degree() @@ -1267,7 +1267,7 @@ def is_galois_absolute(self): r""" Return True if for this relative extension `L/K`, `L` is a Galois extension of `\QQ`. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 - 2) sage: y = polygen(K); L. = K.extension(y^2 - a) @@ -1488,7 +1488,7 @@ def vector_space(self): deliberately not implemented, so that a user cannot confuse :meth:`~relative_vector_space` with :meth:`~absolute_vector_space`. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberFieldTower([x^2 - 17, x^3 - 2]) sage: K.vector_space() @@ -1949,7 +1949,7 @@ def polynomial(self): not implemented. Either :meth:`~relative_polynomial` or :meth:`~absolute_polynomial` must be used. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberFieldTower([x^2 + x + 1, x^3 + x + 1]) sage: K.polynomial() @@ -2214,7 +2214,7 @@ def different(self): not implemented, so that a user cannot mistake the absolute different for the relative different, or vice versa. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberFieldTower([x^2 + x + 1, x^3 + x + 1]) sage: K.different() @@ -2293,7 +2293,7 @@ def discriminant(self): not implemented, so that a user cannot mistake the absolute discriminant for the relative discriminant, or vice versa. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberFieldTower([x^2 + x + 1, x^3 + x + 1]) sage: K.discriminant() @@ -2309,7 +2309,7 @@ def disc(self): not implemented, so that a user cannot mistake the absolute discriminant for the relative discriminant, or vice versa. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberFieldTower([x^2 + x + 1, x^3 + x + 1]) sage: K.disc() diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py index e52e31715aa..7ed2d321817 100644 --- a/src/sage/rings/number_field/order.py +++ b/src/sage/rings/number_field/order.py @@ -291,7 +291,7 @@ def is_maximal(self): """ Returns True if this is the maximal order. - EXAMPLE:: + EXAMPLES:: sage: k. = NumberField(x^2 + 1) sage: O3 = k.order(3*i); O5 = k.order(5*i); Ok = k.maximal_order(); Osum = O3 + O5 @@ -1434,7 +1434,7 @@ def __init__(self, K, absolute_order, is_maximal=None, check=True): """ Create the relative order. - EXAMPLE:: + EXAMPLES:: sage: k. = NumberFieldTower([x^2 - 3, x^2 + 1]) sage: O = k.maximal_order(); O # indirect doctest @@ -1550,7 +1550,7 @@ def __reduce__(self): r""" Used for pickling. - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField([x^2 + 1, x^2 - 5]) sage: O = L.maximal_order() @@ -1625,7 +1625,7 @@ def __and__(left, right): Intersect two relative orders or a relative and absolute order (which always results in an absolute order). - EXAMPLE:: + EXAMPLES:: sage: L. = NumberField([x^2 + 1, x^2 - 5]) sage: O1 = L.order([a, 2*b]) diff --git a/src/sage/rings/padics/CR_template.pxi b/src/sage/rings/padics/CR_template.pxi index 78024550b6b..c56fa547179 100644 --- a/src/sage/rings/padics/CR_template.pxi +++ b/src/sage/rings/padics/CR_template.pxi @@ -826,7 +826,7 @@ cdef class CRElement(pAdicTemplateElement): an equal element with precision set to the minimum of ``self's`` precision and ``absprec`` - EXAMPLE:: + EXAMPLES:: sage: R = Zp(7,4,'capped-rel','series'); a = R(8); a.add_bigoh(1) 1 + O(7) diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py index a464120ac81..6f941a9f997 100644 --- a/src/sage/rings/padics/generic_nodes.py +++ b/src/sage/rings/padics/generic_nodes.py @@ -257,7 +257,7 @@ def construction(self): Also preserves other information that makes this field unique (e.g. precision, rounding, print mode). - EXAMPLE:: + EXAMPLES:: sage: K = Zp(17, 8, print_mode='val-unit', print_sep='&') sage: c, L = K.construction(); L @@ -396,7 +396,7 @@ def construction(self): Also preserves other information that makes this field unique (e.g. precision, rounding, print mode). - EXAMPLE:: + EXAMPLES:: sage: K = Qp(17, 8, print_mode='val-unit', print_sep='&') sage: c, L = K.construction(); L diff --git a/src/sage/rings/padics/padic_extension_generic.py b/src/sage/rings/padics/padic_extension_generic.py index 2e32d4a07fa..d1c36d69e6e 100644 --- a/src/sage/rings/padics/padic_extension_generic.py +++ b/src/sage/rings/padics/padic_extension_generic.py @@ -184,7 +184,7 @@ def ground_ring(self): """ Returns the ring of which this ring is an extension. - EXAMPLE:: + EXAMPLES:: sage: R = Zp(5,5) sage: S. = R[] diff --git a/src/sage/rings/padics/padic_generic_element.pyx b/src/sage/rings/padics/padic_generic_element.pyx index 50bfb515cf5..fc476f52135 100644 --- a/src/sage/rings/padics/padic_generic_element.pyx +++ b/src/sage/rings/padics/padic_generic_element.pyx @@ -398,7 +398,7 @@ cdef class pAdicGenericElement(LocalGenericElement): r""" Returns the multiplicative inverse of self. - EXAMPLE:: + EXAMPLES:: sage: R = Zp(7,4,'capped-rel','series'); a = R(3); a 3 + O(7^4) diff --git a/src/sage/rings/pari_ring.py b/src/sage/rings/pari_ring.py index 0ef56fc8308..3a9697f5ddb 100644 --- a/src/sage/rings/pari_ring.py +++ b/src/sage/rings/pari_ring.py @@ -202,7 +202,7 @@ def random_element(self, x=None, y=None, distribution=None): - `distribution` -- optional string, so that ``ZZ`` can make sense of it as a probability distribution. - EXAMPLE:: + EXAMPLES:: sage: R = PariRing() sage: R.random_element() @@ -220,7 +220,7 @@ def zeta(self): """ Return -1. - EXAMPLE:: + EXAMPLES:: sage: R = PariRing() sage: R.zeta() diff --git a/src/sage/rings/polynomial/infinite_polynomial_ring.py b/src/sage/rings/polynomial/infinite_polynomial_ring.py index 9f8c572b9c2..dc40fd7a1e9 100644 --- a/src/sage/rings/polynomial/infinite_polynomial_ring.py +++ b/src/sage/rings/polynomial/infinite_polynomial_ring.py @@ -774,7 +774,7 @@ def construction(self): A pair ``F,R``, where ``F`` is a construction functor and ``R`` is a ring, so that ``F(R) is self``. - EXAMPLE:: + EXAMPLES:: sage: R. = InfinitePolynomialRing(GF(5)) sage: R.construction() @@ -1550,7 +1550,7 @@ def construction(self): A pair ``F,R``, where ``F`` is a construction functor and ``R`` is a ring, so that ``F(R) is self``. - EXAMPLE:: + EXAMPLES:: sage: R. = InfinitePolynomialRing(GF(5)) sage: R.construction() diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index b94e2804695..c6a58a9d241 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -1620,7 +1620,7 @@ cdef class MPolynomial(CommutativeRingElement): given an ideal ``I = (f_1,...,f_r)`` and some ``g (== self)`` in ``I``, find ``s_1,...,s_r`` such that ``g = s_1 f_1 + ... + s_r f_r``. - EXAMPLE:: + EXAMPLES:: sage: A. = PolynomialRing(CC,2,order='degrevlex') sage: I = A.ideal([x^10 + x^9*y^2, y^8 - x^2*y^7 ]) diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index 9f7fcdb1e38..fce4c5dfdcf 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -72,7 +72,7 @@ def is_MPolynomial(x): class MPolynomial_element(MPolynomial): def __init__(self, parent, x): """ - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3 - 2) sage: L. = K.extension(x^3 - 3) @@ -86,7 +86,7 @@ def __init__(self, parent, x): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar) sage: x + QQbar.random_element() # indirect doctest @@ -383,7 +383,7 @@ def _new_constant_poly(self, x, P): x must be an element of the base ring of P. That assumption is not verified. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ['t'][] sage: x._new_constant_poly(R.base_ring()(2),R) @@ -1778,7 +1778,7 @@ def lift(self,I): ALGORITHM: Use Singular. - EXAMPLE:: + EXAMPLES:: sage: A. = PolynomialRing(CC,2,order='degrevlex') sage: I = A.ideal([x^10 + x^9*y^2, y^8 - x^2*y^7 ]) @@ -1803,7 +1803,7 @@ def quo_rem(self, right): """ Returns quotient and remainder of self and right. - EXAMPLE:: + EXAMPLES:: sage: R. = CC[] sage: f = y*x^2 + x + 1 @@ -1905,7 +1905,7 @@ def reduce(self, I): - ``I`` - a list of polynomials or an ideal - EXAMPLE:: + EXAMPLES:: sage: P. = QQbar[] sage: f1 = -2 * x^2 + x^3 diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index 9d30e70ff80..a7c2a323af7 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -274,7 +274,7 @@ class RequireField(MethodDecorator): """ def __call__(self, *args, **kwds): """ - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(ZZ) sage: I = ideal( x^2 - 3*y, y^3 - x*y, z^3 - x, x^4 - y*z + 1 ) @@ -437,7 +437,7 @@ def syzygy_module(self): Computes the first syzygy (i.e., the module of relations of the given generators) of the ideal. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(QQ) sage: f = 2*x^2 + y @@ -596,7 +596,7 @@ def _groebner_strategy(self): Return Singular's Groebner Strategy object for the Groebner basis of this ideal which implements some optimized functions. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(QQ,2) sage: I = R.ideal([y^3 - x^2]) @@ -997,7 +997,7 @@ def triangular_decomposition(self, algorithm=None, singular=singular_default): ``self`` is the union of the varieties of `t` in `L` and each `t` is in triangular form. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ,5,order='lex') sage: I = sage.rings.ideal.Cyclic(P) @@ -1084,7 +1084,7 @@ def dimension(self, singular=singular_default): """ The dimension of the ring modulo this ideal. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(32003),order='degrevlex') sage: I = ideal(x^2-y,x^3) @@ -1098,7 +1098,7 @@ def dimension(self, singular=singular_default): the Groebner basis, then uses the algorithm described in Chapter 9, Section 1 of Cox, Little, and O'Shea's "Ideals, Varieties, and Algorithms". - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(GF(2147483659),order='lex') sage: I = R.ideal([x*y,x*y+1]) @@ -1197,7 +1197,7 @@ def vector_space_dimension(self): Uses Singular. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(QQ) sage: g = u^4 + v^4 + u^3 + v^3 @@ -1382,7 +1382,7 @@ def _groebner_basis_singular_raw(self, algorithm="groebner", singular=singular_d - ``kwds`` - Singular options - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(QQ, 4, order='lex') sage: I = sage.rings.ideal.Cyclic(R,4) @@ -1665,7 +1665,7 @@ def integral_closure(self, p=0, r=True, singular=singular_default): - ``r`` - check whether self is a radical ideal first (default: ``True``) - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: I = ideal([x^2,x*y^4,y^5]) @@ -1690,7 +1690,7 @@ def syzygy_module(self): Computes the first syzygy (i.e., the module of relations of the given generators) of the ideal. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(QQ) sage: f = 2*x^2 + y @@ -1733,7 +1733,7 @@ def interreduced_basis(self): - `LC(g_i) == 1` for all `i` if the coefficient ring is a field. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(QQ) sage: I = Ideal([z*x+y^3,z+y^3,z+x*y]) @@ -1789,7 +1789,7 @@ def basis_is_groebner(self, singular=singular_default): Uses Singular. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(GF(127),10) sage: I = sage.rings.ideal.Cyclic(R,4) @@ -1979,7 +1979,7 @@ def elimination_ideal(self, variables): - ``variables`` -- a list or tuple of variables in ``self.ring()`` - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(QQ,5) sage: I = R * [x-t,y-t^2,z-t^3,s-x+y^3] @@ -2020,7 +2020,7 @@ def quotient(self, J): - ``J`` - multivariate polynomial ideal - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(GF(181),3) sage: I = Ideal([x^2+x*y*z,y^2-z^3*y,z^3+y^5*x*z]) @@ -2121,7 +2121,7 @@ def variety(self, ring=None): ring of this ideal (default: ``None``) - ``proof`` - return a provably correct result (default: ``True``) - EXAMPLE:: + EXAMPLES:: sage: K. = GF(27) # this example is from the MAGMA handbook sage: P. = PolynomialRing(K, 2, order='lex') @@ -2392,7 +2392,7 @@ def hilbert_polynomial(self): rational coefficients such that `HP(d) = dim_K R_d` for all but finitely many positive integers `d`. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ) sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5]) @@ -2498,7 +2498,7 @@ def hilbert_numerator(self, singular=singular_default, grading=None): An optional ``grading`` can be given, in which case the graded (or weighted) Hilbert numerator is given. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ) sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5]) @@ -2640,7 +2640,7 @@ def _groebner_basis_macaulay2(self): it can compute the Groebner basis of ideals in polynomial rings over the integers. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(ZZ, 4) sage: I = ideal(x*y-z^2, y^2-w^2) @@ -2840,7 +2840,7 @@ def _groebner_strategy(self): Return Singular's Groebner Strategy object for the Groebner basis of this ideal which implements some optimized functions. - EXAMPLE:: + EXAMPLES:: sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) @@ -2868,7 +2868,7 @@ def reduce(self,p): There are left and two-sided ideals. Hence, - EXAMPLE:: + EXAMPLES:: sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) @@ -2932,7 +2932,7 @@ def syzygy_module(self): two-sided, then the syzygies are only one-sided. In that case, a warning is printed. - EXAMPLE:: + EXAMPLES:: sage: A. = FreeAlgebra(QQ, 3) sage: H = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) @@ -2987,7 +2987,7 @@ def res(self, length): two-sided, then the resolution is only one-sided. In that case, a warning is printed. - EXAMPLE:: + EXAMPLES:: sage: A. = FreeAlgebra(QQ, 3) sage: H = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) @@ -3048,7 +3048,7 @@ def gens(self): Return a set of generators / a basis of this ideal. This is usually the set of generators provided during object creation. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ,2) sage: I = Ideal([x,y+1]); I @@ -3064,7 +3064,7 @@ def basis(self): """ Shortcut to ``gens()``. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ,2) sage: I = Ideal([x,y+1]) @@ -3100,7 +3100,7 @@ def __lt__(self, other): #. Return ``True``. - EXAMPLE:: + EXAMPLES:: sage: R. = GF(32003)[] sage: I = R*[x^2 + x, y] @@ -3183,7 +3183,7 @@ def __gt__(self, other): :meth:`__lt__`. - EXAMPLE:: + EXAMPLES:: sage: R. = GF(32003)[] sage: I = R*[x^2 + x, y] @@ -3211,7 +3211,7 @@ def __cmp__(self, other): This algorithm relies on :meth:`.__eq__`. - EXAMPLE:: + EXAMPLES:: sage: R. = ZZ[]; I = R*[x^2 + y, 2*y]; J = R*[x^2 + y] sage: cmp(I,J) @@ -3271,7 +3271,7 @@ def __eq__(self, other): :meth:`__lt__` :meth:`__gt__` - EXAMPLE:: + EXAMPLES:: sage: R = PolynomialRing(QQ,'x,y,z') sage: I = R.ideal() @@ -3808,7 +3808,7 @@ def change_ring(self, P): - ``P`` - a multivariate polynomial ring - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ,3,order='lex') sage: I = sage.rings.ideal.Cyclic(P) @@ -3982,7 +3982,7 @@ def homogenize(self, var='h'): (default: 'h') - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(2)) sage: I = Ideal([x^2*y + z + 1, x + y^2 + 1]); I @@ -4019,7 +4019,7 @@ def is_homogeneous(self): Return ``True`` if this ideal is spanned by homogeneous polynomials, i.e. if it is a homogeneous ideal. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ,3) sage: I = sage.rings.ideal.Katsura(P) @@ -4408,7 +4408,7 @@ def weil_restriction(self): OUTPUT: MPolynomial Ideal - EXAMPLE:: + EXAMPLES:: sage: k. = GF(2^2) sage: P. = PolynomialRing(k,2) diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx index 46a08c9b10b..9faada96a9b 100644 --- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx @@ -2030,7 +2030,7 @@ cdef class MPolynomial_libsingular(sage.rings.polynomial.multi_polynomial.MPolyn The value x must be an element of the base ring. That assumption is not verified. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: x._new_constant_poly(2/1,R) diff --git a/src/sage/rings/polynomial/multi_polynomial_ring.py b/src/sage/rings/polynomial/multi_polynomial_ring.py index deb44e02543..256b09dc0b0 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ring.py +++ b/src/sage/rings/polynomial/multi_polynomial_ring.py @@ -553,7 +553,7 @@ def monomial_quotient(self, f, g, coeff=False): OUTPUT: monomial. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict_domain sage: P. = MPolynomialRing_polydict_domain(QQ, 3, order='degrevlex') @@ -644,7 +644,7 @@ def monomial_lcm(self, f, g): OUTPUT: monomial. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict_domain sage: P. = MPolynomialRing_polydict_domain(QQ,3, order='degrevlex') @@ -855,7 +855,7 @@ def monomial_all_divisors(self, t): OUTPUT: a list of monomials. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict_domain sage: P. = MPolynomialRing_polydict_domain(QQ,3, order='degrevlex') diff --git a/src/sage/rings/polynomial/multi_polynomial_ring_generic.pyx b/src/sage/rings/polynomial/multi_polynomial_ring_generic.pyx index a7bbc6ee82d..6f397a49ac5 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ring_generic.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_ring_generic.pyx @@ -275,7 +275,7 @@ cdef class MPolynomialRing_generic(sage.rings.ring.CommutativeRing): - ``x`` -- a variable of self. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: P.univariate_ring(y) @@ -502,7 +502,7 @@ cdef class MPolynomialRing_generic(sage.rings.ring.CommutativeRing): of ``self`` will be represented as ``gap(self.base_ring()).name()``. - The result of applying the GAP interface to ``self`` is cached. - EXAMPLE:: + EXAMPLES:: sage: F = CyclotomicField(8) sage: P. = F[] diff --git a/src/sage/rings/polynomial/multi_polynomial_sequence.py b/src/sage/rings/polynomial/multi_polynomial_sequence.py index f6a42394753..77d20a58da1 100644 --- a/src/sage/rings/polynomial/multi_polynomial_sequence.py +++ b/src/sage/rings/polynomial/multi_polynomial_sequence.py @@ -186,7 +186,7 @@ def is_PolynomialSequence(F): - ``F`` - anything - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQ) sage: I = [[x^2 + y^2], [x^2 - y^2]] @@ -398,7 +398,7 @@ def __copy__(self): """ Return a copy of this system. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() @@ -413,7 +413,7 @@ def ring(self): """ Return the polynomial ring all elements live in. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True,gf2=True,order='block') sage: F,s = sr.polynomial_system() @@ -434,7 +434,7 @@ def nparts(self): """ Return number of parts of this system. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() @@ -447,7 +447,7 @@ def parts(self): """ Return a tuple of parts of this system. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() @@ -461,7 +461,7 @@ def part(self, i): """ Return ``i``-th part of this system. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() @@ -475,7 +475,7 @@ def ideal(self): """ Return ideal spanned by the elements of this system. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() @@ -507,7 +507,7 @@ def groebner_basis(self, *args, **kwargs): - ``kwargs`` - dictionary of arguments passed to ``MPolynomialIdeal.groebner_basis`` call - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() @@ -521,7 +521,7 @@ def monomials(self): """ Return an unordered tuple of monomials in this polynomial system. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() @@ -538,7 +538,7 @@ def nmonomials(self): """ Return the number of monomials present in this system. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() @@ -552,7 +552,7 @@ def variables(self): Return all variables present in this system. This tuple may or may not be equal to the generators of the ring of this system. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() @@ -569,7 +569,7 @@ def nvariables(self): """ Return number of variables present in this system. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system() @@ -677,7 +677,7 @@ def coefficient_matrix(self, sparse=True): - ``sparse`` - construct a sparse matrix (default: ``True``) - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(127),4) sage: I = sage.rings.ideal.Katsura(P) @@ -749,7 +749,7 @@ def subs(self, *args, **kwargs): - ``args`` - arguments to be passed to ``MPolynomial.subs`` - ``kwargs`` - keyword arguments to be passed to ``MPolynomial.subs`` - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True) sage: F,s = sr.polynomial_system(); F @@ -763,7 +763,7 @@ def _singular_(self): """ Return Singular ideal representation of this system. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(127)) sage: I = sage.rings.ideal.Katsura(P) @@ -785,7 +785,7 @@ def _magma_init_(self, magma): Return Magma ideal representation of the ideal spanned by this system. - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(allow_zero_inversions=True,gf2=True) sage: F,s = sr.polynomial_system() @@ -807,7 +807,7 @@ def _repr_(self): """ Return a string representation of this system. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(127)) sage: I = sage.rings.ideal.Katsura(P) @@ -835,7 +835,7 @@ def __add__(self, right): Add polynomial systems together, i.e. create a union of their polynomials. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(127)) sage: I = sage.rings.ideal.Katsura(P) @@ -879,7 +879,7 @@ def connection_graph(self): vertices and edges between two variables if they appear in the same polynomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: F = Sequence([x*y + y + 1, z + 1]) @@ -935,7 +935,7 @@ def _groebner_strategy(self): This object allows to compute normal forms efficiently, since all conversion overhead is avoided. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(127)) sage: F = Sequence([x*y + z, y + z + 1]) @@ -950,7 +950,7 @@ def maximal_degree(self): """ Return the maximal degree of any polynomial in this sequence. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(7)) sage: F = Sequence([x*y + x, x]) @@ -994,7 +994,7 @@ def reduced(self): - `LC(g_i) == 1` for all `i` if the coefficient ring is a field. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(QQ) sage: F = Sequence([z*x+y^3,z+y^3,z+x*y]) @@ -1076,7 +1076,7 @@ def is_groebner(self, singular=singular): `S * G = \sum_{i=0}^{m} h_ig_i ---->_G 0.` - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(GF(127),10) sage: I = sage.rings.ideal.Cyclic(R,4) @@ -1140,7 +1140,7 @@ def eliminate_linear_variables(self, maxlength=Infinity, skip=None, return_reduc When ``return_reductors==False``, only the first sequence is returned. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: F = Sequence([c + d + b + 1, a + c + d, a*b + c, b*c*d + c]) @@ -1290,7 +1290,7 @@ def _groebner_strategy(self): This object allows to compute normal forms efficiently, since all conversion overhead is avoided. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(2)) sage: F = Sequence([x*y + z, y + z + 1]) @@ -1493,7 +1493,7 @@ def reduced(self): - `LT(g_i)` does not divide `m` for all monomials `m` of `{g_1,...,g_{i-1},g_{i+1},...,g_s}` - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 4, gf2=True, polybori=True) sage: F,s = sr.polynomial_system() @@ -1527,7 +1527,7 @@ def weil_restriction(self): variety corresponding to this polynomial system and express it as a polynomial system over `\mathbb{F}_2`. - EXAMPLE:: + EXAMPLES:: sage: k. = GF(2^2) sage: P. = PolynomialRing(k,2) diff --git a/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py b/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py index 255f2d8dc19..e0232e09a5f 100644 --- a/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py +++ b/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py @@ -161,7 +161,7 @@ def _new_constant_poly(self, a, P): The value a must be an element of the base ring of P. That assumption is not verified. - EXAMPLE:: + EXAMPLES:: sage: R. = Zp(5)[] sage: t._new_constant_poly(O(5),R) diff --git a/src/sage/rings/polynomial/pbori.pyx b/src/sage/rings/polynomial/pbori.pyx index 8238d8df824..3cfa2ef82de 100644 --- a/src/sage/rings/polynomial/pbori.pyx +++ b/src/sage/rings/polynomial/pbori.pyx @@ -449,7 +449,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): def __reduce__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(2) sage: loads(dumps(P)) == P # indirect doctest @@ -583,7 +583,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(2) sage: P # indirect doctest @@ -884,7 +884,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): """ Convert ``other`` to this Boolean polynomial ring. - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(2) sage: P(5) # indirect doctest @@ -1020,7 +1020,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): """ Return a hash of this boolean polynomial ring. - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(4, order='lex') sage: P @@ -1355,7 +1355,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): the ordered list of variable names of this ring. ``R`` also has the same term ordering as this ring. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(2) sage: R = B.cover_ring(); R @@ -1384,7 +1384,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): self.cover_ring()``, and `x_i` any element in the set of variables of this ring. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(2) sage: I = B.defining_ideal(); I @@ -1405,7 +1405,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): TODO: This method does not only return a string but actually calls Singular. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(2) sage: B._singular_() # indirect doctest @@ -1430,7 +1430,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): - ``magma`` - a magma instance - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: magma(B) # indirect doctest; optional - magma @@ -1609,7 +1609,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): def get_order_code(self): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: B.get_order_code() @@ -1630,7 +1630,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): def get_base_order_code(self): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: B.get_base_order_code() @@ -1698,7 +1698,7 @@ cdef class BooleanPolynomialRing(MPolynomialRing_generic): ring.clone(ordering=..., names=..., block=...) generates a shallow copy of ring, but with different ordering, names or blocks if given. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: B.clone() @@ -1898,7 +1898,7 @@ class BooleanMonomialMonoid(UniqueRepresentation,Monoid_class): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleanMonomialMonoid sage: P. = BooleanPolynomialRing(2) @@ -1912,7 +1912,7 @@ class BooleanMonomialMonoid(UniqueRepresentation,Monoid_class): """ Return a hash for this monoid. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleanMonomialMonoid sage: P. = BooleanPolynomialRing(2) @@ -2208,7 +2208,7 @@ cdef class BooleanMonomial(MonoidElement): - ``parent`` - parent monoid this element lives in - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleanMonomialMonoid, BooleanMonomial sage: P. = BooleanPolynomialRing(3) @@ -2223,7 +2223,7 @@ cdef class BooleanMonomial(MonoidElement): """ def __init__(self, parent): """ - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleanMonomialMonoid, BooleanMonomial sage: P. = BooleanPolynomialRing(3) @@ -2327,7 +2327,7 @@ cdef class BooleanMonomial(MonoidElement): """ Evaluate this monomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = x*y @@ -2360,7 +2360,7 @@ cdef class BooleanMonomial(MonoidElement): """ Return a hash of this monomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = x*y @@ -2374,7 +2374,7 @@ cdef class BooleanMonomial(MonoidElement): """ A hash value which is stable across processes. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: m = x.lm() @@ -2393,7 +2393,7 @@ cdef class BooleanMonomial(MonoidElement): """ Return the corresponding boolean ring. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: a.lm().ring() is B @@ -2406,7 +2406,7 @@ cdef class BooleanMonomial(MonoidElement): Return the variable index of the first variable in this monomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = x*y @@ -2491,7 +2491,7 @@ cdef class BooleanMonomial(MonoidElement): Return a set of boolean monomials with all divisors of this monomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = x*y @@ -2510,7 +2510,7 @@ cdef class BooleanMonomial(MonoidElement): - ``rhs`` - a boolean monomial - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = x @@ -2538,7 +2538,7 @@ cdef class BooleanMonomial(MonoidElement): - ``rhs`` - a boolean monomial - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = x*y @@ -2554,7 +2554,7 @@ cdef class BooleanMonomial(MonoidElement): """ Return a boolean set of variables in this monomials. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = x*y @@ -2596,7 +2596,7 @@ cdef class BooleanMonomial(MonoidElement): """ Return a tuple of the variables in this monomial. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleanMonomialMonoid sage: P. = BooleanPolynomialRing(3) @@ -2746,7 +2746,7 @@ cdef class BooleanMonomial(MonoidElement): necessary to supply the ring as argument, when constructing a set out of a navigator. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleSet sage: B = BooleanPolynomialRing(5,'x') @@ -2775,7 +2775,7 @@ cdef class BooleanMonomial(MonoidElement): - ``rhs`` - a boolean monomial - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: a,b,c,d = a.lm(), b.lm(), c.lm(), d.lm() @@ -2817,7 +2817,7 @@ cdef class BooleanMonomialVariableIterator: """ Return an iterator over the variables of a boolean monomial. - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(3) sage: f = x*y + z + 1 @@ -2834,7 +2834,7 @@ cdef class BooleanMonomialVariableIterator: def __next__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(3) sage: f = x*y + z + 1 @@ -2870,7 +2870,7 @@ cdef class BooleanMonomialIterator: """ def __iter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(3) sage: f = x*y + z + 1 @@ -2887,7 +2887,7 @@ cdef class BooleanMonomialIterator: def __next__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(3) sage: f = x*y + z + 1 @@ -2942,7 +2942,7 @@ cdef class BooleanPolynomial(MPolynomial): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: repr(a+b+z^2+1) # indirect doctest @@ -2955,7 +2955,7 @@ cdef class BooleanPolynomial(MPolynomial): Return string representing this boolean polynomial but change the variable names to ``varnames``. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: a._repr_with_changed_varnames(['x','y','z']) @@ -2997,7 +2997,7 @@ cdef class BooleanPolynomial(MPolynomial): r""" Return a LaTeX representation of this boolean polynomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: latex(a+b+a*z^2+1) # indirect doctest @@ -3008,7 +3008,7 @@ cdef class BooleanPolynomial(MPolynomial): cpdef _add_(left, right): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = a*z + b + 1 @@ -3023,7 +3023,7 @@ cdef class BooleanPolynomial(MPolynomial): cpdef _sub_(left, right): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = a*z + b + 1 @@ -3035,7 +3035,7 @@ cdef class BooleanPolynomial(MPolynomial): cpdef _lmul_(self, RingElement left): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: k = B.base_ring() @@ -3058,7 +3058,7 @@ cdef class BooleanPolynomial(MPolynomial): cpdef _mul_(left, right): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = a*z + b + 1 @@ -3073,7 +3073,7 @@ cdef class BooleanPolynomial(MPolynomial): cpdef _div_(left, right): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = a*z + b + 1 @@ -3090,7 +3090,7 @@ cdef class BooleanPolynomial(MPolynomial): def is_equal(self, BooleanPolynomial right): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = a*z + b + 1 @@ -3249,7 +3249,7 @@ cdef class BooleanPolynomial(MPolynomial): r""" Return -``self``. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = a*z + b + 1 @@ -3597,7 +3597,7 @@ cdef class BooleanPolynomial(MPolynomial): Note that this condition is equivalent to being 1 for boolean polynomials. - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(2) sage: P.one().is_unit() @@ -3714,7 +3714,7 @@ cdef class BooleanPolynomial(MPolynomial): r""" Return a tuple of all variables appearing in ``self``. - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(3) sage: (x + y).variables() @@ -3746,7 +3746,7 @@ cdef class BooleanPolynomial(MPolynomial): Return the number of variables used to form this boolean polynomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: f = a*b*c + 1 @@ -3827,7 +3827,7 @@ cdef class BooleanPolynomial(MPolynomial): Return a list of monomials appearing in ``self`` ordered largest to smallest. - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(3,order='lex') sage: f = a + c*b @@ -3866,7 +3866,7 @@ cdef class BooleanPolynomial(MPolynomial): Return a list of monomials appearing in ``self`` ordered largest to smallest. - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(3,order='lex') sage: f = a + c*b @@ -3892,7 +3892,7 @@ cdef class BooleanPolynomial(MPolynomial): - ``mon`` - a monomial - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(2) sage: x.monomial_coefficient(x) @@ -3925,7 +3925,7 @@ cdef class BooleanPolynomial(MPolynomial): """ Return the constant coefficient of this boolean polynomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: a.constant_coefficient() @@ -3943,7 +3943,7 @@ cdef class BooleanPolynomial(MPolynomial): r""" Return hash for ``self``. - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(2) sage: {x:1} # indirect doctest @@ -3982,7 +3982,7 @@ cdef class BooleanPolynomial(MPolynomial): """ Evaluate this boolean polynomials. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = x*y + z + 1 @@ -4057,7 +4057,7 @@ cdef class BooleanPolynomial(MPolynomial): - ``**kwds`` - names parameters - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(3) sage: f = x*y + z + y*z + 1 @@ -4131,7 +4131,7 @@ cdef class BooleanPolynomial(MPolynomial): def __reduce__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(2) sage: loads(dumps(a)) == a @@ -4187,7 +4187,7 @@ cdef class BooleanPolynomial(MPolynomial): Return a ``BooleSet`` with all monomials appearing in this polynomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: (a*b+z+1).set() @@ -4227,7 +4227,7 @@ cdef class BooleanPolynomial(MPolynomial): r""" Return elimination length as used in the SlimGB algorithm. - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing(2) sage: x.elength() @@ -4305,7 +4305,7 @@ cdef class BooleanPolynomial(MPolynomial): Return degree of leading monomial with respect to the lexicographical ordering. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3,order='lex') sage: f = x + y*z @@ -4333,7 +4333,7 @@ cdef class BooleanPolynomial(MPolynomial): r""" Return ``True`` if this element is constant. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: x.constant() @@ -4362,7 +4362,7 @@ cdef class BooleanPolynomial(MPolynomial): necessary to supply the ring as argument, when constructing a set out of a navigator. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleSet sage: B = BooleanPolynomialRing(5,'x') @@ -4395,7 +4395,7 @@ cdef class BooleanPolynomial(MPolynomial): """ Map every variable ``x_i`` in this polynomial to ``x_i + 1``. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = a*b + z + 1; f @@ -4414,7 +4414,7 @@ cdef class BooleanPolynomial(MPolynomial): Return a ``BooleSet`` of all divisors of the leading monomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = a*b + z + 1 @@ -4432,7 +4432,7 @@ cdef class BooleanPolynomial(MPolynomial): Return the first term with respect to the lexicographical term ordering. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3,order='lex') sage: f = b*z + a + 1 @@ -4457,7 +4457,7 @@ cdef class BooleanPolynomial(MPolynomial): - ``rhs`` - a boolean polynomial - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4,order='deglex') sage: f = (a*b + 1)*(c + 1) @@ -4479,7 +4479,7 @@ cdef class BooleanPolynomial(MPolynomial): Return the number of nodes in the ZDD implementing this polynomial. - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -4498,7 +4498,7 @@ cdef class BooleanPolynomial(MPolynomial): Return the number of variables used to form this boolean polynomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: f = a*b*c + 1 @@ -4522,7 +4522,7 @@ cdef class BooleanPolynomial(MPolynomial): - ``deg`` - a degree - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: f = a*b*c + c*d + a*b + 1 @@ -4547,7 +4547,7 @@ cdef class BooleanPolynomial(MPolynomial): Return ``True`` if this boolean polynomial has a constant part, i.e. if ``1`` is a term. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: f = a*b*c + c*d + a*b + 1 @@ -4578,7 +4578,7 @@ cdef class BooleanPolynomial(MPolynomial): - ``s`` - candidate points for evaluation to zero - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: f = a*b + c + d + 1 @@ -4630,7 +4630,7 @@ cdef class BooleanPolynomial(MPolynomial): Return the S-Polynomial of this boolean polynomial and the other boolean polynomial ``rhs``. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: f = a*b*c + c*d + a*b + 1 @@ -4649,7 +4649,7 @@ cdef class BooleanPolynomial(MPolynomial): """ A hash value which is stable across processes. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: x.stable_hash() @@ -4667,7 +4667,7 @@ cdef class BooleanPolynomial(MPolynomial): """ Return the parent of this boolean polynomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: a.ring() is B @@ -4689,7 +4689,7 @@ cdef class BooleanPolynomial(MPolynomial): If I is an ideal, the generators are used. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: I = B.ideal((x0 + x1 + x2 + x3, \ @@ -4748,7 +4748,7 @@ cdef class PolynomialConstruct: Return the leading monomial of boolean polynomial ``x``, with respect to to the order of parent ring. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -4762,7 +4762,7 @@ cdef class PolynomialConstruct: Construct a new :class:`BooleanPolynomial` or return ``x`` if it is a :class:`BooleanPolynomial` already. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -4799,7 +4799,7 @@ cdef class MonomialConstruct: Construct a new :class:`BooleanMonomial` or return ``x`` if it is a :class:`BooleanMonomial` already. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -4836,7 +4836,7 @@ cdef class VariableConstruct: """ Return a Variable for ``x``. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -4859,7 +4859,7 @@ cdef class BooleanPolynomialIterator: """ def __iter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: list(B.random_element()) # indirect doctest @@ -4873,7 +4873,7 @@ cdef class BooleanPolynomialIterator: def __next__(self): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: it = iter(B.random_element()) @@ -5190,7 +5190,7 @@ class BooleanPolynomialIdeal(MPolynomialIdeal): This returns 0 if and only if the element is in this ideal. In any case, this reduction is unique up to monomial orders. - EXAMPLE:: + EXAMPLES:: sage: P = PolynomialRing(GF(2),10, 'x') sage: B = BooleanPolynomialRing(10,'x') @@ -5226,7 +5226,7 @@ class BooleanPolynomialIdeal(MPolynomialIdeal): - ``LT(g_i)`` does not divide ``m`` for all monomials ``m`` of ``{g_1,...,g_{i-1},g_{i+1},...,g_s}`` - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 4, gf2=True, polybori=True) sage: F,s = sr.polynomial_system() @@ -5238,7 +5238,7 @@ class BooleanPolynomialIdeal(MPolynomialIdeal): def __eq__(self, other): """ - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 4, gf2=True, polybori=True) sage: F,s = sr.polynomial_system() sage: I = F.ideal() @@ -5258,7 +5258,7 @@ class BooleanPolynomialIdeal(MPolynomialIdeal): def __ne__(self, other): """ - EXAMPLE:: + EXAMPLES:: sage: sr = mq.SR(1, 1, 1, 4, gf2=True, polybori=True) sage: F,s = sr.polynomial_system() sage: I = F.ideal() @@ -5330,7 +5330,7 @@ cdef class BooleSet: - ``param`` - either a :class:`CCuddNavigator`, a :class:`BooleSet` or ``None``. - ``ring`` - a boolean polynomial ring. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleSet sage: B. = BooleanPolynomialRing(4) @@ -5398,7 +5398,7 @@ cdef class BooleSet: def __repr__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleSet sage: B. = BooleanPolynomialRing(4) @@ -5412,7 +5412,7 @@ cdef class BooleSet: """ Return ``self``. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: BS = (a*b + c).set() @@ -5425,7 +5425,7 @@ cdef class BooleSet: """ Return ``True`` if this set is empty. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: BS = (a*b + c).set() @@ -5450,7 +5450,7 @@ cdef class BooleSet: necessary to supply the ring as argument, when constructing a set out of a navigator. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleSet sage: B = BooleanPolynomialRing(5,'x') @@ -5481,7 +5481,7 @@ cdef class BooleSet: """ Return the parent ring. - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5506,7 +5506,7 @@ cdef class BooleSet: - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5535,7 +5535,7 @@ cdef class BooleSet: X \ Y = \{x | x\in X\;\mathrm{and}\;x\not\in Y\}. - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5569,7 +5569,7 @@ cdef class BooleSet: X \cup Y = \{x | x\in X\;\mathrm{or}\;x\in Y\}. - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5595,7 +5595,7 @@ cdef class BooleSet: """ Swaps the presence of ``x_i`` in each entry of the set. - EXAMPLE:: + EXAMPLES:: sage: P. = BooleanPolynomialRing() sage: f = a+b @@ -5614,7 +5614,7 @@ cdef class BooleSet: """ Return the variables in this set as a monomial. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(order='lex') sage: f = a + b*e + d*f + e + 1 @@ -5631,7 +5631,7 @@ cdef class BooleSet: """ Return the number of nodes in the ZDD. - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5661,7 +5661,7 @@ cdef class BooleSet: def __len__(self): """ - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5675,7 +5675,7 @@ cdef class BooleSet: def __hash__(self): """ - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5696,7 +5696,7 @@ cdef class BooleSet: - ``vs`` - a boolean set - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: f = a*b + b + 1 @@ -5717,7 +5717,7 @@ cdef class BooleSet: - ``m`` - a monomial - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: f = a*b @@ -5743,7 +5743,7 @@ cdef class BooleSet: """ A hash value which is stable across processes. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: s = x.set() @@ -5763,7 +5763,7 @@ cdef class BooleSet: Divide each element of this set by the monomial ``rhs`` and return a new set containing the result. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(order='lex') sage: f = b*e + b*c*d + b @@ -5788,7 +5788,7 @@ cdef class BooleSet: - ``i`` - an index - EXAMPLE:: + EXAMPLES:: sage: BooleanPolynomialRing(5,'x') Boolean PolynomialRing in x0, x1, x2, x3, x4 @@ -5813,7 +5813,7 @@ cdef class BooleSet: - ``i`` - an index - EXAMPLE:: + EXAMPLES:: sage: BooleanPolynomialRing(5,'x') Boolean PolynomialRing in x0, x1, x2, x3, x4 @@ -5833,7 +5833,7 @@ cdef class BooleSet: Extend this set to include all divisors of the elements already in this set and return the result as a new set. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: f = a*d*e + a*f + b*d*e + c*d*e + 1 @@ -5850,7 +5850,7 @@ cdef class BooleSet: """ Return a new set containing a divisor of all elements of this set. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: f = a*d*e + a*f + a*b*d*e + a*c*d*e + a @@ -5874,7 +5874,7 @@ cdef class BooleSet: X \cap Y = \{x | x\in X\;\mathrm{and}\;x\in Y\}. - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5897,7 +5897,7 @@ cdef class BooleSet: - ``m`` - a boolean monomial - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5916,7 +5916,7 @@ cdef class BooleSet: - ``m`` - a boolean monomial - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5931,7 +5931,7 @@ cdef class BooleSet: """ Return the size of this set as a floating point number. - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(5,'x') sage: x0,x1,x2,x3,x4 = B.gens() @@ -5960,7 +5960,7 @@ cdef class BooleSetIterator: """ def __iter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: f = B.random_element() sage: it = iter(f.set()) # indirect doctesrt @@ -5974,7 +5974,7 @@ cdef class BooleSetIterator: def __next__(self): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: f = B.random_element() @@ -6058,7 +6058,7 @@ cdef class BooleanPolynomialVector: """ A vector of boolean polynomials. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import BooleanPolynomialVector @@ -6079,7 +6079,7 @@ cdef class BooleanPolynomialVector: - ``I`` - a list of boolean polynomials. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import BooleanPolynomialVector @@ -6106,7 +6106,7 @@ cdef class BooleanPolynomialVector: def __iter__(self): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import BooleanPolynomialVector @@ -6119,7 +6119,7 @@ cdef class BooleanPolynomialVector: def __len__(self): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import BooleanPolynomialVector @@ -6135,7 +6135,7 @@ cdef class BooleanPolynomialVector: def __getitem__(self, ind): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import BooleanPolynomialVector @@ -6165,7 +6165,7 @@ cdef class BooleanPolynomialVector: def __setitem__(self, ind, p): """ - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import BooleanPolynomialVector @@ -6198,7 +6198,7 @@ cdef class BooleanPolynomialVector: """ Append the element ``el`` to this vector. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import BooleanPolynomialVector @@ -6265,7 +6265,7 @@ cdef class ReductionStrategy: """ def __init__(self, ring): """ - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6277,7 +6277,7 @@ cdef class ReductionStrategy: def __dealloc__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6295,7 +6295,7 @@ cdef class ReductionStrategy: - ``p`` - a boolean polynomial. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6325,7 +6325,7 @@ cdef class ReductionStrategy: Compute the normal form of ``p`` w.r.t. to the generators of this reduction strategy object. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6349,7 +6349,7 @@ cdef class ReductionStrategy: - ``p`` - a polynomial - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6374,7 +6374,7 @@ cdef class ReductionStrategy: - ``p`` - a polynomial - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6396,7 +6396,7 @@ cdef class ReductionStrategy: Return ``True`` if ``p`` can be reduced by the generators of this strategy. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6420,7 +6420,7 @@ cdef class ReductionStrategy: - ``p`` - a boolean polynomial - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6460,7 +6460,7 @@ cdef class ReductionStrategy: - ``monomials`` - - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6521,7 +6521,7 @@ cdef class ReductionStrategy: def __len__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6555,7 +6555,7 @@ cdef class FGLMStrategy: """ Execute the FGLM algorithm. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6607,7 +6607,7 @@ cdef class FGLMStrategy: """ Execute the FGLM algorithm. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6638,7 +6638,7 @@ cdef class GroebnerStrategy: - ``param`` - either ``None`` or a :class:`GroebnerStrategy` object. - EXAMPLE:: + EXAMPLES:: sage: from brial import GroebnerStrategy sage: B. = BooleanPolynomialRing() @@ -6666,7 +6666,7 @@ cdef class GroebnerStrategy: def __dealloc__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from brial import GroebnerStrategy sage: B. = BooleanPolynomialRing() @@ -6691,7 +6691,7 @@ cdef class GroebnerStrategy: - ``p`` - a polynomial - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6718,7 +6718,7 @@ cdef class GroebnerStrategy: - ``p`` - a polynomial - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6746,7 +6746,7 @@ cdef class GroebnerStrategy: - ``p`` - a polynomial - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6834,7 +6834,7 @@ cdef class GroebnerStrategy: - ``v`` - a boolean polynomial vector - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import GroebnerStrategy @@ -6911,7 +6911,7 @@ cdef class GroebnerStrategy: def all_generators(self): """ - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -6943,7 +6943,7 @@ cdef class GroebnerStrategy: - ``v`` - the index of a variable - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import GroebnerStrategy sage: gb = GroebnerStrategy(B) @@ -6977,7 +6977,7 @@ cdef class GroebnerStrategy: - ``p`` - a boolean polynomial - EXAMPLE:: + EXAMPLES:: sage: P = PolynomialRing(GF(2),10, 'x') sage: B = BooleanPolynomialRing(10,'x') @@ -7015,7 +7015,7 @@ cdef class GroebnerStrategy: - ``m`` - a :class:`BooleanMonomial` - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: f = B.random_element() @@ -7037,7 +7037,7 @@ cdef class GroebnerStrategy: """ Return the number of generators. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import GroebnerStrategy @@ -7182,7 +7182,7 @@ def add_up_polynomials(BooleanPolynomialVector v, BooleanPolynomial init): - ``v`` - a vector of boolean polynomials - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -7211,7 +7211,7 @@ def red_tail(ReductionStrategy s, BooleanPolynomial p): - ``s`` - a reduction strategy - ``p`` - a polynomial - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -7230,7 +7230,7 @@ def map_every_x_to_x_plus_one(BooleanPolynomial p): """ Map every variable ``x_i`` in this polynomial to ``x_i + 1``. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: f = a*b + z + 1; f @@ -7257,7 +7257,7 @@ def zeros(pol, BooleSet s): - ``s`` - a set of points encoded as a ``BooleSet`` - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(4) sage: f = a*b + a*c + d + b @@ -7302,7 +7302,7 @@ def interpolate(zero, one): - ``one`` - the set of ones - EXAMPLE:: + EXAMPLES:: sage: B = BooleanPolynomialRing(4,"x0,x1,x2,x3") sage: x = B.gen @@ -7464,7 +7464,7 @@ def ll_red_nf_redsb(p, BooleSet reductors): - ``reductors`` - a boolean set encoding a reduced Groebner basis with linear leading terms. - EXAMPLE:: + EXAMPLES:: sage: from brial import ll_red_nf_redsb sage: B. = BooleanPolynomialRing() @@ -7506,7 +7506,7 @@ def ll_red_nf_noredsb(BooleanPolynomial p, BooleSet reductors): - ``reductors`` - a boolean set encoding a Groebner basis with linear leading terms. - EXAMPLE:: + EXAMPLES:: sage: from brial import ll_red_nf_noredsb sage: B. = BooleanPolynomialRing() @@ -7539,7 +7539,7 @@ def ll_red_nf_noredsb_single_recursive_call(BooleanPolynomial p, BooleSet reduct - ``reductors`` - a boolean set encoding a Groebner basis with linear leading terms. - EXAMPLE:: + EXAMPLES:: sage: from brial import ll_red_nf_noredsb_single_recursive_call sage: B. = BooleanPolynomialRing() @@ -7580,7 +7580,7 @@ def if_then_else(root, a, b): - ``b`` - the else branch, a ``BooleSet`` or a ``BoolePolynomial`` - EXAMPLE:: + EXAMPLES:: sage: from brial import if_then_else sage: B = BooleanPolynomialRing(6,'x') @@ -7658,7 +7658,7 @@ def top_index(s): - ``s`` - ``BooleSet``, ``BooleMonomial``, ``BoolePolynomial`` - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing(3) sage: from brial import top_index @@ -7764,7 +7764,7 @@ def gauss_on_polys(inp): - ``inp`` - an iterable - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from brial import * @@ -7806,7 +7806,7 @@ def substitute_variables(BooleanPolynomialRing parent, vec, BooleanPolynomial po """ ``var(i)`` is replaced by ``vec[i]`` in ``poly``. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: f = a*b + c + 1 @@ -7846,7 +7846,7 @@ def set_random_seed(seed): """ The the PolyBoRi random seed to ``seed`` - EXAMPLE:: + EXAMPLES:: sage: from brial import random_set, set_random_seed sage: B. = BooleanPolynomialRing() @@ -7872,7 +7872,7 @@ def random_set(BooleanMonomial variables, length): Return a random set of monomials with ``length`` elements with each element in the variables ``variables``. - EXAMPLE:: + EXAMPLES:: sage: from brial import random_set, set_random_seed sage: B. = BooleanPolynomialRing() @@ -7896,7 +7896,7 @@ def unpickle_BooleanPolynomial(ring, string): """ Unpickle boolean polynomials - EXAMPLE:: + EXAMPLES:: sage: T = TermOrder('deglex',2)+TermOrder('deglex',2) sage: P. = BooleanPolynomialRing(4,order=T) @@ -7911,7 +7911,7 @@ def unpickle_BooleanPolynomial0(ring, l): """ Unpickle boolean polynomials - EXAMPLE:: + EXAMPLES:: sage: T = TermOrder('deglex',2)+TermOrder('deglex',2) sage: P. = BooleanPolynomialRing(4,order=T) @@ -7927,7 +7927,7 @@ def unpickle_BooleanPolynomialRing(n, names, order): """ Unpickle boolean polynomial rings. - EXAMPLE:: + EXAMPLES:: sage: T = TermOrder('deglex',2)+TermOrder('deglex',2) sage: P. = BooleanPolynomialRing(4,order=T) @@ -7947,7 +7947,7 @@ cdef class BooleConstant: - ``i`` - an integer - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleConstant sage: [BooleConstant(i) for i in range(5)] @@ -7957,7 +7957,7 @@ cdef class BooleConstant: def __repr__(self): """ - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleConstant sage: repr((BooleConstant(0),BooleConstant(1))) # indirect doctest @@ -7972,7 +7972,7 @@ cdef class BooleConstant: """ Get degree of boolean constant. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleConstant sage: BooleConstant(0).deg() @@ -7986,7 +7986,7 @@ cdef class BooleConstant: """ Get variables (return always and empty tuple). - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleConstant sage: BooleConstant(0).variables() @@ -8000,7 +8000,7 @@ cdef class BooleConstant: """ Check whether boolean constant is one. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleConstant sage: BooleConstant(0).is_one() @@ -8014,7 +8014,7 @@ cdef class BooleConstant: """ Check whether boolean constant is zero. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleConstant sage: BooleConstant(1).is_zero() @@ -8028,7 +8028,7 @@ cdef class BooleConstant: """ This is always true for in this case. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleConstant sage: BooleConstant(1).is_constant() @@ -8042,7 +8042,7 @@ cdef class BooleConstant: """ This is true for for `BooleConstant(1)`. - EXAMPLE:: + EXAMPLES:: sage: from brial import BooleConstant sage: BooleConstant(1).has_constant_part() @@ -8091,7 +8091,7 @@ cdef class VariableFactory: Initialize variable factory, if ring is given. Otherwise it initializes a plain constructor - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -8108,7 +8108,7 @@ cdef class VariableFactory: """ Return a Variable for ``x``. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -8141,7 +8141,7 @@ cdef class MonomialFactory: can be used as a Monomial factory for the given ring. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -8154,7 +8154,7 @@ cdef class MonomialFactory: Initialized a polynomial factory of ring is given. Otherwise it it initializes a plain constructor. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -8176,7 +8176,7 @@ cdef class MonomialFactory: """ Generates a Boolean monomial from argument. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -8221,7 +8221,7 @@ cdef class PolynomialFactory: Constructs a polynomial factory if ring is given, or plain constructor otherwise. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -8238,7 +8238,7 @@ cdef class PolynomialFactory: Return the leading monomial of boolean polynomial ``x``, with respect to to the order of parent ring. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() @@ -8252,7 +8252,7 @@ cdef class PolynomialFactory: Construct a new :class:`BooleanPolynomial` or return ``arg`` if it is a :class:`BooleanPolynomial` already. - EXAMPLE:: + EXAMPLES:: sage: from brial import * sage: B. = BooleanPolynomialRing() diff --git a/src/sage/rings/polynomial/plural.pyx b/src/sage/rings/polynomial/plural.pyx index c4166b6b232..78ed4768e9f 100644 --- a/src/sage/rings/polynomial/plural.pyx +++ b/src/sage/rings/polynomial/plural.pyx @@ -650,7 +650,7 @@ cdef class NCPolynomialRing_plural(Ring): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: A. = FreeAlgebra(QQ, 2) sage: H. = A.g_algebra({y*x:-x*y}) @@ -708,7 +708,7 @@ cdef class NCPolynomialRing_plural(Ring): relation. The implicit relations are not provided, unless ``add_commutative==True``. - EXAMPLE:: + EXAMPLES:: sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({z*x:x*z+2*x, z*y:y*z-2*y}) @@ -865,7 +865,7 @@ cdef class NCPolynomialRing_plural(Ring): # """ # Construct quotient ring of ``self`` and the two-sided Groebner basis of `ideal` # -# EXAMPLE:: +# EXAMPLES:: # # sage: A. = FreeAlgebra(QQ, 3) # sage: H = A.g_algebra(relations={y*x:-x*y}, order='lex') diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 40824294432..51890957e85 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -188,7 +188,7 @@ cdef class Polynomial(CommutativeAlgebraElement): """ A polynomial. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ['y'] sage: S. = R['x'] @@ -372,7 +372,7 @@ cdef class Polynomial(CommutativeAlgebraElement): """ Multiply self on the left by a scalar. - EXAMPLE:: + EXAMPLES:: sage: R. = ZZ[] sage: f = (x^3 + x + 5) @@ -392,7 +392,7 @@ cdef class Polynomial(CommutativeAlgebraElement): """ Multiply self on the right by a scalar. - EXAMPLE:: + EXAMPLES:: sage: R. = ZZ[] sage: f = (x^3 + x + 5) @@ -825,7 +825,7 @@ cdef class Polynomial(CommutativeAlgebraElement): """ Returns a quickly-evaluating function on floats. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: f = t^3-t @@ -1172,7 +1172,7 @@ cdef class Polynomial(CommutativeAlgebraElement): def __float__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P = PolynomialRing(ZZ, 'x')([1]) sage: float(P) @@ -1184,7 +1184,7 @@ cdef class Polynomial(CommutativeAlgebraElement): def __int__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P = PolynomialRing(ZZ, 'x')([3]) sage: int(P) @@ -4999,7 +4999,7 @@ cdef class Polynomial(CommutativeAlgebraElement): Create a new constant polynomial from a in P, which MUST be an element of the base ring of P (this is not checked). - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(GF(9,'a'), sparse=True) sage: a = w._new_constant_poly(0, R); a @@ -7872,7 +7872,7 @@ cdef class Polynomial(CommutativeAlgebraElement): def __lshift__(self, k): """ - EXAMPLE:: + EXAMPLES:: sage: R. = ZZ[] sage: f = x + 2 diff --git a/src/sage/rings/polynomial/polynomial_gf2x.pyx b/src/sage/rings/polynomial/polynomial_gf2x.pyx index c802beea58b..8e55dea546b 100644 --- a/src/sage/rings/polynomial/polynomial_gf2x.pyx +++ b/src/sage/rings/polynomial/polynomial_gf2x.pyx @@ -29,7 +29,7 @@ cdef class Polynomial_GF2X(Polynomial_template): """ Univariate Polynomials over GF(2) via NTL's GF2X. - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x^3 + x^2 + 1 @@ -39,7 +39,7 @@ cdef class Polynomial_GF2X(Polynomial_template): """ Create a new univariate polynomials over GF(2). - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x^3 + x^2 + 1 @@ -85,7 +85,7 @@ cdef class Polynomial_GF2X(Polynomial_template): def _pari_(self, variable=None): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: f = x^3 + x^2 + 1 @@ -111,7 +111,7 @@ cdef class Polynomial_GF2X(Polynomial_template): - ``h`` -- a polynomial - ``algorithm`` -- either 'native' or 'ntl' (default: 'native') - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: r = 279 @@ -275,7 +275,7 @@ def GF2X_BuildIrred_list(n): Return the list of coefficients of the lexicographically smallest irreducible polynomial of degree `n` over the field of 2 elements. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.polynomial_gf2x import GF2X_BuildIrred_list sage: GF2X_BuildIrred_list(2) @@ -298,7 +298,7 @@ def GF2X_BuildSparseIrred_list(n): Return the list of coefficients of an irreducible polynomial of degree `n` of minimal weight over the field of 2 elements. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.polynomial_gf2x import GF2X_BuildIrred_list, GF2X_BuildSparseIrred_list sage: all([GF2X_BuildSparseIrred_list(n) == GF2X_BuildIrred_list(n) @@ -318,7 +318,7 @@ def GF2X_BuildRandomIrred_list(n): Return the list of coefficients of an irreducible polynomial of degree `n` of minimal weight over the field of 2 elements. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.polynomial_gf2x import GF2X_BuildRandomIrred_list sage: GF2X_BuildRandomIrred_list(2) diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx index 81183136a8b..7cd90759a47 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx @@ -123,7 +123,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): The given value has to be in the base ring of P. This assumption is not verified. - EXAMPLE:: + EXAMPLES:: sage: R. = ZZ[] sage: x._new_constant_poly(2,R) diff --git a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx index d110fbc1c96..82ba32489cf 100644 --- a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx +++ b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx @@ -365,7 +365,7 @@ cdef class Polynomial_dense_mod_n(Polynomial): See :func:`sage.rings.polynomial.polynomial_modn_dense_ntl.small_roots` for the documentation of this function. - EXAMPLE:: + EXAMPLES:: sage: N = 10001 sage: K = Zmod(10001) diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index 46a4b580ed2..62ee12c2ee9 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -938,7 +938,7 @@ def _S_decomposition(self, S): fields. This is an internal function used by :meth:.S_class_group, :meth:.S_units and :meth:.selmer_group. - EXAMPLE:: + EXAMPLES:: sage: K. = QuadraticField(-5) sage: R. = K[] diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx index 55ba144b797..e50c087a979 100644 --- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx @@ -125,7 +125,7 @@ cdef class Polynomial_rational_flint(Polynomial): x must be a rational or convertible to an int. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: x._new_constant_poly(2/1,R) @@ -1392,7 +1392,7 @@ cdef class Polynomial_rational_flint(Polynomial): a positive integer denominator (coprime to the content of the polynomial), returns the integer polynomial. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: f = (3 * t^3 + 1) / -3 @@ -1413,7 +1413,7 @@ cdef class Polynomial_rational_flint(Polynomial): """ Returns the denominator of self. - EXAMPLE:: + EXAMPLES:: sage: R. = QQ[] sage: f = (3 * t^3 + 1) / -3 diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index 5b5263cd614..05b01c2c4d2 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -2028,7 +2028,7 @@ class PolynomialRing_dense_finite_field(PolynomialRing_field): """ Univariate polynomial ring over a finite field. - EXAMPLE:: + EXAMPLES:: sage: R = PolynomialRing(GF(27, 'a'), 'x') sage: type(R) diff --git a/src/sage/rings/polynomial/polynomial_ring_homomorphism.pyx b/src/sage/rings/polynomial/polynomial_ring_homomorphism.pyx index 61e4a8594ed..45de93b2fb0 100644 --- a/src/sage/rings/polynomial/polynomial_ring_homomorphism.pyx +++ b/src/sage/rings/polynomial/polynomial_ring_homomorphism.pyx @@ -24,7 +24,7 @@ cdef class PolynomialRingHomomorphism_from_base(RingHomomorphism_from_base): The canonical ring homomorphism from `R[x]` to `S[x]` induced by a ring homomorphism from `R` to `S`. - EXAMPLE:: + EXAMPLES:: sage: QQ['x'].coerce_map_from(ZZ['x']) Ring morphism: diff --git a/src/sage/rings/polynomial/polynomial_template.pxi b/src/sage/rings/polynomial/polynomial_template.pxi index c0e756f05ba..000050098f2 100644 --- a/src/sage/rings/polynomial/polynomial_template.pxi +++ b/src/sage/rings/polynomial/polynomial_template.pxi @@ -86,7 +86,7 @@ cdef class Polynomial_template(Polynomial): """ def __init__(self, parent, x=None, check=True, is_gen=False, construct=False): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: P(0) @@ -181,7 +181,7 @@ cdef class Polynomial_template(Polynomial): def __reduce__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: loads(dumps(x)) == x @@ -191,7 +191,7 @@ cdef class Polynomial_template(Polynomial): cpdef list list(self, bint copy=True): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x.list() @@ -204,7 +204,7 @@ cdef class Polynomial_template(Polynomial): def __dealloc__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: del x @@ -225,7 +225,7 @@ cdef class Polynomial_template(Polynomial): cpdef _add_(self, right): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x + 1 @@ -243,7 +243,7 @@ cdef class Polynomial_template(Polynomial): cpdef _sub_(self, right): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x - 1 @@ -260,7 +260,7 @@ cdef class Polynomial_template(Polynomial): def __neg__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: -x @@ -323,7 +323,7 @@ cdef class Polynomial_template(Polynomial): cpdef _mul_(self, right): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x*(x+1) @@ -343,7 +343,7 @@ cdef class Polynomial_template(Polynomial): """ Return the greatest common divisor of self and other. - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: f = x*(x+1) @@ -371,7 +371,7 @@ cdef class Polynomial_template(Polynomial): """ Computes extended gcd of self and other. - EXAMPLE:: + EXAMPLES:: sage: P. = GF(7)[] sage: f = x*(x+1) @@ -445,7 +445,7 @@ cdef class Polynomial_template(Polynomial): cpdef _mod_(self, other): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: (x^2 + 1) % x^2 @@ -477,7 +477,7 @@ cdef class Polynomial_template(Polynomial): @coerce_binop def quo_rem(self, Polynomial_template right): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: f = x^2 + x + 1 @@ -503,7 +503,7 @@ cdef class Polynomial_template(Polynomial): def __long__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: int(x) @@ -520,7 +520,7 @@ cdef class Polynomial_template(Polynomial): def __nonzero__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: bool(x), x.is_zero() @@ -532,7 +532,7 @@ cdef class Polynomial_template(Polynomial): cpdef _richcmp_(self, other, int op): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x != 1 @@ -548,7 +548,7 @@ cdef class Polynomial_template(Polynomial): def __hash__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: {x:1} @@ -584,7 +584,7 @@ cdef class Polynomial_template(Polynomial): def __pow__(self, ee, modulus): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: P. = GF(2)[] @@ -641,7 +641,7 @@ cdef class Polynomial_template(Polynomial): def __copy__(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: copy(x) is x @@ -659,7 +659,7 @@ cdef class Polynomial_template(Polynomial): def is_gen(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x.is_gen() @@ -675,7 +675,7 @@ cdef class Polynomial_template(Polynomial): def shift(self, int n): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: f = x^3 + x^2 + 1 @@ -688,7 +688,7 @@ cdef class Polynomial_template(Polynomial): def __lshift__(self, int n): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: f = x^3 + x^2 + 1 @@ -701,7 +701,7 @@ cdef class Polynomial_template(Polynomial): def __rshift__(self, int n): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x>>1 @@ -715,7 +715,7 @@ cdef class Polynomial_template(Polynomial): cpdef bint is_zero(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x.is_zero() @@ -725,7 +725,7 @@ cdef class Polynomial_template(Polynomial): cpdef bint is_one(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: P(1).is_one() @@ -735,7 +735,7 @@ cdef class Polynomial_template(Polynomial): def degree(self): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(2)[] sage: x.degree() @@ -794,7 +794,7 @@ cdef class Polynomial_template(Polynomial): - ``singular`` -- Singular interpreter (default: default interpreter) - ``have_ring`` -- set to True if the ring was already set in Singular - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(7)) sage: f = 3*x^2 + 2*x + 5 diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx index f355dbb5ece..d37ff950ee6 100644 --- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx @@ -84,7 +84,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): """ def __init__(self, parent, x=None, check=True, is_gen=False, construct=False): """ - EXAMPLE:: + EXAMPLES:: sage: P. = GF(32003)[] sage: f = 24998*x^2 + 29761*x + 2252 @@ -145,7 +145,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): The modulus of P must coincide with the modulus of this element. That assumption is not verified! - EXAMPLE:: + EXAMPLES:: sage: R. = GF(3)[] sage: x._new_constant_poly(4,R) @@ -272,7 +272,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): polynomial is a keyword it is substituted in; otherwise this polynomial is returned unchanged. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(7)) sage: f = x^2 + 1 @@ -361,7 +361,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): See :func:`sage.rings.polynomial.polynomial_modn_dense_ntl.small_roots` for the documentation of this function. - EXAMPLE:: + EXAMPLES:: sage: N = 10001 sage: K = Zmod(10001) @@ -419,7 +419,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): OUTPUT: (Polynomial) the product self*right. - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(next_prime(2^30))) sage: f = P.random_element(1000) diff --git a/src/sage/rings/polynomial/polynomial_zz_pex.pyx b/src/sage/rings/polynomial/polynomial_zz_pex.pyx index 56cd5885680..2cc35226674 100644 --- a/src/sage/rings/polynomial/polynomial_zz_pex.pyx +++ b/src/sage/rings/polynomial/polynomial_zz_pex.pyx @@ -62,7 +62,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): """ Univariate Polynomials over GF(p^n) via NTL's ZZ_pEX. - EXAMPLE:: + EXAMPLES:: sage: K.=GF(next_prime(2**60)**3) sage: R. = PolynomialRing(K,implementation='NTL') @@ -73,7 +73,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): """ Create a new univariate polynomials over GF(p^n). - EXAMPLE:: + EXAMPLES:: sage: K.=GF(next_prime(2**60)**3) sage: R. = PolynomialRing(K,implementation='NTL') @@ -175,7 +175,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): """ Returs the list of coefficients. - EXAMPLE:: + EXAMPLES:: sage: K. = GF(5^3) sage: P = PolynomialRing(K, 'x') @@ -219,7 +219,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): """ Evaluate polynomial at `a`. - EXAMPLE:: + EXAMPLES:: sage: K.=GF(next_prime(2**60)**3) sage: R. = PolynomialRing(K,implementation='NTL') @@ -401,7 +401,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): def shift(self, int n): """ - EXAMPLE:: + EXAMPLES:: sage: K.=GF(next_prime(2**60)**3) sage: R. = PolynomialRing(K,implementation='NTL') @@ -422,7 +422,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): def __lshift__(self, int n): """ - EXAMPLE:: + EXAMPLES:: sage: K.=GF(next_prime(2**60)**3) sage: R. = PolynomialRing(K,implementation='NTL') @@ -436,7 +436,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): def __rshift__(self, int n): """ - EXAMPLE:: + EXAMPLES:: sage: K.=GF(next_prime(2**60)**3) sage: R. = PolynomialRing(K,implementation='NTL') diff --git a/src/sage/rings/polynomial/symmetric_ideal.py b/src/sage/rings/polynomial/symmetric_ideal.py index c058febdb69..4bbf86aa0ae 100644 --- a/src/sage/rings/polynomial/symmetric_ideal.py +++ b/src/sage/rings/polynomial/symmetric_ideal.py @@ -261,7 +261,7 @@ def __mul__ (self, other): polynomials. Hence, when multiplying two symmetric ideals, it does not suffice to simply multiply the respective generators. - EXAMPLE:: + EXAMPLES:: sage: X. = InfinitePolynomialRing(QQ) sage: I=X*(x[1]) diff --git a/src/sage/rings/polynomial/term_order.py b/src/sage/rings/polynomial/term_order.py index e14a4be474a..b444b6563d2 100644 --- a/src/sage/rings/polynomial/term_order.py +++ b/src/sage/rings/polynomial/term_order.py @@ -269,7 +269,7 @@ where `<` is the lexicographic term order. -EXAMPLE:: +EXAMPLES:: sage: m = matrix(2,[2,3,0,1]); m [2 3] @@ -550,7 +550,7 @@ def __setstate__(self, dict): See Trac :trac:`11316`. - EXAMPLE:: + EXAMPLES:: sage: t = TermOrder('lex') sage: t2 = loads(dumps(t)) @@ -805,7 +805,7 @@ def __hash__(self): r""" A hash function - EXAMPLE:: + EXAMPLES:: sage: _=hash(TermOrder('lex')) """ @@ -815,7 +815,7 @@ def __copy(self, other): """ Copy other term order to self. - EXAMPLE:: + EXAMPLES:: sage: t = TermOrder('lex') sage: s = TermOrder(t) @@ -831,7 +831,7 @@ def __getattr__(self,name): Note that the ``compare_tuples`` methods have been deprecated in :trac:`21766`. - EXAMPLE:: + EXAMPLES:: sage: TermOrder('lex').compare_tuples @@ -905,7 +905,7 @@ def sortkey_lex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='lex') sage: x > y^2 # indirect doctest @@ -931,7 +931,7 @@ def sortkey_invlex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='invlex') sage: x > y^2 # indirect doctest @@ -964,7 +964,7 @@ def sortkey_deglex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='deglex') sage: x > y^2 # indirect doctest @@ -998,7 +998,7 @@ def sortkey_degrevlex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='degrevlex') sage: x > y^2 # indirect doctest @@ -1026,7 +1026,7 @@ def sortkey_neglex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='neglex') sage: x > y^2 # indirect doctest @@ -1059,7 +1059,7 @@ def sortkey_negdegrevlex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='negdegrevlex') sage: x > y^2 # indirect doctest @@ -1093,7 +1093,7 @@ def sortkey_negdeglex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='negdeglex') sage: x > y^2 # indirect doctest @@ -1126,7 +1126,7 @@ def sortkey_degneglex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='degneglex') sage: x*y > y*z # indirect doctest @@ -1159,7 +1159,7 @@ def sortkey_wdegrevlex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: t = TermOrder('wdegrevlex',(3,2)) sage: P. = PolynomialRing(QQbar, 2, order=t) @@ -1194,7 +1194,7 @@ def sortkey_wdeglex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: t = TermOrder('wdeglex',(3,2)) sage: P. = PolynomialRing(QQbar, 2, order=t) @@ -1228,7 +1228,7 @@ def sortkey_negwdeglex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: t = TermOrder('negwdeglex',(3,2)) sage: P. = PolynomialRing(QQbar, 2, order=t) @@ -1262,7 +1262,7 @@ def sortkey_negwdegrevlex(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: t = TermOrder('negwdegrevlex',(3,2)) sage: P. = PolynomialRing(QQbar, 2, order=t) @@ -1296,7 +1296,7 @@ def sortkey_block(self, f): - ``f`` -- exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P.=PolynomialRing(QQbar, 6, order='degrevlex(3),degrevlex(3)') sage: a > c^4 # indirect doctest @@ -1323,7 +1323,7 @@ def greater_tuple_matrix(self,f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='m(1,3,1,0)') sage: y > x^2 # indirect doctest @@ -1374,7 +1374,7 @@ def greater_tuple_invlex(self,f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='invlex') sage: f = x + y; f.lm() # indirect doctest @@ -1398,7 +1398,7 @@ def greater_tuple_deglex(self,f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='deglex') sage: f = x + y; f.lm() # indirect doctest @@ -1450,7 +1450,7 @@ def greater_tuple_negdegrevlex(self,f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='negdegrevlex') sage: f = x + y; f.lm() # indirect doctest @@ -1478,7 +1478,7 @@ def greater_tuple_negdeglex(self,f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='negdeglex') sage: f = x + y; f.lm() # indirect doctest @@ -1506,7 +1506,7 @@ def greater_tuple_degneglex(self,f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='degneglex') sage: f = x + y; f.lm() # indirect doctest @@ -1536,7 +1536,7 @@ def greater_tuple_neglex(self,f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P.=PolynomialRing(QQbar, 6, order='degrevlex(3),degrevlex(3)') sage: f = a + c^4; f.lm() # indirect doctest @@ -1557,7 +1557,7 @@ def greater_tuple_wdeglex(self,f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: t = TermOrder('wdeglex',(1,2,3)) sage: P. = PolynomialRing(QQbar, 3, order=t) @@ -1611,7 +1611,7 @@ def greater_tuple_negwdeglex(self,f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: t = TermOrder('negwdeglex',(1,2,3)) sage: P. = PolynomialRing(QQbar, 3, order=t) @@ -1640,7 +1640,7 @@ def greater_tuple_negwdegrevlex(self,f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: t = TermOrder('negwdegrevlex',(1,2,3)) sage: P. = PolynomialRing(QQbar, 3, order=t) @@ -1672,7 +1672,7 @@ def greater_tuple_block(self, f,g): - ``g`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: P.=PolynomialRing(QQbar, 6, order='degrevlex(3),degrevlex(3)') sage: f = a + c^4; f.lm() # indirect doctest @@ -1701,7 +1701,7 @@ def tuple_weight(self, f): - ``f`` - exponent tuple - EXAMPLE:: + EXAMPLES:: sage: t=TermOrder('wdeglex',(1,2,3)) sage: P.=PolynomialRing(QQbar, order=t) @@ -1712,7 +1712,7 @@ def tuple_weight(self, f): def name(self): """ - EXAMPLE:: + EXAMPLES:: sage: TermOrder('lex').name() 'lex' @@ -1721,7 +1721,7 @@ def name(self): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: TermOrder('lex') # indirect doctest Lexicographic term order @@ -1748,7 +1748,7 @@ def singular_str(self): Used to convert polynomial rings to their SINGULAR representation. - EXAMPLE:: + EXAMPLES:: sage: P = PolynomialRing(GF(127),10,names='x',order='lex(3),deglex(5),lex(2)') sage: T = P.term_order() @@ -1805,7 +1805,7 @@ def singular_moreblocks(self): Return a the number of additional blocks SINGULAR needs to allocate for handling non-native orderings like `degneglex`. - EXAMPLE:: + EXAMPLES:: sage: P = PolynomialRing(GF(127),10,names='x',order='lex(3),deglex(5),lex(2)') sage: T = P.term_order() @@ -1845,7 +1845,7 @@ def macaulay2_str(self): Used to convert polynomial rings to their Macaulay2 representation. - EXAMPLE:: + EXAMPLES:: sage: P = PolynomialRing(GF(127), 8,names='x',order='degrevlex(3),lex(5)') sage: T = P.term_order() @@ -1866,7 +1866,7 @@ def magma_str(self): Used to convert polynomial rings to their MAGMA representation. - EXAMPLE:: + EXAMPLES:: sage: P = PolynomialRing(GF(127), 10,names='x',order='degrevlex') sage: magma(P) # optional - magma @@ -1892,7 +1892,7 @@ def blocks(self): to be an *attribute* of the same name and the same content. So, it is a backward incompatible syntax change. - EXAMPLE:: + EXAMPLES:: sage: t=TermOrder('deglex',2)+TermOrder('lex',2) sage: t.blocks() @@ -1907,7 +1907,7 @@ def matrix(self): """ Return the matrix defining matrix term order. - EXAMPLE:: + EXAMPLES:: sage: t = TermOrder("M(1,2,0,1)") sage: t.matrix() @@ -1921,7 +1921,7 @@ def weights(self): """ Return the weights for weighted term orders. - EXAMPLE:: + EXAMPLES:: sage: t=TermOrder('wdeglex',(2,3)) sage: t.weights() @@ -1933,7 +1933,7 @@ def __eq__(self, other): """ Return true if self and other are equal. - EXAMPLE:: + EXAMPLES:: sage: TermOrder('lex') == TermOrder('lex',3) True @@ -1972,7 +1972,7 @@ def __ne__(self, other): """ Return true if self and other are not equal. - EXAMPLE:: + EXAMPLES:: sage: T1 = TermOrder('lex',2)+TermOrder('lex',3) sage: T2 = TermOrder('lex',3)+TermOrder('lex',2) @@ -1991,7 +1991,7 @@ def __add__(self, other): OUTPUT: a block order - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.term_order import TermOrder sage: TermOrder('deglex',2) + TermOrder('degrevlex(3),neglex(3)') @@ -2011,7 +2011,7 @@ def __len__(self): variables it covers. This may be zero for indefinitely many variables. - EXAMPLE:: + EXAMPLES:: sage: T = TermOrder('lex') sage: len(T) @@ -2030,7 +2030,7 @@ def __getitem__(self, i): - ``i`` - index - EXAMPLE:: + EXAMPLES:: sage: T = TermOrder('lex') sage: T[0] @@ -2059,7 +2059,7 @@ def __iter__(self): r""" Iterate over the blocks of this term order. - EXAMPLE:: + EXAMPLES:: sage: T = TermOrder('lex') sage: list(T) # indirect doctest @@ -2084,7 +2084,7 @@ def is_global(self): global. Return false otherwise, which includes unknown term orders. - EXAMPLE:: + EXAMPLES:: sage: T = TermOrder('lex') sage: T.is_global() @@ -2112,7 +2112,7 @@ def is_local(self): local. Return false otherwise, which includes unknown term orders. - EXAMPLE:: + EXAMPLES:: sage: T = TermOrder('lex') sage: T.is_local() @@ -2136,7 +2136,7 @@ def is_block_order(self): """ Return true if self is a block term order. - EXAMPLE:: + EXAMPLES:: sage: t=TermOrder('deglex',2)+TermOrder('lex',2) sage: t.is_block_order() @@ -2148,7 +2148,7 @@ def is_weighted_degree_order(self): """ Return true if self is a weighted degree term order. - EXAMPLE:: + EXAMPLES:: sage: t=TermOrder('wdeglex',(2,3)) sage: t.is_weighted_degree_order() @@ -2171,7 +2171,7 @@ def termorder_from_singular(S): orders for modules. This is not taken into account in Sage. - EXAMPLE:: + EXAMPLES:: sage: singular.eval('ring r1 = (9,x),(a,b,c,d,e,f),(M((1,2,3,0)),wp(2,3),lp)') '' diff --git a/src/sage/rings/polynomial/toy_d_basis.py b/src/sage/rings/polynomial/toy_d_basis.py index ccc70b48229..1878e1237ce 100644 --- a/src/sage/rings/polynomial/toy_d_basis.py +++ b/src/sage/rings/polynomial/toy_d_basis.py @@ -13,7 +13,7 @@ coefficient. Also, what is called LM (the leading monomial) in Sage is called HT (the head term) in [BW93]_. -EXAMPLE:: +EXAMPLES:: sage: from sage.rings.polynomial.toy_d_basis import d_basis @@ -134,7 +134,7 @@ def spol(g1,g2): - ``g1`` - polynomial - ``g2`` - polynomial - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.toy_d_basis import spol sage: P. = PolynomialRing(IntegerRing(), 3, order='lex') @@ -166,7 +166,7 @@ def gpol(g1,g2): - ``g1`` - polynomial - ``g2`` - polynomial - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.toy_d_basis import gpol sage: P. = PolynomialRing(IntegerRing(), 3, order='lex') @@ -197,7 +197,7 @@ def d_basis(F, strat=True): - ``F`` - an ideal - ``strat`` - use update strategy (default: ``True``) - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.toy_d_basis import d_basis sage: A. = PolynomialRing(ZZ, 2) @@ -270,7 +270,7 @@ def select(P): OUTPUT: an element of P - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.toy_d_basis import select sage: A. = PolynomialRing(ZZ, 2) @@ -308,7 +308,7 @@ def update(G,B,h): OUTPUT: ``G,B`` where ``G`` and ``B`` are updated - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.toy_d_basis import update sage: A. = PolynomialRing(ZZ, 2) diff --git a/src/sage/rings/polynomial/toy_variety.py b/src/sage/rings/polynomial/toy_variety.py index 2cdbed95ad3..93d1122a139 100644 --- a/src/sage/rings/polynomial/toy_variety.py +++ b/src/sage/rings/polynomial/toy_variety.py @@ -53,7 +53,7 @@ def is_triangular(B): ``True`` if the basis is triangular; ``False`` otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.toy_variety import is_triangular sage: R. = PolynomialRing(QQ) @@ -100,7 +100,7 @@ def coefficient_matrix(polys): A matrix ``M`` of the coefficients of ``polys``. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.toy_variety import coefficient_matrix sage: R. = PolynomialRing(QQ) @@ -156,7 +156,7 @@ def is_linearly_dependent(polys): ``True`` if the elements of ``polys`` are linearly dependent; ``False`` otherwise. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.toy_variety import is_linearly_dependent sage: R. = PolynomialRing(QQ) @@ -204,7 +204,7 @@ def linear_representation(p, polys): If ``n == len(polys)``, returns ``[a[0],a[1],...,a[n-1]]`` such that ``p == a[0]*poly[0] + ... + a[n-1]*poly[n-1]``. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.polynomial.toy_variety import linear_representation sage: R. = PolynomialRing(GF(32003)) @@ -241,7 +241,7 @@ def triangular_factorization(B, n=-1): A list ``T`` of triangular sets ``T_0``, ``T_1``, etc. - EXAMPLE:: + EXAMPLES:: sage: set_verbose(0) sage: from sage.rings.polynomial.toy_variety import triangular_factorization @@ -315,7 +315,7 @@ def elim_pol(B, n=-1): - ``B`` - a list/tuple of polynomials or a multivariate polynomial ideal - ``n`` - the variable to check (see above) (default: ``-1``) - EXAMPLE:: + EXAMPLES:: sage: set_verbose(0) sage: from sage.rings.polynomial.toy_variety import elim_pol diff --git a/src/sage/rings/power_series_poly.pyx b/src/sage/rings/power_series_poly.pyx index 6b6c08bb3ee..ced5a5eb423 100644 --- a/src/sage/rings/power_series_poly.pyx +++ b/src/sage/rings/power_series_poly.pyx @@ -108,7 +108,7 @@ cdef class PowerSeries_poly(PowerSeries): """ Return the underlying polynomial of self. - EXAMPLE:: + EXAMPLES:: sage: R. = GF(7)[[]] sage: f = 3 - t^3 + O(t^5) @@ -791,7 +791,7 @@ cdef class PowerSeries_poly(PowerSeries): Otherwise, we call _derivative(var) on each coefficient of the series. - SEE ALSO:: + SEEALSO:: self.derivative() diff --git a/src/sage/rings/power_series_ring.py b/src/sage/rings/power_series_ring.py index fafed02b31a..c0c9e0c9f76 100644 --- a/src/sage/rings/power_series_ring.py +++ b/src/sage/rings/power_series_ring.py @@ -810,7 +810,7 @@ def construction(self): the univariate polynomial ring with respect to the indeterminate (to a given precision). - EXAMPLE:: + EXAMPLES:: sage: R = PowerSeriesRing(ZZ, 'x') sage: c, S = R.construction(); S @@ -897,7 +897,7 @@ def _is_valid_homomorphism_(self, codomain, im_gens): This gets called implicitly when one constructs a ring homomorphism from a power series ring. - EXAMPLE:: + EXAMPLES:: sage: S = RationalField(); R.=PowerSeriesRing(S) sage: f = R.hom([0]) diff --git a/src/sage/rings/power_series_ring_element.pyx b/src/sage/rings/power_series_ring_element.pyx index 8fb340fc8cb..00396972d66 100644 --- a/src/sage/rings/power_series_ring_element.pyx +++ b/src/sage/rings/power_series_ring_element.pyx @@ -14,7 +14,7 @@ AUTHORS: - Robert Bradshaw (2007-04): Cython version - Simon King (2012-08): use category and coercion framework, :trac:`13412` -EXAMPLE:: +EXAMPLES:: sage: R. = PowerSeriesRing(ZZ) sage: TestSuite(R).run() diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index 4d0aa78cdd1..4271c392a0f 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -555,7 +555,7 @@ def is_finite(self): Check whether this field is finite. Since this class is only used for fields of characteristic 0, always returns False. - EXAMPLE:: + EXAMPLES:: sage: QQbar.is_finite() False @@ -579,7 +579,7 @@ def order(self): Return the cardinality of self. Since this class is only used for fields of characteristic 0, always returns Infinity. - EXAMPLE:: + EXAMPLES:: sage: QQbar.order() +Infinity @@ -688,7 +688,7 @@ def _element_constructor_(self, x): r""" Construct an element of the field of algebraic real numbers from ``x``. - EXAMPLE:: + EXAMPLES:: sage: QQbar(sqrt(2)) in AA # indirect doctest True @@ -719,7 +719,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: AA._repr_() 'Algebraic Real Field' @@ -746,7 +746,7 @@ def _latex_(self): r""" Latex representation of self. - EXAMPLE:: + EXAMPLES:: sage: AA._latex_() '\\mathbf{A}' @@ -838,7 +838,7 @@ def _is_valid_homomorphism_(self, codomain, im_gens): this cannot be implemented in a mathematically sensible way, and we just test that there exists a canonical coercion. - EXAMPLE:: + EXAMPLES:: sage: AA._is_valid_homomorphism_(QQbar, [QQbar(1)]) True @@ -855,7 +855,7 @@ def gens(self): Return a set of generators for this field. As this field is not finitely generated, we opt for just returning 1. - EXAMPLE:: + EXAMPLES:: sage: AA.gens() (1,) @@ -866,7 +866,7 @@ def gen(self, n=0): r""" Return the `n`-th element of the tuple returned by :meth:`gens`. - EXAMPLE:: + EXAMPLES:: sage: AA.gen(0) 1 @@ -884,7 +884,7 @@ def ngens(self): r""" Return the size of the tuple returned by :meth:`gens`. - EXAMPLE:: + EXAMPLES:: sage: AA.ngens() 1 @@ -900,7 +900,7 @@ def zeta(self, n=2): - ``n`` (integer) -- default 2 - EXAMPLE:: + EXAMPLES:: sage: AA.zeta(1) 1 @@ -1036,7 +1036,7 @@ def is_AlgebraicRealField(F): r""" Check whether ``F`` is an :class:`~AlgebraicRealField` instance. For internal use. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import is_AlgebraicRealField sage: [is_AlgebraicRealField(x) for x in [AA, QQbar, None, 0, "spam"]] @@ -1132,7 +1132,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: QQbar._repr_() 'Algebraic Field' @@ -1143,7 +1143,7 @@ def _latex_(self): r""" Latex representation of self. - EXAMPLE:: + EXAMPLES:: sage: QQbar._latex_() '\\overline{\\QQ}' @@ -1230,7 +1230,7 @@ def construction(self): """ Return a functor that constructs self (used by the coercion machinery). - EXAMPLE:: + EXAMPLES:: sage: QQbar.construction() (AlgebraicClosureFunctor, Rational Field) @@ -1244,7 +1244,7 @@ def gens(self): Return a set of generators for this field. As this field is not finitely generated over its prime field, we opt for just returning I. - EXAMPLE:: + EXAMPLES:: sage: QQbar.gens() (I,) @@ -1255,7 +1255,7 @@ def gen(self, n=0): r""" Return the `n`-th element of the tuple returned by :meth:`gens`. - EXAMPLE:: + EXAMPLES:: sage: QQbar.gen(0) I @@ -1273,7 +1273,7 @@ def ngens(self): r""" Return the size of the tuple returned by :meth:`gens`. - EXAMPLE:: + EXAMPLES:: sage: QQbar.ngens() 1 @@ -1517,7 +1517,7 @@ def is_AlgebraicField(F): r""" Check whether ``F`` is an :class:`~AlgebraicField` instance. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import is_AlgebraicField sage: [is_AlgebraicField(x) for x in [AA, QQbar, None, 0, "spam"]] @@ -1532,7 +1532,7 @@ def is_AlgebraicField_common(F): r""" Check whether ``F`` is an :class:`~AlgebraicField_common` instance. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import is_AlgebraicField_common sage: [is_AlgebraicField_common(x) for x in [AA, QQbar, None, 0, "spam"]] @@ -1547,7 +1547,7 @@ def prec_seq(): Currently just returns powers of 2 starting at 64. - EXAMPLE:: + EXAMPLES:: sage: g = sage.rings.qqbar.prec_seq() sage: [next(g), next(g), next(g)] @@ -1568,7 +1568,7 @@ def short_prec_seq(): computation is possible: returns a couple of small powers of 2 and then ``None``. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import short_prec_seq sage: short_prec_seq() @@ -1580,7 +1580,7 @@ def tail_prec_seq(): r""" A generator over precisions larger than those in :func:`~short_prec_seq`. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import tail_prec_seq sage: g = tail_prec_seq() @@ -2061,7 +2061,7 @@ class AlgebraicGeneratorRelation(SageObject): """ def __init__(self, child1, child1_poly, child2, child2_poly, parent): r""" - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import AlgebraicGeneratorRelation sage: c = AlgebraicGeneratorRelation(None, None, None, None, None) @@ -2145,7 +2145,7 @@ def __hash__(self): commands get executed at load time, so we do not test the value that is returned, just that it doesn't raise an error. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import ANRoot, AlgebraicGenerator, qq_generator sage: _. = QQ['y'] @@ -2161,7 +2161,7 @@ def __cmp__(self, other): r""" Compare self with another AlgebraicGenerator object. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import ANRoot, AlgebraicGenerator, qq_generator sage: _. = QQ['y'] @@ -2178,7 +2178,7 @@ def is_complex(self): r""" Return True if this is a generator for a non-real number field. - EXAMPLE:: + EXAMPLES:: sage: z7 = QQbar.zeta(7) sage: g = z7._descr._generator @@ -2200,7 +2200,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import qq_generator sage: qq_generator._repr_() @@ -2224,7 +2224,7 @@ def root_as_algebraic(self): r""" Return the root attached to self as an algebraic number. - EXAMPLE:: + EXAMPLES:: sage: t = sage.rings.qqbar.qq_generator.root_as_algebraic(); t 1 @@ -2250,7 +2250,7 @@ def field(self): r""" Return the number field attached to self. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import qq_generator sage: qq_generator.field() @@ -2262,7 +2262,7 @@ def pari_field(self): r""" Return the PARI field attached to this generator. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import qq_generator @@ -2291,7 +2291,7 @@ def conjugate(self): If this generator is for the algebraic number `\alpha`, return a generator for the complex conjugate of `\alpha`. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import AlgebraicGenerator sage: x = polygen(QQ); f = x^4 + x + 17 @@ -2323,7 +2323,7 @@ def _interval_fast(self, prec): Returns an interval containing this generator, to the specified precision. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import ANRoot, AlgebraicGenerator, qq_generator sage: y = polygen(QQ, 'y') @@ -2577,7 +2577,7 @@ def neg(self, n): r""" Negation of self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(2)) sage: b = a._descr @@ -2590,7 +2590,7 @@ def invert(self, n): r""" 1/self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(2)) sage: b = a._descr @@ -2603,7 +2603,7 @@ def abs(self, n): r""" Absolute value of self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(2)) sage: b = a._descr @@ -2616,7 +2616,7 @@ def real(self, n): r""" Real part of self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(-7)) sage: b = a._descr @@ -2632,7 +2632,7 @@ def imag(self, n): r""" Imaginary part of self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(-7)) sage: b = a._descr @@ -2648,7 +2648,7 @@ def conjugate(self, n): r""" Complex conjugate of self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(-7)) sage: b = a._descr @@ -2665,7 +2665,7 @@ def norm(self, n): Field norm of self from `\overline{\QQ}` to its real subfield `\mathbf{A}`, i.e.~the square of the usual complex absolute value. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(-7)) sage: b = a._descr @@ -3623,7 +3623,7 @@ def __init__(self, x): r""" Initialize this AlgebraicNumber object. - EXAMPLE:: + EXAMPLES:: sage: t = QQbar.zeta(5) sage: type(t) @@ -4036,7 +4036,7 @@ def _interval_fast(self, prec): r""" Shortcut for :meth:`AlgebraicNumber_base.interval_fast` which uses the complex interval field. - EXAMPLE:: + EXAMPLES:: sage: QQbar(sqrt(-5))._interval_fast(100) 2.236067977499789696409173...?*I @@ -4101,7 +4101,7 @@ def real(self): r""" Return the real part of self. - EXAMPLE:: + EXAMPLES:: sage: QQbar.zeta(5).real() 0.3090169943749474? @@ -4112,7 +4112,7 @@ def imag(self): r""" Return the imaginary part of self. - EXAMPLE:: + EXAMPLES:: sage: QQbar.zeta(7).imag() 0.7818314824680299? @@ -4185,7 +4185,7 @@ def _complex_mpfr_field_(self, field): or any other complex field (in which case ``self.complex_number()`` is called). - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(1 + I).sqrt() sage: t = a._complex_mpfr_field_(CIF); t @@ -4355,7 +4355,7 @@ def _more_precision(self): Recompute the interval bounding this number with higher-precision interval arithmetic. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(2)) sage: a._more_precision() @@ -4746,7 +4746,7 @@ def _interval_fast(self, prec): r""" Compute an approximation to this ``AlgebraicReal`` object in a real interval field of precision prec. - EXAMPLE:: + EXAMPLES:: sage: t = AA(sqrt(7)) sage: t._interval_fast(100) @@ -4889,7 +4889,7 @@ def _complex_mpfr_field_(self, field): Note that the field ``field`` should be a *complex* field (whose ``_real_field()`` method will be called to obtain a real subfield.) - EXAMPLE:: + EXAMPLES:: sage: AA(golden_ratio)._complex_mpfr_field_(ComplexIntervalField(100)) 1.618033988749894848204586834365? @@ -5068,7 +5068,7 @@ def _interval_fast(self, prec): r""" Return an approximation to self in a real interval field of precision prec. - EXAMPLE:: + EXAMPLES:: sage: QQbar(355/113)._descr._interval_fast(30) 3.14159292? @@ -5080,7 +5080,7 @@ def generator(self): Return an :class:`AlgebraicGenerator` object associated to this element. Returns the trivial generator, since self is rational. - EXAMPLE:: + EXAMPLES:: sage: QQbar(0)._descr.generator() Trivial generator @@ -5091,7 +5091,7 @@ def is_complex(self): r""" Return False, since rational numbers are real - EXAMPLE:: + EXAMPLES:: sage: QQbar(1/7)._descr.is_complex() False @@ -5102,7 +5102,7 @@ def exactify(self): r""" Calculate self exactly. Since self is a rational number, return self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(1/3)._descr sage: a.exactify() is a @@ -5128,7 +5128,7 @@ def minpoly(self): r""" Return the min poly of self over `\QQ`. - EXAMPLE:: + EXAMPLES:: sage: QQbar(7)._descr.minpoly() x - 7 @@ -5139,7 +5139,7 @@ def neg(self, n): r""" Negation of self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(3) sage: b = a._descr @@ -5154,7 +5154,7 @@ def invert(self, n): r""" 1/self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(3) sage: b = a._descr @@ -5167,7 +5167,7 @@ def abs(self, n): r""" Absolute value of self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(3) sage: b = a._descr @@ -5181,7 +5181,7 @@ def rational_argument(self, n): Return the argument of self divided by `2 \pi`, or ``None`` if this element is 0. - EXAMPLE:: + EXAMPLES:: sage: QQbar(3)._descr.rational_argument(None) 0 @@ -5201,7 +5201,7 @@ def angle(self): Return a rational number `q \in (-1/2, 1/2]` such that ``self`` is a rational multiple of `e^{2\pi i q}`. Always returns 0, since this element is rational. - EXAMPLE:: + EXAMPLES:: sage: QQbar(3)._descr.angle() 0 @@ -5218,7 +5218,7 @@ def scale(self): i q}` for some `q \in (-1/2, 1/2]`. In other words, just return self as a rational number. - EXAMPLE:: + EXAMPLES:: sage: QQbar(-3)._descr.scale() -3 @@ -5229,7 +5229,7 @@ def is_AlgebraicReal(x): r""" Test if ``x`` is an instance of :class:`~AlgebraicReal`. For internal use. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import is_AlgebraicReal sage: is_AlgebraicReal(AA(sqrt(2))) @@ -5245,7 +5245,7 @@ def is_AlgebraicNumber(x): r""" Test if ``x`` is an instance of :class:`~AlgebraicNumber`. For internal use. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.qqbar import is_AlgebraicNumber sage: is_AlgebraicNumber(AA(sqrt(2))) @@ -5290,7 +5290,7 @@ def __init__(self, poly): r""" Initialize this AlgebraicPolynomialTracker object. - EXAMPLE:: + EXAMPLES:: sage: x = polygen(QQbar) sage: P = QQbar.common_polynomial(x^2 - x - 1) @@ -5361,7 +5361,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: x = polygen(QQ) sage: AA.common_polynomial(x^3 - 7)._repr_() @@ -5373,7 +5373,7 @@ def poly(self): r""" Return the underlying polynomial of self. - EXAMPLE:: + EXAMPLES:: sage: x = polygen(QQ); f = x^3 - 7 sage: g = AA.common_polynomial(f) @@ -5386,7 +5386,7 @@ def is_complex(self): r""" Return True if the coefficients of this polynomial are non-real. - EXAMPLE:: + EXAMPLES:: sage: x = polygen(QQ); f = x^3 - 7 sage: g = AA.common_polynomial(f) @@ -5437,7 +5437,7 @@ def exactify(self): of this polynomial, then factor the polynomial over that field. Store the factors for later use (ignoring multiplicity). - EXAMPLE:: + EXAMPLES:: sage: x = polygen(AA) sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3)) @@ -5476,7 +5476,7 @@ def exactify(self): def factors(self): r""" - EXAMPLE:: + EXAMPLES:: sage: x=polygen(QQ); f=QQbar.common_polynomial(x^4 + 4) sage: f.factors() @@ -5490,7 +5490,7 @@ def generator(self): Return an :class:`AlgebraicGenerator` for a number field containing all the coefficients of self. - EXAMPLE:: + EXAMPLES:: sage: x = polygen(AA) sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3)) @@ -5511,7 +5511,7 @@ def __init__(self, poly, interval, multiplicity=1): r""" Initialize this ``ANRoot`` object. - EXAMPLE:: + EXAMPLES:: sage: x = polygen(QQ); f = (x^3 + x + 1).roots(AA,multiplicities=False)[0]._descr sage: type(f) # indirect doctest @@ -5544,7 +5544,7 @@ def _repr_(self): r""" String representation of self. - EXAMPLE:: + EXAMPLES:: sage: x=polygen(QQ); v = (x^2 - x - 1).roots(ring=AA, multiplicities=False)[1] sage: v._descr._repr_() @@ -5624,7 +5624,7 @@ def is_complex(self): the second example shows; it does *not* trigger exact computation to see if the root is real. - EXAMPLE:: + EXAMPLES:: sage: x = polygen(QQ) sage: (x^2 - x - 1).roots(ring=AA, multiplicities=False)[1]._descr.is_complex() @@ -5638,7 +5638,7 @@ def conjugate(self, n): r""" Complex conjugate of this ANRoot object. - EXAMPLE:: + EXAMPLES:: sage: a = (x^2 + 23).roots(ring=QQbar, multiplicities=False)[0] sage: b = a._descr @@ -6164,7 +6164,7 @@ def _more_precision(self): Recompute the interval enclosing this ``ANRoot`` object at higher precision. - EXAMPLE:: + EXAMPLES:: sage: x = polygen(QQ); y = (x^3 + x + 1).roots(AA,multiplicities=False)[0] sage: z = y._descr @@ -6184,7 +6184,7 @@ def _interval_fast(self, prec): and return the value in that field. (More precision may be used in the computation.) - EXAMPLE:: + EXAMPLES:: sage: x = polygen(QQ); y = (x^3 + x + 1).roots(AA,multiplicities=False)[0]._descr sage: y._interval_fast(128) @@ -6321,7 +6321,7 @@ def is_complex(self): This does not imply that the element itself is definitely non-real, as in the example below. - EXAMPLE:: + EXAMPLES:: sage: rt2 = QQbar(sqrt(2)) sage: rtm3 = QQbar(sqrt(-3)) @@ -6373,7 +6373,7 @@ def generator(self): r""" Return the :class:`~AlgebraicGenerator` object corresponding to self. - EXAMPLE:: + EXAMPLES:: sage: v = (x^2 - x - 1).roots(ring=AA, multiplicities=False)[1]._descr.exactify() sage: v.generator() @@ -6386,7 +6386,7 @@ def exactify(self): Return an exact representation of self. Since self is already exact, just return self. - EXAMPLE:: + EXAMPLES:: sage: v = (x^2 - x - 1).roots(ring=AA, multiplicities=False)[1]._descr.exactify() sage: type(v) @@ -6400,7 +6400,7 @@ def field_element_value(self): r""" Return the underlying number field element. - EXAMPLE:: + EXAMPLES:: sage: v = (x^2 - x - 1).roots(ring=AA, multiplicities=False)[1]._descr.exactify() sage: v.field_element_value() @@ -6474,7 +6474,7 @@ def neg(self, n): r""" Negation of self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) sage: a.exactify() @@ -6492,7 +6492,7 @@ def invert(self, n): r""" 1/self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) sage: a.exactify() @@ -6510,7 +6510,7 @@ def conjugate(self, n): r""" Negation of self. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) sage: a.exactify() @@ -6534,7 +6534,7 @@ def norm(self, n): r""" Norm of self (square of complex absolute value) - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) sage: a.exactify() @@ -6555,7 +6555,7 @@ def abs(self, n): r""" Return the absolute value of self (square root of the norm). - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) sage: a.exactify() @@ -6572,7 +6572,7 @@ def rational_argument(self, n): If the argument of self is `2\pi` times some rational number in `[1/2, -1/2)`, return that rational; otherwise, return ``None``. - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(3)) sage: a.exactify() @@ -6627,7 +6627,7 @@ def __init__(self, arg, op): r""" Initialize this ANUnaryExpr. - EXAMPLE:: + EXAMPLES:: sage: t = ~QQbar(sqrt(2)); type(t._descr) # indirect doctest @@ -6741,7 +6741,7 @@ def is_complex(self): type check, and triggers no computations -- if it returns False, the element might still be real, it just doesn't know it yet. - EXAMPLE:: + EXAMPLES:: sage: t = AA(sqrt(2)) sage: s = (-t)._descr @@ -6758,7 +6758,7 @@ def _interval_fast(self, prec): r""" Calculate an approximation to this ``ANUnaryExpr`` object in an interval field of precision ``prec``. - EXAMPLE:: + EXAMPLES:: sage: t = AA(sqrt(2)) sage: s = (-t)._descr @@ -6815,7 +6815,7 @@ def exactify(self): r""" Trigger exact computation of self. - EXAMPLE:: + EXAMPLES:: sage: v = (-QQbar(sqrt(2)))._descr sage: type(v) @@ -6881,7 +6881,7 @@ def __init__(self, left, right, op): r""" Initialize this ANBinaryExpr. - EXAMPLE:: + EXAMPLES:: sage: t = QQbar(sqrt(2)) + QQbar(sqrt(3)); type(t._descr) # indirect doctest @@ -7019,7 +7019,7 @@ def is_complex(self): Whether this element is complex. Does not trigger exact computation, so may return True even if the element is real. - EXAMPLE:: + EXAMPLES:: sage: x = (QQbar(sqrt(-2)) / QQbar(sqrt(-5)))._descr sage: x.is_complex() @@ -7031,7 +7031,7 @@ def _interval_fast(self, prec): r""" Calculate an approximation to self in an interval field of precision prec. - EXAMPLE:: + EXAMPLES:: sage: x = (QQbar(sqrt(-2)) / QQbar(sqrt(-5)))._descr sage: y= x._interval_fast(64); y @@ -7131,7 +7131,7 @@ def an_binop_expr(a, b, op): - ``op`` -- an operator - EXAMPLE:: + EXAMPLES:: sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3)) sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5)) @@ -7243,7 +7243,7 @@ def _init_qqbar(): that qqbar is imported rather early on in the sage loading. This function is called at the end of sage.all. - EXAMPLE:: + EXAMPLES:: sage: sage.rings.qqbar.QQbar_I_generator # indirect doctest Number Field in I with defining polynomial x^2 + 1 with a in 1*I @@ -7278,7 +7278,7 @@ def get_AA_golden_ratio(): Return the golden ratio as an element of the algebraic real field. Used by :meth:`sage.symbolic.constants.golden_ratio._algebraic_`. - EXAMPLE:: + EXAMPLES:: sage: AA(golden_ratio) # indirect doctest 1.618033988749895? diff --git a/src/sage/rings/quotient_ring.py b/src/sage/rings/quotient_ring.py index 18195e597ef..a670513aa67 100644 --- a/src/sage/rings/quotient_ring.py +++ b/src/sage/rings/quotient_ring.py @@ -730,7 +730,7 @@ def retract(self,x): The image of the given element in ``self``. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(QQ, 2) sage: S = R.quotient(x^2 + y^2) @@ -1257,7 +1257,7 @@ class QuotientRing_generic(QuotientRing_nc, ring.CommutativeRing): r""" Creates a quotient ring of a *commutative* ring `R` by the ideal `I`. - EXAMPLE:: + EXAMPLES:: sage: R. = PolynomialRing(ZZ) sage: I = R.ideal([4 + 3*x + x^2, 1 + x^2]) diff --git a/src/sage/rings/quotient_ring_element.py b/src/sage/rings/quotient_ring_element.py index 75d932d0653..e6565a78b79 100644 --- a/src/sage/rings/quotient_ring_element.py +++ b/src/sage/rings/quotient_ring_element.py @@ -660,7 +660,7 @@ def lt(self): """ Return the leading term of this quotient ring element. - EXAMPLE:: + EXAMPLES:: sage: R.=PolynomialRing(GF(7),3,order='lex') sage: I = sage.rings.ideal.FieldIdeal(R) @@ -682,7 +682,7 @@ def lm(self): """ Return the leading monomial of this quotient ring element. - EXAMPLE:: + EXAMPLES:: sage: R.=PolynomialRing(GF(7),3,order='lex') sage: I = sage.rings.ideal.FieldIdeal(R) @@ -705,7 +705,7 @@ def lc(self): """ Return the leading coefficient of this quotient ring element. - EXAMPLE:: + EXAMPLES:: sage: R.=PolynomialRing(GF(7),3,order='lex') sage: I = sage.rings.ideal.FieldIdeal(R) @@ -779,7 +779,7 @@ def _singular_(self, singular=singular_default): - ``singular`` - a non-standard interpreter may be provided - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(2),2) sage: I = sage.rings.ideal.FieldIdeal(P) @@ -841,7 +841,7 @@ def reduce(self, G): - ``G`` - a list of quotient ring elements - EXAMPLE:: + EXAMPLES:: sage: P. = PolynomialRing(GF(2), 5, order='lex') sage: I1 = ideal([a*b + c*d + 1, a*c*e + d*e, a*b*e + c*e, b*c + c*d*e + 1]) diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index 49c890312a9..59f8d76943b 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -2847,7 +2847,7 @@ cdef class Rational(sage.structure.element.FieldElement): """ Return the numerator of this rational number. - EXAMPLE:: + EXAMPLES:: sage: x = -5/11 sage: x.numer() @@ -2862,7 +2862,7 @@ cdef class Rational(sage.structure.element.FieldElement): """ Return the numerator of this rational number. - EXAMPLE:: + EXAMPLES:: sage: x = 5/11 sage: x.numerator() diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx index 7a8cf0aa706..9a2fe328ed4 100644 --- a/src/sage/rings/real_arb.pyx +++ b/src/sage/rings/real_arb.pyx @@ -577,7 +577,7 @@ class RealBallField(UniqueRepresentation, Field): def gens(self): r""" - EXAMPLE:: + EXAMPLES:: sage: RBF.gens() (1.000000000000000,) diff --git a/src/sage/rings/real_double.pyx b/src/sage/rings/real_double.pyx index 69156fb00c1..473adfa7942 100644 --- a/src/sage/rings/real_double.pyx +++ b/src/sage/rings/real_double.pyx @@ -160,7 +160,7 @@ cdef class RealDoubleField_class(Field): """ Returns ``False``, because doubles are not exact. - EXAMPLE:: + EXAMPLES:: sage: RDF.is_exact() False @@ -2528,7 +2528,7 @@ cdef class RealDoubleElement(FieldElement): Uses the PARI C-library ``algdep`` command. - EXAMPLE:: + EXAMPLES:: sage: r = sqrt(RDF(2)); r 1.4142135623730951 @@ -2629,7 +2629,7 @@ def is_RealDoubleElement(x): """ Check if ``x`` is an element of the real double field. - EXAMPLE:: + EXAMPLES:: sage: from sage.rings.real_double import is_RealDoubleElement sage: is_RealDoubleElement(RDF(3)) diff --git a/src/sage/rings/real_mpfi.pyx b/src/sage/rings/real_mpfi.pyx index eff00af4dee..eb790be3f1c 100644 --- a/src/sage/rings/real_mpfi.pyx +++ b/src/sage/rings/real_mpfi.pyx @@ -865,7 +865,7 @@ cdef class RealIntervalField_class(sage.rings.ring.Field): """ Return a list of generators. - EXAMPLE:: + EXAMPLES:: sage: RIF.gens() [1] diff --git a/src/sage/rings/real_mpfr.pyx b/src/sage/rings/real_mpfr.pyx index 15dff6793f2..b8504e75011 100644 --- a/src/sage/rings/real_mpfr.pyx +++ b/src/sage/rings/real_mpfr.pyx @@ -597,7 +597,7 @@ cdef class RealField_class(sage.rings.ring.Field): Return ``False``, since a real field (represented using finite precision) is not exact. - EXAMPLE:: + EXAMPLES:: sage: RR.is_exact() False @@ -858,7 +858,7 @@ cdef class RealField_class(sage.rings.ring.Field): """ Return a list of generators. - EXAMPLE:: + EXAMPLES:: sage: RR.gens() [1.00000000000000] @@ -1732,7 +1732,7 @@ cdef class RealNumber(sage.structure.element.RingElement): will have the same hash, but allows them to play nicely with other real types. - EXAMPLE:: + EXAMPLES:: sage: hash(RR(1.2)) == hash(1.2r) True @@ -2056,7 +2056,7 @@ cdef class RealNumber(sage.structure.element.RingElement): OUTPUT: a Sage Integer - EXAMPLE:: + EXAMPLES:: sage: a = 119.41212 sage: a.integer_part() @@ -5078,7 +5078,7 @@ cdef class RealNumber(sage.structure.element.RingElement): Uses the PARI C-library ``algdep`` command. - EXAMPLE:: + EXAMPLES:: sage: r = sqrt(2.0); r 1.41421356237310 diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx index e8e0f3bb102..fe317761074 100644 --- a/src/sage/rings/ring.pyx +++ b/src/sage/rings/ring.pyx @@ -2447,7 +2447,7 @@ cdef class CommutativeAlgebra(CommutativeRing): Standard init function. This just checks that the base is a commutative ring and then passes the buck. - EXAMPLE:: + EXAMPLES:: sage: sage.rings.ring.CommutativeAlgebra(QQ) # indirect doctest diff --git a/src/sage/sat/boolean_polynomials.py b/src/sage/sat/boolean_polynomials.py index 7f962053e8a..b7c29b95922 100644 --- a/src/sage/sat/boolean_polynomials.py +++ b/src/sage/sat/boolean_polynomials.py @@ -251,7 +251,7 @@ def learn(F, converter=None, solver=None, max_learnt_length=3, interreduction=Fa A sequence of Boolean polynomials. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.boolean_polynomials import learn as learn_sat # optional - cryptominisat diff --git a/src/sage/sat/converters/polybori.py b/src/sage/sat/converters/polybori.py index 49f6cf7d822..2d764a7e787 100644 --- a/src/sage/sat/converters/polybori.py +++ b/src/sage/sat/converters/polybori.py @@ -153,7 +153,7 @@ def var(self, m=None, decision=None): - ``m`` - something the new variables maps to, usually a monomial - ``decision`` - is this variable a decision variable? - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.converters.polybori import CNFEncoder sage: from sage.sat.solvers.dimacs import DIMACS @@ -170,7 +170,7 @@ def phi(self): """ Map SAT variables to polynomial variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.converters.polybori import CNFEncoder sage: from sage.sat.solvers.dimacs import DIMACS @@ -191,7 +191,7 @@ def zero_blocks(self, f): """ Divides the zero set of ``f`` into blocks. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from sage.sat.converters.polybori import CNFEncoder @@ -259,7 +259,7 @@ def clauses_sparse(self, f): - ``f`` - a :class:`sage.rings.polynomial.pbori.BooleanPolynomial` - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from sage.sat.converters.polybori import CNFEncoder @@ -304,7 +304,7 @@ def clauses_dense(self, f): - ``f`` - a :class:`sage.rings.polynomial.pbori.BooleanPolynomial` - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from sage.sat.converters.polybori import CNFEncoder @@ -352,7 +352,7 @@ def monomial(self, m): OUTPUT: An index for a SAT variable corresponding to ``m``. - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from sage.sat.converters.polybori import CNFEncoder @@ -413,7 +413,7 @@ def permutations(length, equal_zero): - ``length`` - the number of variables - ``equal_zero`` - should the sum be equal to zero? - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.converters.polybori import CNFEncoder @@ -447,7 +447,7 @@ def split_xor(self, monomial_list, equal_zero): - ``monomial_list`` - a list of monomials - ``equal_zero`` - is the constant coefficient zero? - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.converters.polybori import CNFEncoder sage: from sage.sat.solvers.dimacs import DIMACS @@ -493,7 +493,7 @@ def clauses(self, f): - ``f`` - a :class:`sage.rings.polynomial.pbori.BooleanPolynomial` - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from sage.sat.converters.polybori import CNFEncoder @@ -547,7 +547,7 @@ def __call__(self, F): OUTPUT: An inverse map int -> variable - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from sage.sat.converters.polybori import CNFEncoder @@ -590,7 +590,7 @@ def to_polynomial(self, c): - ``c`` - a clause - EXAMPLE:: + EXAMPLES:: sage: B. = BooleanPolynomialRing() sage: from sage.sat.converters.polybori import CNFEncoder diff --git a/src/sage/sat/solvers/cryptominisat/cryptominisat.pyx b/src/sage/sat/solvers/cryptominisat/cryptominisat.pyx index d48b32b91f3..88c70fa9477 100644 --- a/src/sage/sat/solvers/cryptominisat/cryptominisat.pyx +++ b/src/sage/sat/solvers/cryptominisat/cryptominisat.pyx @@ -50,7 +50,7 @@ cdef class CryptoMiniSat(SatSolver): """ The CryptoMiniSat solver. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers import CryptoMiniSat # optional - cryptominisat sage: cms = CryptoMiniSat() # optional - cryptominisat @@ -75,7 +75,7 @@ cdef class CryptoMiniSat(SatSolver): - ``SolverConf`` - a :cls:`sage.sat.solvers.cryptominisat.SolverConf` instance - ``**kwds`` - passed to :cls:`sage.sat.solvers.cryptominisat.SolverConf` - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers import CryptoMiniSat # optional - cryptominisat sage: cms = CryptoMiniSat() # optional - cryptominisat @@ -140,7 +140,7 @@ cdef class CryptoMiniSat(SatSolver): - ``decision`` - if ``True`` this variable will be used for decisions (default: ``None``, let the solver decide.) - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers import CryptoMiniSat # optional - cryptominisat sage: cms = CryptoMiniSat() # optional - cryptominisat @@ -163,7 +163,7 @@ cdef class CryptoMiniSat(SatSolver): """ Return the number of variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers import CryptoMiniSat # optional - cryptominisat sage: cms = CryptoMiniSat() # optional - cryptominisat @@ -190,7 +190,7 @@ cdef class CryptoMiniSat(SatSolver): than the number of variables generated so far, then new variables are created automatically. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers import CryptoMiniSat # optional - cryptominisat sage: cms = CryptoMiniSat() # optional - cryptominisat @@ -228,7 +228,7 @@ cdef class CryptoMiniSat(SatSolver): than the number of variables generated so far, then new variables are created automatically. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers import CryptoMiniSat # optional - cryptominisat sage: cms = CryptoMiniSat() # optional - cryptominisat @@ -323,7 +323,7 @@ cdef class CryptoMiniSat(SatSolver): Return conflict clause if this instance is UNSAT and the last call used assumptions. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers import CryptoMiniSat # optional - cryptominisat sage: cms = CryptoMiniSat() # optional - cryptominisat @@ -377,7 +377,7 @@ cdef class CryptoMiniSat(SatSolver): - ``unitary_only`` - return only unitary learnt clauses (default: ``False``) - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers import CryptoMiniSat # optional - cryptominisat sage: from sage.sat.converters.polybori import CNFEncoder # optional - cryptominisat diff --git a/src/sage/sat/solvers/cryptominisat/solverconf.pyx b/src/sage/sat/solvers/cryptominisat/solverconf.pyx index 776eb6f9758..cfea9bc32a5 100644 --- a/src/sage/sat/solvers/cryptominisat/solverconf.pyx +++ b/src/sage/sat/solvers/cryptominisat/solverconf.pyx @@ -60,7 +60,7 @@ cdef class SolverConf(object): - ``kwds`` - see string representation of any instance of this class for a list of options. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.cryptominisat import SolverConf # optional - cryptominisat sage: s = SolverConf() # optional - cryptominisat @@ -92,7 +92,7 @@ cdef class SolverConf(object): """ Set options using dictionary notation. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.cryptominisat import SolverConf # optional - cryptominisat sage: s = SolverConf() # optional - cryptominisat @@ -135,7 +135,7 @@ cdef class SolverConf(object): """ Set options using attributes. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.cryptominisat import SolverConf # optional - cryptominisat sage: s = SolverConf() # optional - cryptominisat @@ -156,7 +156,7 @@ cdef class SolverConf(object): """ Read options using dictionary notation. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.cryptominisat import SolverConf # optional - cryptominisat sage: s = SolverConf() # optional - cryptominisat @@ -197,7 +197,7 @@ cdef class SolverConf(object): """ Read options using dictionary notation. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.cryptominisat import SolverConf # optional - cryptominisat sage: s = SolverConf() # optional - cryptominisat @@ -218,7 +218,7 @@ cdef class SolverConf(object): """ Print the current configuration. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.cryptominisat import SolverConf # optional - cryptominisat sage: s = SolverConf(); s # optional - cryptominisat @@ -254,7 +254,7 @@ cdef class SolverConf(object): """ Return list of all option names. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.cryptominisat import SolverConf # optional - cryptominisat sage: s = SolverConf() # optional - cryptominisat @@ -300,7 +300,7 @@ cdef class SolverConf(object): """ Return a copy. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.cryptominisat import SolverConf # optional - cryptominisat sage: s = SolverConf() # optional - cryptominisat diff --git a/src/sage/sat/solvers/dimacs.py b/src/sage/sat/solvers/dimacs.py index 24807ebf7da..26b447128a2 100644 --- a/src/sage/sat/solvers/dimacs.py +++ b/src/sage/sat/solvers/dimacs.py @@ -122,7 +122,7 @@ def var(self, decision=None): - ``decision`` - accepted for compatibility with other solvers, ignored. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.dimacs import DIMACS sage: solver = DIMACS() @@ -136,7 +136,7 @@ def nvars(self): """ Return the number of variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.dimacs import DIMACS sage: solver = DIMACS() @@ -163,7 +163,7 @@ def add_clause(self, lits): than the number of variables generated so far, then new variables are created automatically. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.dimacs import DIMACS sage: solver = DIMACS() @@ -194,7 +194,7 @@ def write(self, filename=None): - ``filename`` - if ``None`` default filename specified at initialization is used for writing to (default: ``None``) - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.dimacs import DIMACS sage: fn = tmp_filename() @@ -252,7 +252,7 @@ def clauses(self, filename=None): If ``filename`` points to a writable file, then the list of original clauses is written to that file in DIMACS format. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.dimacs import DIMACS sage: fn = tmp_filename() @@ -306,7 +306,7 @@ def render_dimacs(clauses, filename, nlits): - ``nlits -- the number of literals appearing in ``clauses`` - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.dimacs import DIMACS sage: fn = tmp_filename() @@ -437,7 +437,7 @@ def __call__(self, assumptions=None): - If this instance is UNSAT: ``False`` - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.boolean_polynomials import solve as solve_sat sage: F,s = mq.SR(1,1,1,4,gf2=True,polybori=True).polynomial_system() @@ -484,7 +484,7 @@ def __call__(self, **kwds): - If this instance is UNSAT: ``False`` - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.boolean_polynomials import solve as solve_sat sage: F,s = mq.SR(1,1,1,4,gf2=True,polybori=True).polynomial_system() diff --git a/src/sage/sat/solvers/sat_lp.py b/src/sage/sat/solvers/sat_lp.py index 5191718e597..e374d920e78 100644 --- a/src/sage/sat/solvers/sat_lp.py +++ b/src/sage/sat/solvers/sat_lp.py @@ -25,7 +25,7 @@ def __init__(self, solver=None): of the class :class:`MixedIntegerLinearProgram `. - EXAMPLE:: + EXAMPLES:: sage: S=SAT(solver="LP"); S an ILP-based SAT Solver @@ -38,7 +38,7 @@ def var(self): """ Return a *new* variable. - EXAMPLE:: + EXAMPLES:: sage: S=SAT(solver="LP"); S an ILP-based SAT Solver @@ -55,7 +55,7 @@ def nvars(self): """ Return the number of variables. - EXAMPLE:: + EXAMPLES:: sage: S=SAT(solver="LP"); S an ILP-based SAT Solver @@ -82,7 +82,7 @@ def add_clause(self, lits): than the number of variables generated so far, then new variables are created automatically. - EXAMPLE:: + EXAMPLES:: sage: S=SAT(solver="LP"); S an ILP-based SAT Solver @@ -109,7 +109,7 @@ def __call__(self): - If this instance is UNSAT: ``False`` - EXAMPLE:: + EXAMPLES:: sage: def is_bipartite_SAT(G): ....: S=SAT(solver="LP"); S diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx index 56439bc636b..afdb7661914 100644 --- a/src/sage/sat/solvers/satsolver.pyx +++ b/src/sage/sat/solvers/satsolver.pyx @@ -21,7 +21,7 @@ cdef class SatSolver: """ Constuct a new SATSolver. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.satsolver import SatSolver sage: solver = SatSolver() @@ -36,7 +36,7 @@ cdef class SatSolver: - ``decision`` - is this variable a decision variable? - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.satsolver import SatSolver sage: solver = SatSolver() @@ -51,7 +51,7 @@ cdef class SatSolver: """ Return the number of variables. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.satsolver import SatSolver sage: solver = SatSolver() @@ -76,7 +76,7 @@ cdef class SatSolver: than the number of variables generated so far, then new variables are created automatically. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.satsolver import SatSolver sage: solver = SatSolver() @@ -111,7 +111,7 @@ cdef class SatSolver: - ``filename`` - The name of a file as a string or a file object - EXAMPLE:: + EXAMPLES:: sage: from six import StringIO # for python 2/3 support sage: file_object = StringIO("c A sample .cnf file.\np cnf 3 2\n1 -3 0\n2 3 -1 0 ") @@ -155,7 +155,7 @@ cdef class SatSolver: - If the solver was interrupted before deciding satisfiability ``None``. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.satsolver import SatSolver sage: solver = SatSolver() @@ -171,7 +171,7 @@ cdef class SatSolver: Return conflict clause if this instance is UNSAT and the last call used assumptions. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.satsolver import SatSolver sage: solver = SatSolver() @@ -190,7 +190,7 @@ cdef class SatSolver: - ``unitary_only`` - return only unitary learnt clauses (default: ``False``) - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.satsolver import SatSolver sage: solver = SatSolver() @@ -236,7 +236,7 @@ cdef class SatSolver: clauses is written to that file in DIMACS format. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.satsolver import SatSolver sage: solver = SatSolver() @@ -249,7 +249,7 @@ cdef class SatSolver: def __getattr__(self, name): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.satsolver import SatSolver sage: solver = SatSolver() @@ -267,7 +267,7 @@ cdef class SatSolver: """ Allow alias to appear in tab completion. - EXAMPLE:: + EXAMPLES:: sage: from sage.sat.solvers.satsolver import SatSolver sage: solver = SatSolver() @@ -296,7 +296,7 @@ def SAT(solver=None): - ``None`` (default) -- use CryptoMiniSat if available, and a LP solver otherwise. - EXAMPLE:: + EXAMPLES:: sage: SAT(solver="LP") an ILP-based SAT Solver diff --git a/src/sage/schemes/curves/affine_curve.py b/src/sage/schemes/curves/affine_curve.py index 72c520d7d75..ba4a4a9d113 100644 --- a/src/sage/schemes/curves/affine_curve.py +++ b/src/sage/schemes/curves/affine_curve.py @@ -1496,7 +1496,7 @@ def rational_points(self, algorithm="enum"): Use *very* naive point enumeration to find all rational points on this curve over a finite field. - EXAMPLE:: + EXAMPLES:: sage: A. = AffineSpace(2,GF(9,'a')) sage: C = Curve(x^2 + y^2 - 1) @@ -1542,7 +1542,7 @@ def riemann_roch_basis(self,D): OUTPUT: basis of L(Div) - EXAMPLE:: + EXAMPLES:: sage: R = PolynomialRing(GF(5),2,names = ["x","y"]) sage: x, y = R.gens() @@ -1603,7 +1603,7 @@ def rational_points(self, algorithm="enum"): The Brill-Noether package does not always work. When it fails a RuntimeError exception is raised. - EXAMPLE:: + EXAMPLES:: sage: x, y = (GF(5)['x,y']).gens() sage: f = y^2 - x^9 - x diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py index 3e83b2c218b..e2de777ffac 100644 --- a/src/sage/schemes/curves/projective_curve.py +++ b/src/sage/schemes/curves/projective_curve.py @@ -554,7 +554,7 @@ def arithmetic_genus(self): OUTPUT: Integer. - EXAMPLE:: + EXAMPLES:: sage: x,y,z = PolynomialRing(GF(5), 3, 'xyz').gens() sage: C = Curve(y^2*z^7 - x^9 - x*z^8); C @@ -1568,7 +1568,7 @@ def rational_points_iterator(self): A generator of all the rational points on the curve defined over its base field. - EXAMPLE:: + EXAMPLES:: sage: F = GF(37) sage: P2. = ProjectiveSpace(F,2) @@ -1742,7 +1742,7 @@ def _points_via_singular(self, sort=True): computed by Singular. - EXAMPLE:: + EXAMPLES:: sage: x, y, z = PolynomialRing(GF(5), 3, 'xyz').gens() sage: f = y^2*z^7 - x^9 - x*z^8 @@ -1814,7 +1814,7 @@ def riemann_roch_basis(self, D): A list of function field elements that form a basis of the Riemann-Roch space - EXAMPLE:: + EXAMPLES:: sage: R. = GF(2)[] sage: f = x^3*y + y^3*z + x*z^3 @@ -1891,7 +1891,7 @@ def rational_points(self, algorithm="enum", sort=True): - ``'bn'`` - via Singular's brnoeth package. - EXAMPLE:: + EXAMPLES:: sage: x, y, z = PolynomialRing(GF(5), 3, 'xyz').gens() sage: f = y^2*z^7 - x^9 - x*z^8 diff --git a/src/sage/schemes/elliptic_curves/BSD.py b/src/sage/schemes/elliptic_curves/BSD.py index 3de0c777708..3d2076399bf 100644 --- a/src/sage/schemes/elliptic_curves/BSD.py +++ b/src/sage/schemes/elliptic_curves/BSD.py @@ -18,7 +18,7 @@ class BSD_data: """ Helper class used to keep track of information in proving BSD. - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.BSD import BSD_data sage: D = BSD_data() @@ -50,7 +50,7 @@ def update(self): """ Updates some properties from ``curve``. - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.BSD import BSD_data sage: D = BSD_data() @@ -206,7 +206,7 @@ def heegner_index_work(E): - the discriminant used - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.BSD import heegner_index_work sage: heegner_index_work(EllipticCurve('14a')) diff --git a/src/sage/schemes/elliptic_curves/cm.py b/src/sage/schemes/elliptic_curves/cm.py index 940619a4883..dfbbaaf80e0 100644 --- a/src/sage/schemes/elliptic_curves/cm.py +++ b/src/sage/schemes/elliptic_curves/cm.py @@ -186,7 +186,7 @@ def cm_j_invariants(K, proof=None): (list) -- A list of CM `j`-invariants in the field `K`. - EXAMPLE:: + EXAMPLES:: sage: cm_j_invariants(QQ) [-262537412640768000, -147197952000, -884736000, -12288000, -884736, -32768, -3375, 0, 1728, 8000, 54000, 287496, 16581375] @@ -228,7 +228,7 @@ def cm_j_invariants_and_orders(K, proof=None): `j`-invariant in `K` with quadratic fundamental discriminant `D` and conductor `f`. - EXAMPLE:: + EXAMPLES:: sage: cm_j_invariants_and_orders(QQ) [(-3, 3, -12288000), (-3, 2, 54000), (-3, 1, 0), (-4, 2, 287496), (-4, 1, 1728), (-7, 2, 16581375), (-7, 1, -3375), (-8, 1, 8000), (-11, 1, -32768), (-19, 1, -884736), (-43, 1, -884736000), (-67, 1, -147197952000), (-163, 1, -262537412640768000)] diff --git a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx index 50000de8fa9..31f2de1282b 100644 --- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx +++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx @@ -51,7 +51,7 @@ def test_valuation(a, p): """ Doctest function for cdef long valuation(mpz_t, mpz_t). - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.descent_two_isogeny import test_valuation as tv sage: for i in [1..20]: @@ -110,7 +110,7 @@ def test_padic_square(a, p): """ Doctest function for cdef int padic_square(mpz_t, unsigned long). - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.descent_two_isogeny import test_padic_square as ps sage: for i in [1..300]: @@ -856,7 +856,7 @@ def test_qpls(a,b,c,d,e,p): """ Testing function for Qp_soluble. - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.descent_two_isogeny import test_qpls as tq sage: tq(1,2,3,4,5,7) @@ -916,7 +916,7 @@ def test_els(a,b,c,d,e): """ Doctest function for cdef int everywhere_locally_soluble(mpz_t, mpz_t, mpz_t, mpz_t, mpz_t). - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.descent_two_isogeny import test_els sage: from sage.libs.ratpoints import ratpoints diff --git a/src/sage/schemes/elliptic_curves/ell_finite_field.py b/src/sage/schemes/elliptic_curves/ell_finite_field.py index 12bc266dc94..c97d9c96a4b 100644 --- a/src/sage/schemes/elliptic_curves/ell_finite_field.py +++ b/src/sage/schemes/elliptic_curves/ell_finite_field.py @@ -1280,7 +1280,7 @@ def __getitem__(self, n): Return the n'th point in self's __points list. This enables users to iterate over the curve's point set. - EXAMPLE:: + EXAMPLES:: sage: E=EllipticCurve(GF(97),[2,3]) sage: S=E.points() diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py index b2f33d21dd3..2fc6456230b 100644 --- a/src/sage/schemes/elliptic_curves/ell_number_field.py +++ b/src/sage/schemes/elliptic_curves/ell_number_field.py @@ -17,7 +17,7 @@ the torsion subgroup of the Mordell-Weil group `E(K)`, and it can work with isogenies defined over `K`. -EXAMPLE:: +EXAMPLES:: sage: K. = NumberField(x^2+1) sage: E = EllipticCurve([0,4+i]) @@ -2573,7 +2573,7 @@ def height_function(self): """ Return the canonical height function attached to self. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^2 - 5) sage: E = EllipticCurve(K, '11a3') diff --git a/src/sage/schemes/elliptic_curves/ell_padic_field.py b/src/sage/schemes/elliptic_curves/ell_padic_field.py index d435bbf5b1a..a7bf5a7f9fb 100644 --- a/src/sage/schemes/elliptic_curves/ell_padic_field.py +++ b/src/sage/schemes/elliptic_curves/ell_padic_field.py @@ -55,7 +55,7 @@ def frobenius(self, P=None): Returns the Frobenius as a function on the group of points of this elliptic curve. - EXAMPLE:: + EXAMPLES:: sage: Qp=pAdicField(13) sage: E=EllipticCurve(Qp,[1,1]) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 494081b5469..d5968a7521c 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -271,7 +271,7 @@ def __init__(self, curve, v, check=True): - v -- data determining a point (another point, the integer 0, or a tuple of coordinates) - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('43a') sage: P = E([2, -4, 2]); P @@ -334,7 +334,7 @@ def _repr_(self): """ Return a string representation of this point. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('39a') sage: P = E([-2, 1, 1]) @@ -347,7 +347,7 @@ def _latex_(self): """ Return a LaTeX representation of this point. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('40a') sage: P = E([3, 0]) @@ -360,7 +360,7 @@ def __getitem__(self, n): """ Return the n'th coordinate of this point. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('42a') sage: P = E([-17, -51, 17]) @@ -373,7 +373,7 @@ def __iter__(self): """ Return the coordinates of this point as a list. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('37a') sage: list(E([0,0])) @@ -385,7 +385,7 @@ def __tuple__(self): """ Return the coordinates of this point as a tuple. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('44a') sage: P = E([1, -2, 1]) @@ -505,7 +505,7 @@ def order(self): :meth:`additive_order` is a synonym for :meth:`order` - EXAMPLE:: + EXAMPLES:: sage: K.=FractionField(PolynomialRing(QQ,'t')) sage: E=EllipticCurve([0,0,0,-t^2,0]) @@ -3387,7 +3387,7 @@ def _magma_init_(self, magma): Return a string representation of self that ``MAGMA`` can use for input. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve(GF(17), [1,-1]) sage: P = E([13, 4]) @@ -3422,7 +3422,7 @@ def discrete_log(self, Q, ord=None): - John Cremona. Adapted to use generic functions 2008-04-05. - EXAMPLE:: + EXAMPLES:: sage: F = GF(3^6,'a') sage: a = F.gen() @@ -3449,7 +3449,7 @@ def has_finite_order(self): Since the base field is finite, the answer will always be ``True``. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve(GF(7), [1,3]) sage: P = E.points()[3] diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py index b216fd6bd67..6bfae81594a 100644 --- a/src/sage/schemes/elliptic_curves/ell_rational_field.py +++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py @@ -513,7 +513,7 @@ def conductor(self, algorithm="pari"): common value. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve([1, -1, 1, -29372, -1932937]) sage: E.conductor(algorithm="pari") @@ -7139,7 +7139,7 @@ def elliptic_curve_congruence_graph(curves): label) and an edge from `E` to `F` labelled `p` if and only if `E` is congruent to `F` mod `p` - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.ell_rational_field import elliptic_curve_congruence_graph sage: curves = list(cremona_optimal_curves([11..30])) diff --git a/src/sage/schemes/elliptic_curves/ell_wp.py b/src/sage/schemes/elliptic_curves/ell_wp.py index 90bc21b2f21..5b44cb17dd4 100644 --- a/src/sage/schemes/elliptic_curves/ell_wp.py +++ b/src/sage/schemes/elliptic_curves/ell_wp.py @@ -19,7 +19,7 @@ via the formal group as `x+c` in the variable `z=\log_E(t)` for a constant `c` such that the constant term `c_0` in `\wp(z)` is zero. -EXAMPLE:: +EXAMPLES:: sage: E = EllipticCurve([0,1]) sage: E.weierstrass_p() diff --git a/src/sage/schemes/elliptic_curves/formal_group.py b/src/sage/schemes/elliptic_curves/formal_group.py index 1a12bf71321..f414e1f0c95 100644 --- a/src/sage/schemes/elliptic_curves/formal_group.py +++ b/src/sage/schemes/elliptic_curves/formal_group.py @@ -25,7 +25,7 @@ class EllipticCurveFormalGroup(SageObject): """ def __init__(self, E): """ - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('11a') sage: F = E.formal_group(); F @@ -53,7 +53,7 @@ def __cmp__(self, other): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('43a') sage: F = E.formal_group() @@ -720,7 +720,7 @@ def mult_by_n(self, n, prec=10): def sigma(self, prec=10): """ - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('14a') sage: F = E.formal_group() diff --git a/src/sage/schemes/elliptic_curves/heegner.py b/src/sage/schemes/elliptic_curves/heegner.py index f9bc95e95db..3a71e096109 100644 --- a/src/sage/schemes/elliptic_curves/heegner.py +++ b/src/sage/schemes/elliptic_curves/heegner.py @@ -6299,7 +6299,7 @@ def ell_heegner_discriminants_list(self, n): OUTPUT: The list of the first n Heegner discriminants smaller than -5 for the given elliptic curve. - EXAMPLE:: + EXAMPLES:: sage: E=EllipticCurve('11a') sage: E.heegner_discriminants_list(4) # indirect doctest @@ -6338,7 +6338,7 @@ def heegner_point_height(self, D, prec=2, check_rank=True): OUTPUT: Interval that contains the height of the Heegner point. - EXAMPLE:: + EXAMPLES:: sage: E = EllipticCurve('11a') sage: E.heegner_point_height(-7) diff --git a/src/sage/schemes/elliptic_curves/height.py b/src/sage/schemes/elliptic_curves/height.py index d52b7021e06..4e916d3824a 100644 --- a/src/sage/schemes/elliptic_curves/height.py +++ b/src/sage/schemes/elliptic_curves/height.py @@ -590,7 +590,7 @@ def min_on_disk(f, tol, max_iter=10000): contained in the disk `|z|\le1`, at which `f` takes its minumum value. - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.height import min_on_disk sage: f = lambda x: (x^2+100).abs() @@ -1790,7 +1790,7 @@ def test_mu(self, mu, N, verbose=True): the attempt failed: trying again with larger `N` may yield ``True``. - EXAMPLE:: + EXAMPLES:: sage: K. = NumberField(x^3-2) sage: E = EllipticCurve([0,0,0,0,a]) diff --git a/src/sage/schemes/elliptic_curves/kraus.py b/src/sage/schemes/elliptic_curves/kraus.py index 8baf9046dff..6f4dfc2f4f4 100644 --- a/src/sage/schemes/elliptic_curves/kraus.py +++ b/src/sage/schemes/elliptic_curves/kraus.py @@ -422,7 +422,7 @@ def test_a1a3_local(c4,c6,P,a1,a3, debug=False): The elliptic curve which is the (a1^2/12,a1/2,a3/2)-transform of [0,0,0,-c4/48,-c6/864] if this is integral at P, else False. - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.kraus import test_a1a3_local sage: K. = NumberField(x^2-10) @@ -462,7 +462,7 @@ def test_a1a3_global(c4,c6,a1,a3, debug=False): [0,0,0,-c4/48,-c6/864] if this is integral at all primes P dividing 2, else False. - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.kraus import test_a1a3_global sage: K. = NumberField(x^2-10) diff --git a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx index 2d5160c480a..349df926f92 100644 --- a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx +++ b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx @@ -58,7 +58,7 @@ cdef class PeriodicRegion: def __init__(self, w1, w2, data, full=True): """ - EXAMPLE:: + EXAMPLES:: sage: import numpy as np sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion diff --git a/src/sage/schemes/elliptic_curves/weierstrass_morphism.py b/src/sage/schemes/elliptic_curves/weierstrass_morphism.py index f332d5c20f4..a46bab3121e 100644 --- a/src/sage/schemes/elliptic_curves/weierstrass_morphism.py +++ b/src/sage/schemes/elliptic_curves/weierstrass_morphism.py @@ -86,7 +86,7 @@ def __cmp__(self, other): In a list of automorphisms, there is no guarantee that the identity will be first! - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.elliptic_curves.weierstrass_morphism import * sage: baseWI(1,2,3,4)==baseWI(1,2,3,4) diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py index aeb0d519922..ac8e95ca743 100644 --- a/src/sage/schemes/generic/homset.py +++ b/src/sage/schemes/generic/homset.py @@ -593,7 +593,7 @@ def list(self): A tuple containing all points of the toric variety. - EXAMPLE:: + EXAMPLES:: sage: P1 = toric_varieties.P1(base_ring=GF(3)) sage: P1.point_set().list() diff --git a/src/sage/schemes/generic/spec.py b/src/sage/schemes/generic/spec.py index e82cdc56252..a6150425b83 100644 --- a/src/sage/schemes/generic/spec.py +++ b/src/sage/schemes/generic/spec.py @@ -87,7 +87,7 @@ class SpecFunctor(Functor, UniqueRepresentation): """ def __init__(self, base_ring=None): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.schemes.generic.spec import SpecFunctor sage: SpecFunctor() diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py index cbbbd3c5b7e..2e22b1ef1aa 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py @@ -1,14 +1,14 @@ """ Hyperelliptic curves over a general ring -EXAMPLE:: +EXAMPLES:: sage: P. = GF(5)[] sage: f = x^5 - 3*x^4 - 2*x^3 + 6*x^2 + 3*x - 1 sage: C = HyperellipticCurve(f); C Hyperelliptic Curve over Finite Field of size 5 defined by y^2 = x^5 + 2*x^4 + 3*x^3 + x^2 + 3*x + 4 -EXAMPLE:: +EXAMPLES:: sage: P. = QQ[] sage: f = 4*x^5 - 30*x^3 + 45*x - 22 @@ -107,7 +107,7 @@ def _repr_(self): """ String representation of hyperelliptic curves. - EXAMPLE:: + EXAMPLES:: sage: P. = QQ[] sage: f = 4*x^5 - 30*x^3 + 45*x - 22 diff --git a/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py b/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py index 9f81891529a..85f3c406997 100644 --- a/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py +++ b/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py @@ -744,7 +744,7 @@ def reduce_negative(Q, p, coeffs, offset, exact_form=None): in coeffs[offset]. Note that coeffs[i] will be meaningless for i offset after this function is finished. - EXAMPLE:: + EXAMPLES:: sage: R. = Integers(5^3)['x'] sage: Q = x^3 - x + R(1/4) @@ -845,7 +845,7 @@ def reduce_positive(Q, p, coeffs, offset, exact_form=None): in coeffs[offset]. Note that coeffs[i] will be meaningless for i offset after this function is finished. - EXAMPLE:: + EXAMPLES:: sage: R. = Integers(5^3)['x'] sage: Q = x^3 - x + R(1/4) @@ -937,7 +937,7 @@ def reduce_zero(Q, coeffs, offset, exact_form=None): in coeffs[offset]. This method completely ignores coeffs[i] for i != offset. - EXAMPLE:: + EXAMPLES:: sage: R. = Integers(5^3)['x'] sage: Q = x^3 - x + R(1/4) @@ -996,7 +996,7 @@ def reduce_all(Q, p, coeffs, offset, compute_exact_form=False): The algorithm operates in-place, so the data in coeffs is destroyed. - EXAMPLE:: + EXAMPLES:: sage: R. = Integers(5^3)['x'] sage: Q = x^3 - x + R(1/4) diff --git a/src/sage/schemes/plane_quartics/quartic_generic.py b/src/sage/schemes/plane_quartics/quartic_generic.py index 597e53182f4..10ad1f5ef28 100644 --- a/src/sage/schemes/plane_quartics/quartic_generic.py +++ b/src/sage/schemes/plane_quartics/quartic_generic.py @@ -2,7 +2,7 @@ Plane quartic curves over a general ring. These are generic genus 3 curves, as distinct from hyperelliptic curves of genus 3. -EXAMPLE:: +EXAMPLES:: sage: PP. = ProjectiveSpace(2, QQ) sage: f = X^4 + Y^4 + Z^4 - 3*X*Y*Z*(X+Y+Z) diff --git a/src/sage/schemes/projective/endPN_automorphism_group.py b/src/sage/schemes/projective/endPN_automorphism_group.py index 13d52d8da23..3e5a104a3c2 100644 --- a/src/sage/schemes/projective/endPN_automorphism_group.py +++ b/src/sage/schemes/projective/endPN_automorphism_group.py @@ -927,7 +927,7 @@ def field_descent(sigma, y): - the unique element of the subfield if it exists, otherwise ``None``. - EXAMPLE:: + EXAMPLES:: sage: R = GF(11^2,'b') sage: RR = GF(11) diff --git a/src/sage/schemes/toric/variety.py b/src/sage/schemes/toric/variety.py index 2d9c1de3a44..1da26304e34 100644 --- a/src/sage/schemes/toric/variety.py +++ b/src/sage/schemes/toric/variety.py @@ -2810,7 +2810,7 @@ def Demazure_roots(self): :arxiv:`1110.4275`, :doi:`10.1007/s13366-011-0084-0`. - EXAMPLE:: + EXAMPLES:: sage: P2 = toric_varieties.P2() sage: P2.Demazure_roots() diff --git a/src/sage/stats/distributions/discrete_gaussian_integer.pyx b/src/sage/stats/distributions/discrete_gaussian_integer.pyx index c35729dd2f2..8091abb8383 100644 --- a/src/sage/stats/distributions/discrete_gaussian_integer.pyx +++ b/src/sage/stats/distributions/discrete_gaussian_integer.pyx @@ -363,7 +363,7 @@ cdef class DiscreteGaussianDistributionIntegerSampler(SageObject): r""" Flush the internal cache of random bits. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_integer import DiscreteGaussianDistributionIntegerSampler diff --git a/src/sage/stats/distributions/discrete_gaussian_lattice.py b/src/sage/stats/distributions/discrete_gaussian_lattice.py index 9f4b8c16044..0031f4fb0c8 100644 --- a/src/sage/stats/distributions/discrete_gaussian_lattice.py +++ b/src/sage/stats/distributions/discrete_gaussian_lattice.py @@ -78,7 +78,7 @@ def _iter_vectors(n, lower, upper, step=None): - ``upper`` - upper bound (exclusive), integer ``> lower``. - ``step`` - used for recursion, ignore. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import _iter_vectors sage: list(_iter_vectors(2, -1, 2)) @@ -110,7 +110,7 @@ class DiscreteGaussianDistributionLatticeSampler(SageObject): r""" GPV sampler for Discrete Gaussians over Lattices. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler sage: D = DiscreteGaussianDistributionLatticeSampler(ZZ^10, 3.0); D @@ -157,7 +157,7 @@ def compute_precision(precision, sigma): - ``sigma`` - if ``precision`` is ``None`` then the precision of ``sigma`` is used. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler sage: DiscreteGaussianDistributionLatticeSampler.compute_precision(100, RR(3)) @@ -196,7 +196,7 @@ def _normalisation_factor_zz(self, tau=3): - ``tau`` -- all vectors `v` with `|v|_∞ ≤ τ·σ` are enumerated (default: ``3``). - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler sage: n = 3; sigma = 1.0; m = 1000 @@ -237,7 +237,7 @@ def __init__(self, B, sigma=1, c=None, precision=None): - ``c`` -- center `c`, any vector in `\ZZ^n` is supported, but `c ∈ Λ(B)` is faster. - ``precision`` -- bit precision `≥ 53`. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler sage: n = 2; sigma = 3.0; m = 5000 @@ -320,7 +320,7 @@ def __call__(self): r""" Return a new sample. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler sage: D = DiscreteGaussianDistributionLatticeSampler(ZZ^3, 3.0, c=(1,0,0)) @@ -349,7 +349,7 @@ def sigma(self): Samples from this sampler will have expected norm `\sqrt{n}σ` where `n` is the dimension of the lattice. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler sage: D = DiscreteGaussianDistributionLatticeSampler(ZZ^3, 3.0, c=(1,0,0)) @@ -364,7 +364,7 @@ def c(self): Samples from this sampler will be centered at `c`. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler sage: D = DiscreteGaussianDistributionLatticeSampler(ZZ^3, 3.0, c=(1,0,0)); D @@ -381,7 +381,7 @@ def c(self): def __repr__(self): r""" - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler sage: D = DiscreteGaussianDistributionLatticeSampler(ZZ^3, 3.0, c=(1,0,0)); D @@ -399,7 +399,7 @@ def _call_in_lattice(self): r""" Return a new sample assuming `c ∈ Λ(B)`. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler sage: D = DiscreteGaussianDistributionLatticeSampler(ZZ^3, 3.0, c=(1,0,0)) @@ -418,7 +418,7 @@ def _call(self): """ Return a new sample. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler sage: D = DiscreteGaussianDistributionLatticeSampler(ZZ^3, 3.0, c=(1/2,0,0)) diff --git a/src/sage/stats/distributions/discrete_gaussian_polynomial.py b/src/sage/stats/distributions/discrete_gaussian_polynomial.py index b304d467c12..ad93c70bc4d 100644 --- a/src/sage/stats/distributions/discrete_gaussian_polynomial.py +++ b/src/sage/stats/distributions/discrete_gaussian_polynomial.py @@ -11,7 +11,7 @@ - Martin Albrecht, Robert Fitzpatrick, Daniel Cabracas, Florian Göpfert, Michael Schneider: initial version -EXAMPLE:: +EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler sage: sigma = 3.0; n=1000 @@ -63,7 +63,7 @@ class DiscreteGaussianDistributionPolynomialSampler(SageObject): r""" Discrete Gaussian sampler for polynomials. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler sage: DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)() @@ -90,7 +90,7 @@ def __init__(self, P, n, sigma): :class:`sage.stats.distributions.discrete_gaussian_integer.DiscreteGaussianDistributionIntegerSampler` is passed, then this sampler is used to sample coefficients. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler sage: DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)() @@ -110,7 +110,7 @@ def __call__(self): """ Return a new sample. - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler sage: sampler = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 12.0) @@ -122,7 +122,7 @@ def __call__(self): def _repr_(self): """ - EXAMPLE:: + EXAMPLES:: sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler sage: DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0) diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx index 530d1b5d70c..7dd8497f3a6 100644 --- a/src/sage/structure/coerce.pyx +++ b/src/sage/structure/coerce.pyx @@ -1899,7 +1899,7 @@ cdef class CoercionModel_cache_maps(CoercionModel): This function is only called when someone has incorrectly implemented a user-defined part of the coercion system (usually, a morphism). - EXAMPLE:: + EXAMPLES:: sage: cm = sage.structure.element.get_coercion_model() sage: cm._coercion_error('a', 'f', 'f(a)', 'b', 'g', 'g(b)') diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index 79754a4fe7b..9b63cee3e7b 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -2122,7 +2122,7 @@ cdef class ElementWithCachedMethod(Element): string of this class. Here, we demonstrate lazy attributes. - EXAMPLE:: + EXAMPLES:: sage: cython(''' ....: from sage.structure.element cimport ElementWithCachedMethod @@ -2366,7 +2366,7 @@ cdef class RingElement(ModuleElement): """ Return the (integral) power of self. - EXAMPLE:: + EXAMPLES:: sage: a = Integers(389)['x']['y'](37) sage: p = sage.structure.element.RingElement.__pow__ diff --git a/src/sage/structure/factory.pyx b/src/sage/structure/factory.pyx index d97dc95716c..fe3737dd272 100644 --- a/src/sage/structure/factory.pyx +++ b/src/sage/structure/factory.pyx @@ -524,7 +524,7 @@ cdef class UniqueFactory(SageObject): change without having to re-write :meth:`__reduce__` methods that use it. - EXAMPLE:: + EXAMPLES:: sage: V = FreeModule(ZZ, 5) sage: factory, data = FreeModule.reduce_data(V) diff --git a/src/sage/structure/formal_sum.py b/src/sage/structure/formal_sum.py index 79b7b50c964..13c688f34a0 100644 --- a/src/sage/structure/formal_sum.py +++ b/src/sage/structure/formal_sum.py @@ -397,7 +397,7 @@ def _coerce_map_from_(self, X): r""" Return whether there is a coercion from ``X`` - EXAMPLE:: + EXAMPLES:: sage: FormalSums(QQ).has_coerce_map_from( FormalSums(ZZ) ) # indirect test True diff --git a/src/sage/structure/list_clone.pyx b/src/sage/structure/list_clone.pyx index aea722f227c..d7d734c52a6 100644 --- a/src/sage/structure/list_clone.pyx +++ b/src/sage/structure/list_clone.pyx @@ -1354,7 +1354,7 @@ cdef class ClonableIntArray(ClonableElement): """ Iterate over the items of self. - EXAMPLE:: + EXAMPLES:: sage: from sage.structure.list_clone_demo import IncreasingIntArrays sage: I = IncreasingIntArrays()(range(5)) @@ -1369,7 +1369,7 @@ cdef class ClonableIntArray(ClonableElement): """ Convert self into a Python list. - EXAMPLE:: + EXAMPLES:: sage: from sage.structure.list_clone_demo import IncreasingIntArrays sage: I = IncreasingIntArrays()(range(5)) diff --git a/src/sage/structure/mutability.pyx b/src/sage/structure/mutability.pyx index a107ed91da4..1166df8caaa 100644 --- a/src/sage/structure/mutability.pyx +++ b/src/sage/structure/mutability.pyx @@ -52,7 +52,7 @@ cdef class Mutability: To make this object immutable use self.set_immutable(). - EXAMPLE:: + EXAMPLES:: sage: v = Sequence([1,2,3,4/5]) sage: v[0] = 5 diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx index faae7c51b29..3422bc66fb5 100644 --- a/src/sage/structure/parent.pyx +++ b/src/sage/structure/parent.pyx @@ -967,7 +967,7 @@ cdef class Parent(category_object.CategoryObject): be inherited. This is, e.g., used when creating twosided ideals of matrix algebras. See :trac:`7797`. - EXAMPLE:: + EXAMPLES:: sage: MS = MatrixSpace(QQ,2,2) diff --git a/src/sage/structure/sage_object.pyx b/src/sage/structure/sage_object.pyx index 859f62bd32b..8f268f250d2 100644 --- a/src/sage/structure/sage_object.pyx +++ b/src/sage/structure/sage_object.pyx @@ -941,7 +941,7 @@ def load(*filename, compress=True, verbose=True): of those files are loaded, or all of the objects are loaded and a list of the corresponding loaded objects is returned. - EXAMPLE:: + EXAMPLES:: sage: u = 'http://sage.math.washington.edu/home/was/db/test.sobj' sage: s = load(u) # optional - internet diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py index dc3786c3a59..1aba37bc077 100644 --- a/src/sage/structure/sequence.py +++ b/src/sage/structure/sequence.py @@ -779,7 +779,7 @@ def is_immutable(self): To make this object immutable use :meth:`set_immutable`. - EXAMPLE:: + EXAMPLES:: sage: v = Sequence([1,2,3,4/5]) sage: v[0] = 5 diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index f725816efff..930232e54af 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -8733,7 +8733,7 @@ cdef class Expression(CommutativeRingElement): :meth:`normalize`, :meth:`numerator`, :meth:`denominator`, :meth:`combine` - EXAMPLE:: + EXAMPLES:: sage: x, y, a = var("x y a") sage: ((x+y)^2/(x-y)^3*x^3).numerator_denominator() diff --git a/src/sage/symbolic/expression_conversions.py b/src/sage/symbolic/expression_conversions.py index 0f069d7c0a8..fa236e6543c 100644 --- a/src/sage/symbolic/expression_conversions.py +++ b/src/sage/symbolic/expression_conversions.py @@ -660,7 +660,7 @@ class SympyConverter(Converter): """ Converts any expression to SymPy. - EXAMPLE:: + EXAMPLES:: sage: import sympy sage: var('x,y') diff --git a/src/sage/tensor/modules/comp.py b/src/sage/tensor/modules/comp.py index 46c8287961a..b98c0975c89 100644 --- a/src/sage/tensor/modules/comp.py +++ b/src/sage/tensor/modules/comp.py @@ -519,7 +519,7 @@ def _repr_(self): r""" Return a string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: c = Components(ZZ, [1,2,3], 2) @@ -543,7 +543,7 @@ def _new_instance(self): This method must be redefined by derived classes of :class:`Components`. - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: c = Components(ZZ, [1,2,3], 2) @@ -595,7 +595,7 @@ def _del_zeros(self): NB: The use case of this method must be rare because zeros are not stored in :attr:`_comp`. - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: c = Components(ZZ, [1,2,3], 2) @@ -942,7 +942,7 @@ def _set_list(self, ind_slice, format_type, values): component `T_{ij...}`; in the 1-D case, ``ind_slice`` can be a slice of the full list, in the form ``[a:b]`` - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: c = Components(ZZ, [1,2,3], 2) @@ -979,7 +979,7 @@ def _set_value_list(self, ind, format_type, val): r""" Recursive function to set a list of values to ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: c = Components(ZZ, [1,2,3], 2) @@ -1429,7 +1429,7 @@ def __pos__(self): - an exact copy of ``self`` - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: c = Components(ZZ, [1,2,3], 1) @@ -1454,7 +1454,7 @@ def __neg__(self): - the opposite of the components represented by ``self`` - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: c = Components(ZZ, [1,2,3], 1) @@ -1485,7 +1485,7 @@ def __add__(self, other): - components resulting from the addition of ``self`` and ``other`` - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: a = Components(ZZ, [1,2,3], 1) @@ -1564,7 +1564,7 @@ def __radd__(self, other): r""" Reflected addition (addition on the right to `other``) - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: a = Components(ZZ, [1,2,3], 1) @@ -1598,7 +1598,7 @@ def __sub__(self, other): - components resulting from the subtraction of ``other`` from ``self`` - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: a = Components(ZZ, [1,2,3], 1) @@ -2707,7 +2707,7 @@ def _matrix_(self): r""" Convert a set of ring components with 2 indices into a matrix. - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import Components sage: V = VectorSpace(QQ, 3) @@ -4642,7 +4642,7 @@ def _repr_(self): r""" Return a string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import CompFullySym sage: CompFullySym(ZZ, (1,2,3), 4) @@ -4657,7 +4657,7 @@ def _new_instance(self): Creates a :class:`CompFullySym` instance w.r.t. the same frame, and with the same number of indices. - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import CompFullySym sage: c = CompFullySym(ZZ, (1,2,3), 4) @@ -5107,7 +5107,7 @@ def _new_instance(self): Creates a :class:`CompFullyAntiSym` instance w.r.t. the same frame, and with the same number of indices. - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import CompFullyAntiSym sage: c = CompFullyAntiSym(ZZ, (1,2,3), 4) @@ -5316,7 +5316,7 @@ def _repr_(self): r""" Return a string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import KroneckerDelta sage: KroneckerDelta(ZZ, (1,2,3)) @@ -5330,7 +5330,7 @@ def __setitem__(self, args, value): r""" Should not be used (the components of a Kronecker delta are constant) - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.comp import KroneckerDelta sage: d = KroneckerDelta(ZZ, (1,2,3)) diff --git a/src/sage/tensor/modules/ext_pow_free_module.py b/src/sage/tensor/modules/ext_pow_free_module.py index 4bce4698724..fd12eeafbf9 100644 --- a/src/sage/tensor/modules/ext_pow_free_module.py +++ b/src/sage/tensor/modules/ext_pow_free_module.py @@ -457,7 +457,7 @@ def base_module(self): - instance of :class:`FiniteRankFreeModule` representing the free module on which the exterior power is defined. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 5, name='M') sage: A = M.dual_exterior_power(2) diff --git a/src/sage/tensor/modules/finite_rank_free_module.py b/src/sage/tensor/modules/finite_rank_free_module.py index 61f0020d4e5..d45991dab1f 100644 --- a/src/sage/tensor/modules/finite_rank_free_module.py +++ b/src/sage/tensor/modules/finite_rank_free_module.py @@ -831,7 +831,7 @@ def _an_element_(self): r""" Construct some (unamed) element of ``self``. - EXAMPLE:: + EXAMPLES:: sage: FiniteRankFreeModule._clear_cache_() # for doctests only sage: M = FiniteRankFreeModule(ZZ, 3, name='M') @@ -859,7 +859,7 @@ def _repr_(self): r""" Return a string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: FiniteRankFreeModule(ZZ, 3, name='M') Rank-3 free module M over the Integer Ring diff --git a/src/sage/tensor/modules/format_utilities.py b/src/sage/tensor/modules/format_utilities.py index a7430ed59db..f09c79c2626 100644 --- a/src/sage/tensor/modules/format_utilities.py +++ b/src/sage/tensor/modules/format_utilities.py @@ -329,7 +329,7 @@ def _latex_(self): r""" Return a LaTeX representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: from sage.tensor.modules.format_utilities import FormattedExpansion sage: f = FormattedExpansion('v', r'\tilde v') diff --git a/src/sage/tensor/modules/free_module_alt_form.py b/src/sage/tensor/modules/free_module_alt_form.py index a8630788b0e..ab27062d1fc 100644 --- a/src/sage/tensor/modules/free_module_alt_form.py +++ b/src/sage/tensor/modules/free_module_alt_form.py @@ -371,7 +371,7 @@ def degree(self): r""" Return the degree of ``self``. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: a = M.alternating_form(2, name='a') diff --git a/src/sage/tensor/modules/free_module_automorphism.py b/src/sage/tensor/modules/free_module_automorphism.py index 903733eb206..cf8ed8bbce2 100644 --- a/src/sage/tensor/modules/free_module_automorphism.py +++ b/src/sage/tensor/modules/free_module_automorphism.py @@ -356,7 +356,7 @@ def _del_derived(self): r""" Delete the derived quantities. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(QQ, 3, name='M') sage: e = M.basis('e') diff --git a/src/sage/tensor/modules/free_module_basis.py b/src/sage/tensor/modules/free_module_basis.py index dae6e8e97fe..8161b88060f 100644 --- a/src/sage/tensor/modules/free_module_basis.py +++ b/src/sage/tensor/modules/free_module_basis.py @@ -350,7 +350,7 @@ def module(self): :class:`~sage.tensor.modules.finite_rank_free_module.FiniteRankFreeModule` representing the free module of which ``self`` is a basis - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: e = M.basis('e') diff --git a/src/sage/tensor/modules/free_module_homset.py b/src/sage/tensor/modules/free_module_homset.py index f76d6e5ab56..74a1f2002dc 100644 --- a/src/sage/tensor/modules/free_module_homset.py +++ b/src/sage/tensor/modules/free_module_homset.py @@ -406,7 +406,7 @@ def _an_element_(self): r""" Construct some (unamed) element. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: N = FiniteRankFreeModule(ZZ, 2, name='N') diff --git a/src/sage/tensor/modules/free_module_linear_group.py b/src/sage/tensor/modules/free_module_linear_group.py index f71e0c421f5..3a0254ff69b 100644 --- a/src/sage/tensor/modules/free_module_linear_group.py +++ b/src/sage/tensor/modules/free_module_linear_group.py @@ -521,7 +521,7 @@ def _repr_(self): r""" Return a string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 2, name='M') sage: GL = M.general_linear_group() @@ -535,7 +535,7 @@ def _latex_(self): r""" Return a string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 2, name='M') sage: GL = M.general_linear_group() @@ -556,7 +556,7 @@ def base_module(self): - instance of :class:`FiniteRankFreeModule` representing the free module of which ``self`` is the general linear group - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 2, name='M') sage: GL = M.general_linear_group() diff --git a/src/sage/tensor/modules/free_module_morphism.py b/src/sage/tensor/modules/free_module_morphism.py index 0ba6fb25cd8..eb2c031c323 100644 --- a/src/sage/tensor/modules/free_module_morphism.py +++ b/src/sage/tensor/modules/free_module_morphism.py @@ -734,7 +734,7 @@ def __pos__(self): - an exact copy of ``self`` - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: N = FiniteRankFreeModule(ZZ, 2, name='N') @@ -771,7 +771,7 @@ def __neg__(self): - the homomorphism `-f`, where `f` is ``self`` - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: N = FiniteRankFreeModule(ZZ, 2, name='N') diff --git a/src/sage/tensor/modules/free_module_tensor.py b/src/sage/tensor/modules/free_module_tensor.py index c760bada0f5..c7fe2f48520 100644 --- a/src/sage/tensor/modules/free_module_tensor.py +++ b/src/sage/tensor/modules/free_module_tensor.py @@ -369,7 +369,7 @@ def _repr_(self): r""" Return a string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: t = M.tensor((2,1), name='t') @@ -419,7 +419,7 @@ def _init_derived(self): r""" Initialize the derived quantities - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: t = M.tensor((2,1), name='t') @@ -432,7 +432,7 @@ def _del_derived(self): r""" Delete the derived quantities - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: t = M.tensor((2,1), name='t') @@ -852,7 +852,7 @@ def view(self, basis=None, format_spec=None): Use method :meth:`display` instead. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 2, 'M') sage: e = M.basis('e') @@ -907,7 +907,7 @@ def _new_instance(self): Create a tensor of the same tensor type and with the same symmetries as ``self``. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: t = M.tensor((2,1), name='t') @@ -3215,7 +3215,7 @@ def _repr_(self): r""" Return a string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: e = M.basis('e') @@ -3244,7 +3244,7 @@ def _new_comp(self, basis): - an instance of :class:`~sage.tensor.modules.comp.Components` - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: e = M.basis('e') @@ -3265,7 +3265,7 @@ def _new_instance(self): r""" Create an instance of the same class as ``self``. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3, name='M') sage: e = M.basis('e') diff --git a/src/sage/tensor/modules/tensor_free_module.py b/src/sage/tensor/modules/tensor_free_module.py index cfc713f3759..9cbcb73bf11 100644 --- a/src/sage/tensor/modules/tensor_free_module.py +++ b/src/sage/tensor/modules/tensor_free_module.py @@ -588,7 +588,7 @@ def _repr_(self): r""" Return a string representation of ``self``. - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(QQ, 2, name='M') sage: M.tensor_module(1,1) @@ -635,7 +635,7 @@ def tensor_type(self): - pair `(k,l)` such that ``self`` is the module tensor product `T^{(k,l)}(M)` - EXAMPLE:: + EXAMPLES:: sage: M = FiniteRankFreeModule(ZZ, 3) sage: T = M.tensor_module(1,2) diff --git a/src/sage/tests/benchmark.py b/src/sage/tests/benchmark.py index 708e2454225..5ca2d592df7 100644 --- a/src/sage/tests/benchmark.py +++ b/src/sage/tests/benchmark.py @@ -1959,7 +1959,7 @@ def mpoly_all(include_maple=False): * mathematica is sometimes amazing. * macaulay2 is also quite bad (though not as bad as maple). - EXAMPLE:: + EXAMPLES:: sage: from sage.tests.benchmark import mpoly_all sage: mpoly_all() # not tested From 697adab7976b7ad3754cfbda2bf50881d59f793a Mon Sep 17 00:00:00 2001 From: paulmasson Date: Sun, 19 Feb 2017 16:41:53 -0800 Subject: [PATCH 238/370] Adjust default lighting --- src/ext/threejs/threejs_template.html | 4 ++-- src/sage/plot/plot3d/base.pyx | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ext/threejs/threejs_template.html b/src/ext/threejs/threejs_template.html index 2912cb0be52..2e001a1256e 100644 --- a/src/ext/threejs/threejs_template.html +++ b/src/ext/threejs/threejs_template.html @@ -125,7 +125,7 @@ var lights = SAGE_LIGHTS; for ( var i=0 ; i < lights.length ; i++ ) { - var light = new THREE.DirectionalLight( 0xdddddd, 1 ); + var light = new THREE.DirectionalLight( 0x666666, 1 ); light.position.set( a[0]*lights[i].x, a[1]*lights[i].y, a[2]*lights[i].z ); if ( lights[i].parent === 'camera' ) { light.target.position.set( a[0]*xMid, a[1]*yMid, a[2]*zMid ); @@ -135,7 +135,7 @@ } scene.add( camera ); - scene.add( new THREE.AmbientLight( 0x404040, 1 ) ); + scene.add( new THREE.AmbientLight( 0x999999, 1 ) ); var controls = new THREE.OrbitControls( camera, renderer.domElement ); controls.target.set( a[0]*xMid, a[1]*yMid, a[2]*zMid ); diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx index 6440d93eb94..457132a5b89 100644 --- a/src/sage/plot/plot3d/base.pyx +++ b/src/sage/plot/plot3d/base.pyx @@ -375,8 +375,7 @@ cdef class Graphics3d(SageObject): bounds = "[{{x:{}, y:{}, z:{}}}, {{x:{}, y:{}, z:{}}}]".format( b[0][0], b[0][1], b[0][2], b[1][0], b[1][1], b[1][2]) - lights = '[{"x":10, "y":0, "z":0, "parent":"camera"}, \ - {"x":-10, "y":0, "z":0, "parent":"camera"}]' + lights = '[{"x":-5, "y":3, "z":0, "parent":"camera"}]' import json points, lines, texts = [], [], [] From 49083c50c3b3a9a26f7d9978f84d4e9d8c166863 Mon Sep 17 00:00:00 2001 From: paulmasson Date: Sun, 19 Feb 2017 16:52:37 -0800 Subject: [PATCH 239/370] JSONize ouput --- src/sage/plot/plot3d/base.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx index 457132a5b89..760586c6f31 100644 --- a/src/sage/plot/plot3d/base.pyx +++ b/src/sage/plot/plot3d/base.pyx @@ -372,7 +372,7 @@ cdef class Graphics3d(SageObject): options['axes_labels'] = False b = self.bounding_box() - bounds = "[{{x:{}, y:{}, z:{}}}, {{x:{}, y:{}, z:{}}}]".format( + bounds = '[{{"x":{}, "y":{}, "z":{}}}, {{"x":{}, "y":{}, "z":{}}}]'.format( b[0][0], b[0][1], b[0][2], b[1][0], b[1][1], b[1][2]) lights = '[{"x":-5, "y":3, "z":0, "parent":"camera"}]' @@ -385,18 +385,18 @@ cdef class Graphics3d(SageObject): if hasattr(p, 'loc'): color = p._extra_kwds.get('color', 'blue') opacity = p._extra_kwds.get('opacity', 1) - points.append("{{point:{}, size:{}, color:'{}', opacity:{}}}".format( + points.append('{{"point":{}, "size":{}, "color":"{}", "opacity":{}}}'.format( json.dumps(p.loc), p.size, color, opacity)) if hasattr(p, 'points'): color = p._extra_kwds.get('color', 'blue') opacity = p._extra_kwds.get('opacity', 1) thickness = p._extra_kwds.get('thickness', 1) - lines.append("{{points:{}, color:'{}', opacity:{}, linewidth:{}}}".format( + lines.append('{{"points":{}, "color":"{}", "opacity":{}, "linewidth":{}}}'.format( json.dumps(p.points), color, opacity, thickness)) if hasattr(p, '_trans'): if hasattr(p.all[0], 'string'): m = p.get_transformation().get_matrix() - texts.append("{{text:'{}', x:{}, y:{}, z:{}}}".format( + texts.append('{{"text":"{}", "x":{}, "y":{}, "z":{}}}'.format( p.all[0].string, m[0,3], m[1,3], m[2,3])) points = '[' + ','.join(points) + ']' From 2f6c4a2b8ad8f95bc88834a6ad7ae0f16d8679f5 Mon Sep 17 00:00:00 2001 From: paulmasson Date: Wed, 22 Feb 2017 18:39:44 -0800 Subject: [PATCH 240/370] Expose light colors in Python --- src/ext/threejs/threejs_template.html | 5 +++-- src/sage/plot/plot3d/base.pyx | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ext/threejs/threejs_template.html b/src/ext/threejs/threejs_template.html index 2e001a1256e..b3497ce982d 100644 --- a/src/ext/threejs/threejs_template.html +++ b/src/ext/threejs/threejs_template.html @@ -125,7 +125,7 @@ var lights = SAGE_LIGHTS; for ( var i=0 ; i < lights.length ; i++ ) { - var light = new THREE.DirectionalLight( 0x666666, 1 ); + var light = new THREE.DirectionalLight( lights[i].color, 1 ); light.position.set( a[0]*lights[i].x, a[1]*lights[i].y, a[2]*lights[i].z ); if ( lights[i].parent === 'camera' ) { light.target.position.set( a[0]*xMid, a[1]*yMid, a[2]*zMid ); @@ -135,7 +135,8 @@ } scene.add( camera ); - scene.add( new THREE.AmbientLight( 0x999999, 1 ) ); + var ambient = SAGE_AMBIENT; + scene.add( new THREE.AmbientLight( ambient.color, 1 ) ); var controls = new THREE.OrbitControls( camera, renderer.domElement ); controls.target.set( a[0]*xMid, a[1]*yMid, a[2]*zMid ); diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx index 760586c6f31..7be488dacc8 100644 --- a/src/sage/plot/plot3d/base.pyx +++ b/src/sage/plot/plot3d/base.pyx @@ -375,7 +375,10 @@ cdef class Graphics3d(SageObject): bounds = '[{{"x":{}, "y":{}, "z":{}}}, {{"x":{}, "y":{}, "z":{}}}]'.format( b[0][0], b[0][1], b[0][2], b[1][0], b[1][1], b[1][2]) - lights = '[{"x":-5, "y":3, "z":0, "parent":"camera"}]' + from sage.plot.colors import Color + lights = '[{{"x":-5, "y":3, "z":0, "color":"{}", "parent":"camera"}}]'.format( + Color(.5,.5,.5).html_color()) + ambient = '{{"color":"{}"}}'.format(Color(.5,.5,.5).html_color()) import json points, lines, texts = [], [], [] @@ -397,7 +400,7 @@ cdef class Graphics3d(SageObject): if hasattr(p.all[0], 'string'): m = p.get_transformation().get_matrix() texts.append('{{"text":"{}", "x":{}, "y":{}, "z":{}}}'.format( - p.all[0].string, m[0,3], m[1,3], m[2,3])) + p.all[0].string, m[0,3], m[1,3], m[2,3])) points = '[' + ','.join(points) + ']' lines = '[' + ','.join(lines) + ']' @@ -416,6 +419,7 @@ cdef class Graphics3d(SageObject): html = html.replace('SAGE_OPTIONS', json.dumps(options)) html = html.replace('SAGE_BOUNDS', bounds) html = html.replace('SAGE_LIGHTS', lights) + html = html.replace('SAGE_AMBIENT', ambient) html = html.replace('SAGE_TEXTS', str(texts)) html = html.replace('SAGE_POINTS', str(points)) html = html.replace('SAGE_LINES', str(lines)) From 0989af475e7c08c35dc68c7f52b692c704191b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 23 Feb 2017 10:15:11 +0100 Subject: [PATCH 241/370] First version of is_inscribable method --- src/sage/geometry/polyhedron/base.py | 85 ++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 2cb1a18e80e..a9a76db1891 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2140,6 +2140,91 @@ def radius(self): """ return sqrt(self.radius_square()) + def is_inscribable(self, certify=False): + """ + A full-dimensional compact polytope is inscribable if there exists + a point in space which is equidistant to all its vertices. + + This function tests whether this point exists and returns it if + specified. + + The function first computes the circumsphere of a full-dimensional + simplex with vertices of `self` and then checks if all other vertices + are equidistant to the circumcenter of that simplex. + + INPUT: + + - ``certify`` : Boolean, specify whether to return the circumcenter + if found + + OUTPUT: + + A tuple containing a boolean and potentially the circumcenter of the + polytope. + + EXAMPLES:: + + sage: q = Polyhedron(vertices = [[1,1,1,1],[-1,-1,1,1],[1,-1,-1,1], + ....: [-1,1,-1,1],[1,1,1,-1],[-1,-1,1,-1], + ....: [1,-1,-1,-1],[-1,1,-1,-1],[0,0,10/13,-24/13], + ....: [0,0,-10/13,-24/13]]) + sage: q.is_inscribable(True) + (True, (0, 0, 0, 0)) + + sage: cube = polytopes.cube() + sage: cube.is_inscribable() + (True, None) + + sage: translated_cube = Polyhedron(vertices=[v.vector() + vector([1,2,3]) + ....: for v in cube.vertices()]) + sage: translated_cube.is_inscribable(True) + (True, (1, 2, 3)) + + sage: truncated_cube = cube.face_truncation(cube.faces(0)[0]) + sage: truncated_cube.is_inscribable() + (False, None) + + """ + + if not self.is_compact() or not self.is_full_dimensional(): + raise NotImplementedError("This function is implemented for full-dimensional polytopes only.") + + dimension = self.dimension() + vertices = self.vertices() + vertex = vertices[0] + vertex_neighbors = vertex.neighbors() + simplex_vertices = [vertex] + [vertex_neighbors.next() for i in range(dimension)] + other_vertices = [v for v in vertices if v not in simplex_vertices] + + row_data = [] + for vertex in simplex_vertices: + vertex_vector = vertex.vector() + row_data += [[sum(i**2 for i in vertex_vector)] + \ + [i for i in vertex_vector] + [1]] + matrix_data = matrix(row_data) + + # The determinant "a" should not be zero because the polytope is full + # dimensional and also the simplex. + a = matrix_data.matrix_from_columns(range(1,dimension+2)).determinant() + + minors = [(-1)**(i)*matrix_data.matrix_from_columns([j for j in range(dimension+2) if j != i]).determinant() + for i in range(1,dimension+1)] + c = (-1)**(dimension+1)*matrix_data.matrix_from_columns(range(dimension+1)).determinant() + + circumcenter = vector([minors[i]/(2*a) for i in range(dimension)]) + circumradius = sqrt(sum(m**2 for m in minors) - 4 * a * c) / (2*abs(a)) + + # Checking if the circumcenter has the correct sign + if (vertex.vector() - circumcenter).norm() != circumradius: + circumcenter = - circumcenter + + is_circumscrib = all((v.vector() - circumcenter).norm() == circumradius for v in other_vertices) + + if certify and is_circumscrib: + return (is_circumscrib,circumcenter) + else: + return (is_circumscrib,None) + def is_compact(self): """ Test for boundedness of the polytope. From ecaf3ee45f1a9923850012c469e0eea832350685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 23 Feb 2017 10:20:58 +0100 Subject: [PATCH 242/370] pep8 conventions --- src/sage/geometry/polyhedron/base.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index a9a76db1891..e065c51a0d0 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2118,8 +2118,8 @@ def radius_square(self): sage: p.radius_square() 5 """ - vertices = [ v.vector() - self.center() for v in self.vertex_generator() ] - return max( v.dot_product(v) for v in vertices ) + vertices = [v.vector() - self.center() for v in self.vertex_generator()] + return max(v.dot_product(v) for v in vertices) def radius(self): """ @@ -2165,8 +2165,8 @@ def is_inscribable(self, certify=False): EXAMPLES:: sage: q = Polyhedron(vertices = [[1,1,1,1],[-1,-1,1,1],[1,-1,-1,1], - ....: [-1,1,-1,1],[1,1,1,-1],[-1,-1,1,-1], - ....: [1,-1,-1,-1],[-1,1,-1,-1],[0,0,10/13,-24/13], + ....: [-1,1,-1,1],[1,1,1,-1],[-1,-1,1,-1], + ....: [1,-1,-1,-1],[-1,1,-1,-1],[0,0,10/13,-24/13], ....: [0,0,-10/13,-24/13]]) sage: q.is_inscribable(True) (True, (0, 0, 0, 0)) @@ -2174,12 +2174,12 @@ def is_inscribable(self, certify=False): sage: cube = polytopes.cube() sage: cube.is_inscribable() (True, None) - - sage: translated_cube = Polyhedron(vertices=[v.vector() + vector([1,2,3]) + + sage: translated_cube = Polyhedron(vertices=[v.vector() + vector([1,2,3]) ....: for v in cube.vertices()]) sage: translated_cube.is_inscribable(True) (True, (1, 2, 3)) - + sage: truncated_cube = cube.face_truncation(cube.faces(0)[0]) sage: truncated_cube.is_inscribable() (False, None) @@ -2188,7 +2188,7 @@ def is_inscribable(self, certify=False): if not self.is_compact() or not self.is_full_dimensional(): raise NotImplementedError("This function is implemented for full-dimensional polytopes only.") - + dimension = self.dimension() vertices = self.vertices() vertex = vertices[0] @@ -2199,21 +2199,21 @@ def is_inscribable(self, certify=False): row_data = [] for vertex in simplex_vertices: vertex_vector = vertex.vector() - row_data += [[sum(i**2 for i in vertex_vector)] + \ + row_data += [[sum(i**2 for i in vertex_vector)] + [i for i in vertex_vector] + [1]] matrix_data = matrix(row_data) # The determinant "a" should not be zero because the polytope is full # dimensional and also the simplex. - a = matrix_data.matrix_from_columns(range(1,dimension+2)).determinant() + a = matrix_data.matrix_from_columns(range(1, dimension+2)).determinant() minors = [(-1)**(i)*matrix_data.matrix_from_columns([j for j in range(dimension+2) if j != i]).determinant() - for i in range(1,dimension+1)] + for i in range(1, dimension+1)] c = (-1)**(dimension+1)*matrix_data.matrix_from_columns(range(dimension+1)).determinant() circumcenter = vector([minors[i]/(2*a) for i in range(dimension)]) circumradius = sqrt(sum(m**2 for m in minors) - 4 * a * c) / (2*abs(a)) - + # Checking if the circumcenter has the correct sign if (vertex.vector() - circumcenter).norm() != circumradius: circumcenter = - circumcenter @@ -2221,9 +2221,9 @@ def is_inscribable(self, certify=False): is_circumscrib = all((v.vector() - circumcenter).norm() == circumradius for v in other_vertices) if certify and is_circumscrib: - return (is_circumscrib,circumcenter) + return (is_circumscrib, circumcenter) else: - return (is_circumscrib,None) + return (is_circumscrib, None) def is_compact(self): """ From 2a831bdc2f81ce3661616311ece22a520115c8e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 23 Feb 2017 10:25:36 +0100 Subject: [PATCH 243/370] Added a comment on the method used. --- src/sage/geometry/polyhedron/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index e065c51a0d0..738f1ccf1f5 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2152,6 +2152,9 @@ def is_inscribable(self, certify=False): simplex with vertices of `self` and then checks if all other vertices are equidistant to the circumcenter of that simplex. + The circumsphere of the simplex is found by lifting the points on a + paraboloid to find the hyperplane on which the circumsphere is lifted. + INPUT: - ``certify`` : Boolean, specify whether to return the circumcenter From ef42b4a18fb9f9ceca45994da9287c3df083cc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 23 Feb 2017 10:29:41 +0100 Subject: [PATCH 244/370] corrected indentation --- src/sage/geometry/polyhedron/base.py | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 738f1ccf1f5..e95f979dead 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2157,7 +2157,7 @@ def is_inscribable(self, certify=False): INPUT: - - ``certify`` : Boolean, specify whether to return the circumcenter + - ``certify`` : Boolean, specify whether to return the circumcenter if found OUTPUT: @@ -2167,25 +2167,25 @@ def is_inscribable(self, certify=False): EXAMPLES:: - sage: q = Polyhedron(vertices = [[1,1,1,1],[-1,-1,1,1],[1,-1,-1,1], - ....: [-1,1,-1,1],[1,1,1,-1],[-1,-1,1,-1], - ....: [1,-1,-1,-1],[-1,1,-1,-1],[0,0,10/13,-24/13], - ....: [0,0,-10/13,-24/13]]) - sage: q.is_inscribable(True) - (True, (0, 0, 0, 0)) - - sage: cube = polytopes.cube() - sage: cube.is_inscribable() - (True, None) - - sage: translated_cube = Polyhedron(vertices=[v.vector() + vector([1,2,3]) - ....: for v in cube.vertices()]) - sage: translated_cube.is_inscribable(True) - (True, (1, 2, 3)) - - sage: truncated_cube = cube.face_truncation(cube.faces(0)[0]) - sage: truncated_cube.is_inscribable() - (False, None) + sage: q = Polyhedron(vertices = [[1,1,1,1],[-1,-1,1,1],[1,-1,-1,1], + ....: [-1,1,-1,1],[1,1,1,-1],[-1,-1,1,-1], + ....: [1,-1,-1,-1],[-1,1,-1,-1],[0,0,10/13,-24/13], + ....: [0,0,-10/13,-24/13]]) + sage: q.is_inscribable(True) + (True, (0, 0, 0, 0)) + + sage: cube = polytopes.cube() + sage: cube.is_inscribable() + (True, None) + + sage: translated_cube = Polyhedron(vertices=[v.vector() + vector([1,2,3]) + ....: for v in cube.vertices()]) + sage: translated_cube.is_inscribable(True) + (True, (1, 2, 3)) + + sage: truncated_cube = cube.face_truncation(cube.faces(0)[0]) + sage: truncated_cube.is_inscribable() + (False, None) """ From d3dce249c5399b5af1e2e724337dd6b69f925d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 23 Feb 2017 10:48:05 +0100 Subject: [PATCH 245/370] Added examples with NotImplemented --- src/sage/geometry/polyhedron/base.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index e95f979dead..06d88da7af7 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2187,6 +2187,21 @@ def is_inscribable(self, certify=False): sage: truncated_cube.is_inscribable() (False, None) + The method is not implemented for non-full-dimensional polytope or + unbounded polyhedra:: + + sage: square = Polyhedron(vertices=[[1,0,0],[0,1,0],[1,1,0],[0,0,0]]) + sage: square.is_inscribable() + Traceback (most recent call last) + ... + NotImplementedError: This function is implemented for full-dimensional polytopes only. + + sage: p = Polyhedron(vertices=[(0,0)],rays=[(1,0),(0,1)]) + sage: p.is_inscribable() + Traceback (most recent call last): + ... + NotImplementedError: This function is implemented for full-dimensional polytopes only. + """ if not self.is_compact() or not self.is_full_dimensional(): From 34abce2d0ea0e270a517d5399308894ace98abac Mon Sep 17 00:00:00 2001 From: David Coudert Date: Thu, 23 Feb 2017 16:38:38 +0100 Subject: [PATCH 246/370] trac #22424: fix reported bug --- src/sage/graphs/graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py index 8a16bf69498..1985536c6cf 100644 --- a/src/sage/graphs/graph.py +++ b/src/sage/graphs/graph.py @@ -5183,7 +5183,7 @@ def to_directed(self, implementation='c_graph', data_structure=None, data_structure = "static_sparse" from sage.graphs.all import DiGraph D = DiGraph(name = self.name(), - pos = self._pos, + pos = copy(self._pos), multiedges = self.allows_multiple_edges(), loops = self.allows_loops(), implementation = implementation, From 840b584c9f04ab4ccc6f8efae5fdcc3213fe2fd3 Mon Sep 17 00:00:00 2001 From: David Coudert Date: Fri, 24 Feb 2017 01:33:14 +0100 Subject: [PATCH 247/370] trac #22424: doctest --- src/sage/graphs/graph.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py index 1985536c6cf..19107f4cc44 100644 --- a/src/sage/graphs/graph.py +++ b/src/sage/graphs/graph.py @@ -5165,6 +5165,16 @@ def to_directed(self, implementation='c_graph', data_structure=None, sage: Graph([[1,2]], immutable=True).to_directed() Digraph on 2 vertices + + :trac:`22424`:: + + sage: G1=graphs.Grid2RandomGNP(5,0.5) + sage: gp1 = G1.graphplot(save_pos=True) + sage: G2=G1.to_directed() + sage: G2.delete_vertex(0) + sage: G2.add_vertex(5) + sage: gp2 = G2.graphplot() + sage: gp1 = G1.graphplot() """ if sparse is not None: if data_structure is not None: From ee60184d26fe3a999197cabc537a52637fa33f1d Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Fri, 24 Feb 2017 11:32:03 +0100 Subject: [PATCH 248/370] Upgrade Jupyter notebook --- build/pkgs/jupyter_core/checksums.ini | 6 +++--- build/pkgs/jupyter_core/package-version.txt | 2 +- build/pkgs/notebook/checksums.ini | 6 +++--- build/pkgs/notebook/package-version.txt | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/pkgs/jupyter_core/checksums.ini b/build/pkgs/jupyter_core/checksums.ini index 0eecfe110a6..7c08a350aef 100644 --- a/build/pkgs/jupyter_core/checksums.ini +++ b/build/pkgs/jupyter_core/checksums.ini @@ -1,4 +1,4 @@ tarball=jupyter_core-VERSION.tar.gz -sha1=983a8eca910b3ac4290f1944fe6589770c254b1d -md5=f707f8693e537177341c4a89081fdac3 -cksum=3375597820 +sha1=7ae489bdea8f2d117af5a9b9e1a662d51c99e696 +md5=18819511a809afdeed9a995a9c27bcfb +cksum=1313016246 diff --git a/build/pkgs/jupyter_core/package-version.txt b/build/pkgs/jupyter_core/package-version.txt index fae6e3d04b2..80895903a15 100644 --- a/build/pkgs/jupyter_core/package-version.txt +++ b/build/pkgs/jupyter_core/package-version.txt @@ -1 +1 @@ -4.2.1 +4.3.0 diff --git a/build/pkgs/notebook/checksums.ini b/build/pkgs/notebook/checksums.ini index 186f8347151..0e371266550 100644 --- a/build/pkgs/notebook/checksums.ini +++ b/build/pkgs/notebook/checksums.ini @@ -1,4 +1,4 @@ tarball=notebook-VERSION.tar.gz -sha1=ab665a9b0f42a6fc430dfe61db83a8d54bce3f97 -md5=70cc97ad19c0f9246ad295a653475e2a -cksum=660926754 +sha1=39183995290b59a3fc30af77cbe2b3be19de6390 +md5=3f9074031258de895f12102379394dcd +cksum=2923119232 diff --git a/build/pkgs/notebook/package-version.txt b/build/pkgs/notebook/package-version.txt index f77856a6f1a..cca25a93cd0 100644 --- a/build/pkgs/notebook/package-version.txt +++ b/build/pkgs/notebook/package-version.txt @@ -1 +1 @@ -4.3.1 +4.4.1 From 7553a3c8dfa7bcec07241a07e6a4e7dcf5bb4f26 Mon Sep 17 00:00:00 2001 From: Frederic HAN Date: Sat, 25 Feb 2017 08:39:43 +0100 Subject: [PATCH 249/370] update patches to fix fuzz --- build/pkgs/giac/patches/macos-ifactor.patch | 2 +- build/pkgs/giac/patches/nofltk-check.patch | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/pkgs/giac/patches/macos-ifactor.patch b/build/pkgs/giac/patches/macos-ifactor.patch index 258aa3dbb64..b2a1050619e 100644 --- a/build/pkgs/giac/patches/macos-ifactor.patch +++ b/build/pkgs/giac/patches/macos-ifactor.patch @@ -1,6 +1,6 @@ --- a/src/ifactor.cc 2014-10-11 16:29:01.000000000 +0200 +++ b/src/ifactor.cc 2014-10-11 16:29:28.000000000 +0200 -@@ -3708,7 +3708,7 @@ +@@ -3737,7 +3737,7 @@ return giac_ifactors(n0._VECTptr->front(),contextptr); #ifdef HAVE_LIBPARI #ifdef __APPLE__ diff --git a/build/pkgs/giac/patches/nofltk-check.patch b/build/pkgs/giac/patches/nofltk-check.patch index 67eb82e8ed7..a98993becee 100644 --- a/build/pkgs/giac/patches/nofltk-check.patch +++ b/build/pkgs/giac/patches/nofltk-check.patch @@ -192,13 +192,13 @@ diff -ruN check/TP00-sol.cas.out1 check.new/TP00-sol.cas.out1 +++ b/check/TP00-sol.cas.out1 2015-03-02 15:44:22.000000000 +0100 @@ -66,7 +66,7 @@ 5, - (sqrt(5)-1)/4+(I)*sqrt(2*sqrt(5)+10)/4, + (sqrt(5)-1)/4+I*sqrt(2*sqrt(5)+10)/4, "Done", - (i,j,k)->if k=1 then segment(a^i,a^j); else seq(arc(a^i,a^j,l/k),l=(1 .. k)); + (i,j,k)->if k=1 then segment(a^i,a^j,'color'=56); else seq(arc(a^i,a^j,l/k,'color'=56),l=(1 .. k)); fi , "Done", - pnt(pnt[(sqrt(5)-1)/4+(I)*sqrt(2*sqrt(5)+10)/4,1048580]),pnt(pnt[((sqrt(5)-1)/4+(I)*sqrt(2*sqrt(5)+10)/4)^2,1048580]),pnt(pnt[((sqrt(5)-1)/4+(I)*sqrt(2*sqrt(5)+10)/4)^3,1048580]),pnt(pnt[((sqrt(5)-1)/4+(I)*sqrt(2*sqrt(5)+10)/4)^4,1048580]),pnt(pnt[((sqrt(5)-1)/4+(I)*sqrt(2*sqrt(5)+10)/4)^5,1048580]), + pnt(pnt[(sqrt(5)-1)/4+I*sqrt(2*sqrt(5)+10)/4,1048580]),pnt(pnt[((sqrt(5)-1)/4+I*sqrt(2*sqrt(5)+10)/4)^2,1048580]),pnt(pnt[((sqrt(5)-1)/4+I*sqrt(2*sqrt(5)+10)/4)^3,1048580]),pnt(pnt[((sqrt(5)-1)/4+I*sqrt(2*sqrt(5)+10)/4)^4,1048580]),pnt(pnt[((sqrt(5)-1)/4+I*sqrt(2*sqrt(5)+10)/4)^5,1048580]), diff -ruN check/TP02-sol.cas check.new/TP02-sol.cas --- a/check/TP02-sol.cas 2014-06-26 17:24:46.000000000 +0200 +++ b/check/TP02-sol.cas 2015-03-02 15:38:02.000000000 +0100 From 95d12b63657d26e5476ed2bc63b47314702f7275 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 26 Feb 2017 16:59:33 +0100 Subject: [PATCH 250/370] advanced git: write section on merging new SageMath version --- src/doc/en/developer/advanced_git.rst | 75 +++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/doc/en/developer/advanced_git.rst b/src/doc/en/developer/advanced_git.rst index 6dbbab41f73..d836b692a0f 100644 --- a/src/doc/en/developer/advanced_git.rst +++ b/src/doc/en/developer/advanced_git.rst @@ -66,6 +66,81 @@ branch -D my_branch`` at the end to delete the local branch that you created only to review the ticket. +.. _section-git-update-latest: + +When developing, quite frequently one ends up with a branch which is +not based on the latest (beta) version of SageMath. This is perfecly +fine and usually there is no need to merge in this latest SageMath +version. However sometimes it is, e.g. if there are conflicts with the +latest version or one needs a recent feature or simply because the old +SageMath version is not available on the machine. Then merging in the +latest version has to be done. + + +Merge in the latest SageMath Version +------------------------------------ + +(This is the easy way without minimizing the recompilation time.) + +Suppose we are on our current working branch (branch is checked out). Then +:: + + git merge develop + +does the merging, i.e. we merge the latest development version into +our working branch. + +However, after this merge, we need to (partially) recompile +SageMath. Sometimes this can take ages (as many timestamps are +renewed) and there is a way to avoid it. + + +Minimize the Recompilation Time +------------------------------- + +Suppose we are on some new SageMath (e.g. on branch ``develop``) which +runs successfully, and we have an "old" branch ``some/code``, that +we want to bring onto this SageMath version. + +We first create a new working tree in a directory ``merge`` and switch +to this directory:: + + git worktree add merge + cd merge + +Here we have a new copy of our source files. Thus no timestamps +etc. of the original repository will be changed. Now we do the merge:: + + git checkout some/code + git merge develop + +And go back to our original repository:: + + git checkout something/else + cd .. + +We can now safely checkout ``some/code``:: + + git checkout some/code + +We still need to call:: + + make + +but only changed files will be recompiled. + + +Why not Merging the Other Way Round? +------------------------------------ + +Being on some new SageMath (e.g. on branch ``develop``) which runs +successfully, it would be possible to merge in our branch +``some/code`` into develop. This would produce the same source files +and avoid unnecessary recompilations. However, it destroys git's +history. Thus, for example, it is hard to keep track of changes etc., +as one cannot simply persue the first parent of each git commit. + + .. _section-git-recovery: Reset and Recovery From b13d5c5012ef77be389c8210ec3da674e13b3446 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 26 Feb 2017 16:59:39 +0100 Subject: [PATCH 251/370] rewrite intro --- src/doc/en/developer/advanced_git.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/doc/en/developer/advanced_git.rst b/src/doc/en/developer/advanced_git.rst index d836b692a0f..77a1a77720c 100644 --- a/src/doc/en/developer/advanced_git.rst +++ b/src/doc/en/developer/advanced_git.rst @@ -68,6 +68,19 @@ created only to review the ticket. .. _section-git-update-latest: +Update Branch to Latest SageMath Version (and Minimizing Recompilation Time) +============================================================================ + +- You have a compiled and working new SageMath version ``n``, and +- you want to work on a branch ``some/code`` which is based on some old SageMath version ``o`` +- by updating this branch from version ``o`` to ``n`` +- with only recompiling changed files (and not all touched files from ``o`` to ``n``), +- then continue reading this section. + + +Introduction +------------ + When developing, quite frequently one ends up with a branch which is not based on the latest (beta) version of SageMath. This is perfecly fine and usually there is no need to merge in this latest SageMath From 956c0d028ff4742c5217d532d0d2ad202dd8d99f Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 26 Feb 2017 17:10:40 +0100 Subject: [PATCH 252/370] changes after proof reading --- src/doc/en/developer/advanced_git.rst | 38 ++++++++++++++++++--------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/doc/en/developer/advanced_git.rst b/src/doc/en/developer/advanced_git.rst index 77a1a77720c..e43058099a7 100644 --- a/src/doc/en/developer/advanced_git.rst +++ b/src/doc/en/developer/advanced_git.rst @@ -82,20 +82,31 @@ Introduction ------------ When developing, quite frequently one ends up with a branch which is -not based on the latest (beta) version of SageMath. This is perfecly -fine and usually there is no need to merge in this latest SageMath -version. However sometimes it is, e.g. if there are conflicts with the -latest version or one needs a recent feature or simply because the old -SageMath version is not available on the machine. Then merging in the -latest version has to be done. +not based on the latest (beta) version of SageMath. +.. NOTE:: -Merge in the latest SageMath Version + Continue working on a feature based on an old branch is perfecly + fine and usually there is no need to merge in this latest SageMath + version. + +However sometimes there is a need for a merge, for example + +- if there are conflicts with the latest version or +- one needs a recent feature or +- simply because the old SageMath version is not available on your machine + any longer. + +Then merging in the latest SageMath version has to be done. + + +Merge in the Latest SageMath Version ------------------------------------ (This is the easy way without minimizing the recompilation time.) -Suppose we are on our current working branch (branch is checked out). Then +Suppose we are on our current working branch ``some/code`` +(branch is checked out). Then :: git merge develop @@ -104,16 +115,17 @@ does the merging, i.e. we merge the latest development version into our working branch. However, after this merge, we need to (partially) recompile -SageMath. Sometimes this can take ages (as many timestamps are -renewed) and there is a way to avoid it. +SageMath. Sometimes this can take ages (as many files are touched and +their timestamps are renewed) and there is a way to avoid it. Minimize the Recompilation Time ------------------------------- Suppose we are on some new SageMath (e.g. on branch ``develop``) which -runs successfully, and we have an "old" branch ``some/code``, that -we want to bring onto this SageMath version. +was already compiled and runs successfully, and we have an "old" +branch ``some/code``, that we want to bring onto this SageMath version +(without triggering unnecessary recompilations). We first create a new working tree in a directory ``merge`` and switch to this directory:: @@ -129,7 +141,7 @@ etc. of the original repository will be changed. Now we do the merge:: And go back to our original repository:: - git checkout something/else + git checkout develop cd .. We can now safely checkout ``some/code``:: From abbd05308299c97c7b0eb272a240b73c537350e2 Mon Sep 17 00:00:00 2001 From: David Coudert Date: Mon, 27 Feb 2017 10:05:53 +0100 Subject: [PATCH 253/370] trac #22424: corrected doctest --- src/sage/graphs/graph.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py index 996021c62fb..126a1b86b43 100644 --- a/src/sage/graphs/graph.py +++ b/src/sage/graphs/graph.py @@ -5168,9 +5168,9 @@ def to_directed(self, implementation='c_graph', data_structure=None, :trac:`22424`:: - sage: G1=graphs.Grid2RandomGNP(5,0.5) + sage: G1 = graphs.RandomGNP(5,0.5) sage: gp1 = G1.graphplot(save_pos=True) - sage: G2=G1.to_directed() + sage: G2 = G1.to_directed() sage: G2.delete_vertex(0) sage: G2.add_vertex(5) sage: gp2 = G2.graphplot() From 2d49d35b604259da7a9e2d2c660486085d657b0f Mon Sep 17 00:00:00 2001 From: David Coudert Date: Mon, 27 Feb 2017 11:34:16 +0100 Subject: [PATCH 254/370] trac #22424: fix the bug --- src/sage/graphs/digraph.py | 17 +++++++++++++---- src/sage/graphs/graph.py | 28 +++++++++++++--------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/sage/graphs/digraph.py b/src/sage/graphs/digraph.py index 68be5112e73..a73177d2631 100644 --- a/src/sage/graphs/digraph.py +++ b/src/sage/graphs/digraph.py @@ -467,8 +467,8 @@ def __init__(self, data=None, pos=None, loops=None, format=None, sage: DiGraph(a,sparse=True).adjacency_matrix() == a True - The positions are copied when the DiGraph is built from - another DiGraph or from a Graph :: + The positions are copied when the DiGraph is built from another DiGraph + or from a Graph :: sage: g = DiGraph(graphs.PetersenGraph()) sage: h = DiGraph(g) @@ -477,6 +477,15 @@ def __init__(self, data=None, pos=None, loops=None, format=None, sage: g.get_pos() == graphs.PetersenGraph().get_pos() True + The position dictionary is not the input one (:trac:`22424`):: + + sage: my_pos = {0:(0,0), 1:(1,1)} + sage: D = DiGraph([[0,1], [(0,1)]], pos=my_pos) + sage: my_pos == D._pos + True + sage: my_pos is D._pos + False + Invalid sequence of edges given as an input (they do not all have the same length):: @@ -695,7 +704,7 @@ def __init__(self, data=None, pos=None, loops=None, format=None, self.allow_loops(loops,check=False) if weighted is None: weighted = data.weighted() if data.get_pos() is not None: - pos = data.get_pos().copy() + pos = data.get_pos() self.add_vertices(data.vertex_iterator()) self.add_edges(data.edge_iterator()) self.name(data.name()) @@ -798,7 +807,7 @@ def __init__(self, data=None, pos=None, loops=None, format=None, # weighted, multiedges, loops, verts and num_verts should now be set self._weighted = weighted - self._pos = pos + self._pos = copy(pos) if format != 'DiGraph' or name is not None: self.name(name) diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py index 126a1b86b43..6d6c33a6282 100644 --- a/src/sage/graphs/graph.py +++ b/src/sage/graphs/graph.py @@ -928,14 +928,22 @@ def __init__(self, data=None, pos=None, loops=None, format=None, sage: Graph(a,sparse=True).adjacency_matrix() == a True - The positions are copied when the graph is built from - another graph :: + The positions are copied when the graph is built from another graph :: sage: g = graphs.PetersenGraph() sage: h = Graph(g) sage: g.get_pos() == h.get_pos() True + The position dictionary is not the input one (:trac:`22424`):: + + sage: my_pos = {0:(0,0), 1:(1,1)} + sage: G = Graph([[0,1], [(0,1)]], pos=my_pos) + sage: my_pos == G._pos + True + sage: my_pos is G._pos + False + Or from a DiGraph :: sage: d = DiGraph(g) @@ -1166,7 +1174,7 @@ def __init__(self, data=None, pos=None, loops=None, format=None, self.allow_loops(loops, check=False) self.allow_multiple_edges(multiedges, check=False) if data.get_pos() is not None: - pos = data.get_pos().copy() + pos = data.get_pos() self.name(data.name()) self.add_vertices(data.vertex_iterator()) self.add_edges(data.edge_iterator()) @@ -1265,7 +1273,7 @@ def __init__(self, data=None, pos=None, loops=None, format=None, if weighted is None: weighted = False self._weighted = getattr(self,'_weighted',weighted) - self._pos = pos + self._pos = copy(pos) if format != 'Graph' or name is not None: self.name(name) @@ -5165,16 +5173,6 @@ def to_directed(self, implementation='c_graph', data_structure=None, sage: Graph([[1,2]], immutable=True).to_directed() Digraph on 2 vertices - - :trac:`22424`:: - - sage: G1 = graphs.RandomGNP(5,0.5) - sage: gp1 = G1.graphplot(save_pos=True) - sage: G2 = G1.to_directed() - sage: G2.delete_vertex(0) - sage: G2.add_vertex(5) - sage: gp2 = G2.graphplot() - sage: gp1 = G1.graphplot() """ if sparse is not None: if data_structure is not None: @@ -5193,7 +5191,7 @@ def to_directed(self, implementation='c_graph', data_structure=None, data_structure = "static_sparse" from sage.graphs.all import DiGraph D = DiGraph(name = self.name(), - pos = copy(self._pos), + pos = self.get_pos(), multiedges = self.allows_multiple_edges(), loops = self.allows_loops(), implementation = implementation, From c257367c809926d273ba95ee82bdf4e007de6f9b Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Mon, 27 Feb 2017 23:10:14 +0100 Subject: [PATCH 255/370] 22443: do not make GLPK version appears in doctest --- src/sage/numerical/mip.pyx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sage/numerical/mip.pyx b/src/sage/numerical/mip.pyx index 80211103ce4..94e5777a216 100644 --- a/src/sage/numerical/mip.pyx +++ b/src/sage/numerical/mip.pyx @@ -2518,12 +2518,13 @@ cdef class MixedIntegerLinearProgram(SageObject): sage: b = p.get_backend() sage: b.solver_parameter("simplex_or_intopt", "simplex_only") sage: b.solver_parameter("verbosity_simplex", "GLP_MSG_ALL") - sage: p.solve() # rel tol 1e-5 - GLPK Simplex Optimizer, v4.60 + sage: ans = p.solve() + GLPK Simplex Optimizer, v... 2 rows, 2 columns, 4 non-zeros * 0: obj = 7.000000000e+00 inf = 0.000e+00 (2) * 2: obj = 9.400000000e+00 inf = 0.000e+00 (0) OPTIMAL LP SOLUTION FOUND + sage: ans # rel tol 1e-5 9.4 """ return self._backend From 8e6df076125a573dd219a8240f4f622f7cc2a935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Mon, 27 Feb 2017 23:47:00 +0100 Subject: [PATCH 256/370] Updated the next to python3 standard --- src/sage/geometry/polyhedron/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 06d88da7af7..7b857c033c5 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2211,7 +2211,7 @@ def is_inscribable(self, certify=False): vertices = self.vertices() vertex = vertices[0] vertex_neighbors = vertex.neighbors() - simplex_vertices = [vertex] + [vertex_neighbors.next() for i in range(dimension)] + simplex_vertices = [vertex] + [next(vertex_neighbors) for i in range(dimension)] other_vertices = [v for v in vertices if v not in simplex_vertices] row_data = [] From 2dfd035b6f09ec84dfbc5ebdb98809436e540091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Tue, 28 Feb 2017 00:40:18 +0100 Subject: [PATCH 257/370] First implementation of star --- src/sage/homology/simplicial_complex.py | 33 ++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index a0959eeab79..eb76668a8da 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -2762,7 +2762,38 @@ def link(self, simplex, is_mutable=True): s = Simplex(simplex) for f in self._facets: if s.is_face(f): - faces.append(Simplex(list(f.set().difference(s.set())))) + faces.append(Simplex(f.set().difference(s.set()))) + return SimplicialComplex(faces, is_mutable=is_mutable) + + def star(self, simplex, is_mutable=True): + """ + The star of a simplex in this simplicial complex. + + The star of a simplex `F` is the simplicial complex formed by + all simplices `G` which contain `F`. + + INPUT: + + - `simplex` -- a simplex in this simplicial complex + - `is_mutable` -- (optional) boolean, determines if the output is mutable, default ``True`` + + EXAMPLES:: + + sage: X = SimplicialComplex([[0,1,2], [1,2,3]]) + sage: X.star(Simplex([0])) + Simplicial complex with vertex set (0, 1, 2) and facets {(0, 1, 2)} + sage: X.star(Simplex([1])) + Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)} + sage: X.star(Simplex([1,2])) + Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)} + sage: X.star(Simplex([])) + Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)} + """ + faces = [] + s = Simplex(simplex) + for f in self._facets: + if s.is_face(f): + faces.append(f) return SimplicialComplex(faces, is_mutable=is_mutable) def is_cohen_macaulay(self, base_ring=QQ, ncpus=0): From 04bcbefc61939ee3f2b7ced7542cc0cd3ca2c3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Tue, 28 Feb 2017 14:46:20 +0100 Subject: [PATCH 258/370] Added first implementation of stellar subdivision --- src/sage/homology/simplicial_complex.py | 63 +++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index eb76668a8da..25b42c88730 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -3402,6 +3402,69 @@ def barycentric_subdivision(self): """ return self.face_poset().order_complex() + def stellar_subdivision(self,simplex,inplace=False,mutable=True): + """ + This function returns the stellar subdivision of `simplex` either by + modifying `self` (when inplace is set to `True`). + + The stellar subdivision of a face is obtained by adding a new vertex to the + simplicial complex `self` joined to the star of the face and then + deleting the face `simplex` to the result. + + + EXAMPLES:: + sage: SC = SimplicialComplex([[0,1,2],[1,2,3]]) + sage: F1 = Simplex([1,2]) + sage: F2 = Simplex([1,3]) + sage: F3 = Simplex([1,2,3]) + sage: SC.stellar_subdivision(F1) + Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(0, 1, 4), (1, 3, 4), (2, 3, 4), (0, 2, 4)} + sage: SC.stellar_subdivision(F2) + Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(0, 1, 2), (2, 3, 4), (1, 2, 4)} + sage: SC.stellar_subdivision(F3) + Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} + sage: SC.stellar_subdivision(F3,inplace=True) + Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} + sage: SC + Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} + + + One can not modify an immutable simplicial complex: + + sage: SC = SimplicialComplex([[0,1,2],[1,2,3]],is_mutable=False) + sage: SC.stellar_subdivision(F1,inplace=True) + Traceback (most recent call last) + ... + ValueError: This simplicial complex is not mutable + + """ + + if inplace and not self._is_mutable: + raise ValueError("This simplicial complex is not mutable") + + if inplace: + working_complex = self + else: + working_complex = copy(self) + + vertices = working_complex.vertices() + not_found = True + vertex_label = 0 + while not_found: + if vertex_label not in vertices: + not_found = False + else: + vertex_label += 1 + new_vertex = SimplicialComplex([[vertex_label]]) + new_faces = new_vertex.join(working_complex.star(simplex),rename_vertices=False) + for face in new_faces.facets(): + working_complex.add_face(face) + + working_complex.remove_face(simplex) + + if not inplace: + return working_complex + def graph(self): """ The 1-skeleton of this simplicial complex, as a graph. From c6b38536784c6c5374b2fd9f1998421279cb5922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Tue, 28 Feb 2017 14:49:02 +0100 Subject: [PATCH 259/370] Corrected indentation --- src/sage/homology/simplicial_complex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index 25b42c88730..a4b28ba7a90 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -3429,7 +3429,7 @@ def stellar_subdivision(self,simplex,inplace=False,mutable=True): Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} - One can not modify an immutable simplicial complex: + One can not modify an immutable simplicial complex: sage: SC = SimplicialComplex([[0,1,2],[1,2,3]],is_mutable=False) sage: SC.stellar_subdivision(F1,inplace=True) From e948253065efb36aae179b434f039429fcbf1c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Tue, 28 Feb 2017 14:58:57 +0100 Subject: [PATCH 260/370] pep8 conventions --- src/sage/homology/simplicial_complex.py | 63 ++++++++++++------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index a4b28ba7a90..07add47afa0 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -288,7 +288,7 @@ def lattice_paths(t1, t2, length=None): [path + [(t1[-1], t2[-1])] for path in lattice_paths(t1[:-1], t2[:-1], length=length-1)]) -def rename_vertex(n, keep, left = True): +def rename_vertex(n, keep, left=True): """ Rename a vertex: the vertices from the list ``keep`` get relabeled 0, 1, 2, ..., in order. Any other vertex (e.g. 4) gets @@ -1031,7 +1031,7 @@ def __init__(self, good_faces = [] maximal_simplices = [Simplex(f) for f in maximal_faces] - if maximality_check: # Sorting is useful to filter maximal faces + if maximality_check: # Sorting is useful to filter maximal faces maximal_simplices.sort(key=lambda x: x.dimension(), reverse=True) for face in maximal_simplices: # check whether each given face is actually maximal @@ -2773,21 +2773,21 @@ def star(self, simplex, is_mutable=True): all simplices `G` which contain `F`. INPUT: - + - `simplex` -- a simplex in this simplicial complex - `is_mutable` -- (optional) boolean, determines if the output is mutable, default ``True`` EXAMPLES:: - sage: X = SimplicialComplex([[0,1,2], [1,2,3]]) - sage: X.star(Simplex([0])) - Simplicial complex with vertex set (0, 1, 2) and facets {(0, 1, 2)} - sage: X.star(Simplex([1])) - Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)} - sage: X.star(Simplex([1,2])) - Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)} - sage: X.star(Simplex([])) - Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)} + sage: X = SimplicialComplex([[0,1,2], [1,2,3]]) + sage: X.star(Simplex([0])) + Simplicial complex with vertex set (0, 1, 2) and facets {(0, 1, 2)} + sage: X.star(Simplex([1])) + Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)} + sage: X.star(Simplex([1,2])) + Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)} + sage: X.star(Simplex([])) + Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)} """ faces = [] s = Simplex(simplex) @@ -3413,29 +3413,28 @@ def stellar_subdivision(self,simplex,inplace=False,mutable=True): EXAMPLES:: - sage: SC = SimplicialComplex([[0,1,2],[1,2,3]]) - sage: F1 = Simplex([1,2]) - sage: F2 = Simplex([1,3]) - sage: F3 = Simplex([1,2,3]) - sage: SC.stellar_subdivision(F1) - Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(0, 1, 4), (1, 3, 4), (2, 3, 4), (0, 2, 4)} - sage: SC.stellar_subdivision(F2) - Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(0, 1, 2), (2, 3, 4), (1, 2, 4)} - sage: SC.stellar_subdivision(F3) - Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} - sage: SC.stellar_subdivision(F3,inplace=True) - Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} - sage: SC - Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} - + sage: SC = SimplicialComplex([[0,1,2],[1,2,3]]) + sage: F1 = Simplex([1,2]) + sage: F2 = Simplex([1,3]) + sage: F3 = Simplex([1,2,3]) + sage: SC.stellar_subdivision(F1) + Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(0, 1, 4), (1, 3, 4), (2, 3, 4), (0, 2, 4)} + sage: SC.stellar_subdivision(F2) + Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(0, 1, 2), (2, 3, 4), (1, 2, 4)} + sage: SC.stellar_subdivision(F3) + Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} + sage: SC.stellar_subdivision(F3,inplace=True) + Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} + sage: SC + Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} One can not modify an immutable simplicial complex: - - sage: SC = SimplicialComplex([[0,1,2],[1,2,3]],is_mutable=False) - sage: SC.stellar_subdivision(F1,inplace=True) - Traceback (most recent call last) + + sage: SC = SimplicialComplex([[0,1,2],[1,2,3]],is_mutable=False) + sage: SC.stellar_subdivision(F1,inplace=True) + Traceback (most recent call last) ... - ValueError: This simplicial complex is not mutable + ValueError: This simplicial complex is not mutable """ From 21ec0e70509c26f57f7cc1997ef832c21e5a1e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Tue, 28 Feb 2017 15:03:30 +0100 Subject: [PATCH 261/370] Changed keyword to certificate --- src/sage/geometry/polyhedron/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 7b857c033c5..cbb6cee3540 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2140,7 +2140,7 @@ def radius(self): """ return sqrt(self.radius_square()) - def is_inscribable(self, certify=False): + def is_inscribable(self, certificate=False): """ A full-dimensional compact polytope is inscribable if there exists a point in space which is equidistant to all its vertices. @@ -2157,7 +2157,7 @@ def is_inscribable(self, certify=False): INPUT: - - ``certify`` : Boolean, specify whether to return the circumcenter + - ``certificate`` : Boolean, specify whether to return the circumcenter if found OUTPUT: From 820910a6118298c3d24e4925c1a9a5b7adc62126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Tue, 28 Feb 2017 16:59:13 +0100 Subject: [PATCH 262/370] First edits after review --- src/sage/geometry/polyhedron/base.py | 43 +++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index cbb6cee3540..75187a7e107 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2140,9 +2140,9 @@ def radius(self): """ return sqrt(self.radius_square()) - def is_inscribable(self, certificate=False): + def is_inscribed(self, certificate=False): """ - A full-dimensional compact polytope is inscribable if there exists + A full-dimensional compact polytope is inscribed if there exists a point in space which is equidistant to all its vertices. This function tests whether this point exists and returns it if @@ -2171,37 +2171,36 @@ def is_inscribable(self, certificate=False): ....: [-1,1,-1,1],[1,1,1,-1],[-1,-1,1,-1], ....: [1,-1,-1,-1],[-1,1,-1,-1],[0,0,10/13,-24/13], ....: [0,0,-10/13,-24/13]]) - sage: q.is_inscribable(True) + sage: q.is_inscribed(True) (True, (0, 0, 0, 0)) sage: cube = polytopes.cube() - sage: cube.is_inscribable() - (True, None) + sage: cube.is_inscribed() + True sage: translated_cube = Polyhedron(vertices=[v.vector() + vector([1,2,3]) ....: for v in cube.vertices()]) - sage: translated_cube.is_inscribable(True) + sage: translated_cube.is_inscribed(True) (True, (1, 2, 3)) sage: truncated_cube = cube.face_truncation(cube.faces(0)[0]) - sage: truncated_cube.is_inscribable() - (False, None) + sage: truncated_cube.is_inscribed() + False The method is not implemented for non-full-dimensional polytope or unbounded polyhedra:: sage: square = Polyhedron(vertices=[[1,0,0],[0,1,0],[1,1,0],[0,0,0]]) - sage: square.is_inscribable() + sage: square.is_inscribed() Traceback (most recent call last) ... NotImplementedError: This function is implemented for full-dimensional polytopes only. sage: p = Polyhedron(vertices=[(0,0)],rays=[(1,0),(0,1)]) - sage: p.is_inscribable() + sage: p.is_inscribed() Traceback (most recent call last): ... NotImplementedError: This function is implemented for full-dimensional polytopes only. - """ if not self.is_compact() or not self.is_full_dimensional(): @@ -2212,14 +2211,14 @@ def is_inscribable(self, certificate=False): vertex = vertices[0] vertex_neighbors = vertex.neighbors() simplex_vertices = [vertex] + [next(vertex_neighbors) for i in range(dimension)] - other_vertices = [v for v in vertices if v not in simplex_vertices] + other_vertices = (v for v in vertices if v not in simplex_vertices) - row_data = [] + raw_data = [] for vertex in simplex_vertices: vertex_vector = vertex.vector() row_data += [[sum(i**2 for i in vertex_vector)] + [i for i in vertex_vector] + [1]] - matrix_data = matrix(row_data) + matrix_data = matrix(raw_data) # The determinant "a" should not be zero because the polytope is full # dimensional and also the simplex. @@ -2230,18 +2229,22 @@ def is_inscribable(self, certificate=False): c = (-1)**(dimension+1)*matrix_data.matrix_from_columns(range(dimension+1)).determinant() circumcenter = vector([minors[i]/(2*a) for i in range(dimension)]) - circumradius = sqrt(sum(m**2 for m in minors) - 4 * a * c) / (2*abs(a)) + squared_circumradius = sum(m**2 for m in minors) - 4 * a * c) / (2*abs(a) # Checking if the circumcenter has the correct sign - if (vertex.vector() - circumcenter).norm() != circumradius: + test_vector = vertex.vector() - circumcenter + if sum(i**2 for i in test_vector) != circumradius: circumcenter = - circumcenter - is_circumscrib = all((v.vector() - circumcenter).norm() == circumradius for v in other_vertices) + is_inscribed = all(sum(i**2 for i in v.vector() - circumcenter) == squared_circumradius for v in other_vertices) - if certify and is_circumscrib: - return (is_circumscrib, circumcenter) + if certificate: + if is_inscribed: + return (True, circumcenter) + else: + return (False, None) else: - return (is_circumscrib, None) + return is_inscribed def is_compact(self): """ From a563094ca0140e18bd79691d9adfdb4411ee5aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Tue, 28 Feb 2017 17:26:31 +0100 Subject: [PATCH 263/370] Second small edits --- src/sage/geometry/polyhedron/base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 75187a7e107..0ae798bdb95 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2229,14 +2229,15 @@ def is_inscribed(self, certificate=False): c = (-1)**(dimension+1)*matrix_data.matrix_from_columns(range(dimension+1)).determinant() circumcenter = vector([minors[i]/(2*a) for i in range(dimension)]) - squared_circumradius = sum(m**2 for m in minors) - 4 * a * c) / (2*abs(a) + squared_circumradius = (sum(m**2 for m in minors) - 4 * a * c) /(4*a**2) # Checking if the circumcenter has the correct sign test_vector = vertex.vector() - circumcenter - if sum(i**2 for i in test_vector) != circumradius: + if sum(i**2 for i in test_vector) != squared_circumradius: circumcenter = - circumcenter - is_inscribed = all(sum(i**2 for i in v.vector() - circumcenter) == squared_circumradius for v in other_vertices) + is_inscribed = all(sum(i**2 for i in v.vector() - circumcenter) == squared_circumradius \ + for v in vertices if v not in simplex_vertices) if certificate: if is_inscribed: From 361914c844bc934c51487308aff077351cffab36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Tue, 28 Feb 2017 17:36:33 +0100 Subject: [PATCH 264/370] Make tests pass --- src/sage/geometry/polyhedron/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 0ae798bdb95..47a1a6105d2 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2192,7 +2192,7 @@ def is_inscribed(self, certificate=False): sage: square = Polyhedron(vertices=[[1,0,0],[0,1,0],[1,1,0],[0,0,0]]) sage: square.is_inscribed() - Traceback (most recent call last) + Traceback (most recent call last): ... NotImplementedError: This function is implemented for full-dimensional polytopes only. @@ -2216,7 +2216,7 @@ def is_inscribed(self, certificate=False): raw_data = [] for vertex in simplex_vertices: vertex_vector = vertex.vector() - row_data += [[sum(i**2 for i in vertex_vector)] + + raw_data += [[sum(i**2 for i in vertex_vector)] + [i for i in vertex_vector] + [1]] matrix_data = matrix(raw_data) @@ -2236,7 +2236,7 @@ def is_inscribed(self, certificate=False): if sum(i**2 for i in test_vector) != squared_circumradius: circumcenter = - circumcenter - is_inscribed = all(sum(i**2 for i in v.vector() - circumcenter) == squared_circumradius \ + is_inscribed = all(sum(i**2 for i in v.vector() - circumcenter) == squared_circumradius for v in vertices if v not in simplex_vertices) if certificate: From fae5016a6f594a40fd4757323059f49d9ca38af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Tue, 28 Feb 2017 18:13:58 +0100 Subject: [PATCH 265/370] Review and made tests pass --- src/sage/homology/simplicial_complex.py | 42 ++++++++++++++++++++----- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index 07add47afa0..356c024df30 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -3402,7 +3402,7 @@ def barycentric_subdivision(self): """ return self.face_poset().order_complex() - def stellar_subdivision(self,simplex,inplace=False,mutable=True): + def stellar_subdivision(self,simplex,inplace=False,is_mutable=True): """ This function returns the stellar subdivision of `simplex` either by modifying `self` (when inplace is set to `True`). @@ -3411,6 +3411,20 @@ def stellar_subdivision(self,simplex,inplace=False,mutable=True): simplicial complex `self` joined to the star of the face and then deleting the face `simplex` to the result. + INPUT: + + - `simplex` -- a simplex face of `self` + - `inplace` -- a boolean, determines if the operation is done on `self` + or not. Default is `False` + - `is_mutable` -- a boolean, determines if the output is mutable or not + + OUTPUT: + + - A simplicial complex obtained by the stellar subdivision of the face + `simplex`. If inplace is `True`, the object `self` was modified, + otherwise a new simplicial complex is returned. The parameter + `is_mutable` determines the mutability of the output. + EXAMPLES:: sage: SC = SimplicialComplex([[0,1,2],[1,2,3]]) @@ -3423,23 +3437,32 @@ def stellar_subdivision(self,simplex,inplace=False,mutable=True): Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(0, 1, 2), (2, 3, 4), (1, 2, 4)} sage: SC.stellar_subdivision(F3) Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} - sage: SC.stellar_subdivision(F3,inplace=True) - Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} - sage: SC + sage: SC.stellar_subdivision(F3,inplace=True);SC Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} + The simplex to subdivide should be a face of self: + + sage: SC = SimplicialComplex([[0,1,2],[1,2,3]]) + sage: F4 = Simplex([3,4]) + sage: SC.stellar_subdivision(F4) + Traceback (most recent call last): + ... + ValueError: The face to subdivide is not a face of self. + One can not modify an immutable simplicial complex: sage: SC = SimplicialComplex([[0,1,2],[1,2,3]],is_mutable=False) sage: SC.stellar_subdivision(F1,inplace=True) - Traceback (most recent call last) + Traceback (most recent call last): ... - ValueError: This simplicial complex is not mutable - + ValueError: This simplicial complex is not mutable. """ if inplace and not self._is_mutable: - raise ValueError("This simplicial complex is not mutable") + raise ValueError("This simplicial complex is not mutable.") + + if not Simplex(simplex) in self: + raise ValueError("The face to subdivide is not a face of self.") if inplace: working_complex = self @@ -3461,6 +3484,9 @@ def stellar_subdivision(self,simplex,inplace=False,mutable=True): working_complex.remove_face(simplex) + if not is_mutable: + worksing_complex.set_immutable() + if not inplace: return working_complex From 429dde814708ad2b01c04b5ab667756d635d58c5 Mon Sep 17 00:00:00 2001 From: Mark Saaltink Date: Tue, 28 Feb 2017 17:16:47 -0500 Subject: [PATCH 266/370] Trac 22454 - fixed is_unit and implemented is_nilpotent for multivariate and infinite polynomials. --- .../polynomial/infinite_polynomial_element.py | 46 +++++++++-- .../rings/polynomial/multi_polynomial.pyx | 80 +++++++++++++++++++ .../polynomial/multi_polynomial_element.py | 38 ++------- .../multi_polynomial_libsingular.pyx | 32 -------- 4 files changed, 123 insertions(+), 73 deletions(-) diff --git a/src/sage/rings/polynomial/infinite_polynomial_element.py b/src/sage/rings/polynomial/infinite_polynomial_element.py index 2a92ab58d7e..ec25691f81d 100644 --- a/src/sage/rings/polynomial/infinite_polynomial_element.py +++ b/src/sage/rings/polynomial/infinite_polynomial_element.py @@ -427,13 +427,10 @@ def ring(self): def is_unit(self): r""" - Answers whether ``self`` is a unit + Answer whether ``self`` is a unit. EXAMPLES:: - sage: R1. = InfinitePolynomialRing(ZZ) - sage: R2. = InfinitePolynomialRing(QQ) - sage: p = 1 + x[2] sage: R1. = InfinitePolynomialRing(ZZ) sage: R2. = InfinitePolynomialRing(QQ) sage: (1+x[2]).is_unit() @@ -447,16 +444,49 @@ def is_unit(self): sage: (1+a[2]).is_unit() False + Check that :trac:`22454` is fixed:: + + sage: _. = InfinitePolynomialRing(Zmod(4)) + sage: (1 + 2*x[0]).is_unit() + True + sage: (x[0]*x[1]).is_unit() + False + sage: _. = InfinitePolynomialRing(Zmod(900)) + sage: (7+150*x[0] + 30*x[1] + 120*x[1]*x[100]).is_unit() + True + TESTS:: sage: R. = InfinitePolynomialRing(ZZ.quotient_ring(8)) sage: [R(i).is_unit() for i in range(8)] [False, True, False, True, False, True, False, True] """ - if len(self.variables()) > 0: - return False - else: - return self.base_ring()(self._p).is_unit() + return self._p.is_unit() + + def is_nilpotent(self): + r""" + Return ``True`` if ``self`` is nilpotent, i.e., some power of ``self`` + is 0. + + EXAMPLES:: + + sage: R. = InfinitePolynomialRing(QQbar) + sage: (x[0]+x[1]).is_nilpotent() + False + sage: R(0).is_nilpotent() + True + sage: _. = InfinitePolynomialRing(Zmod(4)) + sage: (2*x[0]).is_nilpotent() + True + sage: (2+x[4]*x[7]).is_nilpotent() + False + sage: _. = InfinitePolynomialRing(Zmod(100)) + sage: (5+2*y[0] + 10*(y[0]^2+y[1]^2)).is_nilpotent() + False + sage: (10*y[2] + 20*y[5] - 30*y[2]*y[5] + 70*(y[2]^2+y[5]^2)).is_nilpotent() + True + """ + return self._p.is_nilpotent() @cached_method def variables(self): diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index b94e2804695..3a2881ab87c 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -2269,6 +2269,86 @@ cdef class MPolynomial(CommutativeRingElement): return (self(tuple(M * vector([x,y]))), M) return self(tuple(M * vector([x,y]))) + def is_unit(self): + r""" + Return ``True`` if ``self`` is a unit, that is, has a + multiplicative inverse. + + EXAMPLES:: + + sage: R. = QQbar[] + sage: (x+y).is_unit() + False + sage: R(0).is_unit() + False + sage: R(-1).is_unit() + True + sage: R(-1 + x).is_unit() + False + sage: R(2).is_unit() + True + + Check that :trac:`22454` is fixed:: + + sage: _. = Zmod(4)[] + sage: (1 + 2*x).is_unit() + True + sage: (x*y).is_unit() + False + sage: _. = Zmod(36)[] + sage: (7+ 6*x + 12*y - 18*x*y).is_unit() + True + + """ + # EXERCISE (Atiyah-McDonald, Ch 1): Let `A[x]` be a polynomial + # ring in one variable. Then `f=\sum a_i x^i \in A[x]` is a unit\ + # if and only if `a_0` is a unit and `a_1,\ldots, a_n` are nilpotent. + # (Also noted in Dummit and Foote, "Abstract Algebra", 1991, + # Section 7.3 Exercise 33). + # Also f is nilpotent if and only if all a_i are nilpotent. + # This generalizes easily to the multivariate case, by considering + # K[x,y,...] as K[x][y]... + from polydict import ETuple + d = self.dict() + zero_key = ETuple([0]*self.parent().ngens()) + if not self.constant_coefficient().is_unit(): + return False + return all(k == zero_key or c.is_nilpotent() for k,c in d.items()) + + def is_nilpotent(self): + r""" + Return ``True`` if ``self`` is nilpotent, i.e., some power of ``self`` + is 0. + + EXAMPLES:: + + sage: R. = QQbar[] + sage: (x+y).is_nilpotent() + False + sage: R(0).is_nilpotent() + True + sage: _. = Zmod(4)[] + sage: (2*x).is_nilpotent() + True + sage: (2+y*x).is_nilpotent() + False + sage: _. = Zmod(36)[] + sage: (4+6*x).is_nilpotent() + False + sage: (6*x + 12*y + 18*x*y + 24*(x^2+y^2)).is_nilpotent() + True + """ + # EXERCISE (Atiyah-McDonald, Ch 1): Let `A[x]` be a polynomial + # ring in one variable. Then `f=\sum a_i x^i \in A[x]` is + # nilpotent if and only if `a_0,\ldots, a_n` are nilpotent. + # (Also noted in Dummit and Foote, "Abstract Algebra", 1991, + # Section 7.3 Exercise 33). + # This generalizes easily to the multivariate case, by considering + # K[x,y,...] as K[x][y]... + d = self.dict() + return all(c.is_nilpotent() for c in d.values()) + + cdef remove_from_tuple(e, int ind): w = list(e) del w[ind] diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index b5fe841a933..aece0407d0b 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -911,42 +911,14 @@ def exponents(self, as_ETuples=True): else: return [tuple(e) for e in self.__exponents] - def is_unit(self): - """ - Return True if self is a unit. - - EXAMPLES:: - - sage: R. = QQbar[] - sage: (x+y).is_unit() - False - sage: R(0).is_unit() - False - sage: R(-1).is_unit() - True - sage: R(-1 + x).is_unit() - False - sage: R(2).is_unit() - True - """ - d = self.element().dict() - k = d.keys() - if len(k) != 1: - return False - k = k[0] - if k != polydict.ETuple([0]*self.parent().ngens()): - return False - return bool(d[k].is_unit()) - def inverse_of_unit(self): d = self.element().dict() k = d.keys() - if len(k) != 1: - raise ArithmeticError("is not a unit") - k = k[0] - if k != polydict.ETuple([0]*self.parent().ngens()): - raise ArithmeticError("is not a unit") - return ~d[k] + if self.is_unit(): + if len(k) != 1: + raise NotImplementedError + return ~d[k[0]] + raise ArithmeticError("is not a unit") def is_homogeneous(self): """ diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx index 570ca4c9bc5..fcdd98ec50e 100644 --- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx @@ -3089,38 +3089,6 @@ cdef class MPolynomial_libsingular(sage.rings.polynomial.multi_polynomial.MPolyn p = pNext(p) return pl - def is_unit(self): - """ - Return ``True`` if self is a unit. - - EXAMPLES:: - - sage: R. = QQ[] - sage: (x+y).is_unit() - False - sage: R(0).is_unit() - False - sage: R(-1).is_unit() - True - sage: R(-1 + x).is_unit() - False - sage: R(2).is_unit() - True - - sage: R. = ZZ[] - sage: R(1).is_unit() - True - sage: R(2).is_unit() - False - - """ - cdef bint is_field = self._parent._base.is_field() - if is_field: - if self._parent_ring != currRing: rChangeCurrRing(self._parent_ring) # bug in p_IsUnit - return bool(p_IsUnit(self._poly, self._parent_ring)) - else: - return bool(p_IsConstant(self._poly, self._parent_ring) and self.constant_coefficient().is_unit()) - def inverse_of_unit(self): """ Return the inverse of this polynomial if it is a unit. From 537849fc78ef4ce4029f50d12e4847d66b96d5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 31 May 2016 20:55:34 +0200 Subject: [PATCH 267/370] trac 20736 first try, failing --- src/bin/sage | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bin/sage b/src/bin/sage index 398609c563c..d5d6eed4a91 100755 --- a/src/bin/sage +++ b/src/bin/sage @@ -276,8 +276,7 @@ fi # an unclobbered environment before testing unsafe tickets. if [ "$1" = '-patchbot' -o "$1" = "--patchbot" ]; then shift - cd "$SAGE_ROOT" - exec local/bin/patchbot/patchbot.py "$@" + exec python -m sage_patchbot.patchbot "$@" fi # Check for '--upgrade' before sourcing sage-env: the top-level "make" From c9c4101b961c454b2acac23508a74ccfbcffb7c4 Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Tue, 2 Aug 2016 17:01:21 +0200 Subject: [PATCH 268/370] Improve --patchbot command --- src/bin/sage | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/bin/sage b/src/bin/sage index d5d6eed4a91..3c79dd9cb31 100755 --- a/src/bin/sage +++ b/src/bin/sage @@ -276,7 +276,26 @@ fi # an unclobbered environment before testing unsafe tickets. if [ "$1" = '-patchbot' -o "$1" = "--patchbot" ]; then shift + # We ask the Python from Sage where the patchbot is installed. + # We set PYTHONPATH to that directory such that the system Python + # should also find the sage_patchbot package. + cmd='import sage_patchbot as p; import os; print(os.path.dirname(p.__path__[0]))' + export PYTHONPATH=`"$SAGE_ROOT/sage" --python -c "$cmd"` + if [ -z "$PYTHONPATH" ]; then + # Something went wrong, assume that the patchbot is not installed + echo >&2 "Error: cannot find installation path for sage_patchbot" + echo >&2 "See https://wiki.sagemath.org/buildbot for instructions" + exit 1 + fi + + # Try "python2.7", then "python2", then "python" + shopt -s execfail # Do not exit if "exec" fails + exec python2.7 -m sage_patchbot.patchbot "$@" + exec python2 -m sage_patchbot.patchbot "$@" exec python -m sage_patchbot.patchbot "$@" + echo >&2 "Error: cannot find a suitable Python program." + echo >&2 "The SageMath patchbot requires a system Python installation." + exit 127 fi # Check for '--upgrade' before sourcing sage-env: the top-level "make" From c886ddba08094e8fb43efa18cdce2782a1109c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Wed, 1 Mar 2017 12:28:20 +0100 Subject: [PATCH 269/370] Second edits after review --- src/sage/geometry/polyhedron/base.py | 48 ++++++++++++++++++---------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 47a1a6105d2..059b97fa006 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2142,28 +2142,36 @@ def radius(self): def is_inscribed(self, certificate=False): """ + This function tests whether the vertices of the polyhedron are + inscribed on a sphere. + + The polyhedron is expected to be compact and full-dimensional. A full-dimensional compact polytope is inscribed if there exists a point in space which is equidistant to all its vertices. - This function tests whether this point exists and returns it if - specified. + ALGORITHM: The function first computes the circumsphere of a full-dimensional - simplex with vertices of `self` and then checks if all other vertices - are equidistant to the circumcenter of that simplex. - - The circumsphere of the simplex is found by lifting the points on a + simplex with vertices of `self`. It is found by lifting the points on a paraboloid to find the hyperplane on which the circumsphere is lifted. + Then, it checks if all other vertices are equidistant to the + circumcenter of that simplex. INPUT: - - ``certificate`` : Boolean, specify whether to return the circumcenter - if found + - ``certificate`` : boolean (default: False). Specifies whether to + return the circumcenter, if found. OUTPUT: - A tuple containing a boolean and potentially the circumcenter of the - polytope. + If ``certificate`` is true, returns a tuple containing: + + 1. Boolean. + 2. The circumcenter of the polytope or None. + + If ``certificate`` is false: + + - a Boolean. EXAMPLES:: @@ -2171,7 +2179,7 @@ def is_inscribed(self, certificate=False): ....: [-1,1,-1,1],[1,1,1,-1],[-1,-1,1,-1], ....: [1,-1,-1,-1],[-1,1,-1,-1],[0,0,10/13,-24/13], ....: [0,0,-10/13,-24/13]]) - sage: q.is_inscribed(True) + sage: q.is_inscribed(certificate=True) (True, (0, 0, 0, 0)) sage: cube = polytopes.cube() @@ -2180,7 +2188,7 @@ def is_inscribed(self, certificate=False): sage: translated_cube = Polyhedron(vertices=[v.vector() + vector([1,2,3]) ....: for v in cube.vertices()]) - sage: translated_cube.is_inscribed(True) + sage: translated_cube.is_inscribed(certificate=True) (True, (1, 2, 3)) sage: truncated_cube = cube.face_truncation(cube.faces(0)[0]) @@ -2194,24 +2202,30 @@ def is_inscribed(self, certificate=False): sage: square.is_inscribed() Traceback (most recent call last): ... - NotImplementedError: This function is implemented for full-dimensional polytopes only. + NotImplementedError: This function is implemented for full-dimensional polyhedron only. sage: p = Polyhedron(vertices=[(0,0)],rays=[(1,0),(0,1)]) sage: p.is_inscribed() Traceback (most recent call last): ... - NotImplementedError: This function is implemented for full-dimensional polytopes only. + NotImplementedError: This function is not implemented for unbounded polyhedron. """ - if not self.is_compact() or not self.is_full_dimensional(): - raise NotImplementedError("This function is implemented for full-dimensional polytopes only.") + if not self.is_compact(): + raise NotImplementedError("This function is not implemented for unbounded polyhedron.") + + if not self.is_full_dimensional(): + raise NotImplementedError("This function is implemented for full-dimensional polyhedron only.") dimension = self.dimension() vertices = self.vertices() vertex = vertices[0] vertex_neighbors = vertex.neighbors() + + # The following simplex is full-dimensional because `self` is assumed + # to be: every vertex has at least `dimension` neighbors and they form + # a full simplex with `vertex`. simplex_vertices = [vertex] + [next(vertex_neighbors) for i in range(dimension)] - other_vertices = (v for v in vertices if v not in simplex_vertices) raw_data = [] for vertex in simplex_vertices: From 649a3b4af20708a24bdd91b854dc633f1e624ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Wed, 1 Mar 2017 12:36:12 +0100 Subject: [PATCH 270/370] pep8 and pyflakes conventions --- src/sage/geometry/polyhedron/base.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 059b97fa006..d21d34f7f18 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2145,7 +2145,7 @@ def is_inscribed(self, certificate=False): This function tests whether the vertices of the polyhedron are inscribed on a sphere. - The polyhedron is expected to be compact and full-dimensional. + The polyhedron is expected to be compact and full-dimensional. A full-dimensional compact polytope is inscribed if there exists a point in space which is equidistant to all its vertices. @@ -2154,18 +2154,18 @@ def is_inscribed(self, certificate=False): The function first computes the circumsphere of a full-dimensional simplex with vertices of `self`. It is found by lifting the points on a paraboloid to find the hyperplane on which the circumsphere is lifted. - Then, it checks if all other vertices are equidistant to the + Then, it checks if all other vertices are equidistant to the circumcenter of that simplex. INPUT: - - ``certificate`` : boolean (default: False). Specifies whether to + - ``certificate`` : boolean (default: False). Specifies whether to return the circumcenter, if found. OUTPUT: If ``certificate`` is true, returns a tuple containing: - + 1. Boolean. 2. The circumcenter of the polytope or None. @@ -2213,7 +2213,7 @@ def is_inscribed(self, certificate=False): if not self.is_compact(): raise NotImplementedError("This function is not implemented for unbounded polyhedron.") - + if not self.is_full_dimensional(): raise NotImplementedError("This function is implemented for full-dimensional polyhedron only.") @@ -2243,14 +2243,14 @@ def is_inscribed(self, certificate=False): c = (-1)**(dimension+1)*matrix_data.matrix_from_columns(range(dimension+1)).determinant() circumcenter = vector([minors[i]/(2*a) for i in range(dimension)]) - squared_circumradius = (sum(m**2 for m in minors) - 4 * a * c) /(4*a**2) + squared_circumradius = (sum(m**2 for m in minors) - 4 * a * c) / (4*a**2) # Checking if the circumcenter has the correct sign test_vector = vertex.vector() - circumcenter if sum(i**2 for i in test_vector) != squared_circumradius: circumcenter = - circumcenter - is_inscribed = all(sum(i**2 for i in v.vector() - circumcenter) == squared_circumradius + is_inscribed = all(sum(i**2 for i in v.vector() - circumcenter) == squared_circumradius for v in vertices if v not in simplex_vertices) if certificate: @@ -4846,7 +4846,7 @@ def restricted_automorphism_group(self, output="abstract"): - For ``output="matrixlist"``: a list of matrices. - REFERENCES: + REFERENCES: - [BSS2009]_ From c42072d33bfef2db3b69013f45585d454e089624 Mon Sep 17 00:00:00 2001 From: Mark Saaltink Date: Wed, 1 Mar 2017 15:17:25 -0500 Subject: [PATCH 271/370] Small speedup in is_unit for multivariate polynomials --- src/sage/rings/polynomial/multi_polynomial.pyx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index 3a2881ab87c..12fd2b124e2 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -33,6 +33,8 @@ from sage.arith.misc import gcd from sage.rings.complex_interval_field import ComplexIntervalField from sage.rings.real_mpfr import RealField_class,RealField +from polydict cimport ETuple + cdef class MPolynomial(CommutativeRingElement): #################### @@ -2308,12 +2310,12 @@ cdef class MPolynomial(CommutativeRingElement): # Also f is nilpotent if and only if all a_i are nilpotent. # This generalizes easily to the multivariate case, by considering # K[x,y,...] as K[x][y]... - from polydict import ETuple - d = self.dict() - zero_key = ETuple([0]*self.parent().ngens()) if not self.constant_coefficient().is_unit(): return False - return all(k == zero_key or c.is_nilpotent() for k,c in d.items()) + cdef dict d = self.dict() + cdef ETuple zero_key = ETuple([0]*self.parent().ngens()) + d.pop(zero_key, None) + return all(d[k].is_nilpotent() for k in d) def is_nilpotent(self): r""" From 61c6b039ec4daf87dff109d30058325e4370936b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 1 Mar 2017 21:53:40 +0100 Subject: [PATCH 272/370] py3 get rid of the last .iteritems and one cmp in multi-filtered vectors --- .../modules/multi_filtered_vector_space.py | 59 +++++++++++++------ 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/src/sage/modules/multi_filtered_vector_space.py b/src/sage/modules/multi_filtered_vector_space.py index 64a20d0bbb6..5bbab4e8fd8 100644 --- a/src/sage/modules/multi_filtered_vector_space.py +++ b/src/sage/modules/multi_filtered_vector_space.py @@ -38,6 +38,7 @@ # the License, or (at your option) any later version. # http://www.gnu.org/licenses/ #***************************************************************************** +from six import iteritems from sage.rings.all import QQ, ZZ, RDF, RR, Integer from sage.rings.infinity import InfinityRing, infinity, minus_infinity @@ -186,10 +187,11 @@ def change_ring(self, base_ring): sage: MultiFilteredVectorSpace(3, base_ring=QQ).change_ring(RR) Unfiltered RR^3 """ - if len(self._filt) == 0: - return MultiFilteredVectorSpace(self.dimension(), base_ring=base_ring) - filtrations = dict() - for key, F in self._filt.iteritems(): + if not self._filt: + return MultiFilteredVectorSpace(self.dimension(), + base_ring=base_ring) + filtrations = {} + for key, F in iteritems(self._filt): filtrations[key] = F.change_ring(base_ring) return MultiFilteredVectorSpace(filtrations, base_ring=base_ring) @@ -322,7 +324,7 @@ def min_degree(self): sage: V.min_degree() 1 """ - if len(self._filt) == 0: + if not self._filt: return infinity return min(F.min_degree() for F in self._filt.values()) @@ -345,7 +347,7 @@ def max_degree(self): sage: V.max_degree() 4 """ - if len(self._filt) == 0: + if not self._filt: return minus_infinity return max(F.max_degree() for F in self._filt.values()) @@ -453,8 +455,9 @@ def _repr_(self): sage: MultiFilteredVectorSpace(123, base_ring=RR) Unfiltered RR^123 """ - if len(self._filt) == 0: - F = FilteredVectorSpace(self.dimension(), base_ring=self.base_ring()) + if not self._filt: + F = FilteredVectorSpace(self.dimension(), + base_ring=self.base_ring()) return 'Unfiltered ' + repr(F) rows = [] support = self.support() @@ -474,7 +477,7 @@ def _repr_(self): lines.append(s) return '\n'.join(lines) - def __cmp__(self, other): + def __eq__(self, other): """ Compare two multi-filtered vector spaces. @@ -488,8 +491,24 @@ def __cmp__(self, other): sage: V == MultiFilteredVectorSpace({'a':F1, 'b':F2}) False """ - return cmp(self._filt, other._filt) + return self._filt == other._filt + def __ne__(self, other): + """ + Compare two multi-filtered vector spaces. + + EXAMPLES:: + + sage: F1 = FilteredVectorSpace(2, 1) + sage: F2 = FilteredVectorSpace(1, 3) + FilteredVectorSpace(1,0) + sage: V = MultiFilteredVectorSpace({1:F1, 2:F2}) + sage: V != MultiFilteredVectorSpace({2:F2, 1:F1}) + False + sage: V != MultiFilteredVectorSpace({'a':F1, 'b':F2}) + True + """ + return not (self == other) + def direct_sum(self, other): """ Return the direct sum. @@ -522,8 +541,9 @@ def direct_sum(self, other): b: QQ^3 >= QQ^2 >= QQ^2 >= QQ^2 >= 0 """ if not self.index_set() == other.index_set(): - raise ValueError('the index sets of the two summands must be the same') - filtrations = dict() + raise ValueError('the index sets of the two summands' + ' must be the same') + filtrations = {} for key in self.index_set(): filtrations[key] = self._filt[key] + other._filt[key] return MultiFilteredVectorSpace(filtrations) @@ -563,8 +583,9 @@ def tensor_product(self, other): b: QQ^2 >= QQ^2 >= QQ^1 >= QQ^1 >= QQ^1 >= 0 """ if not self.index_set() == other.index_set(): - raise ValueError('the index sets of the two summands must be the same') - filtrations = dict() + raise ValueError('the index sets of the two summands' + ' must be the same') + filtrations = {} for key in self.index_set(): filtrations[key] = self._filt[key] * other._filt[key] return MultiFilteredVectorSpace(filtrations) @@ -595,7 +616,7 @@ def exterior_power(self, n): a: QQ^1 >= 0 >= 0 b: QQ^1 >= QQ^1 >= 0 """ - filtrations = dict() + filtrations = {} for key in self.index_set(): filtrations[key] = self._filt[key].exterior_power(n) return MultiFilteredVectorSpace(filtrations) @@ -626,7 +647,7 @@ def symmetric_power(self, n): a: QQ^3 >= QQ^3 >= QQ^3 >= 0 >= 0 >= 0 >= 0 >= 0 b: QQ^3 >= QQ^2 >= QQ^2 >= QQ^2 >= QQ^1 >= QQ^1 >= QQ^1 >= 0 """ - filtrations = dict() + filtrations = {} for key in self.index_set(): filtrations[key] = self._filt[key].symmetric_power(n) return MultiFilteredVectorSpace(filtrations) @@ -650,7 +671,7 @@ def dual(self): a: QQ^2 >= QQ^2 >= QQ^2 >= 0 >= 0 b: QQ^2 >= QQ^1 >= QQ^1 >= QQ^1 >= 0 """ - filtrations = dict() + filtrations = {} for key in self.index_set(): filtrations[key] = self._filt[key].dual() return MultiFilteredVectorSpace(filtrations) @@ -674,7 +695,7 @@ def shift(self, deg): sage: V.shift(-5).support() (-5, -4, -2) """ - filtrations = dict() + filtrations = {} for key in self.index_set(): filtrations[key] = self._filt[key].shift(deg) return MultiFilteredVectorSpace(filtrations) @@ -706,7 +727,7 @@ def random_deformation(self, epsilon=None): Basis matrix: [ 1 8/1197] """ - filtrations = dict() + filtrations = {} for key in self.index_set(): filtrations[key] = self._filt[key].random_deformation(epsilon) return MultiFilteredVectorSpace(filtrations) From efbd87751b8fd5b384c563026e3470bdb42429c2 Mon Sep 17 00:00:00 2001 From: paulmasson Date: Wed, 1 Mar 2017 19:07:52 -0800 Subject: [PATCH 273/370] Add symlink to threejs --- src/sage/repl/ipython_kernel/install.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/sage/repl/ipython_kernel/install.py b/src/sage/repl/ipython_kernel/install.py index 45a3673b511..3912b8cdf52 100644 --- a/src/sage/repl/ipython_kernel/install.py +++ b/src/sage/repl/ipython_kernel/install.py @@ -1,5 +1,5 @@ """ -Installing the SageMath Jupyter Kernel and extensions +Installing the SageMath Jupyter Kernel and Extensions Kernels have to register themselves with Jupyter so that they appear in the Jupyter notebook's kernel drop-down. This is done by @@ -130,6 +130,23 @@ def use_local_jsmol(self): dst = os.path.join(self.nbextensions_dir, 'jsmol') self.symlink(src, dst) + def use_local_threejs(self): + """ + Symlink threejs to the Jupyter notebook. + + EXAMPLES:: + + sage: from sage.repl.ipython_kernel.install import SageKernelSpec + sage: spec = SageKernelSpec() + sage: spec.use_local_threejs() + sage: threejs = os.path.join(spec.nbextensions_dir, 'threejs') + sage: os.path.isdir(threejs) + True + """ + src = os.path.join(SAGE_LOCAL, 'share', 'threejs') + dst = os.path.join(self.nbextensions_dir, 'threejs') + self.symlink(src, dst) + def _kernel_cmd(self): """ Helper to construct the SageMath kernel command. @@ -236,6 +253,7 @@ def update(cls): instance = cls() instance.use_local_mathjax() instance.use_local_jsmol() + instance.use_local_threejs() instance._install_spec() instance._symlink_resources() From b90694190028c1eaa43724fe9ea705407c3170a1 Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Wed, 1 Mar 2017 13:56:43 +0100 Subject: [PATCH 274/370] Add a trivial factor() method for fields --- .../coercion_and_categories.rst | 7 +++++-- src/sage/categories/fields.py | 21 +++++++++++++++++++ .../multi_polynomial_libsingular.pyx | 3 +++ .../polynomial/polynomial_quotient_ring.py | 13 +++++++++++- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst index 017fcfe9e52..c692ae41096 100644 --- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst +++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst @@ -537,8 +537,11 @@ fields instead of the category of fields:: sage: [p for p in dir(QuotientFields().parent_class) if p not in dir(Fields().parent_class)] [] sage: [p for p in dir(QuotientFields().element_class) if p not in dir(Fields().element_class)] - ['_derivative', 'denominator', 'derivative', 'factor', - 'numerator', 'partial_fraction_decomposition'] + ['_derivative', + 'denominator', + 'derivative', + 'numerator', + 'partial_fraction_decomposition'] .. end of output diff --git a/src/sage/categories/fields.py b/src/sage/categories/fields.py index 526ccce9875..2243bf31085 100644 --- a/src/sage/categories/fields.py +++ b/src/sage/categories/fields.py @@ -687,3 +687,24 @@ def xgcd(self, other): return (P.one(), P.zero(), ~other) # else both are 0 return (P.zero(), P.zero(), P.zero()) + + def factor(self): + """ + Return a factorization of ``self``. + + Since ``self`` is either a unit or zero, this function is trivial. + + EXAMPLES:: + + sage: x = GF(7)(5) + sage: x.factor() + 5 + sage: RR(0).factor() + Traceback (most recent call last): + ... + ArithmeticError: factorization of 0.000000000000000 is not defined + """ + if not self: + raise ArithmeticError("factorization of {!r} is not defined".format(self)) + from sage.structure.factorization import Factorization + return Factorization([], self) # No factor; "self" as unit diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx index 570ca4c9bc5..f940dcb4f9a 100644 --- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx @@ -4112,6 +4112,9 @@ cdef class MPolynomial_libsingular(sage.rings.polynomial.multi_polynomial.MPolyn sage: P. = ZZ[] sage: P(2^3*7).factor() 2^3 * 7 + sage: P. = GF(2)[] + sage: P(1).factor() + 1 Factorization for finite prime fields with characteristic `> 2^{29}` is not supported :: diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index 46a4b580ed2..bcbf1965899 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -281,7 +281,18 @@ class of the category, and store the current class of the quotient sage: first_class == Q.__class__ False sage: [s for s in dir(Q.category().element_class) if not s.startswith('_')] - ['cartesian_product', 'euclidean_degree', 'gcd', 'is_idempotent', 'is_one', 'is_unit', 'lcm', 'lift', 'powers', 'quo_rem', 'xgcd'] + ['cartesian_product', + 'euclidean_degree', + 'factor', + 'gcd', + 'is_idempotent', + 'is_one', + 'is_unit', + 'lcm', + 'lift', + 'powers', + 'quo_rem', + 'xgcd'] As one can see, the elements are now inheriting additional methods: lcm and gcd. Even though ``Q.an_element()`` belongs to From fba72c01e000b4ef68c6cdc259f8c1dc5aa1fc84 Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Thu, 2 Mar 2017 08:33:25 +0100 Subject: [PATCH 275/370] Consistent exception messages for 0.factor() --- src/sage/arith/misc.py | 2 +- src/sage/rings/integer.pyx | 2 +- src/sage/rings/polynomial/multi_polynomial_element.py | 6 +++--- src/sage/rings/polynomial/padics/polynomial_padic.py | 2 +- src/sage/rings/polynomial/polynomial_element.pyx | 4 ++-- .../rings/polynomial/polynomial_integer_dense_flint.pyx | 4 ++-- src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx | 4 ++-- src/sage/rings/rational.pyx | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 22f884637d9..21c5e0db2be 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2379,7 +2379,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds): sage: factor(0) Traceback (most recent call last): ... - ArithmeticError: Prime factorization of 0 not defined. + ArithmeticError: factorization of 0 is not defined sage: factor(1) 1 sage: factor(-1) diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 666757187dc..8e23118ce4c 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -3683,7 +3683,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): cdef n_factor_t f if mpz_sgn(self.value) == 0: - raise ArithmeticError("Prime factorization of 0 not defined.") + raise ArithmeticError("factorization of 0 is not defined") if mpz_sgn(self.value) > 0: n = self diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index b5fe841a933..039884a07b1 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -1704,7 +1704,7 @@ def factor(self, proof=True): sage: P(0).factor() Traceback (most recent call last): ... - ArithmeticError: Prime factorization of 0 not defined. + ArithmeticError: factorization of 0 is not defined Check if we can factor a constant polynomial, see :trac:`8207`:: @@ -1730,8 +1730,8 @@ def factor(self, proof=True): R = self.parent() # raise error if trying to factor zero - if self == 0: - raise ArithmeticError("Prime factorization of 0 not defined.") + if not self: + raise ArithmeticError("factorization of {!r} is not defined".format(self)) # if number of variables is zero ... if R.ngens() == 0: diff --git a/src/sage/rings/polynomial/padics/polynomial_padic.py b/src/sage/rings/polynomial/padics/polynomial_padic.py index 75ddf5ba848..38f66139841 100644 --- a/src/sage/rings/polynomial/padics/polynomial_padic.py +++ b/src/sage/rings/polynomial/padics/polynomial_padic.py @@ -212,7 +212,7 @@ def factor(self): (3^2 + 2*3^3 + 2*3^4 + 3^5 + 2*3^6 + O(3^22)) * ((1 + O(3^19))*T + (2*3^-1 + 3 + 3^2 + 2*3^5 + 2*3^6 + 2*3^7 + 3^8 + 3^9 + 2*3^11 + 3^15 + 3^17 + O(3^19))) * ((1 + O(3^20))*T + (2*3 + 3^2 + 3^3 + 3^5 + 2*3^6 + 2*3^7 + 3^8 + 3^10 + 3^11 + 2*3^12 + 2*3^14 + 2*3^15 + 2*3^17 + 2*3^18 + O(3^20))) """ if self == 0: - raise ArithmeticError("factorization of 0 not defined") + raise ArithmeticError("factorization of {!r} is not defined".format(self)) # Scale self such that 0 is the lowest valuation # amongst the coefficients try: diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 40824294432..0cfefddf27a 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -3824,7 +3824,7 @@ cdef class Polynomial(CommutativeAlgebraElement): sage: f.factor() Traceback (most recent call last): ... - ValueError: factorization of 0 not defined + ArithmeticError: factorization of 0 is not defined :: @@ -4002,7 +4002,7 @@ cdef class Polynomial(CommutativeAlgebraElement): ## 200 lines of spagetti code is just way to much! if self.degree() < 0: - raise ValueError("factorization of 0 not defined") + raise ArithmeticError("factorization of {!r} is not defined".format(self)) if self.degree() == 0: return Factorization([], unit=self[0]) diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx index 81183136a8b..1d0e9771989 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx @@ -1598,7 +1598,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): sage: f.factor_mod(3) Traceback (most recent call last): ... - ValueError: factorization of 0 not defined + ArithmeticError: factorization of 0 is not defined sage: f = 2*x*(x-2)*(x-9) sage: f.factor_mod(7) @@ -1609,7 +1609,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): if not p.is_prime(): raise ValueError("p must be prime") if all([c%p==0 for c in self.coefficients()]): - raise ValueError("factorization of 0 not defined") + raise ArithmeticError("factorization of 0 is not defined") f = self._pari_() G = f.factormod(p) k = FiniteField(p) diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx b/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx index fc22438f9e4..9abd32dc3c8 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx +++ b/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx @@ -1012,7 +1012,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): sage: f.factor_mod(3) Traceback (most recent call last): ... - ValueError: factorization of 0 not defined + ArithmeticError: factorization of 0 is not defined sage: f = 2*x*(x-2)*(x-9) sage: f.factor_mod(7) @@ -1023,7 +1023,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): if not p.is_prime(): raise ValueError("p must be prime") if all([c%p==0 for c in self.coefficients()]): - raise ValueError("factorization of 0 not defined") + raise ArithmeticError("factorization of 0 is not defined") f = self._pari_() G = f.factormod(p) k = FiniteField(p) diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index 49c890312a9..652813fe019 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -2971,7 +2971,7 @@ cdef class Rational(sage.structure.element.FieldElement): sage: (0/1).factor() Traceback (most recent call last): ... - ArithmeticError: Prime factorization of 0 not defined. + ArithmeticError: factorization of 0 is not defined """ return self.numerator().factor() * \ sage.structure.factorization.Factorization([(p,-e) for p, e in self.denominator().factor()]) From e9e4016d453b46059c7b38a89ef6a4eb6ed3f1d0 Mon Sep 17 00:00:00 2001 From: Thierry Monteil Date: Thu, 2 Mar 2017 10:05:38 +0100 Subject: [PATCH 276/370] #22487 : add -ltinfo flag to LDFLAGS. --- build/pkgs/gdb/spkg-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/gdb/spkg-install b/build/pkgs/gdb/spkg-install index 01f8c15d332..f7c62fc3fe8 100755 --- a/build/pkgs/gdb/spkg-install +++ b/build/pkgs/gdb/spkg-install @@ -8,7 +8,7 @@ fi cd src -LDFLAGS="${LDFLAGS} -L${SAGE_LOCAL}/lib" +LDFLAGS="${LDFLAGS} -L${SAGE_LOCAL}/lib -ltinfo" export LDFLAGS ./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" \ From 3075f0a916e3913e4d9966326c638610ff4e5635 Mon Sep 17 00:00:00 2001 From: Thierry Monteil Date: Thu, 2 Mar 2017 10:27:55 +0100 Subject: [PATCH 277/370] #22487 add a comment on spkg-install. --- build/pkgs/gdb/spkg-install | 1 + 1 file changed, 1 insertion(+) diff --git a/build/pkgs/gdb/spkg-install b/build/pkgs/gdb/spkg-install index f7c62fc3fe8..cbce65083f1 100755 --- a/build/pkgs/gdb/spkg-install +++ b/build/pkgs/gdb/spkg-install @@ -8,6 +8,7 @@ fi cd src +# We add -ltinfo flag to let gdb compile on some 32bit VM, see #22487. LDFLAGS="${LDFLAGS} -L${SAGE_LOCAL}/lib -ltinfo" export LDFLAGS From a4548554c3cd4d6a64d09502e68268f6898fef51 Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Thu, 2 Mar 2017 10:30:07 +0100 Subject: [PATCH 278/370] Upgrade ncurses to version 6.0 --- build/pkgs/ncurses/SPKG.txt | 6 +- build/pkgs/ncurses/checksums.ini | 8 +- build/pkgs/ncurses/package-version.txt | 2 +- build/pkgs/ncurses/patches/xopen_source.patch | 313 ------------------ 4 files changed, 6 insertions(+), 323 deletions(-) delete mode 100644 build/pkgs/ncurses/patches/xopen_source.patch diff --git a/build/pkgs/ncurses/SPKG.txt b/build/pkgs/ncurses/SPKG.txt index 74eb9bb759d..9b8f450a1c7 100644 --- a/build/pkgs/ncurses/SPKG.txt +++ b/build/pkgs/ncurses/SPKG.txt @@ -38,8 +38,4 @@ None == Special Update/Build Instructions == -=== Patches === - - * xopen_source.patch: remove harmful check from aclocal.m4 which may - reintroduce XOPEN_SOURCE on systems where it should not be used. - +None diff --git a/build/pkgs/ncurses/checksums.ini b/build/pkgs/ncurses/checksums.ini index 24699f0ab9f..27620e7d25a 100644 --- a/build/pkgs/ncurses/checksums.ini +++ b/build/pkgs/ncurses/checksums.ini @@ -1,4 +1,4 @@ -tarball=ncurses-VERSION.tar.bz2 -sha1=c9e9e398a9bcfeb1cc005c4d3eac0998f3445ff2 -md5=b2996284ae18610aa2a4e5a968c5e1f3 -cksum=3072370532 +tarball=ncurses-VERSION.tar.gz +sha1=acd606135a5124905da770803c05f1f20dd3b21c +md5=ee13d052e1ead260d7c28071f46eefb1 +cksum=1470804880 diff --git a/build/pkgs/ncurses/package-version.txt b/build/pkgs/ncurses/package-version.txt index a2a77b0243f..e0ea36feef6 100644 --- a/build/pkgs/ncurses/package-version.txt +++ b/build/pkgs/ncurses/package-version.txt @@ -1 +1 @@ -5.9.20131221 +6.0 diff --git a/build/pkgs/ncurses/patches/xopen_source.patch b/build/pkgs/ncurses/patches/xopen_source.patch deleted file mode 100644 index cbb128b4bab..00000000000 --- a/build/pkgs/ncurses/patches/xopen_source.patch +++ /dev/null @@ -1,313 +0,0 @@ -diff -druN ncurses-5.9.20131221.orig/aclocal.m4 ncurses-5.9.20131221/aclocal.m4 ---- ncurses-5.9.20131221.orig/aclocal.m4 2013-11-23 10:20:50.000000000 -0800 -+++ ncurses-5.9.20131221/aclocal.m4 2014-02-07 06:00:43.277597929 -0800 -@@ -7198,32 +7198,3 @@ - CF_ADD_CFLAGS($cf_xopen_source) - fi - --dnl In anything but the default case, we may have system-specific setting --dnl which is still not guaranteed to provide all of the entrypoints that --dnl _XOPEN_SOURCE would yield. --if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then -- AC_MSG_CHECKING(if _XOPEN_SOURCE really is set) -- AC_TRY_COMPILE([#include ],[ --#ifndef _XOPEN_SOURCE --make an error --#endif], -- [cf_XOPEN_SOURCE_set=yes], -- [cf_XOPEN_SOURCE_set=no]) -- AC_MSG_RESULT($cf_XOPEN_SOURCE_set) -- if test $cf_XOPEN_SOURCE_set = yes -- then -- AC_TRY_COMPILE([#include ],[ --#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE --make an error --#endif], -- [cf_XOPEN_SOURCE_set_ok=yes], -- [cf_XOPEN_SOURCE_set_ok=no]) -- if test $cf_XOPEN_SOURCE_set_ok = no -- then -- AC_MSG_WARN(_XOPEN_SOURCE is lower than requested) -- fi -- else -- CF_TRY_XOPEN_SOURCE -- fi --fi --]) -diff -druN ncurses-5.9.20131221.orig/configure ncurses-5.9.20131221/configure ---- ncurses-5.9.20131221.orig/configure 2013-12-14 16:44:11.000000000 -0800 -+++ ncurses-5.9.20131221/configure 2014-02-07 06:01:25.747602176 -0800 -@@ -8119,273 +8119,6 @@ - - fi - --if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then -- echo "$as_me:8123: checking if _XOPEN_SOURCE really is set" >&5 --echo $ECHO_N "checking if _XOPEN_SOURCE really is set... $ECHO_C" >&6 -- cat >conftest.$ac_ext <<_ACEOF --#line 8126 "configure" --#include "confdefs.h" --#include --int --main () --{ -- --#ifndef _XOPEN_SOURCE --make an error --#endif -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:8141: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:8144: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:8147: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:8150: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- cf_XOPEN_SOURCE_set=yes --else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --cf_XOPEN_SOURCE_set=no --fi --rm -f conftest.$ac_objext conftest.$ac_ext -- echo "$as_me:8159: result: $cf_XOPEN_SOURCE_set" >&5 --echo "${ECHO_T}$cf_XOPEN_SOURCE_set" >&6 -- if test $cf_XOPEN_SOURCE_set = yes -- then -- cat >conftest.$ac_ext <<_ACEOF --#line 8164 "configure" --#include "confdefs.h" --#include --int --main () --{ -- --#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE --make an error --#endif -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:8179: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:8182: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:8185: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:8188: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- cf_XOPEN_SOURCE_set_ok=yes --else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --cf_XOPEN_SOURCE_set_ok=no --fi --rm -f conftest.$ac_objext conftest.$ac_ext -- if test $cf_XOPEN_SOURCE_set_ok = no -- then -- { echo "$as_me:8199: WARNING: _XOPEN_SOURCE is lower than requested" >&5 --echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;} -- fi -- else -- --echo "$as_me:8204: checking if we should define _XOPEN_SOURCE" >&5 --echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6 --if test "${cf_cv_xopen_source+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- -- cat >conftest.$ac_ext <<_ACEOF --#line 8211 "configure" --#include "confdefs.h" -- --#include --#include --#include -- --int --main () --{ -- --#ifndef _XOPEN_SOURCE --make an error --#endif -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:8230: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:8233: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:8236: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:8239: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- cf_cv_xopen_source=no --else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --cf_save="$CPPFLAGS" -- CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" -- cat >conftest.$ac_ext <<_ACEOF --#line 8248 "configure" --#include "confdefs.h" -- --#include --#include --#include -- --int --main () --{ -- --#ifdef _XOPEN_SOURCE --make an error --#endif -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:8267: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:8270: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:8273: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:8276: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- cf_cv_xopen_source=no --else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --cf_cv_xopen_source=$cf_XOPEN_SOURCE --fi --rm -f conftest.$ac_objext conftest.$ac_ext -- CPPFLAGS="$cf_save" -- --fi --rm -f conftest.$ac_objext conftest.$ac_ext -- --fi --echo "$as_me:8291: result: $cf_cv_xopen_source" >&5 --echo "${ECHO_T}$cf_cv_xopen_source" >&6 -- --if test "$cf_cv_xopen_source" != no ; then -- --CFLAGS=`echo "$CFLAGS" | \ -- sed -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -- -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?$//g'` -- --CPPFLAGS=`echo "$CPPFLAGS" | \ -- sed -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -- -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?$//g'` -- -- cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source" -- --cf_fix_cppflags=no --cf_new_cflags= --cf_new_cppflags= --cf_new_extra_cppflags= -- --for cf_add_cflags in $cf_temp_xopen_source --do --case $cf_fix_cppflags in --no) -- case $cf_add_cflags in #(vi -- -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi -- case $cf_add_cflags in -- -D*) -- cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'` -- -- test "${cf_add_cflags}" != "${cf_tst_cflags}" \ -- && test -z "${cf_tst_cflags}" \ -- && cf_fix_cppflags=yes -- -- if test $cf_fix_cppflags = yes ; then -- cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" -- continue -- elif test "${cf_tst_cflags}" = "\"'" ; then -- cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" -- continue -- fi -- ;; -- esac -- case "$CPPFLAGS" in -- *$cf_add_cflags) #(vi -- ;; -- *) #(vi -- case $cf_add_cflags in #(vi -- -D*) -- cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` -- --CPPFLAGS=`echo "$CPPFLAGS" | \ -- sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -- -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` -- -- ;; -- esac -- cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" -- ;; -- esac -- ;; -- *) -- cf_new_cflags="$cf_new_cflags $cf_add_cflags" -- ;; -- esac -- ;; --yes) -- cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" -- -- cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` -- -- test "${cf_add_cflags}" != "${cf_tst_cflags}" \ -- && test -z "${cf_tst_cflags}" \ -- && cf_fix_cppflags=no -- ;; --esac --done -- --if test -n "$cf_new_cflags" ; then -- -- CFLAGS="$CFLAGS $cf_new_cflags" --fi -- --if test -n "$cf_new_cppflags" ; then -- -- CPPFLAGS="$CPPFLAGS $cf_new_cppflags" --fi -- --if test -n "$cf_new_extra_cppflags" ; then -- -- EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" --fi -- --fi -- -- fi --fi -- - # Work around breakage on OS X - - echo "$as_me:8391: checking if SIGWINCH is defined" >&5 From d04a0d36aeaa8e04349dd02326f654ae8a3d6ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 2 Mar 2017 15:03:25 +0100 Subject: [PATCH 279/370] trac 22485 do not touch __cmp__ for the moment ! :( --- .../modules/multi_filtered_vector_space.py | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/sage/modules/multi_filtered_vector_space.py b/src/sage/modules/multi_filtered_vector_space.py index 5bbab4e8fd8..1147fd2389a 100644 --- a/src/sage/modules/multi_filtered_vector_space.py +++ b/src/sage/modules/multi_filtered_vector_space.py @@ -477,7 +477,7 @@ def _repr_(self): lines.append(s) return '\n'.join(lines) - def __eq__(self, other): + def __cmp__(self, other): """ Compare two multi-filtered vector spaces. @@ -491,23 +491,7 @@ def __eq__(self, other): sage: V == MultiFilteredVectorSpace({'a':F1, 'b':F2}) False """ - return self._filt == other._filt - - def __ne__(self, other): - """ - Compare two multi-filtered vector spaces. - - EXAMPLES:: - - sage: F1 = FilteredVectorSpace(2, 1) - sage: F2 = FilteredVectorSpace(1, 3) + FilteredVectorSpace(1,0) - sage: V = MultiFilteredVectorSpace({1:F1, 2:F2}) - sage: V != MultiFilteredVectorSpace({2:F2, 1:F1}) - False - sage: V != MultiFilteredVectorSpace({'a':F1, 'b':F2}) - True - """ - return not (self == other) + return cmp(self._filt, other._filt) def direct_sum(self, other): """ From dd001836f52dc9a526385bfa91d398bc3f5cea58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 2 Mar 2017 17:24:32 +0100 Subject: [PATCH 280/370] First version of improvement and fix of doc in geometry --- .../{geometry => discrete_geometry}/conf.py | 0 .../{geometry => discrete_geometry}/index.rst | 122 +++++++++++------- .../en/reference/hyperbolic_geometry/conf.py | 1 + .../reference/hyperbolic_geometry/index.rst | 14 ++ src/doc/en/reference/index.rst | 3 +- .../geometry/polyhedron/backend_normaliz.py | 6 +- src/sage/geometry/polyhedron/base.py | 2 +- src/sage/geometry/polyhedron/constructor.py | 29 ++++- 8 files changed, 123 insertions(+), 54 deletions(-) rename src/doc/en/reference/{geometry => discrete_geometry}/conf.py (100%) rename src/doc/en/reference/{geometry => discrete_geometry}/index.rst (69%) create mode 120000 src/doc/en/reference/hyperbolic_geometry/conf.py create mode 100644 src/doc/en/reference/hyperbolic_geometry/index.rst diff --git a/src/doc/en/reference/geometry/conf.py b/src/doc/en/reference/discrete_geometry/conf.py similarity index 100% rename from src/doc/en/reference/geometry/conf.py rename to src/doc/en/reference/discrete_geometry/conf.py diff --git a/src/doc/en/reference/geometry/index.rst b/src/doc/en/reference/discrete_geometry/index.rst similarity index 69% rename from src/doc/en/reference/geometry/index.rst rename to src/doc/en/reference/discrete_geometry/index.rst index c8f68c2892f..f62bb77a549 100644 --- a/src/doc/en/reference/geometry/index.rst +++ b/src/doc/en/reference/discrete_geometry/index.rst @@ -1,90 +1,112 @@ -Geometry -======== +Combinatorial or Discrete Geometry +================================== -Combinatorial Geometry ----------------------- +Sage includes classes for hyperplane arrangements, polyhedra, toric varieties +(including polyhedral cones and fans), triangulations and some other helper +classes and functions. -Sage includes classes for convex rational polyhedral cones and fans, Groebner -fans, lattice and reflexive polytopes (with integral coordinates), and generic -polytopes and polyhedra (with rational or numerical coordinates). +Hyperplane arrangements +----------------------- .. toctree:: :maxdepth: 1 - sage/geometry/toric_lattice - sage/geometry/cone - sage/geometry/fan - sage/geometry/fan_morphism - sage/geometry/point_collection - sage/geometry/toric_plotter + sage/geometry/hyperplane_arrangement/arrangement + sage/geometry/hyperplane_arrangement/library + sage/geometry/hyperplane_arrangement/hyperplane + sage/geometry/hyperplane_arrangement/affine_subspace + sage/geometry/hyperplane_arrangement/plot - sage/rings/polynomial/groebner_fan +Polyhedral computations +----------------------- - sage/geometry/lattice_polytope +Polyhedra +~~~~~~~~~ +.. toctree:: + :maxdepth: 1 + + sage/geometry/polyhedron/library sage/geometry/polyhedron/constructor sage/geometry/polyhedron/parent sage/geometry/polyhedron/representation - sage/geometry/polyhedron/library sage/geometry/polyhedron/plot sage/geometry/polyhedron/face sage/geometry/polyhedron/cdd_file_format + +Lattice polyhedra +~~~~~~~~~~~~~~~~~ + +.. toctree:: + :maxdepth: 1 + + sage/geometry/lattice_polytope sage/geometry/polyhedron/lattice_euclidean_group_element sage/geometry/polyhedron/palp_database sage/geometry/polyhedron/ppl_lattice_polygon sage/geometry/polyhedron/ppl_lattice_polytope - sage/geometry/polytope +Base classes for polyhedra +~~~~~~~~~~~~~~~~~~~~~~~~~~ - sage/geometry/pseudolines +.. toctree:: + :maxdepth: 1 - sage/geometry/triangulation/point_configuration - sage/geometry/triangulation/base - sage/geometry/triangulation/element + sage/geometry/polyhedron/base + sage/geometry/polyhedron/base_QQ + sage/geometry/polyhedron/base_ZZ + sage/geometry/polyhedron/base_RDF - sage/geometry/hyperplane_arrangement/arrangement - sage/geometry/hyperplane_arrangement/library - sage/geometry/hyperplane_arrangement/hyperplane - sage/geometry/hyperplane_arrangement/affine_subspace - sage/geometry/hyperplane_arrangement/plot +Backends for Polyhedra +~~~~~~~~~~~~~~~~~~~~~~ - sage/geometry/linear_expression +.. toctree:: + :maxdepth: 1 - sage/geometry/newton_polygon + sage/geometry/polyhedron/backend_cdd + sage/geometry/polyhedron/backend_field + sage/geometry/polyhedron/backend_normaliz + sage/geometry/polyhedron/backend_ppl + sage/geometry/polyhedron/double_description + sage/geometry/polyhedron/double_description_inhomogeneous - sage/geometry/ribbon_graph +Toric varieties +--------------- + +.. toctree:: + :maxdepth: 1 + + sage/geometry/toric_lattice + sage/geometry/cone + sage/geometry/fan + sage/geometry/fan_morphism + sage/geometry/point_collection + sage/geometry/toric_plotter + sage/rings/polynomial/groebner_fan -Hyperbolic Geometry -------------------- +Triangulations +-------------- .. toctree:: :maxdepth: 1 - sage/geometry/hyperbolic_space/hyperbolic_point - sage/geometry/hyperbolic_space/hyperbolic_isometry - sage/geometry/hyperbolic_space/hyperbolic_geodesic - sage/geometry/hyperbolic_space/hyperbolic_model - sage/geometry/hyperbolic_space/hyperbolic_interface + sage/geometry/triangulation/point_configuration + sage/geometry/triangulation/base + sage/geometry/triangulation/element -Backends for Polyhedral Computations ------------------------------------- +Miscellaneous +------------- .. toctree:: :maxdepth: 1 - sage/geometry/polyhedron/backend_cdd - sage/geometry/polyhedron/backend_ppl - sage/geometry/polyhedron/backend_field - sage/geometry/polyhedron/double_description - sage/geometry/polyhedron/double_description_inhomogeneous - sage/geometry/polyhedron/base - sage/geometry/polyhedron/base_QQ - sage/geometry/polyhedron/base_ZZ - sage/geometry/polyhedron/base_RDF - + sage/geometry/linear_expression + sage/geometry/newton_polygon + sage/geometry/ribbon_graph + sage/geometry/pseudolines -Internals ---------- +Helper functions +---------------- .. toctree:: :maxdepth: 1 diff --git a/src/doc/en/reference/hyperbolic_geometry/conf.py b/src/doc/en/reference/hyperbolic_geometry/conf.py new file mode 120000 index 00000000000..2bdf7e68470 --- /dev/null +++ b/src/doc/en/reference/hyperbolic_geometry/conf.py @@ -0,0 +1 @@ +../conf_sub.py \ No newline at end of file diff --git a/src/doc/en/reference/hyperbolic_geometry/index.rst b/src/doc/en/reference/hyperbolic_geometry/index.rst new file mode 100644 index 00000000000..45ede76a217 --- /dev/null +++ b/src/doc/en/reference/hyperbolic_geometry/index.rst @@ -0,0 +1,14 @@ +Hyperbolic Geometry +=================== + +.. toctree:: + :maxdepth: 1 + + sage/geometry/hyperbolic_space/hyperbolic_point + sage/geometry/hyperbolic_space/hyperbolic_isometry + sage/geometry/hyperbolic_space/hyperbolic_geodesic + sage/geometry/hyperbolic_space/hyperbolic_model + sage/geometry/hyperbolic_space/hyperbolic_interface + + +.. include:: ../footer.txt diff --git a/src/doc/en/reference/index.rst b/src/doc/en/reference/index.rst index b91e2858514..bd3247a14b4 100644 --- a/src/doc/en/reference/index.rst +++ b/src/doc/en/reference/index.rst @@ -83,7 +83,8 @@ Calculus Geometry and Topology --------------------- -* :doc:`Combinatorial Geometry ` +* :doc:`Discrete Geometry ` +* :doc:`Hyperbolic Geometry ` * :doc:`Cell Complexes and their Homology ` * :doc:`Differential Forms ` * :doc:`Manifolds ` diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py index 569f19963d8..3862022e992 100644 --- a/src/sage/geometry/polyhedron/backend_normaliz.py +++ b/src/sage/geometry/polyhedron/backend_normaliz.py @@ -2,6 +2,10 @@ """ The Normaliz backend for polyhedral computations +.. NOTE:: + This backend requires `PyNormaliz `_. + To install PyNormaliz, type :code:`sage -i pynormaliz` in the terminal. + AUTHORS: - Matthias Köppe (2016-12): initial version @@ -441,7 +445,7 @@ def integral_points(self, threshold=10000): INPUT: - ``threshold`` -- integer (default: 10000); use the naïve - algorithm as long as the bounding box is smaller than this + algorithm as long as the bounding box is smaller than this OUTPUT: diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 2cb1a18e80e..261b3f21387 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2947,7 +2947,7 @@ def face_truncation(self, face, linear_coefficients=None, cut_frac=None): ``linear_coefficients``. To determine how deep the truncation is done, the method uses the - parameter ``cut_frac``. By default it is equal to `\frac{1}{3}. Once + parameter ``cut_frac``. By default it is equal to `\frac{1}{3}`. Once the normal vector of the cutting hyperplane is chosen, the vertices of polyhedron are evaluated according to the corresponding linear function. The parameter `\frac{1}{3}` means that the cutting diff --git a/src/sage/geometry/polyhedron/constructor.py b/src/sage/geometry/polyhedron/constructor.py index 26e00bca7c2..e21af78a425 100644 --- a/src/sage/geometry/polyhedron/constructor.py +++ b/src/sage/geometry/polyhedron/constructor.py @@ -188,6 +188,33 @@ A 2-dimensional polyhedron in (Number Field in sqrt3 with defining polynomial x^2 - 3)^2 defined as the convex hull of 3 vertices +Base classes +------------ + +Depending on the chosen base ring, a specific class is used to represent the polyhedron object. + +.. SEEALSO:: + - :mod:`Base class for polyhedra ` + - :mod:`Base class for polyhedra over integers ` + - :mod:`Base class for polyhedra over rationals ` + - :mod:`Base class for polyhedra over RDF ` + +The most important base class is **Base class for polyhedra** from which other base classes and backends inherit. + +Backends +-------- + +There are different backends available to deal with polyhedron objects. + +.. SEEALSO:: + - :mod:`cdd backend for polyhedra ` + - :mod:`field backend for polyhedra ` + - :mod:`normaliz backend for polyhedra ` + - :mod:`ppl backend for polyhedra ` + +.. NOTE:: + Depending on the backend used, it may occur that different methods are + available or not. Appendix -------- @@ -195,7 +222,7 @@ REFERENCES: Komei Fukuda's `FAQ in Polyhedral Computation - `_ + `_ AUTHORS: From e6beae2ab804628a3004063203c43fe867864649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 2 Mar 2017 17:40:40 +0100 Subject: [PATCH 281/370] Corrected a title --- src/doc/en/reference/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/en/reference/index.rst b/src/doc/en/reference/index.rst index bd3247a14b4..c31aa71f2fd 100644 --- a/src/doc/en/reference/index.rst +++ b/src/doc/en/reference/index.rst @@ -83,7 +83,7 @@ Calculus Geometry and Topology --------------------- -* :doc:`Discrete Geometry ` +* :doc:`Combinatorial and Discrete Geometry ` * :doc:`Hyperbolic Geometry ` * :doc:`Cell Complexes and their Homology ` * :doc:`Differential Forms ` From eb4dfac0e46749c72faada3d59d3b75b25e69662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 2 Mar 2017 18:09:51 +0100 Subject: [PATCH 282/370] pep8 conventions --- src/sage/homology/simplicial_complex.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index 356c024df30..6744807b33e 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -1597,7 +1597,7 @@ def h_triangle(self): from sage.arith.all import binomial ret = [[0]*(i+1) for i in range(self.dimension() + 2)] f = self.f_triangle() - for i,row in enumerate(ret): + for i, row in enumerate(ret): for j in range(i+1): row[j] = sum((-1)**(j-k) * binomial(i-k, j-k) * f[i][k] for k in range(j+1)) @@ -2954,7 +2954,7 @@ def is_shelling_order(self, shelling_order, certificate=False): return False cur_complex = SimplicialComplex([]) - for i,F in enumerate(shelling_order): + for i, F in enumerate(shelling_order): if i > 0: # The shelling condition is precisely that intersection is # a pure complex of one dimension less and stop if this fails @@ -3423,10 +3423,11 @@ def stellar_subdivision(self,simplex,inplace=False,is_mutable=True): - A simplicial complex obtained by the stellar subdivision of the face `simplex`. If inplace is `True`, the object `self` was modified, otherwise a new simplicial complex is returned. The parameter - `is_mutable` determines the mutability of the output. + `is_mutable` determines the mutability of the output. EXAMPLES:: + sage: SC = SimplicialComplex([[0,1,2],[1,2,3]]) sage: F1 = Simplex([1,2]) sage: F2 = Simplex([1,3]) @@ -3478,7 +3479,7 @@ def stellar_subdivision(self,simplex,inplace=False,is_mutable=True): else: vertex_label += 1 new_vertex = SimplicialComplex([[vertex_label]]) - new_faces = new_vertex.join(working_complex.star(simplex),rename_vertices=False) + new_faces = new_vertex.join(working_complex.star(simplex), rename_vertices=False) for face in new_faces.facets(): working_complex.add_face(face) From 9ed526095a4f3b9e6ccbbaab4624ee5d7b9cd829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 2 Mar 2017 18:13:13 +0100 Subject: [PATCH 283/370] Corrected a silly typo --- src/sage/homology/simplicial_complex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index 6744807b33e..3ab11d3ac2b 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -3486,7 +3486,7 @@ def stellar_subdivision(self,simplex,inplace=False,is_mutable=True): working_complex.remove_face(simplex) if not is_mutable: - worksing_complex.set_immutable() + working_complex.set_immutable() if not inplace: return working_complex From 4d9b5c50a9cdb5953507ec85f5b2f6c7e44ce646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 2 Mar 2017 18:26:23 +0100 Subject: [PATCH 284/370] Added a indentation for doc to build --- src/sage/geometry/polyhedron/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index d21d34f7f18..3a914e76d2a 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2159,8 +2159,8 @@ def is_inscribed(self, certificate=False): INPUT: - - ``certificate`` : boolean (default: False). Specifies whether to - return the circumcenter, if found. + - ``certificate`` -- (default: ``False``) boolean; specifies whether to + return the circumcenter, if found OUTPUT: From 38a89ebcb63d09a8b2e00e801d9360d138c42baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 2 Mar 2017 18:33:58 +0100 Subject: [PATCH 285/370] Added missing linespacing --- src/sage/geometry/polyhedron/backend_normaliz.py | 1 + src/sage/geometry/polyhedron/constructor.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py index 3862022e992..276b8a7df95 100644 --- a/src/sage/geometry/polyhedron/backend_normaliz.py +++ b/src/sage/geometry/polyhedron/backend_normaliz.py @@ -3,6 +3,7 @@ The Normaliz backend for polyhedral computations .. NOTE:: + This backend requires `PyNormaliz `_. To install PyNormaliz, type :code:`sage -i pynormaliz` in the terminal. diff --git a/src/sage/geometry/polyhedron/constructor.py b/src/sage/geometry/polyhedron/constructor.py index e21af78a425..8beb37d995d 100644 --- a/src/sage/geometry/polyhedron/constructor.py +++ b/src/sage/geometry/polyhedron/constructor.py @@ -194,6 +194,7 @@ Depending on the chosen base ring, a specific class is used to represent the polyhedron object. .. SEEALSO:: + - :mod:`Base class for polyhedra ` - :mod:`Base class for polyhedra over integers ` - :mod:`Base class for polyhedra over rationals ` @@ -207,12 +208,14 @@ There are different backends available to deal with polyhedron objects. .. SEEALSO:: + - :mod:`cdd backend for polyhedra ` - :mod:`field backend for polyhedra ` - :mod:`normaliz backend for polyhedra ` - :mod:`ppl backend for polyhedra ` .. NOTE:: + Depending on the backend used, it may occur that different methods are available or not. From dbb3702a7617b8e11fa51603c5e6459c4f2e6474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 2 Mar 2017 21:15:23 +0100 Subject: [PATCH 286/370] a nice little collection of typos --- build/pkgs/zn_poly/SPKG.txt | 2 +- src/doc/en/constructions/groups.rst | 2 +- src/sage/algebras/commutative_dga.py | 4 ++-- .../free_algebra_element_letterplace.pyx | 2 +- src/sage/calculus/desolvers.py | 2 +- .../finite_complex_reflection_groups.py | 2 +- src/sage/combinat/diagram_algebras.py | 2 +- src/sage/combinat/growth.py | 2 +- src/sage/combinat/posets/poset_examples.py | 4 ++-- .../rigged_configuration_element.py | 4 ++-- .../combinat/root_system/weyl_characters.py | 2 +- src/sage/combinat/sf/sfa.py | 2 +- src/sage/geometry/ribbon_graph.py | 6 +++--- src/sage/geometry/triangulation/data.h | 2 +- src/sage/graphs/generic_graph.py | 2 +- src/sage/graphs/strongly_regular_db.pyx | 2 +- src/sage/groups/abelian_gps/values.py | 2 +- src/sage/groups/group_exp.py | 2 +- src/sage/groups/matrix_gps/orthogonal.py | 6 +++--- src/sage/homology/simplicial_set.py | 4 ++-- .../homology/simplicial_set_constructions.py | 2 +- src/sage/interfaces/expect.py | 6 +++--- src/sage/interfaces/r.py | 2 +- .../libs/linkages/padics/fmpz_poly_unram.pxi | 2 +- src/sage/manifolds/differentiable/metric.py | 2 +- src/sage/manifolds/subset.py | 2 +- src/sage/matrix/matrix_generic_sparse.pyx | 2 +- src/sage/matrix/special.py | 2 +- src/sage/misc/sage_input.py | 4 ++-- src/sage/misc/sagedoc.py | 2 +- src/sage/misc/sageinspect.py | 2 +- src/sage/modular/btquotients/btquotient.py | 4 ++-- .../modform_hecketriangle/constructor.py | 2 +- src/sage/parallel/map_reduce.py | 4 ++-- src/sage/quivers/morphism.py | 2 +- src/sage/rings/padics/discrete_value_group.py | 9 +++++---- src/sage/rings/padics/misc.py | 18 ++++++++++-------- src/sage/rings/ring.pyx | 2 +- src/sage/sat/solvers/cryptominisat/decl.pxd | 2 +- .../cryptominisat/solverconf_helper.cpp | 2 +- .../elliptic_curves/ell_rational_field.py | 2 +- .../elliptic_curves/isogeny_small_degree.py | 2 +- .../schemes/product_projective/morphism.py | 2 +- .../schemes/projective/projective_morphism.py | 2 +- src/sage/schemes/toric/weierstrass.py | 2 +- src/sage/symbolic/expression.pyx | 2 +- 46 files changed, 72 insertions(+), 69 deletions(-) diff --git a/build/pkgs/zn_poly/SPKG.txt b/build/pkgs/zn_poly/SPKG.txt index a4679c5f7d3..2a660f1cef5 100644 --- a/build/pkgs/zn_poly/SPKG.txt +++ b/build/pkgs/zn_poly/SPKG.txt @@ -147,7 +147,7 @@ the file src/COPYING for details. * Ticket #8280: cygwin: zn_poly shared library named incorrectly on cygwin === zn_poly-0.9.p1 (David Kirkby, June 29th, 2009) === - * Ticket #6443 A GNUism in zn_poly-0.9.p0 causes linking problems wiith Sun's linker + * Ticket #6443 A GNUism in zn_poly-0.9.p0 causes linking problems with Sun's linker This was an easy fix - just substitue -soname for -h in src/makemakefile.py I did this with a sed script in spkg-install diff --git a/src/doc/en/constructions/groups.rst b/src/doc/en/constructions/groups.rst index 4d9a10f8846..229ce7d315c 100644 --- a/src/doc/en/constructions/groups.rst +++ b/src/doc/en/constructions/groups.rst @@ -538,7 +538,7 @@ order 16 as a semidirect product of cyclic groups. The following table shows the groups of order 15 or less, and how to construct them in Sage. Repeated commands have been omitted but instead are described -by the following exmples. +by the following exemples. The cyclic group of order `n` can be crated with a single command: diff --git a/src/sage/algebras/commutative_dga.py b/src/sage/algebras/commutative_dga.py index 7824d219e8a..022bdad6d5d 100644 --- a/src/sage/algebras/commutative_dga.py +++ b/src/sage/algebras/commutative_dga.py @@ -1292,13 +1292,13 @@ def degree(self, total=False): def is_homogeneous(self, total=False): r""" - Return ``True`` if ``self`` is homogenous and ``False`` otherwise. + Return ``True`` if ``self`` is homogeneous and ``False`` otherwise. INPUT: - ``total`` -- boolean (default ``False``); only used in the multi-graded case, in which case if ``True``, check to see - if ``self`` is homogenenous with respect to total degree + if ``self`` is homogeneous with respect to total degree EXAMPLES:: diff --git a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx index 0cdc3ca9940..f6a26400582 100644 --- a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx +++ b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx @@ -670,7 +670,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): sage: G.ring() is F.current_ring() True - Since the element `p` is of degree 5, it is no surrprise + Since the element `p` is of degree 5, it is no surprise that its reductions with respect to the original generators of `I` (of degree 2), or with respect to `G` (Groebner basis with degree bound 4), or with respect to the Groebner basis diff --git a/src/sage/calculus/desolvers.py b/src/sage/calculus/desolvers.py index 5e02c964b74..516c2888b89 100644 --- a/src/sage/calculus/desolvers.py +++ b/src/sage/calculus/desolvers.py @@ -524,7 +524,7 @@ def sanitize_var(exprs): soln=soln.sage() if is_SymbolicEquation(soln) and soln.lhs() == dvar: # Remark: Here we do not check that the right hand side does not depend on dvar. - # This probably will not hapen for soutions obtained via ode2, anyway. + # This probably will not happen for soutions obtained via ode2, anyway. soln = soln.rhs() if show_method: return [soln,maxima_method.str()] diff --git a/src/sage/categories/finite_complex_reflection_groups.py b/src/sage/categories/finite_complex_reflection_groups.py index e5189064794..7209298e024 100644 --- a/src/sage/categories/finite_complex_reflection_groups.py +++ b/src/sage/categories/finite_complex_reflection_groups.py @@ -92,7 +92,7 @@ def WellGenerated(self): .. SEEALSO:: - :meth:`ComplexRelfectionGroups.Finite.ParentMethods.is_well_generated` + :meth:`ComplexReflectionGroups.Finite.ParentMethods.is_well_generated` EXAMPLES:: diff --git a/src/sage/combinat/diagram_algebras.py b/src/sage/combinat/diagram_algebras.py index 64e96c3554a..fd26541c4cd 100644 --- a/src/sage/combinat/diagram_algebras.py +++ b/src/sage/combinat/diagram_algebras.py @@ -952,7 +952,7 @@ def symmetric_diagrams(self,l=None,perm=None): def from_involution_permutation_triple(self, D1_D2_pi): r""" - Construct a Bruaer diagram of ``self`` from an involution + Construct a Brauer diagram of ``self`` from an involution permutation triple. A Brauer diagram can be represented as a triple where the first diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py index f941c9934de..ceda0153762 100644 --- a/src/sage/combinat/growth.py +++ b/src/sage/combinat/growth.py @@ -315,7 +315,7 @@ def rotate(self): Return the growth diagram with the filling rotated by 180 degrees. For RSK-growth diagrams and rectangular fillings, this - corresponds to evacutation of the P- and the Q-symbol. + corresponds to evacuation of the P- and the Q-symbol. EXAMPLES:: diff --git a/src/sage/combinat/posets/poset_examples.py b/src/sage/combinat/posets/poset_examples.py index 550c4d6001c..06a83e26438 100644 --- a/src/sage/combinat/posets/poset_examples.py +++ b/src/sage/combinat/posets/poset_examples.py @@ -1022,12 +1022,12 @@ def TetrahedralPoset(n, *colors, **labels): REFERENCES: - .. [Striker2011] \J. Striker. *A unifying poset perpective on + .. [Striker2011] \J. Striker. *A unifying poset perspective on alternating sign matrices, plane partitions, Catalan objects, tournaments, and tableaux*, Advances in Applied Mathematics 46 (2011), no. 4, 583-609. :arXiv:`1408.5391` """ - n=n-1 + n = n - 1 try: n = Integer(n) except TypeError: diff --git a/src/sage/combinat/rigged_configurations/rigged_configuration_element.py b/src/sage/combinat/rigged_configurations/rigged_configuration_element.py index 48ac3286ccc..2d9462e240d 100644 --- a/src/sage/combinat/rigged_configurations/rigged_configuration_element.py +++ b/src/sage/combinat/rigged_configurations/rigged_configuration_element.py @@ -8,7 +8,7 @@ AUTHORS: - Travis Scrimshaw (2010-09-26): Initial version -- Travis Scrimshaw (2012-10-25): Added virtual rigged confingurations +- Travis Scrimshaw (2012-10-25): Added virtual rigged configurations """ #***************************************************************************** @@ -308,7 +308,7 @@ def _repr_(self): def _repr_vertical(self): """ - Return the string representation of ``self`` verically. + Return the string representation of ``self`` vertically. EXAMPLES:: diff --git a/src/sage/combinat/root_system/weyl_characters.py b/src/sage/combinat/root_system/weyl_characters.py index 30133cb2b93..fee7a56142e 100644 --- a/src/sage/combinat/root_system/weyl_characters.py +++ b/src/sage/combinat/root_system/weyl_characters.py @@ -70,7 +70,7 @@ class WeylCharacterRing(CombinatorialFreeModule): [R(0,0,0), R(1,0,0), R(1,1,0)] Here ``R(1)``, ``R(fw1)``, and ``R(fw2)`` are irreducible representations - with highest weight vectors `0`, `\Lambda_1`, and `\Lambda_2` respecitively + with highest weight vectors `0`, `\Lambda_1`, and `\Lambda_2` respectively (the first two fundamental weights). For type `A` (also `G_2`, `F_4`, `E_6` and `E_7`) we will take as the diff --git a/src/sage/combinat/sf/sfa.py b/src/sage/combinat/sf/sfa.py index c62e860ea15..9362353925c 100644 --- a/src/sage/combinat/sf/sfa.py +++ b/src/sage/combinat/sf/sfa.py @@ -4785,7 +4785,7 @@ def verschiebung(self, n): ....: for lam in Partitions(6) ) True """ - # Convert to the complete homogenenous basis, there apply + # Convert to the complete homogeneous basis, there apply # Verschiebung componentwise, then convert back. parent = self.parent() h = parent.realization_of().homogeneous() diff --git a/src/sage/geometry/ribbon_graph.py b/src/sage/geometry/ribbon_graph.py index 1cef87c96da..9f41a1f39ae 100644 --- a/src/sage/geometry/ribbon_graph.py +++ b/src/sage/geometry/ribbon_graph.py @@ -88,12 +88,12 @@ def _clean(l): """ return [list(elt) for elt in l if elt] + class RibbonGraph(SageObject, UniqueRepresentation): r""" - A ribbon graph codified as two elements of a certain permutation. - group. + A ribbon graph codified as two elements of a certain permutation group. - A comprenhensive introduction on the topic can be found in the beginning + A comprehensive introduction on the topic can be found in the beginning of [GGD2011]_ Chapter 4. More concretely, we will use a variation of what is called in the reference "The permutation representation pair of a dessin". Note that in that book, ribbon graphs are called "dessins diff --git a/src/sage/geometry/triangulation/data.h b/src/sage/geometry/triangulation/data.h index 65901667951..246ae48ceea 100644 --- a/src/sage/geometry/triangulation/data.h +++ b/src/sage/geometry/triangulation/data.h @@ -65,7 +65,7 @@ struct vertices_order }; -// simplical complex, data compressed by vertices_to_simplex +// simplicial complex, data compressed by vertices_to_simplex class compact_simplices: public std::vector { private: diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 490bf1c9562..c5b4934c545 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -12326,7 +12326,7 @@ def is_chordal(self, certificate = False, algorithm = "B"): sage: (2*g).is_chordal() True - Let us check the certificate given by Sage is indeed a perfect elimintion order:: + Let us check the certificate given by Sage is indeed a perfect elimination order:: sage: (_, peo) = g.is_chordal(certificate = True) sage: for v in peo: diff --git a/src/sage/graphs/strongly_regular_db.pyx b/src/sage/graphs/strongly_regular_db.pyx index cb1053d2fbc..5a241fbd997 100644 --- a/src/sage/graphs/strongly_regular_db.pyx +++ b/src/sage/graphs/strongly_regular_db.pyx @@ -1693,7 +1693,7 @@ def eigenmatrix(int v,int k,int l,int mu): The eigenvalues of `J` are `v` with multiplicity 1, and 0 with multiplicity `v-1`. Thus the eigenvalue of `A'` corresponding to the 1-dimension - `k`-eigenspace of `A` is `v-k-1`. Respecively, the eigenvalues of `A'` + `k`-eigenspace of `A` is `v-k-1`. Respectively, the eigenvalues of `A'` corresponding to `t`-eigenspace of `A`, with `t` unequal to `k`, equals `-t-1`. The 1st eigenmatrix `P` of the C-algebra `C[A]` generated by `A` encodes this eigenvalue information in its three colums; the 2nd (resp. 3rd) diff --git a/src/sage/groups/abelian_gps/values.py b/src/sage/groups/abelian_gps/values.py index 32b2ab77687..3c6b22bfc7b 100644 --- a/src/sage/groups/abelian_gps/values.py +++ b/src/sage/groups/abelian_gps/values.py @@ -156,7 +156,7 @@ class AbelianGroupWithValuesEmbedding(Morphism): - ``domain`` -- a :class:`AbelianGroupWithValues_class` - - ``codomain`` -- the values group (need not be in the cateory of + - ``codomain`` -- the values group (need not be in the category of groups, e.g. symbolic ring). EXAMPLES:: diff --git a/src/sage/groups/group_exp.py b/src/sage/groups/group_exp.py index d8f909f9ea8..acc52a68d87 100644 --- a/src/sage/groups/group_exp.py +++ b/src/sage/groups/group_exp.py @@ -289,7 +289,7 @@ def _repr_(self): def _element_constructor_(self, x): r""" - Construct the multipliciative group element, which wraps the additive + Construct the multiplicative group element, which wraps the additive group element `x`. EXAMPLES:: diff --git a/src/sage/groups/matrix_gps/orthogonal.py b/src/sage/groups/matrix_gps/orthogonal.py index 472ac24926c..8278814eea4 100644 --- a/src/sage/groups/matrix_gps/orthogonal.py +++ b/src/sage/groups/matrix_gps/orthogonal.py @@ -3,7 +3,7 @@ The general orthogonal group `GO(n,R)` consists of all `n\times n` matrices over the ring `R` preserving an `n`-ary positive definite -quadratic form. In cases where there are muliple non-isomorphic +quadratic form. In cases where there are multiple non-isomorphic quadratic forms, additional data needs to be specified to disambiguate. The special orthogonal group is the normal subgroup of matrices of determinant one. @@ -140,7 +140,7 @@ def GO(n, R, e=0, var='a'): The general orthogonal group `GO(n,R)` consists of all `n\times n` matrices over the ring `R` preserving an `n`-ary positive definite - quadratic form. In cases where there are muliple non-isomorphic + quadratic form. In cases where there are multiple non-isomorphic quadratic forms, additional data needs to be specified to disambiguate. @@ -214,7 +214,7 @@ def SO(n, R, e=None, var='a'): The special orthogonal group `GO(n,R)` consists of all `n\times n` matrices with determinant one over the ring `R` preserving an `n`-ary positive definite quadratic form. In cases where there are - muliple non-isomorphic quadratic forms, additional data needs to + multiple non-isomorphic quadratic forms, additional data needs to be specified to disambiguate. .. note:: diff --git a/src/sage/homology/simplicial_set.py b/src/sage/homology/simplicial_set.py index 1f3de357221..fc00ef399b4 100644 --- a/src/sage/homology/simplicial_set.py +++ b/src/sage/homology/simplicial_set.py @@ -135,7 +135,7 @@ sage: simplicial_sets.Point() == simplicial_sets.Point() True -You can construct subsimplical sets by specifying a list of simplices, +You can construct subsimplicial sets by specifying a list of simplices, and then you can define the quotient simplicial set:: sage: X = simplicial_sets.Simplex(2) @@ -488,7 +488,7 @@ def __lt__(self, other): sage: v = AbstractSimplex(0) sage: w = AbstractSimplex(0) - At this point, comparision between v and w is random, based on + At this point, comparison between v and w is random, based on their location in memory. :: sage: v < w and w < v diff --git a/src/sage/homology/simplicial_set_constructions.py b/src/sage/homology/simplicial_set_constructions.py index ffaf973aff9..245c570eaca 100644 --- a/src/sage/homology/simplicial_set_constructions.py +++ b/src/sage/homology/simplicial_set_constructions.py @@ -1157,7 +1157,7 @@ def __init__(self, maps=None, vertex_name=None): simplex comes from a single `Y_i`, it inherits its name. Otherwise it must come from a simplex (or several) in `X`, and then it inherits one of those names, and it should be - the first alphabetically. For examnple, if vertices `v`, `w`, + the first alphabetically. For example, if vertices `v`, `w`, and `z` in `X` are glued together, then the resulting vertex in the pushout will be called `v`. diff --git a/src/sage/interfaces/expect.py b/src/sage/interfaces/expect.py index c86a9bdddba..c283f21ca68 100644 --- a/src/sage/interfaces/expect.py +++ b/src/sage/interfaces/expect.py @@ -1432,17 +1432,17 @@ def __del__(self): class StdOutContext: """ - A context in which all communation between Sage and a subprocess + A context in which all communication between Sage and a subprocess interfaced via pexpect is printed to stdout. """ def __init__(self, interface, silent=False, stdout=None): """ - Construct a new context in which all communation between Sage + Construct a new context in which all communication between Sage and a subprocess interfaced via pexpect is printed to stdout. INPUT: - - ``interface`` - the interface whose communcation shall be dumped. + - ``interface`` - the interface whose communication shall be dumped. - ``silent`` - if ``True`` this context does nothing diff --git a/src/sage/interfaces/r.py b/src/sage/interfaces/r.py index 504ac1f63cb..f29b90bfb61 100644 --- a/src/sage/interfaces/r.py +++ b/src/sage/interfaces/r.py @@ -222,7 +222,7 @@ possible via the -i and -o options. Do "%R?" in a standalone cell to get the documentation. -- %%R alows the execution in R of the whole text of a cell, with +- %%R allows the execution in R of the whole text of a cell, with similar options (do "%%R?" in a standalone cell for documentation). diff --git a/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi b/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi index 569e0ef6fa0..f5915a824be 100644 --- a/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi +++ b/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi @@ -587,7 +587,7 @@ cdef int cteichmuller(celement out, celement value, long prec, PowComputer_ prim We use Hensel lifting to solve the equation `f(T)=T^q-T`. Instead of dividing by the derivative of `f`, we divide by `( q - 1 )` whose first digits coincide with `f'`. This does probably not yield quadratic - convergence but taking inverses would be much more expansive than what is + convergence but taking inverses would be much more expensive than what is done here. """ diff --git a/src/sage/manifolds/differentiable/metric.py b/src/sage/manifolds/differentiable/metric.py index c687d4e6ec6..f6d20a049d9 100644 --- a/src/sage/manifolds/differentiable/metric.py +++ b/src/sage/manifolds/differentiable/metric.py @@ -714,7 +714,7 @@ def connection(self, name=None, latex_name=None): EXAMPLES: - Levi-Civitation connection associated with the Euclidean metric on + Levi-Civita connection associated with the Euclidean metric on `\RR^3`:: sage: M = Manifold(3, 'R^3', start_index=1) diff --git a/src/sage/manifolds/subset.py b/src/sage/manifolds/subset.py index 0d1e72f5d92..fea82d3886d 100644 --- a/src/sage/manifolds/subset.py +++ b/src/sage/manifolds/subset.py @@ -98,7 +98,7 @@ class :class:`~sage.structure.parent.Parent`. - ``name`` -- string; name (symbol) given to the subset - ``latex_name`` -- (default: ``None``) string; LaTeX symbol to denote the subset; if none are provided, it is set to ``name`` - - ``category`` -- (default: ``None``) to specify the categeory; + - ``category`` -- (default: ``None``) to specify the category; if ``None``, the category for generic subsets is used EXAMPLES: diff --git a/src/sage/matrix/matrix_generic_sparse.pyx b/src/sage/matrix/matrix_generic_sparse.pyx index 4317088bea0..617623d3485 100644 --- a/src/sage/matrix/matrix_generic_sparse.pyx +++ b/src/sage/matrix/matrix_generic_sparse.pyx @@ -199,7 +199,7 @@ cdef class Matrix_generic_sparse(matrix_sparse.Matrix_sparse): if entries is None or not entries: # be careful here. We might get entries set to be an empty list # because of the code implemented in matrix_space.MatrixSpace - # So the condtion + # So the condition # if entries is None or not entries: # ... # is valid. But diff --git a/src/sage/matrix/special.py b/src/sage/matrix/special.py index 33bc6a71b9e..a0e7ec7a936 100644 --- a/src/sage/matrix/special.py +++ b/src/sage/matrix/special.py @@ -2697,7 +2697,7 @@ def random_subspaces_matrix(parent, rank=None): OUTPUT: - A matrix whose natrual basis vectors for its four subspaces, when + A matrix whose natural basis vectors for its four subspaces, when computed, have reasonably sized, integral valued, entries. .. note:: diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py index 562d164dece..aeadc0ec94b 100644 --- a/src/sage/misc/sage_input.py +++ b/src/sage/misc/sage_input.py @@ -112,8 +112,8 @@ sage: test_qq_formatter(qq_sage_input_v2) [-ZZ(5)/7, -ZZ(5)/7, -5/7, -5/7, ZZ(3)/1, ZZ(3)/1, 3/1, 3/1] -Next let's get rid of the divisions by 1. These are more complicated, -since if we're not careful we'll get results in \ZZ instead of \QQ.:: +Next let us get rid of the divisions by 1. These are more complicated, +since if we are not careful we will get results in `\ZZ` instead of `\QQ`:: sage: def qq_sage_input_v3(self, sib, coerced): ....: if self.denominator() == 1: diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py index bf2a58a315d..3d77c988d86 100644 --- a/src/sage/misc/sagedoc.py +++ b/src/sage/misc/sagedoc.py @@ -54,7 +54,7 @@ # should instead by taken care of by MathJax -- and nonmath, which # should be done always. -# Math substititions: don't forget the leading backslash '\\'. These +# Math substitutions: don't forget the leading backslash '\\'. These # are done using regular expressions, so it works best to also make # the strings raw: r'\\blah'. math_substitutes = [ diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index 0e0f18d63d7..6bfa9388b85 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -2115,7 +2115,7 @@ class Element: # First, we deal with nested classes. Their name contains a dot, and we # have a special function for that purpose. if (not hasattr(obj, '__class__')) or hasattr(obj,'__metaclass__'): - # That hapens for ParentMethods + # That happens for ParentMethods # of categories if '.' in obj.__name__ or '.' in getattr(obj,'__qualname__',''): return _sage_getsourcelines_name_with_dot(obj) diff --git a/src/sage/modular/btquotients/btquotient.py b/src/sage/modular/btquotients/btquotient.py index 7f2df962eba..2f58ee4d51c 100644 --- a/src/sage/modular/btquotients/btquotient.py +++ b/src/sage/modular/btquotients/btquotient.py @@ -105,7 +105,7 @@ class computes and stores the data corresponding to the Here usual denotes that we have rescaled gamma to have unit determinant, and so that the result is honestly an element - of the arithmetic quarternion group under consideration. In + of the arithmetic quaternion group under consideration. In practice we store integral multiples and keep track of the powers of `p`. @@ -280,7 +280,7 @@ def igamma(self, embedding=None, scale=1): Image under gamma. Elements of the arithmetic group can be regarded as elements - of the global quarterion order, and hence may be represented + of the global quaternion order, and hence may be represented exactly. This function computes the image of such an element under the local splitting and returns the corresponding `p`-adic approximation. diff --git a/src/sage/modular/modform_hecketriangle/constructor.py b/src/sage/modular/modform_hecketriangle/constructor.py index cce2069b949..5c2c915f5d2 100644 --- a/src/sage/modular/modform_hecketriangle/constructor.py +++ b/src/sage/modular/modform_hecketriangle/constructor.py @@ -57,7 +57,7 @@ def rational_type(f, n=ZZ(3), base_ring=ZZ): - ``homo`` -- ``True`` if `f` also has a homogeneous numerator. - - ``k`` -- ``None`` if `f` is not homogeneneous, otherwise + - ``k`` -- ``None`` if `f` is not homogeneous, otherwise the weight of `f` (which is the first component of its degree). diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py index 56c516508b8..779b6d5739e 100644 --- a/src/sage/parallel/map_reduce.py +++ b/src/sage/parallel/map_reduce.py @@ -854,7 +854,7 @@ class RESetMapReduce(object): are actually produced. Furthermore, if ``post_process(x)`` returns ``None``, then ``x`` won't be output at all. - Decription of the map/reduce operation: + Description of the map/reduce operation: - ``map_function=f`` -- (default to ``None``) - ``reduce_function=red`` -- (default to ``None``) @@ -1316,7 +1316,7 @@ def random_worker(self): OUTPUT: - A worker for ``self`` chosed at random + A worker for ``self`` choosed at random EXAMPLES:: diff --git a/src/sage/quivers/morphism.py b/src/sage/quivers/morphism.py index d1e5beaef11..231adfe54b4 100644 --- a/src/sage/quivers/morphism.py +++ b/src/sage/quivers/morphism.py @@ -1253,7 +1253,7 @@ def lift(self, x): def scalar_mult(self, scalar): r""" - Return the result of the scalar multiplcation ``scalar * self``, + Return the result of the scalar multiplication ``scalar * self``, where ``scalar`` is an element of the base ring `k`. EXAMPLES:: diff --git a/src/sage/rings/padics/discrete_value_group.py b/src/sage/rings/padics/discrete_value_group.py index 0ad2cf5b630..4f7fa1153c9 100644 --- a/src/sage/rings/padics/discrete_value_group.py +++ b/src/sage/rings/padics/discrete_value_group.py @@ -1,7 +1,7 @@ r""" Value groups of discrete valuations -This file defines additive subgroups of \QQ generated by a rational number. +This file defines additive subgroups of `\QQ` generated by a rational number. AUTHORS: @@ -23,9 +23,10 @@ category = Modules(ZZ) + class DiscreteValueGroup(UniqueRepresentation, Parent): r""" - The value group of a discrete valuation, an additive subgroup of \QQ + The value group of a discrete valuation, an additive subgroup of `\QQ` generated by ``generator``. INPUT: @@ -124,7 +125,7 @@ def _repr_(self): def __add__(self, other): r""" - Return the subgroup of \QQ generated by this group and ``other``. + Return the subgroup of `\QQ` generated by this group and ``other``. INPUT: @@ -205,7 +206,7 @@ def index(self, other): if not isinstance(other, DiscreteValueGroup): raise ValueError("`other` must be a DiscreteValueGroup") if other._generator not in self: - raise ValueError("`other` must be a subgroup of this group") + raise ValueError("`other must be a subgroup of this group") if other._generator == 0: if self._generator == 0: return ZZ(1) diff --git a/src/sage/rings/padics/misc.py b/src/sage/rings/padics/misc.py index 0c2e88a408e..893fc842a95 100644 --- a/src/sage/rings/padics/misc.py +++ b/src/sage/rings/padics/misc.py @@ -1,7 +1,7 @@ -""" +r""" Miscellaneous Functions -This file contains some miscellaneous functions used by p-adics. +This file contains two miscellaneous functions used by `p`-adics. - ``min`` -- a version of ``min`` that returns `\infty` on empty input. - ``max`` -- a version of ``max`` that returns `-\infty` on empty input. @@ -27,10 +27,11 @@ from six.moves.builtins import max as python_max from sage.rings.infinity import infinity + def min(*L): - """ - Returns the minimum of the inputs, where the minimum of the empty - list is ``infinity``. + r""" + Return the minimum of the inputs, where the minimum of the empty + list is `\infty`. EXAMPLES:: @@ -47,10 +48,11 @@ def min(*L): except ValueError: return infinity + def max(*L): - """ - Returns the maximum of the inputs, where the maximum of the empty - list is ``-infinity``. + r""" + Return the maximum of the inputs, where the maximum of the empty + list is `-\infty`. EXAMPLES:: diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx index e8e0f3bb102..d8e15c703bb 100644 --- a/src/sage/rings/ring.pyx +++ b/src/sage/rings/ring.pyx @@ -2409,7 +2409,7 @@ cdef class Algebra(Ring): except AttributeError: raise AttributeError("Basis is not yet implemented for this algebra.") try: - # TODO: The following code is specific to the quaterion algebra + # TODO: The following code is specific to the quaternion algebra # and should belong there #step 1 for i in range(1,4): diff --git a/src/sage/sat/solvers/cryptominisat/decl.pxd b/src/sage/sat/solvers/cryptominisat/decl.pxd index b859a00026e..34773358063 100644 --- a/src/sage/sat/solvers/cryptominisat/decl.pxd +++ b/src/sage/sat/solvers/cryptominisat/decl.pxd @@ -80,7 +80,7 @@ cdef extern from "Solver.h" namespace "CMSat": #another. NOTE: This precludes using a lot of the algorithms! bint doConglXors #Do variable elimination at the XOR-level (xor-ing 2 xor #clauses thereby removing a variable) - bint doHeuleProcess #Perform local subsitutuion as per Heule's theis + bint doHeuleProcess #Perform local substitution as per Heule's theis bint doSchedSimp #Should simplifyProblem() be scheduled regularly? (if set to #FALSE, a lot of optimisations are disabled) bint doSatELite #Should try to subsume & self-subsuming resolve & diff --git a/src/sage/sat/solvers/cryptominisat/solverconf_helper.cpp b/src/sage/sat/solvers/cryptominisat/solverconf_helper.cpp index 5e678bd54a6..301ea19fe80 100644 --- a/src/sage/sat/solvers/cryptominisat/solverconf_helper.cpp +++ b/src/sage/sat/solvers/cryptominisat/solverconf_helper.cpp @@ -22,7 +22,7 @@ size_t setup_map(sc_entry *entries, CMSat::SolverConf &solver_conf, const size_t entries[17].type = t_bool, entries[17].name = "doRegFindEqLits", entries[17].target = (void*)&(solver_conf.doRegFindEqLits), entries[17].doc = "Regularly find binary xor clauses (i.e. variable equi- and antivalences)"; entries[18].type = t_bool, entries[18].name = "doReplace", entries[18].target = (void*)&(solver_conf.doReplace), entries[18].doc = "Should var-replacing be performed? If set to FALSE, equi- and antivalent variables will not be replaced with one another."; entries[19].type = t_bool, entries[19].name = "doConglXors", entries[19].target = (void*)&(solver_conf.doConglXors), entries[19].doc = "Do variable elimination at the XOR-level (xor-ing 2 xor clauses thereby removing a variable)"; - entries[20].type = t_bool, entries[20].name = "doHeuleProcess", entries[20].target = (void*)&(solver_conf.doHeuleProcess), entries[20].doc = "Perform local subsitutuion as per Heule's theis"; + entries[20].type = t_bool, entries[20].name = "doHeuleProcess", entries[20].target = (void*)&(solver_conf.doHeuleProcess), entries[20].doc = "Perform local substitution as per Heule's theis"; entries[21].type = t_bool, entries[21].name = "doSchedSimp", entries[21].target = (void*)&(solver_conf.doSchedSimp), entries[21].doc = "Should simplifyProblem() be scheduled regularly? (if set to FALSE, a lot of optimisations are disabled)"; entries[22].type = t_bool, entries[22].name = "doSatELite", entries[22].target = (void*)&(solver_conf.doSatELite), entries[22].doc = "Should try to subsume & self-subsuming resolve & variable-eliminate & block-clause eliminate?"; entries[23].type = t_bool, entries[23].name = "doXorSubsumption", entries[23].target = (void*)&(solver_conf.doXorSubsumption), entries[23].doc = "Should try to subsume & local-subsitute xor clauses"; diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py index b4e0f7a5608..0b07fea4eeb 100644 --- a/src/sage/schemes/elliptic_curves/ell_rational_field.py +++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py @@ -1718,7 +1718,7 @@ def analytic_rank_upper_bound(self, sage: E.analytic_rank_upper_bound(max_Delta=0.6,root_number="compute") 0 - The are a small number of curves which have pathalogically low-lying + The are a small number of curves which have pathologically low-lying zeroes. For these curves, this method will produce a bound that is strictly larger than the analytic rank, unless very large values of Delta are used. The following curve ("256944c1" in the Cremona tables) diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py index c72ab31f104..5f749daef94 100644 --- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py +++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py @@ -2032,7 +2032,7 @@ def isogenies_prime_degree_general(E, l): # This function permutes the factors of a given degree, replacing # the factor with roots alpha with the one whose roots are # m(alpha), where m(x) is the rational function giving the - # multiplcation-by-a map on the X-coordinates. Here, a is a + # multiplication-by-a map on the X-coordinates. Here, a is a # generator for (Z/lZ)^* / <-1> (a so-called semi-primitive root). def mult(g): # Find f such that f(m) = 0 mod g diff --git a/src/sage/schemes/product_projective/morphism.py b/src/sage/schemes/product_projective/morphism.py index 16a257432d2..84405524991 100644 --- a/src/sage/schemes/product_projective/morphism.py +++ b/src/sage/schemes/product_projective/morphism.py @@ -130,7 +130,7 @@ def __getitem__(self, i): OUTPUT: - The (multi)-homomgeneous polynomial that is the ``i``-th coordinate. + The (multi)-homogeneous polynomial that is the ``i``-th coordinate. EXAMPLES:: diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index 4f705f8565b..1b14da68bf1 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -5152,7 +5152,7 @@ def normal_form(self, return_conjugation=False): INPUT: - - ``return_conjugation`` -- Boolean - True returns conjugatation element of PGL. + - ``return_conjugation`` -- Boolean - True returns conjugation element of PGL. along with the embedding into the new field. Default: False. (optional) OUTPUT: diff --git a/src/sage/schemes/toric/weierstrass.py b/src/sage/schemes/toric/weierstrass.py index d21a525345c..62aed17182a 100644 --- a/src/sage/schemes/toric/weierstrass.py +++ b/src/sage/schemes/toric/weierstrass.py @@ -95,7 +95,7 @@ (0, -27/4) This allows you to work with either homogeneous or inhomogeneous -variables. For exmple, here is the del Pezzo surface of degree 8:: +variables. For exemple, here is the del Pezzo surface of degree 8:: sage: dP8 = toric_varieties.dP8() sage: dP8.inject_variables() diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index a65c34d569b..633b079a4a8 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -9666,7 +9666,7 @@ cdef class Expression(CommutativeRingElement): Return the expression with any gamma functions that have a common base converted to that base. - Addtionally the expression is normalized so any fractions + Additionally the expression is normalized so any fractions can be simplified through cancellation. EXAMPLES:: From 2b326c2f7ce74c0a892dee3a50f0e550c978844f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 2 Mar 2017 21:17:43 +0100 Subject: [PATCH 287/370] trac 22502 one detail --- src/doc/en/constructions/groups.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/en/constructions/groups.rst b/src/doc/en/constructions/groups.rst index 229ce7d315c..d2de406a092 100644 --- a/src/doc/en/constructions/groups.rst +++ b/src/doc/en/constructions/groups.rst @@ -538,7 +538,7 @@ order 16 as a semidirect product of cyclic groups. The following table shows the groups of order 15 or less, and how to construct them in Sage. Repeated commands have been omitted but instead are described -by the following exemples. +by the following examples. The cyclic group of order `n` can be crated with a single command: From 500eda6bf5886cbff82a31bff9ca0c25cbb513b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 2 Mar 2017 21:19:27 +0100 Subject: [PATCH 288/370] trac 22502 one detail --- src/sage/schemes/toric/weierstrass.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/schemes/toric/weierstrass.py b/src/sage/schemes/toric/weierstrass.py index 62aed17182a..d75239298cf 100644 --- a/src/sage/schemes/toric/weierstrass.py +++ b/src/sage/schemes/toric/weierstrass.py @@ -95,7 +95,7 @@ (0, -27/4) This allows you to work with either homogeneous or inhomogeneous -variables. For exemple, here is the del Pezzo surface of degree 8:: +variables. For example, here is the del Pezzo surface of degree 8:: sage: dP8 = toric_varieties.dP8() sage: dP8.inject_variables() From 789215475c51422bf6eeee56bf199b9421579527 Mon Sep 17 00:00:00 2001 From: "John H. Palmieri" Date: Thu, 2 Mar 2017 12:46:08 -0800 Subject: [PATCH 289/370] trac 22502: a few small fixes --- src/sage/calculus/desolvers.py | 2 +- src/sage/parallel/map_reduce.py | 2 +- src/sage/rings/padics/discrete_value_group.py | 2 +- src/sage/schemes/elliptic_curves/ell_rational_field.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/calculus/desolvers.py b/src/sage/calculus/desolvers.py index 516c2888b89..958c9dd80d5 100644 --- a/src/sage/calculus/desolvers.py +++ b/src/sage/calculus/desolvers.py @@ -524,7 +524,7 @@ def sanitize_var(exprs): soln=soln.sage() if is_SymbolicEquation(soln) and soln.lhs() == dvar: # Remark: Here we do not check that the right hand side does not depend on dvar. - # This probably will not happen for soutions obtained via ode2, anyway. + # This probably will not happen for solutions obtained via ode2, anyway. soln = soln.rhs() if show_method: return [soln,maxima_method.str()] diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py index 779b6d5739e..a0e2e535fe0 100644 --- a/src/sage/parallel/map_reduce.py +++ b/src/sage/parallel/map_reduce.py @@ -1316,7 +1316,7 @@ def random_worker(self): OUTPUT: - A worker for ``self`` choosed at random + A worker for ``self`` chosen at random EXAMPLES:: diff --git a/src/sage/rings/padics/discrete_value_group.py b/src/sage/rings/padics/discrete_value_group.py index 4f7fa1153c9..89efaf4757a 100644 --- a/src/sage/rings/padics/discrete_value_group.py +++ b/src/sage/rings/padics/discrete_value_group.py @@ -206,7 +206,7 @@ def index(self, other): if not isinstance(other, DiscreteValueGroup): raise ValueError("`other` must be a DiscreteValueGroup") if other._generator not in self: - raise ValueError("`other must be a subgroup of this group") + raise ValueError("`other` must be a subgroup of this group") if other._generator == 0: if self._generator == 0: return ZZ(1) diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py index 0b07fea4eeb..19ab532fdfb 100644 --- a/src/sage/schemes/elliptic_curves/ell_rational_field.py +++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py @@ -1718,7 +1718,7 @@ def analytic_rank_upper_bound(self, sage: E.analytic_rank_upper_bound(max_Delta=0.6,root_number="compute") 0 - The are a small number of curves which have pathologically low-lying + There are a small number of curves which have pathologically low-lying zeroes. For these curves, this method will produce a bound that is strictly larger than the analytic rank, unless very large values of Delta are used. The following curve ("256944c1" in the Cremona tables) From 220735012b437440115779f9a06b5f6b2bcf32fb Mon Sep 17 00:00:00 2001 From: Eric Gourgoulhon Date: Thu, 2 Mar 2017 22:05:16 +0100 Subject: [PATCH 290/370] Fix bug with diff(...) in simplify_sqrt_real --- src/sage/manifolds/utilities.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sage/manifolds/utilities.py b/src/sage/manifolds/utilities.py index 00f0c8ab6a3..dbfa70e9a93 100644 --- a/src/sage/manifolds/utilities.py +++ b/src/sage/manifolds/utilities.py @@ -87,10 +87,10 @@ def simplify_sqrt_real(expr): sexpr = str(expr) if 'sqrt(' not in sexpr: # no sqrt to simplify return expr - if 'D[' in sexpr: + if ('D[' in sexpr) or ('diff(' in sexpr): return expr #!# the code below is not capable of simplifying - # expressions with symbolic derivatives denoted by Pynac - # symbols of the type D[0] + # expressions with symbolic derivatives denoted + # by Pynac symbols of the type D[0] or diff(...) # Lists to store the positions of all the top-level sqrt's in sexpr: pos_sqrts = [] # position of first character, i.e. 's' of 'sqrt(...)' pos_after = [] # position of character immediatelty after 'sqrt(...)' @@ -203,6 +203,10 @@ def simplify_abs_trig(expr): sexpr = str(expr) if 'abs(sin(' not in sexpr: # nothing to simplify return expr + if ('D[' in sexpr) or ('diff(' in sexpr): + return expr #!# the code below is not capable of simplifying + # expressions with symbolic derivatives denoted + # by Pynac symbols of the type D[0] or diff(...) tp = [] val = [] for pos in range(len(sexpr)): From 71b1f420886b5f615604810e83da7e11ffec575a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 2 Mar 2017 22:40:22 +0100 Subject: [PATCH 291/370] Several small corrections --- src/doc/en/reference/discrete_geometry/index.rst | 4 ++-- src/doc/en/reference/index.rst | 2 +- src/sage/geometry/polyhedron/constructor.py | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/doc/en/reference/discrete_geometry/index.rst b/src/doc/en/reference/discrete_geometry/index.rst index f62bb77a549..29a19abcc40 100644 --- a/src/doc/en/reference/discrete_geometry/index.rst +++ b/src/doc/en/reference/discrete_geometry/index.rst @@ -1,5 +1,5 @@ -Combinatorial or Discrete Geometry -================================== +Combinatorial and Discrete Geometry +=================================== Sage includes classes for hyperplane arrangements, polyhedra, toric varieties (including polyhedral cones and fans), triangulations and some other helper diff --git a/src/doc/en/reference/index.rst b/src/doc/en/reference/index.rst index c31aa71f2fd..3b549dcb89e 100644 --- a/src/doc/en/reference/index.rst +++ b/src/doc/en/reference/index.rst @@ -83,7 +83,7 @@ Calculus Geometry and Topology --------------------- -* :doc:`Combinatorial and Discrete Geometry ` +* :doc:`Combinatorial and Discrete Geometry ` * :doc:`Hyperbolic Geometry ` * :doc:`Cell Complexes and their Homology ` * :doc:`Differential Forms ` diff --git a/src/sage/geometry/polyhedron/constructor.py b/src/sage/geometry/polyhedron/constructor.py index 8beb37d995d..65d8c48b862 100644 --- a/src/sage/geometry/polyhedron/constructor.py +++ b/src/sage/geometry/polyhedron/constructor.py @@ -57,6 +57,14 @@ sage: triangle.vertices() (A vertex at (-1, 0), A vertex at (1, 0), A vertex at (0, 2)) +.. SEEALSO:: + + If one only needs to keep track of a system of linear system of + inequalities, one should also consider the class for mixed integer linear + programming. + + - :mod:`Mixed Integer Linear Programming ` + Unbounded Polyhedra ------------------- From 2c1c6a84a1757778ede8aaa5d2fbfd6e93419a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Thu, 2 Mar 2017 23:36:23 +0100 Subject: [PATCH 292/370] pep8 conventions and fixed doc --- src/sage/homology/simplicial_complex.py | 51 ++++++++++++------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index 3ab11d3ac2b..2f2e9977207 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -2769,13 +2769,14 @@ def star(self, simplex, is_mutable=True): """ The star of a simplex in this simplicial complex. - The star of a simplex `F` is the simplicial complex formed by - all simplices `G` which contain `F`. + The star of ``simplex`` is the simplicial complex formed by + all simplices which contain ``simplex``. INPUT: - - `simplex` -- a simplex in this simplicial complex - - `is_mutable` -- (optional) boolean, determines if the output is mutable, default ``True`` + - ``simplex`` -- a simplex in this simplicial complex + - ``is_mutable`` -- (default: ``True``) boolean; determines if the output + is mutable EXAMPLES:: @@ -3028,7 +3029,7 @@ def is_shellable(self, certificate=False): if self.is_pure(): if any(x < 0 for x in self.h_vector()): return False - else: # Non-pure complex + else: # Non-pure complex if any(x < 0 for row in self.h_triangle() for x in row): return False @@ -3103,7 +3104,7 @@ def restriction_sets(self, order): # Each time we hit a facet, the complement goes to the restriction cur_complex = SimplicialComplex([]) - for i,F in enumerate(order): + for i, F in enumerate(order): if i > 0: # The shelling condition is precisely that intersection is # a pure complex of one dimension less and stop if this fails @@ -3113,7 +3114,7 @@ def restriction_sets(self, order): if not intersection.is_pure() or self.dimension() - 1 > intersection.dimension(): raise ValueError("not a shelling order") faces = SimplicialComplex([F]).faces() - for k,v in intersection.faces().items(): + for k, v in intersection.faces().items(): faces[k] = faces[k].difference(v) for k in sorted(faces.keys()): if faces[k]: @@ -3265,7 +3266,7 @@ def minimal_nonfaces(self): if new: set_mnf.add(set_candidate) - for candidate in combinations(vertices, dimension+2): # Checks for minimal nonfaces in the remaining dimension + for candidate in combinations(vertices, dimension+2): # Checks for minimal nonfaces in the remaining dimension set_candidate = frozenset(candidate) new = not any(set_candidate.issuperset(mnf) for mnf in set_mnf) if new: @@ -3402,29 +3403,27 @@ def barycentric_subdivision(self): """ return self.face_poset().order_complex() - def stellar_subdivision(self,simplex,inplace=False,is_mutable=True): + def stellar_subdivision(self, simplex, inplace=False, is_mutable=True): """ - This function returns the stellar subdivision of `simplex` either by - modifying `self` (when inplace is set to `True`). + This function returns the stellar subdivision of ``simplex`` either by + modifying ``self`` (when inplace is set to ``True``). The stellar subdivision of a face is obtained by adding a new vertex to the - simplicial complex `self` joined to the star of the face and then - deleting the face `simplex` to the result. + simplicial complex ``self`` joined to the star of the face and then + deleting the face ``simplex`` to the result. INPUT: - - `simplex` -- a simplex face of `self` - - `inplace` -- a boolean, determines if the operation is done on `self` - or not. Default is `False` - - `is_mutable` -- a boolean, determines if the output is mutable or not + - ``simplex`` -- a simplex face of ``self`` + - ``inplace`` -- (default: ``False``) boolean; determines if the + operation is done on ``self`` + - ``is_mutable`` -- (default: ``True``) boolean; determines if the + output is mutable OUTPUT: - A simplicial complex obtained by the stellar subdivision of the face - `simplex`. If inplace is `True`, the object `self` was modified, - otherwise a new simplicial complex is returned. The parameter - `is_mutable` determines the mutability of the output. - + ``simplex`` EXAMPLES:: @@ -3438,10 +3437,10 @@ def stellar_subdivision(self,simplex,inplace=False,is_mutable=True): Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(0, 1, 2), (2, 3, 4), (1, 2, 4)} sage: SC.stellar_subdivision(F3) Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} - sage: SC.stellar_subdivision(F3,inplace=True);SC + sage: SC.stellar_subdivision(F3, inplace=True);SC Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(1, 3, 4), (0, 1, 2), (2, 3, 4), (1, 2, 4)} - The simplex to subdivide should be a face of self: + The simplex to subdivide should be a face of self:: sage: SC = SimplicialComplex([[0,1,2],[1,2,3]]) sage: F4 = Simplex([3,4]) @@ -3450,10 +3449,10 @@ def stellar_subdivision(self,simplex,inplace=False,is_mutable=True): ... ValueError: The face to subdivide is not a face of self. - One can not modify an immutable simplicial complex: + One can not modify an immutable simplicial complex:: - sage: SC = SimplicialComplex([[0,1,2],[1,2,3]],is_mutable=False) - sage: SC.stellar_subdivision(F1,inplace=True) + sage: SC = SimplicialComplex([[0,1,2],[1,2,3]], is_mutable=False) + sage: SC.stellar_subdivision(F1, inplace=True) Traceback (most recent call last): ... ValueError: This simplicial complex is not mutable. From 7c0c9cf8e7ccb3d9b09020ddf11615fcfac61780 Mon Sep 17 00:00:00 2001 From: paulmasson Date: Thu, 2 Mar 2017 15:00:30 -0800 Subject: [PATCH 293/370] Add local Jupyter path --- src/sage/plot/plot3d/base.pyx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx index 4fea9dead1c..2ee5ee162c1 100644 --- a/src/sage/plot/plot3d/base.pyx +++ b/src/sage/plot/plot3d/base.pyx @@ -372,17 +372,30 @@ cdef class Graphics3d(SageObject): if not options['frame']: options['axes_labels'] = False + from sage.repl.rich_output import get_display_manager + backend = get_display_manager()._backend + from sage.repl.rich_output.backend_sagenb import BackendSageNB + if isinstance(backend, BackendSageNB): + options['online'] = True + if options['online']: scripts = ( """ """ ) else: - from sage.env import SAGE_SHARE - scripts = ( """ + from sage.repl.rich_output.backend_ipython import BackendIPythonNotebook + if isinstance(backend, BackendIPythonNotebook): + scripts = ( """ + + + """ ) + else: + from sage.env import SAGE_SHARE + scripts = ( """ - """.format( SAGE_SHARE ) ) + """.format( SAGE_SHARE ) ) lights = "[{x:0, y:0, z:10}, {x:0, y:0, z:-10}]" From c965348bfd957f3a7e4062006d10b85698d81dcb Mon Sep 17 00:00:00 2001 From: paulmasson Date: Thu, 2 Mar 2017 19:06:27 -0800 Subject: [PATCH 294/370] Update sagetex location --- src/doc/de/tutorial/introduction.rst | 2 +- src/doc/de/tutorial/sagetex.rst | 4 ++-- src/doc/en/tutorial/introduction.rst | 2 +- src/doc/en/tutorial/sagetex.rst | 4 ++-- src/doc/es/tutorial/introduction.rst | 2 +- src/doc/fr/tutorial/introduction.rst | 2 +- src/doc/fr/tutorial/sagetex.rst | 4 ++-- src/doc/ja/tutorial/introduction.rst | 2 +- src/doc/ja/tutorial/sagetex.rst | 4 ++-- src/doc/pt/tutorial/introduction.rst | 2 +- src/doc/pt/tutorial/sagetex.rst | 4 ++-- src/doc/ru/tutorial/introduction.rst | 2 +- src/doc/ru/tutorial/sagetex.rst | 4 ++-- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/doc/de/tutorial/introduction.rst b/src/doc/de/tutorial/introduction.rst index 0743f5646dc..b524882ee8c 100644 --- a/src/doc/de/tutorial/introduction.rst +++ b/src/doc/de/tutorial/introduction.rst @@ -101,7 +101,7 @@ Hier geben wir nur ein paar Kommentare ab. einzige Datei in ein Verzeichnis kopieren, welches TeX durchsucht. Die Dokumentation für SageTeX befindet sich in - ``$SAGE_ROOT/local/share/texmf/tex/generic/sagetex/``, wobei + ``$SAGE_ROOT/local/share/texmf/tex/latex/sagetex/``, wobei "``$SAGE_ROOT``" auf das Verzeichnis zeigt, in welches Sie Sage installiert haben, zum Beispiel ``/opt/sage-4.2.1``. diff --git a/src/doc/de/tutorial/sagetex.rst b/src/doc/de/tutorial/sagetex.rst index 5d5cbca0f3f..8f58e812a78 100644 --- a/src/doc/de/tutorial/sagetex.rst +++ b/src/doc/de/tutorial/sagetex.rst @@ -15,7 +15,7 @@ Tutorial und den Abschnitt "Make SageTeX known to TeX" des `Sage installation gu Installationsanleitung führen) um weitere Informationen zu erhalten. Hier stellen wir ein sehr kurzes Beispiel vor wie man SageTeX nutzt. -Die komplette Dokumentation finden Sie unter ``SAGE_ROOT/local/share/texmf/tex/generic/sagetex``, +Die komplette Dokumentation finden Sie unter ``SAGE_ROOT/local/share/texmf/tex/latex/sagetex``, wobei ``SAGE_ROOT`` das Installationsverzeichnis von Sage ist. Dieses Verzeichnis enthält die Dokumentation, eine Beispieldatei und einige nützliche Python Skripte. @@ -103,4 +103,4 @@ an den Sage Befehlen in Ihrem Dokument vorgenommen haben. Es gibt noch viel mehr über SageTeX zu sagen, aber da sowohl Sage alsauch LaTeX komplexe und mächtige Werkzeuge sind, sollten Sie die Dokumentation -über SageTeX in ``SAGE_ROOT/local/share/texmf/tex/generic/sagetex`` lesen. +über SageTeX in ``SAGE_ROOT/local/share/texmf/tex/latex/sagetex`` lesen. diff --git a/src/doc/en/tutorial/introduction.rst b/src/doc/en/tutorial/introduction.rst index 71aed01cb94..493459163b0 100644 --- a/src/doc/en/tutorial/introduction.rst +++ b/src/doc/en/tutorial/introduction.rst @@ -93,7 +93,7 @@ computer. Here we merely make a few comments. will search. The documentation for using SageTeX is located in - ``$SAGE_ROOT/local/share/texmf/tex/generic/sagetex/``, where + ``$SAGE_ROOT/local/share/texmf/tex/latex/sagetex/``, where "``$SAGE_ROOT``" refers to the directory where you installed Sage -- for example, ``/opt/sage-4.2.1``. diff --git a/src/doc/en/tutorial/sagetex.rst b/src/doc/en/tutorial/sagetex.rst index b370cc31c77..4237e23e482 100644 --- a/src/doc/en/tutorial/sagetex.rst +++ b/src/doc/en/tutorial/sagetex.rst @@ -15,7 +15,7 @@ Here is a very brief example of using SageTeX. The full documentation can be found in ``SAGE_ROOT/local/share/doc/sagetex``, where ``SAGE_ROOT`` is the directory where your Sage installation is located. That directory contains the documentation and an example file. -See ``SAGE_ROOT/local/share/texmf/tex/generic/sagetex`` for +See ``SAGE_ROOT/local/share/texmf/tex/latex/sagetex`` for some possibly useful Python scripts. To see how SageTeX works, follow the directions for installing SageTeX (in @@ -120,7 +120,7 @@ installation aware of it before it will work. The key to this is that TeX needs to be able to find ``sagetex.sty``, which can be found in -``SAGE_ROOT/local/share/texmf/tex/generic/sagetex/``, where +``SAGE_ROOT/local/share/texmf/tex/latex/sagetex/``, where ``SAGE_ROOT`` is the directory where you built or installed Sage. If TeX can find ``sagetex.sty``, then SageTeX will work. There are several ways to accomplish this. diff --git a/src/doc/es/tutorial/introduction.rst b/src/doc/es/tutorial/introduction.rst index 942895a15de..01ec7bcdad7 100644 --- a/src/doc/es/tutorial/introduction.rst +++ b/src/doc/es/tutorial/introduction.rst @@ -93,7 +93,7 @@ Sage en tu computador. Aquí hacemos simplemente dos comentarios: en un directorio en el que TeX va a buscar. La documentación para usar SageTeX se encuentra en - ``$SAGE_ROOT/local/share/texmf/tex/generic/sagetex/``, donde + ``$SAGE_ROOT/local/share/texmf/tex/latex/sagetex/``, donde "``$SAGE_ROOT``" se refiere al directorio donde Sage está instalado -- por ejemplo, ``/opt/sage-4.2.1``. diff --git a/src/doc/fr/tutorial/introduction.rst b/src/doc/fr/tutorial/introduction.rst index f82a79edd0b..68a48862727 100644 --- a/src/doc/fr/tutorial/introduction.rst +++ b/src/doc/fr/tutorial/introduction.rst @@ -99,7 +99,7 @@ Nous nous limiterons ici à quelques remarques. d'environnement. La documentation de SageTeX se trouve dans le répertoire - ``$SAGE_ROOT/local/share/texmf/tex/generic/sagetex/``, où + ``$SAGE_ROOT/local/share/texmf/tex/latex/sagetex/``, où "``$SAGE_ROOT``" est le répertoire où vous avez installé Sage, par exemple ``/opt/sage-4.3.4``. diff --git a/src/doc/fr/tutorial/sagetex.rst b/src/doc/fr/tutorial/sagetex.rst index 889594d9654..9aa52f3759a 100644 --- a/src/doc/fr/tutorial/sagetex.rst +++ b/src/doc/fr/tutorial/sagetex.rst @@ -16,7 +16,7 @@ locale) pour plus de détails. Voici un bref exemple d'utilisation de SageTeX. La documentation complète se trouve dans -``SAGE_ROOT/local/share/texmf/tex/generic/sagetex``, où ``SAGE_ROOT`` +``SAGE_ROOT/local/share/texmf/tex/latex/sagetex``, où ``SAGE_ROOT`` désigne le répertoire racine de votre installation Sage. Elle est accompagnée d'un fichier exemple et de scripts Python potentiellement utiles. @@ -114,4 +114,4 @@ compilation précédente.) SageTeX offre bien d'autres possibilités. Puisque Sage comme LaTeX sont des outils complexes et puissants, le mieux est sans doute de consulter la documentation complète de SageTeX, qui se trouve -dans ``SAGE_ROOT/local/share/texmf/tex/generic/sagetex``. +dans ``SAGE_ROOT/local/share/texmf/tex/latex/sagetex``. diff --git a/src/doc/ja/tutorial/introduction.rst b/src/doc/ja/tutorial/introduction.rst index ef90446a4f6..ba092ddd6a3 100644 --- a/src/doc/ja/tutorial/introduction.rst +++ b/src/doc/ja/tutorial/introduction.rst @@ -73,7 +73,7 @@ Sageを自分のコンピュータへインストールする手順について SageTeXの利用に関する解説は -``$SAGE_ROOT/local/share/texmf/tex/generic/sagetex/`` にある. +``$SAGE_ROOT/local/share/texmf/tex/latex/sagetex/`` にある. ``$SAGE_ROOT`` はSageがインストールされているディレクトリで,例えば ``/opt/sage-4.2.1`` などとなっているはずだ. diff --git a/src/doc/ja/tutorial/sagetex.rst b/src/doc/ja/tutorial/sagetex.rst index 139358ba36a..350bc32d9bf 100644 --- a/src/doc/ja/tutorial/sagetex.rst +++ b/src/doc/ja/tutorial/sagetex.rst @@ -13,7 +13,7 @@ SageTeXパッケージを使うと,Sageによる処理結果をLaTeX文書に ここでは,ごく簡単な例題を通してSageTeXの利用手順を紹介する. 完全な解説ドキュメントと例題ファイルは,ディレクトリ ``SAGE_ROOT/local/share/doc/sagetex`` に置いてある. -``SAGE_ROOT/local/share/texmf/tex/generic/sagetex`` にあるPythonスクリプトは何か役に立つ場面があるはずだ. +``SAGE_ROOT/local/share/texmf/tex/latex/sagetex`` にあるPythonスクリプトは何か役に立つ場面があるはずだ. 以上の ``SAGE_ROOT`` は,Sageをインストールしたディレクトリである. @@ -118,7 +118,7 @@ SageTeXはデフォルトでSageにインストールされるが,LaTeX文書 鍵になるのは, TeXが ``sagetex.sty`` を発見できるかどうかである. この ``sagetex.sty`` は, ``SAGE_ROOT`` をSageがビルトあるいはインストールされたディレクトリとすると, -``SAGE_ROOT/local/share/texmf/tex/generic/sagetex/`` に置かれているはずだ. +``SAGE_ROOT/local/share/texmf/tex/latex/sagetex/`` に置かれているはずだ. TeXが ``sagetex.sty`` を読めるようにしてやらなければ,SageTeXも動作できないのである. これを実現するには何通りかのやり方がある. diff --git a/src/doc/pt/tutorial/introduction.rst b/src/doc/pt/tutorial/introduction.rst index d44e960a8e3..127e1b71f9a 100644 --- a/src/doc/pt/tutorial/introduction.rst +++ b/src/doc/pt/tutorial/introduction.rst @@ -93,7 +93,7 @@ computador. Aqui faremos apenas alguns comentários. encontrá-lo. A documentação para usar o SageTex está disponível em - ``$SAGE_ROOT/local/share/texmf/tex/generic/sagetex/``, onde + ``$SAGE_ROOT/local/share/texmf/tex/latex/sagetex/``, onde ``$SAGE_ROOT`` refere-se ao diretório onde você instalou o Sage -- por exemplo, ``/opt/sage-4.2.1``. diff --git a/src/doc/pt/tutorial/sagetex.rst b/src/doc/pt/tutorial/sagetex.rst index 4aae0859754..949b9b3e6db 100644 --- a/src/doc/pt/tutorial/sagetex.rst +++ b/src/doc/pt/tutorial/sagetex.rst @@ -14,7 +14,7 @@ instalação do Sage `_ Aqui vai um breve exemplo de como usar o SageTeX. A documentação completa pode ser encontrada em -``SAGE_ROOT/local/share/texmf/tex/generic/sagetex``, onde +``SAGE_ROOT/local/share/texmf/tex/latex/sagetex``, onde ``SAGE_ROOT`` é o diretório onde se encontra a sua instalação. Esse diretório contém a documentação, um arquivo de exemplo, e alguns scripts em Python possivelmente úteis. @@ -107,4 +107,4 @@ os comandos em Sage em seu documento. Há muito mais sobre o SageTeX, e como tanto o Sage como o LaTeX são ferramentas complexas e poderosas, é uma boa idéia ler a documentação para o SageTeX que se encontra em -``SAGE_ROOT/local/share/texmf/tex/generic/sagetex``. +``SAGE_ROOT/local/share/texmf/tex/latex/sagetex``. diff --git a/src/doc/ru/tutorial/introduction.rst b/src/doc/ru/tutorial/introduction.rst index 71070aa5cc0..820179a9830 100644 --- a/src/doc/ru/tutorial/introduction.rst +++ b/src/doc/ru/tutorial/introduction.rst @@ -89,7 +89,7 @@ Sage в разделе документации: [SA]_ Здесь мы прив всего лишь скопировать один файл в директорию поиска TeX. Документация по использованию SageTeX находится в - ``$SAGE_ROOT/local/share/texmf/tex/generic/sagetex/``, где + ``$SAGE_ROOT/local/share/texmf/tex/latex/sagetex/``, где "``$SAGE_ROOT``" соответствует директории, где установлен сам Sage, например, ``/opt/sage-4.2.1``. diff --git a/src/doc/ru/tutorial/sagetex.rst b/src/doc/ru/tutorial/sagetex.rst index 65c70379618..d23ebc7fb31 100644 --- a/src/doc/ru/tutorial/sagetex.rst +++ b/src/doc/ru/tutorial/sagetex.rst @@ -12,7 +12,7 @@ SageTeX known to TeX" `Руководства по установке Sage по установке). В этом уроке показан небольшой пример использования SageTeX. Полная документация -находится в ``SAGE_ROOT/local/share/texmf/tex/generic/sagetex``, где +находится в ``SAGE_ROOT/local/share/texmf/tex/latex/sagetex``, где ``SAGE_ROOT`` - это директория, в которой установлен Sage. Эта папка содержит документацию, файл с примером и полезные скрипты Python. @@ -89,4 +89,4 @@ SageTeX known to TeX" `Руководства по установке Sage SageTeX предлагает много возможностей, и так как Sage и LaTeX являются мощными инструментами, то стоит изучить -``SAGE_ROOT/local/share/texmf/tex/generic/sagetex``. +``SAGE_ROOT/local/share/texmf/tex/latex/sagetex``. From d68a1a2a9c7ced009bf659acb40f1662f66311b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Fri, 3 Mar 2017 08:54:48 +0100 Subject: [PATCH 295/370] Corrected indentation of input blocks --- src/sage/homology/simplicial_complex.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index 2f2e9977207..1a1cdae3d24 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -2776,7 +2776,7 @@ def star(self, simplex, is_mutable=True): - ``simplex`` -- a simplex in this simplicial complex - ``is_mutable`` -- (default: ``True``) boolean; determines if the output - is mutable + is mutable EXAMPLES:: @@ -3416,14 +3416,14 @@ def stellar_subdivision(self, simplex, inplace=False, is_mutable=True): - ``simplex`` -- a simplex face of ``self`` - ``inplace`` -- (default: ``False``) boolean; determines if the - operation is done on ``self`` + operation is done on ``self`` - ``is_mutable`` -- (default: ``True``) boolean; determines if the - output is mutable + output is mutable OUTPUT: - A simplicial complex obtained by the stellar subdivision of the face - ``simplex`` + ``simplex`` EXAMPLES:: From d9e54156cb0922438fd745ebb080c856036149ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Fri, 3 Mar 2017 09:04:36 +0100 Subject: [PATCH 296/370] Correct an indentation in input block --- src/sage/geometry/polyhedron/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 3a914e76d2a..2ee0c0c9d05 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2160,7 +2160,7 @@ def is_inscribed(self, certificate=False): INPUT: - ``certificate`` -- (default: ``False``) boolean; specifies whether to - return the circumcenter, if found + return the circumcenter, if found OUTPUT: From 1a1e7b15735e4b69de2c91e18420b57fa66fba0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Fri, 3 Mar 2017 09:07:20 +0100 Subject: [PATCH 297/370] Corrected the indentation of an input block --- src/sage/geometry/polyhedron/backend_normaliz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py index 276b8a7df95..2a2d9ba4a70 100644 --- a/src/sage/geometry/polyhedron/backend_normaliz.py +++ b/src/sage/geometry/polyhedron/backend_normaliz.py @@ -446,7 +446,7 @@ def integral_points(self, threshold=10000): INPUT: - ``threshold`` -- integer (default: 10000); use the naïve - algorithm as long as the bounding box is smaller than this + algorithm as long as the bounding box is smaller than this OUTPUT: From 3fe499d51ba8a52fca8872fa440ea86512a8cbe3 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 3 Mar 2017 12:28:17 +0100 Subject: [PATCH 298/370] Upgrade lrslib to 062+autotools-2017-03-03 --- build/pkgs/lrslib/checksums.ini | 6 +++--- build/pkgs/lrslib/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/lrslib/checksums.ini b/build/pkgs/lrslib/checksums.ini index b126d123f27..88276625302 100644 --- a/build/pkgs/lrslib/checksums.ini +++ b/build/pkgs/lrslib/checksums.ini @@ -1,4 +1,4 @@ tarball=lrslib-VERSION.tar.gz -sha1=7d1b187abd8dbb7ff2c8d7fdf0361a4fc27bb087 -md5=17fcc81d6153caf9b1e881566fdb70c1 -cksum=1582540417 +sha1=c644600ca4a51eb08e61ba175e1d4ec999dc3e4b +md5=bb435ccdd5faf292102e246827926680 +cksum=3830123478 diff --git a/build/pkgs/lrslib/package-version.txt b/build/pkgs/lrslib/package-version.txt index 67e8cc7de0c..6ceb12bb4fd 100644 --- a/build/pkgs/lrslib/package-version.txt +++ b/build/pkgs/lrslib/package-version.txt @@ -1 +1 @@ -062+autotools-2016-09-08 +062+autotools-2017-03-03 From f2a6279ec7a2dec6d898be10fba798233f033d1b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 3 Mar 2017 13:23:57 +0100 Subject: [PATCH 299/370] perl_term_readline_gnu: Build fix for Linux --- build/pkgs/perl_term_readline_gnu/spkg-install | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/pkgs/perl_term_readline_gnu/spkg-install b/build/pkgs/perl_term_readline_gnu/spkg-install index f9c8c7dd1c9..8326aa6ac3d 100755 --- a/build/pkgs/perl_term_readline_gnu/spkg-install +++ b/build/pkgs/perl_term_readline_gnu/spkg-install @@ -8,5 +8,10 @@ fi cd src -perl Makefile.PL --prefix=$SAGE_LOCAL INSTALL_BASE=$SAGE_LOCAL +# In the configure phase, the package fails to use rpath for a test +# program that it compiles, causing a build failure on Linux as +# reported in #22505 (libreadline.so not found). We work around it by +# using LD_LIBRARY_PATH. +export LD_LIBRARY_PATH="$SAGE_LOCAL/lib":"$LD_LIBRARY_PATH" +perl Makefile.PL --prefix="$SAGE_LOCAL" INSTALL_BASE="$SAGE_LOCAL" $MAKE install From 1b54fba0f30ef57a4847fe96d771770782fcc612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Fri, 3 Mar 2017 18:55:37 +0100 Subject: [PATCH 300/370] corrected conventions --- src/sage/homology/simplicial_complex.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index 1a1cdae3d24..f56a4113696 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -2767,7 +2767,7 @@ def link(self, simplex, is_mutable=True): def star(self, simplex, is_mutable=True): """ - The star of a simplex in this simplicial complex. + Return the star of a simplex in this simplicial complex. The star of ``simplex`` is the simplicial complex formed by all simplices which contain ``simplex``. @@ -3405,8 +3405,7 @@ def barycentric_subdivision(self): def stellar_subdivision(self, simplex, inplace=False, is_mutable=True): """ - This function returns the stellar subdivision of ``simplex`` either by - modifying ``self`` (when inplace is set to ``True``). + Return the stellar subdivision of a simplex in this simplicial complex. The stellar subdivision of a face is obtained by adding a new vertex to the simplicial complex ``self`` joined to the star of the face and then @@ -3416,7 +3415,7 @@ def stellar_subdivision(self, simplex, inplace=False, is_mutable=True): - ``simplex`` -- a simplex face of ``self`` - ``inplace`` -- (default: ``False``) boolean; determines if the - operation is done on ``self`` + operation is done on ``self`` or on a copy - ``is_mutable`` -- (default: ``True``) boolean; determines if the output is mutable @@ -3447,7 +3446,7 @@ def stellar_subdivision(self, simplex, inplace=False, is_mutable=True): sage: SC.stellar_subdivision(F4) Traceback (most recent call last): ... - ValueError: The face to subdivide is not a face of self. + ValueError: the face to subdivide is not a face of self One can not modify an immutable simplicial complex:: @@ -3455,14 +3454,14 @@ def stellar_subdivision(self, simplex, inplace=False, is_mutable=True): sage: SC.stellar_subdivision(F1, inplace=True) Traceback (most recent call last): ... - ValueError: This simplicial complex is not mutable. + ValueError: this simplicial complex is not mutable """ if inplace and not self._is_mutable: - raise ValueError("This simplicial complex is not mutable.") + raise ValueError("this simplicial complex is not mutable") if not Simplex(simplex) in self: - raise ValueError("The face to subdivide is not a face of self.") + raise ValueError("the face to subdivide is not a face of self") if inplace: working_complex = self From c7acfd690f5283e956bcce87f6a98668da21c798 Mon Sep 17 00:00:00 2001 From: ashutosh1206 Date: Fri, 3 Mar 2017 23:33:42 +0530 Subject: [PATCH 301/370] Fixes #21554 On branch documentation modified: relation.py Authors: Ashutosh Ahelleya --- src/sage/symbolic/relation.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/sage/symbolic/relation.py b/src/sage/symbolic/relation.py index eb0df1e1dba..057120a28da 100644 --- a/src/sage/symbolic/relation.py +++ b/src/sage/symbolic/relation.py @@ -449,6 +449,19 @@ def test_relation_maxima(relation): sage: test_relation_maxima(f1 - f2 == 0) True sage: forget() + + In case one of the solutions while solving an equation is a real number:: + + sage: var('K, d, R') + (K, d, R) + sage: assume(K>0) + sage: assume(K, 'noninteger') + sage: assume(R>0) + sage: assume(R<1) + sage: assume(d 0, K is noninteger, R > 0, R < 1, d < R] + """ m = relation._maxima_() From f0ebd9ceeec6be2126f65df1c7829c019e709764 Mon Sep 17 00:00:00 2001 From: David Coudert Date: Sat, 4 Mar 2017 09:43:38 +0100 Subject: [PATCH 302/370] trac #22424: remove trailing white space and and doctest --- src/sage/graphs/digraph.py | 2 +- src/sage/graphs/graph.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sage/graphs/digraph.py b/src/sage/graphs/digraph.py index a73177d2631..1221081981d 100644 --- a/src/sage/graphs/digraph.py +++ b/src/sage/graphs/digraph.py @@ -479,7 +479,7 @@ def __init__(self, data=None, pos=None, loops=None, format=None, The position dictionary is not the input one (:trac:`22424`):: - sage: my_pos = {0:(0,0), 1:(1,1)} + sage: my_pos = {0:(0,0), 1:(1,1)} sage: D = DiGraph([[0,1], [(0,1)]], pos=my_pos) sage: my_pos == D._pos True diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py index 6d6c33a6282..2d80e0ef196 100644 --- a/src/sage/graphs/graph.py +++ b/src/sage/graphs/graph.py @@ -5173,6 +5173,16 @@ def to_directed(self, implementation='c_graph', data_structure=None, sage: Graph([[1,2]], immutable=True).to_directed() Digraph on 2 vertices + + :trac:`22424`:: + + sage: G1=graphs.RandomGNP(5,0.5) + sage: gp1 = G1.graphplot(save_pos=True) + sage: G2=G1.to_directed() + sage: G2.delete_vertex(0) + sage: G2.add_vertex(5) + sage: gp2 = G2.graphplot() + sage: gp1 = G1.graphplot() """ if sparse is not None: if data_structure is not None: From a89b972e8c296aeadd15fbd07d99ff6b54310ccb Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 4 Mar 2017 18:02:01 +0100 Subject: [PATCH 303/370] Trac #22541 review: rename branch to some_code --- src/doc/en/developer/advanced_git.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/doc/en/developer/advanced_git.rst b/src/doc/en/developer/advanced_git.rst index e43058099a7..8568af327d6 100644 --- a/src/doc/en/developer/advanced_git.rst +++ b/src/doc/en/developer/advanced_git.rst @@ -72,7 +72,7 @@ Update Branch to Latest SageMath Version (and Minimizing Recompilation Time) ============================================================================ - You have a compiled and working new SageMath version ``n``, and -- you want to work on a branch ``some/code`` which is based on some old SageMath version ``o`` +- you want to work on a branch ``some_code`` which is based on some old SageMath version ``o`` - by updating this branch from version ``o`` to ``n`` - with only recompiling changed files (and not all touched files from ``o`` to ``n``), - then continue reading this section. @@ -105,7 +105,7 @@ Merge in the Latest SageMath Version (This is the easy way without minimizing the recompilation time.) -Suppose we are on our current working branch ``some/code`` +Suppose we are on our current working branch ``some_code`` (branch is checked out). Then :: @@ -124,7 +124,7 @@ Minimize the Recompilation Time Suppose we are on some new SageMath (e.g. on branch ``develop``) which was already compiled and runs successfully, and we have an "old" -branch ``some/code``, that we want to bring onto this SageMath version +branch ``some_code``, that we want to bring onto this SageMath version (without triggering unnecessary recompilations). We first create a new working tree in a directory ``merge`` and switch @@ -136,7 +136,7 @@ to this directory:: Here we have a new copy of our source files. Thus no timestamps etc. of the original repository will be changed. Now we do the merge:: - git checkout some/code + git checkout some_code git merge develop And go back to our original repository:: @@ -144,9 +144,9 @@ And go back to our original repository:: git checkout develop cd .. -We can now safely checkout ``some/code``:: +We can now safely checkout ``some_code``:: - git checkout some/code + git checkout some_code We still need to call:: @@ -160,7 +160,7 @@ Why not Merging the Other Way Round? Being on some new SageMath (e.g. on branch ``develop``) which runs successfully, it would be possible to merge in our branch -``some/code`` into develop. This would produce the same source files +``some_code`` into develop. This would produce the same source files and avoid unnecessary recompilations. However, it destroys git's history. Thus, for example, it is hard to keep track of changes etc., as one cannot simply persue the first parent of each git commit. From 4e61be0a55fdf2a8b20881e4f8b6ffbcb4bf893d Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sat, 4 Mar 2017 18:06:05 +0100 Subject: [PATCH 304/370] Trac #22541 review: rename sub directory to new_worktree --- src/doc/en/developer/advanced_git.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/en/developer/advanced_git.rst b/src/doc/en/developer/advanced_git.rst index 8568af327d6..8ed8b73f788 100644 --- a/src/doc/en/developer/advanced_git.rst +++ b/src/doc/en/developer/advanced_git.rst @@ -127,11 +127,11 @@ was already compiled and runs successfully, and we have an "old" branch ``some_code``, that we want to bring onto this SageMath version (without triggering unnecessary recompilations). -We first create a new working tree in a directory ``merge`` and switch +We first create a new working tree in a directory ``new_worktree`` and switch to this directory:: - git worktree add merge - cd merge + git worktree add new_worktree + cd new_worktree Here we have a new copy of our source files. Thus no timestamps etc. of the original repository will be changed. Now we do the merge:: From d5ff154e0bb10e333a3a9c39d3cd20ed9b7b69c2 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Thu, 2 Mar 2017 23:59:53 +0100 Subject: [PATCH 305/370] 22497: generic interface to LattE integrale count --- src/sage/geometry/polyhedron/base.py | 58 +++----- src/sage/geometry/polyhedron/base_ZZ.py | 69 +++------ src/sage/interfaces/latte.py | 180 ++++++++++++++++++++++++ 3 files changed, 219 insertions(+), 88 deletions(-) create mode 100644 src/sage/interfaces/latte.py diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 5f7421b8ba4..8d6cc435674 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4362,7 +4362,7 @@ def bounding_box(self, integral=False): box_min.append(min_coord) return (tuple(box_min), tuple(box_max)) - def integral_points_count(self, verbose=False): + def integral_points_count(self, verbose=False, use_Hrepresentation=False, **kwds): r""" Return the number of integral points in the polyhedron. @@ -4373,6 +4373,13 @@ def integral_points_count(self, verbose=False): - ``verbose`` (boolean; ``False`` by default) -- whether to display verbose output. + - ``use_Hrepresentation`` - (boolean; ``False`` by default) -- whether + to send the H or V representation to LattE + + .. SEEALSO:: + + :mod:`~sage.interfaces.latte` the interface to LattE interfaces + EXAMPLES:: sage: P = polytopes.cube() @@ -4396,12 +4403,15 @@ def integral_points_count(self, verbose=False): sage: Q.integral_points_count() # optional - latte_int Traceback (most recent call last): ... - RuntimeError: LattE integrale failed (exit code 1) to execute... - ...Parse error in CDD-style input file /dev/stdin + RuntimeError: LattE integrale program failed (exit code 1): + ... + Invocation: count '--redundancy-check=none' --cdd /dev/stdin + ... + Parse error in CDD-style input file /dev/stdin sage: Q.integral_points_count(verbose=True) # optional - latte_int Traceback (most recent call last): ... - RuntimeError: LattE integrale failed (exit code 1) to execute count --cdd /dev/stdin, see error message above + RuntimeError: LattE integrale program failed (exit code 1), see error message above TESTS: @@ -4417,40 +4427,12 @@ def integral_points_count(self, verbose=False): if self.is_empty(): return 0 - from subprocess import Popen, PIPE - from sage.misc.misc import SAGE_TMP - from sage.rings.integer import Integer - - ine = self.cdd_Hrepresentation() - args = ['count', '--cdd', '/dev/stdin'] - - try: - # The cwd argument is needed because latte - # always produces diagnostic output files. - latte_proc = Popen(args, - stdin=PIPE, stdout=PIPE, - stderr=(None if verbose else PIPE), - cwd=str(SAGE_TMP)) - except OSError: - from sage.misc.package import PackageNotFoundError - raise PackageNotFoundError('latte_int') - - ans, err = latte_proc.communicate(ine) - ret_code = latte_proc.poll() - if ret_code: - if err is None: - err = ", see error message above" - else: - err = ":\n" + err - raise RuntimeError("LattE integrale failed (exit code {}) to execute {}".format(ret_code, ' '.join(args)) + err.strip()) - - try: - return Integer(ans.splitlines()[-1]) - except IndexError: - # opening a file is slow (30e-6s), so we read the file - # numOfLatticePoints only in case of a IndexError above - with open(SAGE_TMP+'/numOfLatticePoints', 'r') as f: - return Integer(f.read()) + from sage.interfaces.latte import count + return count( + self.cdd_Hrepresentation() if use_Hrepresentation else self.cdd_Vrepresentation(), + cdd=True, + verbose=verbose, + **kwds) def integral_points(self, threshold=100000): r""" diff --git a/src/sage/geometry/polyhedron/base_ZZ.py b/src/sage/geometry/polyhedron/base_ZZ.py index fbfea81a047..268af9db0da 100644 --- a/src/sage/geometry/polyhedron/base_ZZ.py +++ b/src/sage/geometry/polyhedron/base_ZZ.py @@ -178,6 +178,10 @@ def ehrhart_polynomial(self, verbose=False, dual=None, for lattice point enumeration (see https://www.math.ucdavis.edu/~latte/). + .. SEEALSO:: + + :mod:`~sage.interfaces.latte` the interface to LattE integrale + EXAMPLES:: sage: P = Polyhedron(vertices=[(0,0,0),(3,3,3),(-3,2,1),(1,-1,-2)]) @@ -224,7 +228,7 @@ def ehrhart_polynomial(self, verbose=False, dual=None, sage: p = P.ehrhart_polynomial(maxdet=5, verbose=True) # optional - latte_int This is LattE integrale ... ... - Invocation: count --ehrhart-polynomial '--redundancy-check=none' '--maxdet=5' --cdd ... + Invocation: count --ehrhart-polynomial '--redundancy-check=none' --cdd '--maxdet=5' /dev/stdin ... sage: p # optional - latte_int 1/2*t^2 + 3/2*t + 1 @@ -232,7 +236,7 @@ def ehrhart_polynomial(self, verbose=False, dual=None, sage: p = P.ehrhart_polynomial(dual=True, verbose=True) # optional - latte_int This is LattE integrale ... ... - Invocation: count --ehrhart-polynomial '--redundancy-check=none' --dual --cdd ... + Invocation: count --ehrhart-polynomial '--redundancy-check=none' --cdd --dual /dev/stdin ... sage: p # optional - latte_int 1/2*t^2 + 3/2*t + 1 @@ -240,7 +244,7 @@ def ehrhart_polynomial(self, verbose=False, dual=None, sage: p = P.ehrhart_polynomial(irrational_primal=True, verbose=True) # optional - latte_int This is LattE integrale ... ... - Invocation: count --ehrhart-polynomial '--redundancy-check=none' --irrational-primal --cdd ... + Invocation: count --ehrhart-polynomial '--redundancy-check=none' --cdd --irrational-primal /dev/stdin ... sage: p # optional - latte_int 1/2*t^2 + 3/2*t + 1 @@ -248,7 +252,8 @@ def ehrhart_polynomial(self, verbose=False, dual=None, sage: p = P.ehrhart_polynomial(irrational_all_primal=True, verbose=True) # optional - latte_int This is LattE integrale ... ... - Invocation: count --ehrhart-polynomial '--redundancy-check=none' --irrational-all-primal --cdd ... + Invocation: count --ehrhart-polynomial '--redundancy-check=none' --cdd --irrational-all-primal /dev/stdin + ... sage: p # optional - latte_int 1/2*t^2 + 3/2*t + 1 @@ -257,22 +262,17 @@ def ehrhart_polynomial(self, verbose=False, dual=None, sage: P.ehrhart_polynomial(bim_bam_boum=19) # optional - latte_int Traceback (most recent call last): ... - RuntimeError: LattE integrale failed with exit code 1 to execute... + RuntimeError: LattE integrale program failed (exit code 1): + ... + Invocation: count --ehrhart-polynomial '--redundancy-check=none' --cdd '--bim-bam-boum=19' /dev/stdin + Unknown command/option --bim-bam-boum=19 """ - from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing - R = PolynomialRing(QQ, 't') if self.is_empty(): + from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing + from sage.rings.rational_field import QQ + R = PolynomialRing(QQ, 't') return R.zero() - from sage.misc.misc import SAGE_TMP - from subprocess import Popen, PIPE - - ine = self.cdd_Hrepresentation() - - args = ['count', '--ehrhart-polynomial'] - if 'redundancy_check' not in kwds: - args.append('--redundancy-check=none') - # note: the options below are explicitely written in the function # declaration in order to keep tab completion (see #18211). kwds.update({ @@ -287,40 +287,9 @@ def ehrhart_polynomial(self, verbose=False, dual=None, 'triangulation' : triangulation, 'triangulation_max_height': triangulation_max_height}) - for key,value in kwds.items(): - if value is None or value is False: - continue - - key = key.replace('_','-') - if value is True: - args.append('--{}'.format(key)) - else: - args.append('--{}={}'.format(key, value)) - args += ['--cdd', '/dev/stdin'] - - try: - # The cwd argument is needed because latte - # always produces diagnostic output files. - latte_proc = Popen(args, - stdin=PIPE, stdout=PIPE, - stderr=(None if verbose else PIPE), - cwd=str(SAGE_TMP)) - except OSError: - from sage.misc.package import PackageNotFoundError - raise PackageNotFoundError('latte_int') - - ans, err = latte_proc.communicate(ine) - ret_code = latte_proc.poll() - if ret_code: - if err is None: - err = ", see error message above" - else: - err = ":\n" + err - raise RuntimeError("LattE integrale failed with exit code {} to execute {}".format(ret_code, ' '.join(args)) + err.strip()) - - p = ans.splitlines()[-2] - - return R(p) + from sage.interfaces.latte import count + ine = self.cdd_Hrepresentation() + return count(ine, cdd=True, ehrhart_polynomial=True, verbose=verbose, **kwds) @cached_method def polar(self): diff --git a/src/sage/interfaces/latte.py b/src/sage/interfaces/latte.py new file mode 100644 index 00000000000..455271bfacd --- /dev/null +++ b/src/sage/interfaces/latte.py @@ -0,0 +1,180 @@ +r""" +Generic interface to LattE integrale programs +""" +#***************************************************************************** +# Copyright (C) 2017 Vincent Delecroix +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + +def count(arg, ehrhart_polynomial=False, multivariate_generating_function=False, raw_output=False, verbose=False, **kwds): + r""" + Call to the program count from LattE integrale + + INPUT: + + - ``arg`` -- a cdd or LattE description string + + - ``ehrhart_polynomial``, ``multivariate_generating_function`` -- to + compute Ehrhart polynomial or multivariate generating function instead of + just counting points + + - ``raw_output`` -- if ``True`` then return directly the output string from LattE + + - For all other options of the count program, consult the LattE manual + + OUTPUT: + + Either a string (if ``raw_output`` if set to ``True``) or an integer (when + counting points), or a polynomial (if ``ehrhart_polynomial`` is set to + ``True``) or a multivariate THING (if ``multivariate_generating_function`` + is set to ``True``) + + EXAMPLES:: + + sage: from sage.interfaces.latte import count + sage: P = 2 * polytopes.cube() + + Counting integer points from either the H or V representation:: + + sage: count(P.cdd_Hrepresentation(), cdd=True) # optional - latte_int + 125 + sage: count(P.cdd_Vrepresentation(), cdd=True) # optional - latte_int + 125 + + Ehrhart polynomial:: + + sage: count(P.cdd_Hrepresentation(), cdd=True, ehrhart_polynomial=True) # optional - latte_int + 64*t^3 + 48*t^2 + 12*t + 1 + + Multivariate generating function currently only work with ``raw_output=True``:: + + sage: opts = {'cdd': True, + ....: 'multivariate_generating_function': True, + ....: 'raw_output': True} + sage: cddin = P.cdd_Hrepresentation() + sage: print(count(cddin, **opts)) # optional - latte_int + x[0]^2*x[1]^(-2)*x[2]^(-2)/((1-x[1])*(1-x[2])*(1-x[0]^(-1))) + + x[0]^(-2)*x[1]^(-2)*x[2]^(-2)/((1-x[1])*(1-x[2])*(1-x[0])) + + x[0]^2*x[1]^(-2)*x[2]^2/((1-x[1])*(1-x[0]^(-1))*(1-x[2]^(-1))) + + x[0]^(-2)*x[1]^(-2)*x[2]^2/((1-x[1])*(1-x[0])*(1-x[2]^(-1))) + + x[0]^2*x[1]^2*x[2]^(-2)/((1-x[2])*(1-x[0]^(-1))*(1-x[1]^(-1))) + + x[0]^(-2)*x[1]^2*x[2]^(-2)/((1-x[2])*(1-x[0])*(1-x[1]^(-1))) + + x[0]^2*x[1]^2*x[2]^2/((1-x[0]^(-1))*(1-x[1]^(-1))*(1-x[2]^(-1))) + + x[0]^(-2)*x[1]^2*x[2]^2/((1-x[0])*(1-x[1]^(-1))*(1-x[2]^(-1))) + + TESTS: + + Testing raw output:: + + sage: from sage.interfaces.latte import count + sage: P = polytopes.cuboctahedron() + sage: cddin = P.cdd_Vrepresentation() + sage: count(cddin, cdd=True, raw_output=True) # optional - latte_int + '19' + sage: count(cddin, cdd=True, raw_output=True, ehrhart_polynomial=True) # optional - latte_int + ' + 1 * t^0 + 10/3 * t^1 + 8 * t^2 + 20/3 * t^3' + sage: count(cddin, cdd=True, raw_output=True, multivariate_generating_function=True) # optional - latte_int + 'x[0]^(-1)*x[1]^(-1)/((1-x[0]*x[2])*(1-x[0]^(-1)*x[1])*...x[0]^(-1)*x[2]^(-1)))\n' + + Testing the ``verbose`` option:: + + sage: n = count(cddin, cdd=True, verbose=True, raw_output=True) # optional - latte_int + This is LattE integrale ... + ... + Invocation: count '--redundancy-check=none' --cdd /dev/stdin + ... + Total Unimodular Cones: ... + Maximum number of simplicial cones in memory at once: ... + + **** The number of lattice points is: **** + Total time: ... sec + """ + from subprocess import Popen, PIPE + from sage.misc.misc import SAGE_TMP + from sage.rings.integer import Integer + + args = ['count'] + if ehrhart_polynomial and multivariate_generating_function: + raise ValueError + if ehrhart_polynomial: + args.append('--ehrhart-polynomial') + elif multivariate_generating_function: + args.append('--multivariate-generating-function') + + if 'redundancy_check' not in kwds: + args.append('--redundancy-check=none') + + for key,value in kwds.items(): + if value is None or value is False: + continue + + key = key.replace('_','-') + if value is True: + args.append('--{}'.format(key)) + else: + args.append('--{}={}'.format(key, value)) + + if multivariate_generating_function: + from sage.misc.temporary_file import tmp_filename + filename = tmp_filename() + with open(filename, 'w') as f: + f.write(arg) + args += [filename] + else: + args += ['/dev/stdin'] + + try: + # The cwd argument is needed because latte + # always produces diagnostic output files. + latte_proc = Popen(args, + stdin=PIPE, stdout=PIPE, + stderr=(None if verbose else PIPE), + cwd=str(SAGE_TMP)) + except OSError: + from sage.misc.package import PackageNotFoundError + raise PackageNotFoundError('latte_int') + + ans, err = latte_proc.communicate(arg) + ret_code = latte_proc.poll() + if ret_code: + if err is None: + err = ", see error message above" + else: + err = ":\n" + err + raise RuntimeError("LattE integrale program failed (exit code {})".format(ret_code) + err.strip()) + + + if ehrhart_polynomial: + ans = ans.splitlines()[-2] + if raw_output: + return ans + else: + from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing + from sage.rings.rational_field import QQ + R = PolynomialRing(QQ, 't') + return R(ans) + elif multivariate_generating_function: + with open(filename + '.rat') as f: + ans = f.read() + if raw_output: + return ans + else: + raise NotImplementedError("there is no Sage object to handle multivariate series from LattE, use raw_output=True") + else: + ans = ans.splitlines()[-1] + if not ans: + # opening a file is slow (30e-6s), so we read the file + # numOfLatticePoints only in case of a IndexError above + with open(SAGE_TMP+'/numOfLatticePoints', 'r') as f: + ans = f.read() + + if raw_output: + return ans + else: + from sage.rings.integer import Integer + return Integer(ans) From 6095e908045a1e34ee808469c0509af8c010a844 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 5 Mar 2017 08:09:17 +0100 Subject: [PATCH 306/370] Trac #22541 review: rephrase "destroy history" --- src/doc/en/developer/advanced_git.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/en/developer/advanced_git.rst b/src/doc/en/developer/advanced_git.rst index 8ed8b73f788..80e688f6fa4 100644 --- a/src/doc/en/developer/advanced_git.rst +++ b/src/doc/en/developer/advanced_git.rst @@ -161,8 +161,8 @@ Why not Merging the Other Way Round? Being on some new SageMath (e.g. on branch ``develop``) which runs successfully, it would be possible to merge in our branch ``some_code`` into develop. This would produce the same source files -and avoid unnecessary recompilations. However, it destroys git's -history. Thus, for example, it is hard to keep track of changes etc., +and avoid unnecessary recompilations. However, it makes reading git's +history very unpleasant: For example, it is hard to keep track of changes etc., as one cannot simply persue the first parent of each git commit. From ae616073781256753dfad6974bf6adb7e065aa4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 5 Mar 2017 10:30:54 +0100 Subject: [PATCH 307/370] py3 little cleanup of iteritems handling --- src/sage/crypto/boolean_function.pyx | 4 ++-- src/sage/rings/polynomial/laurent_polynomial.pyx | 11 +++++------ src/sage/rings/polynomial/pbori.pyx | 2 +- src/sage/rings/polynomial/plural.pyx | 13 +++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/sage/crypto/boolean_function.pyx b/src/sage/crypto/boolean_function.pyx index 1550f6cf27e..b342438387a 100644 --- a/src/sage/crypto/boolean_function.pyx +++ b/src/sage/crypto/boolean_function.pyx @@ -706,7 +706,7 @@ cdef class BooleanFunction(SageObject): sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction("7969817CC5893BA6AC326E47619F5AD0") - sage: sorted([_ for _ in B.absolute_walsh_spectrum().iteritems() ]) + sage: sorted(B.absolute_walsh_spectrum().items()) [(0, 64), (16, 64)] sage: B = BooleanFunction("0113077C165E76A8") @@ -881,7 +881,7 @@ cdef class BooleanFunction(SageObject): sage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction("7969817CC5893BA6AC326E47619F5AD0") - sage: sorted([ _ for _ in B.absolute_autocorrelation().iteritems() ]) + sage: sorted(B.absolute_autocorrelation().items()) [(0, 33), (8, 58), (16, 28), (24, 6), (32, 2), (128, 1)] """ d = {} diff --git a/src/sage/rings/polynomial/laurent_polynomial.pyx b/src/sage/rings/polynomial/laurent_polynomial.pyx index c6c266e8377..3669b5b7da1 100644 --- a/src/sage/rings/polynomial/laurent_polynomial.pyx +++ b/src/sage/rings/polynomial/laurent_polynomial.pyx @@ -10,7 +10,6 @@ Elements of Laurent polynomial rings # http://www.gnu.org/licenses/ #***************************************************************************** from __future__ import print_function -from six import iterkeys, iteritems from sage.rings.integer cimport Integer from sage.structure.element import is_Element, coerce_binop @@ -1568,7 +1567,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial_generic): if isinstance(x, dict): self._mon = ETuple({}, int(parent.ngens())) D = {} - for k, x_k in iteritems(x): # ETuple-ize keys, set _mon + for k, x_k in x.iteritems(): # ETuple-ize keys, set _mon if not isinstance(k, (tuple, ETuple)) or len(k) != parent.ngens(): self._mon = ETuple({}, int(parent.ngens())) break @@ -1579,7 +1578,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial_generic): else: x = D if not self._mon.is_constant(): # factor out _mon - x = {k.esub(self._mon): x_k for k, x_k in iteritems(x)} + x = {k.esub(self._mon): x_k for k, x_k in x.iteritems()} elif (isinstance(x, LaurentPolynomial_mpair) and parent.variable_names() == x.parent().variable_names()): self._mon = (x)._mon @@ -2147,7 +2146,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial_generic): sage: L. = LaurentPolynomialRing(QQ) sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7 - sage: list(sorted(f.dict().iteritems())) + sage: list(sorted(f.dict().items())) [((3, 1, 0), 3), ((4, 0, -2), 2), ((6, -7, 0), 1), ((7, 0, -1), 4)] """ if self._prod is None: @@ -2771,11 +2770,11 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial_generic): except ValueError: # call _derivative() recursively on coefficients return P({m: c._derivative(var) - for (m, c) in iteritems(self.dict())}) + for (m, c) in self.dict().iteritems()}) # compute formal derivative with respect to generator d = {} - for m, c in iteritems(self.dict()): + for m, c in self.dict().iteritems(): if m[index] != 0: new_m = [u for u in m] new_m[index] += -1 diff --git a/src/sage/rings/polynomial/pbori.pyx b/src/sage/rings/polynomial/pbori.pyx index aa6659c00f5..a4c6819b302 100644 --- a/src/sage/rings/polynomial/pbori.pyx +++ b/src/sage/rings/polynomial/pbori.pyx @@ -2607,7 +2607,7 @@ cdef class BooleanMonomial(MonoidElement): def iterindex(self): """ - Return an iterator over the indicies of the variables in self. + Return an iterator over the indices of the variables in self. EXAMPLES:: diff --git a/src/sage/rings/polynomial/plural.pyx b/src/sage/rings/polynomial/plural.pyx index c4166b6b232..95c3e579626 100644 --- a/src/sage/rings/polynomial/plural.pyx +++ b/src/sage/rings/polynomial/plural.pyx @@ -164,17 +164,18 @@ class G_AlgFactory(UniqueFactory): sage: A. = FreeAlgebra(QQ, 3) sage: H=A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) - sage: sorted(H.relations().iteritems(),key=str) + sage: sorted(H.relations().items(), key=str) [(y*x, x*y - z), (z*x, x*z + 2*x), (z*y, y*z - 2*y)] - """ # key = (base_ring,names, c,d, order, category) # extra args: check - base_ring,names,c,d,order,category = key + base_ring,names, c, d, order, category = key check = extra_args.get('check') - return NCPolynomialRing_plural(base_ring, names, c,d, order, category, check) + return NCPolynomialRing_plural(base_ring, names, c, d, order, + category, check) + def create_key_and_extra_args(self, base_ring, c,d, names=None, order=None, - category=None,check=None): + category=None,check=None): """ Create a unique key for g-algebras. @@ -2931,7 +2932,7 @@ def ExteriorAlgebra(base_ring, names,order='degrevlex'): sage: from sage.rings.polynomial.plural import ExteriorAlgebra sage: E = ExteriorAlgebra(QQ, ['x', 'y', 'z']) ; E #random Quotient of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: -x*z, z*y: -y*z, y*x: -x*y} by the ideal (z^2, y^2, x^2) - sage: sorted(E.cover().domain().relations().iteritems(),key=str) + sage: sorted(E.cover().domain().relations().items(), key=str) [(y*x, -x*y), (z*x, -x*z), (z*y, -y*z)] sage: sorted(E.cover().kernel().gens(),key=str) [x^2, y^2, z^2] From 17e931e9eaebb9d746c94989b067d80568fdd7f7 Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Wed, 22 Feb 2017 19:49:06 +0100 Subject: [PATCH 308/370] added 'neighborliness' and 'is_neighborly' methods --- src/sage/geometry/polyhedron/base.py | 84 +++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 3 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 5f7421b8ba4..8164fd0da38 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -28,7 +28,7 @@ from sage.rings.real_double import RDF from sage.modules.free_module_element import vector from sage.matrix.constructor import matrix -from sage.functions.other import sqrt, floor, ceil +from sage.functions.other import sqrt, floor, ceil, binomial from sage.groups.matrix_gps.finitely_generated import MatrixGroup from sage.graphs.graph import Graph @@ -2890,7 +2890,7 @@ def intersection(self, other): def truncation(self, cut_frac=None): r""" - Return a new polyhedron formed from two points on each edge + Return a new polyhedron formed from two points on each edgeis between two vertices. INPUT: @@ -4169,6 +4169,84 @@ def is_simplex(self): """ return self.is_compact() and (self.dim()+1 == self.n_vertices()) + def neighborliness(self): + r""" + Returns the largest k, such that the polyhedron is k-neighborly. + (Returns ``d+1`` in case of the d-dimensional simplex) + + + EXAMPLES:: + sage: cube = polytopes.cube() + sage: cube.neighborliness() + 1 + sage: P=Polyhedron(); P + The empty polyhedron in ZZ^0 + sage: P.neighborliness() + 0 + sage: C=polytopes.cyclic_polytope(7,10); C + A 7-dimensional polyhedron in QQ^7 defined as the convex hull of 10 vertices + sage: C.neighborliness() + 3 + sage: C=polytopes.cyclic_polytope(6,11); C + A 6-dimensional polyhedron in QQ^6 defined as the convex hull of 11 vertices + sage: C.neighborliness() + 3 + sage: [polytopes.cyclic_polytope(5,n).neighborliness() for n in range(6,10)] + [6, 2, 2, 2] + """ + if self.is_simplex(): + return self.dim() + 1 + else: + k = 1 + while(True): + if len(self.faces(k))==binomial(self.n_vertices(),k+1): + k += 1 + else: + return k + + + def is_neighborly(self, k=None): + r""" + Return whether the polyhedron is neighborly. + If the input k is provided then return whether the polyhedron is k-neighborly + + INPUT: + - ``k`` -- the dimension up to which to check if every set of k + vertices forms a face. If no k is provided, check up to floor + of half the dimension of the polyhedron. + + OUTPUT: + + ``True`` if the every set of up to k vertices forms a face, + ``False`` otherwise + + EXAMPLES:: + + Cyclic polytopes are neighborly: + + sage: all([polytopes.cyclic_polytope(i,i+1+j).is_neighborly() for i in range(5) for j in range(3)]) + True + + sage: cube = polytopes.hypercube(3) + sage: cube.is_neighborly() + True + sage: cube = polytopes.hypercube(4) + sage: cube.is_neighborly() + False + + The neighborliness of a polyhedron equals floor of dimension half + (or is large in case of a simplex) if and only if the polyhedron + is neighborly: + + sage: [(P.neighborliness()>=floor(P.dim()/2)) == P.is_neighborly() for P in [polytopes.cube(), polytopes.cyclic_polytope(6,9), polytopes.simplex(6)]] + [True, True, True] + + """ + if k == None: + k = floor(self.dim()/2) + return all(len(self.faces(l))==binomial(self.n_vertices(),l+1) for l in range(1,k)) + + @cached_method def is_lattice_polytope(self): r""" @@ -4718,7 +4796,7 @@ def restricted_automorphism_group(self, output="abstract"): - For ``output="matrixlist"``: a list of matrices. - REFERENCES: + REFERENCES: - [BSS2009]_ From a05912e84799cee40b1a2fec5483502ab7f73b1a Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Wed, 22 Feb 2017 19:52:04 +0100 Subject: [PATCH 309/370] undo accidental unwanted modification of truncation method --- src/sage/geometry/polyhedron/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 8164fd0da38..fb768cd00ec 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -2890,7 +2890,7 @@ def intersection(self, other): def truncation(self, cut_frac=None): r""" - Return a new polyhedron formed from two points on each edgeis + Return a new polyhedron formed from two points on each edge between two vertices. INPUT: From 07e8c58b93f60768cf44d7bcc0b1d5649935be01 Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Fri, 3 Mar 2017 19:39:55 +0100 Subject: [PATCH 310/370] improved docstring --- src/sage/geometry/polyhedron/base.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index fb768cd00ec..d04e31d4d71 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4171,11 +4171,13 @@ def is_simplex(self): def neighborliness(self): r""" - Returns the largest k, such that the polyhedron is k-neighborly. - (Returns ``d+1`` in case of the d-dimensional simplex) + Returns the largest ``k``, such that the polyhedron is ``k``-neighborly. + + In case of the ``d``-dimensional simplex, it returns ``d+1``. EXAMPLES:: + sage: cube = polytopes.cube() sage: cube.neighborliness() 1 @@ -4208,22 +4210,26 @@ def neighborliness(self): def is_neighborly(self, k=None): r""" Return whether the polyhedron is neighborly. - If the input k is provided then return whether the polyhedron is k-neighborly + + If the input ``k`` is provided then return whether the polyhedron is ``k``-neighborly INPUT: + - ``k`` -- the dimension up to which to check if every set of k - vertices forms a face. If no k is provided, check up to floor + vertices forms a face. If no ``k`` is provided, check up to floor of half the dimension of the polyhedron. OUTPUT: - ``True`` if the every set of up to k vertices forms a face, - ``False`` otherwise + - ``True`` if the every set of up to k vertices forms a face, + - ``False`` otherwise - EXAMPLES:: + EXAMPLES: Cyclic polytopes are neighborly: + :: + sage: all([polytopes.cyclic_polytope(i,i+1+j).is_neighborly() for i in range(5) for j in range(3)]) True @@ -4236,9 +4242,10 @@ def is_neighborly(self, k=None): The neighborliness of a polyhedron equals floor of dimension half (or is large in case of a simplex) if and only if the polyhedron - is neighborly: + is neighborly:: - sage: [(P.neighborliness()>=floor(P.dim()/2)) == P.is_neighborly() for P in [polytopes.cube(), polytopes.cyclic_polytope(6,9), polytopes.simplex(6)]] + sage: testpolys = [polytopes.cube(), polytopes.cyclic_polytope(6,9), polytopes.simplex(6)] + sage: [(P.neighborliness()>=floor(P.dim()/2)) == P.is_neighborly() for P in testpolys] [True, True, True] """ From 8552363654e92cd3a9d8afbaa26f6e68cf612cd8 Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Sun, 5 Mar 2017 11:37:46 +0100 Subject: [PATCH 311/370] spaces and more doctests --- src/sage/geometry/polyhedron/base.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index d04e31d4d71..e2a6176877d 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4173,7 +4173,7 @@ def neighborliness(self): r""" Returns the largest ``k``, such that the polyhedron is ``k``-neighborly. - In case of the ``d``-dimensional simplex, it returns ``d+1``. + In case of the ``d``-dimensional simplex, it returns ``d + 1``. EXAMPLES:: @@ -4185,6 +4185,14 @@ def neighborliness(self): The empty polyhedron in ZZ^0 sage: P.neighborliness() 0 + sage: P=Polyhedron([[0]]); P + A 0-dimensional polyhedron in ZZ^1 defined as the convex hull of 1 vertex + sage: P.neighborliness() + 1 + sage: S=polytopes.simplex(5); S + A 5-dimensional polyhedron in ZZ^6 defined as the convex hull of 6 vertices + sage: S.neighborliness() + 6 sage: C=polytopes.cyclic_polytope(7,10); C A 7-dimensional polyhedron in QQ^7 defined as the convex hull of 10 vertices sage: C.neighborliness() @@ -4200,12 +4208,9 @@ def neighborliness(self): return self.dim() + 1 else: k = 1 - while(True): - if len(self.faces(k))==binomial(self.n_vertices(),k+1): - k += 1 - else: - return k - + while len(self.faces(k)) == binomial(self.n_vertices(), k + 1): + k += 1 + return k def is_neighborly(self, k=None): r""" @@ -4230,7 +4235,7 @@ def is_neighborly(self, k=None): :: - sage: all([polytopes.cyclic_polytope(i,i+1+j).is_neighborly() for i in range(5) for j in range(3)]) + sage: all([polytopes.cyclic_polytope(i, i + 1 + j).is_neighborly() for i in range(5) for j in range(3)]) True sage: cube = polytopes.hypercube(3) @@ -4244,14 +4249,14 @@ def is_neighborly(self, k=None): (or is large in case of a simplex) if and only if the polyhedron is neighborly:: - sage: testpolys = [polytopes.cube(), polytopes.cyclic_polytope(6,9), polytopes.simplex(6)] + sage: testpolys = [polytopes.cube(), polytopes.cyclic_polytope(6, 9), polytopes.simplex(6)] sage: [(P.neighborliness()>=floor(P.dim()/2)) == P.is_neighborly() for P in testpolys] [True, True, True] """ if k == None: k = floor(self.dim()/2) - return all(len(self.faces(l))==binomial(self.n_vertices(),l+1) for l in range(1,k)) + return all(len(self.faces(l)) == binomial(self.n_vertices(), l + 1) for l in range(1, k)) @cached_method From 8e8d0d945305489baec679ce3c0f5eb47a4c5456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 5 Mar 2017 11:58:08 +0100 Subject: [PATCH 312/370] py3 simplify comparison in quadratic number fields (only keep _richcmp_) --- .../number_field_element_quadratic.pyx | 145 ++++++++---------- 1 file changed, 63 insertions(+), 82 deletions(-) diff --git a/src/sage/rings/number_field/number_field_element_quadratic.pyx b/src/sage/rings/number_field/number_field_element_quadratic.pyx index a23c8588dbd..2dc25445fe6 100644 --- a/src/sage/rings/number_field/number_field_element_quadratic.pyx +++ b/src/sage/rings/number_field/number_field_element_quadratic.pyx @@ -764,6 +764,69 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): sage: K. = QuadraticField(2) sage: 1/2 + sqrt2 > 0 True + + Two examples from the same number field with its two possible real + embeddings:: + + sage: K. = NumberField(x^2-x-1, 'phi', embedding=1.618) + sage: phi > 0 + True + sage: -phi > 0 + False + sage: phi - 3 == 2*phi + 1 + False + sage: fibonacci(10)*phi < fibonacci(11) + True + sage: RDF(fibonacci(10)*phi) + 88.99186938124421 + sage: fibonacci(11) + 89 + sage: l = [-2, phi+3, 2*phi-1, 2*phi-5, 0, -phi+2, fibonacci(20)*phi - fibonacci(21)] + sage: l.sort() + sage: l + [-2, 2*phi - 5, 6765*phi - 10946, 0, -phi + 2, 2*phi - 1, phi + 3] + sage: list(map(RDF, l)) + [-2.0, -1.7639320225002102, -6.610696073039435e-05, 0.0, 0.3819660112501051, 2.23606797749979, 4.618033988749895] + + :: + + sage: L. = NumberField(x^2-x-1, 'psi', embedding=-0.618) + sage: psi < 0 + True + sage: 2*psi + 3 == 2*psi + 3 + True + sage: fibonacci(10)*psi < -fibonacci(9) + False + sage: RDF(fibonacci(10)*psi) + -33.99186938124422 + sage: fibonacci(9) + 34 + sage: l = [-1, psi, 0, fibonacci(20)*psi + fibonacci(19), 3*psi+2] + sage: l.sort() + sage: l + [-1, psi, 0, 6765*psi + 4181, 3*psi + 2] + sage: list(map(RDF, l)) + [-1.0, -0.6180339887498949, 0.0, 6.610696073039435e-05, 0.1458980337503153] + + For a field with no specified embedding the comparison uses the standard + embedding:: + + sage: K. = NumberField(x^2-2, 'sqrt2') + sage: sqrt2 > 1 and sqrt2 < 2 + True + + The following examples illustrate the same behavior for a complex + quadratic field:: + + sage: K. = QuadraticField(-1) + sage: l = [-2, i-3, 2*i-2, 2*i+2, 5*i, 1-3*i, -1+i, 1] + sage: l.sort() + sage: l + [i - 3, -2, 2*i - 2, i - 1, 5*i, -3*i + 1, 1, 2*i + 2] + sage: list(map(CDF, l)) + [-3.0 + 1.0*I, -2.0, -2.0 + 2.0*I, -1.0 + 1.0*I, 5.0*I, 1.0 - 3.0*I, 1.0, 2.0 + 2.0*I] + sage: list(map(CDF, l)) == sorted(map(CDF, l)) + True """ # When D > 0 and standard embedding, we compare (a + b * sqrt(D)) / d and (aa + # bb * sqrt(D)) / dd using the comparison of (dd*a - d * aa)^2 and (d*bb - dd*b)^2 * D @@ -845,88 +908,6 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): mpz_clear(j) return rich_to_bool_sgn(op, test) - cpdef int _cmp_(left, _right) except -2: - """ - Comparisons of elements. - - When there is a real embedding defined, the comparisons uses comparison - induced from the reals. Otherwise, comparison is a lexicographic - comparison on coefficients. - - EXAMPLES: - - Two examples from the same number field with its two possible real - embeddings:: - - sage: K. = NumberField(x^2-x-1, 'phi', embedding=1.618) - sage: phi > 0 - True - sage: -phi > 0 - False - sage: phi - 3 == 2*phi + 1 - False - sage: fibonacci(10)*phi < fibonacci(11) - True - sage: RDF(fibonacci(10)*phi) - 88.99186938124421 - sage: fibonacci(11) - 89 - sage: l = [-2, phi+3, 2*phi-1, 2*phi-5, 0, -phi+2, fibonacci(20)*phi - fibonacci(21)] - sage: l.sort() - sage: l - [-2, 2*phi - 5, 6765*phi - 10946, 0, -phi + 2, 2*phi - 1, phi + 3] - sage: list(map(RDF, l)) - [-2.0, -1.7639320225002102, -6.610696073039435e-05, 0.0, 0.3819660112501051, 2.23606797749979, 4.618033988749895] - - :: - - sage: L. = NumberField(x^2-x-1, 'psi', embedding=-0.618) - sage: psi < 0 - True - sage: 2*psi + 3 == 2*psi + 3 - True - sage: fibonacci(10)*psi < -fibonacci(9) - False - sage: RDF(fibonacci(10)*psi) - -33.99186938124422 - sage: fibonacci(9) - 34 - sage: l = [-1, psi, 0, fibonacci(20)*psi + fibonacci(19), 3*psi+2] - sage: l.sort() - sage: l - [-1, psi, 0, 6765*psi + 4181, 3*psi + 2] - sage: list(map(RDF, l)) - [-1.0, -0.6180339887498949, 0.0, 6.610696073039435e-05, 0.1458980337503153] - - For a field with no specified embedding the comparison uses the standard - embedding:: - - sage: K. = NumberField(x^2-2, 'sqrt2') - sage: sqrt2 > 1 and sqrt2 < 2 - True - - The following examples illustrate the same behavior for a complex - quadratic field:: - - sage: K. = QuadraticField(-1) - sage: l = [-2, i-3, 2*i-2, 2*i+2, 5*i, 1-3*i, -1+i, 1] - sage: l.sort() - sage: l - [i - 3, -2, 2*i - 2, i - 1, 5*i, -3*i + 1, 1, 2*i + 2] - sage: list(map(CDF, l)) - [-3.0 + 1.0*I, -2.0, -2.0 + 2.0*I, -1.0 + 1.0*I, 5.0*I, 1.0 - 3.0*I, 1.0, 2.0 + 2.0*I] - sage: list(map(CDF, l)) == sorted(map(CDF, l)) - True - """ - cdef NumberFieldElement_quadratic right = _right - cdef int test - - if left == right: - return 0 - if left > right: - return 1 - return -1 - def continued_fraction_list(self): r""" Return the preperiod and the period of the continued fraction expansion From 51a05cf09ad151dd77eb37a9e088ea9b73efd60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Sun, 5 Mar 2017 12:06:43 +0100 Subject: [PATCH 313/370] Renamed subsection and moved it --- .../en/reference/discrete_geometry/index.rst | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/doc/en/reference/discrete_geometry/index.rst b/src/doc/en/reference/discrete_geometry/index.rst index 29a19abcc40..e59cbd0d2ae 100644 --- a/src/doc/en/reference/discrete_geometry/index.rst +++ b/src/doc/en/reference/discrete_geometry/index.rst @@ -46,6 +46,20 @@ Lattice polyhedra sage/geometry/polyhedron/ppl_lattice_polygon sage/geometry/polyhedron/ppl_lattice_polytope +Toric geometry +~~~~~~~~~~~~~~ + +.. toctree:: + :maxdepth: 1 + + sage/geometry/toric_lattice + sage/geometry/cone + sage/geometry/fan + sage/geometry/fan_morphism + sage/geometry/point_collection + sage/geometry/toric_plotter + sage/rings/polynomial/groebner_fan + Base classes for polyhedra ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -70,19 +84,6 @@ Backends for Polyhedra sage/geometry/polyhedron/double_description sage/geometry/polyhedron/double_description_inhomogeneous -Toric varieties ---------------- - -.. toctree:: - :maxdepth: 1 - - sage/geometry/toric_lattice - sage/geometry/cone - sage/geometry/fan - sage/geometry/fan_morphism - sage/geometry/point_collection - sage/geometry/toric_plotter - sage/rings/polynomial/groebner_fan Triangulations -------------- From 06e55ff0746528a60636046866d3125e59860f78 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 5 Mar 2017 12:07:04 +0100 Subject: [PATCH 314/370] Trac #22451 review: explain removing worktree --- src/doc/en/developer/advanced_git.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/doc/en/developer/advanced_git.rst b/src/doc/en/developer/advanced_git.rst index 80e688f6fa4..ebc38d738f4 100644 --- a/src/doc/en/developer/advanced_git.rst +++ b/src/doc/en/developer/advanced_git.rst @@ -154,6 +154,11 @@ We still need to call:: but only changed files will be recompiled. +To remove the new working tree simply use +:: + + rm -r new_worktree + Why not Merging the Other Way Round? ------------------------------------ From 5a30f8358285a29dd97cd5c57dc6bf9a5a37eee6 Mon Sep 17 00:00:00 2001 From: Daniel Krenn Date: Sun, 5 Mar 2017 12:07:35 +0100 Subject: [PATCH 315/370] Trac #22451: typo with :: --- src/doc/en/developer/advanced_git.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/en/developer/advanced_git.rst b/src/doc/en/developer/advanced_git.rst index ebc38d738f4..a8b1c7b9c4d 100644 --- a/src/doc/en/developer/advanced_git.rst +++ b/src/doc/en/developer/advanced_git.rst @@ -148,7 +148,8 @@ We can now safely checkout ``some_code``:: git checkout some_code -We still need to call:: +We still need to call +:: make From 5bcd77eee9e967719827a4b5cd765333f06b9da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 5 Mar 2017 14:22:13 +0100 Subject: [PATCH 316/370] for clarity of code, use Py_EQ, Py_NE, etc, in rich comparison --- src/sage/combinat/words/word_char.pyx | 13 ++--- src/sage/combinat/words/word_datatypes.pyx | 17 ++++--- src/sage/data_structures/bitset.pyx | 26 +++++----- src/sage/libs/coxeter3/coxeter.pyx | 51 ++++++++++--------- src/sage/libs/ecl.pyx | 9 ++-- src/sage/libs/gap/util.pyx | 13 ++--- src/sage/libs/ppl.pyx | 13 ++--- src/sage/matroids/basis_matroid.pyx | 7 +-- .../matroids/circuit_closures_matroid.pyx | 7 +-- src/sage/matroids/lean_matrix.pyx | 39 +++++++------- src/sage/matroids/linear_matroid.pyx | 7 +-- src/sage/matroids/matroid.pyx | 12 +++-- src/sage/rings/complex_interval.pyx | 13 ++--- src/sage/rings/integer.pyx | 6 ++- .../sat/solvers/cryptominisat/solverconf.pyx | 7 +-- 15 files changed, 128 insertions(+), 112 deletions(-) diff --git a/src/sage/combinat/words/word_char.pyx b/src/sage/combinat/words/word_char.pyx index d93e146224f..9670573d65d 100644 --- a/src/sage/combinat/words/word_char.pyx +++ b/src/sage/combinat/words/word_char.pyx @@ -17,10 +17,12 @@ include "cysignals/memory.pxi" include "sage/data_structures/bitset.pxi" cimport cython +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from sage.rings.integer cimport Integer, smallInteger from sage.rings.rational cimport Rational from libc.string cimport memcpy, memcmp from sage.combinat.words.word_datatypes cimport WordDatatype +from sage.structure.sage_object cimport rich_to_bool from cpython.number cimport PyIndex_Check, PyNumber_Check from cpython.sequence cimport PySequence_Check @@ -292,16 +294,11 @@ cdef class WordDatatype_char(WordDatatype): return NotImplemented # word of different lengths are not equal! - if (op == 2 or op == 3) and ( self)._length != ( other)._length: - return op == 3 + if (op == Py_EQ or op == Py_NE) and ( self)._length != ( other)._length: + return op == Py_NE cdef int test = ( self)._lexico_cmp(other) - if test < 0: - return op < 2 or op == 3 - elif test > 0: - return op > 2 - else: - return op == 1 or op == 2 or op == 5 + return rich_to_bool(op, test) cdef int _lexico_cmp(self, WordDatatype_char other) except -2: r""" diff --git a/src/sage/combinat/words/word_datatypes.pyx b/src/sage/combinat/words/word_datatypes.pyx index 70e08b9ad33..c2dc3663e93 100644 --- a/src/sage/combinat/words/word_datatypes.pyx +++ b/src/sage/combinat/words/word_datatypes.pyx @@ -13,9 +13,10 @@ Datatypes for finite words #***************************************************************************** from __future__ import print_function - +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from itertools import islice + cdef class WordDatatype(object): r""" The generic WordDatatype class. @@ -173,15 +174,15 @@ cdef class WordDatatype_list(WordDatatype): http://docs.cython.org/docs/special_methods.html """ - if op == 2: # == + if op == Py_EQ: if isinstance(other, WordDatatype_list): return self._data == other._data else: # Otherwise, force FiniteWord_class.__eq__ to do it # (if we don't force it, then __cmp__ is called before) from sage.combinat.words.word import FiniteWord_class - return FiniteWord_class.__eq__(self,other) - elif op == 3: # != + return FiniteWord_class.__eq__(self, other) + elif op == Py_NE: if isinstance(other, WordDatatype_list): return self._data != other._data else: @@ -384,7 +385,7 @@ cdef class WordDatatype_str(WordDatatype): http://docs.cython.org/docs/special_methods.html """ - if op == 2: # == + if op == Py_EQ: if isinstance(other, WordDatatype_str): return self._data == other._data else: @@ -392,7 +393,7 @@ cdef class WordDatatype_str(WordDatatype): # (if we don't force it, then __cmp__ is called before) from sage.combinat.words.word import FiniteWord_class return FiniteWord_class.__eq__(self,other) - elif op == 3: # != + elif op == Py_NE: if isinstance(other, WordDatatype_str): return self._data != other._data else: @@ -998,7 +999,7 @@ cdef class WordDatatype_tuple(WordDatatype): http://docs.cython.org/docs/special_methods.html """ - if op == 2: # == + if op == Py_EQ: if isinstance(other, WordDatatype_tuple): return self._data == other._data else: @@ -1006,7 +1007,7 @@ cdef class WordDatatype_tuple(WordDatatype): # (if we don't force it, then __cmp__ is called before) from sage.combinat.words.word import FiniteWord_class return FiniteWord_class.__eq__(self,other) - elif op == 3: # != + elif op == Py_NE: if isinstance(other, WordDatatype_tuple): return self._data != other._data else: diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx index bfb3a93e3d4..24ed5553b6f 100644 --- a/src/sage/data_structures/bitset.pyx +++ b/src/sage/data_structures/bitset.pyx @@ -33,6 +33,8 @@ linear in ``capacity``. from __future__ import print_function include "bitset.pxi" +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE + cdef class FrozenBitset: r""" @@ -657,17 +659,17 @@ cdef class FrozenBitset: left = self right = other._larger_capacity_(self._bitset.size) - if op == 2: # == + if op == Py_EQ: # == return bitset_eq(left._bitset, right._bitset) - elif op == 3: # != + elif op == Py_NE: # != return not bitset_eq(left._bitset, right._bitset) - elif op == 0: # < + elif op == Py_LT: # < return bitset_issubset(left._bitset, right._bitset) and not bitset_eq(left._bitset, right._bitset) - elif op == 1: # <= + elif op == Py_LE: # <= return bitset_issubset(left._bitset, right._bitset) - elif op == 4: # > + elif op == Py_GT: # > return bitset_issuperset(left._bitset, right._bitset) and not bitset_eq(left._bitset, right._bitset) - elif op == 5: # >= + elif op == Py_GE: # >= return bitset_issuperset(left._bitset, right._bitset) cpdef bint issubset(self, FrozenBitset other) except -1: @@ -1399,17 +1401,17 @@ cdef class Bitset(FrozenBitset): left = self right = other._larger_capacity_(self._bitset.size) - if op == 2: # == + if op == Py_EQ: # == return bitset_eq(left._bitset, right._bitset) - elif op == 3: # != + elif op == Py_NE: # != return not bitset_eq(left._bitset, right._bitset) - elif op == 0: # < + elif op == Py_LT: # < return bitset_issubset(left._bitset, right._bitset) and not bitset_eq(left._bitset, right._bitset) - elif op == 1: # <= + elif op == Py_LE: # <= return bitset_issubset(left._bitset, right._bitset) - elif op == 4: # > + elif op == Py_GT: # > return bitset_issuperset(left._bitset, right._bitset) and not bitset_eq(left._bitset, right._bitset) - elif op == 5: # >= + elif op == Py_GE: # >= return bitset_issuperset(left._bitset, right._bitset) cdef FrozenBitset _new(self, long int capacity): diff --git a/src/sage/libs/coxeter3/coxeter.pyx b/src/sage/libs/coxeter3/coxeter.pyx index be688574931..467e633fd12 100644 --- a/src/sage/libs/coxeter3/coxeter.pyx +++ b/src/sage/libs/coxeter3/coxeter.pyx @@ -14,6 +14,7 @@ Low level part of the interface to Fokko Ducloux's Coxeter 3 library #***************************************************************************** from .decl cimport * +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE initConstants() @@ -21,6 +22,7 @@ from sage.rings.integer import Integer from sage.rings.integer_ring import ZZ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing + cdef class String: def __cinit__(self, s=""): """ @@ -96,17 +98,17 @@ cdef class String: s = repr(self) o = repr(other) - if op == 2: # == + if op == Py_EQ: # == return s == o - elif op == 3: # != + elif op == Py_NE: # != return s != o - elif op == 0: # < + elif op == Py_LT: # < return s < o - elif op == 1: # <= + elif op == Py_LE: # <= return s <= o - elif op == 4: # > + elif op == Py_GT: # > return s > o - elif op == 5: # >= + elif op == Py_GE: # >= return s >= o def __len__(self): @@ -219,17 +221,17 @@ cdef class Type: s = repr(self) o = repr(other) - if op == 2: # == + if op == Py_EQ: # == return s == o - elif op == 3: # != + elif op == Py_NE: # != return s != o - elif op == 0: # < + elif op == Py_LT: # < return s < o - elif op == 1: # <= + elif op == Py_LE: # <= return s <= o - elif op == 4: # > + elif op == Py_GT: # > return s > o - elif op == 5: # >= + elif op == Py_GE: # >= return s >= o def __reduce__(self): @@ -368,17 +370,17 @@ cdef class CoxGroup(SageObject): s_r = self.rank() o_r = other.rank() - if op == 2: # == + if op == Py_EQ: # == return s_t == o_t and s_r == o_r - elif op == 3: # != + elif op == Py_NE: # != return s_t != o_t or s_r != o_r - elif op == 0: # < + elif op == Py_LT: # < return s_t < o_t or (s_t == o_t and s_r < o_r) - elif op == 1: # <= + elif op == Py_LE: # <= return s_t < o_t or (s_t == o_t and s_r <= o_r) - elif op == 4: # > + elif op == Py_GT: # > return s_t > o_t or (s_t == o_t and s_r > o_r) - elif op == 5: # >= + elif op == Py_GE: # >= return s_t > o_t or (s_t == o_t and s_r >= o_r) def __reduce__(self): @@ -865,20 +867,19 @@ cdef class CoxGroupElement: s_l = list(self) o_l = list(other) - if op == 2: # == + if op == Py_EQ: # == return s_p == o_p and s_l == o_l - elif op == 3: # != + elif op == Py_NE: # != return s_p != o_p or s_l != o_l - elif op == 0: # < + elif op == Py_LT: # < return s_p < o_p or (s_p == o_p and s_l < o_l) - elif op == 1: # <= + elif op == Py_LE: # <= return s_p < o_p or (s_p == o_p and s_l <= o_l) - elif op == 4: # > + elif op == Py_GT: # > return s_p > o_p or (s_p == o_p and s_l > o_l) - elif op == 5: # >= + elif op == Py_GE: # >= return s_p > o_p or (s_p == o_p and s_l >= o_l) - def __iter__(self): """ Return an iterator for the letters in the reduced word for this element. diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx index 1fafb6cd7b9..26e99c6e31a 100644 --- a/src/sage/libs/ecl.pyx +++ b/src/sage/libs/ecl.pyx @@ -25,6 +25,7 @@ from posix.signal cimport sigaction, sigaction_t from sage.rings.integer cimport Integer from sage.rings.rational cimport Rational +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE #it would be preferrable to let bint_symbolp wrap an efficient macro #but the macro provided in object.h doesn't seem to work @@ -818,13 +819,13 @@ cdef class EclObject: sage: EclObject("<")(a,b) """ - if op == 2: # "==" - if not(isinstance(left,EclObject)) or not(isinstance(right,EclObject)): + if op == Py_EQ: # "==" + if not(isinstance(left,EclObject) and isinstance(right,EclObject)): return False else: return bint_equal((left).obj,(right).obj) - elif op == 3: # "!=" - if not(isinstance(left,EclObject)) or not(isinstance(right,EclObject)): + elif op == Py_NE: # "!=" + if not(isinstance(left,EclObject) and isinstance(right,EclObject)): return True else: return not(bint_equal((left).obj,(right).obj)) diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx index 347fe60a239..730998e4711 100644 --- a/src/sage/libs/gap/util.pyx +++ b/src/sage/libs/gap/util.pyx @@ -12,6 +12,7 @@ Utility functions for libGAP ############################################################################### from __future__ import print_function, absolute_import +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from sage.env import SAGE_LOCAL, GAP_ROOT_DIR from libc.stdint cimport uintptr_t from .element cimport * @@ -59,17 +60,17 @@ cdef class ObjWrapper(object): cdef result cdef libGAP_Obj self_value = self.value cdef libGAP_Obj other_value = other.value - if op==0: # < 0 + if op == Py_LT: # < 0 return self_value < other_value - elif op==1: # <= 1 + elif op == Py_LE: # <= 1 return self_value <= other_value - elif op==2: # == 2 + elif op == Py_EQ: # == 2 return self_value == other_value - elif op==4: # > 4 + elif op == Py_GT: # > 4 return self_value > other_value - elif op==5: # >= 5 + elif op == Py_GE: # >= 5 return self_value >= other_value - elif op==3: # != 3 + elif op == Py_NE: # != 3 return self_value != other_value else: assert False # unreachable diff --git a/src/sage/libs/ppl.pyx b/src/sage/libs/ppl.pyx index 90b31cabc2d..469fc5ab576 100644 --- a/src/sage/libs/ppl.pyx +++ b/src/sage/libs/ppl.pyx @@ -159,6 +159,7 @@ from sage.rings.rational cimport Rational include "cysignals/signals.pxi" from libcpp cimport bool as cppbool +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE #################################################### # Potentially expensive operations: @@ -3131,17 +3132,17 @@ cdef class Polyhedron(_mutable_or_immutable): """ cdef result sig_on() - if op==0: # < 0 + if op == Py_LT: # < 0 result = rhs.strictly_contains(lhs) - elif op==1: # <= 1 + elif op == Py_LE: # <= 1 result = rhs.contains(lhs) - elif op==2: # == 2 + elif op == Py_EQ: # == 2 result = (lhs.thisptr[0] == rhs.thisptr[0]) - elif op==4: # > 4 + elif op == Py_GT: # > 4 result = lhs.strictly_contains(rhs) - elif op==5: # >= 5 + elif op == Py_GE: # >= 5 result = lhs.contains(rhs) - elif op==3: # != 3 + elif op == Py_NE: # != 3 result = (lhs.thisptr[0] != rhs.thisptr[0]) else: assert False # unreachable diff --git a/src/sage/matroids/basis_matroid.pyx b/src/sage/matroids/basis_matroid.pyx index 52b94326897..d14e88b0048 100644 --- a/src/sage/matroids/basis_matroid.pyx +++ b/src/sage/matroids/basis_matroid.pyx @@ -78,6 +78,7 @@ include 'sage/data_structures/bitset.pxi' from .matroid cimport Matroid from .basis_exchange_matroid cimport BasisExchangeMatroid from .set_system cimport SetSystem +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from sage.arith.all import binomial @@ -1152,13 +1153,13 @@ cdef class BasisMatroid(BasisExchangeMatroid): sage: M == N False """ - if op in [0, 1, 4, 5]: # <, <=, >, >= + if op not in (Py_EQ, Py_NE): return NotImplemented if not isinstance(left, BasisMatroid) or not isinstance(right, BasisMatroid): return NotImplemented - if op == 2: # == + if op == Py_EQ: # == res = True - if op == 3: # != + if op == Py_NE: # != res = False # res gets inverted if matroids are deemed different. if left.equals(right): diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx index 17b39071615..a919fb48505 100644 --- a/src/sage/matroids/circuit_closures_matroid.pyx +++ b/src/sage/matroids/circuit_closures_matroid.pyx @@ -70,6 +70,7 @@ from __future__ import absolute_import from .matroid cimport Matroid from .set_system cimport SetSystem from .utilities import setprint_s +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE cdef class CircuitClosuresMatroid(Matroid): @@ -476,15 +477,15 @@ cdef class CircuitClosuresMatroid(Matroid): False """ cdef CircuitClosuresMatroid lt, rt - if op in [0, 1, 4, 5]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: # <, <=, >, >= return NotImplemented if not isinstance(left, CircuitClosuresMatroid) or not isinstance(right, CircuitClosuresMatroid): return NotImplemented lt = left rt = right - if op == 2: # == + if op == Py_EQ: # == res = True - if op == 3: # != + if op == Py_NE: # != res = False # res gets inverted if matroids are deemed different. if lt.groundset() != rt.groundset(): diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx index fb0f20fb3a8..03cf1ba7ba6 100644 --- a/src/sage/matroids/lean_matrix.pyx +++ b/src/sage/matroids/lean_matrix.pyx @@ -33,11 +33,14 @@ AUTHORS: include "cysignals/memory.pxi" include 'sage/data_structures/bitset.pxi' from libc.string cimport memcpy, memset +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE + from sage.matrix.matrix2 cimport Matrix from sage.rings.all import ZZ, FiniteField, GF from sage.rings.integer cimport Integer import sage.matrix.constructor + cdef class LeanMatrix: """ Lean matrices @@ -444,15 +447,15 @@ cdef class LeanMatrix: False """ cdef long i, j - if op in [0, 1, 4, 5]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: # <, <=, >, >= return NotImplemented if not isinstance(left, LeanMatrix) or not isinstance(right, LeanMatrix): return NotImplemented if type(left) != type(right): return NotImplemented - if op == 2: # == + if op == Py_EQ: # == res = True - if op == 3: # != + if op == Py_NE: # != res = False # res gets inverted if matroids are deemed different. if left.nrows() != right.nrows(): @@ -908,13 +911,13 @@ cdef class GenericMatrix(LeanMatrix): False """ cdef long i, j - if op in [0, 1, 4, 5]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: # <, <=, >, >= return NotImplemented if not isinstance(left, GenericMatrix) or not isinstance(right, GenericMatrix): return NotImplemented - if op == 2: # == + if op == Py_EQ: # == res = True - if op == 3: # != + if op == Py_NE: # != res = False # res gets inverted if matroids are deemed different. if left.nrows() != right.nrows(): @@ -1510,13 +1513,13 @@ cdef class BinaryMatrix(LeanMatrix): False """ cdef long i, j - if op in [0, 1, 4, 5]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: # <, <=, >, >= return NotImplemented if not isinstance(left, BinaryMatrix) or not isinstance(right, BinaryMatrix): return NotImplemented - if op == 2: # == + if op == Py_EQ: # == res = True - if op == 3: # != + if op == Py_NE: # != res = False # res gets inverted if matroids are deemed different. if left.nrows() != right.nrows(): @@ -2065,13 +2068,13 @@ cdef class TernaryMatrix(LeanMatrix): False """ cdef long i, j - if op in [0, 1, 4, 5]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: # <, <=, >, >= return NotImplemented if not isinstance(left, TernaryMatrix) or not isinstance(right, TernaryMatrix): return NotImplemented - if op == 2: # == + if op == Py_EQ: # == res = True - if op == 3: # != + if op == Py_NE: # != res = False # res gets inverted if matroids are deemed different. if left.nrows() != right.nrows(): @@ -2664,13 +2667,13 @@ cdef class QuaternaryMatrix(LeanMatrix): False """ cdef long i, j - if op in [0, 1, 4, 5]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: # <, <=, >, >= return NotImplemented if not isinstance(left, QuaternaryMatrix) or not isinstance(right, QuaternaryMatrix): return NotImplemented - if op == 2: # == + if op == Py_EQ: # == res = True - if op == 3: # != + if op == Py_NE: # != res = False if left.base_ring() != right.base_ring(): return not res @@ -3135,13 +3138,13 @@ cdef class IntegerMatrix(LeanMatrix): False """ cdef long i, j - if op in [0, 1, 4, 5]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: # <, <=, >, >= return NotImplemented if not isinstance(left, IntegerMatrix) or not isinstance(right, IntegerMatrix): return NotImplemented - if op == 2: # == + if op == Py_EQ: # == res = True - if op == 3: # != + if op == Py_NE: # != res = False # res gets inverted if matroids are deemed different. if left.nrows() != right.nrows(): diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx index d7d74665397..a10c9035fb3 100644 --- a/src/sage/matroids/linear_matroid.pyx +++ b/src/sage/matroids/linear_matroid.pyx @@ -111,6 +111,7 @@ Methods from __future__ import print_function, absolute_import include 'sage/data_structures/bitset.pxi' +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from sage.matroids.matroid cimport Matroid from sage.matroids.basis_exchange_matroid cimport BasisExchangeMatroid @@ -1221,15 +1222,15 @@ cdef class LinearMatroid(BasisExchangeMatroid): sage: M1 == M3 # indirect doctest True """ - if op in [0, 1, 4, 5]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: # <, <=, >, >= return NotImplemented if not isinstance(left, LinearMatroid) or not isinstance(right, LinearMatroid): return NotImplemented if left.__class__ != right.__class__: # since we have some subclasses, an extra test return NotImplemented - if op == 2: # == + if op == Py_EQ: # == res = True - if op == 3: # != + if op == Py_NE: # != res = False # res gets inverted if matroids are deemed different. if left.is_field_equivalent(right): diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index fe86c5f44bd..bdf68413e72 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -325,6 +325,8 @@ Methods #***************************************************************************** from __future__ import absolute_import +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE + from sage.structure.sage_object cimport SageObject from itertools import combinations, permutations, product from .set_system cimport SetSystem @@ -3542,7 +3544,7 @@ cdef class Matroid(SageObject): True """ from . import basis_matroid - if op in [0, 1, 4, 5]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: # <, <=, >, >= return NotImplemented if left.__class__ != right.__class__: return NotImplemented @@ -3552,15 +3554,15 @@ cdef class Matroid(SageObject): # sage.matroids.matroid.Matroid.__richcmp__(p, q, 2) # Non-abstract subclasses should just call isinstance on both left and right. if hash(left) != hash(right): - if op == 2: # == + if op == Py_EQ: # == return False - if op == 3: # != + if op == Py_NE: # != return True res = (basis_matroid.BasisMatroid(left) == basis_matroid.BasisMatroid(right)) # Default implementation - if op == 2: # == + if op == Py_EQ: # == return res - if op == 3: # != + if op == Py_NE: # != return not res # Minors and duality diff --git a/src/sage/rings/complex_interval.pyx b/src/sage/rings/complex_interval.pyx index e25c7ef561c..c267a5571e2 100644 --- a/src/sage/rings/complex_interval.pyx +++ b/src/sage/rings/complex_interval.pyx @@ -47,6 +47,7 @@ from sage.libs.flint.fmpz cimport * from sage.libs.cypari2.gen cimport Gen as pari_gen from sage.libs.mpfr cimport MPFR_RNDU, MPFR_RNDD +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from sage.structure.element cimport FieldElement, RingElement, Element, ModuleElement from sage.structure.parent cimport Parent from .complex_number cimport ComplexNumber @@ -1448,7 +1449,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): cdef ComplexIntervalFieldElement lt, rt lt = left rt = right - if op == 2: #== + if op == Py_EQ: # == # intervals a == b iff a<=b and b <= a # (this gives a result with two comparisons, where the # obvious approach would use three) @@ -1456,7 +1457,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): and mpfr_lessequal_p(&rt.__re.right, <.__re.left) \ and mpfr_lessequal_p(<.__im.right, &rt.__im.left) \ and mpfr_lessequal_p(&rt.__im.right, <.__im.left) - elif op == 3: #!= + elif op == Py_NE: # != return mpfr_less_p(<.__re.right, &rt.__re.left) \ or mpfr_less_p(&rt.__re.right, <.__re.left) \ or mpfr_less_p(<.__im.right, &rt.__im.left) \ @@ -1468,13 +1469,13 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): diff = left - right real_diff = diff.real() imag_diff = diff.imag() - if op == 0: #< + if op == Py_LT: # < return real_diff < 0 or (real_diff == 0 and imag_diff < 0) - elif op == 1: #<= + elif op == Py_LE: # <= return real_diff < 0 or (real_diff == 0 and imag_diff <= 0) - elif op == 4: #> + elif op == Py_GT: # > return real_diff > 0 or (real_diff == 0 and imag_diff > 0) - elif op == 5: #>= + elif op == Py_GE: # >= return real_diff > 0 or (real_diff == 0 and imag_diff >= 0) cpdef int _cmp_(left, right) except -2: diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 0b9786441a3..624dff489a2 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -911,7 +911,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): c = mpz_cmp((left).value, mpz_tmp) elif isinstance(right, float): d = right - if isnan(d): return op == 3 + if isnan(d): + return op == Py_NE c = mpz_cmp_d((left).value, d) else: return coercion_model.richcmp(left, right, op) @@ -923,7 +924,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): c = mpz_cmp(mpz_tmp, (right).value) if isinstance(left, float): d = left - if isnan(d): return op == 3 + if isnan(d): + return op == Py_NE c = -mpz_cmp_d((right).value, d) else: return coercion_model.richcmp(left, right, op) diff --git a/src/sage/sat/solvers/cryptominisat/solverconf.pyx b/src/sage/sat/solvers/cryptominisat/solverconf.pyx index 36f50d8e455..6f977401b0c 100644 --- a/src/sage/sat/solvers/cryptominisat/solverconf.pyx +++ b/src/sage/sat/solvers/cryptominisat/solverconf.pyx @@ -41,6 +41,7 @@ AUTHORS: ### from libc.stdint cimport uint32_t, uint64_t +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE cdef class SolverConf(object): @@ -288,12 +289,12 @@ cdef class SolverConf(object): ... TypeError: Configurations are not ordered. """ - if op not in (2,3): + if op not in (Py_EQ, Py_NE): raise TypeError("Configurations are not ordered.") res = all(self[name] == other[name] for name in self.trait_names()) - if op == 2: # == + if op == Py_EQ: # == return res - if op == 3: # != + if op == Py_NE: # != return not res def __copy__(self): From ec8fc985db5bd75d4bc4b18e98aeb6b4b81413bd Mon Sep 17 00:00:00 2001 From: Eric Gourgoulhon Date: Sun, 5 Mar 2017 14:36:38 +0100 Subject: [PATCH 317/370] Fix bug in list functionality of free module bases (#22518) --- src/sage/tensor/modules/free_module_basis.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sage/tensor/modules/free_module_basis.py b/src/sage/tensor/modules/free_module_basis.py index dae6e8e97fe..94785479f33 100644 --- a/src/sage/tensor/modules/free_module_basis.py +++ b/src/sage/tensor/modules/free_module_basis.py @@ -72,8 +72,18 @@ def __iter__(self): [Linear form e^0 on the Rank-3 free module M over the Integer Ring, Linear form e^1 on the Rank-3 free module M over the Integer Ring, Linear form e^2 on the Rank-3 free module M over the Integer Ring] + + An example with indices starting at 1 instead of 0:: + + sage: M = FiniteRankFreeModule(ZZ, 3, name='M1', + ....: start_index=1) + sage: e = M.basis('e') + sage: list(e) + [Element e_1 of the Rank-3 free module M1 over the Integer Ring, + Element e_2 of the Rank-3 free module M1 over the Integer Ring, + Element e_3 of the Rank-3 free module M1 over the Integer Ring] """ - for i in range(self._fmodule._rank): + for i in self._fmodule.irange(): yield self[i] def __len__(self): From 64c9d2aa54f016af0286e64a03ce48931aa7b314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 5 Mar 2017 14:37:02 +0100 Subject: [PATCH 318/370] trac 22517 minimize imports --- src/sage/combinat/words/word_char.pyx | 2 +- src/sage/combinat/words/word_datatypes.pyx | 2 +- src/sage/libs/ecl.pyx | 2 +- src/sage/matroids/basis_matroid.pyx | 2 +- src/sage/matroids/circuit_closures_matroid.pyx | 2 +- src/sage/matroids/lean_matrix.pyx | 2 +- src/sage/matroids/linear_matroid.pyx | 2 +- src/sage/matroids/matroid.pyx | 2 +- src/sage/sat/solvers/cryptominisat/solverconf.pyx | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sage/combinat/words/word_char.pyx b/src/sage/combinat/words/word_char.pyx index 9670573d65d..60145da31d2 100644 --- a/src/sage/combinat/words/word_char.pyx +++ b/src/sage/combinat/words/word_char.pyx @@ -17,7 +17,7 @@ include "cysignals/memory.pxi" include "sage/data_structures/bitset.pxi" cimport cython -from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE +from cpython.object cimport Py_EQ, Py_NE from sage.rings.integer cimport Integer, smallInteger from sage.rings.rational cimport Rational from libc.string cimport memcpy, memcmp diff --git a/src/sage/combinat/words/word_datatypes.pyx b/src/sage/combinat/words/word_datatypes.pyx index c2dc3663e93..8c3766e14b2 100644 --- a/src/sage/combinat/words/word_datatypes.pyx +++ b/src/sage/combinat/words/word_datatypes.pyx @@ -13,7 +13,7 @@ Datatypes for finite words #***************************************************************************** from __future__ import print_function -from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE +from cpython.object cimport Py_EQ, Py_NE from itertools import islice diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx index 26e99c6e31a..6992d34f9a9 100644 --- a/src/sage/libs/ecl.pyx +++ b/src/sage/libs/ecl.pyx @@ -25,7 +25,7 @@ from posix.signal cimport sigaction, sigaction_t from sage.rings.integer cimport Integer from sage.rings.rational cimport Rational -from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE +from cpython.object cimport Py_EQ, Py_NE #it would be preferrable to let bint_symbolp wrap an efficient macro #but the macro provided in object.h doesn't seem to work diff --git a/src/sage/matroids/basis_matroid.pyx b/src/sage/matroids/basis_matroid.pyx index d14e88b0048..ad414638b2a 100644 --- a/src/sage/matroids/basis_matroid.pyx +++ b/src/sage/matroids/basis_matroid.pyx @@ -78,7 +78,7 @@ include 'sage/data_structures/bitset.pxi' from .matroid cimport Matroid from .basis_exchange_matroid cimport BasisExchangeMatroid from .set_system cimport SetSystem -from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE +from cpython.object cimport Py_EQ, Py_NE from sage.arith.all import binomial diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx index a919fb48505..5bce0ea31ed 100644 --- a/src/sage/matroids/circuit_closures_matroid.pyx +++ b/src/sage/matroids/circuit_closures_matroid.pyx @@ -70,7 +70,7 @@ from __future__ import absolute_import from .matroid cimport Matroid from .set_system cimport SetSystem from .utilities import setprint_s -from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE +from cpython.object cimport Py_EQ, Py_NE cdef class CircuitClosuresMatroid(Matroid): diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx index 03cf1ba7ba6..5d666b8d08a 100644 --- a/src/sage/matroids/lean_matrix.pyx +++ b/src/sage/matroids/lean_matrix.pyx @@ -33,7 +33,7 @@ AUTHORS: include "cysignals/memory.pxi" include 'sage/data_structures/bitset.pxi' from libc.string cimport memcpy, memset -from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE +from cpython.object cimport Py_EQ, Py_NE from sage.matrix.matrix2 cimport Matrix from sage.rings.all import ZZ, FiniteField, GF diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx index a10c9035fb3..98e553224e5 100644 --- a/src/sage/matroids/linear_matroid.pyx +++ b/src/sage/matroids/linear_matroid.pyx @@ -111,7 +111,7 @@ Methods from __future__ import print_function, absolute_import include 'sage/data_structures/bitset.pxi' -from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE +from cpython.object cimport Py_EQ, Py_NE from sage.matroids.matroid cimport Matroid from sage.matroids.basis_exchange_matroid cimport BasisExchangeMatroid diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index bdf68413e72..5acfd4f61c7 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -325,7 +325,7 @@ Methods #***************************************************************************** from __future__ import absolute_import -from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE +from cpython.object cimport Py_EQ, Py_NE from sage.structure.sage_object cimport SageObject from itertools import combinations, permutations, product diff --git a/src/sage/sat/solvers/cryptominisat/solverconf.pyx b/src/sage/sat/solvers/cryptominisat/solverconf.pyx index 6f977401b0c..49a2aa3d60e 100644 --- a/src/sage/sat/solvers/cryptominisat/solverconf.pyx +++ b/src/sage/sat/solvers/cryptominisat/solverconf.pyx @@ -41,7 +41,7 @@ AUTHORS: ### from libc.stdint cimport uint32_t, uint64_t -from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE +from cpython.object cimport Py_EQ, Py_NE cdef class SolverConf(object): From ccca3354cfa16421ab513f99afb46a3c75afd6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 5 Mar 2017 15:12:39 +0100 Subject: [PATCH 319/370] py3 take care of 2 zip issues --- src/sage/graphs/convexity_properties.pyx | 2 +- src/sage/matrix/matrix2.pyx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/graphs/convexity_properties.pyx b/src/sage/graphs/convexity_properties.pyx index f11df7a7b03..94a5ceb3d30 100644 --- a/src/sage/graphs/convexity_properties.pyx +++ b/src/sage/graphs/convexity_properties.pyx @@ -449,7 +449,7 @@ cdef class ConvexityProperties: p.add_variables(self._n, 0, None, True, False, False, 1, None) # We know that at least 2 vertices are required to cover the whole graph - p.add_linear_constraint(zip(range(self._n), [1]*self._n), 2, None) + p.add_linear_constraint([(i, 1) for i in xrange(self._n)], 2, None) # The set of vertices generated by the current LP solution cdef bitset_t current_hull diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 5bcd056272e..b67f60e8d1f 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -11115,11 +11115,11 @@ cdef class Matrix(matrix1.Matrix): polynomial = not var is None if polynomial: x = sage.rings.polynomial.polynomial_ring.polygen(R, var) - poly = sum([poly[i]*x**i for i in range(len(poly))]) + poly = sum([poly[i] * x**i for i in range(len(poly))]) ambient = R**n if basis == 'echelon': echelon = [] - pivot_col_row = zip(pivots, range(k)) + pivot_col_row = [(v, i) for i, v in enumerate(pivots)] pivot_col_row.sort() aug = augmented.submatrix(0, 0, k, n) for _, pivrow in pivot_col_row: From 3a37a5e38db5218a6f499f7a831990b88e7146a3 Mon Sep 17 00:00:00 2001 From: Release Manager Date: Sun, 5 Mar 2017 17:09:55 +0100 Subject: [PATCH 320/370] Trac #20908: Rework index and catalogs in sage.coding Catalogs of codes/encoders/decoders and `index.rst` file in `sage.coding` contains several problems: - some references are missing, some other are duplicated, - classes are listed without any specific order, and - catalogs randomly use `import` and `lazy_import`. This ticket fixes these problems. URL: https://trac.sagemath.org/20908 Reported by: dlucas Ticket author(s): David Lucas, Johan Rosenkilde Reviewer(s): David Lucas, Johan Rosenkilde From 7c02ed84fdce8c7c6fb2b1a9518c26a215f932c6 Mon Sep 17 00:00:00 2001 From: Eric Gourgoulhon Date: Sun, 5 Mar 2017 17:10:10 +0100 Subject: [PATCH 321/370] Fix display of tensors on free modules of finite rank (#22520) --- src/sage/tensor/modules/comp.py | 14 +++++++++++--- src/sage/tensor/modules/free_module_alt_form.py | 13 ++++++++++++- src/sage/tensor/modules/free_module_tensor.py | 14 ++++++++++++-- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/sage/tensor/modules/comp.py b/src/sage/tensor/modules/comp.py index 8101c27986b..805e2bce942 100644 --- a/src/sage/tensor/modules/comp.py +++ b/src/sage/tensor/modules/comp.py @@ -1153,6 +1153,13 @@ def display(self, symbol, latex_symbol=None, index_positions=None, C_01 = 0.33 C_21 = 0.29 + Check that the bug reported in :trac:`22520` is fixed:: + + sage: c = Components(SR, [1, 2], 1) + sage: c[0] = SR.var('t', domain='real') + sage: c.display('c') + c_0 = t + """ from sage.misc.latex import latex from sage.tensor.modules.format_utilities import FormattedExpansion @@ -1190,7 +1197,8 @@ def display(self, symbol, latex_symbol=None, index_positions=None, for ind in generator: ind_arg = ind + (format_spec,) val = self[ind_arg] - if val != 0 or not only_nonzero: + if not (val == 0) or not only_nonzero: # val != 0 would not be + # correct, see :trac:`22520` indices = '' # text indices d_indices = '' # LaTeX down indices u_indices = '' # LaTeX up indices @@ -1336,7 +1344,7 @@ def is_zero(self): # In other words, the full method should be # return self.comp == {} for val in itervalues(self._comp): - if val != 0: + if not (val == 0): return False return True @@ -3244,7 +3252,7 @@ def __setitem__(self, args, value): else: sign, ind = self._ordered_indices(indices) if sign == 0: - if value != 0: + if not (value == 0): raise ValueError("by antisymmetry, the component cannot " + "have a nonzero value for the indices " + str(indices)) diff --git a/src/sage/tensor/modules/free_module_alt_form.py b/src/sage/tensor/modules/free_module_alt_form.py index a8630788b0e..9fc42bc6290 100644 --- a/src/sage/tensor/modules/free_module_alt_form.py +++ b/src/sage/tensor/modules/free_module_alt_form.py @@ -484,6 +484,15 @@ def display(self, basis=None, format_spec=None): sage: b.display(format_spec=10) # 10 bits of precision b = 0.33 e^1/\e^2 + 2.5 e^1/\e^3 + 4.0 e^2/\e^3 + Check that the bug reported in :trac:`22520` is fixed:: + + sage: M = FiniteRankFreeModule(SR, 2, name='M') + sage: e = M.basis('e') + sage: a = M.alternating_form(2) + sage: a[0,1] = SR.var('t', domain='real') + sage: a.display() + t e^0/\e^1 + """ from sage.misc.latex import latex from sage.tensor.modules.format_utilities import is_atomic, \ @@ -497,7 +506,9 @@ def display(self, basis=None, format_spec=None): for ind in comp.non_redundant_index_generator(): ind_arg = ind + (format_spec,) coef = comp[ind_arg] - if coef != 0: + if not (coef == 0): # NB: coef != 0 would return False for + # cases in which Sage cannot conclude + # see :trac:`22520` bases_txt = [] bases_latex = [] for k in range(self._tensor_rank): diff --git a/src/sage/tensor/modules/free_module_tensor.py b/src/sage/tensor/modules/free_module_tensor.py index c760bada0f5..a2d5dca21e9 100644 --- a/src/sage/tensor/modules/free_module_tensor.py +++ b/src/sage/tensor/modules/free_module_tensor.py @@ -641,6 +641,14 @@ def display(self, basis=None, format_spec=None): sage: v.display(format_spec=10) # 10 bits of precision v = 0.33 e_1 - 2.0 e_2 + Check that the bug reported in :trac:`22520` is fixed:: + + sage: M = FiniteRankFreeModule(SR, 3, name='M') + sage: e = M.basis('e') + sage: t = SR.var('t', domain='real') + sage: (t*e[0]).display() + t e_0 + """ from sage.misc.latex import latex from sage.tensor.modules.format_utilities import is_atomic, \ @@ -655,7 +663,9 @@ def display(self, basis=None, format_spec=None): for ind in comp.index_generator(): ind_arg = ind + (format_spec,) coef = comp[ind_arg] - if coef != 0: + if not (coef == 0): # NB: coef != 0 would return False for + # cases in which Sage cannot conclude + # see :trac:`22520` bases_txt = [] bases_latex = [] for k in range(n_con): @@ -2550,7 +2560,7 @@ def contract(self, *args): for pos in range(0,k2): if pos not in pos2: nb_con_o += 1 - if nb_cov_s != 0 and nb_con_o !=0: + if nb_cov_s != 0 and nb_con_o != 0: # some reodering is necessary: p2 = k1 + l1 - ncontr p1 = p2 - nb_cov_s From be71a2ebf34906ee95969d6df01541d844a05023 Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Sun, 5 Mar 2017 18:23:22 +0100 Subject: [PATCH 322/370] added SEEALSO, links to wikipedia and improved docstrings --- src/sage/geometry/polyhedron/base.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index e2a6176877d..ea53b452f31 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4175,34 +4175,39 @@ def neighborliness(self): In case of the ``d``-dimensional simplex, it returns ``d + 1``. + See :wikipedia:`Neighborly_polytope` EXAMPLES:: sage: cube = polytopes.cube() sage: cube.neighborliness() 1 - sage: P=Polyhedron(); P + sage: P = Polyhedron(); P The empty polyhedron in ZZ^0 sage: P.neighborliness() 0 - sage: P=Polyhedron([[0]]); P + sage: P = Polyhedron([[0]]); P A 0-dimensional polyhedron in ZZ^1 defined as the convex hull of 1 vertex sage: P.neighborliness() 1 - sage: S=polytopes.simplex(5); S + sage: S = polytopes.simplex(5); S A 5-dimensional polyhedron in ZZ^6 defined as the convex hull of 6 vertices sage: S.neighborliness() 6 - sage: C=polytopes.cyclic_polytope(7,10); C + sage: C = polytopes.cyclic_polytope(7,10); C A 7-dimensional polyhedron in QQ^7 defined as the convex hull of 10 vertices sage: C.neighborliness() 3 - sage: C=polytopes.cyclic_polytope(6,11); C + sage: C = polytopes.cyclic_polytope(6,11); C A 6-dimensional polyhedron in QQ^6 defined as the convex hull of 11 vertices sage: C.neighborliness() 3 sage: [polytopes.cyclic_polytope(5,n).neighborliness() for n in range(6,10)] [6, 2, 2, 2] + + SEEALSO: + + :meth:`is_neighborly` """ if self.is_simplex(): return self.dim() + 1 @@ -4218,15 +4223,18 @@ def is_neighborly(self, k=None): If the input ``k`` is provided then return whether the polyhedron is ``k``-neighborly + See :wikipedia:`Neighborly_polytope` + + INPUT: - - ``k`` -- the dimension up to which to check if every set of k + - ``k`` -- the dimension up to which to check if every set of ``k`` vertices forms a face. If no ``k`` is provided, check up to floor of half the dimension of the polyhedron. OUTPUT: - - ``True`` if the every set of up to k vertices forms a face, + - ``True`` if the every set of up to ``k`` vertices forms a face, - ``False`` otherwise EXAMPLES: @@ -4253,6 +4261,9 @@ def is_neighborly(self, k=None): sage: [(P.neighborliness()>=floor(P.dim()/2)) == P.is_neighborly() for P in testpolys] [True, True, True] + SEEALSO: + + :meth:`neighborliness` """ if k == None: k = floor(self.dim()/2) From 13911d8b7476dfa375c5afdad040f264b8db8bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 5 Mar 2017 21:23:58 +0100 Subject: [PATCH 323/370] py3 some care for range --- src/sage/algebras/steenrod/steenrod_algebra_mult.py | 7 ++++--- src/sage/combinat/finite_class.py | 3 ++- src/sage/combinat/free_module.py | 4 ++-- src/sage/combinat/root_system/coxeter_group.py | 6 +++--- src/sage/combinat/words/finite_word.py | 2 +- src/sage/combinat/words/suffix_trees.py | 6 +++--- src/sage/geometry/lattice_polytope.py | 13 +++++++------ src/sage/graphs/generators/basic.py | 6 +++--- .../automorphism_group_canonical_label.pyx | 2 +- .../groups/perm_gps/partn_ref/refinement_graphs.pyx | 2 +- .../groups/perm_gps/partn_ref/refinement_sets.pyx | 4 ++-- src/sage/groups/perm_gps/permgroup_element.pyx | 5 ++++- src/sage/homology/simplicial_set.py | 8 +++++--- src/sage/knots/link.py | 5 +++-- src/sage/libs/coxeter3/coxeter_group.py | 1 - src/sage/libs/ppl.pyx | 4 ++-- src/sage/libs/singular/groebner_strategy.pyx | 2 +- src/sage/manifolds/differentiable/metric.py | 4 +++- src/sage/matroids/lean_matrix.pyx | 6 +++--- src/sage/misc/misc_c.pyx | 2 +- src/sage/numerical/backends/glpk_graph_backend.pyx | 7 +++---- .../quadratic_form__local_field_invariants.py | 4 ++-- src/sage/sandpiles/sandpile.py | 4 ++-- src/sage/tensor/modules/comp.py | 12 +++++++----- src/sage/tests/arxiv_0812_2725.py | 5 +++-- 25 files changed, 68 insertions(+), 56 deletions(-) diff --git a/src/sage/algebras/steenrod/steenrod_algebra_mult.py b/src/sage/algebras/steenrod/steenrod_algebra_mult.py index 81506ffdd47..3c2f6e3512f 100644 --- a/src/sage/algebras/steenrod/steenrod_algebra_mult.py +++ b/src/sage/algebras/steenrod/steenrod_algebra_mult.py @@ -198,6 +198,7 @@ # Copyright (C) 2008-2010 John H. Palmieri # Distributed under the terms of the GNU General Public License (GPL) #***************************************************************************** +from six.moves import range from sage.misc.cachefunc import cached_function @@ -251,7 +252,7 @@ def milnor_multiplication(r,s): cols = len(s) + 1 diags = len(r) + len(s) # initialize matrix - M = range(rows) + M = list(range(rows)) for i in range(rows): M[i] = [0]*cols for j in range(1,cols): @@ -491,7 +492,7 @@ def milnor_multiplication_odd(m1,m2,p): # Now for the Milnor matrices. For each entry '(e,r): coeff' in answer, # multiply r with s. Record coefficient for matrix and multiply by coeff. # Store in 'result'. - if len(s) == 0: + if not s: result = answer else: result = {} @@ -502,7 +503,7 @@ def milnor_multiplication_odd(m1,m2,p): cols = len(s) + 1 diags = len(r) + len(s) # initialize matrix - M = range(rows) + M = list(range(rows)) for i in range(rows): M[i] = [0]*cols for j in range(1,cols): diff --git a/src/sage/combinat/finite_class.py b/src/sage/combinat/finite_class.py index 7b0ed946a04..635d9461e7d 100644 --- a/src/sage/combinat/finite_class.py +++ b/src/sage/combinat/finite_class.py @@ -16,6 +16,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** from __future__ import absolute_import +from six.moves import range from .combinat import CombinatorialClass @@ -127,7 +128,7 @@ def keys(self): sage: F.keys() [0, 1, 2] """ - return range(len(self.l)) + return list(range(len(self.l))) # Backward compatibility pointer # Needed for unpickling. diff --git a/src/sage/combinat/free_module.py b/src/sage/combinat/free_module.py index 08a476fbb75..6be232ed617 100644 --- a/src/sage/combinat/free_module.py +++ b/src/sage/combinat/free_module.py @@ -11,6 +11,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** from __future__ import print_function +from six.moves import range from sage.structure.unique_representation import UniqueRepresentation from sage.structure.element import Element, have_same_parent @@ -1068,7 +1069,6 @@ def __classcall_private__(cls, base_ring, basis_keys, category = None, prefix="B sage: F is G False """ - from six.moves import range if isinstance(basis_keys, range): basis_keys = tuple(basis_keys) if isinstance(basis_keys, (list, tuple)): @@ -2406,7 +2406,7 @@ def _sets_keys(self): sage: CP._sets_keys() [0, 1] """ - return range(len(self._sets)) + return list(range(len(self._sets))) def _repr_(self): """ diff --git a/src/sage/combinat/root_system/coxeter_group.py b/src/sage/combinat/root_system/coxeter_group.py index 0f88becf3e1..ab659832ff0 100644 --- a/src/sage/combinat/root_system/coxeter_group.py +++ b/src/sage/combinat/root_system/coxeter_group.py @@ -8,6 +8,7 @@ # # http://www.gnu.org/licenses/ #***************************************************************************** +from six.moves import range from sage.misc.cachefunc import cached_function, cached_method from sage.groups.perm_gps.permgroup_element import PermutationGroupElement @@ -242,16 +243,15 @@ def _element_class(self): def index_set(self): """ - Returns the index set of this Coxeter group + Return the index set of this Coxeter group. EXAMPLES:: sage: W = CoxeterGroup(["H",3], implementation = "permutation") # optional - gap3 sage: W.index_set() # optional - gap3 [1, 2, 3] - """ - return range(1, self._semi_simple_rank+1) + return list(range(1, self._semi_simple_rank + 1)) @cached_method def reflection(self, i): diff --git a/src/sage/combinat/words/finite_word.py b/src/sage/combinat/words/finite_word.py index 18c17470fc5..9b106c1889e 100644 --- a/src/sage/combinat/words/finite_word.py +++ b/src/sage/combinat/words/finite_word.py @@ -534,7 +534,7 @@ def length(self): sage: w.length() 4 sage: def f(n): - ....: return range(2,12,2)[n] + ....: return list(range(2,12,2))[n] sage: w = Word(f, length=5) sage: w.length() 5 diff --git a/src/sage/combinat/words/suffix_trees.py b/src/sage/combinat/words/suffix_trees.py index 98be1082787..5802b9b7909 100644 --- a/src/sage/combinat/words/suffix_trees.py +++ b/src/sage/combinat/words/suffix_trees.py @@ -10,7 +10,7 @@ # (at your option) any later version. # http://www.gnu.org/licenses/ #***************************************************************************** - +from six.moves import range from six import iteritems from sage.structure.sage_object import SageObject @@ -310,7 +310,7 @@ def states(self): sage: s.states() [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] """ - return range(len(self._transition_function)) + return list(range(len(self._transition_function))) def suffix_link(self, state): r""" @@ -995,7 +995,7 @@ def states(self): sage: t.states() [0, 1, 2, 3, 4, 5, 6, 7] """ - return range(len(self._transition_function)) + return list(range(len(self._transition_function))) def suffix_link(self, state): r""" diff --git a/src/sage/geometry/lattice_polytope.py b/src/sage/geometry/lattice_polytope.py index 53c73c42c8a..c65b44dfc89 100644 --- a/src/sage/geometry/lattice_polytope.py +++ b/src/sage/geometry/lattice_polytope.py @@ -102,6 +102,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** from __future__ import print_function, absolute_import +from six.moves import range from sage.combinat.posets.posets import FinitePoset from sage.geometry.hasse_diagram import Hasse_diagram_from_incidences @@ -3109,7 +3110,7 @@ def index_of_max(iterable): # The array is such that: # S = [i, 1, ..., 1 (ith), j, i+1, ..., i+1 (jth), k ... ] # describes the "symmetry blocks" - S = range(1, n_v + 1) + S = list(range(1, n_v + 1)) for i in range(1, n_v): if b[i-1] == b[i]: S[i] = S[i-1] @@ -3220,7 +3221,7 @@ def index_of_max(iterable): permutations = {k:permutations[k] for k in permutations if k < n_s} # If the automorphisms are not already completely restricted, # update them - if not S == list(range(1, n_v + 1)): + if S != list(range(1, n_v + 1)): # Take the old automorphisms and update by # the restrictions the last worked out # row imposes. @@ -3484,10 +3485,10 @@ def plot3d(self, bc = 1/Integer(len(vertices)) * vector(QQ, sum(vertices)) if show_vindices: if vlabels is None: - vlabels = range(len(vertices)) - for i,v in enumerate(vertices): + vlabels = list(range(len(vertices))) + for i, v in enumerate(vertices): pplot += text3d(vlabels[i], bc+index_shift*(v-bc), rgbcolor=vindex_color) - if show_points and len(points) > 0: + if show_points and len(points): pplot += point3d(points, size=point_size, rgbcolor=point_color) if show_pindices: for i, p in enumerate(points): @@ -3816,7 +3817,7 @@ def skeleton_points(self, k=1): [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26] """ if k >= self.dim(): - return range(self.npoints()) + return list(range(self.npoints())) skeleton = set([]) for face in self.faces(dim=k): skeleton.update(face.ambient_point_indices()) diff --git a/src/sage/graphs/generators/basic.py b/src/sage/graphs/generators/basic.py index 0e7cb1f7bbd..f55b03337fd 100644 --- a/src/sage/graphs/generators/basic.py +++ b/src/sage/graphs/generators/basic.py @@ -517,11 +517,11 @@ def CompleteBipartiteGraph(n1, n2): for i in range(n1): x = c1*i + c3 y = 1 - pos_dict[i] = (x,y) - for i in range(n1+n2)[n1:]: + pos_dict[i] = (x, y) + for i in range(n1,n1+n2): x = c2*(i-n1) + c4 y = 0 - pos_dict[i] = (x,y) + pos_dict[i] = (x, y) G = Graph(n1+n2, pos=pos_dict, name="Complete bipartite graph") G.add_edges((i,j) for i in range(n1) for j in range(n1,n1+n2)) diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx index 24742daa278..ebe2a3bdd00 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx @@ -275,7 +275,7 @@ def coset_rep(list perm=[0,1,2,3,4,5], list gens=[[1,2,3,4,5,0]]): output = get_aut_gp_and_can_lab( perm, part, n, &all_children_are_equivalent_trivial, &refine_and_return_invariant_trivial, &compare_perms, 1, group, NULL, NULL) SC_order(output.group, 0, I.value) assert I == 1 - r_inv = range(n) + r_inv = list(xrange(n)) for i from 0 <= i < n: r_inv[output.relabeling[i]] = i label = [perm[r_inv[i]] for i in range(n)] diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx index 373d9a3f90d..9689ff25cfb 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx @@ -98,7 +98,7 @@ def isomorphic(G1, G2, partn, ordering2, dig, use_indicator_function, sparse=Fal else: if first: partition = partn - to = range(n) + to = list(xrange(n)) frm = to if sparse: G = SparseGraph(n) diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx index 14f02f82204..2ac9fe25696 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx @@ -383,7 +383,7 @@ def sets_isom_py(generators, set1, set2): set2 = uniq(set2) if len(generators) == 0: if set1 == set2: - return range(max(set1)+1) + return list(xrange(max(set1) + 1)) else: return False cdef int i, j, n = len(generators[0]), n_gens = len(generators) @@ -806,7 +806,7 @@ def sets_modulo_perm_group(list generators, int max_size, bint indicate_mem_err if len(generators) == 0: ll = [] for i in range(max_size,-1,-1): - ll.append(range(i)) + ll.append(list(xrange(i))) return ll cdef int n = len(generators[0]), n_gens = len(generators) cdef iterator *subset_iterator diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index 6bfc09a8c63..49bc69e99b4 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -53,7 +53,7 @@ degree. # http://www.gnu.org/licenses/ ########################################################################### from __future__ import print_function - + import random import sage.groups.old as group @@ -228,6 +228,9 @@ def standardize_generator(g, convert_dict=None): if isinstance(g, pari_gen): g = list(g) + if isinstance(g, xrange): + g = list(g) + needs_conversion = True if isinstance(g, GapElement): g = str(g) diff --git a/src/sage/homology/simplicial_set.py b/src/sage/homology/simplicial_set.py index 1f3de357221..9efb3072704 100644 --- a/src/sage/homology/simplicial_set.py +++ b/src/sage/homology/simplicial_set.py @@ -251,6 +251,7 @@ # http://www.gnu.org/licenses/ # #***************************************************************************** +from six.moves import range import copy @@ -2019,7 +2020,8 @@ def homology(self, dim=None, **kwds): raise NotImplementedError('this simplicial set may be infinite, so ' 'specify dimensions when computing homology') else: - if isinstance(dim, (list, tuple)): + if isinstance(dim, (list, tuple, range)): + dim = list(dim) max_dim = max(dim) space = self.n_skeleton(max_dim+1) min_dim = min(dim) @@ -3645,10 +3647,10 @@ def chain_complex(self, dimensions=None, base_ring=ZZ, augmented=False, degree_of_differential=1) return ChainComplex({0: matrix(base_ring, 0, 0)}, degree_of_differential=-1) - dimensions = range(self.dimension()+1) + dimensions = list(range(self.dimension() + 1)) else: if not isinstance(dimensions, (list, tuple)): - dimensions = range(dimensions-1, dimensions+2) + dimensions = list(range(dimensions - 1, dimensions + 2)) else: dimensions = [n for n in dimensions if n >= 0] if not dimensions: diff --git a/src/sage/knots/link.py b/src/sage/knots/link.py index 6dd20bdd3b9..d9e8f2103d0 100644 --- a/src/sage/knots/link.py +++ b/src/sage/knots/link.py @@ -47,6 +47,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** from __future__ import division +from six.moves import range from sage.matrix.constructor import matrix from sage.rings.integer_ring import ZZ @@ -1319,7 +1320,7 @@ def pd_code(self): return self._pd_code if self._braid is not None: - strings = range(1, self._braid.strands() + 1) + strings = list(range(1, self._braid.strands() + 1)) b = list(self._braid.Tietze()) pd = [] strings_max = strings[-1] @@ -2767,7 +2768,7 @@ def plot(self, gap=0.1, component_gap=0.5, solver=None, **kwargs): MLP.set_objective(MLP.sum(v.values())) MLP.solve() # we store the result in a vector s packing right bends as negative left ones - s = range(len(edges)) + s = list(range(len(edges))) values = MLP.get_values(v) for i in range(len(edges)): s[i] = int(values[2*i] - values[2*i + 1]) diff --git a/src/sage/libs/coxeter3/coxeter_group.py b/src/sage/libs/coxeter3/coxeter_group.py index 312a54e7342..9441258d8b3 100644 --- a/src/sage/libs/coxeter3/coxeter_group.py +++ b/src/sage/libs/coxeter3/coxeter_group.py @@ -105,7 +105,6 @@ def index_set(self): (0, 1, 2, 3) """ return self.cartan_type().index_set() - #return range(1, self.rank()+1) def bruhat_interval(self, u, v): """ diff --git a/src/sage/libs/ppl.pyx b/src/sage/libs/ppl.pyx index 90b31cabc2d..ca2d2f496af 100644 --- a/src/sage/libs/ppl.pyx +++ b/src/sage/libs/ppl.pyx @@ -102,7 +102,7 @@ Finally, PPL is fast. For example, here is the permutahedron of 5 basis vectors:: sage: from sage.libs.ppl import Variable, Generator_System, point, C_Polyhedron - sage: basis = range(0,5) + sage: basis = list(range(5)) sage: x = [ Variable(i) for i in basis ] sage: gs = Generator_System(); sage: for coeff in Permutations(basis): @@ -115,7 +115,7 @@ measures it to be 90 microseconds on sage.math). Below we do the same computation with cddlib, which needs more than 3 seconds on the same hardware:: - sage: basis = range(0,5) + sage: basis = list(range(5)) sage: gs = [ tuple(coeff) for coeff in Permutations(basis) ] sage: Polyhedron(vertices=gs, backend='cdd') # long time (3s on sage.math, 2011) A 4-dimensional polyhedron in QQ^5 defined as the convex hull of 120 vertices diff --git a/src/sage/libs/singular/groebner_strategy.pyx b/src/sage/libs/singular/groebner_strategy.pyx index 92485a040a9..bbb0d1599c1 100644 --- a/src/sage/libs/singular/groebner_strategy.pyx +++ b/src/sage/libs/singular/groebner_strategy.pyx @@ -370,7 +370,7 @@ cdef class NCGroebnerStrategy(SageObject): cdef int j if R.base_ring().is_field(): - for j in range(self._strat.sl+1)[::-1]: + for j in range(self._strat.sl,-1,-1): pNorm(self._strat.S[j]) id_Delete(&i, R._ring) diff --git a/src/sage/manifolds/differentiable/metric.py b/src/sage/manifolds/differentiable/metric.py index c687d4e6ec6..66677c07443 100644 --- a/src/sage/manifolds/differentiable/metric.py +++ b/src/sage/manifolds/differentiable/metric.py @@ -28,11 +28,13 @@ # the License, or (at your option) any later version. # http://www.gnu.org/licenses/ #****************************************************************************** +from six.moves import range from sage.rings.integer import Integer from sage.manifolds.differentiable.tensorfield import TensorField from sage.manifolds.differentiable.tensorfield_paral import TensorFieldParal + class PseudoRiemannianMetric(TensorField): r""" Pseudo-Riemannian metric with values on an open subset of a @@ -1836,7 +1838,7 @@ def hodge_star(self, pform): dom_resu = self._domain.intersection(pform.domain()) resu = pform.restrict(dom_resu) * eps.restrict(dom_resu) else: - args = range(p) + [eps] + range(p) + args = list(range(p)) + [eps] + list(range(p)) resu = pform.contract(*args) if p > 1: resu = resu / factorial(p) diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx index fb0f20fb3a8..c456da295b9 100644 --- a/src/sage/matroids/lean_matrix.pyx +++ b/src/sage/matroids/lean_matrix.pyx @@ -1351,7 +1351,7 @@ cdef class BinaryMatrix(LeanMatrix): if bitset_in(row, cols[g]): bitset_add(row2, gaps[g]) # record order of the columns in list `order` - cdef list order = range(lc) + cdef list order = list(xrange(lc)) g = 0 for g in xrange(lg): order[gaps[g]] = cols[g] @@ -2033,7 +2033,7 @@ cdef class TernaryMatrix(LeanMatrix): if bitset_in(row1, p): bitset_add(row1_2, q) # record order of the columns in list `order` - cdef list order = range(lc) + cdef list order = list(xrange(lc)) g = 0 for g in xrange(lg): order[gaps[g]] = cols[g] @@ -2616,7 +2616,7 @@ cdef class QuaternaryMatrix(LeanMatrix): if bitset_in(row1, p): bitset_add(row1_2, q) # record order of the columns in list `order` - cdef list order = range(lc) + cdef list order = list(xrange(lc)) g = 0 for g in xrange(lg): order[gaps[g]] = cols[g] diff --git a/src/sage/misc/misc_c.pyx b/src/sage/misc/misc_c.pyx index e8e39fc7c09..9535c5d14e2 100644 --- a/src/sage/misc/misc_c.pyx +++ b/src/sage/misc/misc_c.pyx @@ -579,7 +579,7 @@ cpdef list normalize_index(object key, int size): raise IndexError("index out of range") return [index] elif isinstance(key, slice): - return range(*key.indices(size)) + return list(xrange(*key.indices(size))) elif type(key) is tuple: index_tuple = key elif type(key) is list: diff --git a/src/sage/numerical/backends/glpk_graph_backend.pyx b/src/sage/numerical/backends/glpk_graph_backend.pyx index ce46356c4fe..086bafca277 100644 --- a/src/sage/numerical/backends/glpk_graph_backend.pyx +++ b/src/sage/numerical/backends/glpk_graph_backend.pyx @@ -1149,10 +1149,9 @@ cdef class GLPKGraphBackend(object): ....: v_dict[v] = vertices[i] sage: gbe.set_vertices_demand(v_dict.items()) sage: cost = ((8, 6, 10, 9), (9, 12, 13, 7), (14, 9, 16, 5)) - sage: lcost = range(len(cost)) - sage: lcost_0 = range(len(cost[0])) - sage: for i in lcost: - ....: for j in lcost_0: + + sage: for i in range(len(cost)): + ....: for j in range(len(cost[0])): ....: gbe.add_edge(str(i), str(j + len(cost)), {"cost":cost[i][j], "cap":100}) sage: gbe.mincost_okalg() 1020.0 diff --git a/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py b/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py index 30d78bcfc60..ff5a186cef2 100644 --- a/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py +++ b/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py @@ -15,7 +15,7 @@ # (at your option) any later version. # http://www.gnu.org/licenses/ #***************************************************************************** - +from six.moves import range ########################################################################### ## TO DO: Add routines for hasse invariants at all places, anisotropic @@ -955,7 +955,7 @@ def compute_definiteness_string_by_determinants(self): ## Check the sign of the ratios of consecutive determinants of the upper triangular r x r submatrices first_coeff = self[0,0] for r in range(1,n+1): - I = range(r) + I = list(range(r)) new_det = M.matrix_from_rows_and_columns(I, I).det() ## Check for a (non-degenerate) zero -- so it's indefinite diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py index f8df686d1cf..be6b9e9b1f7 100644 --- a/src/sage/sandpiles/sandpile.py +++ b/src/sage/sandpiles/sandpile.py @@ -318,7 +318,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** from __future__ import print_function -from six.moves import zip +from six.moves import zip, range from collections import Counter from copy import deepcopy @@ -616,7 +616,7 @@ def __init__(self, g, sink=None): del self._nonsink_vertices[self._sink_ind] # compute Laplacians: self._laplacian = self.laplacian_matrix(indegree=False) - temp = range(self.num_verts()) + temp = list(range(self.num_verts())) del temp[self._sink_ind] self._reduced_laplacian = self._laplacian[temp,temp] diff --git a/src/sage/tensor/modules/comp.py b/src/sage/tensor/modules/comp.py index 8101c27986b..8b2c1f7a11f 100644 --- a/src/sage/tensor/modules/comp.py +++ b/src/sage/tensor/modules/comp.py @@ -248,6 +248,7 @@ class :class:`~sage.tensor.differential_form_element.DifferentialForm`) # http://www.gnu.org/licenses/ #****************************************************************************** from __future__ import print_function +from six.moves import range from six import itervalues from sage.structure.sage_object import SageObject @@ -256,6 +257,7 @@ class :class:`~sage.tensor.differential_form_element.DifferentialForm`) from sage.parallel.parallelism import Parallelism from operator import itemgetter + class Components(SageObject): r""" Indexed set of ring elements forming some components with respect @@ -2522,7 +2524,7 @@ def symmetrize(self, *pos): """ from sage.groups.perm_gps.permgroup_named import SymmetricGroup if not pos: - pos = range(self._nid) + pos = list(range(self._nid)) else: if len(pos) < 2: raise ValueError("at least two index positions must be given") @@ -2673,7 +2675,7 @@ def antisymmetrize(self, *pos): """ from sage.groups.perm_gps.permgroup_named import SymmetricGroup if not pos: - pos = range(self._nid) + pos = list(range(self._nid)) else: if len(pos) < 2: raise ValueError("at least two index positions must be given") @@ -3318,7 +3320,7 @@ def swap_adjacent_indices(self, pos1, pos2, pos3): """ result = self._new_instance() # The symmetries: - lpos = range(self._nid) + lpos = list(range(self._nid)) new_lpos = lpos[:pos1] + lpos[pos2:pos3] + lpos[pos1:pos2] + lpos[pos3:] result._sym = [] for s in self._sym: @@ -4133,7 +4135,7 @@ def symmetrize(self, *pos): """ from sage.groups.perm_gps.permgroup_named import SymmetricGroup if not pos: - pos = range(self._nid) + pos = list(range(self._nid)) else: if len(pos) < 2: raise ValueError("at least two index positions must be given") @@ -4395,7 +4397,7 @@ def antisymmetrize(self, *pos): """ from sage.groups.perm_gps.permgroup_named import SymmetricGroup if not pos: - pos = range(self._nid) + pos = list(range(self._nid)) else: if len(pos) < 2: raise ValueError("at least two index positions must be given") diff --git a/src/sage/tests/arxiv_0812_2725.py b/src/sage/tests/arxiv_0812_2725.py index 415d2c000a7..7fc940db829 100644 --- a/src/sage/tests/arxiv_0812_2725.py +++ b/src/sage/tests/arxiv_0812_2725.py @@ -36,6 +36,7 @@ # # See http://www.gnu.org/licenses/. #***************************************************************************** +from six.moves import range from sage.combinat.set_partition import SetPartitions as SetPartitions @@ -74,7 +75,7 @@ def CompleteMatchings(n): integer depends on what [1..n] returns, and also on what range(1, len([1..n])) is. """ - for m in matchingsset(range(1, n + 1)): + for m in matchingsset(list(range(1, n + 1))): yield m @@ -108,7 +109,7 @@ def matchingsset(L): sage: [m for m in matchingsset(())] [[]] """ - if len(L) == 0: + if not L: yield [] else: for k in range(1, len(L)): From c28fcf05115ba98f832e74a94eb518bb53117d2a Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Mon, 6 Mar 2017 02:10:11 +0100 Subject: [PATCH 324/370] 18220: raise an error for non exact fields --- src/sage/geometry/polyhedron/constructor.py | 9 +++++--- src/sage/geometry/polyhedron/parent.py | 23 +++++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/sage/geometry/polyhedron/constructor.py b/src/sage/geometry/polyhedron/constructor.py index 26e00bca7c2..20554293ea1 100644 --- a/src/sage/geometry/polyhedron/constructor.py +++ b/src/sage/geometry/polyhedron/constructor.py @@ -173,11 +173,14 @@ Without specifying the ``base_ring``, the ``sqrt(3)`` would be a symbolic ring element and, therefore, the polyhedron defined over the -symbolic ring. This is possible as well, but rather slow:: +symbolic ring. This is currently not supported as SR is not exact:: sage: Polyhedron([(0,0), (1,0), (1/2, sqrt(3)/2)]) - A 2-dimensional polyhedron in (Symbolic Ring)^2 defined as the convex - hull of 3 vertices + Traceback (most recent call last): + ... + ValueError: no appropriate backend for computations with Symbolic Ring + sage: SR.is_exact() + False Even faster than all algebraic real numbers (the field ``AA``) is to take the smallest extension field. For the equilateral diff --git a/src/sage/geometry/polyhedron/parent.py b/src/sage/geometry/polyhedron/parent.py index 09055eb8f1b..2c5b1c17688 100644 --- a/src/sage/geometry/polyhedron/parent.py +++ b/src/sage/geometry/polyhedron/parent.py @@ -33,7 +33,8 @@ def Polyhedra(base_ring, ambient_dim, backend=None): - ``ambient_dim`` -- integer. The ambient space dimension. - - ``backend`` -- string. The name of the backend for computations. Currently there are three backends implemented: + - ``backend`` -- string. The name of the backend for computations. There are + several backends implemented: * ``backend="ppl"`` uses the Parma Polyhedra Library @@ -41,6 +42,8 @@ def Polyhedra(base_ring, ambient_dim, backend=None): * ``backend="normaliz"`` uses normaliz + * ``backend="field"`` a generic Sage implementation + OUTPUT: A parent class for polyhedra over the given base ring if the @@ -66,6 +69,17 @@ def Polyhedra(base_ring, ambient_dim, backend=None): sage: Polyhedra(ZZ, 3, backend='cdd') Polyhedra in QQ^3 + + TESTS:: + + sage: Polyhedra(RR, 3, backend='field') + Traceback (most recent call last): + ... + ValueError: the 'field' backend for polyhedron can not be used with non-exact fields + sage: Polyhedra(RR, 3) + Traceback (most recent call last): + ... + ValueError: no appropriate backend for computations with Real Field with 53 bits of precision """ if backend is None: if base_ring is ZZ: @@ -74,8 +88,11 @@ def Polyhedra(base_ring, ambient_dim, backend=None): backend = 'ppl' elif base_ring is RDF: backend = 'cdd' - else: + elif base_ring.is_exact(): backend = 'field' + else: + raise ValueError("no appropriate backend for computations with {}".format(base_ring)) + if backend == 'ppl' and base_ring is QQ: return Polyhedra_QQ_ppl(base_ring, ambient_dim) elif backend == 'ppl' and base_ring is ZZ: @@ -89,6 +106,8 @@ def Polyhedra(base_ring, ambient_dim, backend=None): elif backend == 'cdd' and base_ring is RDF: return Polyhedra_RDF_cdd(RDF, ambient_dim) elif backend == 'field': + if not base_ring.is_exact(): + raise ValueError("the 'field' backend for polyhedron can not be used with non-exact fields") return Polyhedra_field(base_ring.fraction_field(), ambient_dim) else: raise ValueError('No such backend (='+str(backend)+ From 508bc6be8582cd08da99074fcf7119ef90c793ae Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Mon, 6 Mar 2017 02:11:05 +0100 Subject: [PATCH 325/370] initial version --- src/sage/geometry/polyhedron/base.py | 124 ++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 5f7421b8ba4..d1426f09b16 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -31,6 +31,7 @@ from sage.functions.other import sqrt, floor, ceil from sage.groups.matrix_gps.finitely_generated import MatrixGroup from sage.graphs.graph import Graph +from sage.graphs.digraph import DiGraph from .constructor import Polyhedron @@ -4718,7 +4719,7 @@ def restricted_automorphism_group(self, output="abstract"): - For ``output="matrixlist"``: a list of matrices. - REFERENCES: + REFERENCES: - [BSS2009]_ @@ -4979,6 +4980,127 @@ def is_full_dimensional(self): """ return self.dim() == self.ambient_dim() + def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): + """ + Return whether the polyhedron is combinatorially isomorphic to another polyhedron. + + We only consider bounded polyhedra. By definition, they are + combinatorially isomorphic if their faces lattices are isomorphic. + + INPUT: + + - Two polyhedra + - `algo` can be either 'bipartite_graph' (the default) or 'face_lattice' + + OUTPUT: + + - ``True`` if the two polyhedra are combinatorially isomorphic + - ``False`` otherwise + + EXAMPLES: + + Checking that a regular simplex intersected its negative, is combinatorially + isomorpic to intersection a cube with a hyperplane perpendicular to its long + diagonal:: + + sage: def simplex_intersection(k): + ....: S1=Polyhedron([vector(v)-vector(polytopes.simplex(k).center()) for v in polytopes.simplex(k).vertices_list()]) + ....: S2 = Polyhedron([-vector(v) for v in S1.vertices_list()]) + ....: return S1.intersection(S2) + sage: def cube_intersection(k): + ....: C=polytopes.hypercube(k+1) + ....: H=Polyhedron(eqns=[[0]+[1 for i in range(k+1)]]) + ....: return C.intersection(H) + sage: [simplex_intersection(k).is_combinatorially_isomorphic(cube_intersection(k)) for k in range(2,5)] + [True, True, True] + sage: simplex_intersection(2).is_combinatorially_isomorphic(polytopes.regular_polygon(6)) + True + sage: simplex_intersection(3).is_combinatorially_isomorphic(polytopes.octahedron()) + True + + Two polytopes with the same f-vector, but different combinatorial type:: + + sage: P = Polyhedron([[-605520/1525633, -605520/1525633, -1261500/1525633, -52200/1525633, 11833/1525633],\ + [-720/1769, -600/1769, 1500/1769, 0, -31/1769], [-216/749, 240/749, -240/749, -432/749, 461/749], \ + [-50/181, 50/181, 60/181, -100/181, -119/181], [-32/51, -16/51, -4/51, 12/17, 1/17],\ + [1, 0, 0, 0, 0], [16/129, 128/129, 0, 0, 1/129], [64/267, -128/267, 24/89, -128/267, 57/89],\ + [1200/3953, -1200/3953, -1440/3953, -360/3953, -3247/3953], [1512/5597, 1512/5597, 588/5597, 4704/5597, 2069/5597]]) + sage: C = polytopes.cyclic_polytope(5,10) + sage: C.f_vector() == P.f_vector(); C.f_vector() + True + (1, 10, 45, 100, 105, 42, 1) + sage: C.is_combinatorially_isomorphic(P) + False + + sage: S=polytopes.simplex(3) + sage: S=S.face_truncation(S.faces(0)[0]) + sage: S=S.face_truncation(S.faces(0)[0]) + sage: S=S.face_truncation(S.faces(0)[0]) + sage: T=polytopes.simplex(3) + sage: T=T.face_truncation(T.faces(0)[0]) + sage: T=T.face_truncation(T.faces(0)[0]) + sage: T=T.face_truncation(T.faces(0)[1]) + sage: T.is_combinatorially_isomorphic(S) + False + sage: T.f_vector(), S.f_vector() + ((1, 10, 15, 7, 1), (1, 10, 15, 7, 1)) + + + sage: C = polytopes.hypercube(5) + sage: C.is_combinatorially_isomorphic(C) + True + sage: C.is_combinatorially_isomorphic(C, algo='magic') + Traceback (most recent call last): + ... + AssertionError: algo must be 'bipartite graph' or 'face_lattice' + + sage: G = Graph() + sage: C.is_combinatorially_isomorphic(G) + Traceback (most recent call last): + ... + AssertionError: input must be a polyhedron + + sage: H = Polyhedron(eqns=[[0,1,1,1,1]]); H + A 3-dimensional polyhedron in QQ^4 defined as the convex hull of 1 vertex and 3 lines + sage: C.is_combinatorially_isomorphic(H) + Traceback (most recent call last): + ... + AssertionError: polyhedra must be bounded + + + """ + assert isinstance(other, Polyhedron_base), "input must be a polyhedron" + assert self.is_compact() and other.is_compact(), "polyhedra must be bounded" + assert algo in ['bipartite_graph', 'face_lattice'], "algo must be 'bipartite graph' or 'face_lattice'" + + if self.n_vertices() != other.n_vertices() or self.n_facets() != other.n_facets(): + return False + + if algo == 'bipartite_graph': + + def get_incidences(P): + #This function constructs a directed bipartite graph. + #The nodes of the graph are the vertices of the polyhedron + #and the faces of the polyhedron. There is an directed edge + #from a vertex to a face if the vertex is contained in the face. + #We obtain this incidence information from the incidence matrix + G = DiGraph() + M = P.incidence_matrix() + #We construct the edges and remove the columns that have all 1s; + #those correspond to faces, that contain all vertices (which happens + #if the polyhedron is not full-dimensional) + edges = [[i, M.ncols()+j] for i, column in enumerate(M.columns()) if any(entry!=1 for entry in column) for j in range(M.nrows()) if M[j,i]==1] + G.add_edges(edges) + return G + + G_self = get_incidences(self) + G_other = get_incidences(other) + + return G_self.is_isomorphic(G_other) + else: + return self.face_lattice().is_isomorphic(other.face_lattice()) + + def affine_hull(self): """ Return the affine hull. From c9943235016cf104e1948a2b51878d8d9345edd4 Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Mon, 6 Mar 2017 11:08:02 +0100 Subject: [PATCH 326/370] improved docstring --- src/sage/geometry/polyhedron/base.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index ea53b452f31..4573de4996e 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4177,6 +4177,10 @@ def neighborliness(self): See :wikipedia:`Neighborly_polytope` + .. SEEALSO:: + + :meth:`is_neighborly` + EXAMPLES:: sage: cube = polytopes.cube() @@ -4205,9 +4209,6 @@ def neighborliness(self): sage: [polytopes.cyclic_polytope(5,n).neighborliness() for n in range(6,10)] [6, 2, 2, 2] - SEEALSO: - - :meth:`is_neighborly` """ if self.is_simplex(): return self.dim() + 1 @@ -4237,37 +4238,37 @@ def is_neighborly(self, k=None): - ``True`` if the every set of up to ``k`` vertices forms a face, - ``False`` otherwise + .. SEEALSO:: + + :meth:`neighborliness` + EXAMPLES: Cyclic polytopes are neighborly: :: - sage: all([polytopes.cyclic_polytope(i, i + 1 + j).is_neighborly() for i in range(5) for j in range(3)]) - True - sage: cube = polytopes.hypercube(3) sage: cube.is_neighborly() True sage: cube = polytopes.hypercube(4) sage: cube.is_neighborly() False + sage: all([polytopes.cyclic_polytope(i, i + 1 + j).is_neighborly() for i in range(5) for j in range(3)]) + True The neighborliness of a polyhedron equals floor of dimension half - (or is large in case of a simplex) if and only if the polyhedron + (or larger in case of a simplex) if and only if the polyhedron is neighborly:: sage: testpolys = [polytopes.cube(), polytopes.cyclic_polytope(6, 9), polytopes.simplex(6)] sage: [(P.neighborliness()>=floor(P.dim()/2)) == P.is_neighborly() for P in testpolys] [True, True, True] - SEEALSO: - - :meth:`neighborliness` """ if k == None: k = floor(self.dim()/2) - return all(len(self.faces(l)) == binomial(self.n_vertices(), l + 1) for l in range(1, k)) + return all(len(self.faces(i)) == binomial(self.n_vertices(), i + 1) for i in range(1, k)) @cached_method From ca97480c2cbb8eb4455336bdbce86455f90445bc Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Mon, 6 Mar 2017 12:35:56 +0100 Subject: [PATCH 327/370] pep8 errors fixed --- src/sage/geometry/polyhedron/base.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index d1426f09b16..fc4fafa128a 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -5079,17 +5079,19 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): if algo == 'bipartite_graph': def get_incidences(P): - #This function constructs a directed bipartite graph. - #The nodes of the graph are the vertices of the polyhedron - #and the faces of the polyhedron. There is an directed edge - #from a vertex to a face if the vertex is contained in the face. - #We obtain this incidence information from the incidence matrix + # This function constructs a directed bipartite graph. + # The nodes of the graph are the vertices of the polyhedron + # and the facets of the polyhedron. There is an directed edge + # from a vertex to a face if the vertex is contained in the face. + # We obtain this incidence information from the incidence matrix G = DiGraph() M = P.incidence_matrix() - #We construct the edges and remove the columns that have all 1s; - #those correspond to faces, that contain all vertices (which happens - #if the polyhedron is not full-dimensional) - edges = [[i, M.ncols()+j] for i, column in enumerate(M.columns()) if any(entry!=1 for entry in column) for j in range(M.nrows()) if M[j,i]==1] + # We construct the edges and remove the columns that have all 1s; + # those correspond to faces, that contain all vertices (which happens + # if the polyhedron is not full-dimensional) + edges = [[i, M.ncols()+j] for i, column in enumerate(M.columns()) + if any(entry != 1 for entry in column) + for j in range(M.nrows()) if M[j, i] == 1] G.add_edges(edges) return G From 604b46b06f4142ac6c3d2260a4da41b873e6b409 Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Mon, 6 Mar 2017 12:39:18 +0100 Subject: [PATCH 328/370] fixed two pep8 errors --- src/sage/geometry/polyhedron/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 4573de4996e..ee96117a762 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4266,11 +4266,10 @@ def is_neighborly(self, k=None): [True, True, True] """ - if k == None: + if k is None: k = floor(self.dim()/2) return all(len(self.faces(i)) == binomial(self.n_vertices(), i + 1) for i in range(1, k)) - @cached_method def is_lattice_polytope(self): r""" From 03dbd96a6431214c68df02beeec0ca3b0e3d967f Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Mon, 6 Mar 2017 14:25:23 +0100 Subject: [PATCH 329/370] better assertins, improved docstrings --- src/sage/geometry/polyhedron/base.py | 66 +++++++++++++++++----------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index fc4fafa128a..25e0c0a5322 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4981,7 +4981,7 @@ def is_full_dimensional(self): return self.dim() == self.ambient_dim() def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): - """ + r""" Return whether the polyhedron is combinatorially isomorphic to another polyhedron. We only consider bounded polyhedra. By definition, they are @@ -4989,8 +4989,9 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): INPUT: - - Two polyhedra - - `algo` can be either 'bipartite_graph' (the default) or 'face_lattice' + - ``other`` -- a polyhedron object. + - `algo` (default = `bipartite_graph`) -- the algorithm to use. + The other possible value is `face_lattice`. OUTPUT: @@ -4999,17 +5000,31 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): EXAMPLES: - Checking that a regular simplex intersected its negative, is combinatorially - isomorpic to intersection a cube with a hyperplane perpendicular to its long - diagonal:: + The square is combinatorially isomorphic to the 2-dimensional cube:: + + sage: polytopes.hypercube(2).is_combinatorially_isomorphic(polytopes.regular_polygon(4)) + True + + All the faces of the 3-dimensional permutahedron are either + combinatorially isomorphic to a square or a sixgon:: + sage: H = polytopes.regular_polygon(6) + sage: S = polytopes.hypercube(2) + sage: P = polytopes.permutahedron(4) + sage: all(F.as_polyhedron().is_combinatorially_isomorphic(S) or F.as_polyhedron().is_combinatorially_isomorphic(H) for F in P.faces(2)) + True + + Checking that a regular simplex intersected with its negative, + is combinatorially isomorpic to the intersection of a cube with + a hyperplane perpendicular to its long diagonal:: + polytopes.regular_polygon(4) sage: def simplex_intersection(k): - ....: S1=Polyhedron([vector(v)-vector(polytopes.simplex(k).center()) for v in polytopes.simplex(k).vertices_list()]) + ....: S1 = Polyhedron([vector(v)-vector(polytopes.simplex(k).center()) for v in polytopes.simplex(k).vertices_list()]) ....: S2 = Polyhedron([-vector(v) for v in S1.vertices_list()]) ....: return S1.intersection(S2) sage: def cube_intersection(k): - ....: C=polytopes.hypercube(k+1) - ....: H=Polyhedron(eqns=[[0]+[1 for i in range(k+1)]]) + ....: C = polytopes.hypercube(k+1) + ....: H = Polyhedron(eqns=[[0]+[1 for i in range(k+1)]]) ....: return C.intersection(H) sage: [simplex_intersection(k).is_combinatorially_isomorphic(cube_intersection(k)) for k in range(2,5)] [True, True, True] @@ -5018,7 +5033,7 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): sage: simplex_intersection(3).is_combinatorially_isomorphic(polytopes.octahedron()) True - Two polytopes with the same f-vector, but different combinatorial type:: + Two polytopes with the same `f`-vector, but different combinatorial type:: sage: P = Polyhedron([[-605520/1525633, -605520/1525633, -1261500/1525633, -52200/1525633, 11833/1525633],\ [-720/1769, -600/1769, 1500/1769, 0, -31/1769], [-216/749, 240/749, -240/749, -432/749, 461/749], \ @@ -5032,20 +5047,19 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): sage: C.is_combinatorially_isomorphic(P) False - sage: S=polytopes.simplex(3) - sage: S=S.face_truncation(S.faces(0)[0]) - sage: S=S.face_truncation(S.faces(0)[0]) - sage: S=S.face_truncation(S.faces(0)[0]) - sage: T=polytopes.simplex(3) - sage: T=T.face_truncation(T.faces(0)[0]) - sage: T=T.face_truncation(T.faces(0)[0]) - sage: T=T.face_truncation(T.faces(0)[1]) + sage: S = polytopes.simplex(3) + sage: S = S.face_truncation(S.faces(0)[0]) + sage: S = S.face_truncation(S.faces(0)[0]) + sage: S = S.face_truncation(S.faces(0)[0]) + sage: T = polytopes.simplex(3) + sage: T = T.face_truncation(T.faces(0)[0]) + sage: T = T.face_truncation(T.faces(0)[0]) + sage: T = T.face_truncation(T.faces(0)[1]) sage: T.is_combinatorially_isomorphic(S) False sage: T.f_vector(), S.f_vector() ((1, 10, 15, 7, 1), (1, 10, 15, 7, 1)) - sage: C = polytopes.hypercube(5) sage: C.is_combinatorially_isomorphic(C) True @@ -5058,21 +5072,24 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): sage: C.is_combinatorially_isomorphic(G) Traceback (most recent call last): ... - AssertionError: input must be a polyhedron + AssertionError: input `other` must be a polyhedron sage: H = Polyhedron(eqns=[[0,1,1,1,1]]); H A 3-dimensional polyhedron in QQ^4 defined as the convex hull of 1 vertex and 3 lines sage: C.is_combinatorially_isomorphic(H) Traceback (most recent call last): ... - AssertionError: polyhedra must be bounded - + AssertionError: polyhedron `other` must be bounded """ - assert isinstance(other, Polyhedron_base), "input must be a polyhedron" - assert self.is_compact() and other.is_compact(), "polyhedra must be bounded" + assert isinstance(other, Polyhedron_base), "input `other` must be a polyhedron" + assert self.is_compact(), "polyhedron `self` must be bounded" + assert other.is_compact(), "polyhedron `other` must be bounded" assert algo in ['bipartite_graph', 'face_lattice'], "algo must be 'bipartite graph' or 'face_lattice'" + # For speed, we check if the polyhedra have the same number of facets and vertices. + # This is faster then building the bipartite graphs first and + # then check that they won't be isomorphic. if self.n_vertices() != other.n_vertices() or self.n_facets() != other.n_facets(): return False @@ -5102,7 +5119,6 @@ def get_incidences(P): else: return self.face_lattice().is_isomorphic(other.face_lattice()) - def affine_hull(self): """ Return the affine hull. From 64fc4364ec46e36060597033e27f7e19a006f7e9 Mon Sep 17 00:00:00 2001 From: David Coudert Date: Mon, 6 Mar 2017 15:42:15 +0100 Subject: [PATCH 330/370] trac #22424: bloody trailing white space --- src/sage/graphs/graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py index 2d80e0ef196..cad51e522bb 100644 --- a/src/sage/graphs/graph.py +++ b/src/sage/graphs/graph.py @@ -937,7 +937,7 @@ def __init__(self, data=None, pos=None, loops=None, format=None, The position dictionary is not the input one (:trac:`22424`):: - sage: my_pos = {0:(0,0), 1:(1,1)} + sage: my_pos = {0:(0,0), 1:(1,1)} sage: G = Graph([[0,1], [(0,1)]], pos=my_pos) sage: my_pos == G._pos True From 5a2307d1656ec16e3cdf96a01cbe12c18bbc5d4c Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Mon, 6 Mar 2017 16:47:35 +0100 Subject: [PATCH 331/370] reference added --- src/doc/en/reference/references/index.rst | 5 +++++ src/sage/geometry/polyhedron/base.py | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index 4c9c2fd1ab4..682d9e1a749 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -915,6 +915,11 @@ REFERENCES: .. [Ke2008] \B. Keller, *Cluster algebras, quiver representations and triangulated categories*, :arXiv:`0807.1960`. +.. [KK1995] Victor Klee and Peter Kleinschmidt, + *Convex polytopes and related complexes.*, in \R. L. Graham, + \M. Grötschel, \L Lovász, *Handbook of combinatorics*, + Vol. 1, Chapter 18, 1995 + .. [KL2008] Chris Kurth and Ling Long, "Computations with finite index subgroups of `{\rm PSL}_2(\ZZ)` using Farey symbols", Advances in algebra and combinatorics, 225--242, World diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 25e0c0a5322..4d5b21a5a50 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4989,14 +4989,18 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): INPUT: - - ``other`` -- a polyhedron object. + - `other` -- a polyhedron object. - `algo` (default = `bipartite_graph`) -- the algorithm to use. - The other possible value is `face_lattice`. + The other possible value is `face_lattice`. OUTPUT: - - ``True`` if the two polyhedra are combinatorially isomorphic - - ``False`` otherwise + - `True` if the two polyhedra are combinatorially isomorphic + - `False` otherwise + + REFERENCES: + + For the equivalence of the two algorithms see [KK1995]_, p. 877-878 EXAMPLES: @@ -5017,6 +5021,7 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): Checking that a regular simplex intersected with its negative, is combinatorially isomorpic to the intersection of a cube with a hyperplane perpendicular to its long diagonal:: + polytopes.regular_polygon(4) sage: def simplex_intersection(k): ....: S1 = Polyhedron([vector(v)-vector(polytopes.simplex(k).center()) for v in polytopes.simplex(k).vertices_list()]) From 0a29d259a6d815c3a2a9d7ad9faf718598072ea3 Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Mon, 6 Mar 2017 17:54:56 +0100 Subject: [PATCH 332/370] whitespace --- src/doc/en/reference/references/index.rst | 4 ++-- src/sage/geometry/polyhedron/base.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index 682d9e1a749..fe922ae5af2 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -917,8 +917,8 @@ REFERENCES: .. [KK1995] Victor Klee and Peter Kleinschmidt, *Convex polytopes and related complexes.*, in \R. L. Graham, - \M. Grötschel, \L Lovász, *Handbook of combinatorics*, - Vol. 1, Chapter 18, 1995 + \M. Grötschel, \L Lovász, *Handbook of combinatorics*, + Vol. 1, Chapter 18, 1995 .. [KL2008] Chris Kurth and Ling Long, "Computations with finite index subgroups of `{\rm PSL}_2(\ZZ)` using Farey symbols", diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 4d5b21a5a50..74c8b67a9c0 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4989,14 +4989,14 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): INPUT: - - `other` -- a polyhedron object. - - `algo` (default = `bipartite_graph`) -- the algorithm to use. - The other possible value is `face_lattice`. + - ``other`` -- a polyhedron object. + - ``algo`` (default = ``bipartite_graph``) -- the algorithm to use. + The other possible value is ``face_lattice``. OUTPUT: - - `True` if the two polyhedra are combinatorially isomorphic - - `False` otherwise + - ``True`` if the two polyhedra are combinatorially isomorphic + - ``False`` otherwise REFERENCES: From eea121525d892277a6706ff9297fafc527105c7b Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Mon, 6 Mar 2017 18:05:54 +0100 Subject: [PATCH 333/370] moved comment about cyclic polytopes --- src/sage/geometry/polyhedron/base.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index ee96117a762..c19b29dcee2 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4242,11 +4242,7 @@ def is_neighborly(self, k=None): :meth:`neighborliness` - EXAMPLES: - - Cyclic polytopes are neighborly: - - :: + EXAMPLES:: sage: cube = polytopes.hypercube(3) sage: cube.is_neighborly() @@ -4254,6 +4250,11 @@ def is_neighborly(self, k=None): sage: cube = polytopes.hypercube(4) sage: cube.is_neighborly() False + + Cyclic polytopes are neighborly: + + :: + sage: all([polytopes.cyclic_polytope(i, i + 1 + j).is_neighborly() for i in range(5) for j in range(3)]) True From f931571b273b1957634be1d4b98908df6dd88197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Labb=C3=A9?= Date: Mon, 6 Mar 2017 19:10:36 +0100 Subject: [PATCH 334/370] Corrected indentation in doc --- .../en/reference/discrete_geometry/index.rst | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/doc/en/reference/discrete_geometry/index.rst b/src/doc/en/reference/discrete_geometry/index.rst index e1d90b33927..e59cbd0d2ae 100644 --- a/src/doc/en/reference/discrete_geometry/index.rst +++ b/src/doc/en/reference/discrete_geometry/index.rst @@ -9,13 +9,13 @@ Hyperplane arrangements ----------------------- .. toctree:: -:maxdepth: 1 + :maxdepth: 1 -sage/geometry/hyperplane_arrangement/arrangement -sage/geometry/hyperplane_arrangement/library -sage/geometry/hyperplane_arrangement/hyperplane -sage/geometry/hyperplane_arrangement/affine_subspace -sage/geometry/hyperplane_arrangement/plot + sage/geometry/hyperplane_arrangement/arrangement + sage/geometry/hyperplane_arrangement/library + sage/geometry/hyperplane_arrangement/hyperplane + sage/geometry/hyperplane_arrangement/affine_subspace + sage/geometry/hyperplane_arrangement/plot Polyhedral computations ----------------------- @@ -24,27 +24,27 @@ Polyhedra ~~~~~~~~~ .. toctree:: -:maxdepth: 1 + :maxdepth: 1 -sage/geometry/polyhedron/library -sage/geometry/polyhedron/constructor -sage/geometry/polyhedron/parent -sage/geometry/polyhedron/representation -sage/geometry/polyhedron/plot -sage/geometry/polyhedron/face -sage/geometry/polyhedron/cdd_file_format + sage/geometry/polyhedron/library + sage/geometry/polyhedron/constructor + sage/geometry/polyhedron/parent + sage/geometry/polyhedron/representation + sage/geometry/polyhedron/plot + sage/geometry/polyhedron/face + sage/geometry/polyhedron/cdd_file_format Lattice polyhedra ~~~~~~~~~~~~~~~~~ .. toctree:: -:maxdepth: 1 + :maxdepth: 1 -sage/geometry/lattice_polytope -sage/geometry/polyhedron/lattice_euclidean_group_element -sage/geometry/polyhedron/palp_database -sage/geometry/polyhedron/ppl_lattice_polygon -sage/geometry/polyhedron/ppl_lattice_polytope + sage/geometry/lattice_polytope + sage/geometry/polyhedron/lattice_euclidean_group_element + sage/geometry/polyhedron/palp_database + sage/geometry/polyhedron/ppl_lattice_polygon + sage/geometry/polyhedron/ppl_lattice_polytope Toric geometry ~~~~~~~~~~~~~~ From f0ec516d8d4557c4f507e9c862a8ccbb621b9ea5 Mon Sep 17 00:00:00 2001 From: Moritz Firsching Date: Mon, 6 Mar 2017 19:56:57 +0100 Subject: [PATCH 335/370] little improvements, change 'algo' to 'algorithm' --- src/sage/geometry/polyhedron/base.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 74c8b67a9c0..c15b27df1fd 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -4980,7 +4980,7 @@ def is_full_dimensional(self): """ return self.dim() == self.ambient_dim() - def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): + def is_combinatorially_isomorphic(self, other, algorithm='bipartite_graph'): r""" Return whether the polyhedron is combinatorially isomorphic to another polyhedron. @@ -4990,7 +4990,7 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): INPUT: - ``other`` -- a polyhedron object. - - ``algo`` (default = ``bipartite_graph``) -- the algorithm to use. + - ``algorithm`` (default = ``bipartite_graph``) -- the algorithm to use. The other possible value is ``face_lattice``. OUTPUT: @@ -5010,7 +5010,7 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): True All the faces of the 3-dimensional permutahedron are either - combinatorially isomorphic to a square or a sixgon:: + combinatorially isomorphic to a square or a hexagon:: sage: H = polytopes.regular_polygon(6) sage: S = polytopes.hypercube(2) @@ -5018,9 +5018,9 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): sage: all(F.as_polyhedron().is_combinatorially_isomorphic(S) or F.as_polyhedron().is_combinatorially_isomorphic(H) for F in P.faces(2)) True - Checking that a regular simplex intersected with its negative, - is combinatorially isomorpic to the intersection of a cube with - a hyperplane perpendicular to its long diagonal:: + Checking that a regular simplex intersected with its reflection + through the origin is combinatorially isomorphic to the intersection + of a cube with a hyperplane perpendicular to its long diagonal:: polytopes.regular_polygon(4) sage: def simplex_intersection(k): @@ -5038,7 +5038,7 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): sage: simplex_intersection(3).is_combinatorially_isomorphic(polytopes.octahedron()) True - Two polytopes with the same `f`-vector, but different combinatorial type:: + Two polytopes with the same `f`-vector, but different combinatorial types:: sage: P = Polyhedron([[-605520/1525633, -605520/1525633, -1261500/1525633, -52200/1525633, 11833/1525633],\ [-720/1769, -600/1769, 1500/1769, 0, -31/1769], [-216/749, 240/749, -240/749, -432/749, 461/749], \ @@ -5068,10 +5068,10 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): sage: C = polytopes.hypercube(5) sage: C.is_combinatorially_isomorphic(C) True - sage: C.is_combinatorially_isomorphic(C, algo='magic') + sage: C.is_combinatorially_isomorphic(C, algorithm='magic') Traceback (most recent call last): ... - AssertionError: algo must be 'bipartite graph' or 'face_lattice' + AssertionError: `algorithm` must be 'bipartite graph' or 'face_lattice' sage: G = Graph() sage: C.is_combinatorially_isomorphic(G) @@ -5090,7 +5090,7 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): assert isinstance(other, Polyhedron_base), "input `other` must be a polyhedron" assert self.is_compact(), "polyhedron `self` must be bounded" assert other.is_compact(), "polyhedron `other` must be bounded" - assert algo in ['bipartite_graph', 'face_lattice'], "algo must be 'bipartite graph' or 'face_lattice'" + assert algorithm in ['bipartite_graph', 'face_lattice'], "`algorithm` must be 'bipartite graph' or 'face_lattice'" # For speed, we check if the polyhedra have the same number of facets and vertices. # This is faster then building the bipartite graphs first and @@ -5098,7 +5098,7 @@ def is_combinatorially_isomorphic(self, other, algo='bipartite_graph'): if self.n_vertices() != other.n_vertices() or self.n_facets() != other.n_facets(): return False - if algo == 'bipartite_graph': + if algorithm == 'bipartite_graph': def get_incidences(P): # This function constructs a directed bipartite graph. From f696a38cece5be4c209f4f72c24bf7893dd3317c Mon Sep 17 00:00:00 2001 From: Eric Gourgoulhon Date: Mon, 6 Mar 2017 20:46:01 +0100 Subject: [PATCH 336/370] Fix bug in checking validity of coordinate values on a chart (#22535) --- src/sage/manifolds/chart.py | 112 ++++++++++++++++++++++++++---------- 1 file changed, 81 insertions(+), 31 deletions(-) diff --git a/src/sage/manifolds/chart.py b/src/sage/manifolds/chart.py index 69e1a6084d0..76cb8bcdbd8 100644 --- a/src/sage/manifolds/chart.py +++ b/src/sage/manifolds/chart.py @@ -698,19 +698,67 @@ def valid_coordinates(self, *coordinates, **kwds): substitutions = dict(zip(self._xx, coordinates)) if parameters: substitutions.update(parameters) - for restrict in self._restrictions: - if isinstance(restrict, tuple): # case of or conditions - combine = False - for expr in restrict: - combine = combine or bool(expr.subs(substitutions)) - if not combine: - return False - else: - if not bool(restrict.subs(substitutions)): - return False - # All tests have been passed: + return self._check_restrictions(self._restrictions, substitutions) return True + def _check_restrictions(self, restrict, substitutions): + r""" + Recursive helper function to check the validity of coordinates + given some restrictions + + INPUT: + + - restrict: a tuple of conditions (combined with 'or'), a list of + conditions (combined with 'and') or a single coordinate condition + - substitutions: dictionary (keys: coordinates of ``self``) giving the + value of each coordinate + + OUTPUT: + + - boolean stating whether the conditions are fulfilled by the + coordinate values + + TESTS:: + + sage: M = Manifold(2, 'M', structure='topological') + sage: X. = M.chart() + sage: X._check_restrictions(x>0, {x: pi, y: 0}) + True + sage: X._check_restrictions(x>0, {x: -sqrt(2), y: 0}) + False + sage: X._check_restrictions((x>0, [x0, [x0, [x0], {x: 1, y: 2}) + True + sage: X._check_restrictions([(x0], {x: -1, y: 2}) + False + sage: X._check_restrictions([(x0], {x: 1, y: -2}) + True + sage: X._check_restrictions([(x0], {x: 2, y: 1}) + False + + """ + if isinstance(restrict, tuple): # case of 'or' conditions + combine = False + for cond in restrict: + combine = combine or self._check_restrictions(cond, + substitutions) + return combine + elif isinstance(restrict, list): # case of 'and' conditions + combine = True + for cond in restrict: + combine = combine and self._check_restrictions(cond, + substitutions) + return combine + # Case of a single condition: + return bool(restrict.subs(substitutions)) + + + def transition_map(self, other, transformations, intersection_name=None, restrictions1=None, restrictions2=None): r""" @@ -1633,8 +1681,8 @@ def add_restrictions(self, restrictions): for restrict in self._restrictions: restrict_used = False # determines whether restrict is used # to set some coordinate bound - if not isinstance(restrict, tuple): # case of 'or' conditions - # excluded + if not isinstance(restrict, (tuple, list)): # case of combined + # conditions excluded operands = restrict.operands() left = operands[0] right = operands[1] @@ -1812,6 +1860,20 @@ def valid_coordinates(self, *coordinates, **kwds): sage: XD.valid_coordinates(0,0) True + Another open subset of the square, defined by `x^2+y^2<1` or + (`x>0` and `|y|<1`):: + + sage: B = M.open_subset('B', + ....: coord_def={X: (x^2+y^2<1, + ....: [x>0, abs(y)<1])}) + sage: XB = X.restrict(B) + sage: XB.valid_coordinates(-1/2, 0) + True + sage: XB.valid_coordinates(-1/2, 3/2) + False + sage: XB.valid_coordinates(3/2, 1/2) + True + """ n = len(coordinates) if n != self._manifold._dim: @@ -1836,31 +1898,19 @@ def valid_coordinates(self, *coordinates, **kwds): if min_included: if x < xmin: return False - else: - if x <= xmin: - return False + elif x <= xmin: + return False if max_included: if x > xmax: return False - else: - if x >= xmax: - return False + elif x >= xmax: + return False # Check of additional restrictions: - if self._restrictions != []: + if self._restrictions: substitutions = dict(zip(self._xx, coordinates)) if parameters: substitutions.update(parameters) - for restrict in self._restrictions: - if isinstance(restrict, tuple): # case of or conditions - combine = False - for expr in restrict: - combine = combine or bool(expr.subs(substitutions)) - if not combine: - return False - else: - if not bool(restrict.subs(substitutions)): - return False - # All tests have been passed: + return self._check_restrictions(self._restrictions, substitutions) return True @options(max_range=8, color='red', style='-', thickness=1, plot_points=75, From f1d98ca65bf8d28760439a502de5c39f60df6d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 6 Mar 2017 22:09:20 +0100 Subject: [PATCH 337/370] trac 22521 detail of doc --- src/sage/numerical/backends/glpk_graph_backend.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/numerical/backends/glpk_graph_backend.pyx b/src/sage/numerical/backends/glpk_graph_backend.pyx index 086bafca277..02e1934d970 100644 --- a/src/sage/numerical/backends/glpk_graph_backend.pyx +++ b/src/sage/numerical/backends/glpk_graph_backend.pyx @@ -583,7 +583,7 @@ cdef class GLPKGraphBackend(object): sage: gbe.vertices() ['A', 'B'] sage: for ed in gbe.edges(): - ....: print((ed[0], ed[1], ed[2]['cap'], ed[2]['cost'], ed[2]['low'])) + ....: print((ed[0], ed[1], ed[2]['cap'], ed[2]['cost'], ed[2]['low'])) ('A', 'B', 10.0, 5.0, 0.0) sage: gbe.add_edge("B", "C", {"low":0.0, "cap":10.0, "cost":'5'}) Traceback (most recent call last): @@ -1138,7 +1138,7 @@ cdef class GLPKGraphBackend(object): the solution can not be computed for any reason (none exists, or the LP solver was not able to find it, etc...) - EXAMPLE:: + EXAMPLES:: sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend sage: gbe = GLPKGraphBackend() @@ -1146,12 +1146,12 @@ cdef class GLPKGraphBackend(object): sage: vs = gbe.add_vertices([None for i in range(len(vertices))]) sage: v_dict = {} sage: for i, v in enumerate(vs): - ....: v_dict[v] = vertices[i] + ....: v_dict[v] = vertices[i] sage: gbe.set_vertices_demand(v_dict.items()) sage: cost = ((8, 6, 10, 9), (9, 12, 13, 7), (14, 9, 16, 5)) sage: for i in range(len(cost)): - ....: for j in range(len(cost[0])): + ....: for j in range(len(cost[0])): ....: gbe.add_edge(str(i), str(j + len(cost)), {"cost":cost[i][j], "cap":100}) sage: gbe.mincost_okalg() 1020.0 From 752a1ae1095792157378c4a990348afde9fcddc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 6 Mar 2017 22:24:20 +0100 Subject: [PATCH 338/370] trac 22517 remove now superflous comments --- src/sage/data_structures/bitset.pyx | 24 +++++----- src/sage/libs/coxeter3/coxeter.pyx | 48 +++++++++---------- src/sage/libs/ecl.pyx | 4 +- src/sage/libs/gap/util.pyx | 12 ++--- src/sage/libs/ppl.pyx | 24 +++++----- src/sage/matroids/basis_matroid.pyx | 4 +- .../matroids/circuit_closures_matroid.pyx | 6 +-- src/sage/matroids/lean_matrix.pyx | 36 +++++++------- src/sage/matroids/linear_matroid.pyx | 6 +-- src/sage/matroids/matroid.pyx | 10 ++-- src/sage/rings/complex_interval.pyx | 12 ++--- .../sat/solvers/cryptominisat/solverconf.pyx | 4 +- 12 files changed, 95 insertions(+), 95 deletions(-) diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx index 24ed5553b6f..368aa58af2d 100644 --- a/src/sage/data_structures/bitset.pyx +++ b/src/sage/data_structures/bitset.pyx @@ -659,17 +659,17 @@ cdef class FrozenBitset: left = self right = other._larger_capacity_(self._bitset.size) - if op == Py_EQ: # == + if op == Py_EQ: return bitset_eq(left._bitset, right._bitset) - elif op == Py_NE: # != + elif op == Py_NE: return not bitset_eq(left._bitset, right._bitset) - elif op == Py_LT: # < + elif op == Py_LT: return bitset_issubset(left._bitset, right._bitset) and not bitset_eq(left._bitset, right._bitset) - elif op == Py_LE: # <= + elif op == Py_LE: return bitset_issubset(left._bitset, right._bitset) - elif op == Py_GT: # > + elif op == Py_GT: return bitset_issuperset(left._bitset, right._bitset) and not bitset_eq(left._bitset, right._bitset) - elif op == Py_GE: # >= + elif op == Py_GE: return bitset_issuperset(left._bitset, right._bitset) cpdef bint issubset(self, FrozenBitset other) except -1: @@ -1401,17 +1401,17 @@ cdef class Bitset(FrozenBitset): left = self right = other._larger_capacity_(self._bitset.size) - if op == Py_EQ: # == + if op == Py_EQ: return bitset_eq(left._bitset, right._bitset) - elif op == Py_NE: # != + elif op == Py_NE: return not bitset_eq(left._bitset, right._bitset) - elif op == Py_LT: # < + elif op == Py_LT: return bitset_issubset(left._bitset, right._bitset) and not bitset_eq(left._bitset, right._bitset) - elif op == Py_LE: # <= + elif op == Py_LE: return bitset_issubset(left._bitset, right._bitset) - elif op == Py_GT: # > + elif op == Py_GT: return bitset_issuperset(left._bitset, right._bitset) and not bitset_eq(left._bitset, right._bitset) - elif op == Py_GE: # >= + elif op == Py_GE: return bitset_issuperset(left._bitset, right._bitset) cdef FrozenBitset _new(self, long int capacity): diff --git a/src/sage/libs/coxeter3/coxeter.pyx b/src/sage/libs/coxeter3/coxeter.pyx index 467e633fd12..528ddf52a35 100644 --- a/src/sage/libs/coxeter3/coxeter.pyx +++ b/src/sage/libs/coxeter3/coxeter.pyx @@ -98,17 +98,17 @@ cdef class String: s = repr(self) o = repr(other) - if op == Py_EQ: # == + if op == Py_EQ: return s == o - elif op == Py_NE: # != + elif op == Py_NE: return s != o - elif op == Py_LT: # < + elif op == Py_LT: return s < o - elif op == Py_LE: # <= + elif op == Py_LE: return s <= o - elif op == Py_GT: # > + elif op == Py_GT: return s > o - elif op == Py_GE: # >= + elif op == Py_GE: return s >= o def __len__(self): @@ -221,17 +221,17 @@ cdef class Type: s = repr(self) o = repr(other) - if op == Py_EQ: # == + if op == Py_EQ: return s == o - elif op == Py_NE: # != + elif op == Py_NE: return s != o - elif op == Py_LT: # < + elif op == Py_LT: return s < o - elif op == Py_LE: # <= + elif op == Py_LE: return s <= o - elif op == Py_GT: # > + elif op == Py_GT: return s > o - elif op == Py_GE: # >= + elif op == Py_GE: return s >= o def __reduce__(self): @@ -370,17 +370,17 @@ cdef class CoxGroup(SageObject): s_r = self.rank() o_r = other.rank() - if op == Py_EQ: # == + if op == Py_EQ: return s_t == o_t and s_r == o_r - elif op == Py_NE: # != + elif op == Py_NE: return s_t != o_t or s_r != o_r - elif op == Py_LT: # < + elif op == Py_LT: return s_t < o_t or (s_t == o_t and s_r < o_r) - elif op == Py_LE: # <= + elif op == Py_LE: return s_t < o_t or (s_t == o_t and s_r <= o_r) - elif op == Py_GT: # > + elif op == Py_GT: return s_t > o_t or (s_t == o_t and s_r > o_r) - elif op == Py_GE: # >= + elif op == Py_GE: return s_t > o_t or (s_t == o_t and s_r >= o_r) def __reduce__(self): @@ -867,17 +867,17 @@ cdef class CoxGroupElement: s_l = list(self) o_l = list(other) - if op == Py_EQ: # == + if op == Py_EQ: return s_p == o_p and s_l == o_l - elif op == Py_NE: # != + elif op == Py_NE: return s_p != o_p or s_l != o_l - elif op == Py_LT: # < + elif op == Py_LT: return s_p < o_p or (s_p == o_p and s_l < o_l) - elif op == Py_LE: # <= + elif op == Py_LE: return s_p < o_p or (s_p == o_p and s_l <= o_l) - elif op == Py_GT: # > + elif op == Py_GT: return s_p > o_p or (s_p == o_p and s_l > o_l) - elif op == Py_GE: # >= + elif op == Py_GE: return s_p > o_p or (s_p == o_p and s_l >= o_l) def __iter__(self): diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx index 6992d34f9a9..c8382d8ec60 100644 --- a/src/sage/libs/ecl.pyx +++ b/src/sage/libs/ecl.pyx @@ -819,12 +819,12 @@ cdef class EclObject: sage: EclObject("<")(a,b) """ - if op == Py_EQ: # "==" + if op == Py_EQ: if not(isinstance(left,EclObject) and isinstance(right,EclObject)): return False else: return bint_equal((left).obj,(right).obj) - elif op == Py_NE: # "!=" + elif op == Py_NE: if not(isinstance(left,EclObject) and isinstance(right,EclObject)): return True else: diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx index 730998e4711..8ab79e90051 100644 --- a/src/sage/libs/gap/util.pyx +++ b/src/sage/libs/gap/util.pyx @@ -60,17 +60,17 @@ cdef class ObjWrapper(object): cdef result cdef libGAP_Obj self_value = self.value cdef libGAP_Obj other_value = other.value - if op == Py_LT: # < 0 + if op == Py_LT: return self_value < other_value - elif op == Py_LE: # <= 1 + elif op == Py_LE: return self_value <= other_value - elif op == Py_EQ: # == 2 + elif op == Py_EQ: return self_value == other_value - elif op == Py_GT: # > 4 + elif op == Py_GT: return self_value > other_value - elif op == Py_GE: # >= 5 + elif op == Py_GE: return self_value >= other_value - elif op == Py_NE: # != 3 + elif op == Py_NE: return self_value != other_value else: assert False # unreachable diff --git a/src/sage/libs/ppl.pyx b/src/sage/libs/ppl.pyx index 469fc5ab576..c282018bff3 100644 --- a/src/sage/libs/ppl.pyx +++ b/src/sage/libs/ppl.pyx @@ -3132,17 +3132,17 @@ cdef class Polyhedron(_mutable_or_immutable): """ cdef result sig_on() - if op == Py_LT: # < 0 + if op == Py_LT: result = rhs.strictly_contains(lhs) - elif op == Py_LE: # <= 1 + elif op == Py_LE: result = rhs.contains(lhs) - elif op == Py_EQ: # == 2 + elif op == Py_EQ: result = (lhs.thisptr[0] == rhs.thisptr[0]) - elif op == Py_GT: # > 4 + elif op == Py_GT: result = lhs.strictly_contains(rhs) - elif op == Py_GE: # >= 5 + elif op == Py_GE: result = lhs.contains(rhs) - elif op == Py_NE: # != 3 + elif op == Py_NE: result = (lhs.thisptr[0] != rhs.thisptr[0]) else: assert False # unreachable @@ -5656,17 +5656,17 @@ cdef _wrap_Constraint(PPL_Constraint constraint): cdef _make_Constraint_from_richcmp(lhs_, rhs_, op): cdef Linear_Expression lhs = Linear_Expression(lhs_) cdef Linear_Expression rhs = Linear_Expression(rhs_) - if op==0: # < 0 + if op == Py_LT: return _wrap_Constraint(lhs.thisptr[0] < rhs.thisptr[0]) - elif op==1: # <= 1 + elif op == Py_LE: return _wrap_Constraint(lhs.thisptr[0] <= rhs.thisptr[0]) - elif op==2: # == 2 + elif op == Py_EQ: return _wrap_Constraint(lhs.thisptr[0] == rhs.thisptr[0]) - elif op==4: # > 4 + elif op == Py_GT: return _wrap_Constraint(lhs.thisptr[0] > rhs.thisptr[0]) - elif op==5: # >= 5 + elif op == Py_GE: return _wrap_Constraint(lhs.thisptr[0] >= rhs.thisptr[0]) - elif op==3: # != 3 + elif op == Py_NE: raise NotImplementedError else: assert(False) diff --git a/src/sage/matroids/basis_matroid.pyx b/src/sage/matroids/basis_matroid.pyx index ad414638b2a..b3f1a009455 100644 --- a/src/sage/matroids/basis_matroid.pyx +++ b/src/sage/matroids/basis_matroid.pyx @@ -1157,9 +1157,9 @@ cdef class BasisMatroid(BasisExchangeMatroid): return NotImplemented if not isinstance(left, BasisMatroid) or not isinstance(right, BasisMatroid): return NotImplemented - if op == Py_EQ: # == + if op == Py_EQ: res = True - if op == Py_NE: # != + if op == Py_NE: res = False # res gets inverted if matroids are deemed different. if left.equals(right): diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx index 5bce0ea31ed..5fbfcb85d0e 100644 --- a/src/sage/matroids/circuit_closures_matroid.pyx +++ b/src/sage/matroids/circuit_closures_matroid.pyx @@ -477,15 +477,15 @@ cdef class CircuitClosuresMatroid(Matroid): False """ cdef CircuitClosuresMatroid lt, rt - if op not in [Py_EQ, Py_NE]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: return NotImplemented if not isinstance(left, CircuitClosuresMatroid) or not isinstance(right, CircuitClosuresMatroid): return NotImplemented lt = left rt = right - if op == Py_EQ: # == + if op == Py_EQ: res = True - if op == Py_NE: # != + if op == Py_NE: res = False # res gets inverted if matroids are deemed different. if lt.groundset() != rt.groundset(): diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx index 5d666b8d08a..10731421255 100644 --- a/src/sage/matroids/lean_matrix.pyx +++ b/src/sage/matroids/lean_matrix.pyx @@ -447,15 +447,15 @@ cdef class LeanMatrix: False """ cdef long i, j - if op not in [Py_EQ, Py_NE]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: return NotImplemented if not isinstance(left, LeanMatrix) or not isinstance(right, LeanMatrix): return NotImplemented if type(left) != type(right): return NotImplemented - if op == Py_EQ: # == + if op == Py_EQ: res = True - if op == Py_NE: # != + if op == Py_NE: res = False # res gets inverted if matroids are deemed different. if left.nrows() != right.nrows(): @@ -911,13 +911,13 @@ cdef class GenericMatrix(LeanMatrix): False """ cdef long i, j - if op not in [Py_EQ, Py_NE]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: return NotImplemented if not isinstance(left, GenericMatrix) or not isinstance(right, GenericMatrix): return NotImplemented - if op == Py_EQ: # == + if op == Py_EQ: res = True - if op == Py_NE: # != + if op == Py_NE: res = False # res gets inverted if matroids are deemed different. if left.nrows() != right.nrows(): @@ -1513,13 +1513,13 @@ cdef class BinaryMatrix(LeanMatrix): False """ cdef long i, j - if op not in [Py_EQ, Py_NE]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: return NotImplemented if not isinstance(left, BinaryMatrix) or not isinstance(right, BinaryMatrix): return NotImplemented - if op == Py_EQ: # == + if op == Py_EQ: res = True - if op == Py_NE: # != + if op == Py_NE: res = False # res gets inverted if matroids are deemed different. if left.nrows() != right.nrows(): @@ -2068,13 +2068,13 @@ cdef class TernaryMatrix(LeanMatrix): False """ cdef long i, j - if op not in [Py_EQ, Py_NE]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: return NotImplemented if not isinstance(left, TernaryMatrix) or not isinstance(right, TernaryMatrix): return NotImplemented - if op == Py_EQ: # == + if op == Py_EQ: res = True - if op == Py_NE: # != + if op == Py_NE: res = False # res gets inverted if matroids are deemed different. if left.nrows() != right.nrows(): @@ -2667,13 +2667,13 @@ cdef class QuaternaryMatrix(LeanMatrix): False """ cdef long i, j - if op not in [Py_EQ, Py_NE]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: return NotImplemented if not isinstance(left, QuaternaryMatrix) or not isinstance(right, QuaternaryMatrix): return NotImplemented - if op == Py_EQ: # == + if op == Py_EQ: res = True - if op == Py_NE: # != + if op == Py_NE: res = False if left.base_ring() != right.base_ring(): return not res @@ -3138,13 +3138,13 @@ cdef class IntegerMatrix(LeanMatrix): False """ cdef long i, j - if op not in [Py_EQ, Py_NE]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: return NotImplemented if not isinstance(left, IntegerMatrix) or not isinstance(right, IntegerMatrix): return NotImplemented - if op == Py_EQ: # == + if op == Py_EQ: res = True - if op == Py_NE: # != + if op == Py_NE: res = False # res gets inverted if matroids are deemed different. if left.nrows() != right.nrows(): diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx index 98e553224e5..4fdf76198db 100644 --- a/src/sage/matroids/linear_matroid.pyx +++ b/src/sage/matroids/linear_matroid.pyx @@ -1222,15 +1222,15 @@ cdef class LinearMatroid(BasisExchangeMatroid): sage: M1 == M3 # indirect doctest True """ - if op not in [Py_EQ, Py_NE]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: return NotImplemented if not isinstance(left, LinearMatroid) or not isinstance(right, LinearMatroid): return NotImplemented if left.__class__ != right.__class__: # since we have some subclasses, an extra test return NotImplemented - if op == Py_EQ: # == + if op == Py_EQ: res = True - if op == Py_NE: # != + if op == Py_NE: res = False # res gets inverted if matroids are deemed different. if left.is_field_equivalent(right): diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 5acfd4f61c7..149c4e86b7e 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -3544,7 +3544,7 @@ cdef class Matroid(SageObject): True """ from . import basis_matroid - if op not in [Py_EQ, Py_NE]: # <, <=, >, >= + if op not in [Py_EQ, Py_NE]: return NotImplemented if left.__class__ != right.__class__: return NotImplemented @@ -3554,15 +3554,15 @@ cdef class Matroid(SageObject): # sage.matroids.matroid.Matroid.__richcmp__(p, q, 2) # Non-abstract subclasses should just call isinstance on both left and right. if hash(left) != hash(right): - if op == Py_EQ: # == + if op == Py_EQ: return False - if op == Py_NE: # != + if op == Py_NE: return True res = (basis_matroid.BasisMatroid(left) == basis_matroid.BasisMatroid(right)) # Default implementation - if op == Py_EQ: # == + if op == Py_EQ: return res - if op == Py_NE: # != + if op == Py_NE: return not res # Minors and duality diff --git a/src/sage/rings/complex_interval.pyx b/src/sage/rings/complex_interval.pyx index c267a5571e2..d211092bd3d 100644 --- a/src/sage/rings/complex_interval.pyx +++ b/src/sage/rings/complex_interval.pyx @@ -1449,7 +1449,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): cdef ComplexIntervalFieldElement lt, rt lt = left rt = right - if op == Py_EQ: # == + if op == Py_EQ: # intervals a == b iff a<=b and b <= a # (this gives a result with two comparisons, where the # obvious approach would use three) @@ -1457,7 +1457,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): and mpfr_lessequal_p(&rt.__re.right, <.__re.left) \ and mpfr_lessequal_p(<.__im.right, &rt.__im.left) \ and mpfr_lessequal_p(&rt.__im.right, <.__im.left) - elif op == Py_NE: # != + elif op == Py_NE: return mpfr_less_p(<.__re.right, &rt.__re.left) \ or mpfr_less_p(&rt.__re.right, <.__re.left) \ or mpfr_less_p(<.__im.right, &rt.__im.left) \ @@ -1469,13 +1469,13 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): diff = left - right real_diff = diff.real() imag_diff = diff.imag() - if op == Py_LT: # < + if op == Py_LT: return real_diff < 0 or (real_diff == 0 and imag_diff < 0) - elif op == Py_LE: # <= + elif op == Py_LE: return real_diff < 0 or (real_diff == 0 and imag_diff <= 0) - elif op == Py_GT: # > + elif op == Py_GT: return real_diff > 0 or (real_diff == 0 and imag_diff > 0) - elif op == Py_GE: # >= + elif op == Py_GE: return real_diff > 0 or (real_diff == 0 and imag_diff >= 0) cpdef int _cmp_(left, right) except -2: diff --git a/src/sage/sat/solvers/cryptominisat/solverconf.pyx b/src/sage/sat/solvers/cryptominisat/solverconf.pyx index 49a2aa3d60e..ff1c267ef62 100644 --- a/src/sage/sat/solvers/cryptominisat/solverconf.pyx +++ b/src/sage/sat/solvers/cryptominisat/solverconf.pyx @@ -292,9 +292,9 @@ cdef class SolverConf(object): if op not in (Py_EQ, Py_NE): raise TypeError("Configurations are not ordered.") res = all(self[name] == other[name] for name in self.trait_names()) - if op == Py_EQ: # == + if op == Py_EQ: return res - if op == Py_NE: # != + if op == Py_NE: return not res def __copy__(self): From 63f725d65fcd99c3a8669534efdd3114e31bf1ff Mon Sep 17 00:00:00 2001 From: paulmasson Date: Mon, 6 Mar 2017 14:23:25 -0800 Subject: [PATCH 339/370] Fallback to CDN when online --- src/ext/threejs/threejs_template.html | 4 ++-- src/sage/plot/plot3d/base.pyx | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ext/threejs/threejs_template.html b/src/ext/threejs/threejs_template.html index 31244702317..39dc0d0b22a 100644 --- a/src/ext/threejs/threejs_template.html +++ b/src/ext/threejs/threejs_template.html @@ -2,8 +2,8 @@ - - + +