Skip to content

Commit 88d6b53

Browse files
committed
Merge theta=1.0 check into single pass in geometric_lpmf
1 parent 8485f4e commit 88d6b53

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

stan/math/prim/prob/geometric_lpmf.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,14 @@ inline return_type_t<T_prob> geometric_lpmf(const T_n& n,
5858
scalar_seq_view<T_n_ref> n_vec(n_ref);
5959
scalar_seq_view<T_prob_ref> theta_vec(theta_ref);
6060
const size_t max_sz = max_size(n_ref, theta_ref);
61+
bool all_theta_one = true;
6162
for (size_t i = 0; i < max_sz; i++) {
6263
if (value_of(theta_vec[i]) == 1.0) {
6364
if (n_vec[i] > 0) {
6465
return negative_infinity();
6566
}
66-
}
67-
}
68-
bool all_theta_one = true;
69-
for (size_t i = 0; i < stan::math::size(theta); i++) {
70-
if (value_of(theta_vec[i]) != 1.0) {
67+
} else {
7168
all_theta_one = false;
72-
break;
7369
}
7470
}
7571
if (all_theta_one) {

0 commit comments

Comments
 (0)