<div dir="ltr">Hi, <div><br></div><div>When experimenting with the following toy function, </div><div><br></div><div><div>// [[Rcpp::export]]</div><div>void modify_matrix(NumericMatrix A){</div><div>  A(0, 0) = 5;</div><div>}</div></div><div><br></div><div>and applying this on matrices defined in R, I occasionally noticed unexpected behaviour (as it turns out, on integer matrices). <br></div><div><br></div><div>### Example 1 (works as expected)</div><div><br></div><div><div>A = matrix(0, 2, 2)</div><div>modify_matrix(A)</div><div>A</div><div><br></div><div>##      [,1] [,2]</div><div>## [1,]    5    0</div><div>## [2,]    0    0</div></div><div><br></div><div>### Example 2 (does not modify the matrix)</div><div><br></div><div><div>A = matrix(1:4, 2, 2)</div><div>modify_matrix(A)</div><div>A</div><div><br></div><div>##      [,1] [,2]</div><div>## [1,]    1    3</div><div>## [2,]    2    4</div></div><div><br></div><div>I realised that in the latter case, A consists of integers, so I guess I should be using an IntegerMatrix version of my function instead. However, shouldn't Rcpp detect the type mismatch between NumericMatrix and IntegerMatrix?</div><div><br></div><div>Best,</div><div>Kaspar</div><div><br></div></div>