Apologies if this is a naive question - I'm a beginner with Rcpp. I did see some earlier discussion on similar topic, but I don't think it answered my questions.
I am trying (on Windows) to speed up a function currently written in R. This works very well for real-valued arguments of the function. But it needs to work for complex arguments as well. Here is a stripped down (but still non-working) example of what I am trying to do cppFunction(' ComplexVector test(ComplexVector s, ComplexVector lambda) { int n = s.size(); int m = lambda.size(); ComplexVector out(n); for (int i=0; i < n; ++i) { for (int j=0; j < m; ++j) { out[i] = out[i] - log(s[i] + 1/lambda[j]) / 2; } } return out; } ') I have (at least) 2 problems i) Are the logarithm and exponential functions implemented for complex arguments? If not is there a work-around? ii) What is the best way to specify constants like 1 and 2 as complex constants? This must be easy, but everything I tried so far gives an error (except passing them into the function via an extra ComplexVector argument, but there must be a better way). Many thanks for any help, Martin Ridout
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel