[Rcpp-devel] Picking off a matrix-valued list element inside a class constructor?
Michael Hannon
jm_hannon at yahoo.com
Tue Oct 25 00:56:52 CEST 2011
Thanks, Darren. That worked well.
-- Mike
>________________________________
>From: Darren Cook <darren at dcook.org>
>To: rcpp-devel at r-forge.wu-wien.ac.at
>Sent: Sunday, October 23, 2011 1:20 AM
>Subject: Re: [Rcpp-devel] Picking off a matrix-valued list element inside a class constructor?
>
>> Rcpp::IntegerMatrix m = l["m"];;
>> ...
>> This seems to work just fine.
>> ... the seemingly equivalent statement in the body of a class
>> constructor fails with a compilation error:
>> ...
>> CCC(Rcpp::List l){
>> m = l["m"];
>> }
>
>
>In C++, the left side can sometimes give a hint about how the right-side
>should be interpreted. When I changed the constructor body to this it
>worked:
> Rcpp::IntegerMatrix tmp=l["m"];
> m = tmp;
>
>I tried a few ideas to get a one-liner that does the same... and
>couldn't; perhaps someone else knows the magic syntax?
>
>(For reference these were what I tried:
> m =Rcpp::IntegerMatrix(l["m"]);
> m =(Rcpp::IntegerMatrix)l["m"];
> m.operator=<Rcpp::IntegerMatrix>(l["m"]);
>)
>
>> [...]
>> private:
>> Rcpp::IntegerMatrix m;
>> } <-- NEED SEMI-COLON HERE
>> '
>
>BTW, you are missing a semi-colon after the closing bracket for your class.
>
>Darren
>
>--
>Darren Cook, Software Researcher/Developer
>
>http://dcook.org/work/ (About me and my work)
>http://dcook.org/blogs.html (My blogs and articles)
>_______________________________________________
>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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20111024/f0ac8db9/attachment.htm>
More information about the Rcpp-devel
mailing list