Skip to content
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

Rewrite dynamic programming routine in C++ #1

Open
huisaddison opened this issue Jul 1, 2023 · 0 comments
Open

Rewrite dynamic programming routine in C++ #1

huisaddison opened this issue Jul 1, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@huisaddison
Copy link
Contributor

Ryan’s C implementation is included as-is. In order for C++ code in other packages to use the C implementation, it must be exported by Rcpp using the // [[Rcpp::export]] attribute. This directs Rcpp to build the necessary header files, which are made available to other R packages via “LinkingTo”.

However Rcpp doesn't play well with points as function parameters (it needs to map each parameter to its R equivalent, and doesn't know what to do with pointers). This doesn’t work even if we ask only for a C++ interface (i.e., using the Rcpp::interfaces attribute).

Solution: Rewrite tf_dp.c to use modern C++ structures (i.e., vectors and reference semantics), and make that available through an Rcpp header. This is the preferred solution (and can be implemented without changing the R frontend).

Alternative solution: Leave the implementation as-is and distribute a copy of the C code with each R package that requires it (e.g., trendfilter).

@huisaddison huisaddison added the enhancement New feature or request label Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant