[Rcpp-devel] Rf_integrate?

Dirk Eddelbuettel edd at debian.org
Wed Jul 30 21:43:52 CEST 2014


On 30 July 2014 at 15:23, Qiang Kou wrote:
| In my opinion, RcppGSL may be a good choice.

Seconded. GSL has a bit on (numeric) integration. 

However it also uses plain C interfaces to you may start to miss C++ ...
There are a number of quadrature packages on CRAN so maybe one of those can
help too.

As for RcppGSL, the main issue with it, relative to say RcppArmadillo and
RcppEigen, is that you do need to link against the GSL.  I was just helping
another friend off-list on that.

There are two working examples:

  i)  The RcppGSL package ships a complete example used by own unit tests
      too, see its code in the package, or browse at

      https://github.com/eddelbuettel/rcppgsl/tree/master/inst/examples/RcppGSLExample

      You can use this as a basis and copy from.
      
      This package uses configure.


  ii) My more recent RcppZiggurat package also uses the GSL via RcppGSL in
      order to asses the Ziggurat RNG in the GSL.

      It uses a scheme of calling RcppGSL:::LdFlags() which may be simpler
      than configure.

Hope this helps,  Dirk
  
| 
| If you are using Weibull distribution, there is a gsl_ran_weibull_pdf() in GSL
| [1].
| 
| Best,
| 
| KK
| 
| [1] https://www.gnu.org/software/gsl/manual/html_node/
| The-Weibull-Distribution.html#The-Weibull-Distribution
| 
| 
| On Wed, Jul 30, 2014 at 3:15 PM, Silkworth,David J. <SILKWODJ at airproducts.com>
| wrote:
| 
|     I have a current project desire to move something like R’s integrate
|     function inside a loop in Rcpp code.  The performance hit to call back to R
|     seems to kill the advantage of Rcpp in the first place.  Actually my
|     integrand is t*pdf(t), very similar indeed to pweibull which integrates pdf
|     (t).  It has been hard to find previous discussion on this topic since the
|     title of articles and book include the word Integration in  another
|     context.
|      
|     I realize that eventually R’s integrate function calls rdqags (over a
|     definite interval), but there is a lot of memory management that is taken
|     care of before the call.  This is over my head.
|      
|     I could try to incorporate the GSL, but this too seems daunting (even with
|     RcppGSL).  I think there may be integration support in the boost headers,
|     but my head is too small for this yet.
|      
|     Any ideas that could help me?
|      
|     Dave Silkworth
|      
|    
|     _______________________________________________
|     Rcpp-devel mailing list
|     Rcpp-devel at lists.r-forge.r-project.org
|     https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
| 
| 
| 
| 
| --
| Qiang Kou
| qkou at umail.iu.edu
| School of Informatics and Computing, Indiana University
| 
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list