Rcpp Version 0.12.12
convolve13_cpp.cpp
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2 
3 // This is a rewrite of the 'Writing R Extensions' section 5.10.1 example
4 
5 #include <Rcpp.h>
6 
7 template <typename T>
8 T convolve( const T& a, const T& b ){
9  int na = a.size() ; int nb = b.size() ;
10  T out(na + nb - 1);
11  typename T::iterator iter_a(a.begin()), iter_b(b.begin()), iter_ab( out.begin() ) ;
12 
13  for (int i = 0; i < na; i++)
14  for (int j = 0; j < nb; j++)
15  iter_ab[i + j] += iter_a[i] * iter_b[j];
16 
17  return out ;
18 }
19 
20 
21 RcppExport SEXP convolve13cpp(SEXP a, SEXP b){
23 }
24 
25 #include "loopmacro.h"
27 
#define LOOPMACRO_CPP(name)
Definition: loopmacro.h:12
#define RcppExport
Definition: RcppCommon.h:129
T convolve(const T &a, const T &b)
RcppExport SEXP convolve13cpp(SEXP a, SEXP b)