test_mat, an Octave code which defines test matrices for which some of the determinant, eigenvalues, inverse, LLT factorization, LDLT factorization, null vectors, P*L*U factorization or linear system solution are already known, including the Vandermonde and Wathen matrix.

A wide range of matrix dimensions, forms and properties are available. These matrices may be useful in testing an algorithm for correctness on a variety of problems.

Many of the matrices can be rectangular, with the user specifying the number of rows and columns. Almost all the matrices can be made of arbitrary size, with the user specifying the dimension.

Many different matrix zero structures are available, including diagonal, bidiagonal, tridiagonal, pentadiagonal, banded, upper and lower triangular, and Hessenberg.

Many different matrix symmetry patterns are available, including symmetric, antisymmetric, persymmetric, circulant, Toeplitz, and Hankel.

Matrices are available with known inverses, condition numbers, determinants, rank, eigenvalues, and characteristic polynomials. Other matrix properties include positive definiteness, positivity, zero/one, and adjacency matrices.

Many of the matrices come from a MATLAB M file collection developed by Nicholas Higham, Department of Mathematics, University of Manchester.

An earlier version of the collection is available, again as MATLAB M files, in ACM TOMS Algorithm 694, in the TOMS directory of the NETLIB web site.

Many of these matrices, and many other matrices, are available at https://math.nist.gov, the Matrix Market web site.


The computer code described and made available on this web page are distributed under the GNU LGPL license.


test_mat is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and an Octave version and a Python version.

Related Data and Programs:


Source Code:

Last revised on 13 May 2021.