File tree 2 files changed +51
-0
lines changed
2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 40
40
RandSVD,
41
41
Rohess,
42
42
Rosser,
43
+ Sampling,
43
44
Toeplitz,
44
45
Triw
45
46
@@ -81,6 +82,7 @@ include("rando.jl")
81
82
include (" randsvd.jl" )
82
83
include (" rohess.jl" )
83
84
include (" rosser.jl" )
85
+ include (" sampling.jl" )
84
86
include (" toeplitz.jl" )
85
87
include (" triw.jl" )
86
88
@@ -127,6 +129,7 @@ MATRIX_GROUPS[GROUP_BUILTIN] = Set([
127
129
RandSVD,
128
130
Rohess,
129
131
Rosser,
132
+ Sampling,
130
133
Toeplitz,
131
134
Triw,
132
135
])
Original file line number Diff line number Diff line change
1
+ """
2
+ Matrix with Application in Sampling Theory
3
+ ==========================================
4
+ A nonsymmetric matrix with eigenvalues 0, 1, 2, ... n-1.
5
+
6
+ *Input options:*
7
+
8
+ + vec: `vec` is a vector with no repeated elements.
9
+
10
+ + dim: `dim` is the dimension of the matrix.
11
+ `vec = [1:dim;]/dim`.
12
+
13
+ *References:*
14
+
15
+ **L. Bondesson and I. Traat**, A nonsymmetric matrix
16
+ with integer eigenvalues, linear and multilinear algebra, 55(3)
17
+ (2007), pp. 239-247
18
+ """
19
+ struct Sampling{T<: Number } <: AbstractMatrix{T}
20
+ n:: Integer
21
+ vec:: Vector{T}
22
+
23
+ function Sampling (vec:: Vector{T} ) where {T<: Number }
24
+ n = length (vec)
25
+ return new {T} (n, vec)
26
+ end
27
+ end
28
+
29
+ # constructors
30
+ Sampling (n:: Integer ) = Sampling {Float64} (n)
31
+ Sampling {T} (n:: Integer ) where {T<: Number } = Sampling (T[1 : n;] / n)
32
+
33
+ # metadata
34
+ @properties Sampling [:eigen ]
35
+
36
+ # properties
37
+ size (A:: Sampling ) = (A. n, A. n)
38
+
39
+ # functions
40
+ @inline Base. @propagate_inbounds function getindex (A:: Sampling{T} , i:: Integer , j:: Integer ) where {T}
41
+ @boundscheck checkbounds (A, i, j)
42
+ if i == j
43
+ element = sum ([A[i, index] for index = 1 : A. n if index != i])
44
+ else
45
+ element = A. vec[i] / (A. vec[i] - A. vec[j])
46
+ end
47
+ return element
48
+ end
You can’t perform that action at this time.
0 commit comments