Skip to content

mean for integer and complex vector #221

@romainfrancois

Description

@romainfrancois
#include <Rcpp.h>
using namespace Rcpp ;

Rcomplex mean_cplx( ComplexVector v ){
  return mean(v);
}

double mean_int( IntegerVector v ){
  return mean(v);
}

/*** R
  v <- 1:10 + 1i
  mean_cplx(v)

  v <- 1:10
  mean_int(v)
*/

fails to compile:

$ RcppScript /tmp/cx.cpp
cx.cpp:5:10: error: no matching function for call to 'mean'
  return mean(v);
         ^~~~
/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include/Rcpp/sugar/functions/mean.h:59:34: note: candidate template ignored: could not match 'VectorBase' against 'Vector'
inline sugar::Mean<REALSXP,NA,T> mean( const VectorBase<REALSXP,NA,T>& t){
                                 ^
cx.cpp:9:10: error: no matching function for call to 'mean'
  return mean(v);
         ^~~~
/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include/Rcpp/sugar/functions/mean.h:59:34: note: candidate template ignored: could not match 'VectorBase' against 'Vector'
inline sugar::Mean<REALSXP,NA,T> mean( const VectorBase<REALSXP,NA,T>& t){
                                 ^
2 errors generated.
make: *** [cx.o] Error 1
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include  -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include"    -fPIC  -O3 -c cx.cpp -o cx.o
Erreur dans sourceCpp(tail(args, 1), verbose = "-v" %in% args) :
  Error 1 occurred building shared library.
Exécution arrêtée

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions