mapper#
Map the quantum gate to photonic quantum circuit
Classes
|
Map the quantum gate to the unitary matrix of the photonic quantum circuit based on dual-rail encoding. |
- class UnitaryMapper(nqubit: int, nmode: int, ugate: Any, success: float, aux: list | None = None, aux_pos: list | None = None)[source]#
Bases:
objectMap the quantum gate to the unitary matrix of the photonic quantum circuit based on dual-rail encoding.
- Parameters:
nqubit (int) – The number of qubits of the quantum gates.
nmode (int) – The number of modes in the circuit.
ugate (Any) – The target quantum gate.
success (float) – The square root of the probability of the target quantum gate. The preferred value is 1/3 for 2 qubits or 1/4 for 3 qubits.
aux (list | None) – Two auxiliary modes in the circuit, which could be
[0,0]or[1,0]. Default:Noneaux_pos (list | None) – The positions of the auxiliary modes. Default:
None(which means the last two modes).
- f_complex(y)[source]#
Construct \(2^{nqubit}*2^{nqubit}\) equations for \(n*n\) matrix y, obtain complex solutions.
- Parameters:
y – an array with \(2*n^2\) element
- f_real(y)[source]#
Construct equations to obtain real solutions for the real part of the target quantum gate.
- Parameters:
y – Input matrix/array with \(n^2\) elements, where \(n = 2^{nqubit}\).
- get_coeff_sym(input_state: Tensor, output_states: list | None = None)[source]#
Return the transfer state coefficient in a symbolic way.
- get_indx_coeff(coeff_i, all_inputs=None)[source]#
Get the index of y_var for given state transfer coefficients.
- indx_eqs()[source]#
Get the dictinonary of indices of y_mat for each nonlinear equations for n modes.
- static plot_u(unitary, vmax=1, vmin=0, fs=20, len_ticks=5, cl='RdBu')[source]#
Plot the matrix in graphic way.
- Parameters:
unitary – the plotting matrix
vmax – max value of the unitary matrix
vmin – min value of the unitary matrix
fs – fontsize
len_ticks – number of ticks in colorbar
cl – color of plotting
- static product_factorial(state)[source]#
Get the product of the factorial from the state, i.e., \(|s_1,s_2,...s_n> --> s_1!*s_2!*...s_n!\).
- solve_eqs_complex(total_trials=10, trials=1000, precision=1e-05)[source]#
Solve the non-linear eqautions for matrix satisfying ugate with complex solution.
- solve_eqs_real(total_trials=10, trials=1000, precision=1e-06)[source]#
Solve the non-linear eqautions for matrix satisfying ugate with real solution.
- static sub_matrix_sym(unitary, input_state, output_state)[source]#
Get the sub_matrix of transfer probs for given input and output state.