<div dir="ltr"><div><div><div>For your information, here is a header-only library for distribution functions: <a href="https://github.com/kthohr/stats">https://github.com/kthohr/stats</a><br><br></div>The API seems to be designed to mimic the R API.<br><br><br></div>Best,<br></div>Yixuan<br><div><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2018-04-15 23:56 GMT-04:00 Murray Efford <span dir="ltr"><<a href="mailto:murray.efford@gmail.com" target="_blank">murray.efford@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Thanks. This is all happening inside a package for CRAN, so I would rather avoid more complexity and potential platform-dependence, but I also cannot afford for it to break unpredictably (or otherwise).<span class="gmail-HOEnZb"><font color="#888888"><br></font></span></div><span class="gmail-HOEnZb"><font color="#888888">Murray<br></font></span></div><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 16, 2018 at 3:33 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span><br>
On 16 April 2018 at 13:41, Murray Efford wrote:<br>
| I read in the RcppParallel blurb "The code that you write within parallel<br>
| workers should not call the R or Rcpp API in any fashion", which is<br>
| admirably clear. However, it leaves me without threadsafe access to<br>
| distribution functions (dpois, dbinom etc.). In practice, so far, these R<br>
| API calls seem to work for me, but can they be trusted? Is there an<br>
| alternative?<br>
<br>
</span>That's a fair question. They may work, as they are also exposed / available<br>
via the standalone R math library (see Writing R Extensions).<br>
<br>
As such, they may not required memory allocations or other interactions with<br>
the R process and hence "not call R ... in any fashion" per the above. <br>
<br>
But we can't say for sure. If you want to be safe, maybe stick to <br>
equivalent functions from a non-R source: C++11, Boost, ...  <br>
<br>
Dirk<br>
<div class="gmail-m_8449096087844483128HOEnZb"><div class="gmail-m_8449096087844483128h5"><br>
| (It seems this question must have arisen before, but I haven't found an<br>
| answer)<br>
<br>
</div></div><span class="gmail-m_8449096087844483128HOEnZb"><font color="#888888">-- <br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a><br>
</font></span></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-<wbr>project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-<wbr>project.org/cgi-bin/mailman/<wbr>listinfo/rcpp-devel</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Yixuan Qiu <<a href="mailto:yixuan.qiu@cos.name" target="_blank">yixuanq@gmail.com</a>><br>Department of Statistics,<br>Purdue University<br></div>
</div></div></div></div></div></div>