You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a specific reason we don't have an array[] int, int signature for + and -?
Strictly speaking, a Stan array is a container and we've gone with the definition that a Stan array doesn't have mathematical operations. (Adding two arrays doesn't work, adding an array and anything else doesn't work, etc.)
That said, this might not be the right interpretation of the language now.
@SteveBronder / @WardBrian: is this allowed in the language now? Any reason we wouldn't want to allow it?
Would we get into any trouble if we did allow it in the C++?
There’s really no reason we couldn’t do it, but it would be almost exactly the same as this user defined function (as in, not any faster, just syntax for basically the same code under the hood)
array[] int add(array[] x, array[] y){
int N =size(x);
if(N !=size(y))
reject(“sizes mismatch”)
array[N] result;
for (i in1:N)
result[i] = x[i] + y[i];
return result;
}
Description
When I try to add an array of integers and a single integer, I get the error:
Is there a specific reason we don't have an
array[] int, int
signature for + and -?Example
The following Stan code snippet will results in an error, but would be a well defined (vectorized) opteration I believe.
The text was updated successfully, but these errors were encountered: