linalg::swapRow
-- swap two rows
in a matrixlinalg::swapRow
(A, r1, r2)
returns a copy
of the matrix A with the rows with indices r1 and
r2 interchanged.
linalg::swapRow(A, r1, r2)
linalg::swapRow(A, r1, r2, c1..c2)
A |
- | an m x n matrix of a domain of category
Cat::Matrix |
r1, r2 |
- | the row indices: positive integers <= m |
c1..c2 |
- | a range of column indices (positive integers <= n) |
a matrix of the same domain type as A
.
linalg::col
, linalg::delCol
, linalg::delRow
, linalg::row
, linalg::setCol
, linalg::setRow
, linalg::swapCol
linalg::swapRow
(A, r1, r2,
c1..c2)
is that only the components from column c1
to column c2
of row r1
are interchanged with
the corresponding components of row r2
.We consider the following matrix:
>> A := matrix(3, 3, (i, j) -> 3*(i - 1) + j)
+- -+ | 1, 2, 3 | | | | 4, 5, 6 | | | | 7, 8, 9 | +- -+
The following command interchanges the first and the
second row of A
. The result is the following matrix:
>> linalg::swapRow(A, 1, 2)
+- -+ | 4, 5, 6 | | | | 1, 2, 3 | | | | 7, 8, 9 | +- -+
If only the components in the first two columns should be affected, we enter:
>> linalg::swapRow(A, 1, 2, 1..2)
+- -+ | 4, 5, 3 | | | | 1, 2, 6 | | | | 7, 8, 9 | +- -+
The third column remains unchanged.