Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Oct 25, 2021
2 parents a776def + bed7308 commit ad7daf1
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 36 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -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/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -9272,7 +9272,7 @@ def _ford_fulkerson(self, s, t, use_edge_labels=False, integer=False, value_only
0
"""
from sage.graphs.digraph import DiGraph
from sage.functions.other import floor
from sage.arith.misc import integer_floor as floor

# Whether we should consider the edges labeled
if use_edge_labels:
Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/hyperbolicity.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ from sage.graphs.distances_all_pairs cimport c_distances_all_pairs
from sage.arith.all import binomial
from sage.rings.integer_ring import ZZ
from sage.rings.real_mpfr import RR
from sage.functions.other import floor
from sage.data_structures.bitset import Bitset
from sage.graphs.base.static_sparse_graph cimport short_digraph
from sage.graphs.base.static_sparse_graph cimport init_short_digraph
Expand Down
1 change: 0 additions & 1 deletion src/sage/modular/pollack_stevens/dist.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ from sage.matrix.matrix cimport Matrix
from sage.matrix.matrix_space import MatrixSpace
from sage.matrix.constructor import matrix
from sage.misc.prandom import random
from sage.functions.other import floor
from sage.structure.element cimport RingElement, Element
import operator
from sage.rings.padics.padic_generic import pAdicGeneric
Expand Down
1 change: 0 additions & 1 deletion src/sage/quadratic_forms/ternary.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ from sage.arith.all import inverse_mod, xgcd, gcd
from sage.quadratic_forms.extras import extend_to_primitive
from sage.rings.finite_rings.integer_mod import mod
from sage.misc.prandom import randint
from sage.functions.other import ceil, floor


def red_mfact(a,b):
Expand Down

0 comments on commit ad7daf1

Please sign in to comment.