R/BELL.R

Defines functions BELL

Documented in BELL

#Bell gate on 4-dimensional ket
#' @export
BELL <- function(...){
	CNOT <- matrix(c(1,0,0,0, 0,1,0,0, 0,0,0,1, 0,0,1,0),nrow=4,ncol=4)
	H <- 1/2^.5 * matrix(c(1,1,1,-1),nrow=2,ncol=2)		#H gate
	I <- matrix(c(1,0,0,1),nrow=2,ncol=2)
	BELL <- CNOT %*% tensor(H,I)

	ket <- list(...)
	if(length(ket) == 0){
		BELL
	} else {
		BELL %*% ket[[1]]
	}
}

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.