[Rcpp-commits] r1890 - in pkg/RcppExamples: . src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jul 30 15:21:32 CEST 2010
Author: romain
Date: 2010-07-30 15:21:32 +0200 (Fri, 30 Jul 2010)
New Revision: 1890
Modified:
pkg/RcppExamples/DESCRIPTION
pkg/RcppExamples/src/RcppMatrixExample.cpp
Log:
disambiguate sqrt(double) and sqrt(float) .. for suncc
Modified: pkg/RcppExamples/DESCRIPTION
===================================================================
--- pkg/RcppExamples/DESCRIPTION 2010-07-30 12:11:52 UTC (rev 1889)
+++ pkg/RcppExamples/DESCRIPTION 2010-07-30 13:21:32 UTC (rev 1890)
@@ -1,6 +1,6 @@
Package: RcppExamples
Title: Examples using Rcpp to interface R and C++
-Version: 0.1.1
+Version: 0.1.1.1
Date: $Date$
Author: Dirk Eddelbuettel and Romain Francois, based on code written
during 2005 and 2006 by Dominick Samperi
Modified: pkg/RcppExamples/src/RcppMatrixExample.cpp
===================================================================
--- pkg/RcppExamples/src/RcppMatrixExample.cpp 2010-07-30 12:11:52 UTC (rev 1889)
+++ pkg/RcppExamples/src/RcppMatrixExample.cpp 2010-07-30 13:21:32 UTC (rev 1890)
@@ -24,6 +24,9 @@
#include <Rcpp.h>
#include <cmath>
+/* suncc needs help to disambiguate between sqrt( float ) and sqrt(double) */
+inline double sqrt_double( double x ){ return ::sqrt( x ) ; }
+
RcppExport SEXP newRcppMatrixExample(SEXP matrix) {
BEGIN_RCPP
@@ -34,7 +37,7 @@
// int n = mat.nrow(), k=mat.ncol();
// and loop over the elements, but using the STL is so much nicer
// so we use a STL transform() algorithm on each element
- std::transform(orig.begin(), orig.end(), mat.begin(), ::sqrt);
+ std::transform(orig.begin(), orig.end(), mat.begin(), sqrt_double );
return Rcpp::List::create(
Rcpp::Named( "result" ) = mat,
@@ -59,7 +62,7 @@
for (int i=0; i<n; i++) {
for (int j=0; j<k; j++) {
- mat(i,j) = sqrt(orig(i,j));
+ mat(i,j) = sqrt_double(orig(i,j));
}
}
More information about the Rcpp-commits
mailing list