[−][src]Function dqcsim::bindings::dqcs_mat_strip_control
#[no_mangle]pub extern "C" fn dqcs_mat_strip_control(
mat: dqcs_handle_t,
epsilon: c_double,
ignore_global_phase: bool,
control_indices: *mut *mut ssize_t
) -> dqcs_handle_t
Splits a controlled matrix into its non-controlled submatrix and the indices of the control qubits. >
mat
specifies the matrix to modify. This is a borrowed handle.epsilon
specifies the maximum magitude of the difference between the column vectors of the input matrix and the identity matrix (after dephasing ifignore_gphase
is set) for the column vector to be considered to not affect the respective entry in the quantum state vector. Note that if this is greater than zero, the resulting gate may not be exactly equivalent. Ifignore_global_phase
is set, any global phase in the matrix is ignored, but note that if control qubits are stripped the "global" phase of the resulting submatrix is always significant.control_indices
is a return argument through which DQCsim will pass the indices of the qubits that were removed in the process of constructing the submatrix. This is represented as an array of indices terminated by a -1 entry. The returned matrix must be freed usingfree()
when you are done with it to avoid memory leaks. This function returns a new matrix handle with the submatrix, or 0 if it fails. In this case,control_indices
is not mutated.This function assumes that the incoming matrix is unitary (within
epsilon
) without verifying that this is the case. The results may thus be invalid if it was not.