Skip to content

Commit adfaf2c

Browse files
committed
updates to vignettes, changelog and news
1 parent 89e6d83 commit adfaf2c

File tree

5 files changed

+170
-148
lines changed

5 files changed

+170
-148
lines changed

ChangeLog

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
2018-05-05 Dirk Eddelbuettel <[email protected]>
2+
3+
* vignettes/Rcpp-FAQ.Rmd: Also mention TAS paper
4+
* vignettes/Rcpp-introduction.Rmd: Idem
5+
* vignettes/Rcpp-jss-2011.Rnw: Idem
6+
7+
2018-05-04 Romain Francois <[email protected]>
8+
9+
* inst/include/Rcpp/String.h: Extend StoragePolicy support
10+
* inst/include/Rcpp/vector/00_forward_proxy.h: Idem
11+
* inst/include/Rcpp/vector/Vector.h: Idem
12+
* inst/include/Rcpp/vector/const_generic_proxy.h: Idem
13+
* inst/include/Rcpp/vector/const_string_proxy.h: Idem
14+
* inst/include/Rcpp/vector/generic_proxy.h: Idem
15+
* inst/include/Rcpp/vector/proxy.h: Idem
16+
* inst/include/Rcpp/vector/string_proxy.h: Idem
17+
* inst/include/Rcpp/vector/traits.h: Idem
18+
19+
* inst/unitTests/cpp/Vector.cpp: New test
20+
* inst/unitTests/runit.Vector.R: Idem
21+
122
2018-04-25 Dirk Eddelbuettel <[email protected]>
223

324
* DESCRIPTION (Version, Date): Roll minor version

inst/NEWS.Rd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
\item The optional \code{Timer} class header now undefines
1313
\code{FALSE} which was seen to have side-effects on some platforms
1414
(Romain in \ghpr{847} fixing \ghpr{846}).
15+
\item Optional \code{StoragePolicy} attributes now also work for
16+
string vectors (Romain in \ghpr{850} fixing \ghit{849}).
1517
}
1618
\item Changes in Rcpp Documentation:
1719
\itemize{
1820
\item Two internal links to the introduction published in JSS have been
1921
updated to the changed filename given the newer TAS introduction.
2022
\item Some remaining backticks were replaced with straight quotes
2123
(Ralf Stubner in \ghpr{845}).
24+
\item A citation to the Rcpp introducion in the The American
25+
Statistician has been added to the introductory and FAQ vignettes.
2226
}
2327
}
2428
}

vignettes/Rcpp-FAQ.Rmd

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ vignette: >
8787

8888
# Getting started
8989

90-
## How do I get started
90+
## How do I get started
9191

9292
If you have \pkg{Rcpp} installed, please execute the following command
9393
in \proglang{R} to access the introductory vignette (which is a
94-
variant of the \citet{JSS:Rcpp} and \citet{PeerJ:Rcpp} papers) for a
94+
variant of the \citet{JSS:Rcpp} and \citet{PeerJ:Rcpp,TAS:Rcpp} papers) for a
9595
detailed introduction, ideally followed by at least the Rcpp
9696
Attributes \citep{CRAN:Rcpp:Attributes} vignette:
9797

@@ -104,7 +104,7 @@ vignette("Rcpp-attributes")
104104
If you do not have \pkg{Rcpp} installed, these documents should also be available
105105
whereever you found this document, \textsl{i.e.,} on every mirror site of CRAN.
106106

107-
## What do I need
107+
## What do I need
108108

109109
Obviously, \proglang{R} must be installed. \pkg{Rcpp} provides a
110110
\proglang{C++} API as an extension to the \proglang{R} system. As such, it
@@ -125,7 +125,7 @@ means one needs:
125125
Also see the [RStudio documentation](http://www.rstudio.com/ide/docs/packages/prerequisites)
126126
on pre-requisites for R package development.
127127

128-
## What compiler can I use
128+
## What compiler can I use
129129

130130
On almost all platforms, the GNU Compiler Collection (or `gcc`, which
131131
is also the name of its \proglang{C} language compiler) has to be used along
@@ -250,7 +250,7 @@ Template Library to sum the elements of a numeric vector.
250250
fx <- cxxfunction(signature(x = "numeric"),
251251
'NumericVector xx(x);
252252
return wrap(
253-
std::accumulate(xx.begin(),
253+
std::accumulate(xx.begin(),
254254
xx.end(),
255255
0.0)
256256
);',
@@ -277,7 +277,7 @@ the code in a character string in R. This is easily achieved by using
277277

278278
```{r, eval=FALSE}
279279
fx <- cxxfunction(signature(),
280-
paste(readLines("myfile.cpp"),
280+
paste(readLines("myfile.cpp"),
281281
collapse="\n"),
282282
plugin = "Rcpp")
283283
```
@@ -411,7 +411,7 @@ either approach takes care of a lot of these tedious and error-prone manual
411411
steps.
412412

413413

414-
## But R CMD SHLIB still does not work
414+
## But R CMD SHLIB still does not work
415415

416416
We have had reports in the past where build failures occurred when users had
417417
non-standard code in their `~/.Rprofile` or `Rprofile.site` (or
@@ -422,7 +422,7 @@ invocation of `Rscript -e "..."` (as in \faq{using-r-cmd-shlib}
422422
above) to retrieve settings directly from \pkg{Rcpp} will fail.
423423

424424
You may need to uncomment such non-standard code, or protect it by wrapping
425-
it inside `if (interactive())`, or possibly try to use
425+
it inside `if (interactive())`, or possibly try to use
426426
`Rscript --vanilla` instead of plain `Rscript`.
427427

428428
## What about `LinkingTo `
@@ -688,7 +688,7 @@ will even run the R part at the end.
688688
template <typename T> class square :
689689
public std::unary_function<T,T> {
690690
public:
691-
T operator()( T t) const {
691+
T operator()( T t) const {
692692
return t*t ;
693693
}
694694
};
@@ -757,7 +757,7 @@ writeLines(a, file = "myfile.cpp")
757757
If stored in a file `myfile.cpp`, we can use it via \pkg{inline}:
758758

759759
```{r, eval = FALSE}
760-
fx <- cxxfunction(signature(x_="numeric",
760+
fx <- cxxfunction(signature(x_="numeric",
761761
Y_="matrix",
762762
z_="numeric" ),
763763
paste(readLines("myfile.cpp"),
@@ -838,7 +838,7 @@ random variable distributed as $N(m,s)$.
838838
Using Rcpp Attributes, this can be as simple as
839839

840840
```{r, eval = FALSE}
841-
cppFunction('Rcpp::NumericVector ff(int n) {
841+
cppFunction('Rcpp::NumericVector ff(int n) {
842842
return rnorm(n, 0, 100); }')
843843
set.seed(42)
844844
ff(5)
@@ -992,10 +992,10 @@ values instead.
992992
```{r, eval=FALSE}
993993
myplugin <- getPlugin("Rcpp")
994994
myplugin$env$PKG_CXXFLAGS <- "-std=c++11"
995-
f <- cxxfunction(signature(),
995+
f <- cxxfunction(signature(),
996996
settings = myplugin, body = '
997997
// fails without -std=c++0x
998-
std::vector<double> x = { 1.0, 2.0, 3.0 };
998+
std::vector<double> x = { 1.0, 2.0, 3.0 };
999999
return Rcpp::wrap(x);
10001000
')
10011001
f()
@@ -1025,7 +1025,7 @@ src <- '
10251025
x.attr("dimnames") = dimnms;
10261026
return(x);
10271027
'
1028-
fun <- cxxfunction(signature(),
1028+
fun <- cxxfunction(signature(),
10291029
body=src, plugin="Rcpp")
10301030
fun()
10311031
```
@@ -1156,13 +1156,13 @@ void sample_defaults(
11561156
NumericVector x =
11571157
NumericVector::create(), // Size 0 vector
11581158
bool bias = true, // Set to true
1159-
std::string method =
1159+
std::string method =
11601160
"rcpp rules!") { // Set string
1161-
1161+
11621162
Rcpp::Rcout << "x size: " << x.size() << ", ";
11631163
Rcpp::Rcout << "bias value: " << bias << ", ";
11641164
Rcpp::Rcout << "method value: " << ".";
1165-
1165+
11661166
}
11671167

11681168
/*** R
@@ -1212,7 +1212,7 @@ conda install gxx_linux-64
12121212

12131213
helps within this environment as it installs the corresponding
12141214
`x86_64-conda_cos6-linux-gnu-c++` compiler. Documentation for this and other
1215-
systems is provided
1215+
systems is provided
12161216
[at this page](https://conda.io/docs/user-guide/tasks/build-packages/compiler-tools.html).
12171217

12181218
# Support
@@ -1416,12 +1416,12 @@ To illustrate this phenomenon, consider the following scenario:
14161416
// [[Rcpp::export]]
14171417
Rcpp::NumericVector const_override_ex(
14181418
const Rcpp::NumericVector& X) {
1419-
1419+
14201420
Rcpp::NumericVector Y(X); // Create object
14211421
// from SEXP
1422-
1422+
14231423
Y = Y * 2; // Modify new object
1424-
1424+
14251425
return X; // Return old object
14261426
}
14271427
```
@@ -1454,10 +1454,10 @@ the aforementioned approach is emphasized:
14541454
// [[Rcpp::export]]
14551455
std::string explicit_string_conv(
14561456
Rcpp::CharacterVector X) {
1457-
1457+
14581458
std::string s; // define storage
14591459
s = X[0]; // assign from CharacterVector
1460-
1460+
14611461
return s;
14621462
}
14631463
```
@@ -1467,8 +1467,8 @@ e.g. `std::string s = X[0]`, this would result in the compiler triggering
14671467
a conversion error on _some_ platforms. The error would be similar to:
14681468
14691469
```{bash, eval = FALSE}
1470-
error: no viable conversion from 'Proxy'
1471-
(aka 'string_proxy<16>') to 'std::string'
1470+
error: no viable conversion from 'Proxy'
1471+
(aka 'string_proxy<16>') to 'std::string'
14721472
(aka 'basic_string<char, char_traits<char>,
14731473
allocator<char> >')
14741474
```
@@ -1501,14 +1501,14 @@ via `operator=`, then the resulting `Vector` would have a length of
15011501
// [[Rcpp::export]]
15021502
void vec_scalar_assign(int n, double fill_val) {
15031503
Rcpp::NumericVector X(n);
1504-
Rcpp::Rcout << "Value of Vector " <<
1505-
"on Creation: " <<
1504+
Rcpp::Rcout << "Value of Vector " <<
1505+
"on Creation: " <<
15061506
std::endl << X << std::endl;
1507-
1507+
15081508
X = fill_val;
1509-
1509+
15101510
Rcpp::Rcout << "Value of Vector " <<
1511-
"after Assignment: " <<
1511+
"after Assignment: " <<
15121512
std::endl << X << std::endl;
15131513
}
15141514
```
@@ -1535,9 +1535,9 @@ void mat_scalar_assign(int n, double fill_val) {
15351535
Rcpp::Rcout << "Value of Matrix " <<
15361536
"on Creation: " <<
15371537
std::endl << X << std::endl;
1538-
1538+
15391539
X = fill_val;
1540-
1540+
15411541
Rcpp::Rcout << "Value of Matrix " <<
15421542
"after Assignment: " <<
15431543
std::endl << X << std::endl;
@@ -1612,7 +1612,7 @@ adequately for the majority of \pkg{Rcpp} data types. The notable exception
16121612
that makes what would otherwise be a universal quantifier into an existential
16131613
quantifier is the `CharacterVector` data type. Chiefly, the issue with
16141614
sorting strings is related to how the `CharacterVector` relies upon the
1615-
use of `Rcpp::internal::string_proxy`.
1615+
use of `Rcpp::internal::string_proxy`.
16161616
In particular, `Rcpp::internal::string_proxy` is _not_ MoveAssignable since the
16171617
left hand side of `operator=(const string_proxy \&rhs)` is _not_
16181618
viewed as equivalent to the right hand side before the
@@ -1633,20 +1633,20 @@ approach alongside the problematic STL approach:
16331633
// [[Rcpp::export]]
16341634
Rcpp::CharacterVector preferred_sort(
16351635
Rcpp::CharacterVector x) {
1636-
1636+
16371637
Rcpp::CharacterVector y = Rcpp::clone(x);
16381638
y.sort();
1639-
1639+
16401640
return y;
16411641
}
16421642

16431643
// [[Rcpp::export]]
16441644
Rcpp::CharacterVector stl_sort(
16451645
Rcpp::CharacterVector x) {
1646-
1646+
16471647
Rcpp::CharacterVector y = Rcpp::clone(x);
16481648
std::sort(y.begin(), y.end());
1649-
1649+
16501650
return y;
16511651
}
16521652
```
@@ -1699,7 +1699,7 @@ sort(x)
16991699
rcpp_sort(x)
17001700
```
17011701

1702-
## Package building fails with 'symbols not found'
1702+
## Package building fails with 'symbols not found'
17031703

17041704
R 3.4.0 and later strongly encourage registering dynamically loadable
17051705
symbols. In the stronger form (where `.registration=TRUE` is added to the
@@ -1722,4 +1722,3 @@ elsewhere.
17221722
So if your autogenerated file fails, and a `symbols not found` error is reported
17231723
by the linker, consider running `compileAttributes()` twice. Deleting
17241724
`R/RcppExports.R` and `src/RcppExports.cpp` may also work.
1725-

0 commit comments

Comments
 (0)