Returns how many items a matrix holds in total: rows times columns.
A 3 by 4 matrix has 12 elements. Use it to check a matrix against the 100,000 element limit or before a reshape, which needs the same count.
An empty matrix has 0.
Syntax
matrix.elements_count(id: any matrix type) -> series int
matrix.elements_count() -> series intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix to count items in. |
Returns
series int: The number of elements.
Example
//@version=6
indicator("matrix.elements_count: size", overlay = false)
matrix<int> m = matrix.new<int>(3, 4, 0)
plot(matrix.elements_count(m), "Elements")See also
Runs on Sidechair