R/ket.R

Defines functions ket

Documented in ket

#generate a normalized ket (column vector) with arbitrary no of states
#' @export
ket <- function(...){
	coeff <- as.complex(list(...))
	if(Im(coeff[1]) > 0)
		coeff <- coeff / coeff[1]
	coeff <- coeff/sqrt(sum(abs(coeff)^2))
	if(Re(coeff[1]) < 0)
		coeff <- coeff * -1
	matrix(coeff,ncol=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.