<div dir="ltr">Hi,<div><br></div><div>Just to clarify: did you include files from RcppFaddeeva because you need some of its functionality (special complex error functions), or was it only a workaround to get access to complex numbers? In the latter case, I recommend you try making a minimal Rcpp package to see how easy it is to interface with C+ functions, and that way you will only have relevant header files included.</div><div><br></div><div>Best,</div><div><br></div><div>baptiste</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 4 January 2016 at 09:36, Pierre Lafaye de Micheaux <span dir="ltr"><<a href="mailto:lafaye@dms.umontreal.ca" target="_blank">lafaye@dms.umontreal.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all,<br>
<br>
This email comes after a discussion on the R-pkg-devel mailing list:<br>
<a href="https://stat.ethz.ch/pipermail/r-package-devel/2016q1/000627.html" rel="noreferrer" target="_blank">https://stat.ethz.ch/pipermail/r-package-devel/2016q1/000627.html</a><br>
<br>
My purpose was to be able, in two of my packages, to use complex numbers (create some, addition, multiplication, division, modulus, etc)<br>
directly in a C code that is called from R (using the .C interface).<br>
Note that these complex numbers might not come from R but could be created and used directly in my C code, that will then output (via pointers)<br>
real (I mean double) values back to R (via the .C interface). I could also send from R these complex numbers via the .C interface.<br>
<br>
A very simple example of such a function called from R via the .C interface could be the following:<br>
<br>
#include <R.h><br>
#include "Rmath.h"<br>
extern "C" {<br>
void Cfunc(complex double *var) {<br>
    double _Complex z = 1.0 + 2.0 * _Complex_I;<br>
    var[0] = z + exp(var[0]);<br>
return;<br>
}}<br>
<br>
I could call this function from R as follows:<br>
.C(1i)<br>
<br>
No problem so far when I use such a function in a package that is compiled under Linux. But this will not work under windows (see the discussion<br>
on the R-pkg-devel list). So what I did to make everything work under Windows also was to include in the src/ directory of my package the source files<br>
from the RcppFaddeeva package. Then I would modify the function above as follows:<br>
<br>
#include <R.h><br>
#include "Rmath.h"<br>
#include "libraries/callFaddeeva.cpp"<br>
#include "libraries/Faddeeva.cpp"<br>
#include "libraries/RcppExports.cpp"<br>
extern "C" {<br>
void Cfunc(complex double *var) {<br>
    cmplx z = C(1.0, 2.0);<br>
    var[0] = z + cexp(var[0]);<br>
return;<br>
}}<br>
<br>
Maybe there is a way not to include all the Faddeeva source files in my packages? But I do not know how to do it.<br>
<br>
Best regards,<br>
<br>
Pierre L.<br>
<br>
<br>
<br>
-- <br>
Pierre Lafaye de Micheaux<br>
<br>
Adresse courrier:<br>
Université de Montréal<br>
Pavillon André-Aisenstadt<br>
Département de Mathématiques et Statistique<br>
CP 6128 Succursale Centre-ville<br>
Montréal Qc H3C 3J7<br>
CANADA<br>
<br>
Adresse physique:<br>
Département de Mathématiques et Statistique<br>
Bureau 4249, Pavillon André-Aisenstadt<br>
2920, chemin de la Tour<br>
Montréal, Québec H3T 1J4<br>
CANADA<br>
<br>
Tél.: (00-1) <a href="tel:514-343-6607" value="+15143436607" target="_blank">514-343-6607</a> / Fax: (00-1) <a href="tel:514-343-5700" value="+15143435700" target="_blank">514-343-5700</a><br>
<a href="mailto:lafaye@dms.umontreal.ca" target="_blank">lafaye@dms.umontreal.ca</a><br>
<a href="http://www.biostatisticien.eu" rel="noreferrer" target="_blank">http://www.biostatisticien.eu</a><br>
<br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-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-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></blockquote></div><br></div>