Rcpp Version 1.0.7
ConvolveBenchmarks/convolve3_cpp.cpp

A more efficient version of the basic convolution example from Section 5.10.1 of 'Writing R Extensions', now rewritten for Rcpp and using Rcpp::NumericVector.

// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
// This is a rewrite of the 'Writing R Extensions' section 5.10.1 example
#include <Rcpp.h>
RcppExport SEXP convolve3cpp(SEXP a, SEXP b){
int n_xa = xa.size() ;
int n_xb = xb.size() ;
int nab = n_xa + n_xb - 1;
for (int i = 0; i < n_xa; i++)
for (int j = 0; j < n_xb; j++)
xab[i + j] += xa[i] * xb[j];
return xab ;
}
#include "loopmacro.h"
LOOPMACRO_CPP
#define LOOPMACRO_CPP(name)
Definition: loopmacro.h:12
loopmacro.h
RcppExport
#define RcppExport
Definition: RcppCommon.h:139
Rcpp::Vector::size
R_xlen_t size() const
Definition: Vector.h:276
Rcpp::Vector
Definition: 00_forward_Vector.h:26
convolve3cpp
RcppExport SEXP convolve3cpp(SEXP a, SEXP b)
Definition: convolve3_cpp.cpp:7
Rcpp.h