o
�Ul_ � @ sP d Z ddlmZ ddlmZ ddlmZ ddlm Z dd� Z
dd � Zd
d� ZdS )
a�
Boolean linear codes
====================
The ``boolean_linear_code`` module defines the functions:
* ``boolean_linear_code_graph``;
which returns the Boolean linear code corresponding to a Boolean function,
* ``linear_code_from_code_gens``;
which return the Boolean linear code corresponding to a list of generators; and
* ``print_latex_code_parameters``,
which prints the standard parameters of a linear code.
AUTHORS:
- Paul Leopardi (2016-10-28): initial version
� )�
LinearCode)�matrix)�FiniteField��innerc sF d| }� fdd�t |�D ��ttd��fdd�t | �D ��}t|�S )a�
Return the Boolean linear code corresponding to a Boolean function.
INPUT:
- ``dim`` -- positive integer. The assumed dimension of function ``f``.
- ``f`` -- a Python function that takes a positive integer and returns 0 or 1.
This is assumed to represent a Boolean function on :math:`\mathbb{F}_2^{dim}`
via lexicographical ordering.
OUTPUT:
An object of class ``LinearCode``, representing the Boolean linear code
corresponding to the Boolean function represented by ``f``.
EXAMPLES:
::
sage: from sage.crypto.boolean_function import BooleanFunction
sage: bf = BooleanFunction([0,1,0,0,0,1,0,0,1,0,0,0,0,0,1,1])
sage: dim = bf.nvariables()
sage: from boolean_cayley_graphs.boolean_linear_code import boolean_linear_code
sage: bc = boolean_linear_code(dim, bf)
sage: bc.characteristic_polynomial()
-2/3*x + 2
sage: bc.generator_matrix().echelon_form()
[1 0 0 0 1]
[0 1 0 0 0]
[0 0 1 0 0]
[0 0 0 1 1]
REFERENCES:
.. Carlet [Car2010]_.
.. Calderbank and Kantor [CalK1986]_.
.. Ding [Din2015]_ Corollary 10.
� c s g | ]
}� |�d kr|�qS )� � ��.0�y)�fr �M/home/user/Boolean-Cayley-graphs/boolean_cayley_graphs/boolean_linear_code.py�
<listcomp>N s
��z'boolean_linear_code.<locals>.<listcomp>c s g | ]� � fd d��D ��qS )c s g | ] }t d � |��qS )r r r
��kr r r R s ��z2boolean_linear_code.<locals>.<listcomp>.<listcomp>r )r )�supportr r r R s
�
�)�ranger �GFr )�dimr
�v�Mr )r
r r �boolean_linear_code# s *
��r c C s t td�dd� | D ��}t|�S )a
Return the Boolean linear code corresponding to a list of generators.
INPUT:
- ``gens`` -- list. A list of strings of 0,1 characters.
This is assumed to represent the generators of a linear code.
OUTPUT:
An object of class ``LinearCode`` representing the Boolean linear code
corresponding to the generators represented by ``gens``.
EXAMPLE:
::
sage: from boolean_cayley_graphs.boolean_linear_code import linear_code_from_code_gens
sage: gens = (
....: "10001",
....: "01000",
....: "00100",
....: "00011")
sage: c = linear_code_from_code_gens(gens)
sage: c.basis()
[
(1, 0, 0, 0, 1),
(0, 1, 0, 0, 0),
(0, 0, 1, 0, 0),
(0, 0, 0, 1, 1)
]
r c S s g | ]}t |��qS r )�list)r �sr r r r z s z.linear_code_from_code_gens.<locals>.<listcomp>)r r r )�gensr r r r �linear_code_from_code_gensY s !r c C s@ t dt| �� � d t| �� � d t| �� � d dd� dS )ax
Print the standard parameters of a linear code.
INPUT:
- ``c`` -- ``LinearCode``.
OUTPUT:
A string representing the standard parameters of the linear code ``c``.
EXAMPLE:
::
sage: from boolean_cayley_graphs.boolean_linear_code import linear_code_from_code_gens
sage: from boolean_cayley_graphs.boolean_linear_code import print_latex_code_parameters
sage: gens = (
....: "10001",
....: "01000",
....: "00100",
....: "00011")
sage: c = linear_code_from_code_gens(gens)
sage: print_latex_code_parameters(c)
[5,4,1]
�[�,�]� )�endN)�print�str�length� dimension�minimum_distance)�cr r r �print_latex_code_parameters~ s �
��
��
�r( N)
�__doc__�sage.coding.linear_coder �sage.matrix.constructorr �0sage.rings.finite_rings.finite_field_constructorr r �"boolean_cayley_graphs.integer_bitsr r r r( r r r r �<module> s 6%