diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/numeric/interval | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/numeric/interval')
32 files changed, 3433 insertions, 0 deletions
diff --git a/src/boost/libs/numeric/interval/Jamfile b/src/boost/libs/numeric/interval/Jamfile new file mode 100644 index 00000000..e59673e3 --- /dev/null +++ b/src/boost/libs/numeric/interval/Jamfile @@ -0,0 +1,11 @@ +# Boost.Interval Library Jamfile +# +# Copyright (c) 2018 James E. King III +# +# Use, modification, and distribution are subject to the +# Boost Software License, Version 1.0. (See accompanying file +# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +# please order by name to ease maintenance +build-project examples ; +build-project test ; diff --git a/src/boost/libs/numeric/interval/LICENSE b/src/boost/libs/numeric/interval/LICENSE new file mode 100644 index 00000000..36b7cd93 --- /dev/null +++ b/src/boost/libs/numeric/interval/LICENSE @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/boost/libs/numeric/interval/README.md b/src/boost/libs/numeric/interval/README.md new file mode 100644 index 00000000..d211dfb3 --- /dev/null +++ b/src/boost/libs/numeric/interval/README.md @@ -0,0 +1,34 @@ +Interval, part of the collection of [Boost C++ Libraries](http://github.com/boostorg), is intended to help manipulating mathematical intervals. + +### License + +Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). + +### Properties + +* C++03 +* Header-only + +### Build Status + +Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests | +:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- | +[`master`](https://github.com/boostorg/interval/tree/master) | [![Build Status](https://travis-ci.org/boostorg/interval.svg?branch=master)](https://travis-ci.org/boostorg/interval) | [![Build status](https://ci.appveyor.com/api/projects/status/wx6gsonby36or5m2/branch/master?svg=true)](https://ci.appveyor.com/project/jeking3/interval-o0u28/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/17151/badge.svg)](https://scan.coverity.com/projects/boostorg-interval) | [![codecov](https://codecov.io/gh/boostorg/interval/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/interval/branch/master) | [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/interval.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/interval.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/interval.html) +[`develop`](https://github.com/boostorg/interval/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/interval.svg?branch=develop)](https://travis-ci.org/boostorg/interval) | [![Build status](https://ci.appveyor.com/api/projects/status/wx6gsonby36or5m2/branch/develop?svg=true)](https://ci.appveyor.com/project/jeking3/interval-o0u28/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/17151/badge.svg)](https://scan.coverity.com/projects/boostorg-interval) | [![codecov](https://codecov.io/gh/boostorg/interval/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/interval/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/interval.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/interval.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/interval.html) + +### Directories + +| Name | Purpose | +| ----------- | ------------------------------ | +| `doc` | documentation | +| `examples` | use case examples | +| `include` | headers | +| `test` | unit tests | + +### More inintervalion + +* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-interval): Be sure to read the documentation first as Boost.Interval has specific requirements. +* [Report bugs](https://github.com/boostorg/interval/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well. +* [Submit Pull Requests](https://github.com/boostorg/interval/pulls) against the **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). Be sure to include tests proving your changes work properly. +* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[interval]` tag at the beginning of the subject line. + diff --git a/src/boost/libs/numeric/interval/examples/Jamfile.v2 b/src/boost/libs/numeric/interval/examples/Jamfile.v2 new file mode 100644 index 00000000..b2890b11 --- /dev/null +++ b/src/boost/libs/numeric/interval/examples/Jamfile.v2 @@ -0,0 +1,20 @@ +# Boost.Interval Library example Jamfile +# +# Copyright (c) 2018 James E. King III +# +# Distributed under the Boost Software License, Version 1.0. (See accompany- +# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +import testing ; + +{ + test-suite interval-examples + : [ compile filter.cpp : <build>yes <toolset>msvc-10.0:<build>no ] # ambiguous sin() + [ compile findroot_demo.cpp ] + [ compile horner.cpp ] + [ compile io.cpp ] + [ compile newton-raphson.cpp ] + [ compile rational.cpp ] + # [ compile transc.cpp ] requires gmp3, mpfr + ; +} diff --git a/src/boost/libs/numeric/interval/examples/filter.cpp b/src/boost/libs/numeric/interval/examples/filter.cpp new file mode 100644 index 00000000..a2d8f32e --- /dev/null +++ b/src/boost/libs/numeric/interval/examples/filter.cpp @@ -0,0 +1,209 @@ +/* Boost example/filter.cpp + * two examples of filters for computing the sign of a determinant + * the second filter is based on an idea presented in + * "Interval arithmetic yields efficient dynamic filters for computational + * geometry" by Brönnimann, Burnikel and Pion, 2001 + * + * Copyright 2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <cstring> +#include <iostream> + +namespace dummy { + using namespace boost; + using namespace numeric; + using namespace interval_lib; + typedef save_state<rounded_arith_opp<double> > R; + typedef checking_no_nan<double, checking_no_empty<double> > P; + typedef interval<double, policies<R, P> > I; +} + +template<class T> +class vector { + T* ptr; +public: + vector(int d) { ptr = (T*)malloc(sizeof(T) * d); } + ~vector() { free(ptr); } + const T& operator[](int i) const { return ptr[i]; } + T& operator[](int i) { return ptr[i]; } +}; + +template<class T> +class matrix { + int dim; + T* ptr; +public: + matrix(int d): dim(d) { ptr = (T*)malloc(sizeof(T) * dim * dim); } + ~matrix() { free(ptr); } + int get_dim() const { return dim; } + void assign(const matrix<T> &a) { memcpy(ptr, a.ptr, sizeof(T) * dim * dim); } + const T* operator[](int i) const { return &(ptr[i * dim]); } + T* operator[](int i) { return &(ptr[i * dim]); } +}; + +typedef dummy::I I_dbl; + +/* compute the sign of a determinant using an interval LU-decomposition; the + function answers 1 or -1 if the determinant is positive or negative (and + more importantly, the result must be provable), or 0 if the algorithm was + unable to get a correct sign */ +int det_sign_algo1(const matrix<double> &a) { + int dim = a.get_dim(); + vector<int> p(dim); + for(int i = 0; i < dim; i++) p[i] = i; + int sig = 1; + I_dbl::traits_type::rounding rnd; + typedef boost::numeric::interval_lib::unprotect<I_dbl>::type I; + matrix<I> u(dim); + for(int i = 0; i < dim; i++) { + const double* line1 = a[i]; + I* line2 = u[i]; + for(int j = 0; j < dim; j++) + line2[j] = line1[j]; + } + // computation of L and U + for(int i = 0; i < dim; i++) { + // partial pivoting + { + int pivot = i; + double max = 0; + for(int j = i; j < dim; j++) { + const I &v = u[p[j]][i]; + if (zero_in(v)) continue; + double m = norm(v); + if (m > max) { max = m; pivot = j; } + } + if (max == 0) return 0; + if (pivot != i) { + sig = -sig; + int tmp = p[i]; + p[i] = p[pivot]; + p[pivot] = tmp; + } + } + // U[i,?] + { + I *line1 = u[p[i]]; + const I &pivot = line1[i]; + if (boost::numeric::interval_lib::cerlt(pivot, 0.)) sig = -sig; + for(int k = i + 1; k < dim; k++) { + I *line2 = u[p[k]]; + I fact = line2[i] / pivot; + for(int j = i + 1; j < dim; j++) line2[j] -= fact * line1[j]; + } + } + } + return sig; +} + +/* compute the sign of a determinant using a floating-point LU-decomposition + and an a posteriori interval validation; the meaning of the answer is the + same as previously */ +int det_sign_algo2(const matrix<double> &a) { + int dim = a.get_dim(); + vector<int> p(dim); + for(int i = 0; i < dim; i++) p[i] = i; + int sig = 1; + matrix<double> lui(dim); + { + // computation of L and U + matrix<double> lu(dim); + lu.assign(a); + for(int i = 0; i < dim; i++) { + // partial pivoting + { + int pivot = i; + double max = std::abs(lu[p[i]][i]); + for(int j = i + 1; j < dim; j++) { + double m = std::abs(lu[p[j]][i]); + if (m > max) { max = m; pivot = j; } + } + if (max == 0) return 0; + if (pivot != i) { + sig = -sig; + int tmp = p[i]; + p[i] = p[pivot]; + p[pivot] = tmp; + } + } + // L[?,i] and U[i,?] + { + double *line1 = lu[p[i]]; + double pivot = line1[i]; + if (pivot < 0) sig = -sig; + for(int k = i + 1; k < dim; k++) { + double *line2 = lu[p[k]]; + double fact = line2[i] / pivot; + line2[i] = fact; + for(int j = i + 1; j < dim; j++) line2[j] -= line1[j] * fact; + } + } + } + + // computation of approximate inverses: Li and Ui + for(int j = 0; j < dim; j++) { + for(int i = j + 1; i < dim; i++) { + double *line = lu[p[i]]; + double s = - line[j]; + for(int k = j + 1; k < i; k++) s -= line[k] * lui[k][j]; + lui[i][j] = s; + } + lui[j][j] = 1 / lu[p[j]][j]; + for(int i = j - 1; i >= 0; i--) { + double *line = lu[p[i]]; + double s = 0; + for(int k = i + 1; k <= j; k++) s -= line[k] * lui[k][j]; + lui[i][j] = s / line[i]; + } + } + } + + // norm of PAUiLi-I computed with intervals + { + I_dbl::traits_type::rounding rnd; + typedef boost::numeric::interval_lib::unprotect<I_dbl>::type I; + vector<I> m1(dim); + vector<I> m2(dim); + for(int i = 0; i < dim; i++) { + for(int j = 0; j < dim; j++) m1[j] = 0; + const double *l1 = a[p[i]]; + for(int j = 0; j < dim; j++) { + double v = l1[j]; // PA[i,j] + double *l2 = lui[j]; // Ui[j,?] + for(int k = j; k < dim; k++) { + using boost::numeric::interval_lib::mul; + m1[k] += mul<I>(v, l2[k]); // PAUi[i,k] + } + } + for(int j = 0; j < dim; j++) m2[j] = m1[j]; // PAUi[i,j] * Li[j,j] + for(int j = 1; j < dim; j++) { + const I &v = m1[j]; // PAUi[i,j] + double *l2 = lui[j]; // Li[j,?] + for(int k = 0; k < j; k++) + m2[k] += v * l2[k]; // PAUiLi[i,k] + } + m2[i] -= 1; // PAUiLi-I + double ss = 0; + for(int i = 0; i < dim; i++) ss = rnd.add_up(ss, norm(m2[i])); + if (ss >= 1) return 0; + } + } + return sig; +} + +int main() { + int dim = 20; + matrix<double> m(dim); + for(int i = 0; i < dim; i++) for(int j = 0; j < dim; j++) + m[i][j] = /*1 / (i-j-0.001)*/ cos(1+i*sin(1 + j)) /*1./(1+i+j)*/; + + // compute the sign of the determinant of a "strange" matrix with the two + // algorithms, the first should fail and the second succeed + std::cout << det_sign_algo1(m) << " " << det_sign_algo2(m) << std::endl; +} diff --git a/src/boost/libs/numeric/interval/examples/findroot_demo.cpp b/src/boost/libs/numeric/interval/examples/findroot_demo.cpp new file mode 100644 index 00000000..f5330a70 --- /dev/null +++ b/src/boost/libs/numeric/interval/examples/findroot_demo.cpp @@ -0,0 +1,171 @@ +/* Boost example/findroot_demo.cpp + * find zero points of some function by dichotomy + * + * Copyright 2000 Jens Maurer + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + * + * The idea and the 2D function are based on RVInterval, + * which contains the following copyright notice: + + This file is copyrighted 1996 by Ronald Van Iwaarden. + + Permission is hereby granted, without written agreement and + without license or royalty fees, to use, copy, modify, and + distribute this software and its documentation for any + purpose, subject to the following conditions: + + The above license notice and this permission notice shall + appear in all copies or substantial portions of this software. + + The name "RVInterval" cannot be used for any modified form of + this software that does not originate from the authors. + Nevertheless, the name "RVInterval" may and should be used to + designate the optimization software implemented and described + in this package, even if embedded in any other system, as long + as any portion of this code remains. + + The authors specifically disclaim any warranties, including, + but not limited to, the implied warranties of merchantability + and fitness for a particular purpose. The software provided + hereunder is on an "as is" basis, and the authors have no + obligation to provide maintenance, support, updates, + enhancements, or modifications. In no event shall the authors + be liable to any party for direct, indirect, special, + incidental, or consequential damages arising out of the use of + this software and its documentation. +*/ + +#include <boost/numeric/interval.hpp> // must be first for <limits> workaround +#include <boost/numeric/interval/io.hpp> +#include <list> +#include <deque> +#include <vector> +#include <fstream> +#include <iostream> + + +template<class T> +struct test_func2d +{ + T operator()(T x, T y) const + { + return sin(x)*cos(y) - exp(x*y)/45.0 * (pow(x+y, 2)+100.0) - + cos(sin(y))*y/4.0; + } +}; + +template <class T> +struct test_func1d +{ + T operator()(T x) const + { + return sin(x)/(x*x+1.0); + } +}; + +template<class T> +struct test_func1d_2 +{ + T operator()(T x) const + { + using std::sqrt; + return sqrt(x*x-1.0); + } +}; + +template<class Function, class I> +void find_zeros(std::ostream & os, Function f, I searchrange) +{ + std::list<I> l, done; + l.push_back(searchrange); + while(!l.empty()) { + I range = l.front(); + l.pop_front(); + I val = f(range); + if (zero_in(val)) { + if(width(range) < 1e-6) { + os << range << '\n'; + continue; + } + // there's still a solution hidden somewhere + std::pair<I,I> p = bisect(range); + l.push_back(p.first); + l.push_back(p.second); + } + } +} + +template<class T> +std::ostream &operator<<(std::ostream &os, const std::pair<T, T> &x) { + os << "(" << x.first << ", " << x.second << ")"; + return os; +} + +template<class T, class Policies> +std::ostream &operator<<(std::ostream &os, + const boost::numeric::interval<T, Policies> &x) { + os << "[" << x.lower() << ", " << x.upper() << "]"; + return os; +} + +static const double epsilon = 5e-3; + +template<class Function, class I> +void find_zeros(std::ostream & os, Function f, I rx, I ry) +{ + typedef std::pair<I, I> rectangle; + typedef std::deque<rectangle> container; + container l, done; + // l.reserve(50); + l.push_back(std::make_pair(rx, ry)); + for(int i = 1; !l.empty(); ++i) { + rectangle rect = l.front(); + l.pop_front(); + I val = f(rect.first, rect.second); + if (zero_in(val)) { + if(width(rect.first) < epsilon && width(rect.second) < epsilon) { + os << median(rect.first) << " " << median(rect.second) << " " + << lower(rect.first) << " " << upper(rect.first) << " " + << lower(rect.second) << " " << upper(rect.second) + << '\n'; + } else { + if(width(rect.first) > width(rect.second)) { + std::pair<I,I> p = bisect(rect.first); + l.push_back(std::make_pair(p.first, rect.second)); + l.push_back(std::make_pair(p.second, rect.second)); + } else { + std::pair<I,I> p = bisect(rect.second); + l.push_back(std::make_pair(rect.first, p.first)); + l.push_back(std::make_pair(rect.first, p.second)); + } + } + } + if(i % 10000 == 0) + std::cerr << "\rIteration " << i << ", l.size() = " << l.size(); + } + std::cerr << '\n'; +} + +int main() +{ + using namespace boost; + using namespace numeric; + using namespace interval_lib; + + typedef interval<double, + policies<save_state<rounded_transc_opp<double> >, + checking_base<double> > > I; + + std::cout << "Zero points of sin(x)/(x*x+1)\n"; + find_zeros(std::cout, test_func1d<I>(), I(-11, 10)); + std::cout << "Zero points of sqrt(x*x-1)\n"; + find_zeros(std::cout, test_func1d_2<I>(), I(-5, 6)); + std::cout << "Zero points of Van Iwaarden's 2D function\n"; + std::ofstream f("func2d.data"); + find_zeros(f, test_func2d<I>(), I(-20, 20), I(-20, 20)); + std::cout << "Use gnuplot, command 'plot \"func2d.data\" with dots' to plot\n"; +} diff --git a/src/boost/libs/numeric/interval/examples/horner.cpp b/src/boost/libs/numeric/interval/examples/horner.cpp new file mode 100644 index 00000000..dfae2896 --- /dev/null +++ b/src/boost/libs/numeric/interval/examples/horner.cpp @@ -0,0 +1,47 @@ +/* Boost example/horner.cpp + * example of unprotecting rounding for a whole function computation + * + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <iostream> + +// I is an interval class, the polynom is a simple array +template<class I> +I horner(const I& x, const I p[], int n) { + + // initialize and restore the rounding mode + typename I::traits_type::rounding rnd; + + // define the unprotected version of the interval type + typedef typename boost::numeric::interval_lib::unprotect<I>::type R; + + const R& a = x; + R y = p[n - 1]; + for(int i = n - 2; i >= 0; i--) { + y = y * a + (const R&)(p[i]); + } + return y; + + // restore the rounding mode with the destruction of rnd +} + +template<class T, class Policies> +std::ostream &operator<<(std::ostream &os, + const boost::numeric::interval<T, Policies> &x) { + os << "[" << x.lower() << ", " << x.upper() << "]"; + return os; +} + +int main() { + typedef boost::numeric::interval<double> I; + I p[3] = { -1.0, 0, 1.0 }; + I x = 1.0; + std::cout << horner(x, p, 3) << std::endl; + return 0; +} diff --git a/src/boost/libs/numeric/interval/examples/io.cpp b/src/boost/libs/numeric/interval/examples/io.cpp new file mode 100644 index 00000000..de4df499 --- /dev/null +++ b/src/boost/libs/numeric/interval/examples/io.cpp @@ -0,0 +1,172 @@ +/* Boost examples/io.cpp + * show some exampleso of i/o operators + * thanks to all the people who commented on this point, particularly on + * the Boost mailing-list + * + * Copyright 2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <boost/io/ios_state.hpp> +#include <cmath> +#include <cassert> + +namespace io_std { + +template<class T, class Policies, class CharType, class CharTraits> +std::basic_ostream<CharType, CharTraits> &operator<< + (std::basic_ostream<CharType, CharTraits> &stream, + const boost::numeric::interval<T, Policies> &value) +{ + if (empty(value)) { + return stream << "[]"; + } else { + return stream << '[' << lower(value) << ',' << upper(value) << ']'; + } +} + +} // namespace io_std + +namespace io_sngl { + +template<class T, class Policies, class CharType, class CharTraits> +std::basic_ostream<CharType, CharTraits> &operator<< + (std::basic_ostream<CharType, CharTraits> &stream, + const boost::numeric::interval<T, Policies> &value) +{ + if (empty(value)) { + return stream << "[]"; + } else if (singleton(value)) { + return stream << '[' << lower(value) << ']'; + } else { + return stream << '[' << lower(value) << ',' << upper(value) << ']'; + } +} + +} // namespace io_sngl + +namespace io_wdth { + +template<class T, class Policies, class CharType, class CharTraits> +std::basic_ostream<CharType, CharTraits> &operator<< + (std::basic_ostream<CharType, CharTraits> &stream, + const boost::numeric::interval<T, Policies> &value) +{ + if (empty(value)) { + return stream << "nothing"; + } else { + return stream << median(value) << " ± " << width(value) / 2; + } +} + +} // namespace io_wdth + +namespace io_prec { + +template<class T, class Policies, class CharType, class CharTraits> +std::basic_ostream<CharType, CharTraits> &operator<< + (std::basic_ostream<CharType, CharTraits> &stream, + const boost::numeric::interval<T, Policies> &value) +{ + if (empty(value)) { + return stream << "nothing"; + } else if (singleton(value)) { + boost::io::ios_precision_saver state(stream, std::numeric_limits<T>::digits10); + return stream << lower(value); + } else if (zero_in(value)) { + return stream << "0~"; + } else { + const T rel = width(value) / norm(value); + int range = - (int)std::log10(rel); + boost::io::ios_precision_saver state(stream, range); + return stream << median(value); + } +} + +} // namespace io_prec + +namespace io_wide { + +template<class T, class Policies, class CharType, class CharTraits> +std::basic_ostream<CharType, CharTraits> &operator<< + (std::basic_ostream<CharType, CharTraits> &stream, + const boost::numeric::interval<T, Policies> &value) +{ + if (empty(value)) { + return stream << "nothing"; + } else if (singleton(value)) { + boost::io::ios_precision_saver state(stream, std::numeric_limits<T>::digits10); + return stream << lower(value); + } else if (zero_in(value)) { + return stream << "0~"; + } else { + std::streamsize p = stream.precision(); + // FIXME poor man's power of 10, only up to 1E-15 + p = (p > 15) ? 15 : p - 1; + double eps = 1.0; for(; p > 0; --p) { eps /= 10; } + T eps2 = static_cast<T>(eps / 2) * norm(value); + boost::numeric::interval<T, Policies> r = widen(value, eps2); + return stream << '[' << lower(r) << ',' << upper(r) << ']'; + } +} + +} // namespace io_wide + +template<class T, class Policies, class CharType, class CharTraits> inline +std::basic_istream<CharType, CharTraits> &operator>> + (std::basic_istream<CharType, CharTraits> &stream, + boost::numeric::interval<T, Policies> &value) +{ + T l, u; + char c = 0; + stream >> c; + if (c == '[') { + stream >> l >> c; + if (c == ',') stream >> u >> c; else u = l; + if (c != ']') stream.setstate(stream.failbit); + } else { + stream.putback(c); + stream >> l; + u = l; + } + if (stream) + value.assign(l, u); + else + value = boost::numeric::interval<T, Policies>::empty(); + return stream; +} + +// Test program + +#include <iostream> + +int main() +{ + using namespace boost; + using namespace numeric; + using namespace interval_lib; + + typedef interval<double, + policies<rounded_math<double>, + checking_base<double> > > I; + + I tab[] = { I::empty(), I(1,1), I(1,2), I(-1,1), I(12.34,12.35), + I(1234.56,1234.57), I(123456.78, 123456.79), I::empty() }; + unsigned int len = sizeof(tab) / sizeof(I); + std::cout << "Enter an interval: (it will be the last shown)\n"; + std::cin >> tab[len - 1]; + + for(unsigned int i = 0; i < len; ++i) { + { using namespace io_std; std::cout << tab[i] << '\n'; } + { using namespace io_sngl; std::cout << tab[i] << '\n'; } + { using namespace io_wdth; std::cout << tab[i] << '\n'; } + { using namespace io_prec; std::cout << tab[i] << '\n'; } + { using namespace io_wide; std::cout << tab[i] << '\n'; } + std::cout << '\n'; + } + +} diff --git a/src/boost/libs/numeric/interval/examples/newton-raphson.cpp b/src/boost/libs/numeric/interval/examples/newton-raphson.cpp new file mode 100644 index 00000000..7936c2d4 --- /dev/null +++ b/src/boost/libs/numeric/interval/examples/newton-raphson.cpp @@ -0,0 +1,146 @@ +/* Boost example/newton-raphson.cpp + * Newton iteration for intervals + * + * Copyright 2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <vector> +#include <algorithm> +#include <utility> +#include <iostream> +#include <iomanip> + +template <class I> I f(const I& x) +{ return x * (x - 1.) * (x - 2.) * (x - 3.) * (x - 4.); } +template <class I> I f_diff(const I& x) +{ return (((5. * x - 40.) * x + 105.) * x - 100.) * x + 24.; } + +static const double max_width = 1e-10; +static const double alpha = 0.75; + +using namespace boost; +using namespace numeric; +using namespace interval_lib; + +// First method: no empty intervals + +typedef interval<double> I1_aux; +typedef unprotect<I1_aux>::type I1; + +std::vector<I1> newton_raphson(const I1& xs) { + std::vector<I1> l, res; + I1 vf, vd, x, x1, x2; + l.push_back(xs); + while (!l.empty()) { + x = l.back(); + l.pop_back(); + bool x2_used; + double xx = median(x); + vf = f<I1>(xx); + vd = f_diff<I1>(x); + if (zero_in(vf) && zero_in(vd)) { + x1 = I1::whole(); + x2_used = false; + } else { + x1 = xx - division_part1(vf, vd, x2_used); + if (x2_used) x2 = xx - division_part2(vf, vd); + } + if (overlap(x1, x)) x1 = intersect(x, x1); + else if (x2_used) { x1 = x2; x2_used = false; } + else continue; + if (x2_used) { + if (overlap(x2, x)) x2 = intersect(x, x2); + else x2_used = false; + } + if (x2_used && width(x2) > width(x1)) std::swap(x1, x2); + if (!zero_in(f(x1))) { + if (x2_used) { x1 = x2; x2_used = false; } + else continue; + } + if (width(x1) < max_width) res.push_back(x1); + else if (width(x1) > alpha * width(x)) { + std::pair<I1, I1> p = bisect(x); + if (zero_in(f(p.first))) l.push_back(p.first); + x2 = p.second; + x2_used = true; + } else l.push_back(x1); + if (x2_used && zero_in(f(x2))) { + if (width(x2) < max_width) res.push_back(x2); + else l.push_back(x2); + } + } + return res; +} + +// Second method: with empty intervals + +typedef change_checking<I1_aux, checking_no_nan<double> >::type I2_aux; +typedef unprotect<I2_aux>::type I2; + +std::vector<I2> newton_raphson(const I2& xs) { + std::vector<I2> l, res; + I2 vf, vd, x, x1, x2; + l.push_back(xs); + while (!l.empty()) { + x = l.back(); + l.pop_back(); + double xx = median(x); + vf = f<I2>(xx); + vd = f_diff<I2>(x); + if (zero_in(vf) && zero_in(vd)) { + x1 = x; + x2 = I2::empty(); + } else { + bool x2_used; + x1 = intersect(x, xx - division_part1(vf, vd, x2_used)); + x2 = intersect(x, xx - division_part2(vf, vd, x2_used)); + } + if (width(x2) > width(x1)) std::swap(x1, x2); + if (empty(x1) || !zero_in(f(x1))) { + if (!empty(x2)) { x1 = x2; x2 = I2::empty(); } + else continue; + } + if (width(x1) < max_width) res.push_back(x1); + else if (width(x1) > alpha * width(x)) { + std::pair<I2, I2> p = bisect(x); + if (zero_in(f(p.first))) l.push_back(p.first); + x2 = p.second; + } else l.push_back(x1); + if (!empty(x2) && zero_in(f(x2))) { + if (width(x2) < max_width) res.push_back(x2); + else l.push_back(x2); + } + } + return res; +} + +template<class T, class Policies> +std::ostream &operator<<(std::ostream &os, + const boost::numeric::interval<T, Policies> &x) { + os << "[" << x.lower() << ", " << x.upper() << "]"; + return os; +} + +int main() { + { + I1_aux::traits_type::rounding rnd; + std::vector<I1> res = newton_raphson(I1(-1, 5.1)); + std::cout << "Results: " << std::endl << std::setprecision(12); + for(std::vector<I1>::const_iterator i = res.begin(); i != res.end(); ++i) + std::cout << " " << *i << std::endl; + std::cout << std::endl; + } + { + I2_aux::traits_type::rounding rnd; + std::vector<I2> res = newton_raphson(I2(-1, 5.1)); + std::cout << "Results: " << std::endl << std::setprecision(12); + for(std::vector<I2>::const_iterator i = res.begin(); i != res.end(); ++i) + std::cout << " " << *i << std::endl; + std::cout << std::endl; + } +} diff --git a/src/boost/libs/numeric/interval/examples/rational.cpp b/src/boost/libs/numeric/interval/examples/rational.cpp new file mode 100644 index 00000000..937171df --- /dev/null +++ b/src/boost/libs/numeric/interval/examples/rational.cpp @@ -0,0 +1,43 @@ +/* Boost example/rational.cpp + * example program of how to use interval< rational<> > + * + * Copyright 2002-2003 Guillaume Melquiond, Sylvain Pion + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// it would have been enough to only include: +// <boost/numeric/interval.hpp> +// but it's a bit overkill to include processor intrinsics +// and transcendental functions, so we do it by ourselves + +#include <boost/numeric/interval/interval.hpp> // base class +#include <boost/numeric/interval/rounded_arith.hpp> // default arithmetic rounding policy +#include <boost/numeric/interval/checking.hpp> // default checking policy +#include <boost/numeric/interval/arith.hpp> // += *= -= etc +#include <boost/numeric/interval/policies.hpp> // default policy + +#include <boost/rational.hpp> +#include <iostream> + +typedef boost::rational<int> Rat; +typedef boost::numeric::interval<Rat> Interval; + +std::ostream& operator<<(std::ostream& os, const Interval& r) { + os << "[" << r.lower() << "," << r.upper() << "]"; + return os; +} + +int main() { + Rat p(2, 3), q(3, 4); + Interval z(4, 5); + Interval a(p, q); + a += z; + z *= q; + a -= p; + a /= q; + std::cout << z << std::endl; + std::cout << a << std::endl; +} diff --git a/src/boost/libs/numeric/interval/examples/transc.cpp b/src/boost/libs/numeric/interval/examples/transc.cpp new file mode 100644 index 00000000..2036f983 --- /dev/null +++ b/src/boost/libs/numeric/interval/examples/transc.cpp @@ -0,0 +1,90 @@ +/* Boost example/transc.cpp + * how to use an external library (GMP/MPFR in this case) in order to + * get correct transcendental functions on intervals + * + * Copyright 2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +//extern "C" { +#include <gmp.h> +#include <mpfr.h> +//} +#include <iostream> + +struct full_rounding: + boost::numeric::interval_lib::rounded_arith_opp<double> +{ +private: + typedef int mpfr_func(mpfr_t, const __mpfr_struct*, mp_rnd_t); + double invoke_mpfr(double x, mpfr_func f, mp_rnd_t r) { + mpfr_t xx; + mpfr_init_set_d(xx, x, GMP_RNDN); + f(xx, xx, r); + double res = mpfr_get_d(xx, r); + mpfr_clear(xx); + return res; + } +public: +# define GENR_FUNC(name) \ + double name##_down(double x) { return invoke_mpfr(x, mpfr_##name, GMP_RNDD); } \ + double name##_up (double x) { return invoke_mpfr(x, mpfr_##name, GMP_RNDU); } + GENR_FUNC(exp) + GENR_FUNC(log) + GENR_FUNC(sin) + GENR_FUNC(cos) + GENR_FUNC(tan) + GENR_FUNC(asin) + GENR_FUNC(acos) + GENR_FUNC(atan) + GENR_FUNC(sinh) + GENR_FUNC(cosh) + GENR_FUNC(tanh) + GENR_FUNC(asinh) + GENR_FUNC(acosh) + GENR_FUNC(atanh) +}; + +namespace dummy { + using namespace boost; + using namespace numeric; + using namespace interval_lib; + typedef save_state<full_rounding> R; + typedef checking_strict<double> P; + typedef interval<double, policies<R, P> > I; +}; + +typedef dummy::I I; + +template<class os_t> +os_t& operator<<(os_t &os, const I &a) { + os << '[' << a.lower() << ',' << a.upper() << ']'; + return os; +} + +int main() { + I x(0.5, 2.5); + std::cout << "x = " << x << std::endl; + std::cout.precision(16); +# define GENR_TEST(name) \ + std::cout << #name "(x) = " << name(x) << std::endl + GENR_TEST(exp); + GENR_TEST(log); + GENR_TEST(sin); + GENR_TEST(cos); + GENR_TEST(tan); + GENR_TEST(asin); + GENR_TEST(acos); + GENR_TEST(atan); + GENR_TEST(sinh); + GENR_TEST(cosh); + GENR_TEST(tanh); + GENR_TEST(asinh); + GENR_TEST(acosh); + GENR_TEST(atanh); + return 0; +} diff --git a/src/boost/libs/numeric/interval/index.html b/src/boost/libs/numeric/interval/index.html new file mode 100644 index 00000000..30dbacea --- /dev/null +++ b/src/boost/libs/numeric/interval/index.html @@ -0,0 +1,13 @@ +<html> +<head> +<meta http-equiv="refresh" content="0; URL=doc/interval.htm"> +</head> +<body> +Automatic redirection failed, please go to +<a href="doc/interval.htm">doc/interval.htm</a>. <hr> +<p>© Copyright Beman Dawes, 2001</p> +<p>Distributed under the Boost Software License, Version 1.0. (See accompanying +file <a href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy +at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p> +</body> +</html> diff --git a/src/boost/libs/numeric/interval/meta/libraries.json b/src/boost/libs/numeric/interval/meta/libraries.json new file mode 100644 index 00000000..d3fa6cfc --- /dev/null +++ b/src/boost/libs/numeric/interval/meta/libraries.json @@ -0,0 +1,19 @@ +{ + "key": "numeric/interval", + "name": "Interval", + "authors": [ + "Guillaume Melquiond", + "Hervé Brönnimann", + "Sylvain Pion" + ], + "description": "Extends the usual arithmetic functions to mathematical intervals.", + "documentation": "doc/interval.htm", + "category": [ + "Math" + ], + "maintainers": [ + "Sylvain Pion <Sylvain.Pion -at- sophia.inria.fr>", + "Herve Bronnimann <hbr -at- poly.edu>", + "Guillaume Melquiond <guillaume.melquiond -at- ens-lyon.fr>" + ] +} diff --git a/src/boost/libs/numeric/interval/test/Jamfile.v2 b/src/boost/libs/numeric/interval/test/Jamfile.v2 new file mode 100644 index 00000000..0afd0edb --- /dev/null +++ b/src/boost/libs/numeric/interval/test/Jamfile.v2 @@ -0,0 +1,55 @@ +# Boost Interval Library test Jamfile +# +# Copyright 2003 Guillaume Melquiond +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or +# copy at http://www.boost.org/LICENSE_1_0.txt) + +project + : + source-location $(BOOST_ROOT) + : + requirements + # Enable dynamic rounding on Tru64 (Alpha CPU). + <toolset>hp_cxx,<os>OSF:<cflags>"-fprm d" + <toolset>gcc,<os>OSF:<cflags>-mfp-rounding-mode=d + <toolset>gcc:<cxxflags>-frounding-math + <toolset>msvc:<cxxflags>/fp\:strict + ; + +# bring in rules for testing +import testing ; + +{ + test-suite numeric/interval : + [ compile libs/numeric/interval/test/integer.cpp ] + + [ run libs/numeric/interval/test/add.cpp ] + [ run libs/numeric/interval/test/det.cpp ] + [ run libs/numeric/interval/test/fmod.cpp ] + [ run libs/numeric/interval/test/msvc_x64_flags.cpp : : : <build>no <toolset>msvc:<build>yes ] + [ run libs/numeric/interval/test/mul.cpp ] + [ run libs/numeric/interval/test/overflow.cpp ] + [ run libs/numeric/interval/test/pi.cpp ] + [ run libs/numeric/interval/test/pow.cpp ] + + [ run libs/numeric/interval/test/cmp.cpp + ../../../test/build//boost_test_exec_monitor/<link>static ] + [ run libs/numeric/interval/test/cmp_exn.cpp + ../../../test/build//boost_test_exec_monitor/<link>static ] + [ run libs/numeric/interval/test/cmp_exp.cpp + ../../../test/build//boost_test_exec_monitor/<link>static ] + [ run libs/numeric/interval/test/cmp_lex.cpp + ../../../test/build//boost_test_exec_monitor/<link>static ] + [ run libs/numeric/interval/test/cmp_set.cpp + ../../../test/build//boost_test_exec_monitor/<link>static ] + # https://github.com/boostorg/interval/issues/15 + # [ run libs/numeric/interval/test/cmp_tribool.cpp + # ../../../test/build//boost_test_exec_monitor/<link>static ] + [ run libs/numeric/interval/test/test_float.cpp + ../../../test/build//boost_test_exec_monitor/<link>static + : : : <build>yes <toolset>msvc-10.0:<build>no ] + # https://github.com/boostorg/interval/issues/17 + ; +} diff --git a/src/boost/libs/numeric/interval/test/add.cpp b/src/boost/libs/numeric/interval/test/add.cpp new file mode 100644 index 00000000..73d502b6 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/add.cpp @@ -0,0 +1,243 @@ +/* Boost test/add.cpp + * test with symbolic operations if the addition algorithm is correct + * + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval/interval.hpp> +#include <boost/numeric/interval/arith.hpp> +#include <boost/numeric/interval/rounding.hpp> +#include <boost/numeric/interval/rounded_arith.hpp> +#include <boost/numeric/interval/utility.hpp> +#include <boost/numeric/interval/policies.hpp> +#include <boost/test/minimal.hpp> +#include "bugs.hpp" + +typedef enum { EXPR_VAR, EXPR_NEG, EXPR_UP, EXPR_DOWN, EXPR_ADD, EXPR_SUB } e_type; + +struct expr; +struct pexpr { + expr *ptr; + expr* operator->() { return ptr; } + pexpr(expr *p = NULL): ptr(p) { } +}; + +struct expr { + e_type type; + int var; + pexpr e; + pexpr e1, e2; +}; + +pexpr var(int v) { + pexpr e = new expr; + e->type = EXPR_VAR; + e->var = v; + return e; +} + +pexpr operator+(pexpr, pexpr); +pexpr operator-(pexpr, pexpr); +pexpr operator-(pexpr); + +pexpr operator+(pexpr a, pexpr b) { + if (a->type == EXPR_NEG) return b - a->e; + if (b->type == EXPR_NEG) return a - b->e; + if (a->type == EXPR_VAR && b->type == EXPR_VAR && a->var > b->var) return b + a; + pexpr c = new expr; + c->type = EXPR_ADD; + c->e1 = a; + c->e2 = b; + return c; +} + +pexpr operator-(pexpr a, pexpr b) { + if (b->type == EXPR_NEG) return a + b->e; + pexpr c = new expr; + c->type = EXPR_SUB; + c->e1 = a; + c->e2 = b; + return c; +} + +pexpr down(pexpr a) { + pexpr e = new expr; + e->type = EXPR_DOWN; + e->e = a; + return e; +} + +pexpr up(pexpr a) { + pexpr e = new expr; + e->type = EXPR_UP; + e->e = a; + return e; +} + +pexpr operator-(pexpr a) { + if (a->type == EXPR_NEG) return a->e; + if (a->type == EXPR_UP) return down(-a->e); + if (a->type == EXPR_DOWN) return up(-a->e); + if (a->type == EXPR_SUB) return a->e2 - a->e1; + if (a->type == EXPR_ADD) return -a->e1 - a->e2; + pexpr e = new expr; + e->type = EXPR_NEG; + e->e = a; + return e; +} + +bool operator==(pexpr a, pexpr b) { + if (a->type != b->type) return false; + if (a->type == EXPR_VAR) return a->var == b->var; + if (a->type == EXPR_DOWN || a->type == EXPR_UP || a->type == EXPR_NEG) + return a->e == b->e; + return a->e1 == b->e1 && a->e2 == b->e2; +} + +bool operator<=(pexpr, pexpr) { return true; } + +namespace boost { +namespace numeric { +namespace interval_lib { + +template<> +struct rounding_control<pexpr> { + typedef enum { RND_U, RND_M, RND_D } rounding_mode; + static rounding_mode mode; + rounding_control() { mode = RND_M; } + void get_rounding_mode(rounding_mode& m) { m = mode; } + void set_rounding_mode(rounding_mode m) { mode = m; } + void upward() { mode = RND_U; } + void downward() { mode = RND_D; } + pexpr force_rounding(pexpr a) { + switch (mode) { + case RND_U: return up(a); + case RND_D: return down(a); + default: throw "Unset rounding mode"; + } + } +}; + +rounding_control<pexpr>::rounding_mode rounding_control<pexpr>::mode = RND_M; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +template<class I> +bool test_neg() { + I a(var(0), var(1)); + return equal(-a, I(-var(1), -var(0))); +} + +template<class I> +bool test_add() { + I a(var(0), var(1)), b(var(2), var(3)); + return equal(a + b, I(down(var(0) + var(2)), up(var(1) + var(3)))); +} + +template<class I> +bool test_add1() { + I a(var(0), var(1)); + return equal(a + var(2), I(down(var(0) + var(2)), up(var(1) + var(2)))); +} + +template<class I> +bool test_add2() { + I a(var(0), var(1)); + return equal(var(2) + a, I(down(var(0) + var(2)), up(var(1) + var(2)))); +} + +template<class I> +bool test_sub() { + I a(var(0), var(1)), b(var(2), var(3)); + return equal(a - b, I(down(var(0) - var(3)), up(var(1) - var(2)))); +} + +template<class I> +bool test_sub1() { + I a(var(0), var(1)); + return equal(a - var(2), I(down(var(0) - var(2)), up(var(1) - var(2)))); +} + +template<class I> +bool test_sub2() { + I a(var(0), var(1)); + return equal(var(2) - a, I(down(var(2) - var(1)), up(var(2) - var(0)))); +} + +template<class I> +bool test_addeq() { + I a(var(0), var(1)), b(var(2), var(3)); + return equal(a += b, I(down(var(0) + var(2)), up(var(1) + var(3)))); +} + +template<class I> +bool test_addeq1() { + I a(var(0), var(1)); + return equal(a += var(2), I(down(var(0) + var(2)), up(var(1) + var(2)))); +} + +template<class I> +bool test_subeq() { + I a(var(0), var(1)), b(var(2), var(3)); + return equal(a -= b, I(down(var(0) - var(3)), up(var(1) - var(2)))); +} + +template<class I> +bool test_subeq1() { + I a(var(0), var(1)); + return equal(a -= var(2), I(down(var(0) - var(2)), up(var(1) - var(2)))); +} + +struct my_checking +{ + static pexpr pos_inf() { throw; } + static pexpr neg_inf() { throw; } + static pexpr nan() { throw; } + static bool is_nan(const pexpr&) { return false; } + static pexpr empty_lower() { throw; } + static pexpr empty_upper() { throw; } + static bool is_empty(const pexpr&, const pexpr&) { return false; } +}; + +template<class Rounding> +struct my_interval { +private: + typedef boost::numeric::interval_lib::save_state<Rounding> my_rounding; + typedef boost::numeric::interval_lib::policies<my_rounding, my_checking> my_policies; +public: + typedef boost::numeric::interval<pexpr, my_policies> type; +}; + +int test_main(int, char *[]) { + typedef my_interval<boost::numeric::interval_lib::rounded_arith_std<pexpr> >::type I1; + typedef my_interval<boost::numeric::interval_lib::rounded_arith_opp<pexpr> >::type I2; + BOOST_CHECK((test_neg<I1>())); + BOOST_CHECK((test_neg<I2>())); + BOOST_CHECK((test_add<I1>())); + BOOST_CHECK((test_add<I2>())); + BOOST_CHECK((test_add1<I1>())); + BOOST_CHECK((test_add1<I2>())); + BOOST_CHECK((test_add2<I1>())); + BOOST_CHECK((test_add2<I2>())); + BOOST_CHECK((test_sub<I1>())); + BOOST_CHECK((test_sub<I2>())); + BOOST_CHECK((test_sub1<I1>())); + BOOST_CHECK((test_sub1<I2>())); + BOOST_CHECK((test_sub2<I1>())); + BOOST_CHECK((test_sub2<I2>())); + BOOST_CHECK((test_addeq<I1>())); + BOOST_CHECK((test_addeq<I2>())); + BOOST_CHECK((test_addeq1<I1>())); + BOOST_CHECK((test_addeq1<I2>())); + BOOST_CHECK((test_subeq<I1>())); + BOOST_CHECK((test_subeq<I2>())); + BOOST_CHECK((test_subeq1<I1>())); + BOOST_CHECK((test_subeq1<I2>())); + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/bugs.hpp b/src/boost/libs/numeric/interval/test/bugs.hpp new file mode 100644 index 00000000..52a99560 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/bugs.hpp @@ -0,0 +1,43 @@ +/* Boost test/bugs.hpp + * Handles namespace resolution quirks in older compilers and braindead + * warnings [Herve, June 3rd 2003] + * + * Copyright 2002-2003 Hervé Brönnimann + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/config.hpp> + +// Borland compiler complains about unused variables a bit easily and +// incorrectly + +#ifdef __BORLANDC__ +namespace detail { + + template <class T> inline void ignore_unused_variable_warning(const T&) { } + + inline void ignore_warnings() { +# ifdef BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP + using namespace boost::numeric::interval_lib::constants; + ignore_unused_variable_warning( pi_f_l ); + ignore_unused_variable_warning( pi_f_u ); + ignore_unused_variable_warning( pi_d_l ); + ignore_unused_variable_warning( pi_d_u ); +# endif + } + +} +#endif + +// Some compilers are broken with respect to name resolution + +#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) || defined( __BORLANDC__) + +using namespace boost; +using namespace numeric; +using namespace interval_lib; + +#endif diff --git a/src/boost/libs/numeric/interval/test/cmp.cpp b/src/boost/libs/numeric/interval/test/cmp.cpp new file mode 100644 index 00000000..e3a12a3c --- /dev/null +++ b/src/boost/libs/numeric/interval/test/cmp.cpp @@ -0,0 +1,215 @@ +/* Boost test/cmp.cpp + * test standard comparison functions + * + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "cmp_header.hpp" + +// comparisons between [1,2] and [3,4] + +static void test_12_34() { + const I a(1,2), b(3,4); + + BOOST_CHECK(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(b > a); + BOOST_CHECK(b >= a); + BOOST_CHECK(!(b < a)); + BOOST_CHECK(!(b <= a)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,3] and [2,4] + +static void test_13_24() { + const I a(1,3), b(2,4); + + BOOST_C_EXN(a < b); + BOOST_C_EXN(a <= b); + BOOST_C_EXN(a > b); + BOOST_C_EXN(a >= b); + + BOOST_C_EXN(b < a); + BOOST_C_EXN(b <= a); + BOOST_C_EXN(b > a); + BOOST_C_EXN(b >= a); + + BOOST_C_EXN(a == b); + BOOST_C_EXN(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and [2,3] + +static void test_12_23() { + const I a(1,2), b(2,3); + + BOOST_C_EXN(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_C_EXN(a >= b); + + BOOST_CHECK(!(b < a)); + BOOST_C_EXN(b <= a); + BOOST_C_EXN(b > a); + BOOST_CHECK(b >= a); + + BOOST_C_EXN(a == b); + BOOST_C_EXN(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 0 + +static void test_12_0() { + const I a(1,2); + const int b = 0; + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(!(a <= b)); + BOOST_CHECK(a > b); + BOOST_CHECK(a >= b); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 1 + +static void test_12_1() { + const I a(1,2); + const int b = 1; + + BOOST_CHECK(!(a < b)); + BOOST_C_EXN(a <= b); + BOOST_C_EXN(a > b); + BOOST_CHECK(a >= b); + + BOOST_C_EXN(a == b); + BOOST_C_EXN(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 2 + +static void test_12_2() { + const I a(1,2); + const int b = 2; + + BOOST_C_EXN(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_C_EXN(a >= b); + + BOOST_C_EXN(a == b); + BOOST_C_EXN(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 3 + +static void test_12_3() { + const I a(1,2); + const int b = 3; + + BOOST_CHECK(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and [1,2] + +static void test_12_12() { + const I a(1,2), b(1,2); + BOOST_C_EXN(a == b); + BOOST_C_EXN(a != b); +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,1] and [1,1] + +static void test_11_11() { + const I a(1,1), b(1,1); + BOOST_CHECK(a == b); + BOOST_CHECK(!(a != b)); +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,1] and 1 + +static void test_11_1() { + const I a(1,1); + const int b = 1; + BOOST_CHECK(a == b); + BOOST_CHECK(!(a != b)); +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +int test_main(int, char *[]) { + test_12_34(); + test_13_24(); + test_12_23(); + test_12_0(); + test_12_1(); + test_12_2(); + test_12_3(); + test_12_12(); + test_11_11(); + test_11_1(); + + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/cmp_exn.cpp b/src/boost/libs/numeric/interval/test/cmp_exn.cpp new file mode 100644 index 00000000..7f6cc030 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/cmp_exn.cpp @@ -0,0 +1,230 @@ +/* Boost test/cmp_exn.cpp + * test policies with respect to exception throwing + * + * Copyright 2004 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval/interval.hpp> +#include <boost/numeric/interval/checking.hpp> +#include <boost/numeric/interval/compare.hpp> +#include <boost/numeric/interval/policies.hpp> +#include <boost/numeric/interval/compare/tribool.hpp> +#include <boost/test/test_tools.hpp> + +struct my_checking +{ + static int nan() { return -1; } + static bool is_nan(int x) { return x < 0; } + static int empty_lower() { return -1; } + static int empty_upper() { return -1; } + static bool is_empty(int l, int u) { return l == -1 && u == -1; } +}; + +struct empty_class {}; + +typedef boost::numeric::interval_lib::policies< empty_class, my_checking > + my_policies; + +typedef boost::numeric::interval<int, my_policies> I; + +#define BOOST_C_EXN(e) \ + BOOST_CHECK_THROW(e, boost::numeric::interval_lib::comparison_error) + +static void test_cer() +{ + I const a(I::empty()), b(1,2); + int const c = 0, d = my_checking::nan(); + using namespace boost::numeric::interval_lib::compare::certain; + + BOOST_C_EXN(a < b); + BOOST_C_EXN(a <= b); + BOOST_C_EXN(a > b); + BOOST_C_EXN(a >= b); + BOOST_C_EXN(a == b); + BOOST_C_EXN(a != b); + BOOST_C_EXN(b < a); + BOOST_C_EXN(b <= a); + BOOST_C_EXN(b > a); + BOOST_C_EXN(b >= a); + BOOST_C_EXN(b == a); + BOOST_C_EXN(b != a); + + BOOST_C_EXN(a < c); + BOOST_C_EXN(a <= c); + BOOST_C_EXN(a > c); + BOOST_C_EXN(a >= c); + BOOST_C_EXN(a == c); + BOOST_C_EXN(a != c); + BOOST_C_EXN(b < d); + BOOST_C_EXN(b <= d); + BOOST_C_EXN(b > d); + BOOST_C_EXN(b >= d); + BOOST_C_EXN(b == d); + BOOST_C_EXN(b != d); +} + +static void test_def() +{ + I const a(I::empty()), b(1,2); + int const c = 0, d = my_checking::nan(); + + BOOST_C_EXN(a < b); + BOOST_C_EXN(a <= b); + BOOST_C_EXN(a > b); + BOOST_C_EXN(a >= b); + BOOST_C_EXN(a == b); + BOOST_C_EXN(a != b); + BOOST_C_EXN(b < a); + BOOST_C_EXN(b <= a); + BOOST_C_EXN(b > a); + BOOST_C_EXN(b >= a); + BOOST_C_EXN(b == a); + BOOST_C_EXN(b != a); + + BOOST_C_EXN(a < c); + BOOST_C_EXN(a <= c); + BOOST_C_EXN(a > c); + BOOST_C_EXN(a >= c); + BOOST_C_EXN(a == c); + BOOST_C_EXN(a != c); + BOOST_C_EXN(b < d); + BOOST_C_EXN(b <= d); + BOOST_C_EXN(b > d); + BOOST_C_EXN(b >= d); + BOOST_C_EXN(b == d); + BOOST_C_EXN(b != d); +} + +static void test_lex() +{ + I const a(I::empty()), b(1,2); + int const c = 0, d = my_checking::nan(); + using namespace boost::numeric::interval_lib::compare::lexicographic; + + BOOST_C_EXN(a < b); + BOOST_C_EXN(a <= b); + BOOST_C_EXN(a > b); + BOOST_C_EXN(a >= b); + BOOST_C_EXN(a == b); + BOOST_C_EXN(a != b); + BOOST_C_EXN(b < a); + BOOST_C_EXN(b <= a); + BOOST_C_EXN(b > a); + BOOST_C_EXN(b >= a); + BOOST_C_EXN(b == a); + BOOST_C_EXN(b != a); + + BOOST_C_EXN(a < c); + BOOST_C_EXN(a <= c); + BOOST_C_EXN(a > c); + BOOST_C_EXN(a >= c); + BOOST_C_EXN(a == c); + BOOST_C_EXN(a != c); + BOOST_C_EXN(b < d); + BOOST_C_EXN(b <= d); + BOOST_C_EXN(b > d); + BOOST_C_EXN(b >= d); + BOOST_C_EXN(b == d); + BOOST_C_EXN(b != d); +} + +static void test_pos() +{ + I const a(I::empty()), b(1,2); + int const c = 0, d = my_checking::nan(); + using namespace boost::numeric::interval_lib::compare::possible; + + BOOST_C_EXN(a < b); + BOOST_C_EXN(a <= b); + BOOST_C_EXN(a > b); + BOOST_C_EXN(a >= b); + BOOST_C_EXN(a == b); + BOOST_C_EXN(a != b); + BOOST_C_EXN(b < a); + BOOST_C_EXN(b <= a); + BOOST_C_EXN(b > a); + BOOST_C_EXN(b >= a); + BOOST_C_EXN(b == a); + BOOST_C_EXN(b != a); + + BOOST_C_EXN(a < c); + BOOST_C_EXN(a <= c); + BOOST_C_EXN(a > c); + BOOST_C_EXN(a >= c); + BOOST_C_EXN(a == c); + BOOST_C_EXN(a != c); + BOOST_C_EXN(b < d); + BOOST_C_EXN(b <= d); + BOOST_C_EXN(b > d); + BOOST_C_EXN(b >= d); + BOOST_C_EXN(b == d); + BOOST_C_EXN(b != d); +} + +static void test_set() +{ + I const a(I::empty()), b(1,2); + int const c = 0; + using namespace boost::numeric::interval_lib::compare::set; + + BOOST_C_EXN(a < c); + BOOST_C_EXN(a <= c); + BOOST_C_EXN(a > c); + BOOST_C_EXN(a >= c); + BOOST_C_EXN(a == c); + BOOST_C_EXN(a != c); + BOOST_C_EXN(b < c); + BOOST_C_EXN(b <= c); + BOOST_C_EXN(b > c); + BOOST_C_EXN(b >= c); + BOOST_C_EXN(b == c); + BOOST_C_EXN(b != c); +} + +static void test_tri() +{ + I const a(I::empty()), b(1,2); + int const c = 0, d = my_checking::nan(); + using namespace boost::numeric::interval_lib::compare::tribool; + + BOOST_C_EXN(a < b); + BOOST_C_EXN(a <= b); + BOOST_C_EXN(a > b); + BOOST_C_EXN(a >= b); + BOOST_C_EXN(a == b); + BOOST_C_EXN(a != b); + BOOST_C_EXN(b < a); + BOOST_C_EXN(b <= a); + BOOST_C_EXN(b > a); + BOOST_C_EXN(b >= a); + BOOST_C_EXN(b == a); + BOOST_C_EXN(b != a); + + BOOST_C_EXN(a < c); + BOOST_C_EXN(a <= c); + BOOST_C_EXN(a > c); + BOOST_C_EXN(a >= c); + BOOST_C_EXN(a == c); + BOOST_C_EXN(a != c); + BOOST_C_EXN(b < d); + BOOST_C_EXN(b <= d); + BOOST_C_EXN(b > d); + BOOST_C_EXN(b >= d); + BOOST_C_EXN(b == d); + BOOST_C_EXN(b != d); +} + +int test_main(int, char *[]) { + test_cer(); + test_def(); + test_lex(); + test_pos(); + test_set(); + test_tri(); + + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/cmp_exp.cpp b/src/boost/libs/numeric/interval/test/cmp_exp.cpp new file mode 100644 index 00000000..bebd13af --- /dev/null +++ b/src/boost/libs/numeric/interval/test/cmp_exp.cpp @@ -0,0 +1,366 @@ +/* Boost test/cmp_exp.cpp + * test explicit comparison functions + * + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "cmp_header.hpp" + +// comparisons between [1,2] and [3,4] + +static void test_12_34() { + const I a(1,2), b(3,4); + + BOOST_CHECK(cerlt(a, b)); + BOOST_CHECK(cerle(a, b)); + BOOST_CHECK(!cergt(a, b)); + BOOST_CHECK(!cerge(a, b)); + + BOOST_CHECK(!cerlt(b, a)); + BOOST_CHECK(!cerle(b, a)); + BOOST_CHECK(cergt(b, a)); + BOOST_CHECK(cerge(b, a)); + + BOOST_CHECK(poslt(a, b)); + BOOST_CHECK(posle(a, b)); + BOOST_CHECK(!posgt(a, b)); + BOOST_CHECK(!posge(a, b)); + + BOOST_CHECK(!poslt(b, a)); + BOOST_CHECK(!posle(b, a)); + BOOST_CHECK(posgt(b, a)); + BOOST_CHECK(posge(b, a)); + + BOOST_CHECK(!cereq(a, b)); + BOOST_CHECK(cerne(a, b)); + BOOST_CHECK(!poseq(a, b)); + BOOST_CHECK(posne(a, b)); + + BOOST_CHECK(!cereq(b, a)); + BOOST_CHECK(cerne(b, a)); + BOOST_CHECK(!poseq(b, a)); + BOOST_CHECK(posne(b, a)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,3] and [2,4] + +static void test_13_24() { + const I a(1,3), b(2,4); + + BOOST_CHECK(!cerlt(a, b)); + BOOST_CHECK(!cerle(a, b)); + BOOST_CHECK(!cergt(a, b)); + BOOST_CHECK(!cerge(a, b)); + + BOOST_CHECK(!cerlt(b, a)); + BOOST_CHECK(!cerle(b, a)); + BOOST_CHECK(!cergt(b, a)); + BOOST_CHECK(!cerge(b, a)); + + BOOST_CHECK(poslt(a, b)); + BOOST_CHECK(posle(a, b)); + BOOST_CHECK(posgt(a, b)); + BOOST_CHECK(posge(a, b)); + + BOOST_CHECK(poslt(b, a)); + BOOST_CHECK(posle(b, a)); + BOOST_CHECK(posgt(b, a)); + BOOST_CHECK(posge(b, a)); + + BOOST_CHECK(!cereq(a, b)); + BOOST_CHECK(!cerne(a, b)); + BOOST_CHECK(poseq(a, b)); + BOOST_CHECK(posne(a, b)); + + BOOST_CHECK(!cereq(b, a)); + BOOST_CHECK(!cerne(b, a)); + BOOST_CHECK(poseq(b, a)); + BOOST_CHECK(posne(b, a)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and [2,3] + +static void test_12_23() { + const I a(1,2), b(2,3); + + BOOST_CHECK(!cerlt(a, b)); + BOOST_CHECK(cerle(a, b)); + BOOST_CHECK(!cergt(a, b)); + BOOST_CHECK(!cerge(a, b)); + + BOOST_CHECK(!cerlt(b, a)); + BOOST_CHECK(!cerle(b, a)); + BOOST_CHECK(!cergt(b, a)); + BOOST_CHECK(cerge(b, a)); + + BOOST_CHECK(poslt(a, b)); + BOOST_CHECK(posle(a, b)); + BOOST_CHECK(!posgt(a, b)); + BOOST_CHECK(posge(a, b)); + + BOOST_CHECK(!poslt(b, a)); + BOOST_CHECK(posle(b, a)); + BOOST_CHECK(posgt(b, a)); + BOOST_CHECK(posge(b, a)); + + BOOST_CHECK(!cereq(a, b)); + BOOST_CHECK(!cerne(a, b)); + BOOST_CHECK(poseq(a, b)); + BOOST_CHECK(posne(a, b)); + + BOOST_CHECK(!cereq(b, a)); + BOOST_CHECK(!cerne(b, a)); + BOOST_CHECK(poseq(b, a)); + BOOST_CHECK(posne(b, a)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 0 + +static void test_12_0() { + const I a(1,2); + const int b = 0; + + BOOST_CHECK(!cerlt(a, b)); + BOOST_CHECK(!cerle(a, b)); + BOOST_CHECK(cergt(a, b)); + BOOST_CHECK(cerge(a, b)); + + BOOST_CHECK(cerlt(b, a)); + BOOST_CHECK(cerle(b, a)); + BOOST_CHECK(!cergt(b, a)); + BOOST_CHECK(!cerge(b, a)); + + BOOST_CHECK(!poslt(a, b)); + BOOST_CHECK(!posle(a, b)); + BOOST_CHECK(posgt(a, b)); + BOOST_CHECK(posge(a, b)); + + BOOST_CHECK(poslt(b, a)); + BOOST_CHECK(posle(b, a)); + BOOST_CHECK(!posgt(b, a)); + BOOST_CHECK(!posge(b, a)); + + BOOST_CHECK(!cereq(a, b)); + BOOST_CHECK(cerne(a, b)); + BOOST_CHECK(!poseq(a, b)); + BOOST_CHECK(posne(a, b)); + + BOOST_CHECK(!cereq(b, a)); + BOOST_CHECK(cerne(b, a)); + BOOST_CHECK(!poseq(b, a)); + BOOST_CHECK(posne(b, a)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 1 + +static void test_12_1() { + const I a(1,2); + const int b = 1; + + BOOST_CHECK(!cerlt(a, b)); + BOOST_CHECK(!cerle(a, b)); + BOOST_CHECK(!cergt(a, b)); + BOOST_CHECK(cerge(a, b)); + + BOOST_CHECK(!cerlt(b, a)); + BOOST_CHECK(cerle(b, a)); + BOOST_CHECK(!cergt(b, a)); + BOOST_CHECK(!cerge(b, a)); + + BOOST_CHECK(!poslt(a, b)); + BOOST_CHECK(posle(a, b)); + BOOST_CHECK(posgt(a, b)); + BOOST_CHECK(posge(a, b)); + + BOOST_CHECK(poslt(b, a)); + BOOST_CHECK(posle(b, a)); + BOOST_CHECK(!posgt(b, a)); + BOOST_CHECK(posge(b, a)); + + BOOST_CHECK(!cereq(a, b)); + BOOST_CHECK(!cerne(a, b)); + BOOST_CHECK(poseq(a, b)); + BOOST_CHECK(posne(a, b)); + + BOOST_CHECK(!cereq(b, a)); + BOOST_CHECK(!cerne(b, a)); + BOOST_CHECK(poseq(b, a)); + BOOST_CHECK(posne(b, a)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 2 + +static void test_12_2() { + const I a(1,2); + const int b = 2; + + BOOST_CHECK(!cerlt(a, b)); + BOOST_CHECK(cerle(a, b)); + BOOST_CHECK(!cergt(a, b)); + BOOST_CHECK(!cerge(a, b)); + + BOOST_CHECK(!cerlt(b, a)); + BOOST_CHECK(!cerle(b, a)); + BOOST_CHECK(!cergt(b, a)); + BOOST_CHECK(cerge(b, a)); + + BOOST_CHECK(poslt(a, b)); + BOOST_CHECK(posle(a, b)); + BOOST_CHECK(!posgt(a, b)); + BOOST_CHECK(posge(a, b)); + + BOOST_CHECK(!poslt(b, a)); + BOOST_CHECK(posle(b, a)); + BOOST_CHECK(posgt(b, a)); + BOOST_CHECK(posge(b, a)); + + BOOST_CHECK(!cereq(a, b)); + BOOST_CHECK(!cerne(a, b)); + BOOST_CHECK(poseq(a, b)); + BOOST_CHECK(posne(a, b)); + + BOOST_CHECK(!cereq(b, a)); + BOOST_CHECK(!cerne(b, a)); + BOOST_CHECK(poseq(b, a)); + BOOST_CHECK(posne(b, a)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 3 + +static void test_12_3() { + const I a(1,2); + const int b = 3; + + BOOST_CHECK(cerlt(a, b)); + BOOST_CHECK(cerle(a, b)); + BOOST_CHECK(!cergt(a, b)); + BOOST_CHECK(!cerge(a, b)); + + BOOST_CHECK(!cerlt(b, a)); + BOOST_CHECK(!cerle(b, a)); + BOOST_CHECK(cergt(b, a)); + BOOST_CHECK(cerge(b, a)); + + BOOST_CHECK(poslt(a, b)); + BOOST_CHECK(posle(a, b)); + BOOST_CHECK(!posgt(a, b)); + BOOST_CHECK(!posge(a, b)); + + BOOST_CHECK(!poslt(b, a)); + BOOST_CHECK(!posle(b, a)); + BOOST_CHECK(posgt(b, a)); + BOOST_CHECK(posge(b, a)); + + BOOST_CHECK(!cereq(a, b)); + BOOST_CHECK(cerne(a, b)); + BOOST_CHECK(!poseq(a, b)); + BOOST_CHECK(posne(a, b)); + + BOOST_CHECK(!cereq(b, a)); + BOOST_CHECK(cerne(b, a)); + BOOST_CHECK(!poseq(b, a)); + BOOST_CHECK(posne(b, a)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +static void test_12_12() { + const I a(1,2), b(1,2); + BOOST_CHECK(!cereq(a, b)); + BOOST_CHECK(!cerne(a, b)); + BOOST_CHECK(poseq(a, b)); + BOOST_CHECK(posne(a, b)); + BOOST_CHECK(!cereq(b, a)); + BOOST_CHECK(!cerne(b, a)); + BOOST_CHECK(poseq(b, a)); + BOOST_CHECK(posne(b, a)); +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +static void test_11_11() { + const I a(1,1), b(1,1); + BOOST_CHECK(cereq(a, b)); + BOOST_CHECK(!cerne(a, b)); + BOOST_CHECK(poseq(a, b)); + BOOST_CHECK(!posne(a, b)); + BOOST_CHECK(cereq(b, a)); + BOOST_CHECK(!cerne(b, a)); + BOOST_CHECK(poseq(b, a)); + BOOST_CHECK(!posne(b, a)); +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +static void test_11_1() { + const I a(1,1); + const int b = 1; + BOOST_CHECK(cereq(a, b)); + BOOST_CHECK(!cerne(a, b)); + BOOST_CHECK(poseq(a, b)); + BOOST_CHECK(!posne(a, b)); + BOOST_CHECK(cereq(b, a)); + BOOST_CHECK(!cerne(b, a)); + BOOST_CHECK(poseq(b, a)); + BOOST_CHECK(!posne(b, a)); +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +int test_main(int, char *[]) { + test_12_34(); + test_13_24(); + test_12_23(); + test_12_0(); + test_12_1(); + test_12_2(); + test_12_3(); + test_12_12(); + test_11_11(); + test_11_1(); + + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/cmp_header.hpp b/src/boost/libs/numeric/interval/test/cmp_header.hpp new file mode 100644 index 00000000..ef4c209a --- /dev/null +++ b/src/boost/libs/numeric/interval/test/cmp_header.hpp @@ -0,0 +1,26 @@ +/* Boost test/cmp_header.hpp header file + * + * Copyright 2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval/interval.hpp> +#include <boost/numeric/interval/checking.hpp> +#include <boost/numeric/interval/compare.hpp> +#include <boost/numeric/interval/policies.hpp> +#include <boost/test/test_tools.hpp> +#include "bugs.hpp" + +struct empty_class {}; + +typedef boost::numeric::interval_lib::policies + <empty_class, boost::numeric::interval_lib::checking_base<int> > + my_policies; + +typedef boost::numeric::interval<int, my_policies> I; + +#define BOOST_C_EXN(e) \ + BOOST_CHECK_THROW(e, boost::numeric::interval_lib::comparison_error) diff --git a/src/boost/libs/numeric/interval/test/cmp_lex.cpp b/src/boost/libs/numeric/interval/test/cmp_lex.cpp new file mode 100644 index 00000000..6ae0bcb9 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/cmp_lex.cpp @@ -0,0 +1,217 @@ +/* Boost test/cmp_lex.cpp + * test compare::lexicographic + * + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "cmp_header.hpp" + +using namespace boost::numeric::interval_lib::compare::lexicographic; + +// comparisons between [1,2] and [3,4] + +static void test_12_34() { + const I a(1,2), b(3,4); + + BOOST_CHECK(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(b > a); + BOOST_CHECK(b >= a); + BOOST_CHECK(!(b < a)); + BOOST_CHECK(!(b <= a)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,3] and [2,4] + +static void test_13_24() { + const I a(1,3), b(2,4); + + BOOST_CHECK(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(!(b < a)); + BOOST_CHECK(!(b <= a)); + BOOST_CHECK(b > a); + BOOST_CHECK(b >= a); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and [2,3] + +static void test_12_23() { + const I a(1,2), b(2,3); + + BOOST_CHECK(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(!(b < a)); + BOOST_CHECK(!(b <= a)); + BOOST_CHECK(b > a); + BOOST_CHECK(b >= a); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 0 + +static void test_12_0() { + const I a(1,2); + const int b = 0; + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(!(a <= b)); + BOOST_CHECK(a > b); + BOOST_CHECK(a >= b); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 1 + +static void test_12_1() { + const I a(1,2); + const int b = 1; + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(!(a <= b)); + BOOST_CHECK(a > b); + BOOST_CHECK(a >= b); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 2 + +static void test_12_2() { + const I a(1,2); + const int b = 2; + + BOOST_CHECK(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 3 + +static void test_12_3() { + const I a(1,2); + const int b = 3; + + BOOST_CHECK(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +static void test_12_12() { + const I a(1,2), b(1,2); + + BOOST_CHECK(a == b); + BOOST_CHECK(!(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +static void test_11_11() { + const I a(1,1), b(1,1); + + BOOST_CHECK(a == b); + BOOST_CHECK(!(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +static void test_11_1() { + const I a(1,1); + const int b = 1; + + BOOST_CHECK(a == b); + BOOST_CHECK(!(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +int test_main(int, char *[]) { + test_12_34(); + test_13_24(); + test_12_23(); + test_12_0(); + test_12_1(); + test_12_2(); + test_12_3(); + test_12_12(); + test_11_11(); + test_11_1(); + + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/cmp_set.cpp b/src/boost/libs/numeric/interval/test/cmp_set.cpp new file mode 100644 index 00000000..55c44740 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/cmp_set.cpp @@ -0,0 +1,218 @@ +/* Boost test/cmp_set.cpp + * test compare::set + * + * Copyright 2004 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "cmp_header.hpp" + +using namespace boost::numeric::interval_lib::compare::set; + +// comparisons between [1,2] and [3,4] + +static void test_12_34() { + const I a(1,2), b(3,4); + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(!(a <= b)); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(!(b > a)); + BOOST_CHECK(!(b >= a)); + BOOST_CHECK(!(b < a)); + BOOST_CHECK(!(b <= a)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,3] and [2,4] + +static void test_13_24() { + const I a(1,3), b(2,4); + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(!(a <= b)); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(!(b < a)); + BOOST_CHECK(!(b <= a)); + BOOST_CHECK(!(b > a)); + BOOST_CHECK(!(b >= a)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,4] and [2,3] + +static void test_14_23() { + const I a(1,4), b(2,3); + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(!(a <= b)); + BOOST_CHECK(a > b); + BOOST_CHECK(a >= b); + + BOOST_CHECK(b < a); + BOOST_CHECK(b <= a); + BOOST_CHECK(!(b > a)); + BOOST_CHECK(!(b >= a)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and [2,3] + +static void test_12_23() { + const I a(1,2), b(2,3); + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(!(a <= b)); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(!(b < a)); + BOOST_CHECK(!(b <= a)); + BOOST_CHECK(!(b > a)); + BOOST_CHECK(!(b >= a)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and empty set + +static void test_12_E() { + I a(1, 2), b(I::empty()); + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(!(a <= b)); + BOOST_CHECK(a > b); + BOOST_CHECK(a >= b); + + BOOST_CHECK(b < a); + BOOST_CHECK(b <= a); + BOOST_CHECK(!(b > a)); + BOOST_CHECK(!(b >= a)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between two empty sets + +static void test_E_E() { + I a(I::empty()), b(I::empty()); + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(a >= b); + + BOOST_CHECK(!(b < a)); + BOOST_CHECK(b <= a); + BOOST_CHECK(!(b > a)); + BOOST_CHECK(b >= a); + + BOOST_CHECK(a == b); + BOOST_CHECK(!(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and [1,2] + +static void test_12_12() { + const I a(1,2), b(1,2); + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(a >= b); + + BOOST_CHECK(!(b < a)); + BOOST_CHECK(b <= a); + BOOST_CHECK(!(b > a)); + BOOST_CHECK(b >= a); + + BOOST_CHECK(a == b); + BOOST_CHECK(!(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,1] and [1,1] + +static void test_11_11() { + const I a(1,1), b(1,1); + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(a >= b); + + BOOST_CHECK(!(b < a)); + BOOST_CHECK(b <= a); + BOOST_CHECK(!(b > a)); + BOOST_CHECK(b >= a); + + BOOST_CHECK(a == b); + BOOST_CHECK(!(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +int test_main(int, char *[]) { + test_12_34(); + test_13_24(); + test_14_23(); + test_12_23(); + test_12_E(); + test_E_E(); + test_12_12(); + test_11_11(); + + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/cmp_tribool.cpp b/src/boost/libs/numeric/interval/test/cmp_tribool.cpp new file mode 100644 index 00000000..9b2f5a48 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/cmp_tribool.cpp @@ -0,0 +1,224 @@ +/* Boost test/cmp_tribool.cpp + * test compare::tribool + * + * Copyright 2004 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "cmp_header.hpp" +#include <boost/numeric/interval/compare/tribool.hpp> + +using namespace boost::numeric::interval_lib::compare::tribool; + +// comparisons between [1,2] and [3,4] + +static void test_12_34() { + const I a(1,2), b(3,4); + + BOOST_CHECK(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(b > a); + BOOST_CHECK(b >= a); + BOOST_CHECK(!(b < a)); + BOOST_CHECK(!(b <= a)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,3] and [2,4] + +static void test_13_24() { + const I a(1,3), b(2,4); + + BOOST_CHECK(indeterminate(a < b)); + BOOST_CHECK(indeterminate(a <= b)); + BOOST_CHECK(indeterminate(a > b)); + BOOST_CHECK(indeterminate(a >= b)); + + BOOST_CHECK(indeterminate(b < a)); + BOOST_CHECK(indeterminate(b <= a)); + BOOST_CHECK(indeterminate(b > a)); + BOOST_CHECK(indeterminate(b >= a)); + + BOOST_CHECK(indeterminate(a == b)); + BOOST_CHECK(indeterminate(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and [2,3] + +static void test_12_23() { + const I a(1,2), b(2,3); + + BOOST_CHECK(indeterminate(a < b)); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(indeterminate(a >= b)); + + BOOST_CHECK(!(b < a)); + BOOST_CHECK(indeterminate(b <= a)); + BOOST_CHECK(indeterminate(b > a)); + BOOST_CHECK(b >= a); + + BOOST_CHECK(indeterminate(a == b)); + BOOST_CHECK(indeterminate(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 0 + +static void test_12_0() { + const I a(1,2); + const int b = 0; + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(!(a <= b)); + BOOST_CHECK(a > b); + BOOST_CHECK(a >= b); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 1 + +static void test_12_1() { + const I a(1,2); + const int b = 1; + + BOOST_CHECK(!(a < b)); + BOOST_CHECK(indeterminate(a <= b)); + BOOST_CHECK(indeterminate(a > b)); + BOOST_CHECK(a >= b); + + BOOST_CHECK(indeterminate(a == b)); + BOOST_CHECK(indeterminate(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 2 + +static void test_12_2() { + const I a(1,2); + const int b = 2; + + BOOST_CHECK(indeterminate(a < b)); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(indeterminate(a >= b)); + + BOOST_CHECK(indeterminate(a == b)); + BOOST_CHECK(indeterminate(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and 3 + +static void test_12_3() { + const I a(1,2); + const int b = 3; + + BOOST_CHECK(a < b); + BOOST_CHECK(a <= b); + BOOST_CHECK(!(a > b)); + BOOST_CHECK(!(a >= b)); + + BOOST_CHECK(!(a == b)); + BOOST_CHECK(a != b); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,2] and [1,2] + +static void test_12_12() { + const I a(1,2), b(1,2); + + BOOST_CHECK(indeterminate(a == b)); + BOOST_CHECK(indeterminate(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,1] and [1,1] + +static void test_11_11() { + const I a(1,1), b(1,1); + + BOOST_CHECK(a == b); + BOOST_CHECK(!(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +// comparisons between [1,1] and 1 + +static void test_11_1() { + const I a(1,1); + const int b = 1; + + BOOST_CHECK(a == b); + BOOST_CHECK(!(a != b)); + +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(a); + ::detail::ignore_unused_variable_warning(b); +# endif +} + +int test_main(int, char *[]) { + test_12_34(); + test_13_24(); + test_12_23(); + test_12_0(); + test_12_1(); + test_12_2(); + test_12_3(); + test_12_12(); + test_11_11(); + test_11_1(); + + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/det.cpp b/src/boost/libs/numeric/interval/test/det.cpp new file mode 100644 index 00000000..cc401adc --- /dev/null +++ b/src/boost/libs/numeric/interval/test/det.cpp @@ -0,0 +1,103 @@ +/* Boost test/det.cpp + * test protected and unprotected rounding on an unstable determinant + * + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <boost/test/minimal.hpp> +#include "bugs.hpp" + +#define size 8 + +template<class I> +void det(I (&mat)[size][size]) { + for(int i = 0; i < size; i++) + for(int j = 0; j < size; j++) + mat[i][j] = I(1) / I(i + j + 1); + + for(int i = 0; i < size - 1; i++) { + int m = i, n = i; + typename I::base_type v = 0; + for(int a = i; a < size; a++) + for(int b = i; b < size; b++) { + typename I::base_type w = abs(mat[a][b]).lower(); + if (w > v) { m = a; n = b; v = w; } + } + if (n != i) + for(int a = 0; a < size; a++) { + I t = mat[a][n]; + mat[a][n] = mat[a][i]; + mat[a][i] = t; + } + if (m != i) + for(int b = i; b < size; b++) { + I t = mat[m][b]; + mat[m][b] = mat[m][i]; + mat[m][i] = t; + } + if (((m + n) & 1) == 1) { }; + I c = mat[i][i]; + for(int j = i + 1; j < size; j++) { + I f = mat[j][i] / c; + for(int k = i; k < size; k++) + mat[j][k] -= f * mat[i][k]; + } + if (zero_in(c)) return; + } +} + +namespace my_namespace { + +using namespace boost; +using namespace numeric; +using namespace interval_lib; + +template<class T> +struct variants { + typedef interval<T> I_op; + typedef typename change_rounding<I_op, save_state<rounded_arith_std<T> > >::type I_sp; + typedef typename unprotect<I_op>::type I_ou; + typedef typename unprotect<I_sp>::type I_su; + typedef T type; +}; + +} + +template<class T> +bool test() { + typedef my_namespace::variants<double> types; + types::I_op mat_op[size][size]; + types::I_sp mat_sp[size][size]; + types::I_ou mat_ou[size][size]; + types::I_su mat_su[size][size]; + det(mat_op); + det(mat_sp); + { types::I_op::traits_type::rounding rnd; det(mat_ou); } + { types::I_sp::traits_type::rounding rnd; det(mat_su); } + for(int i = 0; i < size; i++) + for(int j = 0; j < size; j++) { + typedef types::I_op I; + I d_op = mat_op[i][j]; + I d_sp = mat_sp[i][j]; + I d_ou = mat_ou[i][j]; + I d_su = mat_su[i][j]; + if (!(equal(d_op, d_sp) && equal(d_sp, d_ou) && equal(d_ou, d_su))) + return false; + } + return true; +} + +int test_main(int, char *[]) { + BOOST_CHECK(test<float>()); + BOOST_CHECK(test<double>()); + BOOST_CHECK(test<long double>()); +# ifdef __BORLANDC__ + ::detail::ignore_warnings(); +# endif + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/fmod.cpp b/src/boost/libs/numeric/interval/test/fmod.cpp new file mode 100644 index 00000000..230dcd2f --- /dev/null +++ b/src/boost/libs/numeric/interval/test/fmod.cpp @@ -0,0 +1,53 @@ +/* Boost test/fmod.cpp + * test the fmod with specially crafted integer intervals + * + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval/interval.hpp> +#include <boost/numeric/interval/arith.hpp> +#include <boost/numeric/interval/arith2.hpp> +#include <boost/numeric/interval/utility.hpp> +#include <boost/numeric/interval/checking.hpp> +#include <boost/numeric/interval/rounding.hpp> +#include <boost/test/minimal.hpp> +#include "bugs.hpp" + +struct my_rounded_arith { + int sub_down(int x, int y) { return x - y; } + int sub_up (int x, int y) { return x - y; } + int mul_down(int x, int y) { return x * y; } + int mul_up (int x, int y) { return x * y; } + int div_down(int x, int y) { + int q = x / y; + return (x % y < 0) ? (q - 1) : q; + } + int int_down(int x) { return x; } +}; + +using namespace boost; +using namespace numeric; +using namespace interval_lib; + +typedef change_rounding<interval<int>, save_state_nothing<my_rounded_arith> >::type I; + +int test_main(int, char *[]) { + + BOOST_CHECK(equal(fmod(I(6,9), 7), I(6,9))); + BOOST_CHECK(equal(fmod(6, I(7,8)), I(6,6))); + BOOST_CHECK(equal(fmod(I(6,9), I(7,8)), I(6,9))); + + BOOST_CHECK(equal(fmod(I(13,17), 7), I(6,10))); + BOOST_CHECK(equal(fmod(13, I(7,8)), I(5,6))); + BOOST_CHECK(equal(fmod(I(13,17), I(7,8)), I(5,10))); + + BOOST_CHECK(equal(fmod(I(-17,-13), 7), I(4,8))); + BOOST_CHECK(equal(fmod(-17, I(7,8)), I(4,7))); + BOOST_CHECK(equal(fmod(I(-17,-13), I(7,8)), I(4,11))); + + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/integer.cpp b/src/boost/libs/numeric/interval/test/integer.cpp new file mode 100644 index 00000000..3e78d8be --- /dev/null +++ b/src/boost/libs/numeric/interval/test/integer.cpp @@ -0,0 +1,24 @@ +/* Boost test/integer.cpp + * test int extension + * + * Copyright 2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <boost/numeric/interval/ext/integer.hpp> +#include "bugs.hpp" + +typedef boost::numeric::interval<float> I; + +int main() { + I x, y; + x = 4 - (2 * y + 1) / 3; +# ifdef __BORLANDC__ + ::detail::ignore_warnings(); +# endif + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/msvc_x64_flags.cpp b/src/boost/libs/numeric/interval/test/msvc_x64_flags.cpp new file mode 100644 index 00000000..a79d2bb0 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/msvc_x64_flags.cpp @@ -0,0 +1,21 @@ +/* Boost test/msvc_x64_flags.cpp + * Test for amd64\ieee.c(102) : Assertion failed: (mask&~(_MCW_DN|_MCW_EM|_MCW_RC))==0. + * This happens with MSVC on x64 in Debug mode. See ticket #4964. + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <boost/test/minimal.hpp> +#include "bugs.hpp" + +int test_main(int, char *[]) { + boost::numeric::interval<double> i(0.0, 0.0); + boost::numeric::interval<double> i2 = 60.0 - i; +# ifdef __BORLANDC__ + ::detail::ignore_warnings(); +# endif + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/mul.cpp b/src/boost/libs/numeric/interval/test/mul.cpp new file mode 100644 index 00000000..118acf32 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/mul.cpp @@ -0,0 +1,124 @@ +/* Boost test/mul.cpp + * test multiplication, division, square and square root on some intervals + * + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <boost/test/minimal.hpp> +#include "bugs.hpp" + +typedef boost::numeric::interval<double> I; + +static double min BOOST_PREVENT_MACRO_SUBSTITUTION (double a, double b, double c, double d) { + return (std::min)((std::min)(a, b), (std::min)(c, d)); +} + +static double max BOOST_PREVENT_MACRO_SUBSTITUTION (double a, double b, double c, double d) { + return (std::max)((std::max)(a, b), (std::max)(c, d)); +} + +static bool test_mul(double al, double au, double bl, double bu) { + I a(al, au), b(bl, bu); + I c = a * b; + return c.lower() == (min)(al*bl, al*bu, au*bl, au*bu) + && c.upper() == (max)(al*bl, al*bu, au*bl, au*bu); +} + +static bool test_mul1(double ac, double bl, double bu) { + I a(ac), b(bl, bu); + I c = ac * b; + I d = b * ac; + I e = a * b; + return equal(c, d) && equal(d, e); +} + +static bool test_div(double al, double au, double bl, double bu) { + I a(al, au), b(bl, bu); + I c = a / b; + return c.lower() == (min)(al/bl, al/bu, au/bl, au/bu) + && c.upper() == (max)(al/bl, al/bu, au/bl, au/bu); +} + +static bool test_div1(double al, double au, double bc) { + I a(al, au), b(bc); + I c = a / bc; + I d = a / b; + return equal(c, d); +} + +static bool test_div2(double ac, double bl, double bu) { + I a(ac), b(bl, bu); + I c = ac / b; + I d = a / b; + return equal(c, d); +} + +static bool test_square(double al, double au) { + I a(al, au); + I b = square(a); + I c = a * a; + return b.upper() == c.upper() && + (b.lower() == c.lower() || (c.lower() <= 0 && b.lower() == 0)); +} + +static bool test_sqrt(double al, double au) { + I a(al, au); + I b = square(sqrt(a)); + return subset(abs(a), b); +} + +int test_main(int, char*[]) { + BOOST_CHECK(test_mul(2, 3, 5, 7)); + BOOST_CHECK(test_mul(2, 3, -5, 7)); + BOOST_CHECK(test_mul(2, 3, -7, -5)); + BOOST_CHECK(test_mul(-2, 3, 5, 7)); + BOOST_CHECK(test_mul(-2, 3, -5, 7)); + BOOST_CHECK(test_mul(-2, 3, -7, -5)); + BOOST_CHECK(test_mul(-3, -2, 5, 7)); + BOOST_CHECK(test_mul(-3, -2, -5, 7)); + BOOST_CHECK(test_mul(-3, -2, -7, -5)); + + BOOST_CHECK(test_mul1(3, 5, 7)); + BOOST_CHECK(test_mul1(3, -5, 7)); + BOOST_CHECK(test_mul1(3, -7, -5)); + BOOST_CHECK(test_mul1(-3, 5, 7)); + BOOST_CHECK(test_mul1(-3, -5, 7)); + BOOST_CHECK(test_mul1(-3, -7, -5)); + + BOOST_CHECK(test_div(30, 42, 2, 3)); + BOOST_CHECK(test_div(30, 42, -3, -2)); + BOOST_CHECK(test_div(-30, 42, 2, 3)); + BOOST_CHECK(test_div(-30, 42, -3, -2)); + BOOST_CHECK(test_div(-42, -30, 2, 3)); + BOOST_CHECK(test_div(-42, -30, -3, -2)); + + BOOST_CHECK(test_div1(30, 42, 3)); + BOOST_CHECK(test_div1(30, 42, -3)); + BOOST_CHECK(test_div1(-30, 42, 3)); + BOOST_CHECK(test_div1(-30, 42, -3)); + BOOST_CHECK(test_div1(-42, -30, 3)); + BOOST_CHECK(test_div1(-42, -30, -3)); + + BOOST_CHECK(test_div2(30, 2, 3)); + BOOST_CHECK(test_div2(30, -3, -2)); + BOOST_CHECK(test_div2(-30, 2, 3)); + BOOST_CHECK(test_div2(-30, -3, -2)); + + BOOST_CHECK(test_square(2, 3)); + BOOST_CHECK(test_square(-2, 3)); + BOOST_CHECK(test_square(-3, 2)); + + BOOST_CHECK(test_sqrt(2, 3)); + BOOST_CHECK(test_sqrt(5, 7)); + BOOST_CHECK(test_sqrt(-1, 2)); + +# ifdef __BORLANDC__ + ::detail::ignore_warnings(); +# endif + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/overflow.cpp b/src/boost/libs/numeric/interval/test/overflow.cpp new file mode 100644 index 00000000..c15fc917 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/overflow.cpp @@ -0,0 +1,44 @@ +/* Boost test/overflow.cpp + * test if extended precision exponent does not disturb interval computation + * + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <boost/test/minimal.hpp> +#include "bugs.hpp" + +template<class I> +void test_one(typename I::base_type x, typename I::base_type f) { + I y = x; + typename I::base_type g = 1 / f; + const int nb = 10000; + for(int i = 0; i < nb; i++) y *= f; + for(int i = 0; i < nb; i++) y *= g; + BOOST_CHECK(in(x, y)); +# ifdef __BORLANDC__ + ::detail::ignore_unused_variable_warning(nb); +# endif +} + +template<class I> +void test() { + test_one<I>(1., 25.); + test_one<I>(1., 0.04); + test_one<I>(-1., 25.); + test_one<I>(-1., 0.04); +} + +int test_main(int, char *[]) { + test<boost::numeric::interval<float> >(); + test<boost::numeric::interval<double> >(); + //test<boost::numeric::interval<long double> >(); +# ifdef __BORLANDC__ + ::detail::ignore_warnings(); +# endif + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/pi.cpp b/src/boost/libs/numeric/interval/test/pi.cpp new file mode 100644 index 00000000..38adec99 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/pi.cpp @@ -0,0 +1,59 @@ +/* Boost test/pi.cpp + * test if the pi constant is correctly defined + * + * Copyright 2002-2003 Guillaume Melquiond, Sylvain Pion + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <boost/limits.hpp> +#include <boost/test/minimal.hpp> +#include "bugs.hpp" + +#define PI 3.14159265358979323846 + +typedef boost::numeric::interval<int> I_i; +typedef boost::numeric::interval<float> I_f; +typedef boost::numeric::interval<double> I_d; +typedef boost::numeric::interval<long double> I_ld; + +using boost::numeric::interval_lib::pi; +using boost::numeric::interval_lib::pi_half; +using boost::numeric::interval_lib::pi_twice; + +int test_main(int, char *[]) { + I_i pi_i = pi<I_i>(); + I_f pi_f = pi<I_f>(); + I_d pi_d = pi<I_d>(); + I_ld pi_ld = pi<I_ld>(); + + BOOST_CHECK(in((int) PI, pi_i)); + BOOST_CHECK(in((float) PI, pi_f)); + BOOST_CHECK(in((double)PI, pi_d)); + BOOST_CHECK(subset(pi_i, widen(I_i((int) PI), 1))); + BOOST_CHECK(subset(pi_f, widen(I_f((float) PI), (std::numeric_limits<float> ::min)()))); + BOOST_CHECK(subset(pi_d, widen(I_d((double)PI), (std::numeric_limits<double>::min)()))); + + // We can't test the following equalities for interval<int>. + I_f pi_f_half = pi_half<I_f>(); + I_f pi_f_twice = pi_twice<I_f>(); + + I_d pi_d_half = pi_half<I_d>(); + I_d pi_d_twice = pi_twice<I_d>(); + + I_ld pi_ld_half = pi_half<I_ld>(); + I_ld pi_ld_twice = pi_twice<I_ld>(); + + BOOST_CHECK(equal(2.0f * pi_f_half, pi_f)); + BOOST_CHECK(equal(2.0 * pi_d_half, pi_d)); + BOOST_CHECK(equal(2.0l * pi_ld_half, pi_ld)); + + BOOST_CHECK(equal(2.0f * pi_f, pi_f_twice)); + BOOST_CHECK(equal(2.0 * pi_d, pi_d_twice)); + BOOST_CHECK(equal(2.0l * pi_ld, pi_ld_twice)); + + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/pow.cpp b/src/boost/libs/numeric/interval/test/pow.cpp new file mode 100644 index 00000000..ef5b268b --- /dev/null +++ b/src/boost/libs/numeric/interval/test/pow.cpp @@ -0,0 +1,42 @@ +/* Boost test/pow.cpp + * test the pow function + * + * Copyright 2002-2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <boost/test/minimal.hpp> +#include "bugs.hpp" + +bool test_pow(double al, double au, double bl, double bu, int p) { + typedef boost::numeric::interval<double> I; + I b = pow(I(al, au), p); + return b.lower() == bl && b.upper() == bu; +} + +int test_main(int, char *[]) { + BOOST_CHECK(test_pow(2, 3, 8, 27, 3)); + BOOST_CHECK(test_pow(2, 3, 16, 81, 4)); + BOOST_CHECK(test_pow(-3, 2, -27, 8, 3)); + BOOST_CHECK(test_pow(-3, 2, 0, 81, 4)); + BOOST_CHECK(test_pow(-3, -2, -27, -8, 3)); + BOOST_CHECK(test_pow(-3, -2, 16, 81, 4)); + + BOOST_CHECK(test_pow(2, 4, 1./64, 1./8, -3)); + BOOST_CHECK(test_pow(2, 4, 1./256, 1./16, -4)); + BOOST_CHECK(test_pow(-4, -2, -1./8, -1./64, -3)); + BOOST_CHECK(test_pow(-4, -2, 1./256, 1./16, -4)); + + BOOST_CHECK(test_pow(2, 3, 1, 1, 0)); + BOOST_CHECK(test_pow(-3, 2, 1, 1, 0)); + BOOST_CHECK(test_pow(-3, -2, 1, 1, 0)); + +# ifdef __BORLANDC__ + ::detail::ignore_warnings(); +# endif + return 0; +} diff --git a/src/boost/libs/numeric/interval/test/test_float.cpp b/src/boost/libs/numeric/interval/test/test_float.cpp new file mode 100644 index 00000000..8f478a79 --- /dev/null +++ b/src/boost/libs/numeric/interval/test/test_float.cpp @@ -0,0 +1,128 @@ +/* Boost test/test_float.cpp + * test arithmetic operations on a range of intervals + * + * Copyright 2003 Guillaume Melquiond + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <boost/numeric/interval.hpp> +#include <boost/test/test_tools.hpp> +#include <boost/config.hpp> +#include "bugs.hpp" + +/* All the following tests should be BOOST_CHECK; however, if a test fails, + the probability is high that hundreds of other tests will fail, so it is + replaced by BOOST_REQUIRE to avoid flooding the logs. */ + +template<class T, class F> +void test_unary() { + typedef typename F::I I; + for(I a(-10., -9.91); a.lower() <= 10.; a += 0.3) { + if (!F::validate(a)) continue; + I rI = F::f_I(a); + T rT1 = F::f_T(a.lower()), rT2 = F::f_T(a.upper()), + rT3 = F::f_T(median(a)); + BOOST_REQUIRE(in(rT1, rI)); + BOOST_REQUIRE(in(rT2, rI)); + BOOST_REQUIRE(in(rT3, rI)); + } +} + +template<class T, class F> +void test_binary() { + typedef typename F::I I; + for(I a(-10., -9.91); a.lower() <= 10.; a += 0.3) { + for(I b(-10., -9.91); b.lower() <= 10.; b += 0.3) { + if (!F::validate(a, b)) continue; + T al = a.lower(), au = a.upper(), bl = b.lower(), bu = b.upper(); + I rII = F::f_II(a, b); + I rIT1 = F::f_IT(a, bl), rIT2 = F::f_IT(a, bu); + I rTI1 = F::f_TI(al, b), rTI2 = F::f_TI(au, b); + I rTT1 = F::f_TT(al, bl), rTT2 = F::f_TT(al, bu); + I rTT3 = F::f_TT(au, bl), rTT4 = F::f_TT(au, bu); + BOOST_REQUIRE(subset(rTT1, rIT1)); + BOOST_REQUIRE(subset(rTT3, rIT1)); + BOOST_REQUIRE(subset(rTT2, rIT2)); + BOOST_REQUIRE(subset(rTT4, rIT2)); + BOOST_REQUIRE(subset(rTT1, rTI1)); + BOOST_REQUIRE(subset(rTT2, rTI1)); + BOOST_REQUIRE(subset(rTT3, rTI2)); + BOOST_REQUIRE(subset(rTT4, rTI2)); + BOOST_REQUIRE(subset(rIT1, rII)); + BOOST_REQUIRE(subset(rIT2, rII)); + BOOST_REQUIRE(subset(rTI1, rII)); + BOOST_REQUIRE(subset(rTI2, rII)); + } + } +} + +#define new_unary_bunch(name, op, val) \ + template<class T> \ + struct name { \ + typedef boost::numeric::interval<T> I; \ + static I f_I(const I& a) { return op(a); } \ + static T f_T(const T& a) { return op(a); } \ + static bool validate(const I& a) { return val; } \ + } + +//#ifndef BOOST_NO_STDC_NAMESPACE +using std::abs; +using std::sqrt; +//#endif + +new_unary_bunch(bunch_pos, +, true); +new_unary_bunch(bunch_neg, -, true); +new_unary_bunch(bunch_sqrt, sqrt, a.lower() >= 0.); +new_unary_bunch(bunch_abs, abs, true); + +template<class T> +void test_all_unaries() { + BOOST_TEST_CHECKPOINT("pos"); test_unary<T, bunch_pos<T> >(); + BOOST_TEST_CHECKPOINT("neg"); test_unary<T, bunch_neg<T> >(); + BOOST_TEST_CHECKPOINT("sqrt"); test_unary<T, bunch_sqrt<T> >(); + BOOST_TEST_CHECKPOINT("abs"); test_unary<T, bunch_abs<T> >(); +} + +#define new_binary_bunch(name, op, val) \ + template<class T> \ + struct bunch_##name { \ + typedef boost::numeric::interval<T> I; \ + static I f_II(const I& a, const I& b) { return a op b; } \ + static I f_IT(const I& a, const T& b) { return a op b; } \ + static I f_TI(const T& a, const I& b) { return a op b; } \ + static I f_TT(const T& a, const T& b) \ + { return boost::numeric::interval_lib::name<I>(a,b); } \ + static bool validate(const I& a, const I& b) { return val; } \ + } + +new_binary_bunch(add, +, true); +new_binary_bunch(sub, -, true); +new_binary_bunch(mul, *, true); +new_binary_bunch(div, /, !zero_in(b)); + +template<class T> +void test_all_binaries() { + BOOST_TEST_CHECKPOINT("add"); test_binary<T, bunch_add<T> >(); + BOOST_TEST_CHECKPOINT("sub"); test_binary<T, bunch_sub<T> >(); + BOOST_TEST_CHECKPOINT("mul"); test_binary<T, bunch_mul<T> >(); + BOOST_TEST_CHECKPOINT("div"); test_binary<T, bunch_div<T> >(); +} + +int test_main(int, char *[]) { + BOOST_TEST_CHECKPOINT("float tests"); + test_all_unaries<float> (); + test_all_binaries<float> (); + BOOST_TEST_CHECKPOINT("double tests"); + test_all_unaries<double>(); + test_all_binaries<double>(); + //BOOST_TEST_CHECKPOINT("long double tests"); + //test_all_unaries<long double>(); + //test_all_binaries<long double>(); +# ifdef __BORLANDC__ + ::detail::ignore_warnings(); +# endif + return 0; +} |