### Manual Installation: Install fplll Source: https://fpylll.readthedocs.io/en/latest/index This command installs the fplll library within the activated virtual environment. It assumes the necessary system libraries are already installed. ```bash (fpylll)$VIRTUAL_ENV ``` -------------------------------- ### Automatic Installation Bootstrap Source: https://fpylll.readthedocs.io/en/latest/index This snippet demonstrates the initial step for an automatic installation process by sourcing a bootstrap script. ```bash source ``` -------------------------------- ### SageMath Manual Update: Install fplll Source: https://fpylll.readthedocs.io/en/latest/index This command installs the fplll library within the SageMath virtual environment. It assumes the necessary system libraries are already installed and uses SAGE_LOCAL for paths. ```bash (sage-sh)$SAGE_LOCAL ``` -------------------------------- ### Manual Installation: Install Optional Python Packages Source: https://fpylll.readthedocs.io/en/latest/index This command installs optional Python packages that enhance fpylll's functionality. ```bash (fpylll) ``` -------------------------------- ### Manual Installation: Activate Virtual Environment Source: https://fpylll.readthedocs.io/en/latest/index This command activates a Python virtual environment, typically named 'fpylll', for manual installation. ```bash source ``` -------------------------------- ### SageMath Manual Update: Verify Installation Source: https://fpylll.readthedocs.io/en/latest/index This Python code snippet verifies the fpylll installation by printing its version number. ```python import fpylll print(fpylll.__version__) ``` -------------------------------- ### Manual Installation: Install Required Python Packages Source: https://fpylll.readthedocs.io/en/latest/index This command installs the core Python dependencies required for fpylll. ```bash (fpylll) ``` -------------------------------- ### SageMath Manual Update: Install Optional Python Packages Source: https://fpylll.readthedocs.io/en/latest/index This command installs optional Python packages for fpylll within the SageMath environment. ```bash (sage-sh) ``` -------------------------------- ### Running fpylll: Start Python Interpreter Source: https://fpylll.readthedocs.io/en/latest/index This command starts the Python interpreter within the activated virtual environment, allowing you to use fpylll. ```bash (fpylll) ``` -------------------------------- ### SageMath Manual Update: Install Python Packages Source: https://fpylll.readthedocs.io/en/latest/index This command installs the core Python dependencies for fpylll within the SageMath environment. ```bash (sage-sh) ``` -------------------------------- ### IntegerMatrix from_file Example Source: https://fpylll.readthedocs.io/en/latest/modules Demonstrates how to create an IntegerMatrix by reading its string representation from a file. This involves generating a matrix, writing it to a temporary file, and then loading it back. ```python import tempfile from fpylll import IntegerMatrix A = IntegerMatrix.random(10, "qary", k=5, bits=20) fn = tempfile.mktemp() with open(fn, "w") as fh: fh.write(str(A)) B = IntegerMatrix.from_file(fn) print(A == B) ``` -------------------------------- ### Enumeration Example Source: https://fpylll.readthedocs.io/en/latest/modules Demonstrates how to use the Enumeration class to find solutions in a lattice. This example sets up a lattice, performs LLL reduction, and then uses the Enumeration class with specific parameters to find short vectors. ```python from fpylll import * FPLLL.set_random_seed(1337) _ = FPLLL.set_threads(1) A = IntegerMatrix.random(80, "qary", bits=30, k=40) _ = LLL.reduction(A) M = GSO.Mat(A) _ = M.update_gso() pruning = Pruning.run(M.get_r(0, 0), 2**40, M.r()[:30], 0.8) enum = Enumeration(M, strategy=EvaluatorStrategy.BEST_N_SOLUTIONS, sub_solutions=True) _ = enum.enumerate(0, 30, 0.999*M.get_r(0, 0), 0, pruning=pruning.coefficients) [int(round(a)) for a,b in enum.sub_solutions[:5]] ``` -------------------------------- ### IntegerMatrix Constructor Examples Source: https://fpylll.readthedocs.io/en/latest/modules Illustrates different ways to construct an IntegerMatrix, including specifying dimensions, using a copy constructor, and handling invalid dimensions. ```python from fpylll import IntegerMatrix # Default constructor with dimensions print(IntegerMatrix(10, 10)) print(IntegerMatrix(10, 0)) # Example of invalid dimension try: IntegerMatrix(-1, 0) except ValueError as e: print(e) # Copy constructor A = IntegerMatrix(2, 2) A[0,0] = 1 B = IntegerMatrix(A) print(B[0,0]) A[0,0] = 2 print(B[0,0]) ``` -------------------------------- ### Manual Installation: Build Python Extension Source: https://fpylll.readthedocs.io/en/latest/index This command builds the Python extension for fpylll, linking it with the installed fplll library. It includes setting PKG_CONFIG_PATH to locate the necessary pkg-config files. ```bash (fpylll)exportPKG_CONFIG_PATH="$VIRTUAL_ENV/lib/pkgconfig:$PKG_CONFIG_PATH" $(fpylll)(fpylll) ``` -------------------------------- ### Get Precision Example Source: https://fpylll.readthedocs.io/en/latest/modules Demonstrates how to get the precision for different floating-point types using FPLLL. ```python import fpylll from fpylll import FPLLL print(FPLLL.get_precision('double')) if fpylll.config.have_long_double: print(FPLLL.get_precision('long double') > 53) else: print(True) print(FPLLL.get_precision('dpe')) _ = FPLLL.set_precision(212) print(FPLLL.get_precision('mpfr')) print(FPLLL.get_precision()) _ = FPLLL.set_precision(53) ``` -------------------------------- ### fpylll Basic Usage Example Source: https://fpylll.readthedocs.io/en/latest/index Demonstrates the basic usage of fpylll for matrix operations, including randomization, GSO updates, and LLL reduction. It shows how to create an IntegerMatrix, randomize it, perform GSO calculations, and apply LLL reduction to obtain a reduced basis. ```python >>> fromfpylllimport * >>> A = IntegerMatrix(50, 50) >>> A.randomize("ntrulike", bits=50, q=127) >>> A[0].norm() 3564748886669202.5 >>> M = GSO.Mat(A) >>> M.update_gso() >>> M.get_mu(1,0) 0.815748944429783 >>> L = LLL.Reduction(M) >>> L() >>> M.get_mu(1,0) 0.41812865497076024 >>> A[0].norm() 24.06241883103193 ``` -------------------------------- ### IntegerMatrix from_iterable Example Source: https://fpylll.readthedocs.io/en/latest/modules Illustrates creating an IntegerMatrix from an iterable (like a list) by specifying the number of rows and columns. ```python from fpylll import IntegerMatrix A = IntegerMatrix.from_iterable(2, 3, [1, 2, 3, 4, 5, 6]) print(A) ``` -------------------------------- ### Manual Installation: Set LD_LIBRARY_PATH Source: https://fpylll.readthedocs.io/en/latest/index This command sets the LD_LIBRARY_PATH environment variable so that Python can find the fpylll shared libraries. It's crucial for runtime loading. ```bash (fpylll)exportLD_LIBRARY_PATH="$VIRTUAL_ENV/lib" ``` -------------------------------- ### IntegerMatrix Type Enforcement Example Source: https://fpylll.readthedocs.io/en/latest/modules Demonstrates the type enforcement for IntegerMatrix when initializing GSO.Mat, ensuring that U.int_type matches B.int_type. ```python fromfpylllimport IntegerMatrix, LLL, GSO B = IntegerMatrix.random(5, 'uniform', bits = 8, int_type = "long") M = GSO.Mat(B, U = IntegerMatrix.identity(B.nrows)) # TypeError: U.int_type != B.int_type B = IntegerMatrix.random(5, 'uniform', bits=8, int_type="long") M = GSO.Mat(B, U = IntegerMatrix.identity(B.nrows, int_type="long")) ``` -------------------------------- ### MatGSO Methods Source: https://fpylll.readthedocs.io/en/latest/modules Provides documentation for various methods within the MatGSO class, including their purpose, parameters, and return values. This covers operations like getting root determinants, slide potentials, and manipulating rows. ```APIDOC get_root_det(_self_, start_row: int, stop_row: int) Return (squared) root determinant of the basis. Parameters: start_row (int): start row (inclusive) stop_row (int): stop row (exclusive) ``` ```APIDOC get_slide_potential(_self_, start_row: int, stop_row: int, block_size: int) Return slide potential of the basis Parameters: start_row (int): start row (inclusive) stop_row (int): stop row (exclusive) block_size (int): block size ``` ```APIDOC move_row(_self_, old_r: int, new_r: int) Row `old_r` becomes row `new_r` and intermediate rows are shifted. If `new_r < old_r`, then `old_r` must be `< n_known_rows`. Parameters: old_r (int): row index new_r (int): row index ``` ```APIDOC negate_row(_self_, i: int) Set b_i to -b_i. Parameters: i (int): index of the row to negate ``` ```APIDOC r(_self_, start: int = 0, end: int = -1) Return `r` vector from `start` to `end` ``` ```APIDOC remove_last_row(_self_) Remove. the last row of `B` (and of `U` if `enable_transform=true`). Do not use if `inverse_transform_enabled=true`. ``` ```APIDOC row_addmul(_self_, i: int, j: int, x) Set b_i = b_i + x ⋅ b_j. After one or several calls to `row_addmul`, `row_op_end` must be called. If `row_op_force_long=true`, `x` is always converted to (`2^expo * long`) instead of (`2^expo * ZT`), which is faster if `ZT=mpz_t` but might lead to a loss of precision in LLL, more Babai iterations are needed. Parameters: i (int): target row j (int): source row x: multiplier ``` ```APIDOC row_op_begin(_self_, first: int, last: int) Must be called before a sequence of `row_addmul`. Parameters: first (int): start index for `row_addmul` operations. last (int): final index (exclusive). Note: It is preferable to use `MatGSORowOpContext` via `row_ops`. ``` ```APIDOC row_op_end(_self_, first: int, last: int) ``` -------------------------------- ### Multiprocessing Example for LLL Reduction Source: https://fpylll.readthedocs.io/en/latest/index This snippet demonstrates how to use Python's multiprocessing module to parallelize the LLL.reduction operation across multiple worker processes. It includes a helper function to display progress during execution. The code generates random integer matrices and applies the LLL reduction algorithm in parallel. ```python from fpylll import IntegerMatrix, LLL from multiprocessing import Pool d, workers, tasks = 30, 4, 128 def run_it(p, f, A, prefix=""): """Print status during parallel execution.""" import sys r = [] for i, retval in enumerate(p.imap_unordered(f, A, 1)): r.append(retval) sys.stderr.write('\r{0} done: {1:.2%}'.format(prefix, float(i)/len(A))) sys.stderr.flush() sys.stderr.write('\r{0} done {1:.2%}\n'.format(prefix, float(i+1)/len(A))) return r A = [IntegerMatrix.random(d, "uniform", bits=30) for _ in range(tasks)] A = run_it(Pool(workers), LLL.reduction, A) ``` -------------------------------- ### FPLLL Utility Functions Source: https://fpylll.readthedocs.io/en/latest/modules Provides utility functions for the FPLLL library, including setting and getting precision, random seed, and thread count. Also includes functions for vector norms and error handling. ```APIDOC FPLLL.set_precision(precision: int) Sets the precision for FPLLL operations. FPLLL.set_random_seed(seed: int) Sets the random seed for FPLLL. FPLLL.set_threads(num_threads: int) Sets the number of threads for FPLLL. FPLLL.threads() Returns the current number of threads used by FPLLL. ReductionError Custom exception for reduction errors. adjust_radius_to_gh_bound(radius: float, lattice: Lattice) Adjusts the radius to the Gaussian heuristic bound. ball_log_vol(radius: float, dimension: int) Computes the logarithm of the volume of a ball. external_enumerator() Returns the currently set external enumerator. gausssian_heuristic(lattice: Lattice) Computes the Gaussian heuristic for a lattice. get_precision() Returns the current precision. get_threads() Returns the current number of threads. precision() Returns the current precision. rrandint(low: int, high: int) Generates a random integer within a range. set_external_enumerator(enumerator: Callable) Sets an external enumerator function. set_precision(precision: int) Sets the precision for FPLLL operations. set_random_seed(seed: int) Sets the random seed for FPLLL. set_threads(num_threads: int) Sets the number of threads for FPLLL. threads() Returns the current number of threads. vector_norm(vector: Vector) Computes the Euclidean norm of a vector. ``` -------------------------------- ### fpylll.fplll.wrapper.Wrapper Methods Source: https://fpylll.readthedocs.io/en/latest/genindex Documentation for the __call__ and __init__ methods of the Wrapper class in fpylll.fplll.wrapper, likely for general wrapper functionalities. ```APIDOC fpylll.fplll.wrapper.Wrapper: __call__(...) - Executes the wrapper functionality. __init__(...) - Initializes the wrapper. ``` -------------------------------- ### IntegerMatrix Initialization and Element Access Source: https://fpylll.readthedocs.io/en/latest/modules Demonstrates creating an IntegerMatrix, setting it to an identity matrix, and accessing individual elements or rows. Shows basic usage of __init__, gen_identity, and __getitem__. ```python from fpylll import IntegerMatrix A = IntegerMatrix(10, 10) A.gen_identity(10) print(A[1,0]) print(A[1]) print(A[0:2]) ``` -------------------------------- ### fpylll.fplll.lll.LLL.Wrapper Methods Source: https://fpylll.readthedocs.io/en/latest/genindex Documentation for the __call__ and __init__ methods of the LLL.Wrapper class within the fpylll.fplll.lll module. These methods are related to the LLL algorithm's wrapper functionality. ```APIDOC fpylll.fplll.lll.LLL.Wrapper: __call__() - Wrapper for the LLL algorithm. __init__(...) - Initializes the LLL wrapper. ``` -------------------------------- ### LLL.Wrapper Constructor and Methods Source: https://fpylll.readthedocs.io/en/latest/modules Details the constructor and key methods of the `LLL.Wrapper` class. The constructor takes an `IntegerMatrix`, `delta`, `eta`, and `flags`. The `__call__` method executes the LLL reduction. ```APIDOC LLL.Wrapper: __init__(B, delta=LLL_DEF_DELTA, eta=LLL_DEF_ETA, flags=LLL_DEFAULT) Initializes the LLL wrapper. Parameters: B (IntegerMatrix): The input integer matrix. delta (double): The LLL reduction parameter delta (default: LLL_DEF_DELTA). eta (double): The LLL reduction parameter eta (default: LLL_DEF_ETA). flags (int): Flags for the reduction process (default: LLL_DEFAULT). __call__(): Runs the LLL reduction on the matrix B. Returns: The result of the LLL reduction. B: Attribute representing the input matrix. U: Attribute representing the transformation matrix. UinvT: Attribute representing the inverse transpose of the transformation matrix. status: Attribute indicating the status of the reduction. ``` -------------------------------- ### Get Thread Count Source: https://fpylll.readthedocs.io/en/latest/modules Retrieves the current number of threads being used by the library. ```python fpylll.util.get_threads() ``` -------------------------------- ### IntegerMatrix.set_matrix() - Python Source: https://fpylll.readthedocs.io/en/latest/modules Sets the matrix from a matrix-like object. Entries starting from A[nrows, ncols] are ignored. ```python >>> z = [[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]] >>> A = IntegerMatrix(4, 4) >>> A.set_matrix(z) >>> print(A) [ 1 2 3 4 ] [ 5 6 7 8 ] [ 9 10 11 12 ] [ 13 14 15 16 ] >>> A = IntegerMatrix(3, 3) >>> A.set_matrix(z) >>> print(A) [ 1 2 3 ] [ 5 6 7 ] [ 9 10 11 ] ``` -------------------------------- ### Running fpylll: Activate Virtual Environment Source: https://fpylll.readthedocs.io/en/latest/index This command reactivates the virtual environment before running fpylll. ```bash source ``` -------------------------------- ### Set External Enumerator Example Source: https://fpylll.readthedocs.io/en/latest/modules Illustrates how to set an external enumeration library using `ctypes`. ```python from fpylll import * import ctypes enumlib = ctypes.cdll.LoadLibrary("enumlib.so") enumlib._Z20enumlib_set_logleveli(1) fn = enumlib._Z17enumlib_enumerateidSt8functionIFvPdmbS0_S0_EES_IFddS0_EES_IFvdS0_iEEbb FPLLL.set_external_enumerator(fn) FPLLL.set_external_enumerator(None) ``` -------------------------------- ### IntegerMatrixRow is_zero Method Source: https://fpylll.readthedocs.io/en/latest/modules Checks if the row vector consists entirely of zeros from a specified starting index. ```python is_zero(_self_ , _int frm=0_) Return `True` if this vector consists of only zeros starting at index `frm` Example: >>> A = IntegerMatrix.from_matrix([[1,0,0]]) >>> A[0].is_zero() False >>> A[0].is_zero(1) True ``` -------------------------------- ### fpylll.fplll.gso.MatGSORowOpContext Methods Source: https://fpylll.readthedocs.io/en/latest/genindex Documentation for the __init__ method of the MatGSORowOpContext class in fpylll.fplll.gso, likely related to context management for row operations in GSO. ```APIDOC fpylll.fplll.gso.MatGSORowOpContext: __init__(...) - Initializes the context for row operations in MatGSO. ``` -------------------------------- ### IntegerMatrix.multiply_left Source: https://fpylll.readthedocs.io/en/latest/modules Performs a left multiplication of a vector v with the transpose of a sub-matrix of A. The sub-matrix is determined by the number of elements in v and the start row. ```python >>> # Example usage would require defining v and IntegerMatrix A ``` -------------------------------- ### Negate Row Example Source: https://fpylll.readthedocs.io/en/latest/modules Demonstrates how to negate a specific row in a matrix using the `negate_row` method within a row operation context. ```python from fpylll import * FPLLL.set_random_seed(42) A = IntegerMatrix(6, 6) A.randomize("ntrulike", bits=6, q=31) print(A) M = GSO.Mat(A) M.update_gso() with M.row_ops(2,2): M.negate_row(2) print(A) ``` -------------------------------- ### IntegerMatrix API Documentation Source: https://fpylll.readthedocs.io/en/latest/modules Comprehensive API documentation for the IntegerMatrix class, including constructors, element access, matrix transformations, file I/O, and matrix generation utilities. ```APIDOC IntegerMatrix: __init__(self, dim=None, T=None, V=None, m=None, n=None, file=None, int_type=None) Initializes an IntegerMatrix. Parameters: dim (int, optional): The dimension of the square matrix. T (list of lists, optional): A list of lists representing the matrix. V (list of lists, optional): Another representation for the matrix. m (int, optional): Number of rows. n (int, optional): Number of columns. file (str, optional): Path to a file to load the matrix from. int_type (str, optional): The integer type to use. __copy__(self) Returns a copy of the IntegerMatrix. __getitem__(self, key) Retrieves an element or a submatrix. Parameters: key (int or tuple): Index or slice for element/submatrix access. __setitem__(self, key, value) Sets an element or a submatrix. Parameters: key (int or tuple): Index or slice for element/submatrix assignment. value (int or list of lists): The value to assign. apply_transform(self, T) Applies a linear transformation to the matrix. Parameters: T (IntegerMatrix): The transformation matrix. clear(self) Clears the matrix, setting all elements to zero. from_file(cls, file, int_type=None) Creates an IntegerMatrix from a file. Parameters: file (str): Path to the matrix file. int_type (str, optional): The integer type to use. Returns: IntegerMatrix from_iterable(cls, iterable, int_type=None) Creates an IntegerMatrix from an iterable. Parameters: iterable (iterable): An iterable of iterables representing the matrix. int_type (str, optional): The integer type to use. Returns: IntegerMatrix from_matrix(cls, matrix, int_type=None) Creates an IntegerMatrix from another matrix-like object. Parameters: matrix (list of lists or similar): The source matrix. int_type (str, optional): The integer type to use. Returns: IntegerMatrix gen_identity(cls, dim, int_type=None) Generates an identity matrix. Parameters: dim (int): The dimension of the identity matrix. int_type (str, optional): The integer type to use. Returns: IntegerMatrix get_max_exp(self) Returns the maximum exponent of the matrix elements. identity(cls, dim, int_type=None) Generates an identity matrix (alias for gen_identity). Parameters: dim (int): The dimension of the identity matrix. int_type (str, optional): The integer type to use. Returns: IntegerMatrix int_type(self) Returns the integer type of the matrix. is_empty(self) Checks if the matrix is empty. Returns: bool mod(self, modulus) Applies a modulus operation to the matrix elements. Parameters: modulus (int): The modulus value. multiply_left(self, T) Multiplies the matrix by another matrix on the left. Parameters: T (IntegerMatrix): The matrix to multiply by. ncols(self) Returns the number of columns. nrows(self) Returns the number of rows. random(cls, nrows, ncols, int_type=None) Generates a random matrix. Parameters: nrows (int): Number of rows. ncols (int): Number of columns. int_type (str, optional): The integer type to use. Returns: IntegerMatrix randomize(self, T) Randomizes the matrix elements based on a transformation matrix. Parameters: T (IntegerMatrix): The transformation matrix. resize(self, nrows, ncols) Resizes the matrix. Parameters: nrows (int): New number of rows. ncols (int): New number of columns. rotate(self, k) Rotates the matrix columns. Parameters: k (int): The number of positions to rotate. rotate_gram_left(self, k) Performs a Gram-Schmidt rotation to the left. Parameters: k (int): The rotation parameter. rotate_gram_right(self, k) Performs a Gram-Schmidt rotation to the right. Parameters: k (int): The rotation parameter. rotate_left(self, k) Rotates the matrix columns to the left. Parameters: k (int): The number of positions to rotate. rotate_right(self, k) Rotates the matrix columns to the right. Parameters: k (int): The number of positions to rotate. set_cols(self, cols) Sets the columns of the matrix. Parameters: cols (list of lists): The columns to set. set_iterable(self, iterable) Sets the matrix elements from an iterable. Parameters: iterable (iterable): An iterable of iterables representing the matrix. set_matrix(self, matrix) Sets the matrix elements from another matrix-like object. Parameters: matrix (list of lists or similar): The source matrix. set_rows(self, rows) Sets the rows of the matrix. Parameters: rows (list of lists): The rows to set. submatrix(self, r1, c1, r2, c2) Extracts a submatrix. Parameters: r1 (int): Starting row index. c1 (int): Starting column index. r2 (int): Ending row index. c2 (int): Ending column index. Returns: IntegerMatrix ``` -------------------------------- ### fpylll.fplll.integer_matrix.IntegerMatrix Methods Source: https://fpylll.readthedocs.io/en/latest/genindex Documentation for methods related to the IntegerMatrix class in fpylll.fplll.integer_matrix, including __copy__, __getitem__, __init__, and __setitem__. These methods handle matrix operations and access. ```APIDOC fpylll.fplll.integer_matrix.IntegerMatrix: __copy__() - Returns a copy of the IntegerMatrix. __getitem__(index) - Accesses elements or rows of the matrix. __init__(...) - Initializes an IntegerMatrix. __setitem__(index, value) - Sets elements or rows of the matrix. ``` -------------------------------- ### IntegerMatrix Methods Source: https://fpylll.readthedocs.io/en/latest/genindex Provides documentation for various methods of the IntegerMatrix class in fpylll, including setting dimensions, submatrix operations, and transformations. ```APIDOC IntegerMatrix.set_cols(self, cols) Sets the number of columns for the integer matrix. IntegerMatrix.set_iterable(self, iterable) Sets the matrix from an iterable object. IntegerMatrix.set_matrix(self, matrix) Sets the matrix data from a given matrix. IntegerMatrix.set_rows(self, rows) Sets the number of rows for the integer matrix. IntegerMatrix.submatrix(self, i, j, rows, cols) Extracts a submatrix from the current matrix. IntegerMatrix.swap_rows(self, i, j) Swaps two rows in the integer matrix. IntegerMatrix.to_matrix(self) Converts the IntegerMatrix object to a standard matrix representation. ``` -------------------------------- ### Set External Enumerator Source: https://fpylll.readthedocs.io/en/latest/modules Sets an external enumeration library. This function takes a CTypes handle to the enumerator. To disable, set to None. Includes an example of loading and setting an external library. ```python fpylll.util.set_external_enumerator(_enumerator_) ``` -------------------------------- ### fpylll.fplll.lll.LLLReduction Methods Source: https://fpylll.readthedocs.io/en/latest/genindex Documentation for the __call__ and __init__ methods of the LLLReduction class in fpylll.fplll.lll, pertaining to the LLL reduction algorithm. ```APIDOC fpylll.fplll.lll.LLLReduction: __call__(...) - Executes the LLL reduction. __init__(...) - Initializes the LLL reduction process. ``` -------------------------------- ### fpylll.algorithms.simple_dbkz Module Source: https://fpylll.readthedocs.io/en/latest/_sources/modules Provides a Python implementation of the Simple Dual BKZ algorithm. Supports initialization, calling, and finding members. ```python import fpylll.algorithms.simple_dbkz # Example usage (assuming methods are available): # simple_dbkz = fpylll.algorithms.simple_dbkz.SimpleDualBKZ() # reduced_basis = simple_dbkz(basis, block_size) ``` -------------------------------- ### LLL Wrapper Class Source: https://fpylll.readthedocs.io/en/latest/modules Illustrates the usage of the `LLL.Wrapper` class for performing LLL reduction. It shows how to initialize the wrapper with an integer matrix and then call the wrapper instance to execute the reduction. ```python from fpylll import LLL, IntegerMatrix A = IntegerMatrix(50, 50) A.randomize("ntrulike", bits=100, q=1023) W = LLL.Wrapper(A) W() # Accessing properties after reduction # print(W.B) # print(W.U) # print(W.UinvT) # print(W.status) ``` -------------------------------- ### Get Precision Settings Source: https://fpylll.readthedocs.io/en/latest/modules Retrieves the currently set precision for different floating-point types. Supports 'double', 'long double', 'dpe', 'dd', 'qd', and 'mpfr'. For MPFR, it can also retrieve the globally set precision. ```python fpylll.util.get_precision(_float_type ='mpfr'_) ``` -------------------------------- ### IntegerMatrix API Source: https://fpylll.readthedocs.io/en/latest/modules Documentation for the IntegerMatrix class methods, including construction, manipulation, and property access. ```APIDOC IntegerMatrix: __init__(nrows, ncols, int_type='mpz') Constructs an integer matrix of size nrows x ncols. Parameters: nrows (int): Number of rows. ncols (int): Number of columns. int_type (str): Underlying integer type (e.g., 'mpz'). from_matrix(A, nrows=None, ncols=None) Constructs an integer matrix from a matrix-like object A. Parameters: A: Matrix-like object with element access A[i,j] or A[i][j]. nrows (int, optional): Number of rows. ncols (int, optional): Number of columns. Returns: IntegerMatrix: The constructed matrix. gen_identity(nrows=-1) Generates an identity matrix. Parameters: nrows (int): Number of rows for the identity matrix. get_max_exp() Returns the maximum exponent of the elements in the matrix. Returns: int: The maximum exponent. identity(cls, nrows, int_type='mpz') Constructs a new identity matrix of dimension nrows x nrows. Parameters: nrows (int): The dimension of the identity matrix. int_type (str): Underlying integer type. Returns: IntegerMatrix: The identity matrix. int_type Property to get or set the integer type of the matrix. is_empty() Checks if the matrix is empty. Returns: bool: True if the matrix is empty, False otherwise. mod(q, start_row=0, start_col=0, stop_row=-1, stop_col=-1) Applies modular reduction modulo q to the matrix or a sub-region. Parameters: q: The modulus. start_row (int): Starting row index. start_col (int): Starting column index. stop_row (int): Stopping row index (exclusive). stop_col (int): Stopping column index (exclusive). multiply_left(v, start=0) Returns v*A' where A' is A reduced to len(v) rows starting at 'start'. Parameters: v: A tuple-like object. start (int): The starting row index. Returns: The result of the multiplication. ncols Property to get the number of columns. Returns: int: The number of columns. nrows Property to get the number of rows. Returns: int: The number of rows. random(cls, d, algorithm, int_type='mpz', **kwds) Constructs a new random matrix. Parameters: d: Dominant size parameter. algorithm (str): Type of matrix creation (e.g., 'intrel', 'simdioph'). int_type (str): Underlying integer type. **kwds: Additional keyword arguments like 'bits', 'bits2'. Returns: IntegerMatrix: A random lattice basis. ``` -------------------------------- ### SageMath Manual Update: Build Python Extension Source: https://fpylll.readthedocs.io/en/latest/index This command builds the Python extension for fpylll within SageMath, setting PKG_CONFIG_PATH to include SageMath's pkgconfig directory. ```bash (sage-sh)exportPKG_CONFIG_PATH="$SAGE_LOCAL/lib/pkgconfig:$PKG_CONFIG_PATH" $(sage-sh)(sage-sh)(sage-sh)exit ``` -------------------------------- ### Linting with flake8 Source: https://fpylll.readthedocs.io/en/latest/index This command runs flake8, a Python linter, to check for style guide violations and potential errors in the codebase. It's part of the automated checks performed on every commit to maintain code quality. ```bash flake8 ``` -------------------------------- ### fpylll.fplll.wrapper Module Source: https://fpylll.readthedocs.io/en/latest/_sources/modules Acts as a wrapper for the LLL (Lenstra–Lenstra–Lovász) algorithm, a key algorithm in lattice reduction. It supports initialization, calling, and copying. ```python import fpylll.fplll.wrapper # Example usage (assuming methods are available): # lll_wrapper = fpylll.fplll.wrapper.LLLWrapper() # reduced_basis = lll_wrapper(basis) ``` -------------------------------- ### Virtual Environment Activation Script Snippet Source: https://fpylll.readthedocs.io/en/latest/index This snippet shows how to modify the virtual environment's activate script to automatically set LD_LIBRARY_PATH and PKG_CONFIG_PATH. ```bash ### LD_LIBRARY_HACK _OLD_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" LD_LIBRARY_PATH="$VIRTUAL_ENV/lib:$LD_LIBRARY_PATH" export### END_LD_LIBRARY_HACK ### PKG_CONFIG_HACK _OLD_PKG_CONFIG_PATH="$PKG_CONFIG_PATH" PKG_CONFIG_PATH="$VIRTUAL_ENV/lib/pkgconfig:$PKG_CONFIG_PATH" export### END_PKG_CONFIG_HACK ``` -------------------------------- ### fpylll.fplll.lll Module Source: https://fpylll.readthedocs.io/en/latest/_sources/modules Contains the core implementation of the LLL algorithm. This module allows for initialization, calling, and copying of LLL operations. ```python import fpylll.fplll.lll # Example usage (assuming methods are available): # lll_instance = fpylll.fplll.lll.LLL() # reduced_basis = lll_instance(basis) ``` -------------------------------- ### fpylll.algorithms.bkz Module Source: https://fpylll.readthedocs.io/en/latest/_sources/modules Contains a Python implementation of the BKZ algorithm. This module supports initialization, calling, and finding members. ```python import fpylll.algorithms.bkz # Example usage (assuming methods are available): # bkz_algo = fpylll.algorithms.bkz.BKZ() # reduced_basis = bkz_algo(basis, block_size) ``` -------------------------------- ### IntegerMatrix API Documentation Source: https://fpylll.readthedocs.io/en/latest/modules API documentation for the IntegerMatrix class, detailing its methods for matrix manipulation. ```APIDOC class fpylll.fplll.integer_matrix.IntegerMatrix: set_matrix(A): Sets this matrix from matrix-like object A. Parameters: A: a matrix like object, with element access A[i,j] or A[i][j] Warning: entries starting from A[nrows, ncols] are ignored. set_rows(rows): Parameters: rows: int submatrix(a, b, c=None, d=None): Construct a new submatrix. Parameters: a: either the index of the first row or an iterable of row indices b: either the index of the first column or an iterable of column indices c: the index of first excluded row (or None) d: the index of first excluded column (or None) Returns: A new IntegerMatrix representing the submatrix. swap_rows(r1, r2): Swaps rows r1 and r2 in-place. Parameters: r1: int, index of the first row r2: int, index of the second row to_matrix(A): Write this matrix to matrix-like object A. Parameters: A: a matrix like object, with element access A[i,j] or A[i][j] Returns: A transpose(): Inline transpose. class fpylll.fplll.integer_matrix.IntegerMatrixRow: __getitem__(column): Return entry at column. Parameters: column: int, integer offset Returns: The element at the specified column. __init__(M, row): Create a row reference. Parameters: M: IntegerMatrix, the matrix containing the row row: int, the index of the row ``` -------------------------------- ### IntegerMatrix Class Documentation Source: https://fpylll.readthedocs.io/en/latest/genindex Provides documentation for the IntegerMatrix class in fpylll. Includes methods for creating identity matrices, checking if a matrix is empty, and performing matrix operations. ```APIDOC IntegerMatrix: identity() Creates an identity matrix. is_empty() Checks if the matrix is empty. multiply_left(other_matrix) Performs a left matrix multiplication. Parameters: other_matrix: The matrix to multiply with. mod(value) Applies a modulo operation to the matrix elements. ``` -------------------------------- ### Module Documentation Source: https://fpylll.readthedocs.io/en/latest/genindex References to various modules within the fpylll library, including enumeration, gso, integer_matrix, lll, and util. ```APIDOC Modules: fpylll.fplll.enumeration fpylll.fplll.gso fpylll.fplll.integer_matrix fpylll.fplll.lll fpylll.fplll.wrapper fpylll.util ``` -------------------------------- ### fpylll.algorithms.simple_bkz Module Source: https://fpylll.readthedocs.io/en/latest/_sources/modules Implements a simplified version of the BKZ algorithm in Python. This module supports initialization, calling, and finding members. ```python import fpylll.algorithms.simple_bkz # Example usage (assuming methods are available): # simple_bkz = fpylll.algorithms.simple_bkz.SimpleBKZ() # reduced_basis = simple_bkz(basis, block_size) ``` -------------------------------- ### fpylll.fplll.gso.MatGSO Methods Source: https://fpylll.readthedocs.io/en/latest/genindex Documentation for the __init__ method of the MatGSO class in fpylll.fplll.gso, related to the Gram-Schmidt orthogonalization process. ```APIDOC fpylll.fplll.gso.MatGSO: __init__(...) - Initializes the MatGSO object for Gram-Schmidt orthogonalization. ``` -------------------------------- ### fpylll.fplll.integer_matrix.IntegerMatrixRow Methods Source: https://fpylll.readthedocs.io/en/latest/genindex Documentation for methods of the IntegerMatrixRow class in fpylll.fplll.integer_matrix, specifically __getitem__, __init__, and addmul. These relate to row access and manipulation. ```APIDOC fpylll.fplll.integer_matrix.IntegerMatrixRow: __getitem__(index) - Accesses elements within the matrix row. __init__(...) - Initializes an IntegerMatrixRow. addmul(vector, scalar) - Adds a scaled vector to the row. ``` -------------------------------- ### LLL Reduction and Verification Source: https://fpylll.readthedocs.io/en/latest/modules Demonstrates how to perform LLL reduction on a matrix and then verify if the resulting matrix is LLL-reduced. It also shows how to use the `reduction` function with default and custom parameters. ```python from fpylll import IntegerMatrix, LLL A = IntegerMatrix(40, 40) A.randomize('uniform', bits=32) # Check if initially reduced (should be False) print(f"Is matrix reduced initially? {LLL.is_reduced(A)}") # Perform LLL reduction LLL.reduction(A) # Check if reduced after operation (should be True) print(f"Is matrix reduced after LLL.reduction? {LLL.is_reduced(A)}") # Example with specific parameters # LLL.reduction(A, delta=0.8, eta=0.4, method='fast') ``` -------------------------------- ### FPLLL Utility Methods Source: https://fpylll.readthedocs.io/en/latest/genindex Documents static methods from the fpylll.util.FPLLL module, including setting external enumerators, precision, random seeds, and threads. ```APIDOC FPLLL.set_external_enumerator(enumerator) Sets an external enumerator for FPLLL operations. FPLLL.set_precision(precision) Sets the precision for FPLLL calculations. FPLLL.set_random_seed(seed) Sets the seed for the random number generator. FPLLL.set_threads(num_threads) Sets the number of threads to be used by FPLLL. FPLLL.threads() Returns the current number of threads used by FPLLL. ``` -------------------------------- ### LLL Algorithm Parameters and Configuration Source: https://fpylll.readthedocs.io/en/latest/modules This section outlines the parameters and configurations available for the LLL algorithm within the fpylll library. It includes default values, reduction strategies, and constants used by the LLL implementation. ```APIDOC LLL: DEFAULT: LLL The default LLL configuration. DEFAULT_DELTA: float The default delta value for LLL reduction. DEFAULT_ETA: float The default eta value for LLL reduction. EARLY_RED: int Constant for early reduction strategy. Reduction: Enum Enum for different reduction strategies. SIEGEL: int Constant for Siegel reduction strategy. VERBOSE: int Constant for verbose output. Wrapper: type The Wrapper class for LLL reduction. ``` -------------------------------- ### fpylll.util Module Source: https://fpylll.readthedocs.io/en/latest/_sources/modules A utility module for the fpylll library, providing helper functions and common operations. Supports initialization, calling, and copying. ```python import fpylll.util # Example usage (assuming methods are available): # util_instance = fpylll.util.Util() # processed_data = util_instance.process(data) ``` -------------------------------- ### FPLLL Algorithms Source: https://fpylll.readthedocs.io/en/latest/modules Documentation for algorithms implemented in the fpylll library, including various versions of the Block Korkine-Zemlin (BKZ) algorithm. ```APIDOC Simple BKZ Implements a simple version of the BKZ algorithm. Simple Dual BKZ Implements a simple version of the Dual BKZ algorithm. BKZ Implements the BKZ algorithm. ``` -------------------------------- ### LLL Reduction Documentation Source: https://fpylll.readthedocs.io/en/latest/genindex Documentation for LLL reduction algorithms and related classes. Includes LLL, LLLReduction, and methods for checking reduction status. ```APIDOC LLL: Wrapper: Inner class or structure within LLL. LLLReduction: last_early_red: Attribute storing information about the last early reduction. M: Attribute related to the reduction process. lll_reduction(): Function to perform LLL reduction. is_LLL_reduced(): Static method to check if a basis is LLL-reduced. is_reduced(): Static method to check if a basis is reduced. ```