/
symmetry.jl
54 lines (49 loc) · 1.07 KB
/
symmetry.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module TestSymmetry
using LinearAlgebra, SparseArrays, Test
using SumOfSquares
function test_linsolve()
x = [1, 2]
for A in [
[
1 0 2 3
0 1 3 -2
],
[
1 2 0 3
0 3 1 -2
],
]
b = A' * x
@test Certificate.Symmetry._linsolve(
A,
b,
Symmetry._RowEchelonMatrix(),
) ≈ x
B = float.(A)
for i in axes(B, 1)
B[i, :] = normalize(B[i, :])
end
b = B' * x
@test Certificate.Symmetry.__linsolve(
B,
b,
Symmetry._OrthogonalMatrix(),
) ≈ x
@test Certificate.Symmetry.__linsolve(
sparse(B),
b,
Symmetry._OrthogonalMatrix(),
) ≈ x
end
end
function runtests()
for name in names(@__MODULE__; all = true)
if startswith("$name", "test_")
@testset "$(name)" begin
getfield(@__MODULE__, name)()
end
end
end
end
end
TestSymmetry.runtests()