Hi,

I have now added these 4 operators into Rcpp :

Rcomplex operator*( const Rcomplex& lhs, const Rcomplex& rhs) ;
Rcomplex operator+( const Rcomplex& lhs, const Rcomplex& rhs) ;
Rcomplex operator-( const Rcomplex& lhs, const Rcomplex& rhs) ;
Rcomplex operator/( const Rcomplex& a, const Rcomplex& b) ;

So they will definitely be included in the next version 0.8.6 when we release it.

Romain

Le 17/08/10 02:19, Christian Gunning a écrit :
Dear list,

I'm trying to use the ComplexVector class, and I'm having difficulty
with multiplication. I sugar multiplication, element-by-element
multiplication (no * operator for either), and using temporary
Rcomplex variables (don't really understand what I'm doing here).

I was able to successfully import get("*") as an Rcpp::Function and do
the multiplication through R. Is this the best option for now?

Thanks,
Christian Gunning
University of New Mexico

// doesn't work
SEXP rcpp_hello_world(SEXP i, SEXP ii){
     using namespace Rcpp ;

     ComplexVector y1(i), y2(ii);
     int n(y1.size()), j;
     ComplexVector y3(n), y4(n);
     y3 = y1 * y2;  // no operator
     for (j = 0; j++; j<n) {
         y4[j] = y1[j] + y2[j]; // no operator
     }
     List z            = List::create( y1, y2, y3) ;
     return z ;
}

// does work, doing multiplication in R
SEXP mymult(SEXP input1, SEXP input2) {
     Rcpp::Environment base("package:base");
     Rcpp::Function funbase = base["get"];
     SEXP funbase1 = funbase("*");
     Rcpp::Function funmult(funbase1);
     Rcpp::ComplexVector xxa = funmult(input1, input2);
     return xxa;
}

SEXP rcpp_hello_world(SEXP i, SEXP ii){
     using namespace Rcpp ;
     ComplexVector y3( mymult(i, ii) );
     return y3 ;
}


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/bzoWrs : Rcpp svn revision 2000
|- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th
`- http://bit.ly/aAyra4 : highlight 0.2-2

_______________________________________________
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

Reply via email to