Rcpp Version 0.9.10
convolve3_cpp.cpp
Go to the documentation of this file.
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 RcppExport SEXP convolve3cpp(SEXP a, SEXP b){
00008     Rcpp::NumericVector xa(a);
00009     Rcpp::NumericVector xb(b);
00010     int n_xa = xa.size() ;
00011     int n_xb = xb.size() ;
00012     int nab = n_xa + n_xb - 1;
00013     Rcpp::NumericVector xab(nab);
00014 
00015     for (int i = 0; i < n_xa; i++)
00016         for (int j = 0; j < n_xb; j++) 
00017             xab[i + j] += xa[i] * xb[j];
00018 
00019     return xab ;
00020 }
00021 
00022 #include "loopmacro.h"
00023 LOOPMACRO_CPP(convolve3cpp)
00024 
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Defines