MTX (.mtx)

Background & Context

    • 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 US National Institute of Standards and Technology (NIST).

Import & 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.
  • The Wolfram Language 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 expri as specifying the corresponding elemi.
  • 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 following reference pages for full general information:
  • Import, Exportimport from or export to a file
    CloudImport, CloudExportimport from or export to a cloud object
    ImportString, ExportStringimport from or export to a string
    ImportByteArray, ExportByteArrayimport from or export to a byte array

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Summary"summary of the file
    "Rules"list of rules for all available elements
  • 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 "Data" 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 "MatrixStructure" 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

Examples

Basic Examples  (2)

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

Import this file as a sparse array object:

This exports a 2×2 matrix to MTX: