Hi, 

I cannot check this right now (being out) but i think you can just yse "as" : 


arma::cx_mat B = Rcpp::as< arma::cx_mat >( beta ) ;

where beta is your complex matrix from the R side.

Romain

Le 6 août 2010 à 15:56, "baptiste Auguié" <[email protected]> a 
écrit :

> Dear list,
> 
> I finally succeeded in porting some code from R to c++, with great 
> performance improvement, although I suspect there are many ugly things since 
> I don't really know c++. One particular worry of mine is the construct I use 
> to pass a complex matrix from R to the armadillo code. Typically, I do the 
> following (a lot),
> 
> using namespace Rcpp ;
> using namespace RcppArmadillo ;
> using namespace std;
> 
> extern "C" {
> 
> SEXP  foo(SEXP betar, SEXP betai){
> 
>      Rcpp::NumericMatrix Brc(betar), Bic(betai);
>      arma::cx_mat B =  arma::cx_mat( arma::mat(Brc.begin(), 3, N, false),  
> arma::mat(Bic.begin(), 3, N, false)); 
> 
> // [...]
> }
> }
> 
> where betar and betai have been obtained at the R level as Re(beta) and 
> Im(beta).
> 
> Is there a simpler, more efficient and sweeter way?
> 
> Best regards,
> 
> baptiste
> 
> _______________________________________________
> Rcpp-devel mailing list
> [email protected]
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to