Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
22144 views
a

�Ul_�@sjdZddlZddlmmZddlmZddl	m
Z
ddlmZ
ddlmZdd�Zd	d
�Zdd�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

�N)�
LinearCode)�matrix)�FiniteField��innercsFd|}�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.

    �csg|]}�|�dkr|�qS)����.0�y)�fr	�M/home/user/Boolean-Cayley-graphs/boolean_cayley_graphs/boolean_linear_code.py�
<listcomp>Ns�z'boolean_linear_code.<locals>.<listcomp>csg|]��fdd��D��qS)csg|]}td�|��qS)rrr
��kr	rrRs�z2boolean_linear_code.<locals>.<listcomp>.<listcomp>r	)r)�supportrrrRs�
�)�ranger�GFr)�dimr
�v�Mr	)r
rr�boolean_linear_code#s*
��rcCs ttd�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)
        ]
    rcSsg|]}t|��qSr	)�list)r�sr	r	rrz�z.linear_code_from_code_gens.<locals>.<listcomp>)rrr)�gensrr	r	r�linear_code_from_code_gensYs!rcCs@tdt|���dt|���dt|���ddd�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))�__doc__�builtins�@py_builtins�_pytest.assertion.rewrite�	assertion�rewrite�
@pytest_ar�sage.coding.linear_coder�sage.matrix.constructorr�0sage.rings.finite_rings.finite_field_constructorrr�"boolean_cayley_graphs.integer_bitsrrrr)r	r	r	r�<module>s&6%