Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

181: pre-assign sizes to variables #182

Merged
merged 8 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Authors@R:
comment = c(ORCID = "0000-0003-2386-4031")),
person(given = "Sebastian",
family = "Funk",
role = c("ctb"),
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-2842-3406")))
Description: Provides functions for working with primary
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +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.
- 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`.

# primarycensored 1.0.0
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pcd
pcens
pdist
pprimarycensored
precalculation
primaryeventdistributions
propto
pwindow
Expand Down
6 changes: 4 additions & 2 deletions inst/stan/functions/primarycensored.stan
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ 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[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)};
int n_params = size(params);
int n_primary_params = size(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};

vector[1] y0 = rep_vector(0.0, 1);
result = ode_rk45(primarycensored_ode, y0, lower_bound, {d}, theta, {d, pwindow}, ids)[1, 1];
Expand Down
Loading