Methods such as Row(), Column(), and Diagonal() return vector views of the data referenced by a general matrix. NMath does not generally provide such methods for structured sparse matrix types, because of the limitations on which elements in the matrix are modifiable.
The exception is the banded matrix types which provide a Diagonal() member function that returns a vector view of a diagonal of a matrix. If no diagonal is specified, a vector view of the main diagonal is returned. For example, this code increments every element along the main diagonal:
Code Example – C# matrix
var A = new FloatBandMatrix( 5, 5, 0, 0 );
Code Example – VB matrix
Dim A As New FloatBandMatrix( 5, 5, 0, 0 )