You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/reference-manual/expressions.qmd
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -301,6 +301,19 @@ The empty expression `[ ]` is ambiguous and therefore is not
301
301
allowed and similarly expressions such as `[ [ ] ]` or
302
302
`[ [ ], [ ] ]` are not allowed.
303
303
304
+
### Empty vectors and matrices {-}
305
+
306
+
If needed, it is possible to create an empty vector with
307
+
```stan
308
+
rep_vector(e, 0)
309
+
```
310
+
where the first expression `e` needs to scalar of type `real`.
311
+
312
+
If needed, it is possible to create an empty matrix with
313
+
```stan
314
+
rep_matrix(e, 0, 0)
315
+
```
316
+
where the first expression `e` needs to scalar of type `real`.
304
317
305
318
### Array expressions {-}
306
319
@@ -334,6 +347,21 @@ array[2, 3] int b = { { 1, 2, 3 },
334
347
{ 4, 5, 6 } };
335
348
```
336
349
350
+
### Empty arrays {-}
351
+
352
+
The empty array expression (`{ }`) is not allowed. See more about restrictions on array expressions in subsection [Restrictions on values](#array-expressions).
353
+
354
+
If needed, it is possible to create an empty array with
355
+
```stan
356
+
rep_array(e, 0)
357
+
```
358
+
where the first expression `e` determines the type of the array. For
359
+
example, `rep_array(0.0, 0)` returns an empty real array of type
360
+
`real[]`, whereas `rep_array({123}, 0)` returns an empty two
361
+
dimensional integer array of type `int[ , ]`. Only the type of the
362
+
first argument is used, so the integer arrays `{123}` and `{0}`
0 commit comments