Skip to content

Commit 2e83578

Browse files
committed
feat(matrices): add parter
1 parent b4289df commit 2e83578

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

Diff for: src/matrices/index.jl

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export
3030
Moler,
3131
Neumann,
3232
Oscillate,
33+
Parter,
3334
Triw
3435

3536
# include all matrices
@@ -60,6 +61,7 @@ include("minij.jl")
6061
include("moler.jl")
6162
include("neumann.jl")
6263
include("oscillate.jl")
64+
include("parter.jl")
6365
include("triw.jl")
6466

6567
# matrix groups
@@ -95,6 +97,7 @@ MATRIX_GROUPS[GROUP_BUILTIN] = Set([
9597
Moler,
9698
Neumann,
9799
Oscillate,
100+
Parter,
98101
Triw,
99102
])
100103
MATRIX_GROUPS[GROUP_USER] = Set([])

Diff for: src/matrices/parter.jl

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
Parter Matrix
3+
=============
4+
The Parter matrix is a Toeplitz and Cauchy matrix
5+
with singular values near `π`.
6+
7+
*Input options:*
8+
9+
+ dim: the dimension of the matrix.
10+
11+
*References:*
12+
13+
The MathWorks Newsletter, Volume 1, Issue 1,
14+
March 1986, page 2. S. V. Parter, On the distribution of the
15+
singular values of Toeplitz matrices, Linear Algebra and
16+
Appl., 80 (1986), pp. 115-130.
17+
"""
18+
struct Parter{T<:Number} <: AbstractMatrix{T}
19+
n::Integer
20+
21+
function Parter{T}(n::Integer) where {T<:Number}
22+
n >= 0 || throw(ArgumentError("$n < 0"))
23+
return new{T}(n)
24+
end
25+
end
26+
27+
# constructors
28+
Parter(n::Integer) = Parter{Int}(n)
29+
Parter{T}(n::Integer) where {T<:Integer} = Parter{Rational{T}}(n)
30+
31+
# metadata
32+
@properties Parter [:eigen]
33+
34+
# properties
35+
size(A::Parter) = (A.n, A.n)
36+
37+
# functions
38+
@inline Base.@propagate_inbounds function getindex(A::Parter{T}, i::Integer, j::Integer) where {T}
39+
@boundscheck checkbounds(A, i, j)
40+
return one(T) / T(i - j + 0.5)
41+
end

0 commit comments

Comments
 (0)