The Stan Forums
How to declare a matrix with all elements set to zero in one statement?
Modeling
andrjohns
February 16, 2021, 3:54am
2
matrix[M,N] bases_mat = rep_matrix(0, M, N)
Will do this for you
2 Likes
show post in topic
Related topics
Topic
Replies
Views
Activity
Initializing array to zero
Modeling
4
8119
January 24, 2018
Vector and matrix variables with dimension of size 0
Developers
3
1623
March 9, 2017
Fixing certain matrix elements in the parameter
General
stanc
10
2307
July 31, 2017
What is created from matrix[n,k] ns=rep_matrix(0,n,k)?
General
8
407
November 12, 2020
Function to return number of non-zero elements in a matrix
Modeling
7
971
March 31, 2025