__Title__

**[M-5] swap()** -- Interchange contents of variables

__Syntax__

*void* **swap(***transmorphic matrix A***,** *transmorphic matrix B***)**

__Description__

**swap(***A***,** *B***)** interchanges the contents of *A* and *B*. *A* and *B* are not
required to be of the same type or dimension.

__Remarks__

There is no faster way than **swap(***A***,** *B***)** to assign *A***=***B* when you do not care
about the contents of *B* after the assignment. For instance, you have the
code

*A* **=** *B*
*B* **=** ...*(matrix expression)*...

Faster is

**swap(***A***,** *B***)**
*B* **=** ...*(matrix expression)*...

The execution time of **swap()** is independent of the size of *A* and *B*, and
**swap()** conserves memory to boot. Pretend that *B* is a 900 *x* 900 matrix.
*A***=***B* is executed, but before *B* is reassigned, two copies of the 900 *x* 900
matrix exist. That does not happen with **swap()**.

__Conformability__

**swap(***A***,** *B***)**:
*input:*
*A*: *r1 x c1*
*B*: *r2 x c2*
*output*
*A*: *r2 x c2*
*B*: *r1 x c1*

__Diagnostics__

**swap(***A***,** *B***)** works only with variables. Do not code, for instance,
**swap(***A***[***i***,***j***],** *A***[***j***,***i***])**. It is not an error, but it will have no effect.

__Source code__

Function is built in.