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 29, 2017, 8:50 p.m.