[Rcpp-devel] Constructor for templated Rcpp::Matrix class from Rcpp::Dimension fails

Romain Francois romain at r-enthusiasts.com
Mon Jun 6 13:49:02 CEST 2011


Le 02/06/11 12:10, romain at r-enthusiasts.com a écrit :
> Thanks.
>
> Making init protected instead of private in Vector.h solved it for me.
>
> I cant commit the fix from the eurostar.
>
> Romain

Done in rev 3046.

> Le 1 juin 2011 à 21:36, Douglas Bates<bates at stat.wisc.edu>  a écrit :
>
>> I am developing classes for sparse matrices with an Rcpp interface that includes
>>
>>     Rcpp::Dimension dim() const {return Rcpp::Dimension(nr(), nc());}
>>
>>     Rcpp::NumericMatrix     asmatrix() const;
>>
>> The implementation of the asmatrix method begins with
>>
>>     Rcpp::NumericMatrix ans(dim());
>>
>> which is a public constructor for the Rcpp::Matrix template but this
>> fails stating
>>
>>
>> In file included from
>> /home/bates/R/x86_64-unknown-linux-gnu-library/2.14/Rcpp/include/Rcpp/Vector.h:58:0,
>>                  from
>> /home/bates/R/x86_64-unknown-linux-gnu-library/2.14/Rcpp/include/Rcpp.h:42,
>>                  from RcppSparse.h:1,
>>                  from Module.cpp:1:
>> /home/bates/R/x86_64-unknown-linux-gnu-library/2.14/Rcpp/include/Rcpp/vector/Vector.h:
>> In constructor ‘Rcpp::Matrix<RTYPE>::Matrix(const Rcpp::Dimension&)
>> [with int RTYPE = 14]’:
>> RcppSparse.h:110:31:   instantiated from here
>> /home/bates/R/x86_64-unknown-linux-gnu-library/2.14/Rcpp/include/Rcpp/vector/Vector.h:640:7:
>> error: ‘void Rcpp::Vector<RTYPE>::init() [with int RTYPE = 14]’ is
>> private
>> /home/bates/R/x86_64-unknown-linux-gnu-library/2.14/Rcpp/include/Rcpp/vector/Matrix.h:49:3:
>> error: within this context
>> make: *** [Module.o] Error 1
>>
>> I can program around this problem by generating the
>> Rcpp::NumericMatrix from the number of rows and number of columns but
>> I would class the behavior of the constructor mentioned earlier as at
>> least an "infelicity" (to use Bill Venables' term).
>> _______________________________________________
>> 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
> _______________________________________________
> 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


-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
http://romain-francois.com
|- http://bit.ly/kaSV6U : Stand up set at Up The Creek
|- http://bit.ly/hdKhCy : Rcpp article in JSS
`- http://bit.ly/elZJRJ : Montpellier Comedie Club - Avril 2011




More information about the Rcpp-devel mailing list