I just want define variable M2_ca=1 if Mc2[i,j]=m, how could i code in rstan?
M2_ca[i,j]=operator==(Mc2[i,j],m);
I just want define variable M2_ca=1 if Mc2[i,j]=m, how could i code in rstan?
M2_ca[i,j]=operator==(Mc2[i,j],m);
Where did you come across this syntax? In 20yrs of coding I’ve never seen anything like that.
Stan Functions Reference, probably.
I guess you’ve never had to deal with C++
Anyway, the operator
keyword is just a weird way to write it as if it were a function signature. The correct way to write Stan code is
M2_ca[i,j] = (Mc2[i,j] == m);
A bit, but clearly not enough to encounter this!