Test Matrices

TEST_MAT, a MATLAB library which defines test matrices for which some of the determinant, eigenvalues, inverse, 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 http://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 a Python version.

Related Data and Programs:

ARPACK, a MATLAB library which uses Arnoldi methods to compute some eigenvalues and eigenvectors of matrices, which may be very large.

CG, a MATLAB library which implements a simple version of the conjugate gradient (CG) method for solving a system of linear equations of the form A*x=b, suitable for situations in which the matrix A is positive definite (only real, positive eigenvalues) and symmetric.

CONDITION, a MATLAB library which implements methods of computing or estimating the condition number of a matrix.

JACOBI_EIGENVALUE, a MATLAB library which implements the Jacobi iteration for the iterative determination of the eigenvalues and eigenvectors of a real symmetric matrix.

LAPACK_EXAMPLES, a FORTRAN90 program which demonstrates the use of the LAPACK linear algebra library.

LINPACK, a MATLAB library which factors matrices, computes determinants and inverses, solves linear systems, for real and complex arithmetic, single and double precision, and for general, banded, symmetric, tridiagonal, or triangular matrices.

MATRIX_EXPONENTIAL, a MATLAB library which demonstrates some simple approaches to the problem of computing the exponential of a matrix.

TEST_EIGEN, a MATLAB library which implements test matrices for eigenvalue analysis.


TEST_MATRIX. a MATLAB library which contains Nick Higham's collection of test matrices.

TEST_MATRIX_EXPONENTIAL, a MATLAB library which defines a set of test cases for computing the matrix exponential.

WATHEN, a MATLAB library which compares storage schemes (full, banded, sparse triplet, sparse) and solution strategies (A\x, Linpack, conjugate gradient) for linear systems involving the Wathen matrix, which can arise when solving a problem using the finite element method (FEM).

Source Code:

Last revised on 29 March 2019.