[Rcpp-devel] replacing a splines ns() call with other Rcpp attached library function
SILKWODJ at airproducts.com
Fri Jun 29 13:18:04 CEST 2012
With respect to replies:
> a) fit a decent, modern, documented C++ implementation of what is needed
Yes, this was the question. Can anyone help? I am failing right here.
> and of course if a) fails, one can always 'rip out' what is underneath a
> known R function and use that as a fallback.
This is where I am. I can easily (I think) 'rip out' kind Douglas Bate's two C functions:
/* Exports */
SEXP spline_basis(SEXP knots, SEXP order, SEXP xvals, SEXP derivs);
SEXP spline_value(SEXP knots, SEXP coeff, SEXP order, SEXP x, SEXP deriv);
By initially just placing the entire contents of splines.c in the inline header for testing.
The challenge now is to send one or both of these the correct arguments, and somehow come up with an order (3 for the cubic spline) by length(xvals) matrix from what appears to be individual vectors returning from calls here.
Since the entire topic of the boor algorithm is new to me just this week this remains a daunting challenge. I plan to single step through the R code of ns() and splineDesign(), which it calls, just to see what args are what and what return objects are what.
We just can't stand for code in the middle of a double loop to go to R just to get all the "boiler-plate" of the R code in ns(). We need to know how to call spline_basis directly with confidence.
I'm just looking to get one function to work for one problem. No thought at this time of actually attempting something like building an "Rf_ns" function to bind into Rcpp.
I suppose if one were to go that far, after understanding what I must, Davor's black art method might be interesting. But that is a long way off from where I stand today. We can rip code into one thesis project and be done I hope.
More information about the Rcpp-devel