## 6.1 Integer-valued matrix size functions

int num_elements(vector x)
The total number of elements in the vector x (same as function rows)
Available since 2.5

int num_elements(row_vector x)
The total number of elements in the vector x (same as function cols)
Available since 2.5

int num_elements(matrix x)
The total number of elements in the matrix x. For example, if x is a $$5 \times 3$$ matrix, then num_elements(x) is 15
Available since 2.5

int rows(vector x)
The number of rows in the vector x
Available since 2.0

int rows(row_vector x)
The number of rows in the row vector x, namely 1
Available since 2.0

int rows(matrix x)
The number of rows in the matrix x
Available since 2.0

int cols(vector x)
The number of columns in the vector x, namely 1
Available since 2.0

int cols(row_vector x)
The number of columns in the row vector x
Available since 2.0

int cols(matrix x)
The number of columns in the matrix x
Available since 2.0

int size(vector x)
The size of x, i.e., the number of elements
Available since 2.26

int size(row_vector x)
The size of x, i.e., the number of elements
Available since 2.26

int size(matrix x)
The size of the matrix x. For example, if x is a $$5 \times 3$$ matrix, then size(x) is 15
Available since 2.26