Rcpp Version 1.0.14
Loading...
Searching...
No Matches
convolve3_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
convolve3cpp
(SEXP a, SEXP b){
8
Rcpp::NumericVector
xa(a);
9
Rcpp::NumericVector
xb(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);
14
15
for
(
int
i = 0; i < n_xa; i++)
16
for
(
int
j = 0; j < n_xb; j++)
17
xab[i + j] += xa[i] * xb[j];
18
19
return
xab ;
20
}
21
22
#include "
loopmacro.h
"
23
LOOPMACRO_CPP
(
convolve3cpp
)
24
RcppExport
#define RcppExport
Definition
RcppCommon.h:141
Rcpp.h
Rcpp::Vector
Definition
Vector.h:35
Rcpp::Vector::size
R_xlen_t size() const
Definition
Vector.h:275
convolve3cpp
RcppExport SEXP convolve3cpp(SEXP a, SEXP b)
Definition
convolve3_cpp.cpp:7
loopmacro.h
LOOPMACRO_CPP
#define LOOPMACRO_CPP(name)
Definition
loopmacro.h:12
inst
examples
ConvolveBenchmarks
convolve3_cpp.cpp
Generated on Sun Jan 12 2025 11:21:42 for Rcpp Version 1.0.14 by
1.9.8