Click or drag to resize
RectangularMatrix  Conversion (RectangularMatrix to SquareMatrix)
Casts a rectangular matrix to a square matrix.

Namespace:  Meta.Numerics.Matrices
Assembly:  Meta.Numerics (in Meta.Numerics.dll) Version: (
public static explicit operator SquareMatrix (
	RectangularMatrix A


Type: Meta.Numerics.MatricesRectangularMatrix
The matrix to cast, which must have an equal number of rows and columns.

Return Value

Type: SquareMatrix
A square matrix, not independent of the original matrix.
InvalidCastExceptionThe row and column dimensions of the matrix are not equal.

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 multiplicants. 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