Mathematica provides several convenient methods for extracting and manipulating parts of matrices. The flexible
[[ ]] (
Part) and
;; (
Span) syntaxes provide compact yet readable representations of operations on submatrices and matrix elements.
Mathematica's symbolic character also allows convenient pattern and rule-based element specifications.
Dimensions — dimensions of a matrix
MatrixQ — test whether an expression is a matrix
Part — elements and submatrices:
m[[i, j]]; resettable with
m[[i, j]]=x
Take — take rows, columns and submatrices
Drop — drop rows, columns and submatrices
Diagonal — get the list of elements on the diagonal
RotateLeft,
RotateRight — cyclically rotate rows or columns
Reverse — reverse rows or columns
Transpose — interchange rows and columns
Join — join rows or columns of several matrices
Position — find positions where elements that match a pattern occur
Extract — extract elements that appear at a list of positions
ReplacePart — make replacements for collections of elements
ArrayRules — get a list of positions and values for nonzero elements
Map — apply a function at any level