Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
name = "IntervalContractors"
uuid = "15111844-de3b-5229-b4ba-526f2f385dc9"
version = "0.6.0"
version = "0.7.0"

[deps]
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
IntervalBoxes = "43d83c95-ebbb-40ec-8188-24586a1458ed"

[compat]
IntervalArithmetic = "1"
IntervalBoxes = "0.3.0"
IntervalArithmetic = "1.1"
julia = "1.10"

[extras]
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ IntervalContractors
[![Build Status](https://github.com/JuliaIntervals/IntervalContractors.jl/workflows/CI/badge.svg)](https://github.com/JuliaIntervals/IntervalContractors.jl/actions/workflows/CI.yml)
</h1>

## ⚠ Deprecated — use `IntervalArithmetic.jl`

As of v0.7.0, every reverse-mode function previously provided by this
package now lives in [`IntervalArithmetic.jl`](https://github.com/JuliaIntervals/IntervalArithmetic.jl)
(v1.1+). The exports here remain available as deprecation shims that
forward to their `IntervalArithmetic` equivalents and emit a
`Base.depwarn`. Once you have migrated, drop the dependency on
`IntervalContractors`. The package will be archived after the 0.7.x
deprecation cycle.

Migration:

| Old | New |
| :-------------------------------------------------------- | :--------------------------------------------------- |
| `IntervalContractors.plus_rev(a, b, c)` | `IntervalArithmetic.plus_rev(a, b, c)` |
| `IntervalContractors.mul_rev(a, b, c)` | `IntervalArithmetic.times_rev(a, b, c)` |
| `IntervalContractors.f_rev(c, x)` returning `(c, x_new)` | `IntervalArithmetic.f_rev(c, x)` returning `x_new` |
| `IntervalContractors.mul_rev_IEEE1788` | `IntervalArithmetic.mul_rev` |
| (other reverse names) | same name in `IntervalArithmetic` |

`using IntervalContractors` and `using IntervalArithmetic` together now
makes the reverse names ambiguous. Resolve by qualifying explicitly
(`IntervalArithmetic.plus_rev(...)`) or by removing `using IntervalContractors`
once your call sites are migrated.

## About `IntervalContractors.jl`

`IntervalContractors.jl` provides contractors and reverse functions (also called backward functions or relational functions) for interval arithmetic.
Expand Down
103 changes: 39 additions & 64 deletions src/IntervalContractors.jl
Original file line number Diff line number Diff line change
@@ -1,72 +1,47 @@
"""
IntervalContractors

**Deprecated** — every reverse-mode function previously defined here now
lives in `IntervalArithmetic.jl`. This package's exports remain available
in the 0.7.x line as deprecation shims that forward to their
`IntervalArithmetic` equivalents and emit a `Base.depwarn`.

Migration:

| Old | New |
| :---------------------------------------- | :--------------------------------------- |
| `IntervalContractors.plus_rev(a, b, c)` | `IntervalArithmetic.plus_rev(a, b, c)` |
| `IntervalContractors.mul_rev(a, b, c)` | `IntervalArithmetic.times_rev(a, b, c)` |
| `IntervalContractors.f_rev(c, x)` returning `(c, x')` | `IntervalArithmetic.f_rev(c, x)` returning the tightened `x` directly |
| `IntervalContractors.mul_rev_IEEE1788` | `IntervalArithmetic.mul_rev` |
| (other names) | same name in `IntervalArithmetic` |

Once you have migrated, drop the dependency on `IntervalContractors`.
The package will be archived after the 0.7.x deprecation cycle.
"""
module IntervalContractors

export plus_rev, minus_rev, inv_rev,
mul_rev, div_rev, power_rev,
sign_rev, max_rev, min_rev,
sqr_rev, sqrt_rev, abs_rev,
exp_rev, exp2_rev, exp10_rev, expm1_rev,
log_rev, log2_rev, log10_rev, log1p_rev,
sin_rev, cos_rev, tan_rev,
asin_rev, acos_rev, atan_rev,
sinh_rev, cosh_rev, tanh_rev,
asinh_rev, acosh_rev, atanh_rev,
mul_rev_IEEE1788, mul_rev_to_pair,
pow_rev1, pow_rev2

using IntervalArithmetic, IntervalArithmetic.Symbols
using IntervalBoxes

sqr_rev, sqrt_rev, abs_rev,
exp_rev, exp2_rev, exp10_rev, expm1_rev,
log_rev, log2_rev, log10_rev, log1p_rev,
sin_rev, cos_rev, tan_rev,
asin_rev, acos_rev, atan_rev,
sinh_rev, cosh_rev, tanh_rev,
asinh_rev, acosh_rev, atanh_rev,
mul_rev_IEEE1788, mul_rev_to_pair,
pow_rev1, pow_rev2

import IntervalArithmetic
using IntervalArithmetic: BareInterval, Interval

# Internal helper retained for backwards compatibility with code that did
# `using IntervalContractors: IntervalType`. Prefer
# `Union{Interval{T}, BareInterval{T}}` directly.
const IntervalType{T} = Union{Interval{T}, BareInterval{T}}

# @generated
# half_pi(::Type{T}) where {T <: IntervalType} = :(exact(0.5) * convert($T, exact(pi)))
# @generated
# two_pi(::Type{T}) where {T <: IntervalType} = :(exact(2.0) * convert($T, exact(pi)))

@generated function half_pi(x::T) where {T <: IntervalType}
return exact(0.5) * convert(T, exact(pi))
end

@generated function two_pi(x::T) where {T <: IntervalType}
return exact(2.0) * convert(T, exact(pi))
end

@generated function pi_interval(x::T) where {T <: IntervalType}
return convert(T, exact(pi))
end


include("arithmetic.jl")
include("transformations.jl")
include("powers.jl")
include("exponential.jl")
include("trig.jl")
include("inverse_trig.jl")
include("hyperbolic.jl")
include("inverse_hyperbolic.jl")
include("extrema.jl")

"""
Dictionary mapping functions to their reverse functions.
"""
const reverse_operations = Dict(
:+ => :plus_rev,
:- => :minus_rev,
:* => :mul_rev,
:/ => :div_rev,
:^ => :power_rev,
:() => :() # empty operation
)

for f in ( :sqrt, :sqr, :abs,
:exp, :exp2, :exp10, :expm1,
:log, :log2, :log10, :log1p,
:sin, :cos, :tan,
:asin, :acos, :atan,
:sinh, :cosh, :tanh,
:asinh, :acosh, :atanh,
:inv, :sign, :max, :min)
reverse_operations[f] = Symbol(f, "_rev")
end
include("deprecations.jl")

end
end # module
Loading
Loading