Tests and Examples

In libs/interval/test/ and libs/interval/examples/ are some test and example 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.

Tests

The test programs are as follows. Please note that they require the use of the Boost.test library and can be automatically tested by using bjam (except for interval_test.cpp).

add.cpp tests if the additive and substractive operators and the respective _std and _opp rounding functions are correctly implemented. It is done by using symbolic expressions as a base type.

cmp.cpp and cmp_lex.cpp test if the operators < > <= >= == != behave correctly for the default comparison and the lexicographic comparison. cmp_exp.cpp tests the explicit comparison functions cer.. and pos.. behave correctly. All these tests use some simple intervals ([1,2] and [3,4], [1,3] and [2,4], [1,2] and [2,3], etc).

det.cpp tests if the _std and _opp versions in protected and unprotected mode produce the same result when Gauss scheme is used on an unstable matrix (in order to exercise rounding). The tests are done for interval<float> and interval<double>.

fmod.cpp defines a minimalistic version of interval<int> and uses it in order to test fmod on some specific interval values.

mul.cpp exercices the multiplication, the finite division, the square and the square root with some integer intervals leading to exact results.

pi.cpp tests if the interval value of π (for int, float and double base types) contains the number π (defined with 21 decimal digits) and if it is a subset of [π±1ulp] (in order to ensure some precision).

pow.cpp tests if the pow function behaves correctly on some simple test cases.

test_float.cpp exercises the arithmetic operations of the library for floating point base types.

interval_test.cpp tests if the interval library respects the inclusion property of interval arithmetic by computing some functions and operations for both double and interval<double>.

Examples

findroot_demo.cpp finds zeros of some functions by using dichotomy and even produces gnuplot datas for one of them. The processor has to correctly handle elementary functions for this example to properly work.

horner.cpp is a really basic example of unprotecting the interval operations for a whole function (which computes the value of a polynomial by using Horner scheme).

newton-raphson.cpp is a (bad) implementation of a specialized version of Newton-Raphson algorithm for finding the zeros of a function knowing its derivative. It exercises unprotecting, full division, some set operations and empty intervals.

interval_speed.cpp is not really an example but more like a benchmark for testing performance of the library. It needs to be compiled with -DUSE_BOOST. The compilation option -DUSE_BOOST_UNPROTECTED allows the program to use unprotected local rounding, leading to better performance.


Revised: 2002-12-15
Copyright (c) Guillaume Melquiond, Sylvain Pion, Hervé Brönnimann, 2002.
Polytechnic University.