[Phylobase-devl] New phylobase build approach using static libncl (Was: Rcpp and OS X compiliation)
Dirk Eddelbuettel
edd at debian.org
Wed Mar 3 23:46:15 CET 2010
On 3 March 2010 at 13:50, Peter Cowan wrote:
| > After 'svn up' I get a rather clean 'R CMD check' with only a few warnings
| > about edge() shadowing a function ape::edge().
|
| Yes this is known, unfortunately APE added an edge function for plots in the latest version. Soon, there won't actually be a dependency on APE, but perhaps there's also a NAMESPACE way for dealing with this...
Right.
| > Looking good. If I can help with the C++ interfacing let me know. If Brian
| > and Derrick want some comments on the two interface functions I'd be glad to
| > help. Otherwise, if you folks want to keep it as is as it is working that is
| > cool too.
|
| Would you my expounding on this a bit? I confess ignorance. Are the
| interface functions you're referring to in Rcpp or phylobase?
"In between" :) I don't want to come across as to lecturing but Romain and I
have made Rcpp a lot easier to use, and the existing functions here still
reflect what we now refer to as the 'old API'.
We have a just-submitted paper in our SVN which I may as well attach that
expounds a little on that, and I am currently giving some talks on this too
(see my website under bio->presentations) and there will be more once I talk
at UCLA on March 30).
| I'm always eager to hear how things can be improved, though "working" does sound
| pretty great!
I can promise not to break things (where unit tests help), but I also don't
want to gratuitously commit code over somebody else's code -- hence my call
for 'if Brian and Derrick are interested'. I'd be happy to take it offline
with you too, of course.
Paper attached, comments will as always be appreciated.
Oh, and while I am at it, my current favourite of how to do lm() really fast
if you must using the Armadillo linear algebra library (for which we have a
tiny bit of C++ glue in a package RcppArmadillo that will be on CRAN
"shortly" and is working as-is from Rcpp's R-Forge SVN). The is the actual
code, I just removed to #if / #endif blocks due to different Armadillo versions
extern "C" SEXP fastLm(SEXP sy, SEXP sX) {
Rcpp::NumericVector yr(sy);
Rcpp::NumericMatrix Xr(sX);
int n = Xr.nrow(), k = Xr.ncol() ;
arma::mat X(Xr.begin(), n, k, false); // reuses memory and avoids extra copy
arma::colvec y(yr.begin(), yr.size());
arma::colvec coef = solve(X, y); // fit model y ~ X
arma::colvec resid = y - X*coef;
double sig2 = arma::as_scalar( trans(resid)*resid/(n-k) );
arma::colvec stderrest = sqrt( sig2 * diagvec( arma::inv(arma::trans(X)*X)) );
Rcpp::Pairlist res(Rcpp::Named( "coef", coef),
Rcpp::Named( "stderr", stderrest));
return res;
}
That gives you a list in R with two named elements 'coef' and 'stderr'.
Cheers, Dirk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RJwrapper.pdf
Type: application/pdf
Size: 162091 bytes
Desc: not available
Url : http://lists.r-forge.r-project.org/pipermail/phylobase-devl/attachments/20100303/1fad7b14/attachment-0001.pdf
-------------- next part --------------
--
Registration is open for the 2nd International conference R / Finance 2010
See http://www.RinFinance.com for details, and see you in Chicago in April!
More information about the Phylobase-devl
mailing list