A Personalizable Test Matrix Collection for Julia

Test matrices are widely used for measuring the performance of an algorithm with respect to accuracy, stability or speed; testing the correctness and robustness of an algorithm on a wide range of problems; and comparing competing algorithms.

Various collections of test matrices have been made available in software, including:

This blog entry is about Matrix Depot, a test matrix collection for the Julia language. Matrix Depot coalesces parameterized test matrices, regularization test problems, and real-life sparse matrix data into a single framework. It not only provides a diverse collection of test matrices but is also extensible and personalizable.

1 Extending the Collection

When Matrix Depot (v0.5.x) is first installed, we have 55 test matrices available to use. Matrices can be easily generated using the interface matrixdepot("name", p1, p2,...), where name is the matrix name and p1, p2,... are input parameters depending on name. For example, the following command will generate a 12-by-12 Wilkinson matrix and then display a 2-D color image of the matrix using PyPlot.

julia> using MatrixDepot
julia> A = matrixdepot("wilkinson", 12)
julia> using PyPlot
julia> matshow(A)

Figure 1: A 12-by-12 Wilkinson matrix.

We can extend the collection by downloading matrices from the University of Florida Sparse Matrix Collection using the interface matrixdepot(name, :get). For example, we can download the matrix web-Google from SNAP (Stanford Network Analysis Platform) by

julia> matrixdepot("SNAP/web-Google", :get)

In addition, we can easily add new matrix generators to Matrix Depot. See http://matrixdepotjl.readthedocs.org/en/latest/user.html for more details.

2 Defining Personalized Groups

Matrix Depot has 10 predefined groups. The function matrixdepot(group) returns a list of matrices in a given group. For example, here a list of random matrices in Matrix Depot.

julia> matrixdepot("random")
8-element Array{ASCIIString,1}:

Every test matrix in Matrix Depot is assigned a unique number. We can access matrices by number and test an algorithm on a group of matrices in a simple loop.

julia> matrixdepot(2, 4, 22:24)
5-element Array{AbstractString,1}:

julia> for name in matrixdepot(2, 4, 22:24)
	   A = matrixdepot(name, 4)
           @printf "%9s has 2-norm %0.3f\n" name norm(A)

 binomial has 2-norm 4.576
   cauchy has 2-norm 0.978
     hilb has 2-norm 1.500
  invhilb has 2-norm 10341.015
    invol has 2-norm 313.525

A user can define new groups with the macro @addgroup and use them just as the predefined groups.

julia> @addgroup testforAlg1 = matrixdepot(2, 4, 22:24)

By extending the collection and defining new groups, Matrix Depot allows you to design your personal test collection.

Author: Weijian Zhang, weijian.zhang@manchester.ac.uk