Hi,

For a matrix, the size intuitively should be just nrow * ncol. Hence,
it is reasonable to call size(). But the following code gives errors,
because two parent class all have the size() member function. Should
something be done to make one of them available to NumericMatrix?

suppressPackageStartupMessages(library(inline))
src='
Rcpp::NumericMatrix x(mx);
return wrap(x.size());
'
fun=cxxfunction(signature(mx="numeric"), src,
  plugin="Rcpp")
orig=matrix(1:6, 2, 3)
fun(orig)


Error in compileCode(f, code, language = language, verbose = verbose) :
  Compilation ERROR, function(s)/method(s) not created!
file3b8313201138.cpp: In function ‘SEXPREC*
file3b8313201138(SEXPREC*)’:
file3b8313201138.cpp:32: error: request for member ‘size’ is ambiguous
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/vector/MatrixBase.h:46:
error: candidates are: int Rcpp::MatrixBase<RTYPE, na, MATRIX>::size()
const [with int RTYPE = 14, bool na = true, MATRIX = Rcpp::Matrix<14>]
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/vector/Vector.h:275:
error:                 R_len_t Rcpp::Vector<RTYPE>::size() const [with
int RTYPE = 14]
make: *** [file3b8313201138.o] Error 1
Calls: cxxfunction -> compileCode
Execution halted


-- 
Regards,
Peng
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to