Rcpp Version 1.1.2
Loading...
Searching...
No Matches
convolve14_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
using namespace
Rcpp
;
8
RcppExport
SEXP
convolve14cpp
(SEXP a, SEXP b){
9
NumericVector
xa(a), xb(b);
10
int
n_xa = xa.size() ;
11
int
n_xb = xb.
size
() ;
12
int
nab = n_xa + n_xb - 1;
13
NumericVector
xab(nab);
14
Fast<NumericVector>
fa(xa), fb(xb), fab(xab) ;
15
16
for
(
int
i = 0; i < n_xa; i++)
17
for
(
int
j = 0; j < n_xb; j++)
18
fab[i + j] += fa[i] * fb[j];
19
20
return
xab ;
21
}
22
23
#include "
loopmacro.h
"
24
LOOPMACRO_CPP
(
convolve14cpp
)
25
RcppExport
#define RcppExport
Definition
RcppCommon.h:140
Rcpp.h
Rcpp::Fast
Definition
Fast.h:27
Rcpp::Vector::size
R_xlen_t size() const
Definition
Vector.h:274
convolve14cpp
RcppExport SEXP convolve14cpp(SEXP a, SEXP b)
Definition
convolve14_cpp.cpp:8
loopmacro.h
LOOPMACRO_CPP
#define LOOPMACRO_CPP(name)
Definition
loopmacro.h:12
Rcpp
Rcpp API.
Definition
algo.h:28
Rcpp::NumericVector
Vector< REALSXP > NumericVector
Definition
instantiation.h:30
inst
examples
ConvolveBenchmarks
convolve14_cpp.cpp
Generated on
for Rcpp Version 1.1.2 by
1.15.0