Skip to content

Commit

Permalink
Improve Stan Function Name(#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
gowerc authored Jun 19, 2024
1 parent 885eaad commit e6fd6ff
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions inst/stan/base/functions.stan
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ functions {

// Replaces the values of `y` with `replacement` if the corresponding value
// of `x` is less than 0.
matrix if_lt0_else(matrix x, matrix y, real replacement) {
matrix if_gte0_else(matrix x, matrix y, real replacement) {
matrix[rows(x), cols(x)] result;
for (i in 1:rows(x)) {
for (j in 1:cols(x)) {
result[i, j] = x[i, j] < 0 ? replacement : y[i, j];
result[i, j] = x[i, j] >= 0 ? y[i, j] : replacement;
}
}
return result;
}
vector if_lt0_else(vector x, vector y, real replacement) {
vector if_gte0_else(vector x, vector y, real replacement) {
vector[rows(x)] result;
for (i in 1:rows(x)) {
result[i] = x[i] < 0 ? replacement : y[i];
result[i] = x[i] >= 0 ? y[i] : replacement;
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion inst/stan/lm-gsf/functions.stan
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ functions {
vector psi_phi
) {
int nrow = rows(time);
vector[nrow] psi_phi_mod = if_lt0_else(time, psi_phi, 0);
vector[nrow] psi_phi_mod = if_gte0_else(time, psi_phi, 0);

vector[nrow] result = fmin(
8000.0,
Expand Down
2 changes: 1 addition & 1 deletion inst/stan/lm-gsf/link_dsld.stan
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ functions {
matrix[nrows, ncols] psi_kg_matrix = rep_matrix(psi_kg, ncols);
matrix[nrows, ncols] psi_phi_matrix = rep_matrix(psi_phi, ncols);

psi_phi_matrix = if_lt0_else(time, psi_phi_matrix, 0);
psi_phi_matrix = if_gte0_else(time, psi_phi_matrix, 0);

matrix[nrows, ncols] result = fmin(
8000.0,
Expand Down
2 changes: 1 addition & 1 deletion inst/stan/lm-stein-fojo/functions.stan
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ functions {
vector psi_kg
) {
int n = rows(time);
vector[n] psi_ks_mod = if_lt0_else(time, psi_ks, 0);
vector[n] psi_ks_mod = if_gte0_else(time, psi_ks, 0);
vector[n] result = fmin(
8000.0,
psi_bsld .* (
Expand Down
2 changes: 1 addition & 1 deletion inst/stan/lm-stein-fojo/link_dsld.stan
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ functions {
matrix[nrows, ncols] psi_ks_matrix = rep_matrix(psi_ks, ncols);
matrix[nrows, ncols] psi_kg_matrix = rep_matrix(psi_kg, ncols);

matrix[nrows, ncols] psi_ks_matrix_mod = if_lt0_else(time, psi_ks_matrix, 0);
matrix[nrows, ncols] psi_ks_matrix_mod = if_gte0_else(time, psi_ks_matrix, 0);

matrix[nrows, ncols] result = fmin(
8000.0,
Expand Down

0 comments on commit e6fd6ff

Please sign in to comment.