Returns a new matrix where rows and columns are swapped.
An r by c matrix becomes c by r, with item (i, j) of the original at position (j, i). The original is left unchanged.
Transposing is the first step in many products, such as the normal equations of a regression.
Syntax
matrix.transpose(id: any matrix type) -> matrix<>
matrix.transpose() -> matrix<>Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix to flip over its main diagonal. The result is a new matrix. |
Returns
matrix<>: A new matrix, the transpose of the original.
Example
//@version=6
indicator("matrix.transpose: flip", overlay = false)
matrix<float> m = matrix.new<float>(2, 3, 1.0)
t = matrix.transpose(m)
plot(matrix.rows(t), "Rows after transpose")See also
Runs on Sidechair