You are here: Matrix Market File Format
MtxVec VCL
ContentsIndex
PreviousUpNext
Matrix Market File Format

The Matrix Market (MM) exchange formats provide a simple mechanism to facilitate the exchange of matrix data. In p articular, the objective has been to define a minimal base ASCII file format which can be very easily explained and parsed, but can easily adapted to applications with a more rigid structure, or extended to related data objects. The MM exchange format for matrices is really a collection of affiliated formats which share design elements. In our initial specification, two matrix formats are defined:

  • Coordinate Format : A file format suitable for representing general sparse matrices. Only nonzero entries are provided, and the coordinates of each nonzero entry is given explicitly. This is illustrated in the example below.
  • Array Format : A file format suitable for representing general dense matrices. All entries are provided in a pre-defined (column-oriented) order.

 

Several instances of each of these basic formats are defined. These are obtained by specifying an arithmetic field for the matrix entries (i.e., real, complex, integer, pattern) and a symmetry structure which may reduce the size of the data file (i.e. general, symmetric, skew-symmetric, Hermitian). 

MM coordinate format is suitable for representing sparse matrices. Only nonzero entries need be encoded, and the coordinates of each are given explicitly. This is illustrated in the following example of a real 5x5 general sparse matrix: 

 

1 0 0 6 0 0 10.5 0 0 0 0 0 .015 0 0 0 250.5 0 -280 33.32 0 0 0 0 12

 

In MM coordinate format this could be represented as follows: 

 

%%MatrixMarket matrix coordinate real general %================================================================================= % % This ASCII file represents a sparse MxN matrix with L % nonzeros in the following Matrix Market format: % % +----------------------------------------------+ % |%%MatrixMarket matrix coordinate real general | <--- header line % |% | <--+ % |% comments | |-- 0 or more comment lines % |% | <--+ % | M N L | <--- rows, columns, entries % | I1 J1 A(I1, J1) | <--+ % | I2 J2 A(I2, J2) | | % | I3 J3 A(I3, J3) | |-- L lines % | . . . | | % | IL JL A(IL, JL) | <--+ % +----------------------------------------------+ % % Indices are 1-based, i.e. A(1,1) is the first element. % %================================================================================= 5 5 8 1 1 1.000e+00 2 2 1.050e+01 3 3 1.500e-02 1 4 6.000e+00 4 2 2.505e+02 4 4 -2.800e+02 4 5 3.332e+01 5 5 1.200e+01

 

The first line contains the type code. In this example, it indicates that the object being represented is a matrix in coordinate format and that the numeric data following is real and represented in general form. (By general we mean that the matrix format is not taking advantage of any symmetry properties.) 

Variants of the coordinate format are defined for matrices with complex and integer entries, as well as for those in which only the position of the nonzero entries is prescribed (pattern matrices). (These would be indicated by changing real to complex, integer, or pattern, respectively, on the header line). Additional variants are defined for cases in which symmetries can be used to significantly reduce the size of the data: symmetric, skew-symmetric and Hermitian. In these cases only entries in the lower triangular portion need be supplied. In the skew-symmetric case the diagonal entries are zero, and hence they too are omitted. (These would be indicated by changing general to symmetric, skew-symmetric, or hermitian, respectively, on the header line). 

You can learn more about the ASCII file formats for matrices redistributed by the Matrix Market by visiting the following link: http://math.nist.gov/MatrixMarket/formats.html#MMformat

Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!