Skip to content

Commit f4a6b53

Browse files
committed
Add tests and fix typos
1 parent 1d8b6b1 commit f4a6b53

File tree

4 files changed

+18
-42
lines changed

4 files changed

+18
-42
lines changed

perf/linear_eq_tabular.txt

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,11 @@ Gauss Seidel
3939

4040
Gauss Elimination
4141

42-
20×3 DataFrames.DataFrame
43-
│ Row │ n │ Base.\\ │ Gauss Elimination │
44-
├─────┼────┼─────────────┼───────────────────┤
45-
│ 1 │ 1 │ 1.0859e-5 │ 1.0402e-5 │
46-
│ 2 │ 10 │ 0.00037311 │ 0.000372278 │
47-
│ 3 │ 11 │ 0.000457845 │ 0.000457603 │
48-
│ 4 │ 12 │ 0.000543028 │ 0.00054428 │
49-
│ 5 │ 13 │ 0.000642694 │ 0.00064314 │
50-
│ 6 │ 14 │ 0.00076788 │ 0.000766503 │
51-
│ 7 │ 15 │ 0.000877223 │ 0.000874887 │
52-
│ 8 │ 16 │ 0.00102177 │ 0.00102244 │
53-
│ 9 │ 17 │ 0.00114972 │ 0.00115541 │
54-
│ 10 │ 18 │ 0.00150682 │ 0.00153407 │
55-
│ 11 │ 19 │ 0.00172544 │ 0.00170808 │
56-
│ 12 │ 2 │ 2.6519e-5 │ 2.5677e-5 │
57-
│ 13 │ 20 │ 0.00192433 │ 0.0019773 │
58-
│ 14 │ 3 │ 4.6299e-5 │ 4.6316e-5 │
59-
│ 15 │ 4 │ 7.2201e-5 │ 7.2106e-5 │
60-
│ 16 │ 5 │ 0.000101941 │ 0.000102027 │
61-
│ 17 │ 6 │ 0.000139823 │ 0.000139717 │
62-
│ 18 │ 7 │ 0.000189156 │ 0.000188991 │
63-
│ 19 │ 8 │ 0.000239304 │ 0.000238721 │
64-
│ 20 │ 9 │ 0.000305721 │ 0.000305388 │
42+
5×3 DataFrames.DataFrame
43+
│ Row │ n │ Base.\\ │ Gauss Elimination │
44+
├─────┼───┼────────────┼───────────────────┤
45+
│ 1 │ 1 │ 1.84e-6 │ 8.127e-6 │
46+
│ 2 │ 2 │ 3.1615e-6 │ 1.0029e-5 │
47+
│ 3 │ 3 │ 4.53986e-6 │ 1.1211e-5 │
48+
│ 4 │ 4 │ 6.8655e-6 │ 1.4342e-5 │
49+
│ 5 │ 5 │ 1.0773e-5 │ 1.7725e-5 │

src/IntervalRootFinding.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ export
2121
bisect, newton1d, slope,
2222
slope_newton1d,
2323
gauss_seidel_interval, gauss_seidel_interval!,
24-
gauss_seidel_contractor, gauss_seidel_contractor!
25-
# gauss_seidel_interval_static1, gauss_seidel_interval_static1!
26-
# gauss_seidel_interval_static2, gauss_seidel_interval_static2!
27-
# gauss_seidel_interval_static, gauss_seidel_interval_static!
24+
gauss_seidel_contractor, gauss_seidel_contractor!,
25+
gauss_elimination_interval, gauss_elimination_interval!
2826

2927
export isunique, root_status
3028

src/linear_eq.jl

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using IntervalArithmetic
21
"""
32
Preconditions the matrix A and b with the inverse of mid(A)
43
"""
@@ -81,16 +80,14 @@ function gauss_elimination_interval(A::AbstractMatrix, b::AbstractArray; precond
8180
n = size(A, 1)
8281
x = fill(-1e16..1e16, n)
8382

84-
x = gauss_seidel_interval!(x, A, b, precondition=precondition)
83+
x = gauss_elimination_interval!(x, A, b, precondition=precondition)
8584

8685
return x
8786
end
8887
"""
89-
Iteratively solves the system of interval linear
90-
equations and returns the solution set. Uses the
91-
Gauss-Seidel method (Hansen-Sengupta version) to solve the system.
92-
Keyword `precondition` to turn preconditioning off.
93-
Eldon Hansen and G. William Walster : Global Optimization Using Interval Analysis - Chapter 5 - Page 115
88+
Solves the system of linear equations using Gaussian Elimination,
89+
with (or without) preconditioning. (kwarg - `precondition`)
90+
Luc Jaulin, Michel Kieffer, Olivier Didrit and Eric Walter - Applied Interval Analysis - Page 72
9491
"""
9592
function gauss_elimination_interval!(x::AbstractArray, a::AbstractMatrix, b::AbstractArray; precondition=true)
9693

@@ -132,16 +129,12 @@ function gauss_elimination_interval1(A::AbstractMatrix, b::AbstractArray; precon
132129
n = size(A, 1)
133130
x = fill(-1e16..1e16, n)
134131

135-
x = gauss_seidel_interval!(x, A, b, precondition=precondition)
132+
x = gauss_elimination_interval1!(x, A, b, precondition=precondition)
136133

137134
return x
138135
end
139136
"""
140-
Iteratively solves the system of interval linear
141-
equations and returns the solution set. Uses the
142-
Gauss-Seidel method (Hansen-Sengupta version) to solve the system.
143-
Keyword `precondition` to turn preconditioning off.
144-
Eldon Hansen and G. William Walster : Global Optimization Using Interval Analysis - Chapter 5 - Page 115
137+
Using `Base.\``
145138
"""
146139
function gauss_elimination_interval1!(x::AbstractArray, a::AbstractMatrix, b::AbstractArray; precondition=true)
147140

test/linear_eq.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using IntervalArithmetic, StaticArrays, IntervalRootFinding
22

3-
@testset "Testing Gauss Seidel Method" begin
3+
@testset "Linear Equations" begin
44

55
A = [[2..3 0..1;1..2 2..3], ]
66
b = [[0..120, 60..240], ]
@@ -9,7 +9,7 @@ using IntervalArithmetic, StaticArrays, IntervalRootFinding
99

1010
for i in 1:length(A)
1111
for precondition in (false, true)
12-
for f in (gauss_seidel_interval, gauss_seidel_contractor)
12+
for f in (gauss_seidel_interval, gauss_seidel_contractor, gauss_elimination_interval)
1313
@test all(x[i] .⊆ f(A[i], b[i]))
1414
end
1515
end

0 commit comments

Comments
 (0)