MatrixMarket is both a vast repository of test data and a text-based exchange file format provided by NIST. Being text-based makes it convenient to deal with and program against, and also works well with versioning tools like Git. But other than CSV it can also store sparse matrices in a compact way.
Math.NET Numerics provides basic support for MatrixMarket files with the MathNet.Numerics.Data.Text package, which is available on NuGet as separate package and not included in the basic distribution.
The MatrixMarketReader
class provides static functions to read a matrix or a vector from a file or string.
It can read from:
All these functions expect the data type of the matrix to be generated as generic type argument. Only Double, Single, Complex and Complex32 are supported.
Example:
|
The dual to the reader above is the MatrixMarketWriter
class that can serialize a matrix or vector
to a MatrixMarket text file, stream or TextWriter.
Example:
|
The data extension packages also offer other ways to serialize a matrix to a binary stream or file. Among others: