|
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 using namespace Rcpp ; 00007 00008 00009 RcppExport SEXP convolve5cpp(SEXP a, SEXP b) { 00010 NumericVector xa(a); int n_xa = xa.size() ; 00011 NumericVector xb(b); int n_xb = xb.size() ; 00012 NumericVector xab(n_xa + n_xb - 1,0.0); 00013 00014 Range r( 0, n_xb-1 ); 00015 for(int i=0; i<n_xa; i++, r++){ 00016 xab[ r ] += xa[i] * xb ; 00017 } 00018 return xab ; 00019 } 00020 00021 #include "loopmacro.h" 00022 LOOPMACRO_CPP(convolve5cpp) 00023