# What is created from matrix[n,k] ns=rep_matrix(0,n,k)?

matrix[n,k] ns=rep_matrix(0,n,k)

`ns` would be a matrix full of 0s with `n` rows and `k` columns:

yes i saw that, will not be a n by k array n consisting of copies of matrix nxk with 0 ?

The doc at the link above says

matrix rep_matrix(real x, int m, int n)
Return the m by n matrix consisting of copies of x.

so I think it should just return a matrix filled will copies of `x` (which is your case is just the real number 0).

what is the difference of this: matrix [n, k] ns = rep_matrix (0, n, k) from this matrix [n, k] rep_matrix (0, n, k) i.e without â€śnsâ€ť what returns?

An error I think. You need the `ns` here (or any other name, it doesnâ€™t have to be `ns`) because thatâ€™s the name of the variable that the matrix is assigned to. So this line

``````matrix [n, k] ns = rep_matrix (0, n, k)
``````

tells Stan to create an n by k matrix with the name `ns`, so that later you can refer to this matrix just by `ns`.

1. you are right! So, it does not create a list (array>2-dimensional?) right?
2. The "matrix[n,k] x[p] " what creates?
thanks a lot for your time
1. Yeah just a single matrix

2. `matrix[n,k] x[p]` would create an array containing `p` matrices, each of which has dimensions `n` by `k`.

thank you so much :)

1 Like