Skip to content

Commit fcf3caa

Browse files
committed
four more /usr/bin/env r conversions
1 parent 916f550 commit fcf3caa

File tree

6 files changed

+61
-58
lines changed

6 files changed

+61
-58
lines changed

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2016-02-27 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/examples/RcppInline/RcppInlineWithLibsExamples.r: Switched to
4+
using '/usr/bin/env r', switch to using 'cxxfunction' and RcppGSL plugin
5+
6+
* inst/examples/RcppInline/external_pointer.r: Switched to '/usr/bin/env r'
7+
* inst/examples/RcppInline/RcppInlineExample.r: Idem
8+
* inst/examples/ConvolveBenchmarks/overhead.r: Idem
9+
10+
* inst/include/Rcpp/Fast.h (Rcpp): Undo two const declarations
11+
112
2016-02-23 Dirk Eddelbuettel <[email protected]>
213

314
* inst/examples/OpenMP/OpenMPandInline.r: Switched to '/usr/bin/env r'

inst/examples/ConvolveBenchmarks/overhead.r

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/r
1+
#!/usr/bin/env r
22

33
set.seed(42)
44
a <- rnorm(100)
@@ -17,12 +17,8 @@ overhead_cpp <- function(a,b) .Call( overhead_cpp_symbol, a, b )
1717
## load benchmarkin helper function
1818
suppressMessages(library(rbenchmark))
1919

20-
benchmark(
21-
22-
overhead_cpp(a,b),
23-
overhead_c(a,b),
24-
25-
columns=c("test", "replications", "elapsed", "relative", "user.self", "sys.self"),
26-
order="relative",
27-
replications=10000)
28-
20+
res <- benchmark(overhead_cpp(a,b), overhead_c(a,b),
21+
columns=c("test", "replications", "elapsed", "relative", "user.self", "sys.self"),
22+
order="relative",
23+
replications=10000)
24+
print(res)

inst/examples/RcppInline/RcppInlineExample.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/r
1+
#!/usr/bin/env r
22

33
suppressMessages(library(Rcpp))
44
suppressMessages(library(inline))

inst/examples/RcppInline/RcppInlineWithLibsExamples.r

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/r -t
1+
#!/usr/bin/env r
22
#
3-
# Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Romain Francois
3+
# Copyright (C) 2009 - 2016 Dirk Eddelbuettel and Romain Francois
44
#
55
# This file is part of Rcpp.
66
#
@@ -18,6 +18,7 @@
1818
# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1919

2020
suppressMessages(library(Rcpp))
21+
suppressMessages(library(RcppGSL))
2122
suppressMessages(library(inline))
2223

2324
firstExample <- function() {
@@ -29,22 +30,20 @@ firstExample <- function() {
2930
3031
r = gsl_rng_alloc (gsl_rng_default);
3132
32-
printf("generator type: %s\\n", gsl_rng_name (r));
33-
printf("seed = %lu\\n", gsl_rng_default_seed);
33+
printf(" generator type: %s\\n", gsl_rng_name (r));
34+
printf(" seed = %lu\\n", gsl_rng_default_seed);
3435
v = gsl_rng_get (r);
35-
printf("first value = %.0f\\n", v);
36+
printf(" first value = %.0f\\n", v);
3637
3738
gsl_rng_free(r);
3839
return R_NilValue;
3940
'
4041

4142
## turn into a function that R can call
4243
## compileargs redundant on Debian/Ubuntu as gsl headers are found anyway
43-
funx <- cfunction(signature(), gslrng,
44-
includes="#include <gsl/gsl_rng.h>",
45-
Rcpp=FALSE,
46-
cppargs="-I/usr/include",
47-
libargs="-lgsl -lgslcblas")
44+
funx <- cxxfunction(signature(), gslrng,
45+
includes="#include <gsl/gsl_rng.h>",
46+
plugin="RcppGSL")
4847

4948
cat("Calling first example\n")
5049
funx()
@@ -67,9 +66,9 @@ secondExample <- function() {
6766
v = gsl_rng_get (r);
6867
6968
#ifndef BeSilent
70-
printf("generator type: %s\\n", gsl_rng_name (r));
71-
printf("seed = %d\\n", seed);
72-
printf("first value = %.0f\\n", v);
69+
printf(" generator type: %s\\n", gsl_rng_name (r));
70+
printf(" seed = %d\\n", seed);
71+
printf(" first value = %.0f\\n", v);
7372
#endif
7473
7574
gsl_rng_free(r);
@@ -79,19 +78,20 @@ secondExample <- function() {
7978
## turn into a function that R can call
8079
## compileargs redundant on Debian/Ubuntu as gsl headers are found anyway
8180
## use additional define for compile to suppress output
82-
funx <- cfunction(signature(par="numeric"), gslrng,
83-
includes="#include <gsl/gsl_rng.h>",
84-
Rcpp=TRUE,
85-
cppargs="-I/usr/include",
86-
libargs="-lgsl -lgslcblas")
81+
funx <- cxxfunction(signature(par="numeric"), gslrng,
82+
includes="#include <gsl/gsl_rng.h>",
83+
plugin="RcppGSL")
8784
cat("\n\nCalling second example without -DBeSilent set\n")
8885
print(funx(0))
8986

90-
funx <- cfunction(signature(par="numeric"), gslrng,
91-
includes="#include <gsl/gsl_rng.h>",
92-
Rcpp=TRUE,
93-
cppargs="-I/usr/include -DBeSilent",
94-
libargs="-lgsl -lgslcblas")
87+
88+
## now override settings to add -D flag
89+
settings <- getPlugin("RcppGSL")
90+
settings$env$PKG_CPPFLAGS <- paste(settings$PKG_CPPFLAGS, "-DBeSilent")
91+
92+
funx <- cxxfunction(signature(par="numeric"), gslrng,
93+
includes="#include <gsl/gsl_rng.h>",
94+
settings=settings)
9595
cat("\n\nCalling second example with -DBeSilent set\n")
9696
print(funx(0))
9797

@@ -123,12 +123,10 @@ thirdExample <- function() {
123123
## turn into a function that R can call
124124
## compileargs redundant on Debian/Ubuntu as gsl headers are found anyway
125125
## use additional define for compile to suppress output
126-
funx <- cfunction(signature(s="numeric", n="numeric"),
127-
gslrng,
128-
includes="#include <gsl/gsl_rng.h>",
129-
Rcpp=TRUE,
130-
cppargs="-I/usr/include",
131-
libargs="-lgsl -lgslcblas")
126+
funx <- cxxfunction(signature(s="numeric", n="numeric"),
127+
gslrng,
128+
includes="#include <gsl/gsl_rng.h>",
129+
plugin="RcppGSL")
132130
cat("\n\nCalling third example with seed and length\n")
133131
print(funx(0, 5))
134132

@@ -160,14 +158,12 @@ fourthExample <- function() {
160158
## turn into a function that R can call
161159
## compileargs redundant on Debian/Ubuntu as gsl headers are found anyway
162160
## use additional define for compile to suppress output
163-
funx <- cfunction(signature(s="numeric", n="numeric"),
164-
gslrng,
165-
includes=c("#include <gsl/gsl_rng.h>",
166-
"using namespace Rcpp;",
167-
"using namespace std;"),
168-
Rcpp=TRUE,
169-
cppargs="-I/usr/include",
170-
libargs="-lgsl -lgslcblas")
161+
funx <- cxxfunction(signature(s="numeric", n="numeric"),
162+
gslrng,
163+
includes=c("#include <gsl/gsl_rng.h>",
164+
"using namespace Rcpp;",
165+
"using namespace std;"),
166+
plugin="RcppGSL")
171167
cat("\n\nCalling fourth example with seed, length and namespaces\n")
172168
print(funx(0, 5))
173169

inst/examples/RcppInline/external_pointer.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/r -t
1+
#!/usr/bin/env r
22
#
33
# Copyright (C) 2009 - 2010 Romain Francois
44
#

inst/include/Rcpp/Fast.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Fast.h: Rcpp R/C++ interface class library -- faster vectors (less interface)
44
//
5-
// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2016 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -26,19 +26,19 @@ namespace Rcpp {
2626
template <typename VECTOR>
2727
class Fast {
2828
public:
29-
typedef typename VECTOR::stored_type value_type ;
29+
typedef typename VECTOR::stored_type value_type;
3030

31-
Fast( const VECTOR& v_) : v(v_), data( v_.begin() ){}
31+
Fast( /*const*/ VECTOR& v_) : v(v_), data(v_.begin()) {}
3232

33-
inline value_type& operator[]( R_xlen_t i){ return data[i] ; }
34-
inline const value_type& operator[]( R_xlen_t i) const { return data[i] ; }
35-
inline R_xlen_t size() const { return v.size() ; }
33+
inline value_type& operator[](R_xlen_t i) { return data[i]; }
34+
inline const value_type& operator[](R_xlen_t i) const { return data[i]; }
35+
inline R_xlen_t size() const { return v.size(); }
3636

3737
private:
38-
const VECTOR& v ;
39-
value_type* data ;
38+
/*const*/ VECTOR& v;
39+
value_type* data;
4040

41-
} ;
41+
};
4242
}
4343

4444
#endif

0 commit comments

Comments
 (0)