@@ -8,16 +8,28 @@ n = 10 #Size of test matrix
8
8
srand (1 )
9
9
10
10
debug && println (" Bidiagonal matrices" )
11
- for relty in (Float32, Float64, BigFloat), elty in (relty, Complex{relty})
11
+ for relty in (Int, Float32, Float64, BigFloat), elty in (relty, Complex{relty})
12
12
debug && println (" elty is $(elty) , relty is $(relty) " )
13
- dv = convert (Vector{elty}, randn (n))
14
- ev = convert (Vector{elty}, randn (n- 1 ))
15
- b = convert (Matrix{elty}, randn (n, 2 ))
16
- c = convert (Matrix{elty}, randn (n, n))
17
- if (elty <: Complex )
18
- dv += im* convert (Vector{elty}, randn (n))
19
- ev += im* convert (Vector{elty}, randn (n- 1 ))
20
- b += im* convert (Matrix{elty}, randn (n, 2 ))
13
+ if relty <: AbstractFloat
14
+ dv = convert (Vector{elty}, randn (n))
15
+ ev = convert (Vector{elty}, randn (n- 1 ))
16
+ b = convert (Matrix{elty}, randn (n, 2 ))
17
+ c = convert (Matrix{elty}, randn (n, n))
18
+ if (elty <: Complex )
19
+ dv += im* convert (Vector{elty}, randn (n))
20
+ ev += im* convert (Vector{elty}, randn (n- 1 ))
21
+ b += im* convert (Matrix{elty}, randn (n, 2 ))
22
+ end
23
+ elseif relty <: Integer
24
+ dv = convert (Vector{elty}, rand (1 : 10 , n))
25
+ ev = convert (Vector{elty}, rand (1 : 10 , n- 1 ))
26
+ b = convert (Matrix{elty}, rand (1 : 10 , n, 2 ))
27
+ c = convert (Matrix{elty}, rand (1 : 10 , n, n))
28
+ if (elty <: Complex )
29
+ dv += im* convert (Vector{elty}, rand (1 : 10 , n))
30
+ ev += im* convert (Vector{elty}, rand (1 : 10 , n- 1 ))
31
+ b += im* convert (Matrix{elty}, rand (1 : 10 , n, 2 ))
32
+ end
21
33
end
22
34
23
35
debug && println (" Test constructors" )
@@ -89,23 +101,24 @@ for relty in (Float32, Float64, BigFloat), elty in (relty, Complex{relty})
89
101
condT = cond (map (Complex128,Tfull))
90
102
x = T \ b
91
103
tx = Tfull \ b
104
+ promty = typeof ((zero (relty)* zero (relty) + zero (relty)* zero (relty))/ one (relty))
92
105
@test_throws DimensionMismatch Base. LinAlg. naivesub! (T,ones (elty,n+ 1 ))
93
- @test norm (x- tx,Inf ) <= 4 * condT* max (eps ()* norm (tx,Inf ), eps (relty )* norm (x,Inf ))
106
+ @test norm (x- tx,Inf ) <= 4 * condT* max (eps ()* norm (tx,Inf ), eps (promty )* norm (x,Inf ))
94
107
@test_throws DimensionMismatch T \ ones (elty,n+ 1 ,2 )
95
108
@test_throws DimensionMismatch T.' \ ones (elty,n+ 1 ,2 )
96
109
@test_throws DimensionMismatch T' \ ones (elty,n+ 1 ,2 )
97
110
if relty != BigFloat
98
111
x = T.' \ c.'
99
112
tx = Tfull.' \ c.'
100
- @test norm (x- tx,Inf ) <= 4 * condT* max (eps ()* norm (tx,Inf ), eps (relty )* norm (x,Inf ))
113
+ elty <: AbstractFloat && @test norm (x- tx,Inf ) <= 4 * condT* max (eps ()* norm (tx,Inf ), eps (promty )* norm (x,Inf ))
101
114
@test_throws DimensionMismatch T.' \ b.'
102
115
x = T' \ c.'
103
116
tx = Tfull' \ c.'
104
- @test norm (x- tx,Inf ) <= 4 * condT* max (eps ()* norm (tx,Inf ), eps (relty )* norm (x,Inf ))
117
+ @test norm (x- tx,Inf ) <= 4 * condT* max (eps ()* norm (tx,Inf ), eps (promty )* norm (x,Inf ))
105
118
@test_throws DimensionMismatch T' \ b.'
106
119
x = T\ c.'
107
120
tx = Tfull\ c.'
108
- @test norm (x- tx,Inf ) <= 4 * condT* max (eps ()* norm (tx,Inf ), eps (relty )* norm (x,Inf ))
121
+ @test norm (x- tx,Inf ) <= 4 * condT* max (eps ()* norm (tx,Inf ), eps (promty )* norm (x,Inf ))
109
122
@test_throws DimensionMismatch T\ b.'
110
123
end
111
124
@@ -133,11 +146,13 @@ for relty in (Float32, Float64, BigFloat), elty in (relty, Complex{relty})
133
146
@test_throws ArgumentError diag (T,n+ 1 )
134
147
135
148
debug && println (" Eigensystems" )
136
- d1, v1 = eig (T)
137
- d2, v2 = eig (map (elty<: Complex ? Complex128 : Float64,Tfull))
138
- @test_approx_eq isupper?d1: reverse (d1) d2
139
- if elty <: Real
140
- Test. test_approx_eq_modphase (v1, isupper?v2: v2[:,n: - 1 : 1 ])
149
+ if relty <: AbstractFloat
150
+ d1, v1 = eig (T)
151
+ d2, v2 = eig (map (elty<: Complex ? Complex128 : Float64,Tfull))
152
+ @test_approx_eq isupper?d1: reverse (d1) d2
153
+ if elty <: Real
154
+ Test. test_approx_eq_modphase (v1, isupper?v2: v2[:,n: - 1 : 1 ])
155
+ end
141
156
end
142
157
143
158
debug && println (" Singular systems" )
@@ -161,8 +176,8 @@ for relty in (Float32, Float64, BigFloat), elty in (relty, Complex{relty})
161
176
@test convert (elty,- 1.0 ) * T == Bidiagonal (- T. dv,- T. ev,T. isupper)
162
177
@test T * convert (elty,- 1.0 ) == Bidiagonal (- T. dv,- T. ev,T. isupper)
163
178
for isupper2 in (true , false )
164
- dv = convert (Vector{elty}, randn (n))
165
- ev = convert (Vector{elty}, randn (n- 1 ))
179
+ dv = convert (Vector{elty}, relty <: AbstractFloat ? randn (n) : rand ( 1 : 10 , n))
180
+ ev = convert (Vector{elty}, relty <: AbstractFloat ? randn (n - 1 ) : rand ( 1 : 10 , n- 1 ))
166
181
T2 = Bidiagonal (dv, ev, isupper2)
167
182
Tfull2 = full (T2)
168
183
for op in (+ , - , * )
0 commit comments