Описание тега matrix-indexing
Indexing into a matrix is a means of selecting a subset of elements from the matrix/array
Matrix indexing is a way to reference a particular element in a matrix, by specifying its row and column number.
The notion extends to multi-dimensional arrays as well.
This is a fundamental concept in many languages such as MATLAB, Octave, Python+ NumPy, R, Julia, etc...
There are several matrix-indexing methods:
- row/column indexing:
M(m,n)
accesses the element on them
-th row on then
-th column. - linear indexing: this methods treats the matrix as a 1D list of elements and access the
n
-element. Note that there may be several ways of "flattening" the matrix row-first or column-first. - logical indexing: by specifying a mask
The use of indexing can often improve performance in the context of code vectorization, as it can replace for-loops, if conditions, etc.