Skip to content

Commit

Permalink
Merge pull request #9 from mrc-ide/update-dust-0-1-0
Browse files Browse the repository at this point in the history
Move to new packing structure
  • Loading branch information
richfitz authored Aug 16, 2024
2 parents f5ea179 + e452e91 commit d8494d8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Imports:
dust2
LinkingTo:
cpp11,
dust2,
dust2 (>= 0.1.1),
mcstate2
Suggests:
testthat (>= 3.0.0)
Expand Down
2 changes: 1 addition & 1 deletion R/dust.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions inst/dust/cows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ class cows {

using rng_state_type = mcstate::random::generator<real_type>;

static size_t size_state(const shared_state& shared) {
return 4 * (shared.n_herds + shared.n_regions);
static auto packing_state(const shared_state& shared) {
return dust2::packing{{"S_herd", {shared.n_herds}}, {"S_region", {shared.n_regions}}, {"E_herd", {shared.n_herds}}, {"E_region", {shared.n_regions}}, {"I_herd", {shared.n_herds}}, {"I_region", {shared.n_regions}}, {"R_herd", {shared.n_herds}}, {"R_region", {shared.n_regions}}};
}

static auto packing_gradient(const shared_state& shared) {
return dust2::packing{};
}

static void initial(real_type time,
Expand All @@ -71,7 +75,8 @@ class cows {
rng_state_type& rng_state,
real_type * state_next) {
// Start by zeroing everything
std::fill(state_next, state_next + size_state(shared), 0);
const auto len_state = 4 * (shared.n_herds + shared.n_regions);
std::fill(state_next, state_next + len_state, 0);
// Then fill in susceptibles from the mean herd size
//
// Thom: should this be drawn from some distribution? If so that
Expand Down
13 changes: 9 additions & 4 deletions src/cows.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d8494d8

Please sign in to comment.