Quantum Fourier Transformation and Phase Estimation

Let's use Yao first

using Yao

Quantum Fourier Transformation

The Quantum Fourier Transformation (QFT) circuit is to repeat two kinds of blocks repeatly:

qft-circuit

The basic building block control phase shift gate is defined as

\[R(k)=\begin{bmatrix} 1 & 0\\ 0 & \exp\left(\frac{2\pi i}{2^k}\right) \end{bmatrix}\]

Let's define block A and block B, block A is actually a control block.

A(i, j) = control(i, j=>shift(2π/(1<<(i-j+1))))
A (generic function with 1 method)

Once you construct the blockl you can inspect its matrix using mat function. Let's construct the circuit in dash box A, and see the matrix of $R_4$ gate.

R4 = A(4, 1)
(n -> control(n, 4, 1 => shift(0.39269908169872414)))

If you have read about preparing GHZ state, you probably know that in Yao, we could just leave the number of qubits, and it will be evaluated when possible.

R4(5)
nqubits: 5
control(4)
└─ (1,) shift(0.39269908169872414)

its matrix will be

mat(R4(5))
32×32 Diagonal{ComplexF64, Vector{ComplexF64}}:
 1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im          ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      0.92388+0.382683im      ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅           1.0+0.0im          ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅      0.92388+0.382683im      ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅           1.0+0.0im          ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅      0.92388+0.382683im      ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅           1.0+0.0im          ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅      0.92388+0.382683im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅           1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im          ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      0.92388+0.382683im      ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅           1.0+0.0im          ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅      0.92388+0.382683im      ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅           1.0+0.0im          ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅      0.92388+0.382683im      ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅           1.0+0.0im          ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅      0.92388+0.382683im

Then we repeat this control block over and over on different qubits, and put a Hadamard gate to ith qubit to construct i-th B block.

B(n, k) = chain(n, j==k ? put(k=>H) : A(j, k) for j in k:n)
B (generic function with 1 method)

We need to input the total number of qubits n here because we have to iterate through from k-th location to the last.

Now, let's construct the circuit by chaining all the B blocks together

qft(n) = chain(B(n, k) for k in 1:n)
qft(4)
nqubits: 4
chain
├─ chain
│  ├─ put on (1)
│  │  └─ H
│  ├─ control(2)
│  │  └─ (1,) shift(1.5707963267948966)
│  ├─ control(3)
│  │  └─ (1,) shift(0.7853981633974483)
│  └─ control(4)
│     └─ (1,) shift(0.39269908169872414)
├─ chain
│  ├─ put on (2)
│  │  └─ H
│  ├─ control(3)
│  │  └─ (2,) shift(1.5707963267948966)
│  └─ control(4)
│     └─ (2,) shift(0.7853981633974483)
├─ chain
│  ├─ put on (3)
│  │  └─ H
│  └─ control(4)
│     └─ (3,) shift(1.5707963267948966)
└─ chain
   └─ put on (4)
      └─ H

Wrap QFT to an external block

In most cases, functions are enough to wrap quantum circuits, like A and B we defined above, but sometimes, we need to dispatch specialized methods on certain kinds of quantum circuit, or we want to define an external block to export, thus, it's useful to be able to wrap circuit to custom blocks.

First, we define a new type as subtype of PrimitiveBlock since we are not going to use the subblocks of QFT, if you need to use its subblocks, it'd be better to define it under CompositeBlock.

struct QFT <: PrimitiveBlock{2}
    n::Int
end

YaoBlocks.nqudits(q::QFT) = q.n

Now, let's define its circuit

circuit(q::QFT) = qft(q.n)
circuit (generic function with 1 method)

And forward mat to its circuit's matrix

YaoBlocks.mat(::Type{T}, x::QFT) where T = mat(T, circuit(x))

You may notice, it is a little ugly to print QFT at the moment, this is because we print the type summary by default, you can define your own printing by overloading print_block

YaoBlocks.print_block(io::IO, x::QFT) = print(io, "QFT($(x.n))")

Since it is possible to use FFT to simulate the results of QFT (like cheating), we could define our custom apply! method:

using FFTW, LinearAlgebra

function YaoBlocks.apply!(r::ArrayReg, x::QFT)
    α = sqrt(length(statevec(r)))
    invorder!(r)
    lmul!(α, ifft!(statevec(r)))
    return r
end

Now let's check if our apply! method is correct:

r = rand_state(5)
r1 = r |> copy |> QFT(5)
r2 = r |> copy |> circuit(QFT(5))
r1 ≈ r2
true

We can get iQFT (inverse QFT) directly by calling adjoint

QFT(5)'
 [†]QFT(5)

QFT and iQFT are different from FFT and IFFT in three ways,

  1. they are different by a factor of $\sqrt{2^n}$ with $n$ the number of qubits.
  2. the bit numbering will exchange after applying QFT or iQFT.
  3. due to the convention, QFT is more related to IFFT rather than FFT.

Phase Estimation

Since we have QFT and iQFT blocks we can then use them to realize phase estimation circuit, what we want to realize is the following circuit:

phase estimation

First we call Hadamard gates repeatly on first n qubits.

Hadamards(n) = repeat(H, 1:n)
Hadamards (generic function with 1 method)

Then in dashed box B, we have controlled unitaries:

ControlU(n, m, U) = chain(n+m, control(k, n+1:n+m=>matblock(U^(2^(k-1)))) for k in 1:n)
ControlU (generic function with 1 method)

each of them is a U of power $2^{(k-1)}$.

Since we will only apply the qft and Hadamard on first n qubits, we could use Subroutine, which creates a context of a sub-scope of the qubits.

PE(n, m, U) =
    chain(n+m, # total number of the qubits
        subroutine(Hadamards(n), 1:n), # apply H in local scope
        ControlU(n, m, U),
        subroutine(QFT(n)', 1:n))
PE (generic function with 1 method)

we use the first n qubits as the output space to store phase $ϕ$, and the other m qubits as the input state which corresponds to an eigenvector of oracle matrix U.

The subroutine here uses focus! and relax! to manage a local scope of quantum circuit, and only activate the first n qubits while applying the block inside the subroutine context, and the scope will be relax!ed back, after the context. This is equivalent to manually focus! then relax!

fullly activated

r = rand_state(5)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 5/5
    nlevel: 2

first 3 qubits activated

focus!(r, 1:3)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 3/5
    nlevel: 2

relax back to the original

relax!(r, 1:3)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 5/5
    nlevel: 2

In this way, we will be able to apply small operator directly on the subset of the qubits.

Details about the algorithm can be found here: Quantum Phase Estimation Algorithm

Now let's check the results of our phase estimation.

First we need to set up a unitary with known phase, we set the phase to be 0.75, which is 0.75 * 2^3 == 6 == 0b110 .

N, M = 3, 5
P = eigen(rand_unitary(1<<M)).vectors
θ = Int(0b110) / 1<<N
phases = rand(1<<M)
phases[0b010+1] = θ
U = P * Diagonal(exp.(2π * im * phases)) * P'
32×32 Matrix{ComplexF64}:
 0.00739558-0.233941im    -0.149065-0.104767im      0.109436+0.0665171im     -0.111854-0.0034325im    0.0184845-0.0879291im       0.305897-0.227201im    -0.000537651-0.157618im      0.0243237-0.0989243im    -0.0241911+0.0126073im   -0.0344516-0.156347im    -0.0316778-0.00496299im    0.0375599+0.259607im      -0.16705-0.03558im     -0.0877374-0.116751im     -0.163236-0.0285093im    -0.187831+0.137374im      0.058631-0.0511052im     0.0317357-0.199239im      -0.207378+0.100919im      0.070679+0.124146im     0.0846677-0.0972149im     0.149266-0.212442im    -0.0553215+0.1784im       -0.255117-0.0883493im      0.0427401-0.0599369im    0.0507468+0.157897im       -0.018622+0.0399121im    0.00995249-0.0254344im    -0.148573-0.00974039im   0.0844598+0.111479im      -0.151185-0.0108646im     -0.200108-0.117338im
 -0.0628106-0.159043im    0.0485784-0.00097675im     0.14468+0.165176im      0.0111759+0.0260564im     -0.19924-0.0535992im     -0.0411979-0.118933im        0.119556+0.0457773im     0.0182079-0.0853164im      -0.10342-0.0626627im    -0.282692+0.0706333im     0.205701-0.0623808im     -0.107652-0.188531im     -0.231223+0.035179im      0.116056-0.0892124im    -0.123653+0.0640154im    -0.104478+0.238396im      0.065418+0.106001im     -0.0222248+0.0274162im      0.141295-0.0942638im    0.0864308+0.0469057im     0.119005-0.1385im      0.00480574+0.227384im     0.0307364-0.272651im     0.0828191-0.107554im       0.0549443+0.113434im     0.0494036-0.10031im        0.0188859-0.21866im      -0.0233078+0.211748im      0.138719-0.00438009im   0.0178304+0.11822im       -0.109322+0.18446im       0.0107406-0.21258im
 -0.0195489+0.110565im    0.0185274+0.00442671im    0.209628-0.334335im      0.0240437-0.115789im     -0.323103-0.196118im        0.184063+0.0564773im     -0.0773224+0.215879im       0.128349-0.175982im      0.0377313+0.190794im    -0.0266543-0.0463016im    0.0910752-0.115341im       0.160392-0.0727708im     0.115022-0.0796706im     0.161234+0.0370525im   -0.0427819-0.0803245im     0.054614-0.0844067im   -0.0148842-0.174679im      -0.193943-0.175897im      0.0439293-0.0608097im  0.000100715+0.0497619im   -0.0793952+0.144453im     0.0154822-0.0802177im    0.0335639-0.0438904im   -0.0844503-0.147592im        0.141981+0.153031im     0.0256932+0.0531552im      -0.151916-0.0390143im      0.144825-0.105687im      0.244492+0.0330056im     0.108761+0.0608856im    -0.0801298-0.124144im      0.0531526+0.0257297im
 -0.0639534-0.153155im    -0.111425+0.166986im     0.0543659+0.0665538im     -0.060405-0.127931im     -0.091212+0.0974719im       0.241381+0.123169im       0.0557443-0.183287im      -0.144016+0.084606im     -0.0703487+0.166489im     -0.188973+0.124556im     0.0434789+0.0225961im     0.0289385-0.103151im     -0.039765+0.198938im       0.19595+0.143672im     0.0960211-0.0175933im     0.172128-0.155521im    -0.0452009+0.121938im       0.211446+0.122335im    -0.00717952-0.0148981im    -0.139589+0.0506646im     0.146461+0.102418im    -0.0896602-0.0862128im      0.05891+0.126564im     0.0843545-0.100576im        0.165333-0.026039im    -0.0401463+0.109879im       0.0924022-0.098624im       0.159155-0.214389im     -0.174932+0.104978im     0.0673146-0.0234987im      -0.19986+0.245693im      0.0610709+0.150141im
 -0.0395244+0.0491901im    0.165404+0.126576im    -0.0986347+0.171364im     -0.0752599+0.200111im      0.081213+0.197609im        0.170924-0.185069im       0.0452518+0.186702im       0.254238-0.118616im      -0.104599+0.024651im     0.0741629+0.0888454im    -0.060022-0.0838255im     0.0225782-0.0802875im    -0.109074-0.0317697im    0.0750262-0.103257im    -0.0164406-0.075799im      0.232989+0.199276im    -0.0345606-0.131078im       0.156173+0.0504398im     0.0653011+0.14444im      0.0917109-0.0550485im    0.0339125+0.134476im      0.150722-0.0573084im     -0.16354+0.0843121im    0.0481205+0.0470349im       0.155654+0.110724im      0.240018+0.0585742im       0.265477-0.0858133im      0.117872-0.0595537im    0.0334797+0.0223234im   -0.0881609+0.133623im        0.15967-0.164901im      0.0829056+0.162065im
 -0.0108565-0.14711im    -0.0107156-0.119644im     -0.145971-0.00619386im    -0.144074-0.122634im      0.102534-0.111071im       -0.167125+0.109618im      -0.0661737-0.0723176im     -0.144354+0.182988im       0.105866-0.0659089im    -0.201025-0.0158774im   -0.0126276-0.170996im     -0.0456065+0.219925im     0.0714133+0.240815im      0.124479-0.146449im    -0.0520117+0.0671928im    0.0662424-0.0912772im    -0.141169-0.142701im     -0.0409384-0.0138328im     -0.140832+0.0193038im    0.0192018+0.0252043im     0.157275+0.217716im     0.0626975+0.0636073im    0.0801304-0.0637531im   0.00614188+0.033813im        0.186838-0.0295619im     0.244395-0.0335674im       0.165447-0.0641331im     0.0883455+0.0919421im      0.25981+0.222332im    -0.0676813-0.0981863im     0.0336414-0.240746im      -0.144129-0.115572im
  0.0577493+0.162628im    -0.118572-0.246037im     0.0612332+0.0717276im     0.0232847-0.0387836im   0.00586177+0.153503im        0.193727-0.00886686im    -0.0952999-0.0174119im    -0.0463743+0.0298218im    -0.0761171-0.0788629im     0.098991+0.130055im    -0.0208721+0.0871486im     0.0513559+0.00608107im   -0.209322+0.195307im    -0.0215072+0.0621927im     0.158769+0.257015im    -0.0552518+0.00740971im   0.0790121+0.203183im     -0.0753347-0.0671712im       -0.1436+0.002428im    -0.0972633-0.0236776im     -0.17288+0.0484067im    -0.110931+0.0400378im    -0.018793-0.00424116im   0.0829906-0.211132im       0.0696861+0.205342im      0.237445-0.180385im       0.0751382+0.213237im      -0.286596-0.189324im      0.233038+0.0333042im    0.0517106+0.150239im     -0.0201326-0.0677921im    -0.0479157+0.0403237im
  -0.257685-0.0190284im   0.0105065+0.0628784im    -0.165125-0.327664im       0.116923+0.09703im      0.0827317-0.00913733im    0.00117479-0.0595287im       0.230356-0.123801im      -0.147349+0.117133im      0.0234361-0.0200495im  -0.00191539+0.138077im      0.105686+0.287537im       0.187039-0.0706749im   -0.0263421+0.100885im    -0.0176112-0.0144669im   -0.0878959-0.00386404im    -0.18355+0.103032im    -0.0333768-0.0876405im      0.324397-0.199829im     -0.0497029-0.143559im     0.0683024+0.107563im    -0.0264876+0.199892im      0.219673+0.0578679im    0.0884884-0.00610054im    0.114436+0.0109906im       -0.13713+0.116709im   -0.00353771-0.00624336im  -0.000583477-0.0319955im    -0.0168376+0.0208819im    0.0839432-0.213231im     0.0991265+0.0303092im    -0.0697144-0.137671im      0.0218758+0.107168im
   0.150225-0.11716im      0.110965+0.351862im     -0.077867+0.125033im      -0.157219-0.028154im    -0.0633834+0.0549399im      0.0359733-0.077135im       0.0828998-0.0744763im     0.0642114+0.0389028im      0.145577-0.0604948im   -0.0517469+0.0122113im   -0.0717766+0.0494343im     0.0301377+0.0258755im      0.11593-0.0206808im  -0.00562556-0.112182im      0.129365+0.116926im     -0.109369-0.163858im     0.0133052-0.10865im       -0.176758+0.0167033im    -0.0483388+0.0265967im    0.0539858-0.246833im     -0.212425+0.0772567im     0.242098-0.0779135im    0.0481278+0.25437im       0.303834-0.063523im      -0.0556641+0.135082im    0.00871997-0.116318im       -0.180687-0.0546132im    -0.0358631+0.148265im     0.0272423+0.128976im      0.242331+0.15265im      -0.0360524+0.13008im     -0.00599755-0.12018im
 -0.0770422+0.0742282im    0.207877+0.0214337im   -0.0100708+0.0403087im    -0.0108089+0.0893806im     -0.25728-0.0837011im    0.000237452-0.00288566im    -0.0444014+0.194179im      -0.384899+0.0537341im    -0.0906417+0.0162281im     0.107685+0.00290817im  -0.0107023-0.0903117im     0.0916853-0.0126246im     0.119781-0.0178432im   -0.0876483+0.213292im     0.0446357-0.221943im    -0.0295686+0.0361654im     -0.18979-0.0524432im      0.169121-0.0375917im     -0.193319+0.125661im     -0.070526-0.00699991im   0.0496789-0.0946421im   -0.0599508+0.0824814im     -0.19293-0.0190393im     0.184038-0.0451801im       0.204192-0.126137im      0.106162+0.0970928im     -0.0604692+0.00217907im    -0.271214+0.194922im     -0.141744+0.0727994im     0.135214+0.167108im     0.00728219-0.0424397im     -0.139231-0.0655252im
   0.204947-0.112591im    0.0508082+0.172367im      0.104671+0.0519731im      0.031045+0.110729im    0.00737494-0.146213im        0.042599-0.0573712im       0.121094+0.065709im     -0.0657026+0.0974235im     0.0638519-0.0991852im    0.0802879+0.118375im      0.149726-0.040373im      0.0325488-0.0958023im   0.00184891-0.143436im    -0.0646426-0.0218652im    0.0138355-0.170088im      0.213624-0.0512892im     0.136981+0.0426458im   -0.00718041-0.0629395im     -0.207013-0.244474im      0.177052+0.00215231im  -0.0581136-0.208811im     -0.136559+0.0142814im   -0.0618176+0.108502im     0.0902434-0.0174689im     -0.0616948+0.0971278im    0.0628482-0.0268053im       0.237145+0.0126758im     0.0328599-0.173328im      0.122666-0.0498772im    0.0812892-0.424168im      -0.105152-0.0912676im     -0.275819-0.0462631im
  0.0367229+0.112833im   -0.0340672-0.0431676im    0.0485097-0.0766737im     0.0334354+0.281511im     0.0498094+0.220037im       -0.127722+0.104155im       -0.141987+0.239582im      0.0646068-0.0323274im    -0.0787689-0.107881im     -0.266678+0.0344246im   -0.0357007-0.0384718im    -0.0615804+0.0354425im    0.0965231-0.121787im     -0.128282+0.183588im    -0.0276158+0.0937323im    -0.100101-0.276784im     0.0692147-0.115474im       0.132743-0.143822im      -0.163059-0.0470579im    0.0413178-0.00763005im   0.0356247-0.0265656im     0.174292+0.0848447im     0.157438-0.0619597im    -0.174886-0.00836362im     0.0911666+0.152326im      0.134823-0.149926im        0.196323+0.0349517im      0.133375-0.0426711im    -0.266683+0.029261im      0.136344+0.00870813im    -0.136047+0.1466im        0.0661194-0.112412im
  0.0710755-0.0230218im    0.104721+0.194859im     -0.191761-0.281503im    -0.00470352+0.0639735im    0.0633059-0.088619im       -0.113134-0.00329665im     0.0641752+0.0297436im     0.0972667+0.0277945im     -0.074355+0.219774im     -0.133902-0.0734785im   -0.0431908-0.0642799im    -0.0887739+0.0166281im    -0.275442-0.0480032im   -0.0838841+0.0965069im     0.290864-0.0077821im     0.237118-0.119139im    -0.0118657+0.285457im    -0.00939166-0.0310901im     -0.135137+0.201924im     0.0562499+0.0480755im     0.143665-0.11324im      0.0996511-0.066993im      0.200519-0.102281im     -0.047265-0.202132im       -0.171592-0.0452113im   -0.0241548+0.12376im        0.0126292+0.0196635im    -0.0438283+0.00976236im    0.137762-0.0671919im   -0.0094073+0.218993im      0.0965258-0.0374994im     -0.133597-0.0750387im
 -0.0374601-0.0726088im   0.0643239-0.0631819im    -0.253349-0.00693925im    0.0610313-0.0498516im   -0.0492885+0.0605523im       0.105357+0.137447im      -0.0753063+0.296319im     -0.0940186-0.205792im     -0.0281706-0.109391im    -0.0728086+0.0805193im     0.290435+0.286198im     -0.0572127+0.187351im     0.0332278+0.175369im    -0.0221696-0.0430003im    0.0391586-0.0697459im     0.132103+0.0595191im   -0.0478131-0.104972im      -0.133912-0.0336136im     0.0720668-0.0316631im   0.00811907+0.101811im    -0.0312536-0.280467im      0.133982+0.0243124im     0.156608+0.34284im     0.00614118-0.199894im       0.0275103-0.143472im     0.0326663-0.0352286im     -0.0231999+0.056669im    -0.00148218+0.0599181im    0.0451375-0.0283242im    -0.230907-0.0698521im     0.0289569+0.116751im      0.0752112+0.0428631im
   0.207699-0.11733im      0.119662+0.18078im      0.0448779-0.229367im       0.158354+0.154209im     0.0109206+0.106719im       0.0811982+0.188058im      -0.0282766-0.170665im      0.0322615-0.06664im       -0.139352+0.0342899im  -0.00335934+0.0263127im      0.15005-0.198292im       0.195747+0.112861im       0.20502+0.109031im     0.0240338+0.0174227im    -0.249847+0.0224312im   -0.0136486+0.144132im     0.0213183+0.253391im     -0.0497114+0.208186im       0.115856+0.0354474im   -0.0872598-0.0311194im     0.177113+0.0150172im    0.0885667+0.0174872im   -0.0229343+0.106381im     -0.103118-0.00386379im    -0.0982432+0.126598im      0.212683-0.16001im        -0.140785-0.0124297im     -0.220768-0.0366664im    -0.158071+0.0412837im   -0.0385217-0.0799503im     0.0460614-0.153344im    -0.00375333-0.0900018im
  -0.019463+0.0822963im  -0.0216902-0.0394636im   -0.0427909+0.0637155im      0.154765+0.156477im     0.0430092-0.139602im         0.12116-0.0403425im      -0.244897-0.124356im      0.0212691-0.365781im       0.206894-0.10272im     -0.0650749-0.0279121im    0.0721621-0.0391554im     0.0614152-0.159994im     0.0510793+0.0228371im    0.0970706-0.0197151im   -0.0785267+0.161752im     0.0184667-0.133689im     -0.156693+0.303333im     0.00647867+0.102804im      -0.106752+0.101019im     0.0842797+0.156434im     -0.282208+0.117025im       0.21691+0.170953im    -0.0150284-0.0333859im    0.0874566-0.0434917im      0.0565165-0.229934im     -0.115805+0.112175im        0.119808-0.0994272im     0.0264165+0.0535863im   -0.0546208-0.0309031im     0.124824-0.109519im      0.0979014-0.0270814im     -0.131317+0.0375184im
   0.200082-0.0163493im   0.0558408+0.0415179im   -0.0692142-0.0478038im      0.109394+0.134042im     0.0885649-0.108824im       0.0923556+0.0260645im     -0.0527994-0.0394878im     -0.256792+0.135852im       0.129909+0.142265im     -0.139695+0.104471im    -0.0027154+0.0839613im    -0.0751857-0.104954im     0.0922513-0.106528im     -0.223935-0.287227im    -0.0087418+0.0535398im   -0.0810816+0.084563im    -0.0748372-0.0264402im     -0.144313-0.0878558im     0.0876341+0.0506908im   -0.0508907-0.0147im      -0.0484466+0.0692527im    -0.291126+0.225048im    -0.0801044+0.0871935im     -0.18069-0.206701im       0.0462241+0.147029im    -0.0785707-0.0384725im      0.0941902-0.119697im       0.204727-0.0402993im    -0.144479+0.0358746im   -0.0828739+0.287325im       0.118165-0.00502254im    -0.110931+0.154616im
 -0.0499847+0.0308643im   -0.164401-0.0809405im      0.12119+0.0578278im      0.302673-0.0648419im     0.174804+0.0164075im       0.105527+0.105732im      -0.0362297+0.0571178im     0.0572416+0.0740418im      0.142449-0.112931im     -0.177401-0.0834007im     0.115223+0.0889076im    -0.0248192-0.161131im    -0.0234376-0.124833im       0.19168-0.183954im    -0.0289264-0.137644im      0.203207-0.00712799im   0.0388796-0.26239im       0.0123004+0.190387im      -0.228669+0.0671749im   -0.0320633-0.139674im      0.191769-0.0171901im  -0.00372899-0.0148817im     0.102669-0.0741588im    0.0407738+0.0353292im      -0.113766-0.0421832im     0.173792-0.0474023im      -0.237939+0.0349484im     -0.149035-0.0182049im   -0.0655743-0.105472im      0.164744+0.15391im        0.134973+0.0612578im     -0.191628+0.15075im
  0.0230977+0.195739im    0.0274168-0.0329649im     0.096265-0.130052im      -0.183021-0.0375848im      0.13273+0.238831im       0.0805155+0.0467145im     -0.0145965-0.0248475im     -0.160496-0.0265262im      0.179495-0.0738966im     0.030017-0.0880986im     0.190892-0.147598im       0.100034-0.0177837im    -0.138912+0.0582316im    -0.131341+0.101994im     -0.124444-0.0203296im     -0.17478-0.00136044im     0.30229-0.0106489im     -0.137603+0.0486371im    -0.0165141+0.154287im     0.0460156-0.0615629im     0.232621-0.228075im     0.0203978+0.0124354im     0.142252+0.0227507im     0.316382+0.0456926im       0.136513-0.0210962im    -0.234622+0.0231414im      0.0531245-0.131857im       0.185849-0.0258948im    0.0325265+0.0149255im    0.0455466+0.0683055im     0.0654415-0.205533im     0.00123928+0.137403im
 -0.0184167+0.206468im    0.0803009-0.139798im     0.0458249-0.126751im     -0.0145008+0.0377973im    -0.185036+0.0186212im       0.258899+0.07742im      -0.00265543-0.101046im     -0.0784155+0.189433im       0.117508-0.0443268im     -0.17974-0.269559im     -0.121165+0.12739im       0.0786085+0.14124im      -0.078323-0.0248375im    -0.164892-0.183191im      0.137469-0.101125im      0.170802+0.102627im      -0.05692+0.0220959im     0.0659538+0.116009im      0.0569798-0.0695799im     0.107073-0.0798739im    -0.112601-0.0588555im     0.126498-0.190666im    0.00272579-0.165187im    -0.0604759-0.0299373im       0.032588+0.0871191im   -0.0918569-0.119828im        0.174561-0.287941im      -0.208788+0.0321406im   -0.0582942+0.105305im     0.0152937-0.198119im      0.0935896+0.0600312im      0.174967-0.0552221im
    0.16054-0.0904641im  -0.0376329-0.372838im      0.116553-0.105664im      -0.307456+0.0691174im    0.0281122-0.0755216im      -0.163727-0.0467101im      0.0950986+0.0756001im    -0.0100189-0.0529633im      0.378573+0.119003im      0.117931+0.226153im      0.212139+0.0443807im     0.0609678-0.10121im      0.0694831-0.0655631im    0.0137368+0.0122766im     0.103032+0.0486551im     0.119215+0.0570784im   -0.0604999+0.00010898im     0.108554+0.0794769im    -0.0161941+0.253466im     -0.153252+0.0481347im     0.023075-0.0134326im     0.202027-0.0623105im   -0.0866428-0.0248709im    0.0179975+0.0215556im        -0.1511+0.213189im     0.0399591+0.0282891im     -0.0261512-0.0632441im    -0.0612019-0.00867805im  -0.0951014+0.0924046im    -0.145576-0.0161012im     -0.137486+0.146024im     -0.0123494-0.00647572im
  0.0372733+0.162928im   -0.0968928-0.0985646im    -0.131462-0.103598im     -0.0774516-0.0609534im     0.161597-0.232766im     -0.00706766-0.151836im        0.103956+0.0896965im  -0.000923232-0.118838im     -0.0864769-0.0945926im    0.0877941+0.0342952im    -0.243469+0.030161im       0.111309+0.157599im      0.112805+0.0235918im    0.0133651-0.0175635im    -0.239956-0.2026im       0.0716927+0.0353998im     0.056912+0.268758im     -0.0288582+0.0394885im   -0.00998731-0.191111im    8.49575e-6-0.321973im        0.1536+0.0307929im    0.0924045+0.148876im      0.102567-0.0368575im    0.0327253-0.114951im        0.103266+0.145548im   -0.00085781+0.123514im       0.0110087+0.0417433im      0.028423+0.0679365im    0.0311336+0.138424im     0.0362382+0.0225141im   -0.00637484+0.336044im     -0.0802489+0.205043im
 -0.0290908-0.0754824im  -0.0635135+0.00596586im  -0.0489376-0.00310165im   -0.0906862+0.115142im     0.0389164-0.0239546im      -0.032135-0.0316922im      -0.116576+0.0846752im    0.00370111+0.0781035im    -0.0571124+0.270334im      0.118117-0.261804im      0.310053+0.193077im     -0.0831269-0.0691466im   -0.0536358+0.0541543im    0.0489657+0.0165717im   -0.0187357+0.0890959im    -0.177355-0.141327im     -0.145122+0.0291695im      0.187946+0.198384im      0.0835349-0.0686787im     0.377866-0.327896im     0.0176379-0.0720886im    0.0569921-0.00427045im   -0.161109-0.0791369im    -0.105182-0.0857199im       0.127603-0.0058283im   -0.0455492-0.118437im       -0.129225+0.136988im      0.0326051-0.106019im     0.0422348+0.184232im    -0.0272374-0.029969im     -0.0307845-0.0700551im     -0.114585+0.0885367im
  0.0659106-0.360533im   -0.0365984-0.189229im     0.0371917-0.208523im      0.0354787-0.177839im     0.0908374+0.0648073im     -0.0624324+0.0707783im      -0.199349-0.0092888im     0.0634356-0.01164im      -0.0370064+0.0886709im    0.0323669+0.0856249im   0.00178498-0.0509105im    -0.0215855-0.0683027im     0.090926-0.0751484im    -0.074962+0.0385641im   0.00283207-0.0623277im    -0.161009+0.0467164im    -0.136871+0.118053im      -0.051423+0.0580286im     -0.155696-0.173856im      0.168555-0.0957816im   -0.0715964-0.116544im     -0.111125-0.237947im     -0.090553+0.0166124im      0.15189-0.0197728im      -0.046133-0.0823097im     0.235807+0.0750997im       0.234129-0.141819im      0.0559302+0.154771im     0.0371169-0.146157im      0.161087+0.121612im       0.132075+0.0718776im      0.289491+0.121129im
   0.118519-0.151105im     0.175117+0.0297846im   -0.0485101-0.0318885im     0.0628307-0.188489im     0.0481794+0.120993im      -0.0196252-0.215754im      -0.0980691+0.0282004im     -0.101752+0.0171407im    0.00932375-0.156335im    -0.0355124-0.293054im      0.125341+0.0523423im    0.00561534+0.33274im        0.18167-0.094881im     0.0952526+0.113091im    -0.0498304+0.0273139im      0.14035+0.0450378im   -0.0352513+0.0851352im       0.13919-0.1216im        0.0610586+0.185888im    -0.0393941+0.102463im    -0.0722043+0.0182059im   -0.0449371+0.0437703im    -0.177407-0.214404im       0.14259+0.0605993im   -0.000415704+0.103411im     -0.028041-0.176967im      -0.0367718-0.025497im       0.168771-0.285702im      0.115712-0.196716im     0.0549295+0.0888198im     0.0424268+0.217613im     -0.0528946+0.017555im
  0.0365584+0.0569147im   -0.166041+0.00778287im  -0.0395538-0.0285483im       0.13051-0.159926im     -0.175647-0.0581003im      -0.029172-0.144922im      -0.0772881-0.262368im       0.053049-0.0618939im      0.204737+0.0714842im  -0.00393706+0.162188im    -0.0171972-0.0770203im      0.114508+0.0619128im   -0.0637752-0.161446im    -0.0674291+0.227134im      0.035891-0.137457im    -0.0313871+0.0329451im    0.0406938-0.21589im        0.103317+0.0180955im      0.256034-0.0282162im    0.0470363-0.186251im      0.082593+0.0531983im    0.0968172+0.0864338im    0.0239867-0.00903401im    0.118155-0.268932im      -0.0456335-0.256399im      0.117798-0.235333im        0.228884+0.140058im      0.0353787-0.0939245im   -0.0773692-0.0247802im    -0.153817+0.0462677im      0.110063+0.0179429im      -0.09026-0.179248im
  0.0275906+0.127105im    0.0496342-0.12804im     -0.0436094+0.0134759im      0.159872-0.190986im     -0.115485-0.0281411im     -0.0327356-0.0331983im       0.210356+0.0169117im      0.161291-0.0567377im  -0.000642322-0.135867im     0.0499587-0.137393im    -0.0412115-0.0802527im      0.195134-0.0791485im     0.132896+0.173951im   -0.00899224+0.0602907im     0.171809+0.253921im     -0.157568-0.0519983im    -0.107775-0.115011im       0.228819+0.132278im     -0.0381466+0.0879495im     0.137036+0.0165847im     0.203957-0.148311im      -0.17142+0.107776im    -0.0287016+0.295254im     -0.161381-0.0708069im      -0.100799+0.190327im    -0.0227999+0.144629im       0.0717753-0.163754im      0.0791552-0.0116217im    0.0829605-0.0200537im    0.0858678-0.0444827im      0.211137+0.097491im     -0.0838058-0.118459im
   0.181328+0.0152624im   0.0449586+0.173113im     0.0658062+0.0295284im    -0.0595158-0.110288im     0.0249529+0.0730195im     -0.0437758+0.192245im       0.0779943+0.144261im       0.140203-0.0130472im      0.229806-0.004663im      0.153932+0.0552246im    0.0582115+0.0274522im      0.155196+0.261829im     -0.137818-0.0970676im   -0.0252536-0.0532243im    0.0076836+0.310477im     0.0428632+0.0690589im    0.0331354+0.0217208im      0.222242-0.105373im       0.100664-0.100136im      0.104744+0.00649659im  -0.0553263+0.0942996im    -0.213603-0.0158166im     0.187891-0.166232im    -0.0318476-0.114152im        0.236269-0.162122im      0.158144+0.124095im       -0.115947-0.113639im     -0.0825517+0.207115im     -0.166676-0.116752im     0.0110673-0.0568997im    -0.0546449+0.01061im       -0.111185+0.155773im
   0.195941+0.143273im   -0.0127697-0.0897201im    -0.234315+0.0128909im    0.00276764-0.0260051im   -0.0888916-0.000441012im    -0.244816+0.0564655im      -0.111679-0.0235691im       0.10838-0.0579134im     -0.184024+0.111601im     0.0411884-0.0476im        0.103777-0.204445im       0.160383+0.0124489im    -0.186377+0.0272139im    -0.103012-0.316053im      0.054577-0.260483im     -0.122897+0.0963731im     0.096374-0.0496295im      0.198725+0.112158im      -0.131228-0.0403091im   -0.0290101+0.245572im     -0.167126+0.0686832im   -0.0485033+0.0333206im    0.0699178+0.0775501im    0.0857988+0.0428873im     -0.0560222-0.119444im     0.0185452-0.184301im       -0.120636-0.0965955im     0.0839975-0.151777im     0.0181907+0.194875im      0.120829+0.0354788im     -0.136745+0.138929im     -0.0174658+0.0992112im
   0.134608+0.0617587im   0.0776609-0.0579442im    0.0114938+0.009401im      -0.124121+0.0652086im  -0.00278462-0.277292im        0.172387-0.119241im      -0.0752646+0.197063im      0.0280024+0.196604im      0.0641276+0.103634im    -0.0350696-0.100282im    -0.0754102-0.12516im       -0.109894-0.102193im     -0.159493+0.233165im    0.00776891+0.164542im   -0.00750956+0.0442998im    -0.144274-0.00824976im  -0.0842454+0.0392092im     -0.010773-0.00515004im    0.0803211-0.23923im      -0.117622+0.141595im     0.0323987+0.0497102im    0.0982058-0.12594im       0.113766+0.11244im        0.12905+0.180901im       0.0169747+0.0317603im     0.141806-0.223916im        -0.12183-0.0212465im       0.10181+0.00796889im   -0.174302-0.274779im    -0.0938744-0.0626768im      0.276551+0.114159im      -0.160023+0.0532088im
   0.139323+0.0448623im  -0.0669959-0.0955917im   -0.0500825+0.10722im     0.000401413+0.293537im    -0.0824401-0.0308336im      0.0942628-0.105867im       -0.159577-0.175467im      -0.183111-0.0725985im    -0.0556284+0.119173im   -0.00554896+0.15696im      0.0163277-0.140432im    -0.00278702+0.345518im     -0.162978-0.194893im      0.280353+0.107594im      0.114789+0.0724579im    0.0480566-0.0301463im    -0.111629-0.131819im      0.0340293-0.0156962im    -0.0959114-0.0349034im     0.113798-0.0606275im     0.152707-0.0132929im    -0.102908+0.129297im      0.059041+0.0954764im   -0.0100477+0.0499535im      -0.149185+0.142677im     -0.131145-0.0482899im      -0.145957-0.0452562im     0.0185574+0.194964im      0.126295-0.109852im     0.0679041-0.111763im      0.0383737-0.01826im        0.232276+0.187527im
   0.192684-0.038778im     0.171737-0.168417im     0.0262653-0.172417im      -0.127472+0.0542544im    -0.173936-0.176457im       0.0852396+0.151006im      -0.0889538-0.0140691im     0.0271959+0.0945046im     -0.172461-0.185188im       0.10042+0.169254im     0.0448495+0.0997179im     -0.060861-0.0724274im   -0.0449112+0.0913244im     0.173757-0.131682im     -0.127775+0.0587623im     0.131707+0.0328099im     0.105791+0.00283342im     0.152495-0.0874691im     0.0575007+0.192698im       0.13198-0.275869im    -0.0385134+0.0964912im    -0.100423-0.010818im      0.179804+0.103486im     -0.033756+0.240477im        0.014144-0.192433im     -0.189934-0.0207879im       0.139828+0.124962im      0.0164096-0.0569171im   -0.0335867-0.100534im      0.137801+0.168308im      0.0344463+0.0438412im   -0.00012675-0.227491im

and then generate the state $ψ$

psi = P[:, 3]
32-element Vector{ComplexF64}:
   0.20083062431930104 + 0.17495124996959024im
   0.31303931029294496 + 0.0im
  -0.09547089050831285 - 0.18361453043574824im
 -0.059295393715591255 - 0.06708335891684847im
   0.09366043072573414 + 0.1275308686075144im
   0.10522562264274843 + 0.025270877923277868im
   0.10369725865981283 - 0.14021249833982996im
  -0.09224000619579767 - 0.0817968313280703im
  -0.14549665323755784 - 0.14285348481737378im
  0.002673699754090708 + 0.2121250298710035im
  -0.12224562019738537 + 0.08681003481299801im
  -0.14469803038174256 - 0.03730120478123651im
  -0.06912272899993205 + 0.12528727911150628im
   0.03102512766463031 - 0.10926506715929027im
  0.017221798781958057 + 0.1331985505357239im
   -0.2553165415186113 - 0.1773755873826438im
  -0.00249712436565171 - 0.05629945955519526im
   0.06922420786194654 - 0.013625161059723629im
   -0.1376213673765197 - 0.05734550030508342im
    0.1966879964445733 + 0.004128566786083171im
    0.2331407767983803 - 0.06035325714429984im
  0.012919515771804078 + 0.04203201892997858im
    0.0541747794792057 + 0.1913223414964953im
    0.0114545611494366 + 0.02419992480605683im
 -0.017181779172377586 + 0.020858041193034867im
   0.19228953789466238 - 0.1260367192292413im
   -0.1222491704558428 - 0.09512977047415344im
   -0.1296800876804865 + 0.09493179829716247im
  -0.19921020763817382 - 0.009204566775442291im
   -0.1489968745250475 + 0.23802490791873043im
  0.031543026635314435 + 0.09585871110862287im
   0.04394563385587985 - 0.122401956855718im

In the phase estimation process, we will feed the state to circuit and measure the first n qubits processed by iQFT.

r = join(ArrayReg(psi), zero_state(N))
r |> PE(N, M, U)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 8/8
    nlevel: 2

Since our phase can be represented by 3 qubits precisely, we only need to measure once

results = measure(r, 1:N; nshots=1)
1-element Vector{DitStr{2, 3, Int64}}:
 011 ₍₂₎

Recall that our QFT's bit numbering is reversed, let's reverse it back

using BitBasis
estimated_phase = bfloat(results[]; nbits=N)
0.75

the phase is exactly 0.75!


This page was generated using Literate.jl.