Skip to content

Commit

Permalink
Cleaned up code for betabinomial
Browse files Browse the repository at this point in the history
  • Loading branch information
hrue committed Dec 5, 2023
1 parent 0092cc7 commit 3a90799
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion inlaprog/src/my.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ double my_betabinomial_helper(int n, double a)
div_t d = div(n, roll);
int m = d.quot * roll;

#pragma GCC ivdep
#pragma omp simd reduction(+: s0)
for (int i = 0; i < m; i += roll) {
double aa = i + a;
s0 += log(aa * (aa + 1.0) * (aa + 2.0) * (aa + 3.0));
Expand All @@ -258,11 +258,13 @@ double my_betabinomial_helper(int n, double a)

return (s0);
}

double my_betabinomial(int y, int n, double a, double b)
{
double s1 = my_betabinomial_helper(y, a);
double s2 = my_betabinomial_helper(n - y, b);
double s3 = my_betabinomial_helper(n, a + b);

return (s1 + s2 - s3);
}

Expand Down

0 comments on commit 3a90799

Please sign in to comment.