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

Yan Zhou zhouyan at me.com
Wed Feb 20 02:48:42 CET 2013


On Feb 20, 2013, at 1:46 AM, Dirk Eddelbuettel <edd at debian.org> wrote:

> 
> On 20 February 2013 at 01:15, Yan Zhou wrote:
> | Hi Dirk,
> 
> I see nothing Rcpp-specific here.  It's more about how to avoid ambiguity
> within C++.  Might make a good question for the C++ tag on StackOverflow.
Yes, exactly. The problem itself is nothing Rcpp specific but the operator implementation was copied directly from Rcpp's proxy header. I will ask it on Stack later.
> 
> Dirk
> 
> | On Feb 20, 2013, at 1:11 AM, Dirk Eddelbuettel <edd at debian.org> wrote:
> | 
> | > 
> | > 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  
> | > _______________________________________________
> | > Rcpp-devel mailing list
> | > Rcpp-devel at lists.r-forge.r-project.org
> | > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
> | 
> 
> -- 
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  



More information about the Rcpp-devel mailing list