[Rcpp-devel] Accessing matrix elements
Dirk Eddelbuettel
edd at debian.org
Sun May 15 00:31:01 CEST 2011
Hi Michael,
On 14 May 2011 at 18:00, Michael Braun wrote:
| Hi, Rcpp-friends:
|
| File this post under "rookie mistake, "educational illustration," or "feature request," but I noticed something in accessing elements from Rcpp matrices that I found somewhat curious. Consider the following code, for which the objective is just to print elements of a matrix.
Rookie mistake -- as
| cout << x[i,j] << " "; // Accessing element using square brackets
simply will not pass any C++ compiler despite whatever magic pixie Rcpp
sprinkles on top. There is no opeator[] that can take two arguments. So use
the round brackets, and rest assured that all other C++ Matrix classes I know
of do the same (e.g. Armadillo is always a good one to check.
Dirk
--
Gauss once played himself in a zero-sum game and won $50.
-- #11 at http://www.gaussfacts.com
More information about the Rcpp-devel
mailing list