From 6c485052c24428b84b05da47e590e1f8cc29b470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Richard?= Date: Mon, 24 Jul 2023 19:28:13 +0200 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 1c0522fc984d2631cc777bac0cd891ff2993e23d Merge: 4c239d52 ee93bd43 Author: Benoît Richard Date: Sun Jul 23 23:13:48 2023 +0200 Merge pull request #569 from vaerksted/master fix typos commit ee93bd43ff6f255a046f764afdc229dba33ed844 Author: spaette Date: Sat Jul 22 12:11:01 2023 -0500 typos commit 4c239d5223a6e430c646bdf91b6978aab976c2f0 Author: Benoît Richard Date: Tue Jul 4 00:35:20 2023 +0200 Bump version commit 249040dedd9fa78b348f59241b309e9e2b03e186 Merge: 44046589 7bef23ed Author: Benoît Richard Date: Tue Jul 4 00:34:13 2023 +0200 Merge pull request #525 from petvana/simplified-mod Simplified version of mod(x::Interval, y::Real) commit 44046589ca7c4ffbb662caa4a23852335dc2464c Author: Benoît Richard Date: Wed Jun 14 14:03:14 2023 +0200 Bump version for release commit 7bef23ed8c85ee8c392f8f80e91092e64fc72d63 Author: Petr Vana Date: Fri May 27 11:11:53 2022 +0200 Cleanup commit f9f4733a1134e4ad3a946ddf8023e0d7b5d7fa80 Author: Petr Vana Date: Fri May 27 11:10:05 2022 +0200 Throw ArgumentError for Interval divisor for mod commit 6fdc809a1ba51df6121a9fa39df388fca054132d Merge: 439723f0 d2603d6c Author: Petr Vana Date: Fri May 27 11:01:43 2022 +0200 Merge branch 'simplified-mod' of github.com:petvana/IntervalArithmetic.jl into simplified-mod commit 439723f068feb228e703fb03b20270586c2d83b9 Author: Petr Vana Date: Fri May 27 11:01:27 2022 +0200 Disable divisor for mod to be an interval commit d2603d6c4524ab884aeaabaf2265f8d123b13d28 Author: Petr Vana Date: Thu May 26 11:34:04 2022 +0200 Update docs commit 45abc460ab885ba1648c3b83fb74a96053c169f9 Author: Petr Vana Date: Thu May 26 11:30:14 2022 +0200 Implementation for strictly negative divisors for mod commit ff4791034526c3104889ee7105b7bcfb3809cd93 Author: Petr Vana Date: Thu May 26 11:11:35 2022 +0200 Add todo for mod with between two intervals commit ea00b231585d2307e4b10ba846f83943f0fe68d8 Author: Petr Vana Date: Wed May 25 19:59:30 2022 +0200 Imrpove test coverage + use zero() commit b56f4bec4b77fba85fee6039943542a7a4caa3d7 Author: Petr Vana Date: Wed May 25 13:44:24 2022 +0200 Use ⊇ operator commit d23df89472ae2721abdfbcaf46687efdd4c3890e Author: Petr Vana Date: Tue May 24 21:13:53 2022 +0200 Update src/intervals/functions.jl Co-authored-by: lucaferranti <49938764+lucaferranti@users.noreply.github.com> commit 153d749887a1cfbe5c480c91630116da25bd8020 Author: Petr Vana Date: Tue May 24 20:27:51 2022 +0200 Improve testing commit fea1b3403a5682874b4d42c5c8170f67be71d582 Author: Petr Vana Date: Tue May 24 20:10:05 2022 +0200 Introduce simplified version of mod --- NEWS.md | 4 +- docs/src/input_output.md | 2 +- .../Range of 2-dimensional functions.ipynb | 4 +- src/multidim/intervalbox.jl | 2 +- test/interval_tests/numeric.jl | 41 +++++++++++++++++++ 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7dc672caa..66ae524cb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,7 +6,7 @@ - The package now supports only Julia v1.3 and later. ### Breaking changes -- Changed from using `FastRounding.jl` to `RoundingEmulator.jl` for the defalt rounding mode. [#370](https://github.com/JuliaIntervals/IntervalArithmetic.jl/pull/370) +- Changed from using `FastRounding.jl` to `RoundingEmulator.jl` for the default rounding mode. [#370](https://github.com/JuliaIntervals/IntervalArithmetic.jl/pull/370) ## v0.15 @@ -293,7 +293,7 @@ v0.1 is the first public release of the package. ### Interval arithmetic - Two methods for interval rounding are available: - (i) narrow/slow (which uses hardward rounding mode changes for `Float64` intervals, and (ii) wide/fast (which does not change the rounding mode) + (i) narrow/slow (which uses hardware rounding mode changes for `Float64` intervals, and (ii) wide/fast (which does not change the rounding mode) - The current interval precision and rounding mode are stored in the `parameters` object - The macro `@interval` generates intervals based on the current interval precision - Trigonometric functions are "nearly" rigorous (for `Float64` intervals, correct rounding is not currently guaranteed) diff --git a/docs/src/input_output.md b/docs/src/input_output.md index 8ac10dc3b..bd7874e0d 100644 --- a/docs/src/input_output.md +++ b/docs/src/input_output.md @@ -73,7 +73,7 @@ 'u' Returns the interval with midpoint as lower bound and radius taken in upward direction. 'C' Returns upper case for Empty, Entire and Nai 'c' Returns lower case for Empty, Entire and Nai - '+' Returns postitve numbers with '+' sign before the number + '+' Returns positive numbers with '+' sign before the number '0' Left-pads the numbers with zeros instead of spaces within the field width - The field width specifies the length of midpoint string. diff --git a/examples/Range of 2-dimensional functions.ipynb b/examples/Range of 2-dimensional functions.ipynb index d1827efc9..6c5e83601 100644 --- a/examples/Range of 2-dimensional functions.ipynb +++ b/examples/Range of 2-dimensional functions.ipynb @@ -356,7 +356,7 @@ "\t\tconsole.log.apply(console, arguments);\n", "\t }\n", "\t},\n", - "\t// a central way to initalize communication\n", + "\t// a central way to initialize communication\n", "\t// for widgets.\n", "\tcommInitializer: function (widget) {\n", "\t widget.sendUpdate = function () {};\n", @@ -435,7 +435,7 @@ " });\n", "\t });\n", "\n", - "\t // coordingate with Comm and redraw Signals\n", + "\t // coordinate with Comm and redraw Signals\n", "\t // XXX: Test using Reactive here to improve performance\n", "\t $([IPython.events]).on(\n", "\t\t'output_appended.OutputArea', function (event, type, value, md, toinsert) {\n", diff --git a/src/multidim/intervalbox.jl b/src/multidim/intervalbox.jl index 48179e65e..05cfdbd26 100644 --- a/src/multidim/intervalbox.jl +++ b/src/multidim/intervalbox.jl @@ -61,7 +61,7 @@ length(::IntervalBox{N}) where {N} = N Return a vector of the `mid` of each interval composing the `IntervalBox`. -See `mid(X::Interval, α=0.5)` for more informations. +See `mid(X::Interval, α=0.5)` for more information. """ mid(X::IntervalBox) = mid.(X) scaled_mid(X::IntervalBox, α) = scaled_mid.(X, α) diff --git a/test/interval_tests/numeric.jl b/test/interval_tests/numeric.jl index bcb136075..b688d81f0 100644 --- a/test/interval_tests/numeric.jl +++ b/test/interval_tests/numeric.jl @@ -386,3 +386,44 @@ end @test nthroot(interval(BigFloat, -81, -16), -4) ≛ ∅ @test nthroot(interval(BigFloat, -81, -16), 1) ≛ interval(BigFloat, -81, -16) end + +# approximation used for testing (not to rely on ≈ for intervals) +# ⪆(x, y) = (x ≈ y) && (x ⊇ y) +⪆(x::Interval, y::Interval) = x.lo ≈ y.lo && x.hi ≈ y.hi && x ⊇ y + +@testset "`mod`" begin + r = 0.0625 + x = r..(1+r) + @test mod(x, 1) == mod(x, 1.0) == 0..1 + @test mod(x, 2) == mod(x, 2.0) ⪆ x + @test mod(x, 2.5) ⪆ x + @test mod(x, 0.5) == 0..0.5 + @test mod(x, -1) == mod(x, -1.0) == -1..0 + @test mod(x, -2) == mod(x, -2.0) ⪆ -2+x + @test mod(x, -2.5) ⪆ -2.5+x + @test mod(x, -0.5) == -0.5..0 + + x = (-1+r) .. -r + @test mod(x, 1) == mod(x, 1.0) ⪆ 1+x + @test mod(x, 2) == mod(x, 2.0) ⪆ 2+x + @test mod(x, 2.5) ⪆ 2.5+x + @test mod(x, 0.5) == 0..0.5 + @test mod(x, -1) == mod(x, -1.0) ⪆ x + @test mod(x, -2) == mod(x, -2.0) ⪆ x + @test mod(x, -2.5) ⪆ x + @test mod(x, -0.5) == -0.5..0 + + x = -r .. 1-r + @test mod(x, 1) == mod(x, 1.0) == 0..1 + @test mod(x, 2) == mod(x, 2.0) == 0..2 + @test mod(x, 2.5) == 0..2.5 + @test mod(x, 0.5) == 0..0.5 + @test mod(x, -1) == mod(x, -1.0) == -1..0 + @test mod(x, -2) == mod(x, -2.0) == -2..0 + @test mod(x, -2.5) == -2.5..0 + @test mod(x, -0.5) == -0.5..0 + + # TODO - implement mod for two intervals + @test_throws ArgumentError mod(1..2, 1.4..1.5) + @test_throws ArgumentError mod(1.0, 1.4..1.5) +end