Algosim documentation: RowSwap

RowSwap

Returns a matrix with two of its rows swapped.

Syntax

Description

If A is a matrix and i and j are valid row indices in A, then RowSwap(A, i, j) returns A with its ith and jth rows swapped.

This is an elementary row operation.

Examples

A ≔ ❨❨5, 1, 2, 3, 4❩, ❨4, 0, 2, 1, 7❩, ❨6, 3, 0, 4, 7❩, ❨4, 5, 2, 3, 9❩, ❨4, 0, 1, 2, 5❩❩
⎛5  1  2  3  4⎞
⎜4  0  2  1  7⎟
⎜6  3  0  4  7⎟
⎜4  5  2  3  9⎟
⎝4  0  1  2  5⎠
RowSwap(A, 2, 4)
⎛5  1  2  3  4⎞
⎜4  5  2  3  9⎟
⎜6  3  0  4  7⎟
⎜4  0  2  1  7⎟
⎝4  0  1  2  5⎠

See also