Math.NET Numerics v0.3

MathNet.Numerics.LinearAlgebra.Sparse Namespace

Matrices and vectors, with basic linear algebra operations

This namespace is originary based on a port of JMP.

This port is still in very rough, the MathNet team encorage users to provide feedback.

The basic datastructures in MathNet are matrices and vectors, stored in double-precision (double). All the indices are 0-based, as is typical of C and C#, but different from Fortran's 1-based indexing. Complex numbers are not supported.

Basic interface

The most fundamental interfaces are IMatrix and IVector. By themselves, they say little about the underlying datastructure, as they only have size-information functions.

Extending Matrix is IElementalAccessMatrix, which has simple assembly and retrieval functions, both elementwise and blockwise. The block-operations are typically more efficient. There is a similiar interface, IElementalAccessVector which extends the basic vector.

Using these methods, most operations can be accomplished easily. There are two more interfaces which are of interest, namely IZeroColumnMatrix and IZeroRowMatrix. Matrices implementing these allow quick zeroing of columns or rows such that boundary conditions for differential equations can be explicitly handled. For convenience, the interfaces IElementalAccessZeroRowMatrixIElementalAccessZeroColumnMatrix extends on both the elemental access interface and one of the zeroing interfaces, and can be used in application codes to easier switch between different underlying storage formats (dense, sparse etc).

The aforementioned functions are sufficient for most applications, but MathNet provides other ways of accessing and changing the datastructures. This is typically by direct access, and is generally not recommended except for developing linear algebra algorithms.

Matrices and vectors

MathNet provides ten matrices and three vectors implementations. Of these, there are five sparse matrices, four dense, and a block-structured matrix. Amongst the sparse and dense matrices, there are both row- and column-oriented ones. Choosing the right structure can have a significant impact on both performance and memory-usage. Most of the matrices implement IElementalAccessMatrix and most of the vectors implement IElementalAccessVector. Row-oriented

NameStorage
Dense matrix (data adapter for Matrix missing)double[,], row/column major
SparseColumnMatrixint[,]/double[,], column major, growable
SparseColumnRowMatrixint[]/double[], column major
SparseRowMatrixint[,]/double[,], row major, growable
SparseRowColumnMatrixint[]/double[], row major
BlockMatrixint[,]/int[,]/Matrix[]
BlockVectorint[]/Vector[]
CoordinateMatrixint[]/int[]/double[]
DenseVectordouble[]
SparseVectorint[]/double[], growable

Notes:

  1. Sparse structures which are growable can exceed the initial bandwidth allocation, while those which are not growable are fixed, and over-allocation will cause an error
  2. Matrices which are column major typically perform better with column-oriented operations, and likewise for row major matrices. Matrix/vector multiplication is row-major, while transpose multiplication is column-major.
  3. Matrices using one-dimensional storage typically exhibit higher performance than the matrices with two-dimensional storage

Based on the original work of: Bjørn-Ove Heimsund (2003).

Port: Joannes Vermorel (2004).

Classes

ClassDescription
AbstractBLAS Partial implementation of BLAS
AbstractIteration Partial implementation of Iteration
AbstractMatrix Partial implementation of Matrix
AbstractVector Partial implementation of Vector.
Blas Contains access to the default BLAS.
BlockMatrix Block matrix
BlockVector Block vector
CoordinateMatrix Coordinate storage matrix. The data is not kept sorted.
DenseVector Dense vector.
IntDoubleVectorPair An index/data pairing with integer indices and double-precision data. Note that the length of the indices and the data need not be equal. Furthermore, the indices must be kept sorted in most cases.
IntIntDoubleVectorTriple Dual indices and data paired together. Used by some of the faster matrices. major contains the index for each data-entry, while minor is either uses as row- or column-delimiters. Within two minor-indices, the major-indices must be sorted for most applications.
NotConvergedException Signals the lack of convergence of an iterative solver. It could be due to too stringent convergence criteria, too few iterations used, or simply due to a malformed problem. The number of iterations are stored, along with the reason (BREAKDOWN, DIVERGENCE, or something else).
SequentialBLAS Sequential BLAS implementation
SparseColumnMatrix Sparse matrix stored as 2D ragged columns. For best performance during assembly, ensure that enough memory is allocated at construction time, as re-allocation may be time-consuming.
SparseColumnRowMatrix Sparse matrix stored as a vector, column major
SparseRowColumnMatrix Sparse matrix stored as one long vector, row major.
SparseRowMatrix Sparse matrix stored as 2D ragged rows. For best performance during assembly, ensure that enough memory is allocated at construction time, as re-allocation may be time-consuming.
SparseVector Sparse vector.

Interfaces

InterfaceDescription
IBLAS Basic linear algebra subroutines. The methods present here are suitable for sparse matrices and iterative solvers, as such not all the Fortran BLAS methods have been implemented. Of particular note is the absence of matrix/matrix multiplication and triangular solvers.
IBlockAccessMatrix Matrix consisting of sub-matrices
IBlockAccessVector Vector consisting of sub-vectors
ICoordinateAccessMatrix Matrix with access by row/column vectors
IDenseDense matrix or vector.
IDenseAccessVector Vector with fast array access.
IDenseColumnAccessMatrix Matrix with fast dense column access.
IDenseColumnRowAccessMatrixDense matrix with fast access to the whole structure, with column-major indices.
IDenseRowAccessMatrix Matrix with fast dense row access.
IDenseRowColumnAccessMatrix Dense matrix with fast access to the whole structure, with row-major indices.
IElementalAccessMatrix Matrix with elemental access operations. The block-wise operations will typically be faster than the elementwise operations, and the extractions methods present here are not likely to be as fast as the custom accessors the matrix may implement.
IElementalAccessVector Vector with elemental access operations. The block-wise operations will typically be faster than the elementwise operations, and the extractions methods present here are not likely to be as fast as the custom accessors the vector may implement.
IElementalAccessZeroColumnMatrix Matrix with elemental access and supporting zeroing of columns.
IElementalAccessZeroRowMatrix Matrix with elemental access and supporting zeroing of rows.
IMatrix Basic matrix interface.
IMatrixAccess Data-access without index-access
IShellMatrix Matrix with external storage and custom matrix/vector product.
ISparseSparse matrix or vector.
ISparseAccessVector Vector with a sparse view.
ISparseColumnAccessMatrix Sparse matrix with fast column access.
ISparseColumnRowAccessMatrix Sparse matrix with fast access to the whole structure, with column-major indices.
ISparseRowAccessMatrix Sparse matrix with fast row-based access.
ISparseRowColumnAccessMatrix Sparse matrix with fast access to the whole structure, with row-major indices.
Iteration Tracks convergence of an iterative linear solver.
IVector Basic vector interface
IVectorAccess Data-access without index-access. Note that matrices storing data as vectors may implement this interface, despite its name.
IZeroColumnMatrix Matrix supporting zeroing of columns
IZeroRowMatrix Matrix supporting zeroing of rows

Enumerations

EnumerationDescription
NORMS