Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
2016-08-14 James J Balamuta <balamut2@illinois.edu>

* inst/examples/FastLM/lmGSL.R: Updated example to use new GSL templates

2016-08-11 Dirk Eddelbuettel <edd@debian.org>

* .travis.yml: Switch to using run.sh for Travis CI
* .travis.yml: Switch to using run.sh for Travis CI

2016-08-09 Artem Klevtsov <a.a.klevtsov@gmail.com>

Expand Down
8 changes: 7 additions & 1 deletion inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
\code{RCPP_RETURN_MATRIX} macro when C++11 compiler used (Artem Klevtsov
in \ghpr{537} fixing \ghit{38}).
}
\item Changes in Rcpp build system
\itemize{
\item Travis CI is now driven via \code{run.sh} from our fork, and deploys
all packages as .deb binaries using our PPA where needed (Dirk in
\ghpr{540} addressing issue \ghit{517}).
}
\item Changes in Rcpp unit tests
\itemize{
\item New unit tests for random number generators the R namespace which
Expand All @@ -34,7 +40,7 @@
\itemize{
\item Examples that used cxxfunction() from the inline package have been
rewritten to use either sourceCpp() or cppFunction()
(James Balamuta in \ghpr{535}, \ghpr{534}, and \ghpr{532}
(James Balamuta in \ghpr{541}, \ghpr{535}, \ghpr{534}, and \ghpr{532}
addressing issue \ghit{56}).
}
}
Expand Down
27 changes: 12 additions & 15 deletions inst/examples/FastLM/lmGSL.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,18 @@ sourceCpp(code='
// [[Rcpp::export]]
Rcpp::List fun(Rcpp::NumericVector Yr, Rcpp::NumericMatrix Xr){

int i,j,n = Xr.nrow(), k = Xr.ncol();
int i, j, n = Xr.nrow(), k = Xr.ncol();
double chisq;

gsl_matrix *X = gsl_matrix_alloc (n, k);
gsl_vector *y = gsl_vector_alloc (n);
gsl_vector *c = gsl_vector_alloc (k);
gsl_matrix *cov = gsl_matrix_alloc (k, k);
RcppGSL::Matrix X(n, k); // allocate a gsl_matrix<double> of dim n, k
RcppGSL::Vector y(n); // allocate a gsl_vector<double> of length n
RcppGSL::Vector c(k); // allocate a gsl_vector<double> of length k
RcppGSL::Matrix cov(k, k); // allocate a gsl_matrix<double> of dim k, k

for (i = 0; i < n; i++) {
for (j = 0; j < k; j++)
gsl_matrix_set (X, i, j, Xr(i,j));
gsl_vector_set (y, i, Yr(i));
X(i, j) = Xr(i, j);
y[i] = Yr(i); // Note vector requires [] not ()
}

gsl_multifit_linear_workspace *work = gsl_multifit_linear_alloc (n, k);
Expand All @@ -105,17 +106,13 @@ Rcpp::List fun(Rcpp::NumericVector Yr, Rcpp::NumericMatrix Xr){

Rcpp::NumericVector coefr(k), stderrestr(k);
for (i = 0; i < k; i++) {
coefr(i) = gsl_vector_get(c,i);
stderrestr(i) = sqrt(gsl_matrix_get(cov,i,i));
coefr(i) = c[i];
stderrestr(i) = sqrt(cov(i,i));
}
gsl_matrix_free (X);
gsl_vector_free (y);
gsl_vector_free (c);
gsl_matrix_free (cov);


return Rcpp::List::create( Rcpp::Named( "coef", coefr),
Rcpp::Named( "stderr", stderrestr));
return Rcpp::List::create( Rcpp::Named("coef") = coefr,
Rcpp::Named("stderr") = stderrestr);
}')
fun
}