[A1,A2,...,Am] = gallery(matrixname,P1,P2,...,Pn)
[A1,A2,...,Am] = gallery(matrixname,P1,P2,...,Pn,typename)
A = gallery(k)
A = gallery("circul", v)
[v,beta] = gallery("house", x)
[A,beta] = gallery("ipjfact", n, k)
A = gallery("cauchy", x, y)
| Parameter | Description |
|---|---|
| matrixname | name of the matrix family to generate (string or character vector), e.g. "circul", "cauchy", "grcar", "minij", "dramadah", "house", "ipjfact" |
| P1, P2, ..., Pn | family-dependent parameters: scalars, vectors or matrices that determine size and entries (for example n, vectors v, x, y, or option flags) |
| n | positive integer specifying matrix order or size |
| v, x, y | vectors used as parameters (for example first row for circulant, point locations for chebvand, or Cauchy parameters) |
| k | option or small integer parameter controlling family behaviour (for example number of superdiagonals for grcar or variant selectors for dramadah) |
| typename | optional output data type: "double" (default) or "single" |
| Parameter | Description |
|---|---|
| A1,A2,...,Am | one or more matrices or arrays produced by the chosen family |
| A | single matrix or multidimensional array when one output is requested |
| v,beta,s | Householder outputs: v (vector), beta (scalar), and optional s returned by house |
| beta | determinant or scalar output for families that return it explicitly (for example ipjfact returns determinant beta) |
The gallery function returns a collection of standard test matrices and generated data used to illustrate numerical linear algebra concepts, test algorithms, and reproduce textbook examples.
Use the matrixname argument to select a family; additional parameters (sizes, vectors, options) depend on the chosen family.
Typical uses: study eigenvalue sensitivity and conditioning, exercise solvers with structured matrices (Toeplitz, Hankel, circulant), generate random or specially structured matrices with prescribed singular/eigenvalue properties, or obtain canonical examples for teaching and tests.
The optional typename forces the numeric output type.
If omitted, the output type is inferred from the inputs: presence of a single input yields single, otherwise outputs are double.
| Name | Syntax | Notes |
|---|---|---|
| gallery(3) | A = gallery(3) | Classic ill-conditioned 3×3 test matrix; demonstrates eigenvalue sensitivity. |
| gallery(5) | A = gallery(5) | 5×5 example with exact characteristic polynomial \(\lambda^5=0\); numerically the eigenvalues are small and sensitive. |
| circul | A = gallery("circul", v) | Circulant matrix: rows are cyclic shifts of v; eigenvalues are the DFT of v. |
| grcar | A = gallery("grcar", n, k) | Toeplitz with -1 on subdiagonal and 1's on main and k superdiagonals; useful for pseudospectra examples. |
| minij | A = gallery("minij", n) | SPD matrix with A(i,j)=min(i,j); inverse is tridiagonal (second-difference structure). |
| dramadah | A = gallery("dramadah", n, k) | Binary (0/1) families; certain k yield unimodular Toeplitz matrices with integer inverses. |
| house | [v,beta] = gallery("house", x) | Returns Householder vector v and scalar beta so H=I-beta*v*v' reflects x onto a multiple of e1. |
| binomial | A = gallery("binomial", n) | Binomial matrix with A^2 = 2^(n-1) I; scaled matrix is involutory. |
| cauchy | A = gallery("cauchy", x, y) | Cauchy matrix A(i,j)=1/(x(i)+y(j)); explicit determinant and inverse formulas exist. |
| ris | A = gallery("ris", n) | Symmetric Hankel matrix with entries 0.5/(n-i-j+1.5); eigenvalues cluster near ±π/2. |
| chebspec | A = gallery("chebspec", n, k) | Chebyshev spectral differentiation matrix. k=0 yields a nilpotent form; k=1 yields a nonsingular, well-conditioned operator. |
| wilk | gallery("wilk", m) | Wilkinson examples (small triangular systems, W21+, etc.) illustrating stability issues. |
| sampling | A = gallery("sampling", x) | Nonsymmetric matrix with integer eigenvalues 0..n-1; eigenvectors are typically ill-conditioned. |
| ipjfact | [A,beta] = gallery("ipjfact", n, k) | Hankel matrix built from factorials (or reciprocals); determinant and inverse known in closed form. |
| moler | A = gallery("moler", n, alpha) | Symmetric positive definite example produced as U'*U; can exhibit an isolated tiny eigenvalue. |
| lotkin | A = gallery("lotkin", n) | Hilbert-like matrix with first row ones; extremely ill-conditioned, inverse has integer structure. |
| chebvand | A = gallery("chebvand", x) | Chebyshev Vandermonde-like matrix: A(i,j)=T_{i-1}(x(j)), useful for spectral interpolation and polynomial bases. |
| lehmer | A = gallery("lehmer", n) | lehmer matrix with entries i/j for i ≤ j; symmetric positive definite and ill-conditioned. |
A = gallery(3)
C = gallery("circul",120);
imagesc(C);
axis square;
colorbar;
| Version | Description |
|---|---|
| 1.15.0 | initial version |