R/nBitAddition.R

Defines functions nBitAddition

Documented in nBitAddition

#Generate a circuit for n-bit addition
#As from "Quantum full adder and subtractor" by Kai-Wen Cheng and Chien-Cheng Tseng
nBitAddition <- function(n){
	g <- list()
	for(j in 1:n){
		idx <- (j-1)*3
		g <- c(g, FullAdder(n=3*n+1,cin=idx,a=idx+1,b=idx+2,cout=idx+3))
	}
	g
}



#input ket must be
# C0 a1 b1 C1 a2 b2 C2 ... Cn
# And the C's must be 0
#thus the input ket is 3n+1 qubits

Try the QuantumOps package in your browser

Any scripts or data that you put into this service are public.

QuantumOps documentation built on Feb. 3, 2020, 5:07 p.m.