Matrix Shape - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

IsMatrixShape

determine if a Matrix has a specified shape

IsVectorShape

determine if a Vector has a specified shape

 Calling Sequence IsMatrixShape(A, shape) IsVectorShape(V, shape)

Parameters

 A - Matrix V - Vector shape - name of the shape

Description

 • The IsMatrixShape(A, shape) function determines whether Matrix A has the specified shape. A Matrix has one of the following built-in shapes if it satisfies the listed condition:
 zero
 All entries are 0.
 identity
 All entries along the main diagonal are 1, and 0 elsewhere.
 scalar
 All entries along the main diagonal have the same value, and are 0 elsewhere. This shape can also be indexed, in which case the entries along the main diagonal must have the value specified by the index.
 diagonal
 All nonzero entries appear on the main diagonal.
 constant
 All entries have the same value. This shape can also be indexed, in which case all entries have the value specified by the index.
 band[b], band[u,l]
 If a single index is given, all nonzero entries must lie on the b sub- and super-diagonals or on the main diagonal. If two indices are given, all nonzero entries must lie on the u subdiagonals, l superdiagonals or on the main diagonal.
 symmetric
 The Matrix must be square and for all i and j, ${M}_{i,j}={M}_{j,i}$.
 skewsymmetric, antisymmetric
 The Matrix must be square and for all i and j, ${M}_{i,j}=-{M}_{j,i}$.
 hermitian
 The Matrix must be square and for all i and ${M}_{i,j}=\stackrel{&conjugate0;}{{M}_{j,i}}$.
 skewhermitian, antihermitian
 The Matrix must be square and for all i and j, ${M}_{i,j}=-\stackrel{&conjugate0;}{{M}_{j,i}}$.
 triangular
 This shape may be given with the indices upper or lower. If no index is given, it defaults to triangular[upper]. A matrix is upper (lower) triangular if all the nonzero entries appear in the upper (lower) triangle. If the optional second index unit is given, all entries on the main diagonal must be 1 as well.
 Hessenberg
 This shape may be given with the indices upper or lower. If no index is given, it defaults to Hessenberg[upper]. A matrix is upper (lower) Hessenberg if all the nonzero entries appear in the upper (lower) triangle and first subdiagonal (superdiagonal).
 Additional Shapes
 Users can make additional shapes known to this routine by defining a Maple procedure. If the procedure IsMatrixShape/myshape is defined then the function call IsMatrixShape(M, myshape) will invoke IsMatrixShape/myshape(M).
 If shape is not a recognized built-in or user-defined shape, this routine returns false.
 If either or both of the row and column dimension of A is zero, IsMatrixShape returns true (regardless of shape).
 • The IsVectorShape(V, shape) function determines whether V has the specified shape. A Vector has one of the following built-in shapes if it satisfies the listed condition:
 zero
 All entries must be 0.
 unit
 V must have exactly one nonzero entry which contains 1. This shape can also be indexed, in which case the index specifies the position where the one appears.
 scalar
 V must have exactly one nonzero entry. This shape can also be indexed using two values j and x, in which case the jth entry of V must contain x.
 constant
 All entries have the same value. This shape can also be indexed, in which case all entries have the value specified by the index.
 Additional Shapes
 Users can make additional shapes known to this routine by defining a Maple procedure. If the procedure IsVectorShape/myshape is defined, then the function call IsVectorShape(V, myshape) will invoke $\mathrm{IsVectorShape/myshape}\left(V\right)$.
 If shape is not a recognized built-in or user-defined shape, this routine returns false.
 If the dimension of V is 0, IsVectorShape returns true (regardless of shape).
 • For information regarding permissible options in Matrices and Vectors, see the Matrix and Vector constructor pages.

Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$
 > $B≔\mathrm{BandMatrix}\left(\left[1,4,1\right],1,4\right)$
 ${B}{≔}\left[\begin{array}{cccc}{4}& {1}& {0}& {0}\\ {1}& {4}& {1}& {0}\\ {0}& {1}& {4}& {1}\\ {0}& {0}& {1}& {4}\end{array}\right]$ (1)
 > $\mathrm{IsMatrixShape}\left(B,\mathrm{triangular}\right)$
 ${\mathrm{false}}$ (2)
 > $\mathrm{IsMatrixShape}\left(B,\mathrm{Hessenberg}\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{IsMatrixShape}\left(B,{\mathrm{band}}_{1,1}\right)$
 ${\mathrm{true}}$ (4)
 > $V≔⟨0|1|0|0⟩$
 ${V}{≔}\left[\begin{array}{cccc}{0}& {1}& {0}& {0}\end{array}\right]$ (5)
 > $\mathrm{IsVectorShape}\left(V,\mathrm{unit}\right)$
 ${\mathrm{true}}$ (6)
 > $\mathrm{IsVectorShape}\left(V,{\mathrm{unit}}_{3}\right)$
 ${\mathrm{false}}$ (7)

A Matrix M is idempotent if M . M = M

 > IsMatrixShape/idempotent := proc(M)    evalb( type(M, 'Matrix'(square)) and Equal(M . M, M) ); end proc:
 > $\mathrm{IsMatrixShape}\left(⟨⟨0,-1⟩|⟨1,0⟩⟩,\mathrm{idempotent}\right)$
 ${\mathrm{false}}$ (8)
 > $\mathrm{IsMatrixShape}\left(⟨⟨\frac{2}{3},-\frac{1}{3},-\frac{1}{3}⟩|⟨-\frac{1}{3},\frac{2}{3},-\frac{1}{3}⟩|⟨-\frac{1}{3},-\frac{1}{3},\frac{2}{3}⟩⟩,\mathrm{idempotent}\right)$
 ${\mathrm{true}}$ (9)

 See Also