qfnn.qf_circ.base module¶
Filename :lib_circuit_base.py Description :This document is used for fundamental class of quantum circuit Time :2021/09/26 13:58:23 Author :Weiwen Jiang & Zhirui Hu Version :1.0
- class qfnn.qf_circ.base.BaseCircuit(n_qubits, n_repeats)¶
Bases:
object
BaseCircuit is a class, which includes fundamental functions of a circuit module.
- Parameters
n_qubits – input qubits of each unit
n_repeats – repeat times of each unit
- add_input_qubits(circuit, name)¶
Function add_input_qubits is to add a group of qubits as input qubit .
- Parameters
circuit – The circuit that you add the unit at the end
name – The name of the group
- Returns
The register of qubits
- Return type
qubits
- add_qubits(circuit, name, number)¶
Function add_qubits is to add a group of qubits to a circuit. [Test at 09/29]
- Parameters
circuit – The circuit that you add the unit at the end
name – The name of the group
number – The number of qubits in the group.
- Returns
The register of qubits
- Return type
qubits
- abstract classmethod forward(circuit)¶
Function forward is to add a circuit unit to the input qubits.
- Parameters
circuit – The circuit that you add the unit at the end
- class qfnn.qf_circ.base.LinnerCircuit(n_qubits, n_repeats)¶
Bases:
qfnn.qf_circ.base.BaseCircuit
LinnerCircuit is a base class of u-layer circuit and ffnn circuit.
- Parameters
n_qubits – input qubits of each unit
n_repeats – repeat times of each unit
- add_aux(circuit)¶
Function add_aux is to add a group of qubits as input qubit .
- Parameters
circuit – The circuit that you add the unit at the end
- Returns
The register of qubits
- Return type
qubits
- add_input_qubits(circuit, name='linner_layer')¶
Function add_input_qubits is to add a group of qubits as input qubit .
- Parameters
circuit – The circuit that you add the unit at the end
- Returns
The register of qubits
- Return type
qubits
- add_out_qubits(circuit)¶
Function add_out_qubits is to add a group of qubits as input qubit .
- Parameters
circuit – The circuit that you add the unit at the end
- Returns
The register of qubits
- Return type
qubits
- add_weight(circuit, weight, in_qubits, data_matrix=None, aux=[])¶
Function add_weight is to add the circuit of ci=wi*xi.
- Parameters
circuit – The circuit that you add the unit at the end
weight – A list of binary weight.
in_qubits – The register of input qubits
data_matrix – The unitary matrix encoding into the qubits
aux – aux qubits
- extract_from_weight()¶
- forward(circuit, weight, in_qubits, out_qubit, data_matrix=None, aux=[])¶
Function forward is to add the circuit of (∑wi*xi)^2/N.
- Parameters
circuit – The circuit that you add the unit at the end
weight – A list of binary weight.
in_qubits – The register of input qubits
out_qubit – The register of output qubits
data_matrix – The unitary matrix encoding into the qubits
aux – aux qubits
- classmethod get_index_list(input, target)¶
- sum2(circuit, in_qubits, out_qubit, aux=[])¶
Function sum2 is to add the circuit of (∑ci)^2/N.
- Parameters
circuit – The circuit that you add the unit at the end
in_qubits – The register of input qubits
out_qubit – The register of output qubits
aux – aux qubits