Le 18/08/10 07:44, Christian Gunning a écrit :
Thanks to all for the helpful suggestions. I was excited to learn
about Armadillo's plans for fft/ifft -- my original interest in Rcpp
was to facilitate the R fft call from C...
For conceptual simplicity, I'm opting for manually adding an operator*
for now.
Note that they will appear in the next version of Rcpp, which is
scheduled (loosely) for the end of august.
Benchmarks show a ~10% speedup over sending large vectors (2
million) to R for multiplication.
One question that I ran into that I don't quite understand -- there
are several permutations of an Rcomplex-returning operator*, depending
upon the type of lhs and rhs (e.g Rcomplex and Rcomplex; Rcomplex and
double; etc.). I admit, the template system is over my head for now,
and this has a low priority for me, but perhaps there's a simple
explanation asides from using separate operator symbols?
Here are 2 definitions that vary in input type:
Rcomplex operator*( const Rcomplex& lhs, const Rcomplex& rhs){
Rcomplex y ;
y.r = lhs.r * rhs.r - lhs.i * rhs.i ;
y.i = lhs.r * rhs.i + rhs.r * lhs.i ;
return y ;
}
Rcomplex operator*( const Rcomplex& lhs, const double& rhs){
Rcomplex y ;
y.r = lhs.r * rhs ;
y.i = lhs.i * rhs ;
return y ;
}
yielding the following compiler error:
rcpp_operators.h:7: error: declaration of C function ‘Rcomplex
operator*(const Rcomplex&, const double&)’ conflicts with
rcpp_operators.h:6: error: previous declaration ‘Rcomplex
operator*(const Rcomplex&, const Rcomplex&)’ here
best,
Christian
Do you include this from a .c file or a .cpp file ? C has no concept of
overloading.
Can you share a small reproducible example that shows the problem.
Romain
--
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