# SquareMatrixQ

gives True if m is a square matrix, and False otherwise.

# Details • A matrix m is square if it has the same number of rows and columns, in which case Dimensions[m]{n,n}. »
• SquareMatrixQ works for symbolic as well as numerical matrices.

# Examples

open allclose all

## Basic Examples(3)

Test if an object is a square matrix:

The following matrix is not square:

These are not matrices:

## Scope(9)

### Basic Uses(5)

Test if a real machine-precision matrix is square:

Test if a complex matrix is square:

Test if an exact matrix is square:

Make the matrix square:

Use SquareMatrixQ with a symbolic matrix:

SquareMatrixQ works efficiently with large numerical matrices:

### Special Matrices(4)

Use SquareMatrixQ with sparse matrices:

Use SquareMatrixQ with structured matrices:

Use with a QuantityArray structured matrix:

Use SquareMatrixQ with an identity matrix:

Use SquareMatrixQ with HilbertMatrix:

## Applications(1)

Define a function that only evaluates for explicit square matrices:

This represents the Hermitian part of a matrix explicitly:

This does not evaluate because the matrix is rectangular:

This does not evaluate because a is not an explicit matrix:

## Properties & Relations(5)

For a square matrix m, Dimensions[m] gives {n,n}:

SquareMatrixQ[expr] returns False for expressions that are not matrices:

The empty list is not considered a square matrix:

A square matrix is made up of vectors of length :

Make sure it is made up of vectors:

Verify that all vectors have the same length and the number of vectors equals their length:

Hence m is a square matrix:

For lists, is equivalent to MatchQ[TensorDimensions[a],{n,n}]: