R/unitary.R

Defines functions unitary

Documented in unitary

#check if matrix is unitary
#' @export
unitary <- function(m,epsilon=1e-13){
	i <- complex(1,0,1)
	#Inverse is equal to adjoint
	#all(solve(m) == adjoint(m)) #issues with precision prevent from working
	all(all(Re(solve(m)) > Re((adjoint(m)-epsilon)) 		) && 
		all(Re(solve(m)) < Re(adjoint(m)+epsilon) 			) && 
		all(Im(solve(m)) > Im((adjoint(m)-epsilon*i)) 		) && 
		all(Im(solve(m)) < Im(adjoint(m)+epsilon*i)  		)
		)
} 

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.