Skip to content

Commit

Permalink
updating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumgizmos committed Oct 23, 2024
1 parent ac01b79 commit ae2246c
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 17 deletions.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Welcome to LDPC's documentation!
ldpc/bp_decoder
ldpc/belief_find_decoder
ldpc/bposd_decoder
ldpc/bplsd_decoder
ldpc/union_find_decoder
ldpc/monte_carlo_simulation
ldpc/sinter_decoders.rst
Expand Down
8 changes: 0 additions & 8 deletions docs/source/ldpc/ldpc_decoder.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/ldpc/ldpc_mod2.rst

This file was deleted.

4 changes: 2 additions & 2 deletions docs/source/ldpc/mod2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Mod2 Linear Algebra
====================

.. automodule:: ldpc.mod2
:members: rank, kernel, pivot_rows
:members: rank, kernel, pivot_rows, row_complement_basis, row_basis, pivot_rows, estimate_code_distance, row_span, compute_exact_code_distance, row_echelon, reduced_row_echelon, inverse, PluDecomposition
:noindex:
:member-order: bysource
:member-order:
48 changes: 48 additions & 0 deletions src_python/ldpc/mod2/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,36 @@ def io_test(pcm: Union[scipy.sparse.spmatrix,np.ndarray]):


def estimate_code_distance(pcm: Union[scipy.sparse.spmatrix,np.ndarray], timeout_seconds: float = 0.025, number_of_words_to_save = 10):
"""
Estimate the code distance of a binary matrix representing a parity-check matrix.
This function estimates the minimum distance of a code defined by the given parity-check matrix (PCM).
The calculation runs until either the specified timeout is reached or an estimate is found.
Parameters
----------
pcm : Union[scipy.sparse.spmatrix, np.ndarray]
The parity-check matrix representing the code, provided as a scipy sparse matrix or a numpy ndarray.
timeout_seconds : float, optional (default=0.025)
The maximum time in seconds allowed for estimating the code distance.
number_of_words_to_save : int, optional (default=10)
The number of minimum-weight codewords to save in the returned matrix.
Returns
-------
min_distance : int
The estimated minimum distance of the code.
samples_searched : int
The number of samples that were searched to find the minimum distance.
min_weight_words_matrix : scipy.sparse.csr_matrix
A sparse matrix containing the minimum-weight codewords found, up to `number_of_words_to_save`.
"""


def row_span(pcm: Union[scipy.sparse.spmatrix,np.ndarray]) -> scipy.sparse.spmatrix:
"""
Compute the row span of a given parity check matrix.
Expand All @@ -113,6 +143,24 @@ def row_span(pcm: Union[scipy.sparse.spmatrix,np.ndarray]) -> scipy.sparse.spmat


def compute_exact_code_distance(pcm: Union[scipy.sparse.spmatrix,np.ndarray]):
"""
Compute the exact code distance of a binary matrix representing a parity-check matrix.
This function computes the exact minimum distance of a code defined by the given parity-check matrix (PCM).
Unlike the estimation function, this function guarantees the precise minimum distance, though it may be computationally intensive.
Parameters
----------
pcm : Union[scipy.sparse.spmatrix, np.ndarray]
The parity-check matrix representing the code, provided as a scipy sparse matrix or a numpy ndarray.
Returns
-------
distance : int
The exact minimum distance of the code.
"""


def row_basis(pcm: Union[scipy.sparse.spmatrix,np.ndarray]) -> scipy.sparse.spmatrix:
"""
Compute the row basis of a given parity check matrix.
Expand Down
46 changes: 46 additions & 0 deletions src_python/ldpc/mod2/_mod2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,35 @@ def io_test(pcm: Union[scipy.sparse.spmatrix,np.ndarray]):
return output
def estimate_code_distance(pcm: Union[scipy.sparse.spmatrix,np.ndarray], timeout_seconds: float = 0.025, number_of_words_to_save = 10):
"""
Estimate the code distance of a binary matrix representing a parity-check matrix.

This function estimates the minimum distance of a code defined by the given parity-check matrix (PCM).
The calculation runs until either the specified timeout is reached or an estimate is found.

Parameters
----------
pcm : Union[scipy.sparse.spmatrix, np.ndarray]
The parity-check matrix representing the code, provided as a scipy sparse matrix or a numpy ndarray.

timeout_seconds : float, optional (default=0.025)
The maximum time in seconds allowed for estimating the code distance.

number_of_words_to_save : int, optional (default=10)
The number of minimum-weight codewords to save in the returned matrix.

Returns
-------
min_distance : int
The estimated minimum distance of the code.

samples_searched : int
The number of samples that were searched to find the minimum distance.

min_weight_words_matrix : scipy.sparse.csr_matrix
A sparse matrix containing the minimum-weight codewords found, up to `number_of_words_to_save`.
"""
cdef int row_count = pcm.shape[0]
cdef int col_count = pcm.shape[1]
Expand Down Expand Up @@ -402,6 +431,23 @@ def row_span(pcm: Union[scipy.sparse.spmatrix,np.ndarray]) -> scipy.sparse.spmat
return csr_to_scipy_sparse(rs, int(2**row_count), col_count)
def compute_exact_code_distance(pcm: Union[scipy.sparse.spmatrix,np.ndarray]):
"""
Compute the exact code distance of a binary matrix representing a parity-check matrix.

This function computes the exact minimum distance of a code defined by the given parity-check matrix (PCM).
Unlike the estimation function, this function guarantees the precise minimum distance, though it may be computationally intensive.

Parameters
----------
pcm : Union[scipy.sparse.spmatrix, np.ndarray]
The parity-check matrix representing the code, provided as a scipy sparse matrix or a numpy ndarray.

Returns
-------
distance : int
The exact minimum distance of the code.
"""
cdef int row_count = pcm.shape[0]
cdef int col_count = pcm.shape[1]
Expand Down

0 comments on commit ae2246c

Please sign in to comment.