Skip to content

Commit

Permalink
optional head/tail
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk committed May 10, 2023
1 parent 5c2857a commit 8c59db1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions inst/stan/functions/convolve.stan
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ vector convolve_with_rev_pmf(vector x, vector y, int len) {
vector[len] z;
for (s in 1:len) {
z[s] = dot_product(
x[max(1, (s - ylen + 1)):min(s, xlen)],
y[max(1, ylen - s + 1):min(ylen, ylen + xlen - s)]
s < ylen ? head(x, min(s, xlen)) : x[(s - ylen + 1):min(s, xlen)],
s < xlen ? tail(y, min(s, ylen)) : y[max(1, ylen - s + 1):(ylen + xlen - s)]
);
}
return(z);
Expand Down

0 comments on commit 8c59db1

Please sign in to comment.