Title: | Generate test matrices |
---|---|
Description: | Functions for generating various test matrices. Inspired by the MATLAB gallery of test matrices. |
Authors: | Thomas Hsiao [aut, cre] |
Maintainer: | Thomas Hsiao <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2025-02-24 05:03:39 UTC |
Source: | https://github.com/txiao95/gallery |
Binomial matrix: an N-by-N multiple of an involuntory matrix with integer entries such that $A^2 = 2^(N-1)*I_N$ Thus B = A*2^((1-N)/2) is involutory, that is B^2 = EYE(N)
binomial_matrix(n)
binomial_matrix(n)
n |
- row dimension |
Arguments x
and y
are vectors of length n
.
C[i,j] = 1 / (x[i] + y[j])
cauchy_matrix(x, y = NULL)
cauchy_matrix(x, y = NULL)
x |
vector of length n |
y |
vector of length n |
Chebyshev spectral differentiation matrix of order n
. k
determines
the character of the output matrix. For either form, the eigenvector matrix is ill-conditioned.
chebspec(n, k = NULL)
chebspec(n, k = NULL)
n |
order of the matrix. |
k |
|
Produces the (primal) Chebyshev Vandermonde matrix based on
the points p
. C[i,j] = T_{i-1}p[j]
, where T_{i-1}
is the Chebyshev
polynomial of degree i-1
chebvand(p, m = NULL)
chebvand(p, m = NULL)
p |
points to evaluate. If a scalar, then |
m |
number of rows of the matrix. |
returns matrix A = H(alpha) + delta * EYE
, such that
H[i,j] = alpha^(i-j+1)
.
chow(n, alpha = 1, delta = 0)
chow(n, alpha = 1, delta = 0)
n |
order of the matrix |
alpha |
defaults to 1 |
delta |
defaults to 0 |
Each row is obtained from the previous by cyclically permuting the entries one step forward. A special Toeplitz matrix in which diagonals "wrap around"
circul(v)
circul(v)
v |
first row of the matrix. If |
a circulant matrix whose first row is the vector v
Returns an n
-by-n
tridiagonal matrix with zeros on the
main diagonal. For k=0
, A
is nonsymmetric. For k=1, A
is
symmetric
clement(n, k = 0)
clement(n, k = 0)
n |
order of matrix |
k |
0 indicates symmetric matrix, 1 asymmetric |
A
For k=0
, if i==j
, $A[i,j]=abs(B[i,j])$ and
A[i,j]=-abs(B[i,j])
otherwise. For k=1
, A
replaces each
diagonal element of B
with its absolute value, and replaces each
off-diagonal with the negative of the largest absolute value off-diagonal
in the same row.
compar(B, k = 0)
compar(B, k = 0)
B |
input matrix |
k |
decides what matrix to return |
A
whose columns repeat cyclicallyReturns an n
-by-n
matrix with cyclically repeating columns
where one cycle consists of the columns defined by randn(n,k)
. Thus, the
rank of matrix A
cannot exceed k
, and k
must be scalar.
cycol(n, k, m = NULL)
cycol(n, k, m = NULL)
n |
number of columns of matrix |
k |
upper limit of rank |
m |
number of rows of matrix |
Returns a n
-by-n
row diagonally dominant,
tridiagonal matrix that is ill-conditioned for small nonnegative values
of theta
. The default value of theta
is 0.01.
dorr(n, theta = 0.01)
dorr(n, theta = 0.01)
n |
order of matrix |
theta |
determines conditionality. Ill-conditioned when theta is nonnegative. |
A
Returns a n
-by-n
nonsingular matrix of 0's and 1's.
With large determinant or inverse. If k=1
, A
is Toeplitz and abs(det(A))=1
.
If k=2
, A
is upper triangular and Toeplitz. If k=3
, A
has maximal
determinant among (0,1) lower Hessenberg matrices. Also is Toeplitz.
Also known as an anti-Hadamard matrix.
dramadah(n, k = 1)
dramadah(n, k = 1)
n |
order of matrix |
k |
decides type of matrix returned. |
Fiedler matrix that has a dominant positive eigenvalue and all others are negative
fiedler(c)
fiedler(c)
c |
N-vector. If |
a symmetric dense matrix A with a dominant positive eigenvalue and all others are negative.
Returns a n
-by-n
matrix equal to the Jordan block with
eigenvalue lambda
, except that A[n,1]=alpha
.
forsythe(n, alpha = .Machine$double.eps, lambda = 0)
forsythe(n, alpha = .Machine$double.eps, lambda = 0)
n |
order of matrix |
alpha |
value of perturbation at |
lambda |
eigenvalue of Jordan block |
N
Frank matrix of order N
. It is upper Hessenberg with
determinant 1.
frank(n, k = 0)
frank(n, k = 0)
n |
order of the matrix |
k |
If k is 1, the elements are reflected about the anti-diagonal. |
Eigenvalues are sensitive.
grcar(n, k = NULL)
grcar(n, k = NULL)
n |
dimension of the square matrix |
k |
number of superdiagonals of ones |
n
-by-n
Toeplitz matrix with -1 on subdiagonal, 1 on diagonal, and k
superdiagionals of 1s.
Matrix whose eigenvalues lie on vertical plane in complex plane.
Returns a 2-by-2 block matrix with four n/2
by n/2
blocks. n
must be an even integer.
[d*eye(m) -diag(1:m),
diag(1:m) d*eye(m)]
hanowa(n, d = NULL)
hanowa(n, d = NULL)
n |
order of matrix |
d |
value of main diagonal |
a n
-byn
involutory matrix and ill-conditioned.
It is a diagonally scaled version of a Hilbert matrix.
invol(n)
invol(n)
n |
order of matrix |
Returns a n
-by-n
JOrdan block with eigenvalue
lambda
. The default is 1.
jordbloc(n, lambda = 1)
jordbloc(n, lambda = 1)
n |
order of matrix |
lambda |
eigenvalue of Jordan block |
the (N + 1) x (N) matrix [ones(1,n); mu*eye(n)]. Well-known example in least squares of the danger of forming t(A)
lauchli(n, mu = NULL, sparse = F)
lauchli(n, mu = NULL, sparse = F)
n |
number of columns |
mu |
constant applied to identity |
sparse |
whether matrix should be sparse |
Lauchli matrix.
the symmetric positive-definite matrix such that A[i,j] = i/j, for j >= i
lehmer(n)
lehmer(n)
n |
order of matrix |
N by N matrix from Leslie population model with average birth and survival rates.
leslie(a, b = NULL, sparse = F)
leslie(a, b = NULL, sparse = F)
a |
average birth numbers (first row) |
b |
survival rates (subdiagonal) |
sparse |
whether to return a sparse matrix |
N by N Leslie population model matrix
MIN(i,j)
The N
-by-N
SPD matrix with A[i,j]=min(i,j)
minij(n)
minij(n)
n |
order of the matrix |
Creates a sparse representation of multiple diagonal matrix
spdiags(A, d, m, n)
spdiags(A, d, m, n)
A |
matrix where columns correspond to the desired diagonals |
d |
indices of the diagonals to be filled in. 0 is main diagonal. -1 is first subdiagonal and +1 is first superdiagonal. |
m |
row dim |
n |
col dim |
dgcMatrix sparse diagonal
Create a sparse tridiagonal matrix of dgcMatrix class.
tridiag(n, x = NULL, y = NULL, z = NULL)
tridiag(n, x = NULL, y = NULL, z = NULL)
n |
dimension of the square matrix |
x |
subdiagonal (-1) |
y |
diagonal (0) |
z |
superdiagonal (+1) |
Sparse tridiagonal matrix