For example, given a vector A = append_row( rep_vector(1, 5), rep_vector(2, 5) ), do we have an Rstan function that directly reshape A as a 1d array of vectors like B = { rep_vector(1, 5), rep_vector(2, 5) }?

This function is useful to prepare the third argument of the function “map_rect”.

The answer to your question is probably “no”, but you can write whichever of these reshaping functions you want in Stan. Or create them in C++ and create a pull request and we can include them in Stan. I’m guessing from the second note that you want this:

vector[] to_array_of_vectors(matrix x) {
vector[cols(x)] y[rows(x)];
for (i in 1:rows(x))
for (j in 1:cols(x))
y[i, j] = x[i, j];
return y;
}