-
Must each side of an assignment statement have the same dimensions in Stan or can it recycle values? For example
a[1:2] = 9in R is equivalent toa[1:2] = c(9,9)but I suppose for the vectorain Stan, we needa[1:2] = [9,9]? -
The compound declaration section of the reference manual states that
matrix[3, 2] a = b;“declares a matrix variableaand assigns it to the value ofb, which must be of typematrixfor the compound statement to be well formed.” Should this say “assigns it the value ofb?”
Must each side of an assignment statement have the same dimensions in Stan or can it recycle values? For example
a[1:2] = 9in R is equivalent toa[1:2] = c(9,9)but I suppose for the vectorain Stan, we needa[1:2] = [9,9]?
Yes both sides need to have the same dimension and type, there isn’t any implicit recycling. For your a example, you could also use a[1:2] = rep_vector(9, 2)
The compound declaration section of the reference manual states that
matrix[3, 2] a = b;“declares a matrix variableaand assigns it to the value ofb, which must be of typematrixfor the compound statement to be well formed.” Should this say “assigns it the value ofb?”
Good catch, this wording is a little unclear - I’ll open an issue in our docs repo about this