This is a legal local declaration

row_vector[K] x[N];

How should you declare this as a function argument

real my_func(row_vector[] x[]){

real my_func(row_vector[] x[3]){

real my_func(row_vector[,] x){

none of these works.

This is a legal local declaration

row_vector[K] x[N];

How should you declare this as a function argument

real my_func(row_vector[] x[]){

real my_func(row_vector[] x[3]){

real my_func(row_vector[,] x){

none of these works.

`real my_func(row_vector[] x)`

I did that. But then

real num_visit = x[0];

fails.

Likely because Stanâ€™s indexing starts at 1 rather than 0.

same failure for

real num_visit = x[1];

actually I would want

row_vector num_visit = x[1];

which also fails

even

row_vector[3] num_visit = x;

fails. thatâ€™s just a direct restatement.

What are the error messages saying? Iâ€™m guessing it didnâ€™t compile?

It should be `real num_visit = x[1][1]`

.

Yes, that worked! thank you. I got it now.

Youâ€™ve declared an array of row vectors, so itâ€™s just `row_vector[]`

as a function type. Thereâ€™s a full explanation in the manual section 6.4, â€śUnsized Argument Typesâ€ť.

It can also be `x[1, 1]`

if you prefer.

1 Like