From 2cfa80242e406533f41eba9c1f33472e2af3ff82 Mon Sep 17 00:00:00 2001 From: Sebastian Funk Date: Wed, 11 Dec 2024 10:36:22 +0000 Subject: [PATCH] 177: use `num_elements` instead of `size` (#178) * use `num_elements` instead of `size` * add news item --- NEWS.md | 1 + inst/stan/functions/primarycensored.stan | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 03dfe1c..63e5ba5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,7 @@ 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. +- Changed a call to `size()` to use `num_elements()` instead as an underlying type conversion was causing issues on some platforms. # primarycensored 1.0.0 diff --git a/inst/stan/functions/primarycensored.stan b/inst/stan/functions/primarycensored.stan index c424dde..5534b7a 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}); - array[size(params) + size(primary_params)] real theta = append_array(params, primary_params); - array[4] int ids = {dist_id, primary_id, size(params), size(primary_params)}; + array[num_elements(params) + num_elements(primary_params)] real theta = append_array(params, primary_params); + array[4] int ids = {dist_id, primary_id, num_elements(params), num_elements(primary_params)}; vector[1] y0 = rep_vector(0.0, 1); result = ode_rk45(primarycensored_ode, y0, lower_bound, {d}, theta, {d, pwindow}, ids)[1, 1];