[Rcpp-devel] Efficient DataFrame access by row & column

Dirk Eddelbuettel edd at debian.org
Wed Feb 20 02:11:32 CET 2013


On 19 February 2013 at 23:46, Ken Williams wrote:
| > From: Dirk Eddelbuettel [mailto:edd at debian.org]
| > You are relying on an implicit conversion here to make df(.,.) a double. The
| > compiler tells you that it is trying sugar operators.  Sugar is good to have in
| > Rcpp, but occassionally there is a cost. This may be one of those times.
| >
| > Try
| >
| >       double a = df(j,i);
| >       double b = df(j,last_i);
| >         if (fabs(a - b) > thresh) {
| >
| > and see if that works.
| 
| Unfortunately no, I get a similar error when I try that:
| 
| window.cpp:68:24: error: conversion from 'Rcpp::Vector<19>::Proxy {aka Rcpp::internal::generic_proxy<19>}' to 'double' is ambiguous
| window.cpp:68:24: note: candidates are:
| C:/mybin/R/R-2.15.2/library/Rcpp/include/Rcpp/vector/string_proxy.h:273:4: note: Rcpp::internal::generic_proxy<RTYPE>::operator int() const [with int RTYPE = 19]
| C:/mybin/R/R-2.15.2/library/Rcpp/include/Rcpp/vector/string_proxy.h:272:4: note: Rcpp::internal::generic_proxy<RTYPE>::operator bool() const [with int RTYPE = 19]
| C:/mybin/R/R-2.15.2/library/Rcpp/include/Rcpp/vector/string_proxy.h:267:26: note: Rcpp::internal::generic_proxy<RTYPE>::operator U() const [with U = double, int RTYPE = 19]

Maybe try std::fabs() instead of fabs() ?

That is one of the reasons I do not like a global 'using namespace Rcpp' in
my code.  Explicit namespaces are, well, explicit.

Dirk
| 
| 
| >
| > Not every conceivable operation is implemented in Rcpp,
| 
| Of course. =)
| 
| > but we are always
| > open to patches to make it more complete.
| 
| If I can get myself up to speed with my understanding, I'll be happy to contribute what I can.
| 
|  -Ken
| 
| ________________________________
| 
| CONFIDENTIALITY NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of any kind is strictly prohibited. If you are not the intended recipient, please contact the sender via reply e-mail and destroy all copies of the original message. Thank you.

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  


More information about the Rcpp-devel mailing list