6.7 Broadcast functions
The following broadcast functions allow vectors, row vectors and matrices to be created by copying a single element into all of their cells. Matrices may also be created by stacking copies of row vectors vertically or stacking copies of column vectors horizontally.
vector
rep_vector
(real x, int m)
Return the size m (column) vector consisting of copies of x.
Available since 2.0
row_vector
rep_row_vector
(real x, int n)
Return the size n row vector consisting of copies of x.
Available since 2.0
matrix
rep_matrix
(real x, int m, int n)
Return the m by n matrix consisting of copies of x.
Available since 2.0
matrix
rep_matrix
(vector v, int n)
Return the m by n matrix consisting of n copies of the (column) vector
v of size m.
Available since 2.0
matrix
rep_matrix
(row_vector rv, int m)
Return the m by n matrix consisting of m copies of the row vector rv
of size n.
Available since 2.0
Unlike the situation with array broadcasting (see section array broadcasting), where there is a distinction between integer and real arguments, the following two statements produce the same result for vector broadcasting; row vector and matrix broadcasting behave similarly.
vector[3] x;
1, 3);
x = rep_vector(1.0, 3); x = rep_vector(
There are no integer vector or matrix types, so integer values are automatically promoted.