-
Notifications
You must be signed in to change notification settings - Fork 12
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
Speedup with c++ using Rcpp #11
Comments
Yes! I just haven't gotten around to it. But absolutely yes, mpoly badly needs it. I think it's the right way to go, in mpoly, and the dependency is no problem.
This is great, please submit a PR and I'll look more. As you've correctly identified, |
Well, I haven't looked at I created the pull request with the Rcpp implementation. Again, there may be more room for enhancement of the C code itself, as I'm relatively new to cpp. |
hello guys, not sure of the etiquette here; I'm new to github. I've written a bare-bones R package, skimpy, which uses the the STL map class (actually it uses it twice, once for the variables in a single term, and once for the terms itself). It is at https://github.com/RobinHankin/skimpy.git and it's considerably faster than both multipol and spray. But I've not written a print method (mpoly's print method is wonderful) How to proceed? Robin |
Have you thought about implementing (the bulk of) the code using Rcpp (nice intro here)? As that's C++ code, it would be quite faster than the current implementation.
In my fork of the repo I rewrote the
mpoly
function, the main workhorse, and some mpoly arithmetic functions (*
and^
) using Rcpp. The code basically follows your algorithm almost exactly, just in C++. It is relatively straightforward to implement the current code (at least thempoly
function and arithmetic) in Rcpp, and the speed gains are 4-5 fold.I made a quick benchmark, which you can see here. The implementation is quite straightforward, so there may well be room for more optimization, as I'm not really an expert C++ coder.
I am making a package which would make use of (multivariate) Lagrange polynomial, so I'm using mpoly to generate the polynomial (the reduced polynomial that mpoly gives is easy to vectorize to give quick evaluation), and the number of collocation points, and thus the degree of the poly, can get quite high, so the speed of generation of the polynomial (the
mpoly
function being the main workhorse) is very important to me, so that brought me to try and implement it in Rcpp and the results have been satisfying for now.I'd love to hear what you have to say and where we could go from here. Maybe the package could go the Rcpp route (I don't know if you'd like to add another dependency?). Or perhaps I may, in parallel, work on the, let's say, "Rcppmpoly" package which focuses a bit more on speed?
Sorry for the long post :)
The text was updated successfully, but these errors were encountered: