Skip to content

Commit 9af6f82

Browse files
committed
use const declaration
1 parent ce8b91a commit 9af6f82

File tree

15 files changed

+403
-403
lines changed

15 files changed

+403
-403
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: phylopomp
22
Type: Package
33
Title: Phylodynamic Inference for POMP Models
4-
Version: 0.15.1.3
4+
Version: 0.15.1.4
55
Date: 2026-01-26
66
Authors@R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"),email="kingaa@umich.edu",comment=c(ORCID="0000-0001-6159-3207")),
77
person(given=c("Qianying"),family="Lin",role=c("aut"),comment=c(ORCID="0000-0001-8620-9910"))

src/sir.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "generics.h"
55
#include "internal.h"
66

7-
static int Infected = 0;
7+
static const int Infected = 0;
88

99
//! SIR process state.
1010
typedef struct {

src/strains.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include "generics.h"
55
#include "internal.h"
66

7-
static int strain1 = 0;
8-
static int strain2 = 1;
9-
static int strain3 = 2;
7+
static const int strain1 = 0;
8+
static const int strain2 = 1;
9+
static const int strain3 = 2;
1010

1111
//! Strains process state.
1212
typedef struct {

src/twoundead.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
#include "generics.h"
55
#include "internal.h"
66

7-
static int host1 = 0;
8-
static int host2 = 1;
9-
static int ghost1 = 2;
10-
static int ghost2 = 3;
11-
static int outside = 4;
7+
static const int host1 = 0;
8+
static const int host2 = 1;
9+
static const int ghost1 = 2;
10+
static const int ghost2 = 3;
11+
static const int outside = 4;
1212

1313
//! TwoUndead process state.
1414
typedef struct {

yaml/add_model.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ GENERICS({%name%},{%gen%})
108108
mapply(
109109
\(d,n) {
110110
render(
111-
r"{static int {%name%} = {%number%};}",
111+
r"{static const int {%name%} = {%number%};}",
112112
name=d,
113113
number=n-1L
114114
)

yaml/src/lbdp.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "generics.h"
55
#include "internal.h"
66

7-
static int deme = 0;
7+
static const int deme = 0;
88

99
//! LBDP process state.
1010
typedef struct {
@@ -65,21 +65,21 @@ double lbdp_proc_t::event_rates (double *rate, int n) const {
6565
template<>
6666
void lbdp_genealogy_t::rinit (void) {
6767
state.n = params.n0;
68-
graft(deme,params.n0);
68+
graft(deme,params.n0);
6969
}
7070

7171
template<>
7272
void lbdp_genealogy_t::jump (int event) {
7373
switch (event) {
7474
case 0:
75-
state.n += 1; birth();
76-
break;
77-
case 1:
78-
state.n -= 1; death();
79-
break;
80-
case 2:
81-
sample();
82-
break;
75+
state.n += 1; birth();
76+
break;
77+
case 1:
78+
state.n -= 1; death();
79+
break;
80+
case 2:
81+
sample();
82+
break;
8383
default: // #nocov
8484
assert(0); // #nocov
8585
break; // #nocov

yaml/src/moran.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "generics.h"
55
#include "internal.h"
66

7-
static int deme = 0;
7+
static const int deme = 0;
88

99
//! Moran process state.
1010
typedef struct {
@@ -63,18 +63,18 @@ double moran_proc_t::event_rates (double *rate, int n) const {
6363
template<>
6464
void moran_genealogy_t::rinit (void) {
6565
state.m = state.g = 0;
66-
graft(deme,params.n);
66+
graft(deme,params.n);
6767
}
6868

6969
template<>
7070
void moran_genealogy_t::jump (int event) {
7171
switch (event) {
7272
case 0:
73-
state.m += 1; birth(); death();
74-
break;
75-
case 1:
76-
state.g += 1; sample();
77-
break;
73+
state.m += 1; birth(); death();
74+
break;
75+
case 1:
76+
state.g += 1; sample();
77+
break;
7878
default: // #nocov
7979
assert(0); // #nocov
8080
break; // #nocov

yaml/src/s2i2r2.cc

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include "generics.h"
55
#include "internal.h"
66

7-
static int host1 = 0;
8-
static int host2 = 1;
9-
static int outside = 2;
7+
static const int host1 = 0;
8+
static const int host2 = 1;
9+
static const int outside = 2;
1010

1111
//! S2I2R2 process state.
1212
typedef struct {
@@ -148,77 +148,77 @@ double s2i2r2_proc_t::event_rates (double *rate, int n) const {
148148
template<>
149149
void s2i2r2_genealogy_t::rinit (void) {
150150
state.S1 = params.S1_0;
151-
state.I1 = params.I1_0;
152-
state.R1 = params.R1_0;
153-
state.S2 = params.S2_0;
154-
state.I2 = params.I2_0;
155-
state.R2 = params.R2_0;
156-
state.N1 = double(params.S1_0+params.I1_0+params.R1_0);
157-
state.N2 = double(params.S2_0+params.I2_0+params.R2_0);
158-
graft(host1,params.I1_0);
159-
graft(host2,params.I2_0);
151+
state.I1 = params.I1_0;
152+
state.R1 = params.R1_0;
153+
state.S2 = params.S2_0;
154+
state.I2 = params.I2_0;
155+
state.R2 = params.R2_0;
156+
state.N1 = double(params.S1_0+params.I1_0+params.R1_0);
157+
state.N2 = double(params.S2_0+params.I2_0+params.R2_0);
158+
graft(host1,params.I1_0);
159+
graft(host2,params.I2_0);
160160
}
161161

162162
template<>
163163
void s2i2r2_genealogy_t::jump (int event) {
164164
switch (event) {
165165
case 0:
166-
state.S1 -= 1; state.I1 += 1; birth(host1,host1);
167-
break;
168-
case 1:
169-
state.S2 -= 1; state.I2 += 1; birth(host2,host2);
170-
break;
171-
case 2:
172-
state.S1 -= 1; state.I1 += 1; birth(host2,host1);
173-
break;
174-
case 3:
175-
state.I1 -= 1; state.R1 += 1; death(host1);
176-
break;
177-
case 4:
178-
state.I2 -= 1; state.R2 += 1; death(host2);
179-
break;
180-
case 5:
181-
state.R1 -= 1; state.S1 += 1;
182-
break;
183-
case 6:
184-
state.R2 -= 1; state.S2 += 1;
185-
break;
186-
case 7:
187-
sample(host1);
188-
break;
189-
case 8:
190-
sample(host2);
191-
break;
192-
case 9:
193-
state.S1 -= 1; state.I1 += 1; graft(outside); migrate(outside,host1);
194-
break;
195-
case 10:
196-
state.S2 -= 1; state.I2 += 1; graft(outside); migrate(outside,host2);
197-
break;
198-
case 11:
199-
state.S1 -= 1; state.N1 -= 1;
200-
break;
201-
case 12:
202-
state.S2 -= 1; state.N2 -= 1;
203-
break;
204-
case 13:
205-
state.I1 -= 1; state.N1 -= 1; death(host1);
206-
break;
207-
case 14:
208-
state.I2 -= 1; state.N2 -= 1; death(host2);
209-
break;
210-
case 15:
211-
state.R1 -= 1; state.N1 -= 1;
212-
break;
213-
case 16:
214-
state.R2 -= 1; state.N2 -= 1;
215-
break;
216-
case 17:
217-
state.S1 += 1; state.N1 += 1;
218-
break;
219-
case 18:
220-
state.S2 += 1; state.N2 += 1;
221-
break;
166+
state.S1 -= 1; state.I1 += 1; birth(host1,host1);
167+
break;
168+
case 1:
169+
state.S2 -= 1; state.I2 += 1; birth(host2,host2);
170+
break;
171+
case 2:
172+
state.S1 -= 1; state.I1 += 1; birth(host2,host1);
173+
break;
174+
case 3:
175+
state.I1 -= 1; state.R1 += 1; death(host1);
176+
break;
177+
case 4:
178+
state.I2 -= 1; state.R2 += 1; death(host2);
179+
break;
180+
case 5:
181+
state.R1 -= 1; state.S1 += 1;
182+
break;
183+
case 6:
184+
state.R2 -= 1; state.S2 += 1;
185+
break;
186+
case 7:
187+
sample(host1);
188+
break;
189+
case 8:
190+
sample(host2);
191+
break;
192+
case 9:
193+
state.S1 -= 1; state.I1 += 1; graft(outside); migrate(outside,host1);
194+
break;
195+
case 10:
196+
state.S2 -= 1; state.I2 += 1; graft(outside); migrate(outside,host2);
197+
break;
198+
case 11:
199+
state.S1 -= 1; state.N1 -= 1;
200+
break;
201+
case 12:
202+
state.S2 -= 1; state.N2 -= 1;
203+
break;
204+
case 13:
205+
state.I1 -= 1; state.N1 -= 1; death(host1);
206+
break;
207+
case 14:
208+
state.I2 -= 1; state.N2 -= 1; death(host2);
209+
break;
210+
case 15:
211+
state.R1 -= 1; state.N1 -= 1;
212+
break;
213+
case 16:
214+
state.R2 -= 1; state.N2 -= 1;
215+
break;
216+
case 17:
217+
state.S1 += 1; state.N1 += 1;
218+
break;
219+
case 18:
220+
state.S2 += 1; state.N2 += 1;
221+
break;
222222
default: // #nocov
223223
assert(0); // #nocov
224224
break; // #nocov

yaml/src/seir.cc

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include "generics.h"
55
#include "internal.h"
66

7-
static int Exposed = 0;
8-
static int Infectious = 1;
7+
static const int Exposed = 0;
8+
static const int Infectious = 1;
99

1010
//! SEIR process state.
1111
typedef struct {
@@ -91,32 +91,32 @@ double seir_proc_t::event_rates (double *rate, int n) const {
9191
template<>
9292
void seir_genealogy_t::rinit (void) {
9393
state.S = params.S0;
94-
state.E = params.E0;
95-
state.I = params.I0;
96-
state.R = params.R0;
97-
state.N = double(params.S0+params.E0+params.I0+params.R0);
98-
graft(0,params.E0);
99-
graft(1,params.I0);
94+
state.E = params.E0;
95+
state.I = params.I0;
96+
state.R = params.R0;
97+
state.N = double(params.S0+params.E0+params.I0+params.R0);
98+
graft(0,params.E0);
99+
graft(1,params.I0);
100100
}
101101

102102
template<>
103103
void seir_genealogy_t::jump (int event) {
104104
switch (event) {
105105
case 0:
106-
state.S -= 1; state.E += 1; birth(Infectious,Exposed);
107-
break;
108-
case 1:
109-
state.E -= 1; state.I += 1; migrate(Exposed,Infectious);
110-
break;
111-
case 2:
112-
state.I -= 1; state.R += 1; death(Infectious);
113-
break;
114-
case 3:
115-
sample(Infectious);
116-
break;
117-
case 4:
118-
state.R -= 1; state.S += 1;
119-
break;
106+
state.S -= 1; state.E += 1; birth(Infectious,Exposed);
107+
break;
108+
case 1:
109+
state.E -= 1; state.I += 1; migrate(Exposed,Infectious);
110+
break;
111+
case 2:
112+
state.I -= 1; state.R += 1; death(Infectious);
113+
break;
114+
case 3:
115+
sample(Infectious);
116+
break;
117+
case 4:
118+
state.R -= 1; state.S += 1;
119+
break;
120120
default: // #nocov
121121
assert(0); // #nocov
122122
break; // #nocov

0 commit comments

Comments
 (0)