File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Clement Matrix
3+ ==============
4+ The Clement matrix is a tridiagonal matrix with zero
5+ diagonal entries. If k = 1, the matrix is symmetric.
6+
7+ *Input options:*
8+
9+ + dim, k: `dim` is the dimension of the matrix.
10+ If `k = 0`, the matrix is of type `Tridiagonal`.
11+ If `k = 1`, the matrix is of type `SymTridiagonal`.
12+
13+ + dim: `k = 0`.
14+
15+ *References:*
16+
17+ **P. A. Clement**, A class of triple-diagonal
18+ matrices for test purposes, SIAM Review, 1 (1959), pp. 50-52.
19+ """
20+ abstract type Clement{T<: Number } <: AbstractMatrix{T} end
21+
22+ # constructors
23+ Clement (n:: Integer ) = Clement (n, 0 )
24+ Clement (n:: Integer , k:: Integer ) = Clement {Float64} (n, k)
25+ Clement {T} (n:: Integer ) where {T<: Number } = Clement {T} (n, 0 )
26+ function Clement {T} (n:: Integer , k:: Integer ) where {T}
27+ # 1x1 case
28+ if n == 1
29+ return zeros (T, 1 , 1 )
30+ end
31+
32+ # create the matrix
33+ n = n - 1
34+ x = T[n: - 1 : 1 ;]
35+ z = T[1 : n;]
36+ if k == 0
37+ return Tridiagonal (x, zeros (T, n + 1 ), z)
38+ else
39+ y = sqrt .(x .* z)
40+ return SymTridiagonal (zeros (T, n + 1 ), y)
41+ end
42+ end
43+
44+ # metadata
45+ @properties Clement [:symmetric , :inverse , :eigen ]
Original file line number Diff line number Diff line change 99 ChebSpec,
1010 Chow,
1111 Circulant,
12+ Clement,
1213 Companion,
1314 DingDong,
1415 Fiedler,
@@ -53,6 +54,7 @@ include("cauchy.jl")
5354include (" chebspec.jl" )
5455include (" chow.jl" )
5556include (" circulant.jl" )
57+ include (" clement.jl" )
5658include (" companion.jl" )
5759include (" dingdong.jl" )
5860include (" fiedler.jl" )
@@ -102,6 +104,7 @@ MATRIX_GROUPS[GROUP_BUILTIN] = Set([
102104 ChebSpec,
103105 Chow,
104106 Circulant,
107+ Clement,
105108 Companion,
106109 DingDong,
107110 Fiedler,
You can’t perform that action at this time.
0 commit comments