Skip to content

Commit 6c4c057

Browse files
committed
Merge branch 'master' of github.com:RcppCore/Rcpp
2 parents 935ef84 + 00b1d6b commit 6c4c057

File tree

358 files changed

+6963
-6957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

358 files changed

+6963
-6957
lines changed

inst/examples/Attributes/Export.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,34 @@ using namespace Rcpp;
55

66
// [[Rcpp::export]]
77
int fibonacci(const int x) {
8-
8+
99
if (x == 0) return(0);
1010
if (x == 1) return(1);
11-
11+
1212
return (fibonacci(x - 1)) + fibonacci(x - 2);
1313
}
1414

1515

1616
// [[Rcpp::export("convolveCpp")]]
1717
NumericVector convolve(NumericVector a, NumericVector b) {
18-
18+
1919
int na = a.size(), nb = b.size();
2020
int nab = na + nb - 1;
2121
NumericVector xab(nab);
22-
22+
2323
for (int i = 0; i < na; i++)
2424
for (int j = 0; j < nb; j++)
2525
xab[i + j] += a[i] * b[j];
26-
26+
2727
return xab;
2828
}
2929

3030

3131
// [[Rcpp::export]]
3232
List lapplyCpp(List input, Function f) {
33-
33+
3434
List output(input.size());
35-
35+
3636
std::transform(input.begin(), input.end(), output.begin(), f);
3737
output.names() = input.names();
3838

inst/examples/ConvolveBenchmarks/convolve10_cpp.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
22

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
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
55
// NumericVector that is the problem. So what is it then ?
66
//
7-
// could it be because NumericVector is in a different library than
7+
// could it be because NumericVector is in a different library than
88
// this code, so that operator[] is not inlined ?
9-
//
10-
// clues:
9+
//
10+
// clues:
1111
// - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3538.html
1212

1313
#include <Rcpp.h>
@@ -21,11 +21,11 @@ RcppExport SEXP convolve10cpp(SEXP a, SEXP b){
2121
int n_xb = xb.size() ;
2222
int nab = n_xa + n_xb - 1;
2323
Rcpp::NumericVector xab(nab);
24-
24+
2525
Vec vab(xab.begin()), va(xa.begin()), vb(xb.begin()) ;
26-
26+
2727
for (int i = 0; i < n_xa; i++)
28-
for (int j = 0; j < n_xb; j++)
28+
for (int j = 0; j < n_xb; j++)
2929
vab[i + j] += va[i] * vb[j];
3030

3131
return xab ;

inst/examples/ConvolveBenchmarks/convolve10_cpp.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ class Cache{
33
public:
44
typedef double& proxy ;
55
typedef double* iterator ;
6-
6+
77
Cache( iterator data_) : data(data_){}
8-
8+
99
inline proxy ref(int i){ return data[i] ; }
1010
inline proxy ref(int i) const { return data[i] ; }
11-
12-
private:
11+
12+
private:
1313
iterator data ;
1414
} ;
1515

1616
class Vec {
1717
public:
1818
typedef double& proxy ;
19-
19+
2020
Vec( double* data_ ) : cache(data_){}
2121
inline proxy operator[]( int i){ return cache.ref(i) ; }
2222
inline proxy operator[]( int i) const { return cache.ref(i) ; }
23-
23+
2424
private:
2525
Cache cache ;
2626
} ;

inst/examples/ConvolveBenchmarks/convolve11_cpp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RcppExport SEXP convolve11cpp(SEXP a, SEXP b) {
1111
NumericVector xa(a); int n_xa = xa.size() ;
1212
NumericVector xb(b); int n_xb = xb.size() ;
1313
NumericVector xab(n_xa + n_xb - 1,0.0);
14-
14+
1515
Range r( 0, n_xb-1 );
1616
for(int i=0; i<n_xa; i++, r++){
1717
xab[ r ] += noNA(xa[i]) * noNA(xb) ;

inst/examples/ConvolveBenchmarks/convolve12_cpp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ RcppExport SEXP convolve12cpp(SEXP a, SEXP b){
88
Rcpp::NumericVector xa(a), xb(b);
99
int n_xa = xa.size(), n_xb = xb.size();
1010
Rcpp::NumericVector xab(n_xa + n_xb - 1);
11-
11+
1212
typedef Rcpp::NumericVector::iterator vec_iterator ;
1313
vec_iterator ia = xa.begin(), ib = xb.begin();
1414
vec_iterator iab = xab.begin();
1515
for (int i = 0; i < n_xa; i++)
16-
for (int j = 0; j < n_xb; j++)
16+
for (int j = 0; j < n_xb; j++)
1717
iab[i + j] += ia[i] * ib[j];
1818

1919
return xab;

inst/examples/ConvolveBenchmarks/convolve13_cpp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ T convolve( const T& a, const T& b ){
99
int na = a.size() ; int nb = b.size() ;
1010
T out(na + nb - 1);
1111
typename T::iterator iter_a(a.begin()), iter_b(b.begin()), iter_ab( out.begin() ) ;
12-
12+
1313
for (int i = 0; i < na; i++)
14-
for (int j = 0; j < nb; j++)
14+
for (int j = 0; j < nb; j++)
1515
iter_ab[i + j] += iter_a[i] * iter_b[j];
1616

1717
return out ;

inst/examples/ConvolveBenchmarks/convolve14_cpp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ RcppExport SEXP convolve14cpp(SEXP a, SEXP b){
1212
int nab = n_xa + n_xb - 1;
1313
NumericVector xab(nab);
1414
Fast<NumericVector> fa(xa), fb(xb), fab(xab) ;
15-
15+
1616
for (int i = 0; i < n_xa; i++)
17-
for (int j = 0; j < n_xb; j++)
17+
for (int j = 0; j < n_xb; j++)
1818
fab[i + j] += fa[i] * fb[j];
1919

2020
return xab ;

inst/examples/ConvolveBenchmarks/convolve3_cpp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RcppExport SEXP convolve3cpp(SEXP a, SEXP b){
1313
Rcpp::NumericVector xab(nab);
1414

1515
for (int i = 0; i < n_xa; i++)
16-
for (int j = 0; j < n_xb; j++)
16+
for (int j = 0; j < n_xb; j++)
1717
xab[i + j] += xa[i] * xb[j];
1818

1919
return xab ;

inst/examples/ConvolveBenchmarks/convolve4_cpp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ RcppExport SEXP convolve4cpp(SEXP a, SEXP b) {
1111
int n_xb = xb.size() ;
1212
int nab = n_xa + n_xb - 1;
1313
Rcpp::NumericVector xab(nab,0.0);
14-
14+
1515
double* pa = xa.begin() ;
1616
double* pb = xb.begin() ;
1717
double* pab = xab.begin() ;
18-
int i,j=0;
18+
int i,j=0;
1919
for (i = 0; i < n_xa; i++)
20-
for (j = 0; j < n_xb; j++)
20+
for (j = 0; j < n_xb; j++)
2121
pab[i + j] += pa[i] * pb[j];
2222

2323
return xab ;

inst/examples/ConvolveBenchmarks/convolve5_cpp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RcppExport SEXP convolve5cpp(SEXP a, SEXP b) {
1010
NumericVector xa(a); int n_xa = xa.size() ;
1111
NumericVector xb(b); int n_xb = xb.size() ;
1212
NumericVector xab(n_xa + n_xb - 1,0.0);
13-
13+
1414
Range r( 0, n_xb-1 );
1515
for(int i=0; i<n_xa; i++, r++){
1616
xab[ r ] += xa[i] * xb ;

0 commit comments

Comments
 (0)