Input of map_rec() function

Hi all, I wonder whether the input of map_rec() function should only be 2-d array? Could it be a 3-d array?
I packed all my data into a 3-d array and each shelf is a shard. Here is how I defined my 3-d array:

int<lower = 0> xi[N_THREAD,M+1, 2*(N_DNA + N_RNA)]

And here is my function:

functions{
   vector f(vector alpha, vector beta , real[] xr , int[] xi ){
      int M = size(xr);
      int N_DNA = xi[M+1, 1];
      int N_RNA = xi[M+1, 2];
      int a[M,N_DNA] = xi[1:M,1:N_DNA];
       .....

and the compiler reports the error that

SYNTAX ERROR, MESSAGE(S) FROM PARSER:
Too many indexes, expression dimensions=1, indexes found=2
 error in '/multiple2_2shards.stan' at line 25, column 28
  -------------------------------------------------
    23:    vector f(vector alpha, vector beta , real[] xr , int[] xi ){
    24:       int M = size(xr);
    25:       int N_DNA = xi[M+1, 1];
                                   ^
    26:       int N_RNA = xi[M+1, 2];
  -------------------------------------------------

And my full code is here:
multiple_2shards.stan (3.5 KB)
functions.stan (759 Bytes)
Any advice would be helpful! Thank you!

The thing you pass to map_rect should be 2d. The signatures are strict 3d won’t work. You’ll need to pack and unpack stuff. It’s pretty awkward for now.

For f, int[] xi is a 1d array, so there’s only one index there.

For map_rect(), the 2nd argument is a vector that will be shaped by all parallel jobs, the 3rd argument is a 1-dimensional array of vectors, the last two arguments are 2-dimensional arrays.

Note that, the 2nd and 3rd arguments are input of parameters, and the last two arguments are for data.

I think 3-d array will not work for map_rect()

Thank! Then I need to write a flattern and unflattern functions here to pack the data here.