[Rcpp-devel] as<arma::cx_double>(x)
baptiste auguie
baptiste.auguie at googlemail.com
Wed Oct 26 04:05:58 CEST 2011
Dear list,
I'm probably missing something basic, but I expected the following to work,
library(RcppArmadillo)
library(inline)
fx <- cxxfunction(signature(x = "Rcomplex") , '
arma::cx_double y = as<arma::cx_double>(x);
return wrap( y ) ;
', plugin = "RcppArmadillo" )
fx( 1+2i )
yet it fails to compile. I believe I need a conversion since arma does
not know what to do with Rcomplex objects, e.g. multiplying x by i =
arma::cx_double(0,1) yields
error: no match for 'operator*' in 'x * i'
I've successfully used cx_vec instead of cx_double,
fx <- cxxfunction(signature(x = "Rcomplex") , '
arma::cx_vec y = as<arma::cx_vec>(x);
const arma::cx_double i = arma::cx_double(0,1);
return wrap( y * i ) ;
', plugin = "RcppArmadillo" )
fx( 1+2i )
Does this make sense?
Best regards,
baptiste
More information about the Rcpp-devel
mailing list