#' Find Powers
#'
#' @param N
#' @param f0
#' @param Nyq
#' @param prec
#'
#' @return
#' @export
#'
#' @examples
findPowers <- function(N,f0,Nyq,prec) {
if(N < 0){
stop("N must be greater than or equal to 0")
}
nFFT <- 1e30
low2 <- 0
high2 <- floor(log(N,2))+2
low3 <- 0
high3 <- floor(log(N,3))+2
low5 <- 0
high5 <- floor(log(N,5))+2
low7 <- 0
high7 <- floor(log(N,7))+2
for(i in low2:high2) {
for(j in low3:high3) {
for(k in low5:high5) {
for(l in low7:high7) {
att <- 2^i * 3^j * 5^k * 7^l
if((att > 2*N) & att < 100*N) {
df <- (Nyq*2)/att
if( abs(trunc(f0/df)*df - f0) < prec ) {
if(att < nFFT) {
nFFT <- att
}
}
} # big enough
} # end of 7
} # end of 5
} # end of 3
} # end of 2
if(nFFT == 1e30) {
return(-1)
} else {
return(nFFT)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.