<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">I wrote a function foo using RcppParallel and I am observing a bug, which I can’t figure out.</div><div class="">I first wrote the function in R, then in Rcpp, then RcppParallel.</div><div class=""><br class=""></div><div class="">foo is doing exactly what it is supposed to do in R and Rcpp.</div><div class="">However, I am observing some wired things in RcppParallel.</div><div class=""><br class=""></div><div class="">foo_par is running, giving almost what I want.</div><div class=""><br class=""></div><div class="">foo compares two matrices columnwise all pairwise combinations.</div><div class="">thus we have 3 loops. </div><div class="">In the smallest step it takes two values e.g. m[c(row1, row2), 1] from the first matrix and checks if they are</div><div class="">appear in 1 column in the second matrix. If they are 1 is returned, if not 0.</div><div class=""><br class=""></div><div class="">However, before that there is a check if one of the c(1,2) is even, then only a NA is returned. </div><div class="">Check below for this step.</div><div class=""><br class=""></div><div class=""><b class="">The wired thing is, that this works perfectly fine the very 1st instance this case happens </b></div><div class=""><b class="">and not any more in the thereafter examples. </b></div><div class=""><b class=""><br class=""></b></div><div class=""><b class="">E.g: </b></div><div class=""><b class=""><br class=""></b></div><div class=""><div class="">> foo(m1, m2)</div><div class="">     [,1] [,2] [,3] [,4]</div><div class="">[1,]    1    1    1    1</div><div class="">[2,]    1   <b class="">NA</b>    1    <b class="">0*</b></div><div class="">[3,]    1    <b class="">0*</b>    1    <b class="">0*</b></div></div><div class=""><b class=""><br class=""></b></div><div class=""><b class="">the 0s with * should be NA. </b></div><div class=""><b class=""><br class=""></b></div><div class=""><b class=""><br class=""></b></div><div class=""><br class=""></div><div class=""><div class="">if ( (row1 % 2 == 0) || (row2 % 2 == 0) ){</div><div class="">       </div><div class="">           result_matrix(count, col) = NA_REAL;</div><div class=""><br class=""></div><div class="">          } else { </div></div><div class=""><br class=""></div><div class="">do the 0, 1 stuff</div><div class="">}</div><div class=""><br class=""></div><div class="">** count: i am using a counter for the filling of the resulting matrix (indicates the row where it should be put)</div><div class="">** col: this is from the outest loop. it loops over columns and then writes the result into the according col in the result matrix. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Is this enough information?</div><div class="">If someone needs to see the full function, I would prefer to send this via mail directly, since </div><div class="">this is for a publication…</div><div class=""><br class=""></div><div class="">I appreciate any hints!</div><div class="">And I am wondering if this is coming from the parallelization itself?</div><div class="">The modulo is somehow not working correctly?</div><div class=""><br class=""></div><div class="">Cheers, </div><div class="">Franz</div></body></html>