Sidechair

matrix.reverse()

Browse the reference

Reverses a matrix in place so the first row becomes the last and each row reads backward.

Try it in the editor

The effect is a half-turn of the grid: item (r, c) moves to (rows - 1 - r, columns - 1 - c). The shape stays the same.

Applying it twice returns the original matrix.

Syntax

Pine Script
matrix.reverse(id: any matrix type) -> void
matrix.reverse() -> void

Arguments

NameTypeDefaultDescription
idany matrix typerequiredThe matrix to reverse in place: row order and the order inside each row.

Returns

Nothing.

Example

Pine ScriptHalf-turnOpen in editor
//@version=6
indicator("matrix.reverse: half-turn", overlay = false)
matrix<float> m = matrix.new<float>(2, 2, 0.0)
matrix.set(m, 0, 0, 1.0)
matrix.reverse(m)
plot(matrix.get(m, 1, 1), "Now 1")

See also

Runs on Sidechair