Basics

MatrixDepot is a collection of matrix-centric problems from different sources. Local problems are generated on the local machine and take parameters, for example the dimension. Remote problems come from one of two repositories, the SuiteSparse Matrix Collection and the Matrix Market Collection. Downloaded matrices and additional data are cached on the local disk.

The internal database is loaded automatically by using MatrixDepot, which downloads the index files of the remote collections on first use.

Matrix names

Each problem has a canonical name in the form of a relative path name:

collectionformexample
local"name""vand"
SuiteSparse"dir/name""HB/ash219"
Matrix Market"dir/subdir/name""Harwell-Boeing/smtape/ash219"

Name components must not contain any of the characters /*[]. Within each collection, problems also have integer identifiers counting from 1, accessible as builtin, user, sp and mm.

Each canonical name is mapped to a MatrixData object by MatrixDepot.mdata(name).

Generating matrices

matrixdepot returns the matrix selected by a name or a pattern matching exactly one problem; further arguments are passed to the generator:

matrixdepot("hilb", 5, 4)
5×4 Matrix{Float64}:
 1.0       0.5       0.333333  0.25
 0.5       0.333333  0.25      0.2
 0.333333  0.25      0.2       0.166667
 0.25      0.2       0.166667  0.142857
 0.2       0.166667  0.142857  0.125

An element type can be given as the first parameter:

matrixdepot("hilb", Float16, 3)
3×3 Matrix{Float16}:
 1.0     0.5     0.3333
 0.5     0.3333  0.25
 0.3333  0.25    0.2

mdinfo shows the documentation of a problem, including its input options, groups and references:

mdinfo("moler")

Moler Matrix (moler)

The Moler matrix is a symmetric positive definite matrix. It has one small eigenvalue.

Input options:

  • [type,] dim, alpha: dim is the dimension of the matrix, alpha is a scalar.

  • [type,] dim: alpha = -1.

Groups: ["inverse", "illcond", "symmetric", "posdef"]

References:

J.C. Nash, Compact Numerical Methods for Computers: Linear Algebra and Function Minimisation, second edition, Adam Hilger, Bristol, 1990 (Appendix 1).

mdopen returns a descriptor that gives access to the matrix and accompanying data. For the regularization problems this includes a right-hand side and solution:

md = mdopen("gravity", 4, false)
md.b
4-element Vector{Float64}:
 4.959241031551041
 6.967912638015086
 4.392467726082367
 1.473238838718313

Called without arguments, mdinfo() gives an overview of all loaded problems, groups and remote collections.

Patterns

A pattern selects a subset of the problems in the database. Patterns are accepted by matrixdepot, mdinfo, mdlist, listnames, listdata, mdopen (single match required), MatrixDepot.load, MatrixDepot.loadinfo and MatrixDepot.loadsvd. listdir accepts only strings. mdlist returns the names matching a pattern, and charfun turns a pattern into the characteristic function of the subset.

The elementary patterns are:

  1. A name, or a shell pattern with the wildcards ? (one character except /), * (any sequence except /), ** (any sequence including /) and [...]. Example: "*/???/w*", "**/1138*".
  2. A regular expression applied to the name, e.g. r"^v.*d$".
  3. An integer identifier builtin(n), user(n), sp(n) or mm(n), where n may be integers, ranges or :. Example: builtin(1, 3, 10:11).
  4. An alternate-collection pattern sp(pattern) or mm(pattern), which selects the corresponding matrix of the other remote collection, if it exists (names are sometimes mangled). Example: sp("*/*/1138_bus") selects "HB/1138_bus".
  5. A group name as a Symbol, e.g. :symmetric; see Groups.
  6. A predicate function f(::MatrixData)::Bool, for example data::MatrixDepot.RemoteMatrixData -> data.n <= 100, or the shorthand @pred: @pred(n <= 100).
  7. A predefined predicate:
    • element type: isboolean, isinteger, isreal, iscomplex
    • symmetry: isgeneral, issymmetric, ishermitian, isskew
    • status: isbuiltin, isuser, islocal, isremote, isloaded, isunloaded
    • properties: issvdok (SVD data available), isposdef
    • keyword(expr): single keyword or keywords combined with & and |
    • hasdata(symbol): data with that name are available, e.g. mdlist(hasdata(:b)) lists problems with mdopen(...).b.

The @pred macro defines a predicate by an expression applied to the data object. Names found in propertynames(data) refer to those properties; other names refer to global names visible where @pred is used.

Combining patterns

Patterns of all kinds combine with the operators | (or), & (and) and ~ (not); equivalently, a vector of patterns means or and a tuple means and. See also logical.

mdlist((issymmetric | ishermitian) & :illcond & ~:posdef)
1-element Vector{String}:
 "prolate"
listnames(:symmetric & :inverse & :illcond & :posdef)
list(7)
cauchyhilbinvhilbkmsmolerpascalpei
mdlist(builtin(1:4, 6, 10:15))
11-element Vector{String}:
 "baart"
 "binomial"
 "blur"
 "cauchy"
 "chow"
 "deriv2"
 "dingdong"
 "erdrey"
 "fiedler"
 "forsythe"
 "foxgood"

Patterns over remote properties work the same way:

julia> mdlist(@pred(324085 <= n < 325700))
2-element Vector{String}:
 "LAW/cnr-2000"
 "Sorensen/Linux_call_graph"

julia> mdlist("*/*/*" & @pred(n > 50000))
2-element Vector{String}:
 "misc/cylshell/s3dkq4m2"
 "misc/cylshell/s3dkt3m2"

julia> mdlist(sp(:)) == mdlist("*/*")
true