Skip to content

Commit

Permalink
avoid defining ± for Intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Mar 5, 2024
1 parent 6c25ca7 commit caf083d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
5 changes: 0 additions & 5 deletions src/IntervalMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@ if vIA >= v"0.22"
import Base: intersect
export ±, midpoint_radius

function ±(x::Number, y::Number)
return x + interval(-y, y)
end

function Base.:(==)(A::AbstractMatrix{<:Interval}, B::AbstractMatrix{<:Interval})
return size(A) == size(B) && all(map((a, b) -> isequal_interval(a, b), A, B))
end

else
import IntervalArithmetic: ±, midpoint_radius

Expand Down
4 changes: 2 additions & 2 deletions src/exponential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function _exp_remainder(A::IntervalMatrix{T}, t, p; n=checksquare(A)) where {T}
end
M = exp(C * t)
Y = M - Q
Γ = IntervalMatrix(fill(zero(T) ± one(T), (n, n)))
Γ = IntervalMatrix(fill(interval(-one(T), one(T)), (n, n)))
E = Γ * Y
return E
end
Expand All @@ -111,7 +111,7 @@ function _exp_remainder_series(A::IntervalMatrix{T}, t, p; n=checksquare(A)) whe
@assert c < 1 "the remainder of the matrix exponential could not be " *
"computed because a convergence condition is not satisfied: $c ≥ 1 " *
"but it should be smaller than 1; try choosing a larger order"
Γ = IntervalMatrix(fill(zero(T) ± one(T), (n, n)))
Γ = IntervalMatrix(fill(interval(-one(T), one(T)), (n, n)))
return Γ * ((nA * t)^(p + 1) * (1 / factorial(p + 1) * 1 / (1 - c)))
end

Expand Down
8 changes: 4 additions & 4 deletions src/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ parametrized in the number field, the interval type, and the matrix type.
### Examples
```jldoctest
julia> A = IntervalMatrix([-0.9±0.1 0±0; 0±0 -0.9±0.1])
julia> A = IntervalMatrix([-1 .. -0.8 0 .. 0; 0 .. 0 -1 .. -0.8])
2×2 IntervalMatrix{Float64, Interval{Float64}, Matrix{Interval{Float64}}}:
[-1.00001, -0.7999999] [0.0, 0.0]
[0.0, 0.0] [-1.00001, -0.7999999]
[-1.0, -0.7999999] [0.0, 0.0]
[0.0, 0.0] [-1.0, -0.7999999]
```
An interval matrix proportional to the identity matrix can be built using the
Expand Down Expand Up @@ -182,7 +182,7 @@ function ±(C::MT, S::MT) where {T,MT<:AbstractMatrix{T}}
"radii matrix should match, but they are $(size(C)) " *
"and $(size(S)) respectively"))

return IntervalMatrix(map((x, y) -> x ± y, C, S))
return IntervalMatrix(map((x, y) -> interval(x - y, x + y), C, S))
end

for op in (:Adjoint, :Bidiagonal, :Diagonal, :Hermitian,
Expand Down

0 comments on commit caf083d

Please sign in to comment.