Hello,
Firstly, I would like to thank the develops of Rcpp for this tool.
Then, here is the function:
-----------------------------
code<-'
NumericVector my_id(id);
NumericMatrix my_link(link);
NumericVector lst(1000);
for (int i=0;i<1000;i++){
for (int j=0;j<1000;j++){
if (my_link(my_id[i],my_id[j])==1){
lst[i]+=1;}}}
return lst;
'
fun<-cxxfunction(signature(id="numeric",link="numeric"),body=code,plugin="Rcpp")
------------------------------
And my question is: How to use multicores to calculate the loop and output the final result?
Thank you.
Best,
Zhao
[Rcpp-devel] parallelization in Rcpp
2 messages · Zhao Yang, Tim Triche, Jr.
there is an example of using OpenMP for this: http://dirk.eddelbuettel.com/code/rcpp/html/OpenMP_2OpenMPandInline_8r-example.html thanks Dirk :-)
On Thu, Feb 14, 2013 at 3:43 AM, Zhao Yang <kikyoyangz at gmail.com> wrote:
Hello,
Firstly, I would like to thank the develops of Rcpp for this tool.
Then, here is the function:
-----------------------------
code<-'
NumericVector my_id(id);
NumericMatrix my_link(link);
NumericVector lst(1000);
for (int i=0;i<1000;i++){
for (int j=0;j<1000;j++){
if (my_link(my_id[i],my_id[j])==1){
lst[i]+=1;}}}
return lst;
'
fun<-cxxfunction(signature(id="numeric",link="numeric"),body=code,plugin="Rcpp")
------------------------------
And my question is: How to use multicores to calculate the loop and output
the final result?
Thank you.
Best,
Zhao
_______________________________________________ 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
*A model is a lie that helps you see the truth.* * * Howard Skipper<http://cancerres.aacrjournals.org/content/31/9/1173.full.pdf> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130214/1abe8e6a/attachment.html>