R/dft.R

Defines functions dft

Documented in dft

#' Discrete Fourier Transform
#'
#' @param x real or complex vector
#' @param inverse logical, defaults to FALSE
#'
#' @useDynLib leeR dft_
#'
#' @export
#'
#' @return the DFT of x
dft <- function(x, inverse = FALSE) {
  # If inverse is true: 1, false: -1
  inverse <- ifelse(inverse, 1, -1)

  # Ensure the input is a complex number
  if (is.complex(x) == FALSE) {  x <- as.complex(x) }

  # Call the C-code with the DFT implementation
  a <- .Call("dft_", x, inverse, PACKAGE = "leeR")

  return(a)
}
leerichardson/leeR documentation built on May 21, 2019, 1:39 a.m.