[Rcpp-devel] Simple problem with modules

Hadley Wickham h.wickham at gmail.com
Fri Feb 22 16:11:41 CET 2013


Thanks for fix!
Hadley

On Thu, Feb 21, 2013 at 1:33 AM, Romain Francois
<romain at r-enthusiasts.com> wrote:
> Hello,
>
> I think this is about having
>
> const NumericVector& x_;
>
> In your class definition.
>
> It all works fine for me when I switch to
>
> NumericVector x_ ;
>
> and leave everything else unchanged.
>
>
> I'm not sure what the problem is though.
>
> Romain
>
> Le 20/02/13 22:14, Hadley Wickham a écrit :
>
>> I've attached a somewhat tweaked example which I think might indicate
>> that modules don't know about const NumericVector&?
>>
>>
>>> GroupFixed <- m$GroupFixed
>>
>>
>>> g <- GroupFixed$new(x, 0.1, 0)
>>
>>
>>> g$size()
>>
>> [1] 1
>>
>>> g$bin(1L)
>>
>> [1] 0
>>
>>> g$get(1L)
>>
>> [1] 6.953223e-310
>>
>>
>> The answers should be 8, 100 and 0.08075014 respectively.
>>
>> Hadley
>>
>>
>> On Wed, Feb 20, 2013 at 11:39 AM, Hadley Wickham <h.wickham at gmail.com>
>> wrote:
>>>
>>> Hi all,
>>>
>>> I'm having a simple problem with modules - when I instantiating the
>>> object and call the methods in C++, I get a different answer from
>>> instantiating and calling the methods in R via a module.  I've
>>> attached a simple test case that you can run with sourceCpp() - when I
>>> run it (using svn rev 4264 or CRAN version) I get 0 instead of 8. What
>>> am I doing wrong?
>>>
>>> Thanks!
>>>
>>> Hadley
>>>
>>> --
>>> Chief Scientist, RStudio
>>> http://had.co.nz/
>
>
> --
> Romain Francois
> Professional R Enthusiast
> +33(0) 6 28 91 30 30
>
> R Graph Gallery: http://gallery.r-enthusiasts.com
>
> blog:            http://romainfrancois.blog.free.fr
> |- http://bit.ly/14LJhmm : bibtex 0.3-5
> `- http://bit.ly/RE6sYH  : OOP with Rcpp modules
>
> _______________________________________________
> 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



-- 
Chief Scientist, RStudio
http://had.co.nz/


More information about the Rcpp-devel mailing list