-
Notifications
You must be signed in to change notification settings - Fork 12
Description
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 the mpoly 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 :)