Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cylint: some details in arith, algebras and crypto folders #36039

Merged
merged 1 commit into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/sage/algebras/letterplace/free_algebra_letterplace.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ cdef MPolynomialRing_libsingular make_letterplace_ring(base_ring, blocks):
(Lexicographic term order of length 3,
Lexicographic term order of length 3)
"""
n = base_ring.ngens()
T0 = base_ring.term_order()
T = T0
cdef i
Expand Down Expand Up @@ -680,7 +679,6 @@ cdef class FreeAlgebra_letterplace(Algebra):
C = self.current_ring()
cdef FreeAlgebraElement_letterplace x
ngens = self.__ngens
degbound = self._degbound
cdef list G = [C(x._poly) for x in g]
from sage.groups.perm_gps.permgroup_named import CyclicPermutationGroup
CG = CyclicPermutationGroup(C.ngens())
Expand Down
18 changes: 9 additions & 9 deletions src/sage/arith/constants.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
#

cdef extern from *:
double M_PI "0x3.243f6a8885a3p+0" # π
double M_EULER "0x9.3c467e37db0c8p-4" # γ
double M_LN2 "0xb.17217f7d1cf78p-4" # log(2)
double M_LN10 "0x2.4d763776aaa2cp+0" # log(10)
double M_LNPI "0x1.250d048e7a1bdp+0" # log(π)
double M_1_LN2 "0x1.71547652b82fep+0" # 1/log(2)
double M_1_LN10 "0x6.f2dec549b9438p-4" # 1/log(10)
double M_1_LNPI "0xd.fa22fdd8cfd98p-4" # 1/log(π)
double M_LN2_LN10 "0x4.d104d427de7fcp-4" # log(2)/log(10)
double M_PI "0x3.243f6a8885a3p+0" # π
double M_EULER "0x9.3c467e37db0c8p-4" # γ
double M_LN2 "0xb.17217f7d1cf78p-4" # log(2)
double M_LN10 "0x2.4d763776aaa2cp+0" # log(10)
double M_LNPI "0x1.250d048e7a1bdp+0" # log(π)
double M_1_LN2 "0x1.71547652b82fep+0" # 1/log(2)
double M_1_LN10 "0x6.f2dec549b9438p-4" # 1/log(10)
double M_1_LNPI "0xd.fa22fdd8cfd98p-4" # 1/log(π)
double M_LN2_LN10 "0x4.d104d427de7fcp-4" # log(2)/log(10)

double LOG_TEN_TWO_PLUS_EPSILON "0x3.5269e12f346e4p+0" # log(10,2) rounded up
16 changes: 8 additions & 8 deletions src/sage/arith/multi_modular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ cdef class MultiModularBasis_base():
new_partial_products.append(M)
mpz_clear(height)
return self.extend_with_primes(new_moduli, new_partial_products,
check=False)
check=False)

def _extend_moduli_to_count(self, int count):
r"""
Expand Down Expand Up @@ -470,7 +470,7 @@ cdef class MultiModularBasis_base():
Compute and store `\prod_j=1^{i-1} m_j^{-1} (mod m_i)` for i >= start.
"""
if start == 0:
start = 1 # first one is trivial, never used
start = 1 # first one is trivial, never used
self.C[0] = 1
for i in range(start, self.n):
self.C[i] = ai.c_inverse_mod_longlong(mpz_fdiv_ui(self.partial_products[i-1], self.moduli[i]), self.moduli[i])
Expand All @@ -483,7 +483,7 @@ cdef class MultiModularBasis_base():
self._extend_moduli_to_height_c(height)

cdef int count
count = self.n * mpz_sizeinbase(height, 2) / mpz_sizeinbase(self.partial_products[self.n-1], 2) # an estimate
count = self.n * mpz_sizeinbase(height, 2) / mpz_sizeinbase(self.partial_products[self.n-1], 2) # an estimate
count = max(min(count, self.n), 1)
while count > 1 and mpz_cmp(height, self.partial_products[count-1]) < 0:
count -= 1
Expand Down Expand Up @@ -568,7 +568,7 @@ cdef class MultiModularBasis_base():
s = 1
mpz_init_set_si(z, b[0])
if b[0] == 0:
while s < len and b[s] == 0: # fast forward to first non-zero
while s < len and b[s] == 0: # fast forward to first non-zero
s += 1
else:
s = 0
Expand Down Expand Up @@ -619,10 +619,10 @@ cdef class MultiModularBasis_base():
if offset == 0:
mpz_set_si(z[j], b[0][j])
if b[0][j] == 0:
while i < len and b[i][j] == 0: # fast forward to first non-zero
while i < len and b[i][j] == 0: # fast forward to first non-zero
i += 1
while i < len:
mpz_set_si(u, ((b[i][j] + m[i] - mpz_fdiv_ui(z[j], m[i])) * self.C[i]) % m[i]) # u = ((b_i - z) * C_i) % m_i
mpz_set_si(u, ((b[i][j] + m[i] - mpz_fdiv_ui(z[j], m[i])) * self.C[i]) % m[i]) # u = ((b_i - z) * C_i) % m_i
mpz_mul(u, u, self.partial_products[i-1])
mpz_add(z[j], z[j], u)
i += 1
Expand Down Expand Up @@ -831,7 +831,7 @@ cdef class MultiModularBasis_base():
"""
if isinstance(ix, slice):
return self.__class__(self.list()[ix], l_bound = self._l_bound,
u_bound = self._u_bound)
u_bound = self._u_bound)

cdef Py_ssize_t i = ix
if i != ix:
Expand All @@ -850,7 +850,7 @@ cdef class MultiModularBasis_base():
sage: MultiModularBasis_base([10007])
MultiModularBasis with moduli [10007]
"""
return "MultiModularBasis with moduli "+str(self.list())
return "MultiModularBasis with moduli " + str(self.list())


cdef class MultiModularBasis(MultiModularBasis_base):
Expand Down
6 changes: 3 additions & 3 deletions src/sage/arith/numerical_approx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ r"""
Generic numerical approximation function
"""

#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2016 Jeroen Demeyer <jdemeyer@cage.ugent.be>
#
# 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/
#*****************************************************************************
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.structure.parent cimport Parent
from sage.structure.element cimport parent
Expand Down
6 changes: 3 additions & 3 deletions src/sage/arith/power.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ This implements powering of arbitrary objects using a
square-and-multiply algorithm.
"""

#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2017 Jeroen Demeyer <J.Demeyer@UGent.be>
#
# 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/
#*****************************************************************************
# https://www.gnu.org/licenses/
# ****************************************************************************

from cysignals.signals cimport sig_check

Expand Down
6 changes: 3 additions & 3 deletions src/sage/arith/rational_reconstruction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ AUTHORS:
- Jeroen Demeyer (2014-10-20): move this function from ``gmp.pxi``,
simplify and fix some bugs, see :trac:`17180`
"""
#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2006 ???
# Copyright (C) 2014 Jeroen Demeyer <jdemeyer@cage.ugent.be>
#
# 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/
#*****************************************************************************
# https://www.gnu.org/licenses/
# ****************************************************************************

from cysignals.signals cimport sig_on, sig_off

Expand Down
6 changes: 3 additions & 3 deletions src/sage/crypto/boolean_function.pxd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cdef inline unsigned int hamming_weight(unsigned int x):
# valid for 32bits
x -= (x>>1) & 0x55555555UL # 0-2 in 2 bits
x = ((x>>2) & 0x33333333UL) + (x & 0x33333333UL) # 0-4 in 4 bits
x = ((x>>4) + x) & 0x0f0f0f0fUL # 0-8 in 8 bits
x -= (x>>1) & 0x55555555UL # 0-2 in 2 bits
x = ((x>>2) & 0x33333333UL) + (x & 0x33333333UL) # 0-4 in 4 bits
x = ((x>>4) + x) & 0x0f0f0f0fUL # 0-8 in 8 bits
x *= 0x01010101UL
return x>>24

Expand Down
Loading