linalg
Linear algebra utilities for GF(2) operations.
find_basis
find_basis(
vectors: ndarray,
) -> tuple[np.ndarray, np.ndarray]
Decompose a set of binary vectors into a basis subset and a transformation matrix over GF(2).
Given a set of vectors V, this function finds a maximal linearly independent subset B (the basis) and computes a transformation matrix T such that the original vectors can be reconstructed from the basis via matrix multiplication over GF(2):
V = T @ B (mod 2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors | ndarray | Input binary vectors of shape | required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray] | A tuple |
Source code in src/tsim/utils/linalg.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
matmul_gf2
matmul_gf2(a: Array, b: Array) -> Array
Compute binary dot products mod 2 as a_GTP x b_BP -> b_BGT.
Uses float32 matmul (integer matmul does not have BLAS support on CPU) then casts back to uint8.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a | Array | Parameter bit-masks, shape | required |
b | Array | Binary parameter values, shape | required |
Returns:
| Type | Description |
|---|---|
Array | Binary row-sums mod 2, shape |
Source code in src/tsim/utils/linalg.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |