Rcpp Version 1.0.9
convolve10_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 version expands convolve8_cpp by making Vec mimic the structure of
4
// NumericVector. It peforms well, so this is is not the structure of
5
// NumericVector that is the problem. So what is it then ?
6
//
7
// could it be because NumericVector is in a different library than
8
// this code, so that operator[] is not inlined ?
9
//
10
// clues:
11
// - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3538.html
12
13
#include <
Rcpp.h
>
14
15
#include "
convolve10_cpp.h
"
16
17
RcppExport
SEXP
convolve10cpp
(SEXP a, SEXP b){
18
Rcpp::NumericVector
xa(a);
19
Rcpp::NumericVector
xb(b);
20
int
n_xa = xa.
size
() ;
21
int
n_xb = xb.
size
() ;
22
int
nab = n_xa + n_xb - 1;
23
Rcpp::NumericVector
xab(nab);
24
25
Vec
vab(xab.
begin
()), va(xa.
begin
()), vb(xb.
begin
()) ;
26
27
for
(
int
i = 0; i < n_xa; i++)
28
for
(
int
j = 0; j < n_xb; j++)
29
vab[i + j] += va[i] * vb[j];
30
31
return
xab ;
32
}
33
34
#include "
loopmacro.h
"
35
LOOPMACRO_CPP
(
convolve10cpp
)
36
RcppExport
#define RcppExport
Definition:
RcppCommon.h:140
Rcpp.h
Rcpp::Vector
Definition:
Vector.h:36
Rcpp::Vector::size
R_xlen_t size() const
Definition:
Vector.h:276
Rcpp::Vector::begin
iterator begin()
Definition:
Vector.h:334
Vec
Definition:
convolve10_cpp.h:16
convolve10cpp
RcppExport SEXP convolve10cpp(SEXP a, SEXP b)
Definition:
convolve10_cpp.cpp:17
convolve10_cpp.h
loopmacro.h
LOOPMACRO_CPP
#define LOOPMACRO_CPP(name)
Definition:
loopmacro.h:12
inst
examples
ConvolveBenchmarks
convolve10_cpp.cpp
Generated on Sat Jul 9 2022 09:14:51 for Rcpp Version 1.0.9 by
1.9.1