Meta.Numerics Library

## RectangularMatrix Conversion (RectangularMatrix to SquareMatrix) |

Casts a rectangular matrix to a square matrix.

Syntax

- A
- Type: Meta.Numerics.MatricesRectangularMatrix

The matrix to cast, which must have an equal number of rows and columns.

A square matrix, not independent of the original matrix.

Exceptions

Exception | Condition |
---|---|

InvalidCastException | The row and column dimensions of the matrix are not equal. |

Remarks

It can occur that the mode of construction of a RectangularMatrix guarantees that it is actually square. For example, if you multiply an N X M rectangular matrix by an M X N rectangular matrix, the result is an N X N square matrix. However, when determining the type of the product, the .NET compiler considers only the types of the multiplicands. Since a RectangularMatrix times a RectangularMatrix yields a RectangularMatrix, it will consider the type of the product to be RetangularMatrix, even though its rows and column dimensions will be equal. You can use this explicit cast to obtain a SquareMatrix type.

Note that the output of the cast is not independent of the original matrix. This makes the cast operation fast, but changes to the resulting SquareMatrix will also change the original RectangularMatrix. To obtain an independent matrix, use the Copy method.

See Also