-
Notifications
You must be signed in to change notification settings - Fork 9
Extra Utilities
There are some extra utilities that can be found in search_compiler.utils
. Most of these are mainly used as subroutines by our code, but some of them you may find useful.
-
endian_reverse
- This function takes a unitary matrix, and reverses its endianness. This is needed to compare matrices from sources that use little endian, such as Qiskit, to matrices from sources that use big endian, such assearch_compiler
. This function relies onremap
, described below. -
remap
- This function takes a unitary matrix and a list representing a rearrangement of qubits, and reorganizes the unitary according to the new arrangement. For example,remap(U, [1,0,2])
will produce the matrix that would represent the circuit produced by taking a circuit forU
and swapping the names of qubits 1 and 0.
-
matrix_distance_squared
- This is the default value oferror_func
andeval_func
, and is an example of how to write your own versions of these functions. It is also a highly efficient distance function that can be used to compare two unitary matrices. It produces a value between 0 and 1, where a value of 0 indicates identical matrices and higher values indicate more different matrices. It ignores an overall phase difference between the two matrices. It only produces well-defined output for unitary matrices. -
matrix_distance_squared_jac
- This is a function used to calculate the Jacobian formatrix_distance_squared
, and is a good example of how to write a Jacobian of custom distance functions, which is necessary in order to take advantage of Jacobian solvers. Functions of this type are provided aserror_jac
. -
matrix_residuals
- This is the residuals function thatsearch_compiler.solver.LeastSquares_Jac_Solver
minimizes. It also has amatrix_residuals_jac
implementation. Note that the LeastSquares solver uses a different format, soeval_func
must be specified in addition toerror_func
if you are customizing it. The default settings will automatically changeeval_func
for you when using LeastSquares.