Skip to content
Prev 8232 / 10988 Next

[Rcpp-devel] Rcpp: Modification of input argument: Undefined behaviour

Hi Yixuan,


You're right!


Whether the input matrix can be modified by a function that takes NumericMatrix is determined by whether the input matrix is a NumericMatrix or an IntegerMatrix (the latter needs to be copied and converted). The `mode()` function was pretty useless for determining a matrix object's type, but as at least `is.integer()` is predictive.


When I wrote another function that takes an IntegerMatrix, it was able to modify an input IntegerMatrix in-place.


Thank you,

David