Skip to content

Commit d255a7b

Browse files
merge from master branch
2 parents 731f958 + dedec9d commit d255a7b

File tree

28 files changed

+450
-187
lines changed

28 files changed

+450
-187
lines changed

ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2014-02-23 Kevin Ushey <[email protected]>
2+
3+
* inst/include/Rcpp/DataFrame.h: better nrows behavior
4+
5+
2014-02-17 Romain Francois <[email protected]>
6+
7+
* inst/include/Rcpp/traits/un_pointer.h: fix bug in un_pointer for object<T>
8+
9+
2014-02-16 JJ Allaire <[email protected]>
10+
11+
* src/attributes.cpp Replace (incorrect) call to
12+
Rcpp::internal::jumpToTop with Rf_onintr
13+
114
2014-02-07 Kevin Ushey <[email protected]>
215

316
* inst/include/Rcpp/Reference.h: Add default ctor

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
33
Version: 0.11.0.2
4-
Date: 2014-02-07
4+
Date: 2014-02-08
55
Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "[email protected]" ),
66
person("Romain", "Francois", role = "aut", email = "[email protected]"),
77
person("JJ", "Allaire", role = "ctb", email = "[email protected]"),

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ and `Rcpp::as` which are highly flexible and extensible, as documented
2525
in the [Rcpp-extending](http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-extending.pdf) vignette.
2626

2727
Rcpp also provides Rcpp modules, a framework that allows exposing
28-
C++ functions and classes to the R level. The [Rcpp-modules]((http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-modules.pdf) vignette
28+
C++ functions and classes to the R level. The [Rcpp-modules](http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-modules.pdf) vignette
2929
details the current set of features of Rcpp-modules.
3030

3131
Rcpp includes a concept called Rcpp sugar that brings many R functions
3232
into C++. Sugar takes advantage of lazy evaluation and expression templates
3333
to achieve great performance while exposing a syntax that is much nicer
34-
to use than the equivalent low-level loop code. The [Rcpp-sugar]((http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-sugar.pdf)
34+
to use than the equivalent low-level loop code. The [Rcpp-sugar](http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-sugar.pdf)
3535
gives an overview of the feature.
3636

3737
Rcpp attributes provide a high-level syntax for declaring C++
@@ -40,7 +40,7 @@ required to invoke them. Attributes are intended to facilitate both
4040
interactive use of C++ within R sessions as well as to support R
4141
package development. Attributes are built on top of Rcpp modules and
4242
their implementation is based on previous work in the inline package.
43-
See the [Rcpp-atttributes]((http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-attributes.pdf) vignettes for more details.
43+
See the [Rcpp-atttributes](http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-attributes.pdf) vignettes for more details.
4444

4545
## Documentation
4646

inst/NEWS.Rd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,22 @@
1111
objects
1212
\item Add missing default constructor to Reference class that was
1313
omitted in the header-only rewrite
14+
\item Fixes re: the NA, NaN handling for the IndexHash class, as well
15+
as the vector .sort() method. These fixes ensure that sugar functions
16+
depending on IndexHash (unique, sort_unique, match) will now properly
17+
handle NA and NaN values for numeric vectors.
18+
\item DataFrame::nrows now more accurately mimics R's internal behavior
19+
(checks the row.names attribute)
1420
}
21+
\item Changes in Rcpp Attributes
22+
\itemize{
23+
\item Fix issue preventing packages with Rcpp::interfaces attribute
24+
from compiling.
25+
}
26+
\item Changes in Rcpp modules
27+
\itemize{
28+
\item \code{un_pointer} implementation for \code{object} was wrong.
29+
}
1530
}
1631
}
1732

inst/examples/Attributes/Export.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ List lapplyCpp(List input, Function f) {
3737
output.names() = input.names();
3838

3939
return output;
40-
}
40+
}

inst/examples/ConvolveBenchmarks/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ all : $(c_sharedlibs) $(cpp_sharedlibs)
2626
PKG_CPPFLAGS="$(RCPPFLAGS) $(RCPPINCL)" PKG_LIBS="$(RLDFLAGS) $(RCPPLIBS)" R CMD SHLIB $<
2727

2828
run : $(c_sharedlibs) $(cpp_sharedlibs)
29-
Rscript exampleRCode.r
29+
Rscript exampleRCode.r

inst/include/Rcpp/DataFrame.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ namespace Rcpp{
6060
}
6161

6262
inline int nrows() const {
63-
return Rf_length( VECTOR_ELT(Parent::get__(), 0) );
63+
SEXP rn = Rf_getAttrib( Parent::get__(), R_RowNamesSymbol );
64+
if (TYPEOF(rn) == INTSXP && LENGTH(rn) == 2 && INTEGER(rn)[0] == NA_INTEGER)
65+
return INTEGER(rn)[1];
66+
if (Rf_isNull(rn))
67+
return 0;
68+
return LENGTH(rn);
6469
}
6570

6671
static DataFrame_Impl create(){

inst/include/Rcpp/hash/IndexHash.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// from Simon's fastmatch package
55
//
66
// Copyright (C) 2010, 2011 Simon Urbanek
7-
// Copyright (C) 2012 - 2014 Dirk Eddelbuettel and Romain Francois
7+
// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois
8+
// Copyright (C) 2014 Dirk Eddelbuettel, Romain Francois and Kevin Ushey
89
//
910
// This file is part of Rcpp.
1011
//
@@ -159,18 +160,25 @@ namespace Rcpp{
159160
#endif
160161
}
161162

163+
inline bool not_equal(const STORAGE& lhs, const STORAGE& rhs) {
164+
return ! internal::NAEquals<STORAGE>()(lhs, rhs);
165+
}
162166

163167
bool add_value(int i){
164168
RCPP_DEBUG_2( "%s::add_value(%d)", DEMANGLE(IndexHash), i )
165169
STORAGE val = src[i++] ;
166170
int addr = get_addr(val) ;
167-
while (data[addr] && src[data[addr] - 1] != val) {
171+
while (data[addr] && not_equal( src[data[addr] - 1], val)) {
168172
addr++;
169-
if (addr == m) addr = 0;
173+
if (addr == m) {
174+
addr = 0;
175+
}
170176
}
177+
171178
if (!data[addr]){
172179
data[addr] = i ;
173180
size_++ ;
181+
174182
return true ;
175183
}
176184
return false;
@@ -206,8 +214,8 @@ namespace Rcpp{
206214
union dint_u val_u;
207215
/* double is a bit tricky - we nave to normalize 0.0, NA and NaN */
208216
if (val == 0.0) val = 0.0;
209-
if (R_IsNA(val)) val = NA_REAL;
210-
else if (R_IsNaN(val)) val = R_NaN;
217+
if (internal::Rcpp_IsNA(val)) val = NA_REAL;
218+
else if (internal::Rcpp_IsNaN(val)) val = R_NaN;
211219
val_u.d = val;
212220
addr = RCPP_HASH(val_u.u[0] + val_u.u[1]);
213221
return addr ;

inst/include/Rcpp/hash/SelfHash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ namespace sugar{
104104
union dint_u val_u;
105105
/* double is a bit tricky - we nave to normalize 0.0, NA and NaN */
106106
if (val == 0.0) val = 0.0;
107-
if (R_IsNA(val)) val = NA_REAL;
108-
else if (R_IsNaN(val)) val = R_NaN;
107+
if (internal::Rcpp_IsNA(val)) val = NA_REAL;
108+
else if (internal::Rcpp_IsNaN(val)) val = R_NaN;
109109
val_u.d = val;
110110
addr = RCPP_HASH(val_u.u[0] + val_u.u[1]);
111111
return addr ;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2+
/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
3+
//
4+
// NAComparator.h: Rcpp R/C++ interface class library -- comparator
5+
//
6+
// Copyright (C) 2012-2014 Dirk Eddelbuettel, Romain Francois and Kevin Ushey
7+
//
8+
// This file is part of Rcpp.
9+
//
10+
// Rcpp is free software: you can redistribute it and/or modify it
11+
// under the terms of the GNU General Public License as published by
12+
// the Free Software Foundation, either version 2 of the License, or
13+
// (at your option) any later version.
14+
//
15+
// Rcpp is distributed in the hope that it will be useful, but
16+
// WITHOUT ANY WARRANTY; without even the implied warranty of
17+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
// GNU General Public License for more details.
19+
//
20+
// You should have received a copy of the GNU General Public License
21+
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
22+
23+
#ifndef Rcpp__internal__NAComparator__h
24+
#define Rcpp__internal__NAComparator__h
25+
26+
namespace Rcpp{
27+
28+
namespace internal {
29+
30+
inline int StrCmp(SEXP x, SEXP y) {
31+
if (x == NA_STRING) return (y == NA_STRING ? 0 : 1);
32+
if (y == NA_STRING) return -1;
33+
if (x == y) return 0; // same string in cache
34+
return strcmp(char_nocheck(x), char_nocheck(y));
35+
}
36+
37+
template <typename T>
38+
struct NAComparator {
39+
inline bool operator()(T left, T right) const {
40+
return left < right;
41+
}
42+
};
43+
44+
template <>
45+
struct NAComparator<int> {
46+
inline bool operator()(int left, int right) const {
47+
if (left == NA_INTEGER) return false;
48+
if (right == NA_INTEGER) return true;
49+
return left < right;
50+
}
51+
};
52+
53+
template <>
54+
struct NAComparator<double> {
55+
inline bool operator()(double left, double right) const {
56+
57+
bool leftNaN = (left != left);
58+
bool rightNaN = (right != right);
59+
60+
// this branch inspired by data.table: see
61+
// https://github.com/arunsrinivasan/datatable/commit/1a3e476d3f746e18261662f484d2afa84ac7a146#commitcomment-4885242
62+
if (Rcpp_IsNaN(right) and Rcpp_IsNA(left))
63+
return true;
64+
65+
if (leftNaN != rightNaN) {
66+
return leftNaN < rightNaN;
67+
} else {
68+
return left < right;
69+
}
70+
71+
}
72+
73+
};
74+
75+
template <>
76+
struct NAComparator<SEXP> {
77+
inline bool operator()(SEXP left, SEXP right) const {
78+
return StrCmp(left, right) < 0;
79+
}
80+
};
81+
82+
}
83+
84+
}
85+
86+
#endif

0 commit comments

Comments
 (0)