QFT

This module builds the QFT in Qiskit and runs it

QFT_length(nWires)[source]

Returns the length (number of gates) of the QFT.

Parameters:nWires (int) – Number of qbits on the system.
Returns:int – Number of gates in the QFT.
all_QFT_circuits(nWires)[source]
Returns a list of quantum circuit of the QFT built up to \(k\) gates, with
\(k\) varying between 0 and the full length of the QFT.
Parameters:nWires (int) – Number of qbits on the system.
Returns:list[QuantumCircuit] – A lits the partial QFTs of length varying between 0 and the full length of the QFT.
build_QFT_0_to_k(nWires, k, measure=False)[source]

Builds the QFT on nWires wires up to the \(k^{th}\) state generates.

Note that the whole QFT can be generated in Qiskit using the \(QFT\) method

Parameters:
  • nWires (int) – number of wires
  • k (int) – number of gates in the output
Returns:

QuantumCirctuit – \(k^{th}\) first gates of the QFT circuit

get_coef_from_optimization_file(filename, iteration, evaluation=False)[source]
The file fed in this function must be a csv file with one of columns
being named “iteration”, an other one being named “coefficients” and if the \(evaluation\) parameter is set to \(True\) a column named “intricationValue”. The “iteration” column must contain integers, the “coefficients” column must contain tuples of real numbers (the mermin coefficients) and the “intricationValue” column must contain real numbers.
Example:
>>> get_coef_from_optimization_file("../examples/QFT-optimized-coefficients/1-1-4.csv",2)
([(-0.197738971530022, -0.00983193840670331,  0.980205403028067), 
  (0.892812904656093,  -0.035586934469795,    0.449019695976237), 
  (-0.892282320991669, -0.00788653439204609, -0.451408974457756), 
  (0.982839628418978,   0.012341254672589,   -0.184048793102134)], 
 [(0.430894968126063,  -0.0211632981654613,   0.902153890006799), 
  (-0.984337747324624,  0.0105235779205133,   0.175978559772592), 
  (0.984221659519729,  -0.0118117927364157,  -0.176545196719091), 
  (0.883187500168151,   0.0083188846423974,   0.468946303647911)])
Parameters:
  • filename (str) – Name of the CSV file containing the information about the Mermin coefficients.
  • iteration (int) – Designates the line from which the data must be retrieved.
  • intricationValue (bool) – If \(True\), the evaluation will be returned as well as the coefficients.
Returns:

tuple[list[tuple[real]]], real(optional) – The mermin coefficients previously optimized in packed shape, eventually with the optimum computed with these coefficients.

periodic_state(l, r, nWires)[source]
Returns the periodic state \(|\varphi^{l,r}>\) of size \(2^{nWires}\). We
have:

\(|\varphi^{l,r}> = \sum_{i=0}^{A-1}|l+ir>/\sqrt(A)\) with \(A = floor((2^{nWires}-l)/r)+1\)

In this definition, l is the shift of the state, and r is the period of the state.

Example:

Since \(|\varphi^{1,5}> = (|1>+|6>+|11>)/\sqrt(3)=(|0001>+|0110>+|1011>)/\sqrt(3)\),

>>> periodic_state(1,5,4)
(0, 1/3*sqrt(3), 0, 0, 0, 0, 1/3*sqrt(3), 0, 0, 0, 0, 1/3*sqrt(3), 0, 0, 0, 0)
Parameters:
  • l (int) – The shift of the state.
  • r (int) – The period of the state.
  • nWires (int) – The size of the system (number of qubits).
Returns:

vector – The state defined by l, r and nWires according to the definition given above.