pauliarray.binary package#
Submodules#
pauliarray.binary.bit_operations module#
- pauliarray.binary.bit_operations.add(bit_matrix_1: np.ndarray[np.bool], bit_matrix_2: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Performs element-wise XOR operation between two binary matrices.
- Parameters:
bit_matrix_1 ("np.ndarray[np.bool]") – First binary matrix.
bit_matrix_2 ("np.ndarray[np.bool]") – Second binary matrix.
- Returns:
Element-wise XOR result of the two input matrices.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.bit_operations.bit_sum(bit_strings: np.ndarray[np.bool]) int [source]#
Calculates the sum of booleans along the last axis of the input array.
- Parameters:
bit_strings ("np.ndarray[np.bool]") – Array of booleans.
- Returns:
Sum of bits along the last axis.
- Return type:
int
- pauliarray.binary.bit_operations.dot(bit_strings_1: np.ndarray[np.bool], bit_strings_2: np.ndarray[np.bool]) np.ndarray[np.int] [source]#
Computes the dot product between two arrays of boolean values.
- Parameters:
bit_strings_1 ("np.ndarray[np.bool]") – First array of boolean values.
bit_strings_2 ("np.ndarray[np.bool]") – Second array of boolean values.
- Returns:
Dot product of the two input arrays.
- Return type:
“np.ndarray[np.int]”
- pauliarray.binary.bit_operations.intersection(bit_strings_1: np.ndarray[np.bool], bit_strings_2: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Computes the intersection of two sets of bit strings.
- Args
bit_strings_1 (“np.ndarray[np.bool]”): First array of boolean values. bit_strings_2 (“np.ndarray[np.bool]”): Second array of boolean values.
- Returns
“np.ndarray[np.bool]”: Intersection of the input bit strings.
- pauliarray.binary.bit_operations.intersection_row_space(bit_matrix_1: np.ndarray[np.bool], bit_matrix_2: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Given two matrices which rows are spanning two subspace, this fonction returns rows spanning the intersection subspace.
- Parameters:
bit_matrix_1 ("np.ndarray[np.bool]") – First binary matrix.
bit_matrix_2 ("np.ndarray[np.bool]") – Second binary matrix.
- Returns:
Rows spanning the intersection subspace.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.bit_operations.inv(bit_matrix: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Computes the inverse of a binary matrix.
- Parameters:
bit_matrix ("np.ndarray[np.bool]") – Input binary matrix.
- Returns:
Inverse of the input binary matrix.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.bit_operations.is_orthogonal(bit_strings_1: np.ndarray[np.bool], bit_strings_2: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Checks if two sets of bit strings are orthogonal.
- Parameters:
bit_strings_1 ("np.ndarray[np.bool]") – First array of boolean values.
bit_strings_2 ("np.ndarray[np.bool]") – Second array of boolean values.
- Returns
“np.ndarray[np.bool]”: True if the input bit strings are orthogonal, False otherwise.
- pauliarray.binary.bit_operations.kernel(bit_matrix: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Computes the Kernel of a two dimensions “np.ndarray[np.bool]”. The Kernel of a matrix A is a matrix which the columns are formed by the vectors x such that
\[A x = 0.\]- Parameters:
bit_matrix ("np.ndarray[np.bool]") – Input binary matrix.
- Returns:
Kernel of the input binary matrix.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.bit_operations.matmul(bit_matrix_1: np.ndarray[np.bool], bit_matrix_2: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Performs matrix multiplication over binary matrices.
- Parameters:
bit_matrix_1 ("np.ndarray[np.bool]") – First binary matrix.
bit_matrix_2 ("np.ndarray[np.bool]") – Second binary matrix.
- Returns:
Resultant binary matrix after multiplication.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.bit_operations.orthogonal_basis(bit_strings: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Computes the orthogonal basis of the given set of bit strings.
- Parameters:
bit_strings ("np.ndarray[np.bool]") – Input array of bit strings.
- Returns
“np.ndarray[np.bool]”: Orthogonal basis of the input bit strings.
- pauliarray.binary.bit_operations.orthogonal_complement(bit_strings: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Computes the orthogonal complement of the given set of bit strings.
- Parameters:
bit_strings ("np.ndarray[np.bool]") – Input array of bit strings.
- Returns
“np.ndarray[np.bool]”: Orthogonal basis of the input bit strings.
- pauliarray.binary.bit_operations.rank(bit_matrix: np.ndarray[np.bool]) int [source]#
Computes the rank of a binary matrix.
- Parameters:
bit_matrix ("np.ndarray[np.bool]") – Input binary matrix.
- Returns:
Rank of the binary matrix.
- Return type:
int
- pauliarray.binary.bit_operations.row_echelon(bit_matrix: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Applies Gauss-Jordan elimination on a binary matrix to produce row echelon form.
- Parameters:
bit_matrix ("np.ndarray[np.bool]") – Input binary matrix.
- Returns:
Row echelon form of the provided matrix.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.bit_operations.row_space(bits: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Computes the row space of a binary matrix using Gauss-Jordan elimination and removing the zero lines.
- Parameters:
bits ("np.ndarray[np.bool]") – Input binary matrix.
- Returns
“np.ndarray[np.bool]”: Row space of the current matrix
- pauliarray.binary.bit_operations.strings_to_ints(bit_strings: np.ndarray[np.bool]) np.ndarray[np.int] [source]#
Converts binary strings to integers.
- Parameters:
bit_strings ("np.ndarray[np.bool]") – Input array of binary strings.
- Returns:
Integers obtained from input binary strings
- Return type:
“np.ndarray[np.int]”
pauliarray.binary.symplectic module#
- pauliarray.binary.symplectic.coisotropic_subspace(orthogonal_zx_strings: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Given a list of zx_strings which are mutually orthogonal in the smplectic sense, returns a list of zx_strings which are orthogonal to the provided zx_strings. For zx_strings of length 2*n, the number of returned zx_strings is 2*n - rank(zx_strings). The returned zx_strings might not be mutually orthogonal in the symplectic sense.
- Parameters:
orthogonal_zx_strings ("np.ndarray[np.bool]") – A list of zx_strings (2d-array of bools) which are mutually
strings. (orthogonal. Last dimension is along the length of the)
- Returns:
A list of zx_strings defining the coisotropic subspace.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.symplectic.conjugate_subspace(isotropic_zx_strings: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Conctruct a conjugate subspace to the provided isotropic subspace. Each zx_string the conjugate subspace is orthogonal ins the symplectic sense to all provided zx_strings of the isotropic subspace, except for one : its conjugate.
- Parameters:
isotropic_zx_strings ("np.ndarray[np.bool]") – Isotropic subspace.
- Returns:
Conjugate subspace to the input isotropic subspace.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.symplectic.dot(zx_strings_1: np.ndarray[np.bool], zx_strings_2: np.ndarray[np.bool]) np.ndarray[np.int] [source]#
Computes the binary dot product between two zx boolean strings.
- Parameters:
zx_strings_1 ("np.ndarray[np.bool]") – First input zx string to compute the dot product with.
zx_strings_2 ("np.ndarray[np.bool]") – Second input zx string to compute the dot product with.
- Returns:
Dot product of the two input arrays.
- Return type:
“np.ndarray[np.int]”
- pauliarray.binary.symplectic.flip_zx(zx_strings: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Flips an input zx string into an xz string.
- Parameters:
zx_strings ("np.ndarray[np.bool]") – Input zx string to flip
- Returns:
Flipped zx string (xz string)
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.symplectic.gram_schmidt_orthogonalization(zx_strings: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Performs a Gram Schmidt orthogonalization procedure in the symplectic space.
- Parameters:
zx_strings ("np.ndarray[np.bool]") – Input space.
- Returns:
Bit strings which are mutually symplectic orthogonal spawning the same space as the input.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.symplectic.is_coisotropic(zx_strings: np.ndarray[np.bool]) bool [source]#
Checks if a given list of zx_strings defines an coisotropic subspace.
- Parameters:
zx_strings ("np.ndarray[np.bool]") – A list of zx_strings (2d-array of bools) defining a subspace.
strings. (Last dimension is along the length of the)
- Returns:
Wether or not input is coisotropic
- Return type:
bool
- pauliarray.binary.symplectic.is_isotropic(zx_strings: np.ndarray[np.bool]) bool [source]#
Checks if a given list of zx_strings defines an isotropic subspace.
- Parameters:
zx_strings ("np.ndarray[np.bool]") – A list of zx_strings (2d-array of bools) defining a subspace.
strings. (Last dimension is along the length of the)
- Returns:
Wether or not input is isotropic
- Return type:
bool
- pauliarray.binary.symplectic.is_lagrangian(zx_strings: np.ndarray[np.bool]) bool [source]#
Checks if a given list of zx_strings defines a Lagrangian subspace.
- Parameters:
zx_strings ("np.ndarray[np.bool]") – A list of zx_strings (2d-array of bools) defining a subspace.
strings. (Last dimension is along the length of the)
- Returns:
Wether or not input is lagrangian
- Return type:
bool
- pauliarray.binary.symplectic.is_orthogonal(zx_strings_1: np.ndarray[np.bool], zx_strings_2: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Check if the zx_strings of one string array are orthogonal to the zx_strings of an other string array element wise and using the simplectic dot product. Two zx_strings are orthogonal if the symplectic dot product is 0.
- Parameters:
zx_strings_1 ("np.ndarray[np.bool]") – A list of zx_strings defining a subspace.
strings. (Last dimension is along the length of the)
zx_strings_2 ("np.ndarray[np.bool]") – A list of zx_strings defining a subspace.
strings.
- Returns:
Wether or not the two input string are orthogonal to each other.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.symplectic.isotropic_subspace(orthogonal_zx_strings: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Given a list of zx_strings which are mutually orthogonal in the smplectic sense, returns a list of zx_strings which are mutually orthogonal and linearly independent.
- Parameters:
orthogonal_zx_strings ("np.ndarray[np.bool]") – A list of zx_strings (2d-array of bools) which are mutually
strings. (orthogonal. Last dimension is along the length of the)
- Returns:
A list of zx_strings defining the isotropic subspace.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.symplectic.lagrangian_subspace(orthogonal_zx_strings: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Given a list of zx_strings of length 2*n which are mutually orthogonal in the smplectic sense, returns a list of n zx_strings which are mutually orthogonal and orthogonal to the provided zx_strings.
- Parameters:
orthogonal_zx_strings ("np.ndarray[np.bool]") – A list of zx_strings (2d-array of bools) which are mutually
strings. (orthogonal. Last dimension is along the length of the)
- Returns:
A list of zx_strings defining the Lagrangian subspace.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.symplectic.merge_zx_strings(z_strings: np.ndarray[np.bool], x_strings: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Merges z and x strings to create one zx string.
- Parameters:
z_strings ("np.ndarray[np.bool]") – First string to concatenate (z)
x_strings ("np.ndarray[np.bool]") – Second string to concatenate (x)
- Returns:
Concatenated zx string.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.symplectic.orthogonal_complement(zx_strings: np.ndarray[np.bool]) np.ndarray[np.bool] [source]#
Finds a list of zx_strings which or orthogonal in the symplectic sense to the provided zx_strings. For zx_strings of length 2*n, the number of returned zx_strings is 2*n - rank(zx_strings). The returned zx_strings might not be mutually orthogonal in the symplectic sense.
- Parameters:
zx_strings ("np.ndarray[np.bool]") – A list of zx_strings (2d-array of bools) defining a subspace.
strings. (Last dimension is along the length of the)
- Returns:
A list of zx_strings defining the orthogonal completement.
- Return type:
“np.ndarray[np.bool]”
- pauliarray.binary.symplectic.split_zx_strings(zx_strings: np.ndarray[np.bool]) tuple[np.ndarray[np.bool], np.ndarray[np.bool]] [source]#
Split one concatenated zx string into a z string and an x string.
- Parameters:
zx_strings ("np.ndarray[np.bool]") – Concatenated zx string
- Returns:
Split z string and x string.
- Return type:
tuple[“np.ndarray[np.bool]”, “np.ndarray[np.bool]”]
Module contents#
Binary module. Implements operations on binary data structures.