From 9b5513bb9a5df8c7deb2c02f853747c2ab0b83e5 Mon Sep 17 00:00:00 2001 From: ivanpanch Date: Mon, 28 Jul 2025 21:24:40 +0200 Subject: [PATCH 01/11] Update checking.htm --- doc/checking.htm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/checking.htm b/doc/checking.htm index c8af504..307c76a 100644 --- a/doc/checking.htm +++ b/doc/checking.htm @@ -22,10 +22,10 @@

Checking policies

is a NaN). What to do in such a case? First, we could say that the second argument can never be an invalid number. Second, we could also say such a situation can arise but is forbidden. Third, we could allow such values and - generate an empty interval when encountered. And there is many other + generate an empty interval when encountered. And there are many other possibilities.

-

It is the reason why such a policy is used: there is a lot of +

It is the reason why such a policy is used: there are a lot of interesting behaviors and it would be sad to arbitrarily select one of these.

@@ -56,19 +56,19 @@

Requirements

value, such a value can be used.

Next comes nan. This function is used each time a function - need to return a value of type T but is unable to compute it. + needs to return a value of type T but is unable to compute it. It only happens when one of the arguments of the function is invalid. For example, if you ask what the median value of an empty interval is, nan will be used. But please remember: lower and upper directly return the value stocked in the interval; so, if the interval is empty, lower will not answer by a call to checking::nan (but will return the - same value than checking::empty_lower could return).

+ same value as checking::empty_lower could return).

empty_lower and empty_upper respectively return the lower and upper bound of the empty interval. There is no - requirements for empty_lower and empty_upper to - return the same value than checking::nan. For example, if the + requirement for empty_lower and empty_upper to + return the same value as checking::nan. For example, if the type T does not have any invalid value, the empty_ functions can return the [1;0] interval.

@@ -76,7 +76,7 @@

Requirements

invalid or not. is_empty tests if the interval formed by the two arguments is empty or not. Such tests will generally be at the beginning of each function which involves an argument of type - T. If one of the inputs is declared invalid, the the function + T. If one of the inputs is declared invalid, the function will try to produce an invalid value or an input interval.

Synopsis

@@ -115,10 +115,10 @@

Predefined classes

empty_upper; and a basic test is used for is_nan (it is x!=x). If T does not have quiet NaNs, then nan is an assert(false), the empty interval is - [1,0], and is_nan always return false. As for + [1,0], and is_nan always returns false. As for nan, pos_inf returns numeric_limits::infinity() if possible, or is an - assert(false) otherwise. neg_inf returns the + assert(false) otherwise. neg_inf returns the opposite. Finally, is_empty(T l,T u) is always defined by !(l<=u).

@@ -171,7 +171,7 @@

Customizing your own checking policy

the conversion at the first encountered problem. So empty_lower and empty_upper need to return suitable values in order to define an empty interval (you can use an upper - bound which is not greater or equal than the lower bound for example); and + bound which is not greater or equal to the lower bound for example); and is_empty must be able to distinguish empty intervals from the valid intervals.

@@ -227,7 +227,7 @@

Some examples

  • If you do not mind having undefined results when an empty interval or an interval number is produced, your best bet is to create your own policy by overloading checking_base and modifying - is_nan et is_empty in order for them to always + is_nan and is_empty in order for them to always return false. It is probably the fastest checking policy available; however, it suffers from its deficient security.
  • From 0d455e7914787f930636c11113872160219032ab Mon Sep 17 00:00:00 2001 From: ivanpanch Date: Mon, 28 Jul 2025 21:42:30 +0200 Subject: [PATCH 02/11] Update comparisons.htm --- doc/comparisons.htm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/comparisons.htm b/doc/comparisons.htm index e084d7b..ff6c4e3 100644 --- a/doc/comparisons.htm +++ b/doc/comparisons.htm @@ -14,14 +14,14 @@

    Comparisons

    As was said before, the definition of the comparison operators induces a - slight problem. There are many ways to define them, depending of the return + slight problem. There are many ways to define them, depending on the return type or the expected order. It is the reason why the meaning of the operators is not fixed once and for all.

    The way the operators are defined could have been influenced by a policy, as it is already the case for the rounding and the checking. - However, comparisons are more an external property of the the class rather - than an internal one. They are meant to be locally modified, independantly + However, comparisons are more an external property of the class rather + than an internal one. They are meant to be locally modified, independently of the type of the intervals.

    The operators <, <=, >, @@ -30,7 +30,7 @@

    Comparisons

    type. However, due to technical limitations, this base type can only be the second argument; so the operators are unfortunately not fully symmetric. The return type is not always bool, since some interesting - results can be achieved by using a tri-state return type. So here is the + results can be achieved by using a tri-state return type. So here are the common signatures of the operators:

     template<class T, class Policies1, class Policies2>
    @@ -44,9 +44,9 @@ 

    vided comparisons

    Default comparison

    -

    If nothing is specified, the meaning of the comparison operators are an +

    If nothing is specified, the meaning of the comparison operators is an extension of the operator on the base type. More precisely, if one of the - argument is invalid or empty, an exception is thrown. If the arguments are + arguments is invalid or empty, an exception is thrown. If the arguments are valid, the following rules are applied to determine the result of [a,b] op [c,d] (just consider c == d if the second argument is of type @@ -55,11 +55,11 @@

    Default comparison

    • if ∀ x ∈ [a,b] ∀ y ∈ [c,d] (x op - y), then true
    • + y), then true
    • if ∀ x ∈ [a,b] ∀ y ∈ [c,d] !(x op - y), then false
    • + y), then false
    • otherwise throw an exception.
    @@ -107,7 +107,7 @@

    Other comparisons

    their respective header files under <boost/numeric/interval/compare/...>. And as for the default comparison, the operators will generally complain by throwing an - exception if feed by invalid values.

    + exception if fed by invalid values.

    • certain: this comparison is equivalent to the default @@ -122,7 +122,7 @@

      Other comparisons

    • lexicographic: the lexicographic order (the lower bounds are first compared, and if it is not enough to know the result, the upper bounds are then compared). This order does not have a meaning in interval - arithmetic. However, since it is the natural total order on pair of + arithmetic. However, since it is the natural total order on pairs of (totally ordered) numbers, it may be handy in some cases.
    • set: the set inclusion partial order. This time, an From 7a9af0c26b81c12c6fbe9301c12300cdc963df15 Mon Sep 17 00:00:00 2001 From: ivanpanch Date: Mon, 28 Jul 2025 21:53:25 +0200 Subject: [PATCH 03/11] Update examples.htm --- doc/examples.htm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/examples.htm b/doc/examples.htm index 81400c8..3b41a4a 100644 --- a/doc/examples.htm +++ b/doc/examples.htm @@ -17,7 +17,7 @@

      A first example

      This example shows how to design a function which takes a polynomial and a value and returns the sign of this polynomial at this point. This - function is a filter: if the answer is not guaranteed, the functions says + function is a filter: if the answer is not guaranteed, the function says so. The reason of using a filter rather than a simple evaluation function is: computations with floating-point numbers will incur approximations and it can be enough to change the sign of the polynomial. So, in order to @@ -107,7 +107,7 @@

      Other tests and examples

      In libs/numeric/interval/test/ and libs/numeric/interval/examples/ are some test and example - programs.. The examples illustrate a few uses of intervals. For a general + programs. The examples illustrate a few uses of intervals. For a general description and considerations on using this library, and some potential domains of application, please read this mini-guide.

      @@ -178,8 +178,8 @@

      Examples

      operations for a whole function (which computes the value of a polynomial by using Horner scheme).

      -

      io.cpp shows some stream input and output operators for intervals - .The wide variety of possibilities explains why the library do not +

      io.cpp shows some stream input and output operators for intervals. + The wide variety of possibilities explains why the library does not implement i/o operators and they are left to the user.

      newton-raphson.cpp is an implementation of a specialized version From 179e2c9812b5b8cbd83836b73a0bc0a142a4c066 Mon Sep 17 00:00:00 2001 From: ivanpanch Date: Mon, 28 Jul 2025 22:06:24 +0200 Subject: [PATCH 04/11] Update guide.htm --- doc/guide.htm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/guide.htm b/doc/guide.htm index 5c30aa5..375f92a 100644 --- a/doc/guide.htm +++ b/doc/guide.htm @@ -13,14 +13,14 @@

      Choosing Your Own Interval Type

      -

      First of all, you need to select your base type. In order to obtain an +

      First of all, you need to select your base type. In order to obtain a useful interval type, the numbers should respect some requirements. Please refer to this page in order to see them. When your base type is robust enough, you can go to the next step: the choice of the policies.

      As you should already know if you did not come to this page by accident, - the interval class expect a policies argument describing the + the interval class expects a policies argument describing the rounding and checking policies. The first thing to do is to verify if the default policies are or are not adapted to your case. If your base type is not float, @@ -31,7 +31,7 @@

      Choosing Your Own Interval Type

      The default policies define an interval type that performs precise computations (for float, double, long - double), detects invalid numbers and throws exception each times an + double), detects invalid numbers and throws an exception each times an empty interval is created. This is a brief description and you should refer to the corresponding sections for a more precise description of the default policies. Unless you need some special behavior, this default type is @@ -51,12 +51,12 @@

      Solving systems

      boost::interval<double> is probably what you need. The computations are precise, and they may be fast if enclosed in a protected rounding mode block (see the performance - section). The comparison are "certain"; it is probably the most used type + section). The comparisons are "certain"; it is probably the most used type of comparison, and the other comparisons are still accessible by the - explicit comparison functions. The checking forbid empty interval; they are - not needed since there would be an empty interval at end of the computation + explicit comparison functions. The checking forbids empty intervals; they are + not needed since there would be an empty interval at the end of the computation if an empty interval is created during the computation, and no root would - be inside. The checking also forbid invalid numbers (NaN for floating-point + be inside. The checking also forbids invalid numbers (NaN for floating-point numbers). It can be a minor performance hit if you only use exact floating-point constants (which are clearly not NaNs); however, if performance really does matter, you will probably use a good compiler which @@ -101,7 +101,7 @@

      Switching interval types

      the computations; it is a change of the rounding policy. It also happens when you want to temporarily allow empty intervals to be created; it is a change of the checking policy. These changes should not be prohibited: they - can greatly enhance a program (lisibility, interest, performance).

      + can greatly enhance a program (legibility, interest, performance).


      Date: Mon, 28 Jul 2025 22:16:28 +0200 Subject: [PATCH 05/11] Update includes.htm --- doc/includes.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/includes.htm b/doc/includes.htm index eb8880d..0aca329 100644 --- a/doc/includes.htm +++ b/doc/includes.htm @@ -193,7 +193,7 @@

      interval/ext/integer.hpp

      interval/ext/x86_fast_rounding_control.hpp

      -

      This header defines a new rounding policy allowing to workaround the +

      This header defines a new rounding policy allowing to work around the precision problem of the x86 processors (and so speeding up the computations). However, it only is a partial solution and it shouldn't be used when there is a possibility of underflow or overflow.

      From f3095df3e3c80142334d6b3bafe1a845879700b4 Mon Sep 17 00:00:00 2001 From: ivanpanch Date: Mon, 28 Jul 2025 23:14:02 +0200 Subject: [PATCH 06/11] Update interval.htm --- doc/interval.htm | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/doc/interval.htm b/doc/interval.htm index db8c069..e43c4ab 100644 --- a/doc/interval.htm +++ b/doc/interval.htm @@ -107,11 +107,11 @@

      Interval Arithmetic

      inclusion property:

      -
      ``if f is a function on a set of numbers, f can be +
      "If f is a function on a set of numbers, f can be extended to a new function defined on intervals. This new function f takes one interval argument and returns an interval result such as: ∀ x ∈ [a,b], f(x) - ∈ f([a,b]).''
      + ∈ f([a,b])."

      Such a property is not limited to functions with only one argument. @@ -153,10 +153,10 @@

      Numbers, rounding, and exceptional behavior

      Secondly, the computations must be exact or provide some rounding methods (for instance, toward minus or plus infinity) if we want to - guarantee the inclusion property. Note that we also may explicitely specify + guarantee the inclusion property. Note that we also may explicitly specify no rounding, for instance if the base number type is exact, i.e. the result of a mathematical operation is always computed and represented without loss - of precision. If the number type is not exact, we may still explicitely + of precision. If the number type is not exact, we may still explicitly specify no rounding, with the obvious consequence that the inclusion property is no longer guaranteed.

      @@ -211,11 +211,11 @@

      Comparisons

      only if: ∃ x ∈ [a,b] ∃ y ∈ [c,d], x < y.

      -

      Since any of these solution has a clearly defined semantics, it is not +

      Since any of these solutions has a clearly defined semantics, it is not clear that we should enforce either of them. For this reason, the default - behavior consists to mimic the real comparisons by throwing an exception in - the indeterminate case. Other behaviors can be selected bu using specific - comparison namespace. There is also a bunch of explicitely named comparison + behavior consists in mimicking the real comparisons by throwing an exception in + the indeterminate case. Other behaviors can be selected by using specific + comparison namespace. There is also a bunch of explicitly named comparison functions. See comparisons pages for further details.

      @@ -248,7 +248,7 @@

      Overview of the library, and usage

      For some functions which take several parameters of type interval<T>, all combinations of argument types T and interval<T> which contain at least - one interval<T>, are considered in order to avoid a + one interval<T> are considered in order to avoid a conversion from the arguments of type T to a singleton of type interval<T>. This is done for efficiency reasons (the fact that an argument is a singleton sometimes renders some tests @@ -523,7 +523,7 @@

      Operators + - * /

      The operators / and /= will try to produce an empty interval if the denominator is exactly zero. If the denominator contains zero (but not only zero), the result will be the smallest interval - containing the set of division results; so one of its bound will be + containing the set of division results; so one of its bounds will be infinite, but it may not be the whole interval.

      lower upper median @@ -630,14 +630,14 @@

      sqrt log exp sin

      The function fmod(interval x, interval y) expects the lower bound of y to be strictly positive and returns an interval - z such as 0 <= z.lower() < y.upper() and - such as z is a superset of x-n*y (with + z such that 0 <= z.lower() < y.upper() and + such that z is a superset of x-n*y (with n being an integer). So, if the two arguments are positive singletons, this function fmod(interval, interval) will behave like the traditional function fmod(double, double).

      Please note that fmod does not respect the inclusion - property of arithmetic interval. For example, the result of + property of interval arithmetic. For example, the result of fmod([13,17],[7,8]) should be [0,8] (since it must contain [0,3] and [5,8]). But this answer is not really useful when the purpose is to restrict an interval in order to compute a periodic function. It is the @@ -654,7 +654,7 @@

      Constants

      Some constants are hidden in the boost::numeric::interval_lib namespace. They need to be - explicitely templated by the interval type. The functions are + explicitly templated by the interval type. The functions are pi<I>(), pi_half<I>() and pi_twice<I>(), and they return an object of interval type I. Their respective values are π, π/2 and @@ -827,7 +827,7 @@

      Comparisons

      Another misleading interpretation of the comparison is: you cannot always expect [a,b] < [c,d] to be !([a,b] >= [c,d]) since the comparison is not necessarily total. Equality and less comparison should be - seen as two distincts relational operators. However the default comparison + seen as two distinct relational operators. However the default comparison operators do respect this property since they throw an exception whenever [a,b] and [c,d] overlap.

      @@ -841,7 +841,7 @@

      Interval values and references

      square(x), x-x and 0, etc. So the main cause of wide intervals is that interval arithmetic does not identify different occurrences of the same variable. So, whenever possible, the user has to - rewrite the formulas to eliminate multiple occurences of the same variable. + rewrite the formulas to eliminate multiple occurrences of the same variable. For example, square(x)-2*x is far less precise than square(x-1)-1.

      @@ -914,7 +914,7 @@

      Rationale

      Specialization of std::less. Since the operator < depends on the comparison namespace locally chosen by the user, it is not possible to correctly specialize - std::less. So you have to explicitely provide such a class to + std::less. So you have to explicitly provide such a class to all the algorithms and templates that could require it (for example, std::map).

      @@ -929,9 +929,9 @@

      Rationale

      template codes, it is common there are operations like 2*x. However, the library does not provide them by default because the conversion from int to the base number type is not always - correct (think about the conversion from a 32bit integer to a single + correct (think about the conversion from a 32-bit integer to a single precision floating-point number). So the functions have been put in a - separate header and the user needs to include them explicitely if she wants + separate header and the user needs to include them explicitly if she wants to benefit from these mixed operators. Another point, there is no mixed comparison operators due to the technical way they are defined.

      From 76506ff4f2cf632b6976e4cce520b1727966c142 Mon Sep 17 00:00:00 2001 From: ivanpanch Date: Mon, 28 Jul 2025 23:23:29 +0200 Subject: [PATCH 07/11] Update numbers.htm --- doc/numbers.htm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/numbers.htm b/doc/numbers.htm index 45a1c7b..84dbced 100644 --- a/doc/numbers.htm +++ b/doc/numbers.htm @@ -14,7 +14,7 @@

      Numbers Requirements

      What we call "number" is the base type of the interval - class. The interval library expect a lot of properties from this base type + class. The interval library expects a lot of properties from this base type in order to respect the inclusion property. All these properties are already detailed in the other sections of this documentation; but we will try to summarize them here.

      @@ -26,7 +26,7 @@

      Ordering

      It must be a total order (reflexivity, antisymmetry, transitivity, and each pair of numbers is ordered). So complex<T> will not be a good candidate for the base type; if you need the inclusion property of - interval property, you should use complex< interval<T> + interval arithmetic, you should use complex< interval<T> > in place of interval< complex<T> > (but unfortunately, complex only provides specialization).

      @@ -129,7 +129,7 @@

      Rounding

      Constants

      In order for the trigonometric functions to correctly work, the library - need to know the value of the π constant (and also π/2 and 2π). + needs to know the value of the π constant (and also π/2 and 2π). Since these constants may not be representable in the base type, the library does not have to know the exact value: a lower bound and an upper bound are enough. If these values are not provided by the user, the default @@ -142,7 +142,7 @@

      Operators and conversions

      defined for the base type. The rounding policy defines a lot of functions used by the interval library. So the arithmetic operators do not need to be defined for the base type (unless required by one of the predefined - classes). However, there is an exception: the unary minus need to be + classes). However, there is an exception: the unary minus needs to be defined. Moreover, this operator should only provide exact results; it is the reason why the rounding policy does not provide some negation functions.

      From 214c1b611876f5210e4fabe517db5f79f0088e78 Mon Sep 17 00:00:00 2001 From: ivanpanch Date: Tue, 29 Jul 2025 00:13:59 +0200 Subject: [PATCH 08/11] Update rounding.htm --- doc/rounding.htm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/rounding.htm b/doc/rounding.htm index 26e4d90..ccb1745 100644 --- a/doc/rounding.htm +++ b/doc/rounding.htm @@ -96,7 +96,7 @@

      Requirements

      important semantic requirement: they are responsible for setting and resetting the rounding modes of the computation on T. For instance, if T is a standard floating point type and floating point computation is performed - according to the Standard IEEE 754, the constructor can save the current + according to the standard IEEE 754, the constructor can save the current rounding state, each _up (resp. _down) function will round up (resp. down), and the destructor will restore the saved rounding state. Indeed this is the behavior of the default rounding @@ -115,7 +115,7 @@

      Requirements

      must round down the value and the second one must round it up.

      The type unprotected_rounding allows to remove all - controls. For reasons why one might to do this, see the protection paragraph below.

      Overview of the provided classes

      @@ -346,7 +346,7 @@

      Transcendental functions

      valid values. For example, cos_down always returns -1. In this way, we do verify the inclusion property for the default implementation, even if this has strictly no value for the user. In order to have useful - values, another policy should be used explicitely, which will most likely + values, another policy should be used explicitly, which will most likely lead to a violation of the inclusion property. In this way, we ensure that the violation is clearly pointed out to the user who then knows what he stands against. This class could have been used as the default @@ -468,7 +468,7 @@

      Speeding up consecutive operations

      sets the floating point environment. This protection is done by the constructor and destructor of the rounding policy.

      -

      Les us now consider the case of two consecutive interval additions: +

      Let us now consider the case of two consecutive interval additions: [a,b] + [c,d] + [e,f]. The generated code should look like:

      @@ -514,10 +514,10 @@ 

      Speeding up consecutive operations

      Example

      -

      Here is an example of Horner's scheme to compute the value of a polynom. +

      Here is an example of Horner's scheme to compute the value of a polynomial. The rounding mode switches are disabled for the whole computation.

      -// I is an interval class, the polynom is a simple array
      +// I is an interval class, the polynomial is a simple array
       template<class I>
       I horner(const I& x, const I p[], int n) {
       
      @@ -564,7 +564,7 @@ 

      Extended Registers

      done with double registers, or double computations with long double registers). Consequently, many problems can arise.

      -

      The first one is due to to the extended precision of the mantissa. The +

      The first one is due to the extended precision of the mantissa. The rounding is also done on this extended precision. And consequently, we still have down(a+b) = -up(-a-b) in the extended registers. But back to the standard precision, we now have From d6aa35b018c2980df759ce7b5fec50b5490c5d48 Mon Sep 17 00:00:00 2001 From: ivanpanch Date: Tue, 29 Jul 2025 00:19:49 +0200 Subject: [PATCH 09/11] Update horner.cpp --- examples/horner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/horner.cpp b/examples/horner.cpp index dfae289..589dcef 100644 --- a/examples/horner.cpp +++ b/examples/horner.cpp @@ -11,7 +11,7 @@ #include #include -// I is an interval class, the polynom is a simple array +// I is an interval class, the polynomial is a simple array template I horner(const I& x, const I p[], int n) { From 652f92732e9c09520c6acd3189461832cd2c19db Mon Sep 17 00:00:00 2001 From: ivanpanch Date: Tue, 29 Jul 2025 00:20:41 +0200 Subject: [PATCH 10/11] Update io.cpp --- examples/io.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/io.cpp b/examples/io.cpp index de4df49..889fa46 100644 --- a/examples/io.cpp +++ b/examples/io.cpp @@ -1,5 +1,5 @@ /* Boost examples/io.cpp - * show some exampleso of i/o operators + * show some examples of i/o operators * thanks to all the people who commented on this point, particularly on * the Boost mailing-list * From 6b7225ba049ced447f9bad91127a840891f11e35 Mon Sep 17 00:00:00 2001 From: ivanpanch Date: Tue, 29 Jul 2025 00:38:14 +0200 Subject: [PATCH 11/11] Update io.hpp --- include/boost/numeric/interval/io.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/numeric/interval/io.hpp b/include/boost/numeric/interval/io.hpp index dc4179e..c91e392 100644 --- a/include/boost/numeric/interval/io.hpp +++ b/include/boost/numeric/interval/io.hpp @@ -4,7 +4,7 @@ * implementation of the output operator. It is * provided for test programs that aren't even * interested in the precision of the results. - * A real progam should define its own operators + * A real program should define its own operators * and never include this header. * * Copyright 2003 Guillaume Melquiond