Re: [Rcpp-devel] Rcpp catching a domain error

2014-12-12 Thread Qiang Kou
Hi, Devin, You may misunderstand NaN. NaN is a special floating number. It doesn't equal to anything, even itself. If x is NaN, x == x will return false. Actually this is a trick to detect whether it is NaN or not. However, there is a standard way to handle it, using isnan [1]. Try the code below

Re: [Rcpp-devel] Rcpp catching a domain error

2014-12-12 Thread Dirk Eddelbuettel
On 12 December 2014 at 10:09, Devin wrote: | ... but you can't set a mathematical operation equal to a string. I also tried: | | int test() | { | gsl_set_error_handler_off(); | if(gsl_sf_hyperg_2F1(1,1,1.1467003,1) == NAN){ | std::cout << "Error" << std::endl; | } | retur

Re: [Rcpp-devel] Rcpp catching a domain error

2014-12-12 Thread Devin
-branch? I appreciate your input! Devin -Original Message- From: Dirk Eddelbuettel [mailto:e...@debian.org] Sent: Thursday, December 11, 2014 4:36 PM To: Qiang Kou Cc: Devin; rcpp-devel@lists.r-forge.r-project.org Subject: Re: [Rcpp-devel] Rcpp catching a domain error Hi there, On 11 Dec

Re: [Rcpp-devel] Rcpp catching a domain error

2014-12-11 Thread Qiang Kou
Of course, if you think it is necessary. I met a very similar problem about one year ago. GSL is a pure C library, and try/catch is something in C++. Best, KK On Thu, Dec 11, 2014 at 10:36 AM, Dirk Eddelbuettel wrote: > > > Qiang, how about wrapping ten lines of context around > it and making

Re: [Rcpp-devel] Rcpp catching a domain error

2014-12-11 Thread Dirk Eddelbuettel
Hi there, On 11 December 2014 at 10:27, Qiang Kou wrote: | Hi, Devin, | | I don't whether this is the standard solution. | | As I understand, the default error handler in GSL will abort the program after | printing error message. So you need to close it first.  Qiang beat me to it, but when I

Re: [Rcpp-devel] Rcpp catching a domain error

2014-12-11 Thread Qiang Kou
Hi, Devin, I don't whether this is the standard solution. As I understand, the default error handler in GSL will abort the program after printing error message. So you need to close it first. In most time I don't use try-catch with GSL, I detect whether the result is 'nan' or not. Try the code b

[Rcpp-devel] Rcpp catching a domain error

2014-12-11 Thread Devin
Dear list My Rcpp source file contains a gsl_sf_hyperg_2F1() function, and for some input values to this function the return value is "NaN", which leads in RStudio to an abortion error. In order to avoid abortion errors, I try to implement a try/catch exception handler: // [[Rcpp::depend