Indexing and Submatrices

First of all, every matrix may be indexed as a matrix or a as a long vector consisting of the stacked columns of the matrix (corresponding to the usual vec(.) operator in the numerical linear algebra literature), i.e., for every matrix class, a matrix A can be indexed via

For most matrix classes it is possible to extract a single row or column or several rows and columns indexed by a given Indexmatrix ind via

Likewise most classes offer possibilities to delete a subset of columns/rows to insert single columns/rows, to concat matrices of appropriate sizes below or to the right, and to extract the main diagonal of the matrix with the operator diag(). For the class Matrix it is also possible to assign matrices to appropriately indexed submatrices or to extract upper or lower triangles starting with any diagonal, for details see the documentation there.

The content of two matrices A and B of the same type can always be exchanged with very litte constant cost by the friend function swap(A,B). It simply exchanges the vector pointing to the memory.

Every matrix class also offers direct access to its internal representation. Needless to say, that users should be extremely careful in making use of these methods.