What is a .mtx file?
text/x-matrixmarket
Matrix Market (.mtx) is a plain-text exchange format for sparse and dense matrices from NIST. A banner line declares the object, format, field, and symmetry — for example `%%MatrixMarket matrix coordinate real general` — comment lines follow, and then a size line gives rows, columns, and the number of stored entries. Coordinate entries list a 1-based row, a 1-based column, and a value, with symmetric matrices storing only the lower triangle.
How to use a .mtx file
Use an example .mtx file to test sparse-matrix loaders and numerical pipelines, verifying 1-based to 0-based index conversion, correct expansion of symmetric and pattern matrices, and that the declared entry count matches the data.
Download example .mtx files
- Matrix Market — Sparse Coordinate, Real, General (.mtx)An 8x8 sparse matrix in Matrix Market coordinate form with twelve stored entries and 1-based indices, the convention that catches every reader written against 0-based arrays. Comment lines beginning with a percent sign appear before the size line, where the format requires them.
- Matrix Market — Dense Array, Column-Major Order (.mtx)A 4x3 dense matrix where values run down each column rather than across each row, which is the Matrix Market array convention and the opposite of what most readers assume. Getting it wrong rearranges every element rather than raising an error.
- Matrix Market — Symmetric Pattern, Lower Triangle Only (.mtx)A symmetric pattern matrix carrying only positions and only the lower triangle, so nine stored lines describe sixteen non-zeros. Both halves of that — no value column and an implied mirror — are places a reader can silently disagree with the file.
- Matrix Market — Complex Hermitian With Conjugate Mirroring (.mtx)A Hermitian complex matrix where each line carries a real and an imaginary part and the implied mirror entry is the complex conjugate rather than a copy. Every diagonal entry has a zero imaginary part, which the Hermitian property requires and a validator should check.
- Matrix Market — Integer Field, Not Floats (.mtx)A matrix whose banner declares an integer field, so the values are integers and must not be widened to floats on the way in. The stored range deliberately reaches the signed 16-bit limits, so a narrow integer type overflows visibly.
- Matrix Market — Zero Stored Entries, Still Valid (.mtx)A valid Matrix Market file describing a 6x6 matrix with no stored entries, which is an all-zero matrix rather than an error. It separates readers that model an empty result from readers that treat a missing entry block as truncation.
- Intentionally Corrupt Matrix Market — Declared Count Exceeds the Entries (.mtx)An intentionally corrupt Matrix Market file whose banner and size line are perfectly valid and whose entry block stops seven lines short of the declared count. A reader that preallocates from the declared count and never checks ends up with seven silent zeros.