Test Matrices

TEST_MAT is 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 and data files 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 FORTRAN77 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.

LINPLUS, a MATLAB library of routines for factoring matrices, computing determinants and inverses, solving linear systems, for real arithmetic for a variety of matrix storage formats.

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).


  1. Milton Abramowitz, Irene Stegun,
    Handbook of Mathematical Functions,
    National Bureau of Standards, 1964,
    ISBN: 0-486-61272-4,
    LC: QA47.A34.
  2. MJ Aegerter,
    Construction of a Set of Test Matrices,
    Communications of the ACM,
    Volume 2, Number 8, August 1959, pages 10-12.
  3. Marlow Anderson, Todd Feil,
    Turning Lights Out With Linear Algebra,
    Mathematics Magazine,
    Volume 71, Number 4, October 1998, pages 300-303.
  4. Wayne Barrett, Tyler Jarvis,
    Spectral Properties of a Matrix of Redheffer,
    Linear Algebra and Its Applications,
    Volume 162-164, February 1992, pages 673-683.
  5. Richard Beam, Robert Warming,
    The asymptotic spectra of banded Toeplitz and quasi-Toeplitz matrices,
    SIAM Journal on Scientific and Statistical Computing,
    Volume 14, Number 4, July 1993, pages 971-1006
  6. Dario Bini, Paola Favati,
    On a matrix algebra related to the discrete Hartley transform,
    SIAM Journal on Matrix Analysis and Applications,
    Volume 14, Number 2, April 1993, pages 500-507.
  7. John Boothroyd,
    Algorithm 274: Generation of Hilbert Derived Test Matrix,
    Communications of the ACM,
    Volume 9, Number 1, January 1966, page 11.
  8. Robert Brawer, Magnus Pirovino,
    The linear algebra of the Pascal matrix,
    Linear Algebra and Its Applications,
    Volume 174, September 1992, pages 13-23.
  9. Jacqueline Burm, Paul Fishback,
    Period-3 Orbits Via Sylvester's Theorem and Resultants,
    Mathematics Magazine,
    Volume 74, Number 1, February 2001, pages 47-51.
  10. Gregory Call, Daniel Velleman,
    Pascal's Matrices,
    American Mathematical Monthly,
    Volume 100, Number 4, April 1993, pages 372-376.
  11. Francoise Chaitin-Chatelin,
    Eigenvalues of Matrices,
    John Wiley, 1993,
    ISBN: 0471935387,
    LC: QA188.C44.
  12. Ke Chen, Peter Giblin, Alan Irving,
    Mathematical Explorations with MATLAB,
    Cambridge University Press, 1999,
    ISBN: 0-521-63920-4.
  13. Man-Duen Choi,
    Tricks or treats with the Hilbert matrix,
    American Mathematical Monthly,
    Volume 90, Number 5, May 1983, pages 301-312.
  14. TS Chow,
    A class of Hessenberg matrices with known eigenvalues and inverses,
    SIAM Review,
    Volume 11, Number 3, July 1969, pages 391-395.
  15. Paul Clement,
    A class of triple-diagonal matrices for test purposes,
    SIAM Review,
    Volume 1, Number 1, January 1959, pages 50-52.
  16. Alan Cline, Russell Rew,
    A set of counterexamples to three condition number estimators,
    SIAM Journal on Scientific and Statistical Computing,
    Volume 4, Number 4, December 1983, pages 602-611.
  17. David Collison,
    Algorithm 117: and Algorithm 118: Magic square (even order) and Magic square (odd order),
    Communications of the ACM,
    Volume 5, Number 8, August 1962, pages 435-436.
  18. George Cybenko, Charles vanLoan,
    Computing the minimum eigenvalue of a symmetric positive definite Toeplitz matrix,
    SIAM Journal on Scientific and Statistical Computing,
    Volume 7, Number 1, January 1986, pages 123-131.
  19. George Dantzig,
    Linear Programming and Extensions,
    Princeton University Press, 1998,
    ISBN: 0691059136,<
    LC: QA265.D3.
  20. Philip Davis,
    Circulant Matrices,
    Second Edition,
    Chelsea, 1994,
    ISBN: 0828403384,
    LC: QA188.D37.
  21. Fred Dorr,
    An example of ill-conditioning in the numerical solution of singular perturbation problems,
    Mathematics of Computation,
    Volume 25, Number 114, April 1971, pages 271-283.
  22. Patricia Eberlein,
    A Two-Parameter Test Matrix,
    Mathematics of Computation,
    Volume 18, Number 86, April 1964, pages 296-298.
  23. Alan Edelman, Eric Kostlan,
    The road from Kac's matrix to Kac's random polynomials.
    in Proceedings of the Fifth SIAM Conference on Applied Linear Algebra,
    edited by John Lewis,
    SIAM, 1994,
    ISBN: 0898713366,
    LC: QA184.S58.
  24. Graeme Fairweather,
    On the eigenvalues and eigenvectors of a class of Hessenberg matrices,
    SIAM Review,
    Volume 13, Number 2, April 1971, pages 220-221.
  25. WL Frank,
    Computing eigenvalues of complex matrices by determinant evaluation, and by methods of Danilewski and Wielandt,
    Journal of the Society for Industrial and Applied Mathematics,
    Volume 6, 1958, pages 378-392.
  26. Charles Gear,
    A simple set of test matrices for eigenvalue programs,
    Mathematics of Computation,
    Volume 23, Number 105, January 1969, pages 119-125.
  27. Gene Golub, Charles VanLoan,
    Matrix Computations, Third Edition,
    Johns Hopkins, 1996,
    ISBN: 0-8018-4513-X,
    LC: QA188.G65.
  28. Gene Golub, James Wilkinson,
    Ill-conditioned eigensystems and the computation of the Jordan canonical form,
    SIAM Review,
    Volume 18, Number 4, October 1976, pages 578-619.
  29. MJC Gover,
    The explicit inverse of factorial Hankel matrices,
    Department of Mathematics, University of Bradford, 1993.
  30. Ronald Graham, Neil Sloane,
    Anti-Hadamard Matrices,
    Linear Algebra and Applications,
    Volume 62, November 1984, pages 113-137.
  31. Joseph Grcar,
    Operator coefficient methods for linear equations,
    Technical Report SAND89-8691,
    Sandia National Laboratories,
    Albuquerque, New Mexico, 1989.
  32. Robert Gregory, David Karney,
    A Collection of Matrices for Testing Computational Algorithms,
    Wiley, 1969,
    ISBN: 0882756494,
    LC: QA263.G68.
  33. Ernst Hairer, Syvert Norsett, Gerhard Wanner,
    Solving Ordinary Differential Equations I: Nonstiff Problems,
    Springer, 1987,
    ISBN: 3540566708,
    LC: QA372.H16.
  34. Per Hansen, Tony Chan,
    FORTRAN Subroutines for General Toeplitz Systems,
    ACM Transactions on Mathematical Software,
    Volume 18, Number 3, September 1992, pages 256-273.
  35. Harry Harman,
    Modern Factor Analysis,
    Third Edition,
    The University of Chicago Press, 1976,
    ISBN: 0226316521,
    LC: QA276.H38.
  36. John Herndon,
    Algorithm 52: A Set of Test Matrices,
    Communications of the ACM,
    Volume 4, Number 4, April 1961, page 180.
  37. Nicholas Higham,
    A survey of condition number estimation for triangular matrices,
    SIAM Review,
    Volume 29, Number 4, December 1987, pages 575-596.
  38. Nicholas Higham,
    Accuracy and Stability of Numerical Algorithms,
    SIAM, 1996,
    ISBN: 0898715210,
    LC: QA297.H53.
  39. Nicholas Higham,
    Algorithm 694: A Collection of Test Matrices in MATLAB,
    ACM Transactions on Mathematical Software,
    Volume 17, Number 3, September 1991, pages 289-305.
  40. Nicholas Higham,
    Stability analysis of algorithms for solving confluent Vandermonde-like systems,
    SIAM Journal on Matrix Analysis and Applications,
    Volume 11, Number 1, January 1990, pages 23-41.
  41. Nicholas Higham, Desmond Higham,
    Large growth factors in Gaussian elimination with pivoting,
    SIAM Journal on Matrix Analysis and Applications,
    Volume 10, Number 2, April 1989, pages 155-164.
  42. John Holte,
    Carries, Combinatorics, and an Amazing Matrix,
    The American Mathematical Monthly,
    Volume 104, Number 2, February 1997, pages 138-149.
  43. Roger Horn, Charles Johnson,
    Matrix Analysis,
    Cambridge, 1985,
    ISBN: 0-521-38632-2,
    LC: QA188.H66.
  44. Alston Householder, John Carpenter,
    The singular values of involutory and of idempotent matrices,
    Numerische Mathematik,
    Volume 5, Number 1, December 1963, pages 234-237.
  45. Lawrence Huber, Jacqueline Meulman, Willem Heiser,
    Two Purposes for Matrix Factorization: A Historical Appraisal,
    SIAM Review,
    Volume 41, Number 1, March 1999, pages 68-82.
  46. William Kahan,
    Numerical Linear Algebra,
    Canadian Mathematical Bulletin,
    Volume 9, 1966, pages 757-801.
  47. Sam Karlin,
    Total Positivity, Volume 1,
    Stanford University Press, 1968,
    ISBN: 0804703140,
    LC: QA355.K33.
  48. Charles Kenney, Alan Laub,
    Controllability and stability radii for companion form systems,
    Math. Control Signals Systems,
    Volume 1, 1988, pages 239-256.
  49. David Kershaw,
    The Incomplete Cholesky-Conjugate Gradient Method for the Iterative Solution of Systems of Linear Equations,
    Journal of Computational Physics,
    Volume 26, Number 1, January 1978, pages 43-65.
  50. Donald Knuth,
    The Art of Computer Programming,
    Volume 1, Fundamental Algorithms,
    Third Edition
    Addison-Wesley, 1997,
    ISBN: 0201896834,
    LC: QA76.6.K64.
  51. Maurice Kraitchik,
    Mathematical Recreations,
    Norton, 1942,
    LC: QA95.K72.
  52. Henry Lancaster,
    The Helmert Matrices,
    American Mathematical Monthly,
    Volume 72, Number 1, January 1965, pages 4-12.
  53. Peter Lauchli,
    Jordan-Elimination und Ausgleichung nach kleinsten Quadraten,
    (Jordan elimination and smoothing by least squares),
    Numerische Mathematik,
    Volume 3, Number 1, December 1961, pages 226-240.
  54. Jon Lee,
    Hoffman's Circle Untangled,
    SIAM Review,
    Volume 39, Number 1, March 1997, pages 98-105.
  55. Wim Lenferink, Marc Spijker,
    On the use of stability regions in the numerical analysis of initial value problems,
    Mathematics of Computation,
    Volume 57, Number 195, July 1991, pages 221-237.
  56. M Lietzke, R Stoughton, Marjorie Lietzke,
    A Comparison of Seeral Method for Inverting Large Symmetric Positive Definite Matrics,
    Mathematics of Computation
    Volume 18, Number 87, pages 449-456.
  57. Max Lotkin,
    A set of test matrices,
    Mathematics Tables and Other Aids to Computation,
    Volume 9, 1955, pages 153-161.
  58. Roger Martin, G Peters, James Wilkinson,
    HQR, The QR Algorithm for Real Hessenberg Matrices,
    Numerische Mathematik,
    Volume 14, Number 3, February 1970, pages 219-231.
  59. Roger Martin, James Wilkinson,
    Similarity Reduction of a General Matrix to Hessenberg Form: ELMHES,
    Numerische Mathematik,
    Volume 12, Number 5, December 1968, pages 349-368.
  60. John McCarthy,
    Pick's Theorem: What's the Big Deal?
    American Mathematical Monthly,
    Volume 110, Number 1, January 2003, pages 36-45.
  61. Noel Nachtigal, Lothar Reichel, Lloyd Trefethen,
    A hybrid GMRES algorithm for nonsymmetric linear systems,
    SIAM Journal on Matrix Analysis and Applications,
    Volume 13, Number 3, June 1992, pages 796-825.
  62. John Nash,
    Compact Numerical Methods for Computers: Linear Algebra and Function Minimisation,
    Second Edition,
    Taylor & Francis, 1990,
    ISBN: 085274319X,
    LC: QA184.N37.
  63. Morris Newman, John Todd,
    The evaluation of matrix inversion programs,
    Journal of the Society for Industrial and Applied Mathematics,
    Volume 6, Number 4, 1958, pages 466-476.
  64. Albert Nijenhuis, Herbert Wilf,
    Combinatorial Algorithms for Computers and Calculators,
    Second Edition,
    Academic Press, 1978,
    ISBN: 0-12-519260-6,
    LC: QA164.N54.
  65. Alexander Ostrowski,
    On the spectrum of a one-parametric family of matrices,
    Journal fuer Reine und Angewandte Mathematik,
    Volume 193, Numbers 3/4, 1954, pages 143-160.
  66. Seymour Parter,
    On the distribution of the singular values of Toeplitz matrices,
    Linear Algebra and Applications,
    Volume 80, August 1986, pages 115-130.
  67. ML Pei,
    A test matrix for inversion procedures,
    Communications of the ACM,
    Volume 5, Number 10, October 1962, page 508.
  68. Charles Pinter,
    A Book of Abstract Algebra,
    Second Edition,
    McGraw Hill, 2003,
    ISBN: 0072943505,
    LC: QA162.P56.
  69. William Pratt,
    Digital Image Processing,
    Second Edition,
    Wiley, 1991,
    ISBN13: 978-0471857662,
    LC: TA1632.P7.
  70. Lothar Reichel, Lloyd Trefethen,
    Eigenvalues and pseudo-eigenvalues of Toeplitz matrices,
    Linear Algebra and Its Applications,
    Volume 162-164, February 1992, pages 153-185.
  71. Friedrich Roesler,
    Riemann's hypothesis as an eigenvalue problem,
    Linear Algebra and Its Applications,
    Volume 81, September 1986, pages 153-198.
  72. Daniel Rutherford,
    Some continuant determinants arising in physics and chemistry II,
    Proceedings of the Royal Society Edinburgh,
    Volume 63, A, 1952, pages 232-241.
  73. Heinz Rutishauser,
    On test matrices,
    Programmation en Mathematiques Numeriques,
    Centre National de la Recherche Scientifique,
    1966, pages 349-365.
  74. Herbert Ryser,
    Combinatorial Mathematics,
    Mathematical Association of America, 1963,
    ISBN: 0883850141,
    LC: QA165.R95.
  75. Brian Smith, James Boyle, Jack Dongarra, Burton Garbow, Yasuhiko Ikebe, Virginia Klema, Cleve Moler,
    Matrix Eigensystem Routines, EISPACK Guide,
    Lecture Notes in Computer Science, Volume 6,
    Springer, 1976,
    ISBN13: 978-3540075462,
    LC: QA193.M37.
  76. Dennis Stanton, Dennis White,
    Constructive Combinatorics,
    Springer, 1986,
    ISBN: 0387963472,
    LC: QA164.S79.
  77. Pete Stewart,
    Efficient Generation of Random Orthogonal Matrices With an Application to Condition Estimators,
    SIAM Journal on Numerical Analysis,
    Volume 17, Number 3, June 1980, pages 403-409.
  78. Pete Stewart,
    Introduction to Matrix Computations,
    Academic Press, 1973.
  79. Douglas Sweet,
    The use of pivoting to improve the numerical performance of Toeplitz solvers,
    In "Advanced Algorithms and Architectures for Signal Processing",
    Edited by J M Speiser,
    Proceedings SPIE 696, 1986, pages 8-18.
  80. Gabor Szego,
    Solution to problem 3705,
    American Mathematical Monthly,
    Volume 43, Number 4, 1936, pages 246-259
  81. Olga Taussky, John Todd,
    Another look at a matrix of Mark Kac,
    Linear Algebra and Its Applications,
    Volume 150, May 1991, pages 341-360.
  82. Olga Taussky, Marvin Marcus,
    Eigenvalues of finite matrices,
    in Survey of Numerical Analysis,
    edited by John Todd,
    McGraw-Hill, 1962,
    LC: QA297.T6.
  83. John Todd,
    Basic Numerical Mathematics,
    Volume 2: Numerical Algebra,
    Birkhauser, 1980,
    ISBN: 0817608117,
    LC: QA297.T58.
  84. Lloyd Trefethen,
    Spectral Methods in MATLAB,
    SIAM, 2000,
    ISBN: 0898714656,
    LC: QA377.T65.
  85. Lloyd Trefethen, David Bau,
    Numerical Linear Algebra,
    SIAM, 1997,
    ISBN: 0-89871-361-7,
    LC: QA184.T74.
  86. Lloyd Trefethen,
    Pseudospectra of matrices,
    in Numerical Analysis 1991,
    Proceedings of the 14th Dundee Conference,
    DF Griffiths and GA Watson, editors,
    Pitman Research Notes in Mathematics, volume 260,
    Longman Scientific and Technical, Essex, UK, 1992, pages 234-266.
  87. William Trench,
    Numerical solution of the eigenvalue problem for Hermitian Toeplitz matrices,
    SIAM Journal on Matrix Analysis and Applications,
    Volume 10, Number 2, April 1989, pages 135-146.
  88. HW Turnbull,
    The Theory of Determinants, Matrices, and Invariants,
    Blackie, 1929.
  89. Evgeny Tyrtyshnikov,
    Cauchy-Toeplitz matrices and some applications,
    Linear Algebra and Applications,
    Volume 149, 15 April 1991, pages 1-18.
  90. James Varah,
    A generalization of the Frank matrix,
    SIAM Journal on Scientific and Statistical Computing,
    Volume 7, Number 3, August 1986, pages 835-839.
  91. James Varah,
    The Prolate Matrix,
    Linear Algebra and Applications,
    Volume 187, 1993, pages 269-278.
  92. Andrew Wathen,
    Realistic eigenvalue bounds for the Galerkin mass matrix,
    IMA Journal of Numerical Analysis,
    Volume 7, Number 4, October 1987, pages 449-457
  93. Eric Weisstein,
    CRC Concise Encyclopedia of Mathematics,
    CRC Press, 2002,
    Second edition,
    ISBN: 1584883472,
    LC: QA5.W45
  94. Joan Westlake,
    A Handbook of Numerical Matrix Inversion and Solution of Linear Equations,
    John Wiley, 1968,
    ISBN13: 978-0471936756,
    LC: QA263.W47.
  95. James Wilkinson,
    Error Analysis of Direct Methods of Matrix Inversion,
    Journal of the ACM,
    Volume 8, Number 3, July 1961, pages 281-330.
  96. James Wilkinson,
    Error analysis of floating-point computation,
    Numerische Mathematik,
    Volume 2, 1960, pages 319-340.
  97. James Wilkinson,
    Rounding Errors in Algebraic Processes,
    Prentice Hall, 1963,
    ISBN: 0-486-67999-3,
    LC: QA76.5.W53.
  98. James Wilkinson,
    The Algebraic Eigenvalue Problem,
    Oxford University Press, 1988,
    ISBN: 0198534183,
    LC: QA218.W5.
  99. James Wilkinson, Christian Reinsch,
    Handbook for Automatic Computation,
    Volume II, Linear Algebra, Part 2,
    Springer, 1971,
    ISBN: 0387054146,
    LC: QA251.W67.
  100. Gerhard Zielke,
    Testmatrizen mit maximaler Konditionszahl,
    (Test matrices with maximal condition number),
    Volume 13, Number 1, March 1974, pages 33-54.
  101. Daniel Zwillinger, Steven Kokoska,
    Standard Probability and Statistical Tables,
    CRC Press, 2000,
    ISBN: 1-58488-059-7,
    LC: QA273.3.Z95.

Source Code:

Examples and Tests:

You can go up one level to the MATLAB source codes.

Last revised on 22 April 2014.