rbchan / unmarked

R package for hierarchical models in ecological research
https://rbchan.github.io/unmarked/
37 stars 25 forks source link

Compiler conflicts in C++ code for gdistsamp #134

Closed kenkellner closed 4 years ago

kenkellner commented 5 years ago

Opening this mainly to record some notes...there may be no need to change anything.

There are header file conflicts between RcppArmadillo.h and R_ext/Applic.h which I currently use to access Rdqags for numerical integration in the C++ code for gdistsamp. The only information I could find about dealing with this is, ironically, a 7-year old mailing list post by @rbchan where it looks like he ran into the same issue.

Despite the conflicts and resulting warnings the code compiles for me on Linux. I am not sure if Windows/Mac might have issues or if CRAN will complain on submission.

If there are problems one alternative is to switch to using the RcppNumerical package to handle integration instead of Rdqags. This would add dependencies to RcppNumerical and also RcppEigen.

I was able implement this change successfully in this branch for both distsamp and gdistsamp.

rbchan commented 5 years ago

Hi Ken,

I agree that we should deal with the header conflicts, and we should probably stop using Rdqags. I just wonder if RcppNumerical is overkill for this problem? Could we use a simple Reimann sum instead? Also, there are analytical solutions to some of these integrals. Some of the analytical solutions are implemented already, but not consistently among functions.

Richard

On Fri, May 17, 2019 at 4:47 PM Ken Kellner notifications@github.com wrote:

Opening this mainly to record some notes...there may be no need to change anything.

There are header file conflicts between RcppArmadillo.h and R_ext/Applic.h which I currently use to access Rdqags for numerical integration in the C++ code for gdistsamp. The only information I could find about dealing with this is, ironically, a 7-year old mailing list post http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-March/003557.html by @rbchan https://github.com/rbchan where it looks like he ran into the same issue.

Despite the conflicts and resulting warnings the code compiles for me on Linux. I am not sure if Windows/Mac might have issues or if CRAN will complain on submission.

If there are problems one alternative is to switch to using the RcppNumerical https://github.com/yixuan/RcppNumerical package to handle integration instead of Rdqags. This would add dependencies to RcppNumerical and also RcppEigen.

I was able implement this change successfully in this branch https://github.com/kenkellner/unmarked/tree/use_RcppNumerical for both distsamp and gdistsamp.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rbchan/unmarked/issues/134?email_source=notifications&email_token=AABWRCRYZQT45HO2NNPVSALPV4KUHA5CNFSM4HNYJS6KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GUPP5YQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AABWRCRUDTQBI637XHVDK4LPV4KUHANCNFSM4HNYJS6A .

kenkellner commented 4 years ago

Resolved in #135