Skip to content
This repository was archived by the owner on Apr 26, 2021. It is now read-only.

Commit aff5695

Browse files
RalphASsimonbyrne
authored andcommitted
Accommodate edge case of single row or column (#8)
1 parent d8d48a0 commit aff5695

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/GenericSVD.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ then applying a Golub-Kahan QR iteration.
9797
"""
9898
function svd!{T<:Real}(B::Bidiagonal{T}, U=nothing, Vt=nothing, ɛ=eps(T))
9999
n = size(B, 1)
100+
if n == 1
101+
@goto done
102+
end
100103
n₂ = n
101104

102105
maxB = max(maximum(abs, B.dv), maximum(abs, B.ev))

test/bigfloat.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,18 @@ bS = svdfact(bX)
7474
@test isapprox(full(bS), bX, rtol=1e3*eps(BigFloat))
7575
@test isapprox(svdvals(bX), svdvals(X), rtol=1e3*eps())
7676
@test bX == X # check we didn't modify the input
77+
78+
n = 100
79+
X = randn(n,1)
80+
bX = big.(X)
81+
bS = svdfact(bX)
82+
@test isapprox(full(bS), bX, rtol=1e3*eps(BigFloat))
83+
@test isapprox(svdvals(bX), svdvals(X), rtol=1e3*eps())
84+
@test bX == X # check we didn't modify the input
85+
86+
X = randn(1,n)
87+
bX = big.(X)
88+
bS = svdfact(bX)
89+
@test isapprox(full(bS), bX, rtol=1e3*eps(BigFloat))
90+
@test isapprox(svdvals(bX), svdvals(X), rtol=1e3*eps())
91+
@test bX == X # check we didn't modify the input

0 commit comments

Comments
 (0)