def _apply_krauss_single_qubit(krauss: Union[Tuple[Any], Sequence[Any]],
        args: 'ApplyChannelArgs') -> np.ndarray:
    """Use slicing to apply single qubit channel."""
    zero_left = linalg.slice_for_qubits_equal_to(args.left_axes, 0)
    one_left = linalg.slice_for_qubits_equal_to(args.left_axes, 1)
    zero_right = linalg.slice_for_qubits_equal_to(args.right_axes, 0)
    one_right = linalg.slice_for_qubits_equal_to(args.right_axes, 1)
    for krauss_op in krauss:
        np.copyto(dst=args.target_tensor,
                  src=args.auxiliary_buffer0)
        linalg.apply_matrix_to_slices(
                args.target_tensor,
                krauss_op,
                [zero_left, one_left],
                out=args.auxiliary_buffer1)
        # No need to transpose as we are acting on the tensor
        # representation of matrix, so transpose is done for us.
        linalg.apply_matrix_to_slices(
                args.auxiliary_buffer1,
                np.conjugate(krauss_op),
                [zero_right, one_right],
                out=args.target_tensor)
        args.out_buffer += args.target_tensor
    return args.out_buffer
def _apply_krauss_single_qubit ( krauss : Union [ Tuple [ Any ] , Sequence [ Any ] ] , args : 'ApplyChannelArgs' ) -> np . ndarray : zero_left = linalg . slice_for_qubits_equal_to ( args . left_axes , 0 ) one_left = linalg . slice_for_qubits_equal_to ( args . left_axes , 1 ) zero_right = linalg . slice_for_qubits_equal_to ( args . right_axes , 0 ) one_right = linalg . slice_for_qubits_equal_to ( args . right_axes , 1 ) for krauss_op in krauss : np . copyto ( dst = args . target_tensor , src = args . auxiliary_buffer0 ) linalg . apply_matrix_to_slices ( args . target_tensor , krauss_op , [ zero_left , one_left ] , out = args . auxiliary_buffer1 ) linalg . apply_matrix_to_slices ( args . auxiliary_buffer1 , np . conjugate ( krauss_op ) , [ zero_right , one_right ] , out = args . target_tensor ) args . out_buffer += args . target_tensor return args . out_buffer
Use slicing to apply single qubit channel.