Skip to content

Commit cee6f12

Browse files
committed
Update
1 parent a494aa3 commit cee6f12

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

test/Bridges/Constraint/test_QuadtoSOCBridge.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,36 @@ function test_clique_trees_compute_sparse_sqrt_edge_cases()
426426
return
427427
end
428428

429+
function test_compute_sparse_sqrt_edge_cases()
430+
for A in AbstractMatrix[
431+
[1.0 0.0; 0.0 2.0],
432+
[1.0 0.0 1.0; 0.0 1.0 1.0; 1.0 1.0 3.0],
433+
[1.0 1.0; 1.0 1.0],
434+
[2.0 2.0; 2.0 2.0],
435+
[2.0 0.0; 0.0 0.0],
436+
[1.0 1.0 0.0; 1.0 1.0 0.0; 0.0 0.0 1.0],
437+
BigFloat[1.0 0.0; 0.0 2.0],
438+
BigFloat[1.0 1.0; 1.0 1.0],
439+
]
440+
I, J, V = MOI.Utilities.compute_sparse_sqrt(SparseArrays.sparse(A))
441+
U = zeros(eltype(A), size(A))
442+
for (i, j, v) in zip(I, J, V)
443+
U[i, j] += v
444+
end
445+
@test isapprox(A, U' * U; atol = 1e-10)
446+
end
447+
# Test failures
448+
for A in Any[
449+
[-1.0 0.0; 0.0 1.0],
450+
[0.0 -1.0; -1.0 0.0],
451+
BigFloat[-1.0 0.0; 0.0 1.0],
452+
]
453+
@test MOI.Utilities.compute_sparse_sqrt(SparseArrays.sparse(A)) ===
454+
nothing
455+
end
456+
return
457+
end
458+
429459
function test_clique_trees_semidefinite_cholesky_fail()
430460
inner = MOI.Utilities.Model{Float64}()
431461
model = MOI.Bridges.Constraint.QuadtoSOC{Float64}(inner)

0 commit comments

Comments
 (0)