From 8c57a1c2c57bf7d07335503072840e1a51fe76c5 Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Wed, 5 Feb 2025 11:05:59 +0000 Subject: [PATCH 1/2] replace size with num_elements as reported by @sbfnk --- inst/stan/functions/primarycensored.stan | 4 ++-- inst/stan/functions/primarycensored_ode.stan | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/inst/stan/functions/primarycensored.stan b/inst/stan/functions/primarycensored.stan index 30447f84..37e3e779 100644 --- a/inst/stan/functions/primarycensored.stan +++ b/inst/stan/functions/primarycensored.stan @@ -37,8 +37,8 @@ real primarycensored_cdf(data real d, int dist_id, array[] real params, } else { // Use numerical integration for other cases real lower_bound = max({d - pwindow, 1e-6}); - int n_params = size(params); - int n_primary_params = size(primary_params); + int n_params = num_elements(params); + int n_primary_params = num_elements(primary_params); array[n_params + n_primary_params] real theta = append_array(params, primary_params); array[4] int ids = {dist_id, primary_id, n_params, n_primary_params}; diff --git a/inst/stan/functions/primarycensored_ode.stan b/inst/stan/functions/primarycensored_ode.stan index 1df06a20..b2adf94f 100644 --- a/inst/stan/functions/primarycensored_ode.stan +++ b/inst/stan/functions/primarycensored_ode.stan @@ -100,7 +100,7 @@ vector primarycensored_ode(real t, vector y, array[] real theta, } array[primary_params_len] real primary_params; if (primary_params_len) { - int primary_loc = size(theta); + int primary_loc = num_elements(theta); primary_params = theta[primary_loc - primary_params_len + 1:primary_loc]; } From 8f8e15856f037a11864419cb4a2df320e2974c3f Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Wed, 5 Feb 2025 11:31:25 +0000 Subject: [PATCH 2/2] add a news file update --- NEWS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index f93058a8..b51d9dff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,8 +16,9 @@ Development release. ## Bug fixes - Added a missing `@family` tag to the `pcens` functions. This omission resulted in the Weibull analytical solution not being visible in the package documentation. -- Added precalculation of vector sizes to the `primarycensored_cdf()` stan function, avoiding errors on some platforms due to narrowing conversions in aggregate initialisation. +- Added precalculation of vector sizes to the `primarycensored_cdf()` stan function, avoiding errors on some platforms due to narrowing conversions in aggregate initialisation. - Changed `D` to be of type real in `pcens_model.stan` in order to support infinite `relative_obs_time`. +- Switched to using `num_elements()` over `size()` in all stan code to resolve compilation issues on some platforms as reported by @sbfnk. # primarycensored 1.0.0