# linalg::swapRow

Swap two rows in a matrix

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

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

## Description

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

The effect of ```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`.

## Examples

### Example 1

We consider the following matrix:

`A := matrix(3, 3, (i, j) -> 3*(i - 1) + j)`

The following command interchanges the first and the second row of `A`. The result is the following matrix:

`linalg::swapRow(A, 1, 2)`

If only the components in the first two columns should be affected, we enter:

`linalg::swapRow(A, 1, 2, 1..2)`

The third column remains unchanged.

## Parameters

 `A` An m×n matrix of a domain of category `Cat::Matrix` `r1`, `r2` The row indices: positive integers less or equal to m `c1 .. c2` A range of column indices (positive integers less or equal to n)

## Return Values

Matrix of the same domain type as `A`.