Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-08 Thread Romain Francois
On 02/07/2010 03:58 PM, [email protected] wrote: > > Yes. The new api is our current focus. > > You can find many real examples as part of our unit tests (in the "unitTests" > installed directory of the package). > > Some other examples in our blogs > > A draft article in the "papers" sub dir

Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-07 Thread Dirk Eddelbuettel
ginal Message- | From: Leo Alekseyev | Date: Sun, 7 Feb 2010 08:11:48 | To: Romain Francois | Cc: | Subject: Re: [Rcpp-devel] Handling NAs in RcppMatrix | | D'oh, I should have guessed it was an integer/double issue -- I | actually tried to check by testing something like c(1.0:2.2,NA), but

Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-07 Thread francoisromain
Original Message- From: Leo Alekseyev Date: Sun, 7 Feb 2010 08:11:48 To: Romain Francois Cc: Subject: Re: [Rcpp-devel] Handling NAs in RcppMatrix D'oh, I should have guessed it was an integer/double issue -- I actually tried to check by testing something like c(1.0:2.2,NA), but this of

Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-07 Thread Leo Alekseyev
D'oh, I should have guessed it was an integer/double issue -- I actually tried to check by testing something like c(1.0:2.2,NA), but this of course still produced an integer. So as a general question -- would you recommend using the new API (Rcpp::CharacterVector, Rcpp::NumericVector) over RcppMat

Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-07 Thread Romain Francois
I've logged this as a bug in Rcpp's bug tracker : https://r-forge.r-project.org/tracker/?atid=637&group_id=155&func=browse Romain On 02/07/2010 10:15 AM, Romain Francois wrote: > Hello, > > I think the problem is that c(1:2, NA) produces an __integer__ vector, > and RcppVector does not take care

Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-07 Thread Romain Francois
On 02/06/2010 11:56 PM, Leo Alekseyev wrote: > Howdy folks, [...] > > On a (probably) unrelated note, I get the following error when > compiling my C++ code: > Error in RcppCxx0xFlags() : could not find function "capture.output" > Calls: -> cat -> RcppCxx0xFlags I think I've fixed this in svn b

Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-07 Thread Romain Francois
Hello, I think the problem is that c(1:2, NA) produces an __integer__ vector, and RcppVector does not take care of coercion properly. > typeof( c(1:2,NA) ) [1] "integer" > typeof( c(1,2,NA) ) [1] "double" The "garbage value" you get I suppose is -2^31, which is how R represents NA for intege

Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-06 Thread Leo Alekseyev
The behavior I'm seeing is a bit bizarre. The NaN conversion seems to fail for RcppMatrix and RcppVector, but not for NumericVector. The most interesting bit is this: if I run the test code on e.g. c(NA,1,2), RcppVector works (NA is printed as nan), whereas if I use c(NA,1:2), instead of nan it p

Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-06 Thread Dirk Eddelbuettel
On 6 February 2010 at 22:08, Leo Alekseyev wrote: | Thanks for the response. Your new unit test runs, but I still see the | problem (running 0.7.4 installed from CRAN). Consider this version of | the test -- the only difference is that it uses a 2x2 matrix and | checks for NAs: | | test.RcppMat

Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-06 Thread Leo Alekseyev
Thanks for the response. Your new unit test runs, but I still see the problem (running 0.7.4 installed from CRAN). Consider this version of the test -- the only difference is that it uses a 2x2 matrix and checks for NAs: test.RcppMatrix.double.na <- function() { src <- 'RcppMatrix m(x);

Re: [Rcpp-devel] Handling NAs in RcppMatrix

2010-02-06 Thread Dirk Eddelbuettel
Hi Leo, On 6 February 2010 at 17:56, Leo Alekseyev wrote: | Howdy folks, | I started playing around with Rcpp recently, and so far haven't been | able to figure out how to detect NAs in a matrix that I pass to the | C++ code. | My test code looks something like this: | RcppExport SEXP rcpp_test(S

[Rcpp-devel] Handling NAs in RcppMatrix

2010-02-06 Thread Leo Alekseyev
Howdy folks, I started playing around with Rcpp recently, and so far haven't been able to figure out how to detect NAs in a matrix that I pass to the C++ code. My test code looks something like this: RcppExport SEXP rcpp_test(SEXP N1, SEXP V1, SEXP M1, SEXP parms) { ... RcppMatrix m1(M1);//