MTX (.mtx)

Matrix Market matrix format.
Used for exchanging and storing test matrices.
Plain text format.
File format of the NIST Matrix Market collection of standard test matrices.
Stores numerical or pattern matrices in a dense ("array format") or sparse ("coordinate format") representation.
Developed in 1996 by R. Boisvert, R. Pozo, K. Remington, and J. Dongarra.
Maintained by the U.S. National Institute of Standards and Technology (NIST).
  • Import and Export fully support the Matrix Market file format.

Import and ExportImport and Export

  • Import["file.mtx"] imports matrix data from a Matrix Market file.
  • Export["file.mtx", expr] exports any numerical or pattern matrix to a Matrix Market file.
  • Import["file.mtx"] reads an MTX matrix file and returns an array.
  • Mathematica converts "array format" files to packed arrays and "coordinate format" files to sparse arrays.
  • Import["file.mtx", elem] imports the specified element from a Matrix Market file.
  • Import["file.mtx", {elem, suba, subb, ...}] imports a subelement.
  • Import["file.mtx", {{elem1, elem2, ...}}] imports multiple elements.
  • The import format can be specified with Import["file", "MTX"] or Import["file", {"MTX", elem, ...}].
  • Export["file.mtx", expr, elem] creates a Matrix Market file by treating expr as specifying element elem.
  • Export["file.mtx", {expr1, expr2, ...}, {{elem1, elem2, ...}}] treats each as specifying the corresponding .
  • Export["file.mtx", expr, opt1->val1, ...] exports expr with the specified option elements taken to have the specified values.
  • Export["file.mtx", {elem1->expr1, elem2->expr2, ...}, "Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the Matrix Market file format.

ElementsElements

  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation elements:
  • "Data"matrix data given as a packed or sparse array
    "Graphics"a visual representation of the values of the matrix elements
  • Import uses the element by default.
  • Import["file.mtx", "Graphics"] uses MatrixPlot to render the matrix structure as graphics.
  • Meta-information elements:
  • "Comments"user comments stored in the file
    "MatrixStructure"symmetry properties of the matrix
  • Possible values for are:
  • "Hermitian"matrix that is equal to its own conjugate transpose
    "General"matrix without transposition symmetry
    "SkewSymmetric"matrix whose transpose is also its negative
    "Symmetric"matrix that is equal to its transpose

ExamplesExamplesopen allclose all

Basic Examples (2)Basic Examples (2)

This imports a sparse matrix from an MTX sample file, giving a visual representation of it:

In[1]:=
Click for copyable input
Out[1]=

Import this file as a sparse array object:

In[2]:=
Click for copyable input
Out[2]=

This exports a 2×2 matrix to MTX:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
New in 6
New to Mathematica? Find your learning path »
Have a question? Ask support »