Stan transformed parameters question

Hi,
I am struggling with how to make stan to calculate matrix x row_vector in stan. I do not want to expand my row_vector to a matrix to do matrix x matrix calculation.

data {
    matrix[I, P2] Z;
}
parameters {
    vector [P2] theta;
}
transformed parameters {
    row_vector[I] Ztheta = Z * theta'; 
}

I get the error saying "No matches for: matrix * row_vector". I can understand stan can not calculate matrix* vector_row, but I do not know how to make the equation run, with only getting a row_vector[I] ranther than a matrix [I, P2].

Any one can help me on this problem, I am very appreciated!

Are you sure you don’t want to use rep_matrix to expand your row_vector then use the element-wise multiplication operator “.*”?

Yes, I mean I want a vector for the output. If I expand theta to a matrix, say matrix[ P2, I], then any method to get a vector [I] rather than a matrix [I,I] or [I, 1]?

What is the precise computation you want to occur? A dot product maybe?

I am not sure. The reason I want a vector output instead of a matrix is that I can use the vector to the future calculation where all other variables are vectors as well. If I expand to a matrix here, all my output would be all matrix, giving me too many reduplicated rows/columns.

I think I need more info about your model. Can you post the code and a brief explanation of what you’re trying to model?