# Simple syntax error row\_vector /= real

**URL:** <https://discourse.mc-stan.org/t/simple-syntax-error-row-vector-real/3785>\
**Category:** General\
**Created:** [April 5, 2018, 3:26am UTC](https://discourse.mc-stan.org/t/simple-syntax-error-row-vector-real/3785 "2018-04-05T03:26:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cyril](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@Cyril](https://discourse.mc-stan.org/u/Cyril)\
**Post date:** [April 5, 2018, 3:26am UTC](https://discourse.mc-stan.org/t/simple-syntax-error-row-vector-real/3785/1 "2018-04-05T03:26:10Z")

</div>

Hi there, I am assuming this is a simple issue, I have a matrix ‘expectations’ I want to divide all the elements by the sums of the row. So I used the following code

```
int Y = 10;
int A = 8;
matrix[Y, A] expectations;
real year_total;
for (t in 1:Y) {
  year_total = sum(expectations[t,]);
  expectations[t,] /= year_total;
}

```

But get the following error ‘PARSER EXPECTED: \<expression\>’ the manual says I should be allowed to use the /= operator between a row\_vector and real, so I am unsure whats going on. Any help would be much appreciated.

---

<div class="post-metadata">

**Author:** ![martinmodrak](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/martinmodrak/32/133_2.png) [@martinmodrak](https://discourse.mc-stan.org/u/martinmodrak)\
**Post date:** [April 7, 2018, 4:10pm UTC](https://discourse.mc-stan.org/t/simple-syntax-error-row-vector-real/3785/2 "2018-04-07T16:10:04Z")

</div>

I am not a Stan dev, but this really looks like a bug, especially since `expectations[t,] = expectations[t,] / year_total;` is OK. The compound operators are new so maybe that is something that was overlooked. Consider filing an issue at [https://github.com/stan-dev/stan/issues/](https://github.com/stan-dev/stan/issues/) (with a more minimal example of the issue).

Thanks!

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [April 8, 2018, 3:53am UTC](https://discourse.mc-stan.org/t/simple-syntax-error-row-vector-real/3785/3 "2018-04-08T03:53:41Z")

</div>

I’m not sure but I’m tagging @Bob_Carpenter and @mitzimorris one of whom should know.

Also make sure the values in that matrix are initialized before you divide otherwise you’re dividing by NaN.

---

<div class="post-metadata">

**Author:** ![Cyril](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@Cyril](https://discourse.mc-stan.org/u/Cyril)\
**Post date:** [April 8, 2018, 3:56am UTC](https://discourse.mc-stan.org/t/simple-syntax-error-row-vector-real/3785/4 "2018-04-08T03:56:50Z")

</div>

I am in the process of making a simple reproducible example, the error occurs using stanc() call in R which I use to debug models. I am using rstan\_2.17.3 StanHeaders\_2.17.2, if that helps

---

<div class="post-metadata">

**Author:** ![Cyril](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@Cyril](https://discourse.mc-stan.org/u/Cyril)\
**Post date:** [April 8, 2018, 4:28am UTC](https://discourse.mc-stan.org/t/simple-syntax-error-row-vector-real/3785/5 "2018-04-08T04:28:11Z")

</div>

I have posted an issue in the rstan github page for future reference [here](https://github.com/stan-dev/rstan/issues/513)

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [April 8, 2018, 6:57pm UTC](https://discourse.mc-stan.org/t/simple-syntax-error-row-vector-real/3785/6 "2018-04-08T18:57:08Z")

</div>

Thanks for opening the issue and following up!

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [April 13, 2018, 8:59pm UTC](https://discourse.mc-stan.org/t/simple-syntax-error-row-vector-real/3785/7 "2018-04-13T20:59:07Z")

</div>

I moved the issue to Stan, but you can get there by following the links. The problem is that we don’t support sliced lvalues in compound declare-define.
