matrix_props.is_square¶
Checks if the matrix is a square matrix.
Functions¶
Module Contents¶
- matrix_props.is_square.is_square(mat)¶
Determine if a matrix is square [1].
A matrix is square if the dimensions of the rows and columns are equivalent.
Examples
Consider the following matrix
\[\begin{split}A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix}\end{split}\]our function indicates that this is indeed a square matrix.
import numpy as np from toqito.matrix_props import is_square A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) is_square(A)
True
Alternatively, the following example matrix \(B\) defined as
\[\begin{split}B = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix}\end{split}\]is not square.
import numpy as np from toqito.matrix_props import is_square B = np.array([[1, 2, 3], [4, 5, 6]]) is_square(B)
False
References
- Raises:
ValueError – If variable is not a matrix.
- Parameters:
mat (numpy.ndarray) – The matrix to check.
- Returns:
Returns
True
if the matrix is square andFalse
otherwise.- Return type:
bool