Re: [Rcpp-devel] C++11 in Windows R package
Hi Matteo, On 11 June 2014 at 23:29, Matteo Fasiolo wrote: | after realizing that the only C++11 feature I was using was I decided | to switch | to boost::normal_distribution. In particular I now link to BH, but I don't use | the boost::normal_distribution | from there, but the one in this commit: | | http://lists.boost.org/boost-commit/2012/10/43158.php | | which is much faster than the current version. Hopefully the package will now | work on all platforms! Nice, and it should thanks to BH and its headers. OS X won't have OpenMP support (yet, apparently some future version will). But Linux and Windows should be fine. Dirk | Thanks, | | Matteo | | | On Mon, Jun 9, 2014 at 8:02 PM, Dirk Eddelbuettel wrote: | | | On 9 June 2014 at 17:45, Matteo Fasiolo wrote: | | Hi Dirk | | | | | | | | Saw that -- mvnfast looks quite interesting with OpenMP-based RNG! | | | | | | | | | Yes, using a single header parallel RNG, which is compatible with C++11 | random | | distributions made | | all the work much easier! The C++11 part is creating lots of problems, | though. | | I owe you a follow-up (maybe later today) about how/where it built for me | with clang. This seems to have to do with the 'C++' library one uses with | clang/llvm; it seems on Debian it comes from g++-4.8 which works. | | Dirk | | | Yes. For the two (smaller) packages (RcppCNPy, and RcppBDT) where I | use | | C++11 features I have | | | | Depends: R (>= 3.1.0) | | | | and you should too as C++11 does need R 3.1.0 or later. | | | | | | | | | | Thanks, Prof. Ripley pointed at the same solution. | | | | Matteo | | -- | http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org | | -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] C++11 in Windows R package
Hi Dirk, after realizing that the only C++11 feature I was using was I decided to switch to boost::normal_distribution. In particular I now link to BH, but I don't use the boost::normal_distribution from there, but the one in this commit: http://lists.boost.org/boost-commit/2012/10/43158.php which is much faster than the current version. Hopefully the package will now work on all platforms! Thanks, Matteo On Mon, Jun 9, 2014 at 8:02 PM, Dirk Eddelbuettel wrote: > > On 9 June 2014 at 17:45, Matteo Fasiolo wrote: > | Hi Dirk > | > | > | > | Saw that -- mvnfast looks quite interesting with OpenMP-based RNG! > | | > | > | > | Yes, using a single header parallel RNG, which is compatible with C++11 > random > | distributions made > | all the work much easier! The C++11 part is creating lots of problems, > though. > > I owe you a follow-up (maybe later today) about how/where it built for me > with clang. This seems to have to do with the 'C++' library one uses with > clang/llvm; it seems on Debian it comes from g++-4.8 which works. > > Dirk > > | Yes. For the two (smaller) packages (RcppCNPy, and RcppBDT) where I > use > | C++11 features I have > | > | Depends: R (>= 3.1.0) > | > | and you should too as C++11 does need R 3.1.0 or later. > | > | > | > | > | Thanks, Prof. Ripley pointed at the same solution. > | > | Matteo > > -- > http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org > ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] RcppMLPACK ?
Understood! I will contact Ryan and modify the package in the weekend. Best, KK On Wed, Jun 11, 2014 at 9:28 AM, Dirk Eddelbuettel wrote: > > On 11 June 2014 at 08:50, Qiang Kou wrote: > | Thanks for the opinions! > > As they say, "talk is cheap" so I dispense it freely :) > > | On Wed, Jun 11, 2014 at 7:38 AM, Dirk Eddelbuettel > wrote: > | And smart how you just added the little bit from Boost > | we don't have in BH (program_options). > | > | As far as I know all parts in BH package are headers-only, and > | "program_options" is required by MLPACK to handle command line options. > As I > | see, it will not be used, since we don't need those options when calling > it in > | R. > > Correct. > > So the best way forward would be to talk to Ryan to ifdef these parts, or > maybe deal with it at your end so that file containing options parsing is > not used. > > Not including it would be even better as you'd avoid all possible version > skew between BH and your included file. > > | Should the cpp files in inst/include be in src/, or maybe src/mlpack > | instead? > | > | To be frank, I don't know which place is better. I just follow the > structures > | of RcppArmadillo. > > Not really. Look for carefully: directory inst/include/ for Rcpp, > RcppArmadillo, RcppEigen, BH, ... only include __header__ files whereas you > included source files (ie .cpp). > > | It may be less than ideal that the kmeans example hides the base > function. > | Maybe make it mlKmeans, or keep it unexported, or ... ? > | > | Of course, I will change names of functions, at least not the same with R > | built-in functions. > > Yes. And one fun thing you could play with is to see if you either re-use > or > mimic the print, summary, ... methods for kmeans. > > A very good start, and good to gave on GitHub! > > Dirk > > -- > http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org > -- Qiang Kou q...@umail.iu.edu School of Informatics and Computing, Indiana University ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] Using spatstat in Rcpp
Hello, You seem to be confusing R namespaces and C++ namespaces and assuming you can call an R function as if it belonged to a C++ namespace. R functions and c++ functions are different things. You can do something like: // get the spatstat environment Environment spatstat( "package:spatstat" ) ; // get the discpartarea function from that env Function discpartarea = spatstat["discpartarea"]; Then you can call discpartarea. Romain Le 11 juin 2014 à 19:01, mohammad ghorbani a écrit : > Hi there, > > I would like to call discpartarea() and as.owin() functions of spatstat from > Rcpp. In a simple example > consider the following C++ code in which I'm trying to access the above > functions: > > #include > using namespace Rcpp; > > // [[Rcpp::export]] > NumericVector IndepSelfCortCpp( NumericMatrix obsu) { > NumericMatrix obsxy = obsu( _ , Range(1,2) ) ; > NumericVector xyW= NumericVector::create(0,56,0,38); > double rslt = 0; > > rslt= spatstat::discpartarea(obsxy, 0.1, spatstat::as.owin(xyW)); > > return (rslt); > } > /* ** R > obsu <- matrix(c(0.5, 1.5, 4, 12, 1,2,3,4,2,3,5,7), ncol=3) > IndepSelfCortCpp(obsu) > */ > > When I source the file in Rstudio with sourceCpp(), I get the error: > " 'spatstat' has not been declard " > > I was wondering, a direct call a function of an R package like spatstat is > possible from Rcpp. > If yes, Could anyone help me on debugging the code? > > Best Regards, > Mohammad Ghorbani > ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
[Rcpp-devel] Using spatstat in Rcpp
Hi there, I would like to call discpartarea() and as.owin() functions of spatstat from Rcpp. In a simple example consider the following C++ code in which I'm trying to access the above functions: #include using namespace Rcpp; // [[Rcpp::export]] NumericVector IndepSelfCortCpp( NumericMatrix obsu) { NumericMatrix obsxy = obsu( _ , Range(1,2) ) ; NumericVector xyW= NumericVector::create(0,56,0,38); double rslt = 0; rslt= spatstat::discpartarea(obsxy, 0.1, spatstat::as.owin(xyW)); return (rslt); } /* ** R obsu <- matrix(c(0.5, 1.5, 4, 12, 1,2,3,4,2,3,5,7), ncol=3) IndepSelfCortCpp(obsu) */ When I source the file in Rstudio with sourceCpp(), I get the error:" 'spatstat' has not been declard " I was wondering, a direct call a function of an R package like spatstat is possible from Rcpp. If yes, Could anyone help me on debugging the code? Best Regards, Mohammad Ghorbani I was wondering is it possible to call ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] RcppMLPACK ?
On 11 June 2014 at 08:50, Qiang Kou wrote: | Thanks for the opinions! As they say, "talk is cheap" so I dispense it freely :) | On Wed, Jun 11, 2014 at 7:38 AM, Dirk Eddelbuettel wrote: | And smart how you just added the little bit from Boost | we don't have in BH (program_options). | | As far as I know all parts in BH package are headers-only, and | "program_options" is required by MLPACK to handle command line options. As I | see, it will not be used, since we don't need those options when calling it in | R. Correct. So the best way forward would be to talk to Ryan to ifdef these parts, or maybe deal with it at your end so that file containing options parsing is not used. Not including it would be even better as you'd avoid all possible version skew between BH and your included file. | Should the cpp files in inst/include be in src/, or maybe src/mlpack | instead? | | To be frank, I don't know which place is better. I just follow the structures | of RcppArmadillo. Not really. Look for carefully: directory inst/include/ for Rcpp, RcppArmadillo, RcppEigen, BH, ... only include __header__ files whereas you included source files (ie .cpp). | It may be less than ideal that the kmeans example hides the base function. | Maybe make it mlKmeans, or keep it unexported, or ... ? | | Of course, I will change names of functions, at least not the same with R | built-in functions. Yes. And one fun thing you could play with is to see if you either re-use or mimic the print, summary, ... methods for kmeans. A very good start, and good to gave on GitHub! Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] RcppMLPACK ?
Thanks for the opinions! On Wed, Jun 11, 2014 at 7:38 AM, Dirk Eddelbuettel wrote: > And smart how you just added the little bit from Boost > we don't have in BH (program_options). > As far as I know all parts in BH package are headers-only, and "program_options" is required by MLPACK to handle command line options. As I see, it will not be used, since we don't need those options when calling it in R. > Should the cpp files in inst/include be in src/, or maybe src/mlpack > instead? To be frank, I don't know which place is better. I just follow the structures of RcppArmadillo. > It may be less than ideal that the kmeans example hides the base function. > Maybe make it mlKmeans, or keep it unexported, or ... ? > Of course, I will change names of functions, at least not the same with R built-in functions. Best, KK ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] RcppMLPACK ?
On 10 June 2014 at 23:34, Qiang Kou wrote: | Hi, guys, | | I have a little more time to work on the RcppMLPACK package during this summer. | | I set up a repo on github [1] and it follows the structure of RcppArmadillo. I | just test a simple kmeans function and it seems that it works. Nice work! Installs and runs fine. Does create a million warnings under my compiler settings (ie -Wall -pedantic ) some of which of course come from MLPACK and/or Boost. And smart how you just added the little bit from Boost we don't have in BH (program_options). Should the cpp files in inst/include be in src/, or maybe src/mlpack instead? It may be less than ideal that the kmeans example hides the base function. Maybe make it mlKmeans, or keep it unexported, or ... ? Dirk | Since almost all the input/output of MLPACK is handled by Armadillo, there is | not much work as I have seen. | | Please send pull request If interested in contributing code or testing. | | Best, | | KK | | [1] https://github.com/thirdwing/RcppMLPACK.git | | | On Sun, Apr 6, 2014 at 1:08 AM, Dirk Eddelbuettel wrote: | | | James, Qiang, | | On 5 April 2014 at 23:33, Qiang Kou wrote: | | Hi, I think we can try to start this in the summer, since I am also a | little | | busy as a student. | | | | I my opinion, we can follow the structure of RcppArmadillo and start from | 'as' | | and 'wrap' functions for matrix structure in mlpack. | | There is definitely general interest in doing that. And as mentioned | earlier | in this thread, there has been previous talk between Ryan (MLPACK), Conrad | (Arma) and myself. It would probably be best to somehow involve Ryan and | his | group as they have thoughts (and have considered Swig and other tools). It | would need some thought, and someone with time and knowledge of both | projects | to be involved. | | That said, you can of course also start with simple as<>() and wrap() | converters just to get going. Nothing wrong with some explorations and | examples while figuring out the bigger picture. | | Cheers, Dirk | | | | | Best, | | | | KK | | | | | | On Sat, Apr 5, 2014 at 10:10 PM, James Li wrote: | | | | Hello Damian and other Rcpp Devs, | | | | I am extremely interested in putting in (non-trivial) time into | something | | like this - but I am not sure I am expert enough to head such a | project. | | | | My question to you is: have you or anyone else started a project like | this | | that I can contribute to? And if not, could someone point me the | right way | | to get started? | | | | Thanks! | | | | Best, | | James | | | | | | On Mon, Jan 20, 2014 at 9:42 AM, Dirk Eddelbuettel | wrote: | | | | | | Damian, | | | | On 20 January 2014 at 20:12, Damian Lyons wrote: | | | Dear Rcpp developers, | | | | | | Firstly, many thanks for your work on Rcpp. It has saved me | | countless hours | | | (or is that months?) of simulation time. | | | | | | I'm a big fan of RcppArmadillo and Armadillo. Recently I came | | across MLPACK, | | | which is a large and useful C++ machine learning library that | uses | | Armadillo: | | | http://mlpack.org | | | | Sure. I am in somewhat regular contact with Ryan Curtin, its lead | | developer, | | because of our joint interactions with Conrad and his priceless | | Armadillo | | library. But Ryan is a grad student, and we while we have talked | | about R | | binding (meaning the real thing and not just some SWIG | interfaces), he | | is not | | exactly overflowing with free time. Neither am I. | | | | | If you have the time to do so, I humbly request for an official | | RcppMLPACK | | | package. I believe other people will also find it useful. I'm | | currently | | | copying and pasting code out of MLPACK into my own package, but | this | | is not the | | | most friendly solution. | | | | This makes YOU the perfect candidate to start a project NOW as | YOU need | | IT. | | And YOU have already worked with both pieces. | | | | None of our projects became what they are overnight. You have to | start | | somewhere. Do it right, do it in the open, and if you do that | and | | have some | | luck maybe others will join and help. | | | | Dirk | | | | -- | | Dirk Eddelbuettel | e...@debian.org | htt