Commit 77eb0929 authored by Radford Neal's avatar Radford Neal

Merge branch '89' into 89-gradient

parents 77b801f1 7bab621b
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\encoding{UTF-8} \encoding{UTF-8}
\section{CHANGES IN VERSION RELEASED 2019-01-08}{ \section{CHANGES IN VERSION RELEASED 2019-01-11}{
\subsection{INTRODUCTION}{ \subsection{INTRODUCTION}{
\itemize{ \itemize{
...@@ -57,6 +57,10 @@ ...@@ -57,6 +57,10 @@
\item Fixed a bug involving the "scalar stack" that could affect evaluation \item Fixed a bug involving the "scalar stack" that could affect evaluation
of arithmetic operations when deep recursion has occurred. of arithmetic operations when deep recursion has occurred.
}} }}
\subsection{BUG FIXES FROM R CORE RELEASES}{
\itemize{
\item From R-3.4.4: \code{is.na(NULL)} no longer warns. (\PR{16107})
}}
} }
......
Miscellaneous performance improvements. Miscellaneous performance improvements.
Faster is.na, etc. for scalars. Faster is.na, etc. for scalars. Also does bug fix for is.na(NULL).
Speed of sampling without replacement improved for some cases, and Speed of sampling without replacement improved for some cases, and
overhead reduced for small cases of sample. overhead reduced for small cases of sample.
Reduced interpretive overhead.
...@@ -2074,45 +2074,56 @@ static SEXP do_isvector(SEXP call, SEXP op, SEXP args, SEXP rho) ...@@ -2074,45 +2074,56 @@ static SEXP do_isvector(SEXP call, SEXP op, SEXP args, SEXP rho)
#endif #endif
/* Prelude & postlude for fast versions of is.xxx functions. For /* Prelude & postlude for fast versions of is.xxx functions. For
VARIANT_AND and VARIANT_OR, when the result will be a scalar VARIANT_AND and VARIANT_OR of atomic vectors (or NULL), for which
logical, the value is returned via ScalarLogicalMaybeConst - the the result will be a scalar logical, the value is returned via
...fast... routine should store the result in 'ret' and then do a ScalarLogicalMaybeConst - the ...fast... routine should store the
'goto vret'. Otherwise, 'lans' is set to the place to store the result in 'ret' and then do a 'goto vret'. Otherwise, 'lans' is
logical vector result; after the ...fast... routines stores the set to the place to store the logical vector result; after the
result in it, it should let control flow into IS_POSTLUDE. */ ...fast... routines stores the result in it, it should let control
flow into IS_POSTLUDE. */
#define IS_PRELUDE \ #define IS_PRELUDE \
POP_IF_TOP_OF_STACK(x); \ POP_IF_TOP_OF_STACK(x); \
SEXP dims = R_NilValue; \
SEXP names = R_NilValue; \
SEXP ans = R_NilValue; \ SEXP ans = R_NilValue; \
int n = length(x); /* Length of argument & answer */ \ int n = length(x); /* Length of argument & answer */ \
int scalar_ans; /* Answer location if arg scalar, no dim, no names */ \ int scalar_ans; /* Answer location if arg scalar, no dim, no names */ \
int * restrict lans; /* Pointer to where answer is stored */ \ int * restrict lans; /* Pointer to where answer is stored */ \
int ret; /* Scalar result value for length 1 or variant ret */ \ int ret; /* Scalar result value for length 1 or variant ret */ \
if (VARIANT_KIND(variant) != VARIANT_AND \ if (x != R_NilValue && !isVectorAtomic(x) \
&& VARIANT_KIND(variant) != VARIANT_OR) { \ || VARIANT_KIND(variant) != VARIANT_AND \
&& VARIANT_KIND(variant) != VARIANT_OR) { \
SEXP dims, names; \
dims = names = R_NilValue; \
if (isVector(x)) { \ if (isVector(x)) { \
dims = getDimAttrib(x); \
if (dims != R_NilValue) PROTECT(dims); \
names = getAttrib(x, \ names = getAttrib(x, \
isArray(x) ? R_DimNamesSymbol : R_NamesSymbol); \ isArray(x) ? R_DimNamesSymbol : R_NamesSymbol); \
if (names != R_NilValue) PROTECT(names); \ if (names != R_NilValue) PROTECT(names); \
dims = getDimAttrib(x); \
if (dims != R_NilValue) PROTECT(dims); \
} \
if (n != 1 || dims != R_NilValue || names != R_NilValue) { \
ans = allocVector(LGLSXP, n); \
if (dims != R_NilValue) { \
setAttrib (ans, R_DimSymbol, dims); \
UNPROTECT(1); \
} \
if (names != R_NilValue) { \
setAttrib (ans, isArray(x) ? R_DimNamesSymbol : R_NamesSymbol, \
names); \
UNPROTECT(1); \
} \
PROTECT(ans); \
lans = LOGICAL(ans); \
} \ } \
if (n != 1 || dims != R_NilValue || names != R_NilValue) \ else \
PROTECT(ans = allocVector(LGLSXP, n)); \ lans = &scalar_ans; \
lans = ans == R_NilValue ? &scalar_ans : LOGICAL(ans); \
} }
#define IS_POSTLUDE \ #define IS_POSTLUDE \
if (dims != R_NilValue) \ if (ans != R_NilValue) { \
setAttrib (ans, R_DimSymbol, dims); \ UNPROTECT (1); \
if (names != R_NilValue) \
setAttrib (ans, isArray(x) ? R_DimNamesSymbol : R_NamesSymbol, \
names); \
UNPROTECT ((dims!=R_NilValue) + (names!=R_NilValue) + (ans!=R_NilValue)); \
if (ans != R_NilValue) \
return ans; \ return ans; \
} \
ret = *lans; /* Scalar return value */\ ret = *lans; /* Scalar return value */\
vret: \ vret: \
return ScalarLogicalMaybeConst(ret); return ScalarLogicalMaybeConst(ret);
...@@ -2123,6 +2134,13 @@ static SEXP do_fast_isna (SEXP call, SEXP op, SEXP x, SEXP rho, int variant) ...@@ -2123,6 +2134,13 @@ static SEXP do_fast_isna (SEXP call, SEXP op, SEXP x, SEXP rho, int variant)
int i; int i;
switch (TYPEOF(x)) { switch (TYPEOF(x)) {
case NILSXP:
case RAWSXP: /* no such thing as a raw NA */
if (VARIANT_KIND(variant) == VARIANT_AND) { ret = n==0; goto vret; }
if (VARIANT_KIND(variant) == VARIANT_OR) { ret = FALSE; goto vret; }
for (i = 0; i < n; i++)
lans[i] = 0;
break;
case LGLSXP: /* assumes logical same as integer */ case LGLSXP: /* assumes logical same as integer */
case INTSXP: case INTSXP:
if (VARIANT_KIND(variant) == VARIANT_AND) { if (VARIANT_KIND(variant) == VARIANT_AND) {
...@@ -2342,13 +2360,6 @@ static SEXP do_fast_isna (SEXP call, SEXP op, SEXP x, SEXP rho, int variant) ...@@ -2342,13 +2360,6 @@ static SEXP do_fast_isna (SEXP call, SEXP op, SEXP x, SEXP rho, int variant)
} }
# endif # endif
break; break;
case RAWSXP:
/* no such thing as a raw NA */
if (VARIANT_KIND(variant) == VARIANT_AND) { ret = n==0; goto vret; }
if (VARIANT_KIND(variant) == VARIANT_OR) { ret = FALSE; goto vret; }
for (i = 0; i < n; i++)
lans[i] = 0;
break;
/* Same code for LISTSXP and VECSXP : */ /* Same code for LISTSXP and VECSXP : */
#define LIST_VEC_NA(s) \ #define LIST_VEC_NA(s) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment