Skip to content

Commit b6e4381

Browse files
authored
Merge pull request #68 from aplavin/patch-3
2 parents 29a7cbe + fde53e4 commit b6e4381

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/bounds/ellipsoid.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ volume(ell::Ellipsoid) = ell.volume
3838
# Returns the principal axes
3939
axes(ell::Ellipsoid) = ell.axes
4040

41-
function decompose(A::AbstractMatrix)
41+
decompose(A::AbstractMatrix) = decompose(Symmetric(A)) # ensure that eigen() always returns real values
42+
43+
function decompose(A::Symmetric)
4244
E = eigen(A)
4345
axlens = @. 1 / sqrt(E.values)
4446
axes = E.vectors * Diagonal(axlens)

test/bounds/bounds.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ const BOUNDST = [
1212
Bounds.MultiEllipsoid
1313
]
1414

15+
@testset "pathological cases" begin
16+
A_almost_symmetric = [2.6081830533175096e8 -5.4107420917559285e6 -1.9314298704966028e9 -2.360066561768968e9; -5.410742091755895e6 379882.440454782 6.715028007245775e7 2.0195280814040575e7; -1.931429870496611e9 6.715028007245693e7 9.811342987452753e10 -4.6579127705367036e7; -2.3600665617689605e9 2.0195280814042665e7 -4.6579127705418006e7 9.80946804720486e10]
17+
# shouldn't fail:
18+
ell = Bounds.Ellipsoid(zeros(4), A_almost_symmetric)
19+
Bounds.volume(ell)
20+
end
21+
1522
@testset "interface - $B, $T, D=$D" for B in BOUNDST, T in [Float32, Float64], D in 1:20
1623
# creation, inspection
1724
bound = B(T, D)

test/bounds/ellipsoids.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const NMAX = 20
1111
@test volume(ell) volume_prefactor(N) * scale^N
1212
axs, axlens = decompose(ell)
1313
@test axlens fill(scale, N)
14-
@test axs Bounds.axes(ell) scale * Matrix(I, N, N)
14+
@test axs Bounds.axes(ell)
15+
@test norm.(eachcol(axs)) == fill(scale, N)
1516
end
1617

1718
@testset "Scaling" begin

0 commit comments

Comments
 (0)