Rcpp Version 1.0.14
All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
convolve4_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
7RcppExport SEXP convolve4cpp(SEXP a, SEXP b) {
10 int n_xa = xa.size() ;
11 int n_xb = xb.size() ;
12 int nab = n_xa + n_xb - 1;
13 Rcpp::NumericVector xab(nab,0.0);
14
15 double* pa = xa.begin() ;
16 double* pb = xb.begin() ;
17 double* pab = xab.begin() ;
18 int i,j=0;
19 for (i = 0; i < n_xa; i++)
20 for (j = 0; j < n_xb; j++)
21 pab[i + j] += pa[i] * pb[j];
22
23 return xab ;
24}
25
26#include "loopmacro.h"
28
29
#define RcppExport
Definition RcppCommon.h:141
R_xlen_t size() const
Definition Vector.h:275
iterator begin()
Definition Vector.h:333
RcppExport SEXP convolve4cpp(SEXP a, SEXP b)
#define LOOPMACRO_CPP(name)
Definition loopmacro.h:12