R/sinc.R

`sinc` <-
function(X)
{
	# copy X to Y, so Y has same format as X
	Y <- X
	
	# find zero elements in X
	Z <- X == 0
	Y[Z] <- 1 # sinc(0) = 1
	Y[!Z] <- sin(pi*X[!Z]) / (pi*X[!Z]) # sinc(x) = sin(x)/x for x != 0
	
	return(Y)
}

Try the rdetools package in your browser

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

rdetools documentation built on May 2, 2019, 7:02 a.m.