Re: [Rcpp-devel] Limit of 20

2021-12-15 Thread Balamuta, James Joseph
For those interested, the few other instances can be found by looking under the inst/include/Rcpp/generated/ folder: https://github.com/RcppCore/Rcpp/tree/master/inst/include/Rcpp/generated In the case of Vector__create.h, one would need to do some varidic templating to abstract away from the

Re: [Rcpp-devel] Exporting rcpp-based function into parLapply workers in an R package

2021-05-14 Thread Balamuta, James Joseph
For code searches, consider using the {searcher} package: https://github.com/r-assist/searcher In particular, the search_github() function handles the query formatting. As an example, try: searcher::search_github("clusterEvalQ ") This opens a web browser with: https://github.com/search?q=clu

Re: [Rcpp-devel] Exporting rcpp-based function into parLapply workers in an R package

2021-05-14 Thread Balamuta, James Joseph
Naeem, The best path for including compiled code in a package is to place it within the `src/` directory instead of using `Rcpp::cppFunction()` to compile. The reasons for this are stated succiently here: https://stackoverflow.com/a/6074391/1345455 From there, the C++ can easily be exported ac

Re: [Rcpp-devel] Ranges and Casting

2021-01-16 Thread Balamuta, James Joseph
Francisco, Based on the opening post, I’d probably push you more toward Armadillo as Dirk was in the previous message. Using linspace<>(), may be a drop-in replacement for seq() with the appropriate helper functions. Long ago (~4+ years now) I wrote a few, see: https://github.com/coatless/r-to

Re: [Rcpp-devel] building shared library error with sourceCpp

2019-12-28 Thread Balamuta, James Joseph
Fatima, I think the ~/.R/Makevars didn’t get created correctly. In particular, the ${R_HOME} path didn’t get extended: > -Wl,-rpath,/lib /lib/libc++abi.1.dylib Could you modify the ~/.R/Makevars file and ensure it has: # clang: start CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/M

Re: [Rcpp-devel] Segmentation faults

2019-12-06 Thread Balamuta, James Joseph
Greetings and Salutations Brook, The segfault is related to `int main() {}`. There is no need to use `int main() {}` unless you want to make this standalone in which case you want to use RInside to embed R within a C++ application. Rcpp enables embedding C++ within R. So, R already is using it

Re: [Rcpp-devel] finding plugins

2018-12-01 Thread Balamuta, James Joseph
Mark, Consider: cppFunction('//Anything', depends="RcppArmadillo", plugin="RcppArmadillo", verbose=TRUE) Armadillo is not a plugin but a library. Plugins are for changing the C++ compilation standard, enabling OpenMP, or changing the long jump behavior. Examples of built-in plugins can be fou

Re: [Rcpp-devel] Distribution functions threadsafe in RcppParallel?

2018-04-16 Thread Balamuta, James Joseph
Greetings and Salutations, There is also the boost header libraries that you can use: https://www.boost.org/doc/libs/1_67_0/doc/html/boost_random.html Gallery example: http://gallery.rcpp.org/articles/timing-normal-rngs/ If you need parallel draws, see the sitmo engine: https://github.com/coa

Re: [Rcpp-devel] Fwd: Calling R function in Rcpp returns compatibility issues

2017-07-27 Thread Balamuta, James Joseph
Greetings and Salutations Sharat, Could you supply some test data? Sincerely, JJB From: rcpp-devel-boun...@lists.r-forge.r-project.org [mailto:rcpp-devel-boun...@lists.r-forge.r-project.org] On Behalf Of Sharat Sent: Thursday, July 27, 2017 8:31 AM To: rcpp-devel@lists.r-forge.r-project.org Su

Re: [Rcpp-devel] Rcpp-devel Digest, Vol 85, Issue 8

2016-11-23 Thread Balamuta, James Joseph
Greetings and Salutations Ben and Christian, This issue has been addressed! In fact, Dirk beat me to it by a few minutes. See https://github.com/RcppCore/RcppArmadillo/issues/111 Alas, the updated version has yet to be pushed to CRAN due to the monthly update policy. If I had to guess, this n

Re: [Rcpp-devel] Help with WARNING msg: checking line endings in C/C++/Fortran sources/headers ...

2016-11-17 Thread Balamuta, James Joseph
Greetings and Salutations, Odd that the warning would end up being triggered as file is automatically generated with appropriate line endings. Within the package directory, try running: Rcpp::compileAttributes() This will recreate the export files (e.g. src/RcppExports.cpp or R/RcppExports.R

Re: [Rcpp-devel] Error for exp() using RcppArmadillo

2016-09-11 Thread Balamuta, James Joseph
Greetings and Salutations, The operation that you are using here: exp(alpha1(0)+beta1(1)); Returns a double instead of an arma::vec. Hence, from ‘double’ to ‘arma::vec {aka arma::Col}’ To fix this, use: arma::vec temp(1); temp << exp(alpha1(0)+beta1(1)); // assumes 1 element i

Re: [Rcpp-devel] NLopt linking problem

2016-04-26 Thread Balamuta, James Joseph
Greetings and Salutations, Try setting the environment variable NLOPT_HOME with the location of the NLopt library and then add to the Makevars.win file: PKG_CFLAGS = -I"$(NLOPT_HOME)$(R_ARCH)/include" PKG_LIBS = -L"$(NLOPT_HOME)$(R_ARCH)/lib" -lnlopt_cxx Sincerely, JJB From: rcpp-devel-boun..

Re: [Rcpp-devel] fatal error: 'omp.h' file not found

2016-03-14 Thread Balamuta, James Joseph
Greetings and Salutations, OS X does not currently support OpenMP under the default compiler (clang). Hence, you are receiving an error as it relates to the header file not being found. For more details, see: https://cran.r-project.org/doc/manuals/r-release/R-exts.html#OpenMP-support

Re: [Rcpp-devel] Rcpp problem related to sourceCpp_1.so

2016-02-04 Thread Balamuta, James Joseph
Greetings and Salutations, See: http://thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks-lgfortran-and-lquadmath-error/ Also, another example / more help setting up the dev environment on OS X is here: http://thecoatlessprofessor.com/programming/r-compiler-tools-for-rc

Re: [Rcpp-devel] Incorrect results from RcppArmadillo::sample

2015-10-18 Thread Balamuta, James Joseph
Greetings and Salutations, At this code: Rcpp::NumericVector JJ(15); // creates a vector with 15 spaces JJ[0] = 15; // fills only the first space You have only initiated slot 0 to 15. The remaining slots (1-14) are uninitialized at 0. You probably want to use: Rcpp::Inte

Re: [Rcpp-devel] Sparse matrix and RcppEigen

2015-06-10 Thread Balamuta, James Joseph
Thanks for the reproducible example! Here is the solution: library(Matrix) Omega <- Matrix(c(1,0.8,0.8,1),2,2) invSqrtV <- Diagonal(2,1) Omega.M <- as(as.matrix(Omega),"dgCMatrix") invSqrtV.M <- as.vector(diag(invSqrtV)) partialsolveCS <- ' using namespace Rcpp; using namespace Eigen; const Spar

Re: [Rcpp-devel] Sparse matrix and RcppEigen

2015-06-09 Thread Balamuta, James Joseph
Regarding the code not compiling…. Try: src <- ' using Eigen::Map; using Eigen::SparseMatrix; using Eigen::LLT; const SparseMatrix Omega(as >(Omegas)); const SparseMatrix invSqrtV(as >(invSqrtVs)); // First solver associated with Omega matrix (taken w.r.t to Upper triangular view) Eigen::Simpl

Re: [Rcpp-devel] Sparse matrix and RcppEigen

2015-06-08 Thread Balamuta, James Joseph
Greetings and Salutations Wagner, 1. I think you solved your own initial problem as it relates to solving matrices within eigen using the “solver” class. e.g. SparseMatrix A; SparseMatrix B; SolverClassName > solver(A); SparseMatrix x = solver.solve(B); 2. Taking a square root of a matrix in

Re: [Rcpp-devel] OpenMP and Parallel BLAS

2015-05-31 Thread Balamuta, James Joseph
Greetings and Salutations, The answer is yes, multiple processes can concurrently modify different parts of the object. So, the object is not “locked.” In this case, it’s important to note the scope of the object being “shared” and not “private.” Also, the object is not being used in any compu

Re: [Rcpp-devel] OpenMP and Parallel BLAS

2015-05-26 Thread Balamuta, James Joseph
Greetings and Salutations, I would suggest the following modifications: 1. Use the Rcpp omp plugin // [[Rcpp::plugins(openmp)] Instead of using set flags. (assuming you are on Rcpp >= 0.10.5 ) 2. Modify the function parameters to include: int cores This allows you to specify cores during run

Re: [Rcpp-devel] build error on a starter package made from RcppArmadillo.package.skeleton

2015-05-08 Thread Balamuta, James Joseph
For OS X install instructions see: http://www.thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks-lgfortran-and-lquadmath-error From: rcpp-devel-boun...@lists.r-forge.r-project.org [mailto:rcpp-devel-boun...@lists.r-forge.r-project.org] On Behalf Of Yue Li Sent: Friday,

[Rcpp-devel] Linking code in src/ subfolders

2015-03-10 Thread Balamuta, James Joseph
Greetings and Salutations All, I'm trying to add structure to the src folder since the amount of files I have residing in the src directory could be better organized. Note: These files are made using RcppArmadillo. E.g. I'm looking to go from: src/ |-> main.cpp |-> testA.cpp |-> t

Re: [Rcpp-devel] Status of ARMA_64BIT_WORD in RcppArmadillo

2014-12-14 Thread Balamuta, James Joseph
] Sent: Sunday, December 14, 2014 10:14 PM To: Balamuta, James Joseph Cc: rcpp-devel@lists.r-forge.r-project.org Subject: Re: [Rcpp-devel] Status of ARMA_64BIT_WORD in RcppArmadillo On 15 December 2014 at 03:49, Balamuta, James Joseph wrote: | Greetings and Salutations All, | | Recently, I've ha

[Rcpp-devel] Status of ARMA_64BIT_WORD in RcppArmadillo

2014-12-14 Thread Balamuta, James Joseph
Greetings and Salutations All, Recently, I've had the need to collide large matrices 1x10^7 using code written in RcppArmadillo. Initially, I triggered: Error: Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD Upon a quick search, I stumbled upon a Stack Exchange post