Skip to content

Commit 235fd4c

Browse files
authored
Fix typo in estimate_σ⁻ (#88)
1 parent f3e9d27 commit 235fd4c

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ libblastrampoline_jll = "8e850b90-86db-534c-a0d3-1478176c7d93"
1212
julia = "1.6"
1313

1414
[extras]
15+
DoubleFloats = "497a8b3b-efae-58df-a0af-a86822472b78"
1516
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
1617
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1718

1819
[targets]
19-
test = ["Quaternions", "Test"]
20+
test = ["DoubleFloats", "Quaternions", "Test"]

src/svd.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function estimate_σ⁻(dv::AbstractVector, ev::AbstractVector, n1::Integer, n2:
114114
μ = abs(dv[n1])
115115
B1 = μ
116116
for j in n1:(n2 - 1)
117-
μ = abs(dv[j + 1])**+ abs(ev[j])))
117+
μ = abs(dv[j + 1])*/+ abs(ev[j])))
118118
B1 = min(B1, μ)
119119
end
120120

test/svd.jl

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Test, GenericLinearAlgebra, LinearAlgebra, Quaternions
1+
using Test, GenericLinearAlgebra, LinearAlgebra, Quaternions, DoubleFloats
22

33
@testset "Singular value decomposition" begin
44
@testset "Problem dimension ($m,$n)" for
@@ -73,7 +73,38 @@ using Test, GenericLinearAlgebra, LinearAlgebra, Quaternions
7373
end
7474

7575
@testset "Issue 81" begin
76-
m = [1 0 0 0; 0 2 1 0; 0 1 2 0; 0 0 0 -1]
77-
@test Float64.(svdvals(big.(m))) svdvals(m)
76+
A = [1 0 0 0; 0 2 1 0; 0 1 2 0; 0 0 0 -1]
77+
@test Float64.(svdvals(big.(A))) svdvals(A)
78+
79+
A = [
80+
0.3 0.0 0.0 0.0 0.0 0.2 0.3 0.0;
81+
0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0;
82+
0.0 -0.2 0.0 0.0 0.0 0.0 0.0 -0.2;
83+
0.3 0.0 0.0 0.0 0.0 0.2 0.4 0.0;
84+
0.0 0.4 -0.2 0.0 0.0 0.0 0.0 0.3;
85+
0.2 0.0 0.0 0.0 0.0 0.0 0.2 0.0;
86+
0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0;
87+
0.0 0.3 -0.2 0.0 0.0 0.0 0.0 0.3
88+
]
89+
@test GenericLinearAlgebra._svdvals!(
90+
GenericLinearAlgebra.bidiagonalize!(copy(A)).bidiagonal
91+
) svdvals(A)
92+
93+
n = 17
94+
A = zeros(Double64, n, n)
95+
for j in 1:n, i in 1:n
96+
A[i, j] = 1 / Double64(i + j - 1)
97+
end
98+
@test svdvals(A) svdvals(Float64.(A))
99+
100+
# From https://github.com/JuliaMath/DoubleFloats.jl/issues/149
101+
n = 64
102+
c = Complex{BigFloat}(3//1 + 1im//1)
103+
A = diagm(
104+
1 => c*ones(BigFloat, n - 1),
105+
-1 => c*ones(BigFloat,n - 1),
106+
-2 => ones(BigFloat, n - 2)
107+
)
108+
@test svdvals(A) svdvals(Complex{Double64}.(A))
78109
end
79110
end

0 commit comments

Comments
 (0)