On 13 November 2015 at 20:24, Roebuck,Paul L wrote: | Too bad you couldn't just use C++ std::complex, but that's a no-go if your function needs C linkage. | | <http://stackoverflow.com/questions/1063406/c99-complex-support-with-visual-studio> | suggests MS-specific topic, but answers explain more. | | Have you looked at RCpp package?
Rcpp can help quite a bit with all of the mechanics: header files, linking, loading, conversion, ... We don't use it all that much for complex data types but some things certainly work, and Baptiste has a few packages (using RcppArmadillo) which use complex numbers. Here is a quick example: R> library(Rcpp) # load Rcpp, them define a one-liner in the R shell R> cppFunction("ComplexVector timesTwo(ComplexVector x) { ComplexVector y = x+x; return y; }") R> timesTwo(7i) # use it [1] 0+14i R> timesTwo(c(4+2i, 7i)) # vectors or scalars are the same to R [1] 8+ 4i 0+14i R> This should very much work the same way in Windows. And note that we didn't have to specify a single header (though you can of course should you need extra ones -- see many examples at http://gallery.rcpp.org) Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel