This is an old version, view current version.

## 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

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

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

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