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

2014-11-26 Thread William Dunlap
uan Qiu > *Sent:* November 26, 2014 2:13 AM > *To:* David Shih > *Cc:* rcpp-devel@lists.r-forge.r-project.org > *Subject:* Re: [Rcpp-devel] Rcpp: Modification of input argument: > Undefined behaviour > > > Hello David, > The general answer to your question is, if the type

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

2014-11-26 Thread David Shih
2:13 AM To: David Shih Cc: rcpp-devel@lists.r-forge.r-project.org Subject: Re: [Rcpp-devel] Rcpp: Modification of input argument: Undefined behaviour Hello David, The general answer to your question is, if the type of your matrix (integer or numeric) in R is different from the one you declare in Rcpp,

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

2014-11-26 Thread Dirk Eddelbuettel
On 26 November 2014 at 02:13, Yixuan Qiu wrote: | Hello David, | The general answer to your question is, if the type of your matrix (integer or | numeric) in R is different from the one you declare in Rcpp, Rcpp will make a | copy and cast it to the appropriate type. Precisely. | For example,

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

2014-11-25 Thread Yixuan Qiu
Hello David, The general answer to your question is, if the type of your matrix (integer or numeric) in R is different from the one you declare in Rcpp, Rcpp will make a copy and cast it to the appropriate type. For example, 1:12 is of type integer, and if you pass it as a NumericMatrix, Rcpp will

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

2014-11-25 Thread David Shih
Hello, There was an earlier post on this subject, but based on my experimentation, the behaviour of modifying input argument is different depending on how the matrix was initialization and other factors... I wrote a Rcpp function to modify an input matrix. After calling this function, the inpu