On 10 December 2012 at 10:45, Douglas Bates wrote:
| On Mon, Dec 10, 2012 at 10:38 AM, Romain Francois <[email protected]>
| wrote:
|
| Le 10/12/12 17:29, Douglas Bates a écrit :
|
| or does it matter?
|
|
| A[i,j] is wrong, not valid C or C++ code. so there is only one choice.
No, it's worse, It is valid:
R> cppFunction("double val(Rcpp::NumericMatrix X) { return X[1,2]; }")
R> val(matrix(1:9,3,3))
[1] 3
R>
| Indeed. Thanks. Somehow I managed to convince myself that I had used A[i,j]
| at some point and the compiler accepted it. Apparently my memory isn't what
| it used to be.
.. but it is possibly the worst gotcha we can have in C++ and matrices as the
comma _is_ in fact a valid operator coming from C --- here though A[i,j] simply
collapses to A[j] with i being ignored as comma sequences the statements
around it.
Dirk
--
Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel