From d50645d863d63943a3673ba09ef94e6523789ea1 Mon Sep 17 00:00:00 2001 From: Neves-P Date: Tue, 14 Mar 2023 18:23:20 +0100 Subject: [PATCH 01/10] No single quotes in integers For portability without C++14 standard --- src/DAISIE_CS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DAISIE_CS.cpp b/src/DAISIE_CS.cpp index 332f9957..e568ee7b 100644 --- a/src/DAISIE_CS.cpp +++ b/src/DAISIE_CS.cpp @@ -16,7 +16,7 @@ namespace { // maximal number of steps the solver is executing. // prevents odeint from getting stuckle // at-hoc - 'solution'. - static constexpr int default_max_cs_steps = 1'000'000; + static constexpr int default_max_cs_steps = 1000000; static int max_cs_steps = default_max_cs_steps; // step-size factor for adams_bashforth_moulton integration From dc2ea3f250ae52eeff4540f149184e96101cba12 Mon Sep 17 00:00:00 2001 From: Neves-P Date: Tue, 14 Mar 2023 18:23:46 +0100 Subject: [PATCH 02/10] No C++ standard flag in Makevars --- src/Makevars | 1 - src/Makevars.win | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Makevars b/src/Makevars index 1fada8d1..4b994660 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1,2 +1 @@ -CXX_STD = CXX14 PKG_CPPFLAGS = -D_HAS_AUTO_PTR_ETC=0 diff --git a/src/Makevars.win b/src/Makevars.win index 1fada8d1..4b994660 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1,2 +1 @@ -CXX_STD = CXX14 PKG_CPPFLAGS = -D_HAS_AUTO_PTR_ETC=0 From b0275b2e58a315910d2125496cc45dbc63fcba6e Mon Sep 17 00:00:00 2001 From: Neves-P Date: Tue, 14 Mar 2023 18:46:33 +0100 Subject: [PATCH 03/10] Add make_unique feature check [run ci] --- src/DAISIE_odeint.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/DAISIE_odeint.h b/src/DAISIE_odeint.h index a2d531a5..338a0cd1 100644 --- a/src/DAISIE_odeint.h +++ b/src/DAISIE_odeint.h @@ -12,6 +12,20 @@ #include #include +#if !defined(__cpp_lib_make_unique) +#if (__cpp_lib_make_unique < 201304) + +namespace std { + +template +unique_ptr make_unique( Args&& ...args ) +{ + return unique_ptr( new T( std::forward(args)... ) ); +} + +} +#endif +#endif using namespace Rcpp; using namespace boost::numeric::odeint; @@ -45,7 +59,6 @@ class padded_vector_view namespace daisie_odeint { - extern double abm_factor; @@ -89,6 +102,7 @@ namespace daisie_odeint { { if (!J_) { // once-only, generic evaluation + J_ = std::make_unique>(J.size1(), J.size2()); auto single = vector_t(x.size(), 0); auto dxdt = vector_t(x.size()); From d390d13f2749c33fb8cdcdb05c2984ddf36dc28e Mon Sep 17 00:00:00 2001 From: Neves-P Date: Tue, 14 Mar 2023 19:29:27 +0100 Subject: [PATCH 04/10] Credit https://herbsutter.com/gotw/_102/ --- src/DAISIE_odeint.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/DAISIE_odeint.h b/src/DAISIE_odeint.h index 338a0cd1..45cb1942 100644 --- a/src/DAISIE_odeint.h +++ b/src/DAISIE_odeint.h @@ -12,6 +12,8 @@ #include #include +// Implement own make_unique if C++ standard is below 14. +// Adapted from Herb Sutter's post https://herbsutter.com/gotw/_102/ #if !defined(__cpp_lib_make_unique) #if (__cpp_lib_make_unique < 201304) From 273ec777e8e65d4b1ddb52f186f26545e95c16dd Mon Sep 17 00:00:00 2001 From: Neves-P Date: Wed, 15 Mar 2023 11:25:27 +0100 Subject: [PATCH 05/10] Don't mess with the namespace [run ci] thanks @hhildenbrandt! --- src/DAISIE_odeint.h | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/DAISIE_odeint.h b/src/DAISIE_odeint.h index 45cb1942..9957b76d 100644 --- a/src/DAISIE_odeint.h +++ b/src/DAISIE_odeint.h @@ -14,19 +14,14 @@ // Implement own make_unique if C++ standard is below 14. // Adapted from Herb Sutter's post https://herbsutter.com/gotw/_102/ -#if !defined(__cpp_lib_make_unique) -#if (__cpp_lib_make_unique < 201304) - -namespace std { - +#if defined(__cpp_lib_make_unique) && (__cpp_lib_make_unique >= 201304) +using std::make_unique; +#else template -unique_ptr make_unique( Args&& ...args ) +std::unique_ptr make_unique( Args&& ...args ) { - return unique_ptr( new T( std::forward(args)... ) ); + return std::unique_ptr( new T( std::forward(args)... ) ); } - -} -#endif #endif using namespace Rcpp; @@ -105,7 +100,7 @@ namespace daisie_odeint { if (!J_) { // once-only, generic evaluation - J_ = std::make_unique>(J.size1(), J.size2()); + J_ = make_unique>(J.size1(), J.size2()); auto single = vector_t(x.size(), 0); auto dxdt = vector_t(x.size()); for (size_t i = 0; i < J.size1(); ++i) { From d615177bbd707861ff341d5f7f5b682b981f985a Mon Sep 17 00:00:00 2001 From: Neves-P Date: Wed, 15 Mar 2023 13:32:19 +0100 Subject: [PATCH 06/10] make_unique fix in DAISIE_IW [run ci] --- src/DAISIE_IW.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DAISIE_IW.cpp b/src/DAISIE_IW.cpp index 1c74694e..a9a46aae 100644 --- a/src/DAISIE_IW.cpp +++ b/src/DAISIE_IW.cpp @@ -195,10 +195,10 @@ namespace { } int sysdim = pars["sysdim"]; if (1 == sysdim) { - iw2 = std::make_unique>(pars); + iw2 = make_unique>(pars); } else { - iw3 = std::make_unique>(pars); + iw3 = make_unique>(pars); } } From 97a6030944bd3939450d73a33a28a02abf855d76 Mon Sep 17 00:00:00 2001 From: Neves-P Date: Wed, 15 Mar 2023 14:15:08 +0100 Subject: [PATCH 07/10] Compile w C++17 --- DESCRIPTION | 1 + src/DAISIE_IW.cpp | 4 ++-- src/DAISIE_odeint.h | 16 ++-------------- src/Makevars | 1 + src/Makevars.win | 1 + 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 813d99dc..3f30bcb7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -111,6 +111,7 @@ Description: Simulates and computes the (maximum) likelihood of a dynamical extinction. See e.g. Valente et al. 2015. Ecology Letters 18: 844-852, . NeedsCompilation: yes +SystemRequirements: C++17 Encoding: UTF-8 VignetteBuilder: knitr URL: https://github.com/rsetienne/DAISIE diff --git a/src/DAISIE_IW.cpp b/src/DAISIE_IW.cpp index a9a46aae..1c74694e 100644 --- a/src/DAISIE_IW.cpp +++ b/src/DAISIE_IW.cpp @@ -195,10 +195,10 @@ namespace { } int sysdim = pars["sysdim"]; if (1 == sysdim) { - iw2 = make_unique>(pars); + iw2 = std::make_unique>(pars); } else { - iw3 = make_unique>(pars); + iw3 = std::make_unique>(pars); } } diff --git a/src/DAISIE_odeint.h b/src/DAISIE_odeint.h index 9957b76d..20fa9fa2 100644 --- a/src/DAISIE_odeint.h +++ b/src/DAISIE_odeint.h @@ -12,18 +12,6 @@ #include #include -// Implement own make_unique if C++ standard is below 14. -// Adapted from Herb Sutter's post https://herbsutter.com/gotw/_102/ -#if defined(__cpp_lib_make_unique) && (__cpp_lib_make_unique >= 201304) -using std::make_unique; -#else -template -std::unique_ptr make_unique( Args&& ...args ) -{ - return std::unique_ptr( new T( std::forward(args)... ) ); -} -#endif - using namespace Rcpp; using namespace boost::numeric::odeint; @@ -100,7 +88,7 @@ namespace daisie_odeint { if (!J_) { // once-only, generic evaluation - J_ = make_unique>(J.size1(), J.size2()); + J_ = std::make_unique>(J.size1(), J.size2()); auto single = vector_t(x.size(), 0); auto dxdt = vector_t(x.size()); for (size_t i = 0; i < J.size1(); ++i) { @@ -117,7 +105,7 @@ namespace daisie_odeint { RHS& rhs_; std::unique_ptr> J_; - }; + }; } diff --git a/src/Makevars b/src/Makevars index 4b994660..3e7f275e 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1 +1,2 @@ +CXX_STD = CXX17 PKG_CPPFLAGS = -D_HAS_AUTO_PTR_ETC=0 diff --git a/src/Makevars.win b/src/Makevars.win index 4b994660..3e7f275e 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1 +1,2 @@ +CXX_STD = CXX17 PKG_CPPFLAGS = -D_HAS_AUTO_PTR_ETC=0 From e81cedff61db2a54bb047e0395f86a351b215030 Mon Sep 17 00:00:00 2001 From: Neves-P Date: Wed, 15 Mar 2023 14:18:22 +0100 Subject: [PATCH 08/10] Update data [run ci] --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3f30bcb7..e857d7a7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: DAISIE Type: Package Title: Dynamical Assembly of Islands by Speciation, Immigration and Extinction Version: 4.3.3 -Date: 2023-03-10 +Date: 2023-03-15 Depends: R (>= 4.1.0) biocViews: Imports: From 66edec097db9cb474321131893b607c6f4e0cd70 Mon Sep 17 00:00:00 2001 From: Hanno Hildenbrandt Date: Thu, 16 Mar 2023 10:15:42 +0100 Subject: [PATCH 09/10] C++17 --- DESCRIPTION | 2 +- src/DAISIE_CS.cpp | 1 - src/DAISIE_IW.cpp | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e857d7a7..44f58e64 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,7 +3,7 @@ Type: Package Title: Dynamical Assembly of Islands by Speciation, Immigration and Extinction Version: 4.3.3 Date: 2023-03-15 -Depends: R (>= 4.1.0) +Depends: R (>= 4.2.0) biocViews: Imports: deSolve, diff --git a/src/DAISIE_CS.cpp b/src/DAISIE_CS.cpp index e568ee7b..8afa8f8d 100644 --- a/src/DAISIE_CS.cpp +++ b/src/DAISIE_CS.cpp @@ -1,7 +1,6 @@ // [[Rcpp::plugins(cpp14)]] // [[Rcpp::depends(BH)]] - //' @export daisie_odeint_cs #include "config.h" diff --git a/src/DAISIE_IW.cpp b/src/DAISIE_IW.cpp index 1c74694e..ae84a11a 100644 --- a/src/DAISIE_IW.cpp +++ b/src/DAISIE_IW.cpp @@ -1,6 +1,9 @@ //' @export daisie_odeint_iw + // [[Rcpp::plugins(cpp14)]] // [[Rcpp::plugins(openmp)]] +// [[Rcpp::depends(BH)]] +// [[Rcpp::depends(RcppEigen)]] #include "config.h" #include "DAISIE_odeint.h" From 13a4fe84e3edf7df973a99d07d75c2671d608fb6 Mon Sep 17 00:00:00 2001 From: Neves-P Date: Thu, 16 Mar 2023 14:58:48 +0100 Subject: [PATCH 10/10] Increment version number --- DESCRIPTION | 4 ++-- NEWS.md | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 44f58e64..1586e294 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: DAISIE Type: Package Title: Dynamical Assembly of Islands by Speciation, Immigration and Extinction -Version: 4.3.3 -Date: 2023-03-15 +Version: 4.3.4 +Date: 2023-03-16 Depends: R (>= 4.2.0) biocViews: Imports: diff --git a/NEWS.md b/NEWS.md index eaf98bc1..7819a59e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,13 @@ +# DAISIE 4.3.4 + +* Require C++17 via `CXX_STD` flag on Makevars[.win]. +* Add SystemRequirements: C++17 to DESCRIPTION as for that standard +"Writing R Extensions" requires it be explicitly stated. +* Depends on R (>= 4.2.0) due to C++17 requirement on Windows due to Rtools 4.0, +which is used for R 4.0-4.1. Toolchain for Rtools 4.0 is gcc 8.3 but "GCC 9.1 +was the first release with non-experimental C++17 support". as per +https://gcc.gnu.org/. + # DAISIE 4.3.3 * Address problem detected by valgrind: unitialized member variable