Rcpp Version 0.10.3
Main Page
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Friends
Macros
convolve12_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
RcppExport
SEXP
convolve12cpp
(SEXP
a
, SEXP
b
){
8
Rcpp::NumericVector
xa
(a),
xb
(b);
9
int
n_xa =
xa
.size(), n_xb = xb.size();
10
Rcpp::NumericVector
xab
(n_xa + n_xb - 1);
11
12
typedef
Rcpp::NumericVector::iterator
vec_iterator ;
13
vec_iterator ia =
xa
.begin(), ib = xb.begin();
14
vec_iterator iab = xab.begin();
15
for
(
int
i
= 0;
i
< n_xa;
i
++)
16
for
(
int
j
= 0;
j
< n_xb;
j
++)
17
iab[
i
+
j
] += ia[
i
] * ib[
j
];
18
19
return
xab
;
20
}
21
22
#include "
loopmacro.h
"
23
LOOPMACRO_CPP
(
convolve12cpp
)
24
inst
examples
ConvolveBenchmarks
convolve12_cpp.cpp
Generated on Sat Mar 23 2013 11:26:07 for Rcpp Version 0.10.3 by
1.8.1.2