Returns true when a matrix equals its own transpose.
A symmetric matrix mirrors itself across the main diagonal, so item (i, j) equals item (j, i): [[1, 4], [4, 2]] passes and [[1, 4], [5, 2]] fails.
Covariance and correlation matrices are symmetric by construction. A matrix that is not square cannot be symmetric.
Syntax
matrix.is_symmetric(id: matrix<int/float>) -> series bool
matrix.is_symmetric() -> series boolArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | matrix<int/ | required | The matrix compared with its own transpose; every item must equal its mirror across the main diagonal. |
Returns
series bool: true when the matrix equals its transpose, otherwise false.series bool: true when the receiving matrix is symmetric, otherwise false.
Example
//@version=6
indicator("matrix.is_symmetric: correlation", overlay = false)
matrix<float> c = matrix.new<float>(2, 2, 1.0)
matrix.set(c, 0, 1, 0.4)
matrix.set(c, 1, 0, 0.4)
plot(matrix.is_symmetric(c) ? 1 : 0, "Symmetric")See also
Runs on Sidechair