Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 19204
1
r"""
2
Classification of bent functions by their weight
3
================================================
4
5
The ``weight_class`` module defines the ``weight_class`` function,
6
which returns the weight class corresponding to a weight.
7
8
AUTHORS:
9
10
- Paul Leopardi (2016-09-25): initial version
11
12
EXAMPLES:
13
14
::
15
16
sage: from boolean_cayley_graphs.weight_class import weight_class
17
sage: weight_class(4,1)
18
0
19
sage: weight_class(16,10)
20
1
21
22
REFERENCES:
23
24
Leopardi [Leo2017]_ Section 2.2.
25
"""
26
#*****************************************************************************
27
# Copyright (C) 2016-2017 Paul Leopardi [email protected]
28
#
29
# Distributed under the terms of the GNU General Public License (GPL)
30
# as published by the Free Software Foundation; either version 2 of
31
# the License, or (at your option) any later version.
32
# http://www.gnu.org/licenses/
33
#*****************************************************************************
34
35
from sage.functions.other import sqrt
36
37
38
def weight_class(length, weight):
39
r"""
40
Return the weight class corresponding to a given length and weight.
41
42
The length is the length of the truth table of a Boolean function.
43
The weight is the Hamming weight of the Boolean function.
44
45
INPUT:
46
47
- ``length`` -- positive integer:
48
- ``weight`` -- positive integer: the given Hamming weight.
49
50
OUTPUT:
51
52
An integer representing the weight class corresponding to ``length`` and
53
``weight``.
54
55
EXAMPLES:
56
57
::
58
59
sage: from boolean_cayley_graphs.weight_class import weight_class
60
sage: weight_class(4,1)
61
0
62
sage: weight_class(16,10)
63
1
64
sage: weight_class(16,6)
65
0
66
sage: weight_class(64,36)
67
1
68
sage: weight_class(63,37)
69
1
70
sage: weight_class(65,35)
71
0
72
73
.. NOTE::
74
75
The weight class really only makes sense for bent functions, for which
76
the weight class is either 0 or 1 [Leo2017]_.
77
78
REFERENCES:
79
80
Leopardi [Leo2017]_ Section 2.2.
81
82
"""
83
sqrtlength = sqrt(length)
84
return int(((weight*2)/sqrtlength - sqrtlength + 1) / 2)
85
86