[Rcpp-devel] Bug with table sugar and NumericVector in Rcpp 0.10.3
Romain Francois
romain at r-enthusiasts.com
Tue Apr 2 16:36:47 CEST 2013
Le 29/03/13 16:37, Dirk Eddelbuettel a écrit :
>
> On 29 March 2013 at 16:20, romain at r-enthusiasts.com wrote:
> | Cool. I'll have a look when I'm back from easter weekend.
>
> Sounds good.
>
> And that point, it would be really nice if you could also restore the ability
> to build Rcpp, which appears to have broken with your Data.Frame patch.
>
> Details are below.
Should be back up now. With new versions of DataFrame::create that work
better.
> Dirk
>
> edd at max:~/svn/rcpp/pkg$ R CMD build Rcpp
> * checking for file ‘Rcpp/DESCRIPTION’ ... OK
> * preparing ‘Rcpp’:
> * checking DESCRIPTION meta-information ... OK
> * cleaning src
> * running ‘cleanup’
> * installing the package to process help pages
> -----------------------------------
> * installing *source* package ‘Rcpp’ ...
> ** libs
> ccache g++-4.7 -I/usr/share/R/include -DNDEBUG -I../inst/include/ -fpic -g0 -O3 -Wall -pipe -Wno-variadic-macros -pedantic -c Date.cpp -o Date.o
> ccache g++-4.7 -I/usr/share/R/include -DNDEBUG -I../inst/include/ -fpic -g0 -O3 -Wall -pipe -Wno-variadic-macros -pedantic -c Module.cpp -o Module.o
> In file included from ../inst/include/RcppCommon.h:102:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/Named.h: In instantiation of ‘Rcpp::traits::named_object<SEXPREC*> Rcpp::Argument::operator=(const T&) [with T = int]’:
> Module.cpp:40:128: required from here
> ../inst/include/Rcpp/Named.h:34:52: error: ‘wrap’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
> In file included from ../inst/include/RcppCommon.h:117:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/internal/wrap.h:902:13: note: ‘template<class InputIterator> SEXPREC* Rcpp::wrap(InputIterator, InputIterator)’ declared here, later in the translation unit
> In file included from ../inst/include/RcppCommon.h:102:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/Named.h: In instantiation of ‘Rcpp::traits::named_object<SEXPREC*> Rcpp::Argument::operator=(const T&) [with T = char [5]]’:
> Module.cpp:40:146: required from here
> ../inst/include/Rcpp/Named.h:34:52: error: ‘wrap’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
> In file included from ../inst/include/RcppCommon.h:117:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/internal/wrap.h:902:13: note: ‘template<class InputIterator> SEXPREC* Rcpp::wrap(InputIterator, InputIterator)’ declared here, later in the translation unit
> In file included from ../inst/include/RcppCommon.h:102:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/Named.h: In instantiation of ‘Rcpp::traits::named_object<SEXPREC*> Rcpp::Argument::operator=(const T&) [with T = char [12]]’:
> Module.cpp:52:127: required from here
> ../inst/include/Rcpp/Named.h:34:52: error: ‘wrap’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
> In file included from ../inst/include/RcppCommon.h:117:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/internal/wrap.h:902:13: note: ‘template<class InputIterator> SEXPREC* Rcpp::wrap(InputIterator, InputIterator)’ declared here, later in the translation unit
> In file included from ../inst/include/RcppCommon.h:102:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/Named.h: In instantiation of ‘Rcpp::traits::named_object<SEXPREC*> Rcpp::Argument::operator=(const T&) [with T = char [15]]’:
> Module.cpp:61:133: required from here
> ../inst/include/Rcpp/Named.h:34:52: error: ‘wrap’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
> In file included from ../inst/include/RcppCommon.h:117:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/internal/wrap.h:902:13: note: ‘template<class InputIterator> SEXPREC* Rcpp::wrap(InputIterator, InputIterator)’ declared here, later in the translation unit
> In file included from ../inst/include/RcppCommon.h:102:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/Named.h: In instantiation of ‘Rcpp::traits::named_object<SEXPREC*> Rcpp::Argument::operator=(const T&) [with T = char [22]]’:
> Module.cpp:67:133: required from here
> ../inst/include/Rcpp/Named.h:34:52: error: ‘wrap’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
> In file included from ../inst/include/RcppCommon.h:117:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/internal/wrap.h:902:13: note: ‘template<class InputIterator> SEXPREC* Rcpp::wrap(InputIterator, InputIterator)’ declared here, later in the translation unit
> In file included from ../inst/include/RcppCommon.h:102:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/Named.h: In instantiation of ‘Rcpp::traits::named_object<SEXPREC*> Rcpp::Argument::operator=(const T&) [with T = char [11]]’:
> Module.cpp:73:142: required from here
> ../inst/include/Rcpp/Named.h:34:52: error: ‘wrap’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
> In file included from ../inst/include/RcppCommon.h:117:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/internal/wrap.h:902:13: note: ‘template<class InputIterator> SEXPREC* Rcpp::wrap(InputIterator, InputIterator)’ declared here, later in the translation unit
> In file included from ../inst/include/RcppCommon.h:102:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/Named.h: In instantiation of ‘Rcpp::traits::named_object<SEXPREC*> Rcpp::Argument::operator=(const T&) [with T = char [20]]’:
> Module.cpp:77:139: required from here
> ../inst/include/Rcpp/Named.h:34:52: error: ‘wrap’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
> In file included from ../inst/include/RcppCommon.h:117:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/internal/wrap.h:902:13: note: ‘template<class InputIterator> SEXPREC* Rcpp::wrap(InputIterator, InputIterator)’ declared here, later in the translation unit
> In file included from ../inst/include/RcppCommon.h:102:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/Named.h: In instantiation of ‘Rcpp::traits::named_object<SEXPREC*> Rcpp::Argument::operator=(const T&) [with T = SEXPREC*]’:
> Module.cpp:265:50: required from here
> ../inst/include/Rcpp/Named.h:34:52: error: ‘wrap’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
> In file included from ../inst/include/RcppCommon.h:117:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/internal/wrap.h:902:13: note: ‘template<class InputIterator> SEXPREC* Rcpp::wrap(InputIterator, InputIterator)’ declared here, later in the translation unit
> In file included from ../inst/include/RcppCommon.h:102:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/Named.h: In instantiation of ‘Rcpp::traits::named_object<SEXPREC*> Rcpp::Argument::operator=(const T&) [with T = bool]’:
> Module.cpp:266:39: required from here
> ../inst/include/Rcpp/Named.h:34:52: error: ‘wrap’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
> In file included from ../inst/include/RcppCommon.h:117:0,
> from ../inst/include/Rcpp.h:27,
> from Module.cpp:22:
> ../inst/include/Rcpp/internal/wrap.h:902:13: note: ‘template<class InputIterator> SEXPREC* Rcpp::wrap(InputIterator, InputIterator)’ declared here, later in the translation unit
> make: *** [Module.o] Error 1
> ERROR: compilation failed for package ‘Rcpp’
> * removing ‘/tmp/RtmpfejSO9/Rinst312b332a9a19/Rcpp’
> -----------------------------------
> ERROR: package installation failed
> edd at max:~/svn/rcpp/pkg$
> |
> | Romain
> |
> | Le 2013-03-29 16:00, Dirk Eddelbuettel a écrit :
> | > On 29 March 2013 at 09:40, Dirk Eddelbuettel wrote:
> | > |
> | > | On 29 March 2013 at 15:24, romain at r-enthusiasts.com wrote:
> | > | | Le 2013-03-29 14:31, Dirk Eddelbuettel a écrit :
> | > | | > On 29 March 2013 at 09:11, romain at r-enthusiasts.com wrote:
> | > | | > |
> | > | | > | Hello,
> | > | | > |
> | > | | > | This is related to this change:
> | > | | > |
> | > | | > | 2013-01-15 Dirk Eddelbuettel <edd at debian.org>
> | > | | > |
> | > | | > | * src/api.cpp (Rcpp): Commented-out coerce_to_string() for
> | > real
> | > | | > and
> | > | | > | complex arguments as R-devel (as of today) dislikes use of
> | > non-API
> | > | | > | functions Rf_EncodeComplex’, ‘Rf_EncodeReal’,
> | > ‘Rf_formatComplex’
> | > | | > |
> | > | | > | So maybe Dirk has a plan to fix it.
> | > | | >
> | > | | > I do not.
> | > | |
> | > | | Fine. So I'll fix it.
> | > |
> | > | Hold on.
> | > |
> | > | I am in the middle of it. I do have a poor replacementment for
> | > EncodeReal,
> | > | and am about to test one for complex. Will post soon.
> | > |
> | > | Am not covering scientific notation at this point.
> | >
> | > Ok, here replacement candidates. Kudos to Kevin for sending
> | > something
> | > reproducible that triggered this. This snipped below grew from his
> | > code and
> | > provids replacement candidates for coerce_to_string() for the real
> | > and
> | > complex cases, not using the internal R functions (which I also did
> | > not look
> | > at). Obviously the function headers need to change from the sample
> | > to what
> | > api.cpp uses.
> | >
> | > What we get is simple snprintf() calls which almost surely is less
> | > featureful
> | > than what R has, but please complaon to R Core about the sillyness of
> | > us not
> | > being able to use _existing and tested functions_. It's painful.
> | >
> | >
> | > Dirk
> | >
> | > #include <Rcpp.h>
> | >
> | > static const char* dropTrailing0(char *s, char cdec) {
> | > /* Note that 's' is modified */
> | > char *p = s;
> | > for (p = s; *p; p++) {
> | > if(*p == cdec) {
> | > char *replace = p++;
> | > while ('0' <= *p && *p <= '9')
> | > if(*(p++) != '0')
> | > replace = p;
> | > if(replace != p)
> | > while((*(replace++) = *(p++)))
> | > ;
> | > break;
> | > }
> | > }
> | > return s;
> | > }
> | >
> | > //template <>
> | > // const char* coerce_to_string/*<REALSXP>*/(double x){
> | > // [[Rcpp::export]]
> | > const char* coerce_to_stringRE(double x){
> | > int w,d,e ;
> | > // cf src/main/format.c in R's sources:
> | > // The return values are
> | > // w : the required field width
> | > // d : use %w.df in fixed format, %#w.de in scientific format
> | > // e : use scientific format if != 0, value is number of exp
> | > digits - 1
> | > //
> | > // nsmall specifies the minimum number of decimal digits in
> | > fixed format:
> | > // it is 0 except when called from do_format.
> | > Rf_formatReal( &x, 1, &w, &d, &e, 0 ) ;
> | > // we are no longer allowed to use this:
> | > // char* tmp = const_cast<char*>( Rf_EncodeReal(x, w, d, e,
> | > '.') );
> | > // so approximate it poorly as
> | > char tmp[128];
> | > snprintf(tmp, 127, "%*.*f", w, d, x);
> | > //Rcpp::Rcout << "Vec is " << vec << std::endl;
> | > return dropTrailing0(tmp, '.');
> | >
> | > }
> | >
> | > //template <>
> | > //const char* coerce_to_string/*<CPLXSXP>*/(Rcomplex x){
> | > // [[Rcpp::export]]
> | > std::string coerce_to_stringCP(Rcomplex x){
> | > int wr, dr, er, wi, di, ei;
> | > // cf src/main/format.c in R's sources:
> | > Rf_formatComplex(&x, 1, &wr, &dr, &er, &wi, &di, &ei, 0);
> | > //return Rf_EncodeComplex(x, wr, dr, er, wi, di, ei, '.' );
> | >
> | > // we are no longer allowed to use this:
> | > // Rf_EncodeComplex(x, wr, dr, er, wi, di, ei, '.' );
> | > // so approximate it poorly as
> | > char tmp[128];
> | > snprintf(tmp, 127, "%*.*f+%*.*fi", wr, dr, x.r, wi, di, x.i);
> | > return std::string(tmp); // force a copy
> | > }
> | >
> | > using namespace Rcpp;
> | >
> | > // // [[Rcpp::export]]
> | > // IntegerVector counts(NumericVector x) {
> | > // return table(x);
> | > // }
> |
>
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
R Graph Gallery: http://gallery.r-enthusiasts.com
blog: http://blog.r-enthusiasts.com
|- http://bit.ly/ZTFLDo : Simpler R help tooltips
`- http://bit.ly/YFsziW : R Help tooltips
More information about the Rcpp-devel
mailing list