[Rcpp-commits] r1396 - in pkg/Rcpp: . inst inst/include/Rcpp/traits inst/unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jun 2 13:20:41 CEST 2010
Author: romain
Date: 2010-06-02 13:20:41 +0200 (Wed, 02 Jun 2010)
New Revision: 1396
Added:
pkg/Rcpp/inst/unitTests/runit.complex.R
Modified:
pkg/Rcpp/DESCRIPTION
pkg/Rcpp/NEWS
pkg/Rcpp/inst/ChangeLog
pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h
pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h
Log:
support for std::complex was not complete
Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION 2010-06-02 09:48:59 UTC (rev 1395)
+++ pkg/Rcpp/DESCRIPTION 2010-06-02 11:20:41 UTC (rev 1396)
@@ -1,6 +1,6 @@
Package: Rcpp
Title: Rcpp R/C++ interface package
-Version: 0.8.0.1
+Version: 0.8.0.2
Date: $Date$
Author: Dirk Eddelbuettel and Romain Francois, with contributions
by Simon Urbanek, David Reiss and Douglas Bates; based on code written during
Modified: pkg/Rcpp/NEWS
===================================================================
--- pkg/Rcpp/NEWS 2010-06-02 09:48:59 UTC (rev 1395)
+++ pkg/Rcpp/NEWS 2010-06-02 11:20:41 UTC (rev 1396)
@@ -26,6 +26,8 @@
cppfunction <- function(...) cxxfunction( ..., plugin = "Rcpp" )
+ o support for std::complex was incomplete
+
0.8.0 2010-05-17
o All Rcpp headers have been moved to the inst/include directory,
Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog 2010-06-02 09:48:59 UTC (rev 1395)
+++ pkg/Rcpp/inst/ChangeLog 2010-06-02 11:20:41 UTC (rev 1396)
@@ -1,5 +1,10 @@
2010-06-01 Romain Francois <romain at r-enthusiasts.com>
+ * inst/include/Rcpp/traits/r_type_traits.h: added missing support for
+ std::complex<double>, needed by RcppArmadillo
+
+2010-06-01 Romain Francois <romain at r-enthusiasts.com>
+
* inst/doc/Rcpp-package*: new mini vignette "Rcpp-package" to improve the
documentation of Rcpp.package.skeleton and details the steps involved in
making a package that uses Rcpp
Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h 2010-06-02 09:48:59 UTC (rev 1395)
+++ pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h 2010-06-02 11:20:41 UTC (rev 1396)
@@ -63,6 +63,11 @@
template<> struct r_sexptype_traits<rcpp_ulong_long_type>{ enum{ rtype = REALSXP } ; } ;
#endif
+/* std::complex */
+template<> struct r_sexptype_traits< std::complex<double> >{ enum{ rtype = CPLXSXP } ; } ;
+template<> struct r_sexptype_traits< std::complex<float> >{ enum{ rtype = CPLXSXP } ; } ;
+
+
/**
* Indicates if a primitive type needs a static_cast
*/
Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2010-06-02 09:48:59 UTC (rev 1395)
+++ pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2010-06-02 11:20:41 UTC (rev 1396)
@@ -113,6 +113,14 @@
template<> struct r_type_traits<unsigned short>{ typedef r_type_primitive_tag r_category ; } ;
template<> struct r_type_traits< std::pair<const std::string,unsigned short> >{ typedef r_type_primitive_tag r_category ; } ;
+/* std::complex<double> */
+template<> struct r_type_traits< std::complex<double> >{ typedef r_type_primitive_tag r_category ; } ;
+template<> struct r_type_traits< std::pair<const std::string,std::complex<double> > >{ typedef r_type_primitive_tag r_category ; } ;
+
+/* std::complex<float> */
+template<> struct r_type_traits< std::complex<float> >{ typedef r_type_primitive_tag r_category ; } ;
+template<> struct r_type_traits< std::pair<const std::string,std::complex<float> > >{ typedef r_type_primitive_tag r_category ; } ;
+
/* long long int */
#ifdef RCPP_HAS_LONG_LONG_TYPES
template<> struct r_type_traits<rcpp_long_long_type>{ typedef r_type_primitive_tag r_category ; } ;
Added: pkg/Rcpp/inst/unitTests/runit.complex.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.complex.R (rev 0)
+++ pkg/Rcpp/inst/unitTests/runit.complex.R 2010-06-02 11:20:41 UTC (rev 1396)
@@ -0,0 +1,35 @@
+#!/usr/bin/r -t
+#
+# Copyright (C) 2009 - 2010 Romain Francois
+#
+# This file is part of Rcpp.
+#
+# Rcpp is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Rcpp is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+test.vector.complex <- function(){
+
+ fx <- cxxfunction( signature() , '
+
+ std::vector< std::complex<double> > v_double(10) ;
+ std::vector< std::complex<float> > v_float(10) ;
+
+ return List::create( _["float"] = v_float, _["double"] = v_double ) ;
+
+ ', plugin = "Rcpp" )
+ checkEquals(
+ fx(),
+ list( float = rep(0+0i), double = rep(0+0i) ),
+ msg = "range wrap over std::complex" )
+}
+
More information about the Rcpp-commits
mailing list