Monotonic Matrix

Author

Eric W. Weisstein
July 25, 2003

This notebook downloaded from http://mathworld.wolfram.com/notebooks/LinearAlgebra/MonotonicMatrix.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/MonotonicMatrix.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Initialization

<<Matrices`

Code

MonotonicQ[m_List?MatrixQ]:=Module[{u=DeleteCases[Union[Flatten[m]],0]},
And[
Less@@@And@@DeleteCases[m,0,{2}],
Greater@@@And@@DeleteCases[Transpose[m],0,{2}],And@@Greater@@@(Last/@Position[m,#]&/@u)
]
]

MonotonicQ[{{0}}]:=True
MonotonicQ[{{1}}]:=True

Enumeration

MatrixForm/@Select[Matrices[2,Range[0,2]],MonotonicQ]

Count[Matrices[1,Range[0,1]],_?MonotonicQ]

Count[Matrices[2,Range[0,2]],_?MonotonicQ]

Count[Matrices[3,Range[0,3]],_?MonotonicQ]

Maximal Numbers of Occupied Cells

Max@@Length/@DeleteCases[Flatten/@Select[Matrices[2,Range[0,2]],MonotonicQ],0,{2}]

Max@@Length/@DeleteCases[Flatten/@Select[Matrices[3,Range[0,3]],MonotonicQ],0,{2}]

Examples

MatrixForm[m1={{2,0,3},{0,0,1},{1,3,0}}]

MatrixForm[m2={{0,0,4,0,5},{4,0,0,5,0},{0,0,1,2,3},{3,5,0,0,0},{1,2,0,0,0}}]

MonotonicQ/@{m1,m2}