[Rcpp-devel] RcppArmadillo: passing complex matrices

baptiste auguie baptiste.auguie at googlemail.com
Fri Aug 6 20:39:54 CEST 2010


Amazing, it works! thanks a lot,

baptiste

On 6 August 2010 17:47,  <romain at r-enthusiasts.com> wrote:
> 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é" <baptiste.auguie at googlemail.com> 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
>> Rcpp-devel at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>



-- 
____________________

Dr. Baptiste Auguié

Departamento de Química Física,
Universidade de Vigo,
Campus Universitario, 36310, Vigo, Spain

tel: +34 9868 18617
http://webs.uvigo.es/coloides
____________________


More information about the Rcpp-devel mailing list