|
Rcpp Version 0.9.10
|
00001 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 00002 00003 // This is a rewrite of the 'Writing R Extensions' section 5.10.1 example 00004 00005 #include <Rcpp.h> 00006 00007 using namespace Rcpp ; 00008 RcppExport SEXP convolve14cpp(SEXP a, SEXP b){ 00009 NumericVector xa(a), xb(b); 00010 int n_xa = xa.size() ; 00011 int n_xb = xb.size() ; 00012 int nab = n_xa + n_xb - 1; 00013 NumericVector xab(nab); 00014 Fast<NumericVector> fa(xa), fb(xb), fab(xab) ; 00015 00016 for (int i = 0; i < n_xa; i++) 00017 for (int j = 0; j < n_xb; j++) 00018 fab[i + j] += fa[i] * fb[j]; 00019 00020 return xab ; 00021 } 00022 00023 #include "loopmacro.h" 00024 LOOPMACRO_CPP(convolve14cpp) 00025