HenrikBengtsson / matrixStats

R package: Methods that Apply to Rows and Columns of Matrices (and to Vectors)
https://cran.r-project.org/package=matrixStats
202 stars 33 forks source link

CRAN: Replace deprecated legacy S constants #219

Closed HenrikBengtsson closed 2 years ago

HenrikBengtsson commented 2 years ago

---------- Forwarded message --------- From: Prof Brian Ripley Date: Sat, Mar 26, 2022 at 10:40 AM Subject: CRAN packages using deprecated legacy S constants ...

That is

BAS BayesLN DynamicGP GIGrvg L1pack Matching NMF POT PearsonDS PreciseSums RobStatTM SimEUCartelLaw SpatialExtremes actuar bfp bnlearn caret chebpol checkmate circular deSolve dynaTree evd evdbayes expint fastmatrix flexclust gcmr geometry ghyp heavy hmma kohonen laGP matrixStats missSOM monomvn plgp pomp rgenoud rknn robustbase rugarch sp spatstat.geom spatstat.random spdep spgwr subplex svd treeperm unmarked vegan

NEWS for 4.2.0 alpha (and R-devel for months before) has

     • The legacy S-compatibility macros DOUBLE_* in R_ext/Constants.h        (included by R.h) are deprecated.

and these packages use them.  The plan is to remove them in R-devel soon after the release of 4.2.0, so please do so in your package before Apr 23.

The standard C99 constants are those used in that header:

define DOUBLE_DIGITS  DBL_MANT_DIG

define DOUBLE_EPS     DBL_EPSILON

define DOUBLE_XMAX    DBL_MAX

define DOUBLE_XMIN    DBL_MIN

defined in or for C++, , so please change to those.

Unfortunately there is no portable way to give a deprecation warning in a header so once these are removed your package will fail to install.

$ grep DOUBLE_ src/*.{c,h}
src/sum2.c:    if (sum > DOUBLE_XMAX) {
src/sum2.c:    } else if (sum < -DOUBLE_XMAX) {
src/mean2_lowlevel_template.h:  if (sum > DOUBLE_XMAX) {
src/mean2_lowlevel_template.h:  } else if (sum < -DOUBLE_XMAX) {
src/productExpSumLog_lowlevel_template.h:    if (y > DOUBLE_XMAX) {
src/productExpSumLog_lowlevel_template.h:    } else if (y < -DOUBLE_XMAX) {
src/rowMeans2_lowlevel_template.h:    if (sum > DOUBLE_XMAX) {
src/rowMeans2_lowlevel_template.h:    } else if (sum < -DOUBLE_XMAX) {
src/rowSums2_lowlevel_template.h:    if (sum > DOUBLE_XMAX) {
src/rowSums2_lowlevel_template.h:    } else if (sum < -DOUBLE_XMAX) {
src/weightedMean_lowlevel_template.h:  if (wtotal > DOUBLE_XMAX || wtotal < -DOUBLE_XMAX) {
src/weightedMean_lowlevel_template.h:  } else if (sum > DOUBLE_XMAX) {
src/weightedMean_lowlevel_template.h:  } else if (sum < -DOUBLE_XMAX) {
yaccos commented 2 years ago

If I have understood this correctly, we have change all occurences of DOUBLE_XMAX to DBL_MAX in the code before R 4.2.0 is released on April 23th.

HenrikBengtsson commented 2 years ago

If I have understood this correctly, we have change all occurences of DOUBLE_XMAX to DBL_MAX in the code before R 4.2.0 is released on April 23th.

Yes, correct.

I've just fixed this in the develop branch.