Uf {QuantumOps}R Documentation

Uf

Description

Generates an operator (oracle) of specified size that implements the function that is passed to it. Assumes there are n qubits in data register and m qubits in target register.

Usage

Uf(fun,n,m)

Arguments

fun

Function of an n-bit argument that produces an m-bit result

n

Integer that specifies the number of qubits in the data register, same as number of bits to function

m

Integer that specifies the number of qubits in the target register, same as number of bits as output of function

Value

Matrix of the operator (oracle) which implements the specified function)

Examples

 Uf(function(x){x - floor(x/2)*2},1,1)
 Uf(function(x){0},2,2)
 Uf(function(x){1},2,2)
 Uf(function(x){x - floor(x/4)*4},2,2)
 Uf(function(x){x^3},3,4)

[Package QuantumOps version 3.0.1 Index]