Actually, ignore that. While testing your code I found other errors.
The first:
-------------------------------------------------
8: vector[la+lb-1] out;
9:
10: out = inv_fft(fft(a) .* fft(b));
^
11: return out;
12:
-------------------------------------------------
Ill-typed arguments supplied to assignment operator =: lhs has type vector and rhs has type complex_vector
Is because you’ve declared out
(and the function return) to be type vector
, but the inv_fft()
function returns a complex_vector
.
Once I make those changes, it compiles fine for me:
modcode = "
functions {
complex_vector conv(vector a, vector b) {
int la = num_elements(a);
int lb = num_elements(b);
complex_vector[la+lb-1] out;
out = inv_fft(fft(a) .* fft(b));
return out;
}
}
data { real y_mean; } parameters { real y; } model { y ~ normal(y_mean, 0); }
"
mod <- cmdstan_model(write_stan_file(modcode))