Predicates related to matrices

(directly go to documentation on : IsScalar, IsVector, IsMatrix, IsSquareMatrix, IsHermitian, IsOrthogonal, IsDiagonal, IsLowerTriangular, IsUpperTriangular, IsSymmetric, IsSkewSymmetric, IsUnitary, IsIdempotent. )

# 17. Predicates related to matrices

IsScalar | test for a scalar
IsVector | test for a vector
IsMatrix | test for a matrix
IsSquareMatrix | test for a square matrix
IsHermitian | test for a Hermitian matrix
IsOrthogonal | test for an orthogonal matrix
IsDiagonal | test for a diagonal matrix
IsLowerTriangular | test for a lower triangular matrix
IsUpperTriangular | test for an upper triangular matrix
IsSymmetric | test for a symmetric matrix
IsSkewSymmetric | test for a skew-symmetric matrix
IsUnitary | test for a unitary matrix
IsIdempotent | test for an idempotent matrix

###

IsScalar -- test for a scalar

##### Standard library

##### Calling format:

    IsScalar(expr)

##### Parameters:

`expr` -- a mathematical object

##### Description:

`IsScalar` returns `True` if `expr` is a scalar, `False` otherwise. Something is considered to be a scalar if it's not a list.

##### Examples:

    In> IsScalar(7)
    Out> True;
    In> IsScalar(Sin(x)+x)
    Out> True;
    In> IsScalar({x,y})
    Out> False;

##### See also:

IsList , IsVector , IsMatrix .

###

IsVector -- test for a vector

##### Standard library

##### Calling format:

    IsVector(expr)

    IsVector(pred,expr)

##### Parameters:

`expr` -- expression to test

`pred` -- predicate test (e.g. IsNumber, IsInteger, ...)

##### Description:

`IsVector(expr)` returns `True` if `expr` is a vector, `False` otherwise. Something is considered to be a vector if it's a list of scalars. `IsVector(pred,expr)` returns `True` if `expr` is a vector and if the predicate test `pred` returns `True` when applied to every element of the vector `expr`, `False` otherwise.

##### Examples:

    In> IsVector({a,b,c})
    Out> True;
    In> IsVector({a,{b},c})
    Out> False;
    In> IsVector(IsInteger,{1,2,3})
    Out> True;
    In> IsVector(IsInteger,{1,2.5,3})
    Out> False;

##### See also:

IsList , IsScalar , IsMatrix .

###

IsMatrix -- test for a matrix

##### Standard library

##### Calling format:

    IsMatrix(expr)

    IsMatrix(pred,expr)

##### Parameters:

`expr` -- expression to test

`pred` -- predicate test (e.g. IsNumber, IsInteger, ...)

##### Description:

`IsMatrix(expr)` returns `True` if `expr` is a matrix, `False` otherwise. Something is considered to be a matrix if it's a list of vectors of equal length. `IsMatrix(pred,expr)` returns `True` if `expr` is a matrix and if the predicate test `pred` returns `True` when applied to every element of the matrix `expr`, `False` otherwise.

##### Examples:

    In> IsMatrix(1)
    Out> False;
    In> IsMatrix({1,2})
    Out> False;
    In> IsMatrix({{1,2},{3,4}})
    Out> True;
    In> IsMatrix(IsRational,{{1,2},{3,4}})
    Out> False;
    In> IsMatrix(IsRational,{{1/2,2/3},{3/4,4/5}})
    Out> True;

##### See also:

IsList , IsVector .

###

IsSquareMatrix -- test for a square matrix

##### Standard library

##### Calling format:

    IsSquareMatrix(expr)

    IsSquareMatrix(pred,expr)

##### Parameters:

`expr` -- expression to test

`pred` -- predicate test (e.g. IsNumber, IsInteger, ...)

##### Description:

`IsSquareMatrix(expr)` returns `True` if `expr` is a square matrix, `False` otherwise. Something is considered to be a square matrix if it's a matrix having the same number of rows and columns. `IsMatrix(pred,expr)` returns `True` if `expr` is a square matrix and if the predicate test `pred` returns `True` when applied to every element of the matrix `expr`, `False` otherwise.

##### Examples:

    In> IsSquareMatrix({{1,2},{3,4}});
    Out> True;
    In> IsSquareMatrix({{1,2,3},{4,5,6}});
    Out> False;
    In> IsSquareMatrix(IsBoolean,{{1,2},{3,4}});
    Out> False;
    In> IsSquareMatrix(IsBoolean,{{True,False},{False,True}});
    Out> True;

##### See also:

IsMatrix .

###

IsHermitian -- test for a Hermitian matrix

##### Standard library

##### Calling format:

    IsHermitian(A)

##### Parameters:

`A` -- a square matrix

##### Description:

IsHermitian(A) returns `True` if `A` is Hermitian and `False` otherwise. A is a Hermitian matrix iff Conjugate( Transpose A )= A. If A is a real matrix, it must be symmetric to be Hermitian.

##### Examples:

    In> IsHermitian({{0,I},{-I,0}})
    Out> True;
    In> IsHermitian({{0,I},{2,0}})
    Out> False;

##### See also:

IsUnitary .

###

IsOrthogonal -- test for an orthogonal matrix

##### Standard library

##### Calling format:

    IsOrthogonal(A)

##### Parameters:

`A` -- square matrix

##### Description:

`IsOrthogonal(A)` returns `True` if `A` is orthogonal and `False` otherwise. A is orthogonal iff A*Transpose( A) = Identity, or equivalently Inverse( A) = Transpose( A).

##### Examples:

    In> A := {{1,2,2},{2,1,-2},{-2,2,-1}};
    Out> {{1,2,2},{2,1,-2},{-2,2,-1}};
    In> PrettyForm(A/3)

    /                      \
    | / 1 \  / 2 \ / 2 \   |
    | | - |  | - | | - |   |
    | \ 3 /  \ 3 / \ 3 /   |
    |                      |
    | / 2 \  / 1 \ / -2 \  |
    | | - |  | - | | -- |  |
    | \ 3 /  \ 3 / \ 3  /  |
    |                      |
    | / -2 \ / 2 \ / -1 \  |
    | | -- | | - | | -- |  |
    | \ 3  / \ 3 / \ 3  /  |
    \                      /
    Out> True;
    In> IsOrthogonal(A/3)
    Out> True;

###

IsDiagonal -- test for a diagonal matrix

##### Standard library

##### Calling format:

    IsDiagonal(A)

##### Parameters:

`A` -- a matrix

##### Description:

`IsDiagonal(A)` returns `True` if `A` is a diagonal square matrix and `False` otherwise.

##### Examples:

    In> IsDiagonal(Identity(5))
    Out> True;
    In> IsDiagonal(HilbertMatrix(5))
    Out> False;

###

IsLowerTriangular -- test for a lower triangular matrix

###

IsUpperTriangular -- test for an upper triangular matrix

##### Standard library

##### Calling format:

    IsLowerTriangular(A)
    IsUpperTriangular(A)

##### Parameters:

`A` -- a matrix

##### Description:

A lower/upper triangular matrix is a square matrix which has all zero entries above/below the diagonal.

`IsLowerTriangular(A)` returns `True` if `A` is a lower triangular matrix and `False` otherwise. `IsUpperTriangular(A)` returns `True` if `A` is an upper triangular matrix and `False` otherwise.

##### Examples:

    In> IsUpperTriangular(Identity(5))
    Out> True;
    In> IsLowerTriangular(Identity(5))
    Out> True;
    In> IsLowerTriangular({{1,2},{0,1}})
    Out> False;
    In> IsUpperTriangular({{1,2},{0,1}})
    Out> True;

A non-square matrix cannot be triangular:

    In> IsUpperTriangular({{1,2,3},{0,1,2}})
    Out> False;

##### See also:

IsDiagonal .

###

IsSymmetric -- test for a symmetric matrix

##### Standard library

##### Calling format:

    IsSymmetric(A)

##### Parameters:

`A` -- a matrix

##### Description:

`IsSymmetric(A)` returns `True` if `A` is symmetric and `False` otherwise. A is symmetric iff Transpose ( A) = A.

##### Examples:

    In> A := {{1,0,0,0,1},{0,2,0,0,0},{0,0,3,0,0},
      {0,0,0,4,0},{1,0,0,0,5}};
    In> PrettyForm(A)

    /                                \
    | ( 1 ) ( 0 ) ( 0 ) ( 0 ) ( 1 )  |
    |                                |
    | ( 0 ) ( 2 ) ( 0 ) ( 0 ) ( 0 )  |
    |                                |
    | ( 0 ) ( 0 ) ( 3 ) ( 0 ) ( 0 )  |
    |                                |
    | ( 0 ) ( 0 ) ( 0 ) ( 4 ) ( 0 )  |
    |                                |
    | ( 1 ) ( 0 ) ( 0 ) ( 0 ) ( 5 )  |
    \                                /
    Out> True;
    In> IsSymmetric(A)
    Out> True;

##### See also:

IsHermitian , IsSkewSymmetric .

###

IsSkewSymmetric -- test for a skew-symmetric matrix

##### Standard library

##### Calling format:

    IsSkewSymmetric(A)

##### Parameters:

`A` -- a square matrix

##### Description:

`IsSkewSymmetric(A)` returns `True` if `A` is skew symmetric and `False` otherwise. A is skew symmetric iff Transpose(A) =-A.

##### Examples:

    In> A := {{0,-1},{1,0}}
    Out> {{0,-1},{1,0}};
    In> PrettyForm(%)

    /               \
    | ( 0 ) ( -1 )  |
    |               |
    | ( 1 ) ( 0 )   |
    \               /
    Out> True;
    In> IsSkewSymmetric(A);
    Out> True;

##### See also:

IsSymmetric , IsHermitian .

###

IsUnitary -- test for a unitary matrix

##### Standard library

##### Calling format:

    IsUnitary(A)

##### Parameters:

`A` -- a square matrix

##### Description:

This function tries to find out if A is unitary.

A matrix A is orthogonal iff A^(-1) = Transpose( Conjugate(A) ). This is equivalent to the fact that the columns of A build an orthonormal system (with respect to the scalar product defined by `InProduct`).

##### Examples:

    In> IsUnitary({{0,I},{-I,0}})
    Out> True;
    In> IsUnitary({{0,I},{2,0}})
    Out> False;

##### See also:

IsHermitian , IsSymmetric .

###

IsIdempotent -- test for an idempotent matrix

##### Standard library

##### Calling format:

    IsIdempotent(A)

##### Parameters:

`A` -- a square matrix

##### Description:

`IsIdempotent(A)` returns `True` if `A` is idempotent and `False` otherwise. A is idempotent iff A^2=A. Note that this also implies that A raised to any power is also equal to A.

##### Examples:

    In> IsIdempotent(ZeroMatrix(10,10));
    Out> True;
    In> IsIdempotent(Identity(20))
    Out> True;