Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge #32731
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Oct 26, 2021
2 parents f0121c5 + 33a2e7b commit 6abf489
Show file tree
Hide file tree
Showing 69 changed files with 290 additions and 261 deletions.
18 changes: 18 additions & 0 deletions src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5031,6 +5031,24 @@ def integer_floor(x):
raise NotImplementedError("computation of floor of %s not implemented"%x)


def integer_trunc(i):
"""
Truncate to the integer closer to zero
EXAMPLES::
sage: from sage.arith.misc import integer_trunc as trunc
sage: trunc(-3/2), trunc(-1), trunc(-1/2), trunc(0), trunc(1/2), trunc(1), trunc(3/2)
(-1, -1, 0, 0, 0, 1, 1)
sage: isinstance(trunc(3/2), Integer)
True
"""
if i >= 0:
return integer_floor(i)
else:
return integer_ceil(i)


def two_squares(n):
"""
Write the integer `n` as a sum of two integer squares if possible;
Expand Down
3 changes: 2 additions & 1 deletion src/sage/coding/code_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@
from sage.rings.all import QQ, RR, ZZ, RDF
from sage.arith.misc import is_prime_power
from sage.arith.all import binomial
from sage.functions.all import log, sqrt
from sage.functions.all import log
from sage.misc.functional import sqrt
from .delsarte_bounds import (delsarte_bound_hamming_space,
delsarte_bound_additive_hamming_space)

Expand Down
3 changes: 2 additions & 1 deletion src/sage/coding/guruswami_sudan/gs_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
from sage.coding.guruswami_sudan.utils import (johnson_radius,
gilt,
solve_degree2_to_integer_range)
from sage.functions.other import floor, sqrt
from sage.functions.other import floor
from sage.misc.functional import sqrt

def n_k_params(C, n_k):
r"""
Expand Down
3 changes: 2 additions & 1 deletion src/sage/coding/guruswami_sudan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#*****************************************************************************


from sage.functions.other import floor, sqrt
from sage.functions.other import floor
from sage.misc.functional import sqrt
from sage.rings.integer_ring import ZZ
from sage.rings.integer import Integer

Expand Down
2 changes: 1 addition & 1 deletion src/sage/coding/linear_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ def chinen_polynomial(self):
- Chinen, K. "An abundance of invariant polynomials satisfying the
Riemann hypothesis", April 2007 preprint.
"""
from sage.functions.all import sqrt
from sage.misc.functional import sqrt
C = self
n = C.length()
RT = PolynomialRing(QQ,2,"Ts")
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/binary_recurrence_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from sage.rings.integer import Integer
from sage.arith.all import lcm, next_prime, is_prime, next_prime_power, legendre_symbol
from sage.functions.log import log
from sage.functions.other import sqrt
from sage.misc.functional import sqrt


class BinaryRecurrenceSequence(SageObject):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/crystals/littelmann_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from sage.rings.integer import Integer
from sage.rings.rational_field import QQ
from sage.combinat.root_system.root_system import RootSystem
from sage.functions.other import floor
from sage.arith.misc import integer_floor as floor
from sage.misc.latex import latex


Expand Down
21 changes: 1 addition & 20 deletions src/sage/combinat/crystals/tensor_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,8 @@
from sage.misc.flatten import flatten
from sage.structure.element import get_coercion_model
from sage.rings.semirings.non_negative_integer_semiring import NN
from sage.arith.misc import integer_trunc as trunc

##############################################################################
# Until trunc gets implemented in sage.function.other

from sage.functions.other import floor, ceil
def trunc(i):
"""
Truncates to the integer closer to zero
EXAMPLES::
sage: from sage.combinat.crystals.tensor_product import trunc
sage: trunc(-3/2), trunc(-1), trunc(-1/2), trunc(0), trunc(1/2), trunc(1), trunc(3/2)
(-1, -1, 0, 0, 0, 1, 1)
sage: isinstance(trunc(3/2), Integer)
True
"""
if i>= 0:
return floor(i)
else:
return ceil(i)

##############################################################################
# Support classes
Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/crystals/tensor_product_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
from sage.structure.parent cimport Parent

from sage.misc.cachefunc import cached_method, cached_in_parent_method
from sage.functions.other import ceil
from sage.combinat.tableau import Tableau
from sage.rings.integer_ring import ZZ

Expand Down
3 changes: 2 additions & 1 deletion src/sage/combinat/diagram_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
from sage.misc.misc_c import prod
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.functions.other import floor, ceil
from sage.arith.misc import integer_floor as floor
from sage.arith.misc import integer_ceil as ceil

import itertools

Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/parallelogram_polyomino.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from sage.combinat.combinat import catalan_number
from sage.combinat.combinatorial_map import combinatorial_map
from sage.functions.trig import cos, sin
from sage.functions.other import sqrt
from sage.misc.functional import sqrt

from sage.plot.graphics import Graphics
from sage.plot.line import line
Expand Down
3 changes: 2 additions & 1 deletion src/sage/combinat/posets/poset_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,8 @@ def _random_lattice(n, p):
meet for `e, m` for all `m \in M`. We do that by keeping
track of meet matrix and list of maximal elements.
"""
from sage.functions.other import floor, sqrt
from sage.functions.other import floor
from sage.misc.functional import sqrt
from sage.misc.prandom import random

n = n-1
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/root_system/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ def barycentric_projection_matrix(n, angle=0):
"""
from sage.matrix.constructor import matrix
from sage.functions.other import sqrt
from sage.misc.functional import sqrt
n = ZZ(n)
if n == 0:
return matrix(QQ, 0, 1)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/symmetric_group_representations.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# ****************************************************************************

from sage.symbolic.ring import SR
from sage.functions.all import sqrt
from sage.misc.functional import sqrt
from sage.combinat.partition import Partition, Partitions
from sage.combinat.permutation import Permutation, Permutations, from_cycles
from sage.combinat.tableau import StandardTableaux, Tableau
Expand Down
3 changes: 2 additions & 1 deletion src/sage/combinat/words/word_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ def FibonacciWord(self, alphabet=(0, 1), construction_method="recursive"):
return w

elif construction_method == "function":
from sage.functions.other import sqrt, floor
from sage.functions.other import floor
from sage.misc.functional import sqrt
phi = (1 + sqrt(5))/2 # the golden ratio
f = lambda n:a if floor((n+2)*phi) - floor((n+1)*phi) == 2 else b
return W(f)
Expand Down
3 changes: 2 additions & 1 deletion src/sage/crypto/lwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
"""

from sage.functions.log import log
from sage.functions.other import sqrt, floor, ceil
from sage.functions.other import floor, ceil
from sage.misc.functional import sqrt
from sage.misc.functional import cyclotomic_polynomial, round
from sage.misc.randstate import set_random_seed
from sage.misc.prandom import randint
Expand Down
20 changes: 10 additions & 10 deletions src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from copy import copy, deepcopy
from sage.combinat.subset import Subsets
from sage.functions.all import sqrt
from sage.misc.functional import sqrt
from itertools import permutations, combinations, product
from sage.matrix.constructor import matrix
from sage.structure.element import is_Matrix
Expand All @@ -39,7 +39,7 @@
from sage.sets.set import Set
from sage.combinat.permutation import Arrangements
from sage.parallel.use_fork import p_iter_fork
from sage.functions.other import floor


def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False, iso_type=False):
r"""
Expand Down Expand Up @@ -2213,8 +2213,8 @@ def find_conjugations_arrangement(tuples):
# and check linear independence in parallel
if len(all_subsets) > num_cpus:
for i in range(num_cpus):
start = floor(len(all_subsets)*i/num_cpus)
end = floor(len(all_subsets)*(i+1)/num_cpus)
start = (len(all_subsets) * i) // num_cpus
end = (len(all_subsets) * (i+1)) // num_cpus
tuples = all_subsets[start:end]
parallel_data.append(([tuples], {}))

Expand Down Expand Up @@ -2242,8 +2242,8 @@ def find_conjugations_arrangement(tuples):
all_arrangements += list(product(*subset_arrangements))
parallel_data = []
for i in range(num_cpus):
start = floor(len(all_arrangements)*i/num_cpus)
end = floor(len(all_arrangements)*(i+1)/num_cpus)
start = (len(all_arrangements) * i) // num_cpus
end = (len(all_arrangements) * (i+1)) // num_cpus
tuples = all_arrangements[start:end]
parallel_data.append(([tuples], {}))
X = p_iter_fork(num_cpus)
Expand Down Expand Up @@ -2350,8 +2350,8 @@ def find_conjugations_arrangement(tuples):
# and check linear independence in parallel
if len(all_subsets) > num_cpus:
for i in range(num_cpus):
start = floor(len(all_subsets)*i/num_cpus)
end = floor(len(all_subsets)*(i+1)/num_cpus)
start = (len(all_subsets) * i) // num_cpus
end = (len(all_subsets) * (i+1)) // num_cpus
tuples = all_subsets[start:end]
parallel_data.append(([tuples], {}))

Expand Down Expand Up @@ -2380,8 +2380,8 @@ def find_conjugations_arrangement(tuples):
all_arrangements += list(product(*subset_arrangements))
parallel_data = []
for i in range(num_cpus):
start = floor(len(all_arrangements)*i/num_cpus)
end = floor(len(all_arrangements)*(i+1)/num_cpus)
start = (len(all_arrangements) * i) // num_cpus
end = (len(all_arrangements) * (i+1)) // num_cpus
tuples = all_arrangements[start:end]
parallel_data.append(([tuples], {}))
X = p_iter_fork(num_cpus)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/dynamics/arithmetic_dynamics/projective_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class initialization directly.
from sage.categories.number_fields import NumberFields
from sage.categories.homset import End
from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem
from sage.functions.all import sqrt
from sage.misc.functional import sqrt
from sage.functions.other import ceil
from sage.libs.pari.all import PariError
from sage.matrix.constructor import matrix, identity_matrix
Expand Down
2 changes: 1 addition & 1 deletion src/sage/dynamics/arithmetic_dynamics/wehlerK3.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from sage.calculus.functions import jacobian
from sage.categories.fields import Fields
from sage.categories.number_fields import NumberFields
from sage.functions.all import sqrt
from sage.misc.functional import sqrt
from sage.misc.cachefunc import cached_method
from sage.misc.mrange import xmrange
from sage.rings.all import CommutativeRing
Expand Down
2 changes: 1 addition & 1 deletion src/sage/functions/bessel.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.functions.other import sqrt
from sage.misc.functional import sqrt
from sage.functions.log import exp
from sage.functions.hyperbolic import sinh, cosh
from sage.functions.trig import sin, cos
Expand Down
3 changes: 2 additions & 1 deletion src/sage/functions/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
from sage.symbolic.function import BuiltinFunction
from sage.libs.mpmath import utils as mpmath_utils
from sage.symbolic.expression import Expression
from sage.functions.all import sqrt, exp
from sage.functions.all import exp
from sage.misc.functional import sqrt
from sage.symbolic.constants import pi
from sage.rings.rational import Rational
from sage.rings.infinity import unsigned_infinity
Expand Down
2 changes: 1 addition & 1 deletion src/sage/functions/orthogonal_polys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,7 @@ def eval_recursive(self, n, m, x, **kwds):
sage: gen_legendre_Q(2,2,x).subs(x=2).expand()
9/2*I*pi - 9/2*log(3) + 14/3
"""
from sage.functions.all import sqrt
from sage.misc.functional import sqrt
if m == n + 1 or n == 0:
if m.mod(2).is_zero():
denom = (1 - x**2)**(m/2)
Expand Down
Loading

0 comments on commit 6abf489

Please sign in to comment.