How to transform "vector[N] X" into "vector[1] X[N]"?

Suppose I have a vector X of size N, then how can I transform it to an array of size N with each element of the array being a vector of size 1?

before : vector[N] X
after : vector[1] X[N]

Thank You

Before answering, just fyi unless you have some very specific need for this structure the vector[1] X[N] is going to be slow compared to vector[N]. The vector[N] X in C++ is a contiguous array (An Eigen::VectorXd) with some nice stuff around it, while a vector[1] X[N] is an array of arrays (std::vector<Eigen::VectorXd>) where all that nice stuff before is multiplied in size by N making it not so nice. Is there a reason you can’t use vector[N]?

Would just a for loop work for you like the below?

data {
 int N;
 vector[N] X;
transformed data {
 vector[1] X_vec[N];
 for (i in 1:N) {
  X_vec[i][1] = X[i];
1 Like

Thanks @stevebronder
I am actually trying to map a function to a vector of dimension N, but unfortunately this vector is a parameter.
In the map_rect example, the argument vector[] thetas is the only way we could provide job specific parameters, hence the question.

This is the third thread you are asking the very same question for something trivial.

Sorry, but to me asking 3 times the same thing does not help, but falls in the category of unwanted messages. We have people looking around to make sure that things get answered.