Re: [Rcpp-devel] Create an instance of a reference class for a C++ class exported as a module from within C++?
This is something we have to add at some point. At the moment the only way i see is to make an R call to "new" and construct the object this way... Le 2 juin 2011 à 21:31, Douglas Bates a écrit : > Sorry for the long subject line but I hope it describes what I want to > do. I have a C++ class, dgTMatrix, that is exported in a module > definition. > > RCPP_MODULE(RcppSp) { > ... >class_("dgCMatrix") >... >; > } > > Many of the methods for this class return other members of this class. > Can I create a new instance of the reference class in R from within > the module? I'm sure it is possible, I'm just wondering if there is > an easy way to do this without duplicating large chunks of the code in > Rcpp/src/Module.cpp. Can i somehow clone the SEXP representing the > current instance then swap the external pointer to the C++ object? > ___ > 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 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] Create an instance of a reference class for a C++ class exported as a module from within C++?
> At the moment the only way i see is to make an R call to "new" and construct > the object this way... >> Many of the methods for this class return other members of this class. >> Can I create a new instance of the reference class in R from within >> the module? I'm sure it is possible, I'm just wondering if there is >> an easy way to do this without duplicating large chunks of the code in >> Rcpp/src/Module.cpp. Can i somehow clone the SEXP representing the >> current instance then swap the external pointer to the C++ object? To elaborate a bit: Am I off-base in thinking you can make a custom constructor for your class that calls R's new(), being careful to avoid circularity, that returns a blank instance to your method to be filled? Is something like the following anywhere near this? class MyClass { public: Bar(bool x_) : {} // for spawn Bar() : {} private: Bar spawn() { Environment meth("package:methods"); Function Rnew = meth["new"]; Rcpp::XPtr NewObj( Rnew(false) ); } }; -Christian -- A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama! ___ 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] RcppArmadillo inv() depends on Lapack, zgetri_ not available on CRAN / R-forge?
Dear list, My package cda, which I was hoping to release on CRAN, fails to compile on R-forge with error, ** testing if installed package can be loaded Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/tmp/RtmpbztUMm/Rinst1829c04c/cda/libs/cda.so': /tmp/RtmpbztUMm/Rinst1829c04c/cda/libs/cda.so: undefined symbol: zgetri_ It builds fine on my local machines (Mac OS 10.5, 10.6). >From an older discussion on this list < http://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/msg00678.html> the issue seems to be that Armadillo's inv() relies on a function that is not provided by R, only by LAPACK. I have just replaced inv() by pinv() and solve() in my code; merely to see what happens, but chances are they also require a full LAPACK. Does anybody have any experience dealing with such issues w.r.t releasing a package on R-forge / CRAN? Is there any chance they would consider installing LAPACK on those servers, or is there no point in asking such things? Best regards, baptiste ___ 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] RcppArmadillo inv() depends on Lapack, zgetri_ not available on CRAN / R-forge?
Baptiste, On 4 June 2011 at 11:45, baptiste auguie wrote: | Dear list, | | My package cda, which I was hoping to release on CRAN, fails to | compile on R-forge with error, | | ** testing if installed package can be loaded | Error in dyn.load(file, DLLpath = DLLpath, ...) : | unable to load shared object '/tmp/RtmpbztUMm/Rinst1829c04c/cda/libs/cda.so': | /tmp/RtmpbztUMm/Rinst1829c04c/cda/libs/cda.so: undefined symbol: zgetri_ | | It builds fine on my local machines (Mac OS 10.5, 10.6). | | >From an older discussion on this list < | http://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/msg00678.html> | the issue seems to be that Armadillo's inv() relies on a function that | is not provided by R, only by LAPACK. I have just replaced inv() by | pinv() and solve() in my code; merely to see what happens, but chances | are they also require a full LAPACK. Sometime relatively early in the RcppArmadillo development process, Doug convinced Romain and myself to go for a pure template solution with Armadillo as all / most things found during the configure (or in this case, cmake) stage can be assumed 'found' given that we have around us by design. So no testing, no local library and full reliance and what R gives us. That was a brilliant idea, and has freed us from having to rely on building and shipping a library, having to tell users how to set PKG_LIBS etc pp and I firmly believe that this helped tremendously in getting RcppArmadillo more widely used. So I would not want to revert this. In any event, it seems that you need more LAPACK than R has for you. That is likely to be a dicey situation as you per se do not know whether R was built and linked with its own (subset) copy of LAPACK, or whether it uses system LAPACK libraries (as e.g. the Debian / Ubuntu systems do). So you may be in a spot bother and I not sure what I can recommend --- other than trying your luck at some short configure snippets that will run at package build time to determine whether the system you want to build cda on it 'rich' enough to support it. I can help you off list with some configure snippets as some of my packages have configure code; adding a test for zgetri should be feasible. | Does anybody have any experience | dealing with such issues w.r.t releasing a package on R-forge / CRAN? | Is there any chance they would consider installing LAPACK on those | servers, or is there no point in asking such things? I don't think it is a matter of fixing the R-Forge server. I think it is a matter of making your package installable on the largest number of user systems. Also try win-builder.r-project.org to see how it fares on that platform. Dirk -- Gauss once played himself in a zero-sum game and won $50. -- #11 at http://www.gaussfacts.com ___ 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