Re: [Rcpp-devel] parallel distance matrix calculation

2014-07-11 Thread Jonathan Olmsted
James, My attempt at marginal usefulness (compared to DE and JJE's comments) would be to offer some code examples that I've got using OpenMP--based parallelism. There are examples in the gallery, of course. But I've got a number of others for euclidean distance and one for an EM algorithm. If you

Re: [Rcpp-devel] Rcpp C++ code debug / Calling Rcpp in a C++ environment

2014-07-11 Thread Jing Peng
Hi KK, Thanks for your advice! I actually managed to get it work, by creating an embeeded R instance before calling the Rcpp function. I didn't post the solution yet because it is still not clear to me why that fixes the problem. 1) I compiled the code with an IDE, so I didn't post the command. I

Re: [Rcpp-devel] parallel distance matrix calculation

2014-07-11 Thread Dirk Eddelbuettel
On 11 July 2014 at 21:19, JJ Allaire wrote: | (2) The premise of RcppParallel is that you are reading and writing directly | into C arrays in background threads (it's not safe to call into R and therefore | not really safe to call into Rcpp). So to interact with a Matrix/Vector you | need to calc

Re: [Rcpp-devel] parallel distance matrix calculation

2014-07-11 Thread JJ Allaire
Two things to consider: (1) The parallelFor and parallelReduce functions don't require iterators -- they just take indexes which you can use for iterating over any range. In the gallery examples they are used to offset NumericVector.begin() to get the address of the slide of the vector or matrix t

[Rcpp-devel] parallel distance matrix calculation

2014-07-11 Thread James Bullard
Sorry, this is a continuation of my previous email, I've just learned a new gmail keybinding for accidentally sending ... My questions are: - is it right to parallelize the outer loop versus doing a parallelReduce on the kl_divergence function? - is there a row iterator which returns NumericVector

[Rcpp-devel] parallel distance matrix calculation

2014-07-11 Thread James Bullard
Hi All, I'm attempting to paralellize some Rcpp code I have now, but I'm having a hard time understanding the best route for this. I'm looking for some guidance about how things need to be restructured to take advantage of the parallelFor (if that would be the speediest option). I have the follow

Re: [Rcpp-devel] Rcpp C++ code debug / Calling Rcpp in a C++ environment

2014-07-11 Thread Qiang Kou
Hi, I don't have a Windows developing environment just now, so I can not figure out what is wrong. I can try in the weekends. Just little personal advice. (1) Maybe you should also put the compiling commands here, not only the output. It may be easier to see your configuration and the problem.

Re: [Rcpp-devel] Manipulation of IntegerVector

2014-07-11 Thread Sven E. Templer
hi, you should change the line matched[j+1] = tmp; to matched[j-1] = tmp; to get rid of your error. require(Rcpp) require(inline) sourceCpp(code=' #include using namespace Rcpp; // [[Rcpp::export]] List createVectorList_Numeric_cpp(NumericMatrix df) { CharacterVector rownames = VECTOR

Re: [Rcpp-devel] Manipulation of IntegerVector

2014-07-11 Thread Sameer D'Costa
On Fri, Jul 11, 2014 at 3:19 AM, Mario Deng wrote: > But when I do "matched[j+1] = matched[j]+1;" everything crashes, I don't > get any error informations etc. Also, is there a way to avoid that the R > instance/RStudio crashes? > I was able to compile and run part of your code on linux outside

[Rcpp-devel] Manipulation of IntegerVector

2014-07-11 Thread Mario Deng
Hello everyone, I still struggle with Rcpp, I hope you guys are patient. The problem occurs here: IntegerVector matched = match(sorted_vec, one_col); for(int j = 0; j < (matched.size() - 1); j++){ if( matched[j] >= matched[j+1] ){ matched[j+1] = matched[j]+1; } } I can access