Previous Page Next Page Contents

linalg::swapRow -- swap two rows in a matrix

Introduction

linalg::swapRow(A, r1, r2) returns a copy of the matrix A with the rows with indices r1 and r2 interchanged.

Call(s)

linalg::swapRow(A, r1, r2)
linalg::swapRow(A, r1, r2, c1..c2)

Parameters

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)

Returns

a matrix of the same domain type as A.

Related Functions

linalg::col, linalg::delCol, linalg::delRow, linalg::row, linalg::setCol, linalg::setRow, linalg::swapCol

Details

Example 1

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.




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000