New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Export fftw c++ methods for use in other packages #5
Comments
Hi, @jkennel, thanks. A pull request is of course welcome. In the meanwhile, I'll try to export and make sure the function generates expected results in the https://github.com/dipterix/ravetools/tree/test branch
|
Hi, @jkennel , sorry for the late reply. I was busy working on other projects these days so there is a delay on this issue. Currently I have exposed some C++ functions so that you can dynamically link to my package. I'll gradually release other functions (I have to test them to make sure they comply with the FFTW documentation and produce the correct results in most cases). Here are some examples to link those functions in C++ code: library(Rcpp)
# --- FFTW r2c ----------------
test_fftw_r2c <- cppFunction(
depends = "ravetools",
'SEXP test_fftw_r2c(SEXP data, int HermConj = 1, int fftwplanopt = 0, SEXP ret = R_NilValue) {
SEXP re = PROTECT(ravetools::fftw_r2c(data, HermConj, fftwplanopt, ret));
// Do something
UNPROTECT(1);
return re;
}')
data <- rnorm(1000)
ret <- complex(1000)
invisible(test_fftw_r2c(data, ret = ret))
ret
# --- Filter signals, agrees with Matlab filter function ----------
test_filter <- cppFunction(
depends = "ravetools",
'SEXP test(SEXP b, SEXP a, SEXP x, SEXP z) {
SEXP re = PROTECT(ravetools::cpp_filter(b, a, x, z));
// Do something
UNPROTECT(1);
return re;
}')
t <- seq(0, 1, by = 0.01)
x <- sin(2 * pi * t * 2.3)
bf <- signal::butter(2, c(0.15, 0.3))
test_filter(bf$b, bf$a, x, rep(0, 4)) I'm trying to update # Enable repository from dipterix
options(repos = c(
dipterix = 'https://dipterix.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
# Download and install ravetools in R
install.packages('ravetools') |
This is great! Thank you for all your efforts on this! |
I've been looking for some nice wrappers for fftw for quite some time and it looks like you have done a great job with it! I have a desire to use the functions inside of some C++ code and was wondering if you would be willing export them from your package. I could generate a pull request for this if you are interested. I followed the instructions here and it worked great. Thanks for the nice package!
The text was updated successfully, but these errors were encountered: