mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-11-19 07:20:28 +01:00
rework IntervalArithmetic.± application
This commit is contained in:
parent
4f2caf84cd
commit
cdb3c39d2a
@ -1,5 +1,3 @@
|
|||||||
import Base: rationalize
|
|
||||||
|
|
||||||
using IntervalArithmetic
|
using IntervalArithmetic
|
||||||
|
|
||||||
IntervalArithmetic.setrounding(Interval, :tight)
|
IntervalArithmetic.setrounding(Interval, :tight)
|
||||||
@ -7,9 +5,20 @@ IntervalArithmetic.setformat(sigfigs=12)
|
|||||||
|
|
||||||
import IntervalArithmetic.±
|
import IntervalArithmetic.±
|
||||||
|
|
||||||
function (±){T<:Number}(X::AbstractArray{T}, tol::Real)
|
function (±)(X::SparseVector, tol::Real)
|
||||||
r{T}(x::T) = (x == zero(T)? @interval(0) : x ± tol)
|
I, V = findnz(X)
|
||||||
return r.(X)
|
Vint = [v ± tol for v in V]
|
||||||
|
return sparsevec(I, Vint)
|
||||||
|
end
|
||||||
|
|
||||||
|
function (±)(X::Array{T}, tol::Real) where {T<:AbstractFloat}
|
||||||
|
result = zeros(Interval{Float64}, size(X)...)
|
||||||
|
for i in eachindex(X)
|
||||||
|
if X[i] != zero(T)
|
||||||
|
result[i] = X[i] ± tol
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
(±)(X::GroupRingElem, tol::Real) = GroupRingElem(X.coeffs ± tol, parent(X))
|
(±)(X::GroupRingElem, tol::Real) = GroupRingElem(X.coeffs ± tol, parent(X))
|
||||||
|
Loading…
Reference in New Issue
Block a user