5.1 Integer-Valued Matrix Size Functions

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

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

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

int rows(vector x)
The number of rows in the vector x

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

int rows(matrix x)
The number of rows in the matrix x

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

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

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