phase_estimation: phase_estimation

Description Usage Arguments Examples

View source: R/phase_estimation.R

Description

phase estimation algorithm

Usage

1
phase_estimation(bitmask, FUN, x, ...)

Arguments

bitmask

integer. Vector of qubits for the t qubit wide register needed for the phase estimation

FUN

a function implementing the controlled application of a unitary operator U to the power 2^(j-1) to the state x. It's first argument must be the control qubit 'c', the second the integer 'j' and the third the state 'x'. Additional parameters can be passed via '...'.

x

a 'qstate' object

...

additional parameter to be passed on to 'FUN'

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## NOT^k = Id if k even
cnotwrapper <- function(c, j, x, t) {
  if(j == 1) return(CNOT(c(c, t)) * x)
  return(Id(t) * x)
}
x <- X(1) * qstate(3)
## X has eigenvalues lambda=1 and lambda=-1
## thus phases 0 and 1/2
x <- phase_estimation(bitmas=c(2:3), FUN=cnotwrapper, x=x, t=1)
x

qsimulatR documentation built on Jan. 13, 2021, 3:13 p.m.