I am working on converting my function in R into the Stan format and I am a little confused on how I should code my 3D array. I need to input data into my 3D array and it must be able to undergo matrix multiplication. Any feed back on how to reformat this function would be helpful, but particularly if I should be using real Nf[ , , ] or matrix[ , ] Nf[ ] for my 3D array.

```
functions {
do.function(int mesh, int time, int Q, vector dat, vector Fe, real cv_q, real cv, real sigma.p, real R0, real S0, real steep, matrix K) {
real Nf[mesh, time, Q];
real RR;
vector[time] Nrand;
Nf[,1,] = rep_matrix(dat, Q) ;
Nf[,1,] <- Nf[,1,] + normal_rng(rep_vector(0, time), cv_q * dat);
if (Nf < 0) { Nf == 0 }; // make sure there are no negatives
for (t in 2:time){
for (q in 1:Q){
real E;
real Recruits;
Nrand = normal_rng(0, sigma.p);
Nf[, t, q] = K .* Nf[, t-1, q] * dx; // K is a mesh x mesh matrix (200x200)
E = sum(Fe * Nf[, t-1, q]) * dx ;
// BH equation
Recruits = (4 * steep * exp(R0) * E) / ((S0 * (1 - steep)) + (E * (5 * steep - 1)));
RR = exp(normal_rng(log(Recruits) - ((cv * log(Recruits))^2)/2, cv * log(Recruits) ));
Nf[, t, q] = Nf[, t, q] + (RR+ Nrand) ;
} // end of Q loop
if (Nf < 0) { Nf == 0 }; // make sure there are no negatives
} // end of T loop
} // end of fxn
```

And I am getting the following error @ the line with: Nf[,1,] = rep_matrix(dat, Q)

```
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
Info: assignment operator <- deprecated in the Stan language; use = instead.
Dimension mismatch in assignment; variable name = Nf, type = real[ , ]; right-hand side type = matrix.
Illegal statement beginning with non-void expression parsed as
Nf[:, 1, :]
```