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