|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61157 - in sandbox/itl: boost/itl boost/itl/detail boost/itl/type_traits boost/itl_xt boost/validate/driver boost/validate/gentor libs/itl/test libs/itl/test/test_casual_ libs/itl/test/test_continuous_interval_ libs/validate/example/labat_single_
From: afojgo_at_[hidden]
Date: 2010-04-09 11:26:11
Author: jofaber
Date: 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
New Revision: 61157
URL: http://svn.boost.org/trac/boost/changeset/61157
Log:
Added statically and dynamically bounded interval concepts. Implemented interval concepts as a set of free functions. Via design_config.hpp we can switch between the old and the new implementation (default old itl::interval implementation). Stable for msvc-9.0
Added:
sandbox/itl/boost/itl/discrete_interval.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/interval_type_of.hpp (contents, props changed)
Text files modified:
sandbox/itl/boost/itl/closed_interval.hpp | 175 ++++++-------------
sandbox/itl/boost/itl/continuous_interval.hpp | 27 +-
sandbox/itl/boost/itl/detail/design_config.hpp | 17 +
sandbox/itl/boost/itl/detail/element_iterator.hpp | 88 +++++-----
sandbox/itl/boost/itl/interval.hpp | 91 ----------
sandbox/itl/boost/itl/interval_base_map.hpp | 27 ---
sandbox/itl/boost/itl/interval_base_set.hpp | 12 -
sandbox/itl/boost/itl/interval_bounds.hpp | 71 ++++++-
sandbox/itl/boost/itl/interval_functions.hpp | 224 +++++++++++++++++++------
sandbox/itl/boost/itl/predicates.hpp | 8
sandbox/itl/boost/itl/rightopen_interval.hpp | 11 -
sandbox/itl/boost/itl_xt/interval_bitset.hpp | 26 +-
sandbox/itl/boost/itl_xt/itvgentor.hpp | 9
sandbox/itl/boost/validate/driver/itl_set_driver.hpp | 27 +-
sandbox/itl/boost/validate/driver/map_copy_conformity_driver.hpp | 16
sandbox/itl/boost/validate/gentor/randomgentor.hpp | 352 ++++++++++++++++++---------------------
sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp | 100 +++++++++++
sandbox/itl/libs/itl/test/test_continuous_interval_/test_continuous_interval.cpp | 1
sandbox/itl/libs/itl/test/test_itl_interval.hpp | 2
sandbox/itl/libs/itl/test/test_itl_interval_shared.hpp | 23 +-
sandbox/itl/libs/validate/example/labat_single_/labat_single.cpp | 7
21 files changed, 667 insertions(+), 647 deletions(-)
Modified: sandbox/itl/boost/itl/closed_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/closed_interval.hpp (original)
+++ sandbox/itl/boost/itl/closed_interval.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -8,39 +8,40 @@
#ifndef BOOST_ITL_CLOSED_INTERVAL_HPP_JOFA_100324
#define BOOST_ITL_CLOSED_INTERVAL_HPP_JOFA_100324
+#include <boost/itl/type_traits/value_size.hpp>
+#include <boost/itl/type_traits/type_to_string.hpp>
#include <boost/itl/detail/base_interval.hpp>
+#include <boost/itl/interval_functions.hpp>
namespace boost{namespace itl
{
-typedef unsigned char bound_type;
-
-template <class SubType, class DomainT,
+template <class DomainT,
ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT)>
-class asymmetric_interval : public base_interval<DomainT,Compare>
+class closed_interval : public base_interval<DomainT,Compare>
{
public:
- typedef base_interval<DomainT,Compare> base_type;
- typedef asymmetric_interval<SubType,DomainT,Compare> type;
- typedef SubType sub_type;
+ typedef closed_interval<DomainT,Compare> type;
+ typedef DomainT domain_type;
public:
//==========================================================================
//= Construct, copy, destruct
//==========================================================================
- /** Default constructor; yields an empty interval <tt>[0,0)</tt> or <tt>(0,0]</tt> */
- asymmetric_interval() : _lwb(unon<DomainT>::value()), _upb(neutron<DomainT>::value())
+ /** Default constructor; yields an empty interval <tt>[0,0)</tt>. */
+ closed_interval()
+ : _lwb(unon<DomainT>::value()), _upb(neutron<DomainT>::value())
{
BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
+ BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));//JODO is_discrete?
}
//NOTE: Compiler generated copy constructor is used
/** Constructor for a closed singleton interval <tt>[val,val]</tt> */
- explicit asymmetric_interval(const DomainT& val) :
- _lwb(val), _upb(val)
+ explicit closed_interval(const DomainT& val)
+ : _lwb(val), _upb(val)
{
BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
@@ -48,131 +49,67 @@
}
/** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bounds</tt> */
- asymmetric_interval(const DomainT& low, const DomainT& up) :
+ closed_interval(const DomainT& low, const DomainT& up) :
_lwb(low), _upb(up)
{
BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
}
domain_type lower()const{ return _lwb; }
domain_type upper()const{ return _upb; }
- /** Is the interval empty? */
- bool empty()const{ return domain_less(_upb, _lwb); }
-
- /** Maximal element of <tt>*this</tt> is less than the minimal element of <tt>x2</tt> */
- bool exclusive_less(const asymmetric_interval& x2)const
- { return domain_less(_upb, x2._lwb); }
-
- /** There is no gap between <tt>*this</tt> and <tt>x2</tt> but they have no element in common */
- bool touches(const asymmetric_interval& x2)const
- { return domain_equal(_upb, succ(x2._lwb)); }
-
- bool is_disjoint(const asymmetric_interval& x2)const //JODO ex
- { return exclusive_less(x2) || x2.exclusive_less(*this); }
-
- sub_type& extend(const sub_type& x2) //JODO ex
- {
- if (x2.empty()) return *that();
- else if(empty()) return *that() = x2;
- else
- {
- if(domain_less(x2._lwb, _lwb))
- _lwb = x2._lwb;
- if(domain_less(_upb, x2._upb))
- _upb = x2._upb;
- return *that();
- }
- }
-
- /** subtract \c left_minuend from the \c *this interval on it's left side.
- *this becomes the difference: The part of \c *this right of \c left_minuend.
- \code
- right_over = *this - left_minuend; //on the left.
- ... d] : right
- ...c] : left_minuend
- [c+1 d] : right_over = *this
- \endcode
- */
- sub_type& left_subtract(const sub_type& left_minuend)
- {
- if(!left_minuend.exclusive_less(*this))
- _lwb = succ(left_minuend._upb);
- return *that();
- }
-
-
- /** subtract \c right_minuend from the \c *this interval on it's right side.
- *this becomes the difference: The part of \c *this right of \c right_minuend.
- \code
- left_over = *this - right_minuend; //on the right side.
- [a ... : left
- [b ... : right_minuend
- [a b-1] : left_over = *this
- \endcode
- */
- sub_type& right_subtract(const sub_type& right_minuend)
- {
- if(!exclusive_less(right_minuend))
- _upb = pred(right_minuend._lwb);
- return *that();
- }
-
- /*JODO
- [a c]
- [b d]
- [a b-1][b c][c+1 d]
- */
- sub_type& operator &= (const sub_type& sectant)
- {
- _lwb = (std::max)(_lwb, sectant._lwb);
- _upb = (std::min)(_upb, sectant._upb);
- return *that();
- }
+ domain_type first()const{ return _lwb; }
+ domain_type last() const{ return _upb; }
- //CL REV -- For representation
- bool is_left(bound_type bounded)const
- { return 0 != (bounded & right_open); }
-
- bool is_right(bound_type bounded)const
- { return bounded==open_bounded || bounded==right_open; }
-
- //CL REV -- For the generator
- void set(DomainP left, DomainP right, bound_type bounds)
- { _lwb = left; _upb = right; }
-
- //JODO
- std::string as_string()const
- {
- std::string itvRep("");
- std::string lwbRep, ubpRep;
+private:
+ domain_type _lwb;
+ domain_type _upb;
+};
- itvRep += is_left(open_bounded) ? "(" : "[" ;
- itvRep += itl::to_string<DomainT>::apply(_lwb);
- itvRep += ",";
- itvRep += itl::to_string<DomainT>::apply(_upb);
- itvRep += is_right(open_bounded) ? ")" : "]" ;
- return itvRep;
- }
+template<class CharType, class CharTraits, class DomainT, ITL_COMPARE Compare>
+std::basic_ostream<CharType, CharTraits>& operator <<
+ (std::basic_ostream<CharType, CharTraits> &stream,
+ closed_interval<DomainT,Compare> const& object)
+{
+ if(itl::is_empty(object))
+ return stream << "[]";
+ else
+ return stream << "[" << object.lower() << "," << object.upper()<< "]";
+}
- bool lower_equal(const sub_type& x2)const{ return _lwb==x2._lwb; }
- bool upper_equal(const sub_type& x2)const{ return _upb==x2._upb; }
- bool lower_less (const sub_type& x2)const{ return domain_less(_lwb, x2._lwb); }
- bool upper_less (const sub_type& x2)const{ return domain_less(_upb, x2._upb); }
+//==============================================================================
+//= Type traits
+//==============================================================================
+template <class DomainT, ITL_COMPARE Compare>
+struct is_interval<closed_interval<DomainT,Compare> >
+{
+ typedef is_interval<closed_interval<DomainT,Compare> > type;
+ BOOST_STATIC_CONSTANT(bool, value = true);
+};
-protected:
- sub_type* that() { return static_cast< sub_type*>(this); }
- const sub_type* that()const { return static_cast<const sub_type*>(this); }
+template <class DomainT, ITL_COMPARE Compare>
+struct has_static_bounds<closed_interval<DomainT,Compare> >
+{
+ typedef has_static_bounds<closed_interval<DomainT,Compare> > type;
+ BOOST_STATIC_CONSTANT(bool, value = true);
+};
-private:
- domain_type _lwb;
- domain_type _upb;
+template <class DomainT, ITL_COMPARE Compare>
+struct type_to_string<itl::closed_interval<DomainT,Compare> >
+{
+ static std::string apply()
+ { return "[I]<"+ type_to_string<DomainT>::apply() +">"; }
};
+template<class DomainT>
+struct value_size<itl::closed_interval<DomainT> >
+{
+ static std::size_t apply(const itl::closed_interval<DomainT>& value)
+ { return 2; }
+};
}} // namespace itl boost
Modified: sandbox/itl/boost/itl/continuous_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/continuous_interval.hpp (original)
+++ sandbox/itl/boost/itl/continuous_interval.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -8,6 +8,8 @@
#ifndef BOOST_ITL_CONTINUOUS_INTERVAL_HPP_JOFA_100327
#define BOOST_ITL_CONTINUOUS_INTERVAL_HPP_JOFA_100327
+#include <boost/itl/type_traits/value_size.hpp>
+#include <boost/itl/type_traits/type_to_string.hpp>
#include <boost/itl/type_traits/is_continuous.hpp>
#include <boost/itl/type_traits/is_continuous_interval.hpp>
#include <boost/itl/detail/base_interval.hpp>
@@ -26,6 +28,7 @@
public:
typedef continuous_interval<DomainT,Compare> type;
typedef DomainT domain_type;
+ typedef typename bounded_value<DomainT,Compare>::type bounded_domain_type;
public:
//==========================================================================
@@ -33,13 +36,13 @@
//==========================================================================
/** Default constructor; yields an empty interval <tt>[0,0)</tt>. */
continuous_interval()
- : _lwb(neutron<DomainT>::value()), _upb(neutron<DomainT>::value())
- , _bounds(interval_bounds::right_open())
+ : _lwb(neutron<DomainT>::value()), _upb(neutron<DomainT>::value())
+ , _bounds(interval_bounds::right_open())
{
BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
//JODO URG BOOST_STATIC_ASSERT((itl::is_continuous<DomainT>::value));
- //JODO we must assert this via appropriate defaults for template parameters
+ //JODO we must assert this via appropriate defaults for template parameters
}
//NOTE: Compiler generated copy constructor is used
@@ -55,7 +58,8 @@
/** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bounds</tt> */
continuous_interval(const DomainT& low, const DomainT& up,
- interval_bounds bounds = interval_bounds::right_open())
+ interval_bounds bounds = interval_bounds::right_open(),
+ continuous_interval* = 0)
: _lwb(low), _upb(up), _bounds(bounds)
{
BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
@@ -67,14 +71,6 @@
domain_type upper()const { return _upb; }
interval_bounds bounds()const{ return _bounds; }
- domain_type first()const{ return _lwb; }
-
- DomainT last()const
- {
- BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
- return pred(_upb);
- }
-
private:
domain_type _lwb;
domain_type _upb;
@@ -90,7 +86,8 @@
if(itl::is_empty(object))
return stream << "[)";
else
- return stream << "[" << object.lower() << "," << object.upper()<< ")";
+ return stream << left_bracket(object.bounds()) << object.lower()
+ << "," << object.upper()<< right_bracket(object.bounds());
}
@@ -108,7 +105,7 @@
struct is_continuous_interval<continuous_interval<DomainT,Compare> >
{
typedef is_continuous_interval<continuous_interval<DomainT,Compare> > type;
- BOOST_STATIC_CONSTANT(bool, value = is_continuous<DomainT>::value);
+ BOOST_STATIC_CONSTANT(bool, value = is_continuous<DomainT>::value);
};
template <class DomainT, ITL_COMPARE Compare>
@@ -122,7 +119,7 @@
struct type_to_string<itl::continuous_interval<DomainT,Compare> >
{
static std::string apply()
- { return "[R)<"+ type_to_string<DomainT>::apply() +">"; }
+ { return "cI<"+ type_to_string<DomainT>::apply() +">"; }
};
template<class DomainT>
Modified: sandbox/itl/boost/itl/detail/design_config.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/design_config.hpp (original)
+++ sandbox/itl/boost/itl/detail/design_config.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -15,7 +15,6 @@
#ifndef BOOST_ITL_DESIGN_CONFIG_HPP_JOFA_090214
#define BOOST_ITL_DESIGN_CONFIG_HPP_JOFA_090214
-
//------------------------------------------------------------------------------
// Auxiliary macros for denoting template signatures.
// Purpose:
@@ -28,12 +27,12 @@
#define ITL_USE_COMPARE_TEMPLATE_TEMPLATE
#define ITL_USE_COMBINE_TEMPLATE_TEMPLATE
#define ITL_USE_SECTION_TEMPLATE_TEMPLATE
-//#define ITL_USE_INTERVAL_TEMPLATE_TEMPLATE
+#define ITL_USE_INTERVAL_TEMPLATE_TEMPLATE
//#define ITL_USE_COMPARE_TEMPLATE_TYPE
//#define ITL_USE_COMBINE_TEMPLATE_TYPE
//#define ITL_USE_SECTION_TEMPLATE_TYPE
-#define ITL_USE_INTERVAL_TEMPLATE_TYPE
+//#define ITL_USE_INTERVAL_TEMPLATE_TYPE
//------------------------------------------------------------------------------
// template parameter Compare can not be a template type parameter as long as
@@ -87,14 +86,22 @@
# define ITL_INTERVAL(itl_compare) class
# define ITL_INTERVAL2(itl_compare) class
# define ITL_INTERVAL_TYPE(itl_interval, domain_type, itl_compare) itl_interval
-# define ITL_INTERVAL_INSTANCE(interval_instance,domain_type,itl_compare) interval_instance<domain_type,itl_compare>
+# define ITL_INTERVAL_INSTANCE(interval_instance,domain_type,itl_compare) typename interval_instance<domain_type,itl_compare>::type
#endif
//------------------------------------------------------------------------------
-//#define ITL_INTERVAL_DEFAULT itl::rightopen_interval
#define ITL_INTERVAL_DEFAULT boost::itl::interval
+//#define ITL_INTERVAL_DEFAULT itl::rightopen_interval
//#define ITL_INTERVAL_DEFAULT itl::continuous_interval
+//#define ITL_INTERVAL_DEFAULT itl::interval_type_of
+
+//------------------------------------------------------------------------------
+//JODO find proper solution here
+#define ITL_discrt_INTERVAL_DEF itl::interval
+#define ITL_contin_INTERVAL_DEF itl::interval
+//#define ITL_discrt_INTERVAL_DEF itl::discrete_interval
+//#define ITL_contin_INTERVAL_DEF itl::continuous_interval
//------------------------------------------------------------------------------
#define ITL_ALLOC template<class>class
Modified: sandbox/itl/boost/itl/detail/element_iterator.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/element_iterator.hpp (original)
+++ sandbox/itl/boost/itl/detail/element_iterator.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -75,52 +75,52 @@
#ifdef ITL_USE_INTERVAL_TEMPLATE_TEMPLATE
- template<class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval>
- struct elemental<ITL_INTERVAL_TYPE(Interval,DomainT,Compare) >
- {
- typedef ITL_INTERVAL_TYPE(Interval,DomainT,Compare) segment_type;
- typedef segment_type interval_type;
- typedef DomainT type;
- typedef DomainT domain_type;
- typedef DomainT codomain_type;
- typedef DomainT transit_type;
- };
-
- template< class DomainT, class CodomainT,
- ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval >
- struct elemental<std::pair<ITL_INTERVAL_TYPE(Interval,DomainT,Compare)const, CodomainT> >
- {
- typedef std::pair<ITL_INTERVAL_TYPE(Interval,DomainT,Compare), CodomainT> segment_type;
- typedef ITL_INTERVAL_TYPE(Interval,DomainT,Compare) interval_type;
- typedef std::pair<DomainT, CodomainT> type;
- typedef DomainT domain_type;
- typedef CodomainT codomain_type;
- typedef mapped_reference<DomainT, CodomainT> transit_type;
- };
+ template<class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct elemental<ITL_INTERVAL_TYPE(Interval,DomainT,Compare) >
+ {
+ typedef ITL_INTERVAL_TYPE(Interval,DomainT,Compare) segment_type;
+ typedef segment_type interval_type;
+ typedef DomainT type;
+ typedef DomainT domain_type;
+ typedef DomainT codomain_type;
+ typedef DomainT transit_type;
+ };
+
+ template< class DomainT, class CodomainT,
+ ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval >
+ struct elemental<std::pair<ITL_INTERVAL_TYPE(Interval,DomainT,Compare)const, CodomainT> >
+ {
+ typedef std::pair<ITL_INTERVAL_TYPE(Interval,DomainT,Compare), CodomainT> segment_type;
+ typedef ITL_INTERVAL_TYPE(Interval,DomainT,Compare) interval_type;
+ typedef std::pair<DomainT, CodomainT> type;
+ typedef DomainT domain_type;
+ typedef CodomainT codomain_type;
+ typedef mapped_reference<DomainT, CodomainT> transit_type;
+ };
#else //ITL_USE_INTERVAL_TEMPLATE_TYPE
- template<ITL_INTERVAL(ITL_COMPARE) Interval>
- struct elemental
- {
- typedef ITL_INTERVAL_TYPE(Interval,DomainT,Compare) segment_type;
- typedef segment_type interval_type;
- typedef typename interval_type::domain_type domain_type;
- typedef domain_type type;
- typedef domain_type codomain_type;
- typedef domain_type transit_type;
- };
-
- template< class CodomainT, ITL_INTERVAL(ITL_COMPARE) Interval >
- struct elemental<std::pair<ITL_INTERVAL_TYPE(Interval,DomainT,Compare)const, CodomainT> >
- {
- typedef std::pair<ITL_INTERVAL_TYPE(Interval,DomainT,Compare), CodomainT> segment_type;
- typedef ITL_INTERVAL_TYPE(Interval,DomainT,Compare) interval_type;
- typedef typename interval_type::domain_type domain_type;
- typedef CodomainT codomain_type;
- typedef std::pair<domain_type, codomain_type> type;
- typedef mapped_reference<domain_type, codomain_type> transit_type;
- };
+ template<ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct elemental
+ {
+ typedef ITL_INTERVAL_TYPE(Interval,DomainT,Compare) segment_type;
+ typedef segment_type interval_type;
+ typedef typename interval_type::domain_type domain_type;
+ typedef domain_type type;
+ typedef domain_type codomain_type;
+ typedef domain_type transit_type;
+ };
+
+ template< class CodomainT, ITL_INTERVAL(ITL_COMPARE) Interval >
+ struct elemental<std::pair<ITL_INTERVAL_TYPE(Interval,DomainT,Compare)const, CodomainT> >
+ {
+ typedef std::pair<ITL_INTERVAL_TYPE(Interval,DomainT,Compare), CodomainT> segment_type;
+ typedef ITL_INTERVAL_TYPE(Interval,DomainT,Compare) interval_type;
+ typedef typename interval_type::domain_type domain_type;
+ typedef CodomainT codomain_type;
+ typedef std::pair<domain_type, codomain_type> type;
+ typedef mapped_reference<domain_type, codomain_type> transit_type;
+ };
#endif //ITL_USE_INTERVAL_TEMPLATE_TEMPLATE
@@ -186,7 +186,7 @@
#else // ITL_USE_INTERVAL_TEMPLATE_TYPE
template<class SegmentIteratorT, ITL_INTERVAL(ITL_COMPARE) Interval>
-struct segment_adapter //CL <SegmentIteratorT, ITL_INTERVAL_TYPE(Interval,DomainT,Compare) >
+struct segment_adapter
{
typedef segment_adapter type;
typedef ITL_INTERVAL_TYPE(Interval,DomainT,Compare) segment_type;
Added: sandbox/itl/boost/itl/discrete_interval.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/discrete_interval.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -0,0 +1,143 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_DISCRETE_INTERVAL_HPP_JOFA_100403
+#define BOOST_ITL_DISCRETE_INTERVAL_HPP_JOFA_100403
+
+#include <boost/static_assert.hpp>
+#include <boost/itl/type_traits/value_size.hpp>
+#include <boost/itl/type_traits/type_to_string.hpp>
+#include <boost/itl/type_traits/is_continuous.hpp>
+#include <boost/itl/type_traits/is_discrete_interval.hpp>
+#include <boost/itl/detail/base_interval.hpp>
+#include <boost/itl/interval_bounds.hpp>
+#include <boost/itl/interval_functions.hpp>
+
+namespace boost{namespace itl
+{
+
+typedef unsigned char bound_type; //JODO
+
+template <class DomainT,
+ ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT)>
+class discrete_interval : public base_interval<DomainT,Compare>
+{
+public:
+ typedef discrete_interval<DomainT,Compare> type;
+ typedef DomainT domain_type;
+ typedef typename bounded_value<DomainT,Compare>::type bounded_domain_type;
+
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+ /** Default constructor; yields an empty interval <tt>[0,0)</tt>. */
+ discrete_interval()
+ : _lwb(neutron<DomainT>::value()), _upb(neutron<DomainT>::value())
+ , _bounds(interval_bounds::right_open())
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ //JODO URG BOOST_STATIC_ASSERT((itl::is_continuous<DomainT>::value));
+ //JODO we must assert this via appropriate defaults for template parameters
+ }
+
+ //NOTE: Compiler generated copy constructor is used
+
+ /** Constructor for a closed singleton interval <tt>[val,val]</tt> */
+ explicit discrete_interval(const DomainT& val)
+ : _lwb(val), _upb(val), _bounds(interval_bounds::closed())
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ //JODO BOOST_STATIC_ASSERT((itl::is_continuous<DomainT>::value));
+ }
+
+ /** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bounds</tt> */
+ discrete_interval(const DomainT& low, const DomainT& up,
+ interval_bounds bounds = interval_bounds::right_open(),
+ discrete_interval* = 0)
+ : _lwb(low), _upb(up), _bounds(bounds)
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ //JODO BOOST_STATIC_ASSERT((itl::is_continuous<DomainT>::value));
+ }
+
+ domain_type lower()const { return _lwb; }
+ domain_type upper()const { return _upb; }
+ interval_bounds bounds()const{ return _bounds; }
+
+ domain_type first()const{ return _lwb; }
+
+ DomainT last()const
+ {
+ BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
+ return pred(_upb);
+ }
+
+private:
+ domain_type _lwb;
+ domain_type _upb;
+ interval_bounds _bounds;
+};
+
+
+template<class CharType, class CharTraits, class DomainT, ITL_COMPARE Compare>
+std::basic_ostream<CharType, CharTraits>& operator <<
+ (std::basic_ostream<CharType, CharTraits> &stream,
+ discrete_interval<DomainT,Compare> const& object)
+{
+ if(itl::is_empty(object))
+ return stream << "[)";
+ else
+ return stream << "[" << object.lower() << "," << object.upper()<< ")";//JODO
+}
+
+
+//==============================================================================
+//= Type traits
+//==============================================================================
+template <class DomainT, ITL_COMPARE Compare>
+struct is_interval<discrete_interval<DomainT,Compare> >
+{
+ typedef is_interval<discrete_interval<DomainT,Compare> > type;
+ BOOST_STATIC_CONSTANT(bool, value = true);
+};
+
+template <class DomainT, ITL_COMPARE Compare>
+struct is_discrete_interval<discrete_interval<DomainT,Compare> >
+{
+ typedef is_discrete_interval<discrete_interval<DomainT,Compare> > type;
+ BOOST_STATIC_CONSTANT(bool, value = !is_continuous<DomainT>::value); //JODO
+};
+
+template <class DomainT, ITL_COMPARE Compare>
+struct has_dynamic_bounds<discrete_interval<DomainT,Compare> >
+{
+ typedef has_dynamic_bounds<discrete_interval<DomainT,Compare> > type;
+ BOOST_STATIC_CONSTANT(bool, value = true);
+};
+
+template <class DomainT, ITL_COMPARE Compare>
+struct type_to_string<itl::discrete_interval<DomainT,Compare> >
+{
+ static std::string apply()
+ { return "dI<"+ type_to_string<DomainT>::apply() +">"; }
+};
+
+template<class DomainT>
+struct value_size<itl::discrete_interval<DomainT> >
+{
+ static std::size_t apply(const itl::discrete_interval<DomainT>& value)
+ { return 2; }
+};
+
+}} // namespace itl boost
+
+#endif
+
Modified: sandbox/itl/boost/itl/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval.hpp (original)
+++ sandbox/itl/boost/itl/interval.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -40,20 +40,6 @@
namespace boost{namespace itl
{
-/*CL
-/// Constants for intervalbounds
-enum BoundTypes {
- /// Both open: <tt>(x,y)</tt>
- open_bounded = 0,
- /// Left open right closed: <tt>(x,y]</tt>
- left_open = 1,
- /// Left closed right open: <tt>[x,y)</tt>
- right_open = 2,
- /// Both closed: <tt>[x,y]</tt>
- closed_bounded = 3
-} ;
-*/
-
typedef unsigned char bound_type;
/** \brief A class template for intervals */
@@ -375,22 +361,6 @@
/** Last element of \c *this is equal to the last element of \c x2 */
bool upper_equal(const interval& x2)const;
-//CL
-//public:
-// typedef typename boost::call_traits<DomainT>::param_type DomainP;
-//
-// /** Less compare of interval elements. */
-// inline static bool domain_less(DomainP left, DomainP right)
-// {return domain_compare()(left, right) ;}
-//
-// /** Less or equal compare of interval elements. */
-// inline static bool domain_less_equal(DomainP left, DomainP right)
-// {return !domain_compare()(right, left );}
-//
-// /** Equality compare of interval elements. */
-// inline static bool domain_equal(DomainP left, DomainP right)
-// {return !domain_compare()(left, right) && !domain_compare()(right, left);}
-
private:
typedef std::pair<DomainT, bound_type> BoundT;
@@ -1034,67 +1004,6 @@
{ return exclusive_less(left, right); }
};
-
-//==============================================================================
-//= Addition
-//==============================================================================
-
-/** \c hull returns the smallest interval containing \c left and \c right. */
-//CL template <class DomainT, ITL_COMPARE Compare>
-//inline interval<DomainT,Compare> hull(interval<DomainT,Compare> left,
-// const interval<DomainT,Compare>& right)
-//{
-// return left.extend(right);
-//}
-
-//==============================================================================
-//= Subtraction
-//==============================================================================
-
-/** subtract \c right_minuend from the \c left interval on it's right side.
- Return the difference: The part of \c left right of \c right_minuend.
-\code
-left_over = left - right_minuend; //on the right side.
-[a ... : left
- [b ... : right_minuend
-[a b) : left_over
-\endcode
-*/
-//CL template <class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval>
-//inline ITL_INTERVAL_TYPE(Interval,DomainT,Compare) right_subtract(ITL_INTERVAL_TYPE(Interval,DomainT,Compare) left,
-// const ITL_INTERVAL_TYPE(Interval,DomainT,Compare)& right_minuend)
-//{
-// return left.right_subtract(right_minuend);
-//}
-
-/** subtract \c left_minuend from the \c right interval on it's left side.
- Return the difference: The part of \c right right of \c left_minuend.
-\code
-right_over = right - left_minuend; //on the left.
-... d) : right
-... c) : left_minuend
- [c d) : right_over
-\endcode
-*/
-//CL template <class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval>
-//inline ITL_INTERVAL_TYPE(Interval,DomainT,Compare) left_subtract(ITL_INTERVAL_TYPE(Interval,DomainT,Compare) right,
-// const ITL_INTERVAL_TYPE(Interval,DomainT,Compare)& left_minuend)
-//{
-// return right.left_subtract(left_minuend);
-//}
-
-//==============================================================================
-//= Intersection
-//==============================================================================
-
-/** Returns the intersection of \c left and \c right interval. */
-//CL template <class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval>
-//inline ITL_INTERVAL_TYPE(Interval,DomainT,Compare) operator & (ITL_INTERVAL_TYPE(Interval,DomainT,Compare) left,
-// const ITL_INTERVAL_TYPE(Interval,DomainT,Compare)& right)
-//{
-// return left &= right;
-//}
-
/** Returns true if the intersection of \c left and \c right is not empty. */
template <class DomainT, ITL_COMPARE Compare>
inline bool intersects(const itl::interval<DomainT,Compare>& left,
Modified: sandbox/itl/boost/itl/interval_base_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_map.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -687,13 +687,6 @@
element_const_reverse_iterator elements_rbegin()const{ return element_const_reverse_iterator(this->rbegin()); }
element_const_reverse_iterator elements_rend() const{ return element_const_reverse_iterator(this->rend()); }
- //==========================================================================
- //= Representation
- //==========================================================================
-
- /** Object as string */
- //CL std::string as_string()const;
-
//==========================================================================
//= Morphisms
@@ -1249,26 +1242,6 @@
return *this;
}
-/*CL ::as_string
-template
-<
- class SubType,
- class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc
->
-std::string interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>::as_string()const
-{
- std::string res("");
- const_FOR_IMPLMAP(it_) {
- std::string cur("(");
- cur += it_->first.as_string();
- cur += ",";
- cur += itl::to_string<CodomainT>::apply(it_->second);
- cur += ")";
- res += cur;
- }
- return res;
-}
-*/
template
<
Modified: sandbox/itl/boost/itl/interval_base_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_set.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -10,6 +10,7 @@
#define __interval_base_set_h_JOFA_990223__
#include <limits>
+#include <boost/itl/type_traits/interval_type_of.hpp>
#include <boost/itl/detail/interval_set_algo.hpp>
#include <boost/itl/set.hpp>
#include <boost/itl/interval.hpp>
@@ -446,17 +447,6 @@
*/
void uniform_bounds(itl::bound_type bounded);
-
- //==========================================================================
- //= Representation
- //==========================================================================
-
- /** Interval container's string representation */
- /*CL ::as_string
- const std::string as_string()const
- { std::string res(""); const_FOR_IMPL(it_) res += (*it_).as_string(); return res; }
- */
-
//==========================================================================
//= Algorithm unifiers
Modified: sandbox/itl/boost/itl/interval_bounds.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_bounds.hpp (original)
+++ sandbox/itl/boost/itl/interval_bounds.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -31,18 +31,20 @@
class interval_bounds
{
public:
- interval_bounds():_bits(){}
+ interval_bounds():_bits(){}
explicit interval_bounds(bound_type bounds): _bits(bounds){}
- interval_bounds left ()const { return interval_bounds(_bits & 1); }
- interval_bounds right()const { return interval_bounds(_bits & 2); }
- interval_bounds both ()const { return interval_bounds(_bits & 3); }
-
- bound_type bits()const{ return _bits; }
-
- static interval_bounds open() { return interval_bounds(0); } //JODO URG LITERALS
- static interval_bounds left_open() { return interval_bounds(1); }
- static interval_bounds right_open(){ return interval_bounds(2); }
- static interval_bounds closed() { return interval_bounds(3); }
+ interval_bounds both ()const { return interval_bounds(_bits & 3); } //JODO literals
+ interval_bounds left ()const { return interval_bounds(_bits & 2); }
+ interval_bounds right()const { return interval_bounds(_bits & 1); }
+ interval_bounds reverse_left ()const { return interval_bounds((~_bits>>1) & 1); }
+ interval_bounds reverse_right()const { return interval_bounds((~_bits<<1) & 2); }
+
+ bound_type bits()const{ return _bits; }
+
+ static interval_bounds open() { return interval_bounds(0); } //JODO URG LITERALS
+ static interval_bounds left_open() { return interval_bounds(1); }
+ static interval_bounds right_open(){ return interval_bounds(2); }
+ static interval_bounds closed() { return interval_bounds(3); }
public:
bound_type _bits;
@@ -50,17 +52,20 @@
inline interval_bounds left(interval_bounds x1)
-{ return interval_bounds(x1._bits & 1); }
+{ return interval_bounds(x1._bits & 2); }
inline interval_bounds right(interval_bounds x1)
-{ return interval_bounds(x1._bits & 2); }
+{ return interval_bounds(x1._bits & 1); }
inline interval_bounds all(interval_bounds x1)
-{ return interval_bounds(x1._bits & 2); }
+{ return interval_bounds(x1._bits & 3); }
inline bool operator == (const interval_bounds x1, const interval_bounds x2)
{ return x1._bits == x2._bits; }
+inline bool operator != (const interval_bounds x1, const interval_bounds x2)
+{ return x1._bits != x2._bits; }
+
inline interval_bounds operator & (interval_bounds x1, interval_bounds x2)
{ return interval_bounds(x1._bits & x2._bits); }
@@ -76,13 +81,13 @@
{ return interval_bounds(bounds._bits >> shift); }
inline interval_bounds operator ~ (interval_bounds x1)
-{ return interval_bounds(all(~x1)); }
+{ return all(interval_bounds(~(x1._bits))); }
inline interval_bounds outer_bounds(interval_bounds x1, interval_bounds x2)
{ return left(x1) | right(x2); }
inline interval_bounds inner_bounds(interval_bounds x1, interval_bounds x2)
-{ return ~(right(x1) | left(x2)); }
+{ return interval_bounds(x1.reverse_right() | x2.reverse_left()); }
inline interval_bounds left_bounds(interval_bounds x1, interval_bounds x2)
{ return left(x1) | (left(x2) >> 1); }
@@ -99,6 +104,22 @@
inline bool is_complementary(interval_bounds x1)
{ return x1 == interval_bounds::right_open() || x1 == interval_bounds::left_open(); }
+inline std::string left_bracket(interval_bounds bounds)
+{ return bounds.left().bits()==2 ? "[" : "("; }
+
+inline std::string right_bracket(interval_bounds bounds)
+{ return bounds.right().bits()==1 ? "]" : ")"; }
+
+template<class CharType, class CharTraits>
+std::basic_ostream<CharType, CharTraits>& operator <<
+ (std::basic_ostream<CharType, CharTraits> &stream,
+ interval_bounds const& object)
+{
+ return stream << "'" << left_bracket(object) << right_bracket(object) << "'";
+}
+
+
+
template<class IntervalT>
inline typename
boost::enable_if<has_dynamic_bounds<IntervalT>, interval_bounds>::type
@@ -136,6 +157,24 @@
{ return right_subtract_bounds(x1.bounds(), x2.bounds()); }
+template<class DomainT, ITL_COMPARE Compare>
+class bounded_value
+{
+public:
+ typedef DomainT domain_type;
+ typedef bounded_value<DomainT,Compare> type;
+public:
+ bounded_value(const domain_type& value, interval_bounds bound)
+ : _value(value), _bound(bound) {}
+
+ domain_type value()const { return _value; }
+ interval_bounds bound()const { return _bound; }
+
+private:
+ domain_type _value;
+ interval_bounds _bound;
+};
+
}} // namespace itl boost
#endif
Modified: sandbox/itl/boost/itl/interval_functions.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_functions.hpp (original)
+++ sandbox/itl/boost/itl/interval_functions.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -16,6 +16,7 @@
#include <boost/itl/type_traits/is_continuous_interval.hpp>
#include <boost/itl/type_traits/has_dynamic_bounds.hpp>
+
namespace boost{namespace itl
{
typedef unsigned char bound_type; //JODO encapsulation in a small class
@@ -25,6 +26,69 @@
//= Construct
//==============================================================================
+//JODO include struktur und deklarationen
+template<class DomainT, ITL_COMPARE Compare> class interval;
+template<class DomainT, ITL_COMPARE Compare> class discrete_interval;
+template<class DomainT, ITL_COMPARE Compare> class continuous_interval;
+
+class interval_bounds;
+template<class DomainT, ITL_COMPARE Compare> class bounded_value;
+
+template<class IntervalT>
+struct construct_interval;
+
+template<class DomainT, ITL_COMPARE Compare>
+struct construct_interval< itl::interval<DomainT,Compare> >
+{
+ static itl::interval<DomainT,Compare> apply(const DomainT& lo, const DomainT& up, interval_bounds bounds)
+ {
+ return boost::itl::interval<DomainT,Compare>(lo, up, bounds.bits());
+ }
+};
+
+template<class DomainT, ITL_COMPARE Compare>
+struct construct_interval<boost::itl::discrete_interval<DomainT,Compare> >
+{
+ static itl::discrete_interval<DomainT,Compare> apply(const DomainT& lo, const DomainT& up, interval_bounds bounds)
+ {
+ return itl::discrete_interval<DomainT,Compare>(lo, up, bounds,
+ static_cast<itl::discrete_interval<DomainT,Compare>* >(0) );
+ }
+
+ static itl::discrete_interval<DomainT,Compare> bounded(const bounded_value<DomainT,Compare>& lo,
+ const bounded_value<DomainT,Compare>& up)
+ {
+ return itl::discrete_interval<DomainT,Compare>
+ (
+ lo.value(), up.value(),
+ lo.bound().left() | up.bound().right(),
+ static_cast<itl::discrete_interval<DomainT,Compare>* >(0)
+ );
+ }
+};
+
+template<class DomainT, ITL_COMPARE Compare>
+struct construct_interval<boost::itl::continuous_interval<DomainT,Compare> >
+{
+ static itl::continuous_interval<DomainT,Compare> apply(const DomainT& lo, const DomainT& up, interval_bounds bounds)
+ {
+ return itl::continuous_interval<DomainT,Compare>(lo, up, bounds,
+ static_cast<itl::continuous_interval<DomainT,Compare>* >(0) );
+ }
+
+ static itl::continuous_interval<DomainT,Compare> bounded(const bounded_value<DomainT,Compare>& lo,
+ const bounded_value<DomainT,Compare>& up)
+ {
+ return itl::continuous_interval<DomainT,Compare>
+ (
+ lo.value(), up.value(),
+ lo.bound().left() | up.bound().right(),
+ static_cast<itl::continuous_interval<DomainT,Compare>* >(0)
+ );
+ }
+};
+
+
//- construct(3) ---------------------------------------------------------------
template<class IntervalT>
typename boost::enable_if<is_asymmetric_interval<IntervalT>, IntervalT>::type
@@ -39,20 +103,88 @@
typename boost::enable_if<is_universal_interval<IntervalT>, IntervalT>::type
construct(const typename IntervalT::domain_type& low,
const typename IntervalT::domain_type& up,
- itl::bound_type bounds)
+ interval_bounds bounds)
+{
+ return construct_interval<IntervalT>::apply(low, up, bounds);
+}
+
+template<class IntervalT>
+typename boost::enable_if<is_discrete_interval<IntervalT>, IntervalT>::type
+construct(const typename IntervalT::domain_type& low,
+ const typename IntervalT::domain_type& up,
+ interval_bounds bounds)
{
- return IntervalT(low, up, bounds);
+ return construct_interval<IntervalT>::apply(low, up, bounds);
}
template<class IntervalT>
typename boost::enable_if<is_continuous_interval<IntervalT>, IntervalT>::type
construct(const typename IntervalT::domain_type& low,
const typename IntervalT::domain_type& up,
- itl::bound_type bounds)
+ interval_bounds bounds)
{
- return IntervalT(low, up, interval_bounds(bounds));
+ return construct_interval<IntervalT>::apply(low, up, bounds);
+}
+
+//- construct(2) ---------------------------------------------------------------
+template<class IntervalT>
+typename boost::enable_if<is_discrete_interval<IntervalT>, IntervalT>::type
+construct(const typename IntervalT::bounded_domain_type& low,
+ const typename IntervalT::bounded_domain_type& up)
+{
+ return construct_interval<IntervalT>::bounded(low, up);
+}
+
+template<class IntervalT>
+typename boost::enable_if<is_continuous_interval<IntervalT>, IntervalT>::type
+construct(const typename IntervalT::bounded_domain_type& low,
+ const typename IntervalT::bounded_domain_type& up)
+{
+ return construct_interval<IntervalT>::bounded(low, up);
+}
+
+
+//==============================================================================
+//= Selection
+//==============================================================================
+
+template<class IntervalT>
+typename boost::enable_if<has_dynamic_bounds<IntervalT>,
+ typename IntervalT::bounded_domain_type>::type
+bounded_lower(const IntervalT& object)
+{
+ return typename
+ IntervalT::bounded_domain_type(object.lower(), object.bounds().left());
+}
+
+template<class IntervalT>
+typename boost::enable_if<has_dynamic_bounds<IntervalT>,
+ typename IntervalT::bounded_domain_type>::type
+reverse_bounded_lower(const IntervalT& object)
+{
+ return typename
+ IntervalT::bounded_domain_type(object.lower(), object.bounds().reverse_left());
+}
+
+template<class IntervalT>
+typename boost::enable_if<has_dynamic_bounds<IntervalT>,
+ typename IntervalT::bounded_domain_type>::type
+bounded_upper(const IntervalT& object)
+{
+ return typename
+ IntervalT::bounded_domain_type(object.upper(), object.bounds().right());
+}
+
+template<class IntervalT>
+typename boost::enable_if<has_dynamic_bounds<IntervalT>,
+ typename IntervalT::bounded_domain_type>::type
+reverse_bounded_upper(const IntervalT& object)
+{
+ return typename
+ IntervalT::bounded_domain_type(object.upper(), object.bounds().reverse_right());
}
+
//==============================================================================
//= Containedness
//==============================================================================
@@ -82,11 +214,10 @@
template<class IntervalT>
typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
is_empty(const IntervalT& object)
-{
- if(object.bounds() == interval_bounds::closed())
- return IntervalT::domain_less(object.lower(), object.upper());
- else
- return IntervalT::domain_less_equal(object.lower(), object.upper());
+{
+ return IntervalT::domain_less(object.upper(), object.lower())
+ || ( IntervalT::domain_equal(object.upper(), object.lower())
+ && object.bounds() != interval_bounds::closed() );
}
//- contains -------------------------------------------------------------------
@@ -94,14 +225,14 @@
typename boost::enable_if<is_interval<IntervalT>, bool>::type
contains(const IntervalT& super, const IntervalT& sub)
{
- return lower_less_equal(super,sub) && upper_less_equal(sub,super);
+ return lower_less_equal(super,sub) && upper_less_equal(sub,super);
}
template<class IntervalT>
typename boost::enable_if<is_interval<IntervalT>, bool>::type
contains(const IntervalT& super, const typename IntervalT::domain_type& element)
{
- return contains(super,IntervalT(element));
+ return contains(super,IntervalT(element));
}
//- within ---------------------------------------------------------------------
@@ -109,22 +240,10 @@
typename boost::enable_if<is_interval<IntervalT>, bool>::type
within(const IntervalT& sub, const IntervalT& super)
{
- return contains(super,sub);
+ return contains(super,sub);
}
-
-//==============================================================================
-//= Properties
-//==============================================================================
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
-is_closed(const IntervalT& object)
-{
- is_closed(object.bounds());
-}
-
//==============================================================================
//= Equivalences and Orderings
//==============================================================================
@@ -157,10 +276,9 @@
typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
exclusive_less(const IntervalT& left, const IntervalT& right)
{
- if(inner_bounds(left,right) == interval_bounds::closed())
- return IntervalT::domain_less(left.lower(), right.upper());
- else
- return IntervalT::domain_less_equal(left.lower(), right.upper());
+ return IntervalT::domain_less(left.upper(), right.lower())
+ || ( IntervalT::domain_equal(left.upper(), right.lower())
+ && inner_bounds(left,right) != interval_bounds::open() );
}
//------------------------------------------------------------------------------
@@ -189,7 +307,7 @@
typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
lower_less(const IntervalT& left, const IntervalT& right)
{
- if(left_bounds(left,right) == interval_bounds::right_open()) //'[(' == 10
+ if(left_bounds(left,right) == interval_bounds::right_open()) //'[(' == 10
return IntervalT::domain_less_equal(left.lower(), right.lower());
else
return IntervalT::domain_less(left.lower(), right.lower());
@@ -222,7 +340,7 @@
typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
upper_less(const IntervalT& left, const IntervalT& right)
{
- if(right_bounds(left,right) == interval_bounds::left_open())
+ if(right_bounds(left,right) == interval_bounds::left_open())
return IntervalT::domain_less_equal(left.upper(), right.upper());
else
return IntervalT::domain_less(left.upper(), right.upper());
@@ -231,37 +349,37 @@
//------------------------------------------------------------------------------
template<class IntervalT>
typename boost::enable_if<has_dynamic_bounds<IntervalT>,
- typename IntervalT::domain_type >::type
+ typename IntervalT::bounded_domain_type >::type
lower_min(const IntervalT& left, const IntervalT& right)
{
- return lower_less(left, right) ? left.lower() : right.lower();
+ return lower_less(left, right) ? bounded_lower(left) : bounded_lower(right);
}
//------------------------------------------------------------------------------
template<class IntervalT>
typename boost::enable_if<has_dynamic_bounds<IntervalT>,
- typename IntervalT::domain_type >::type
+ typename IntervalT::bounded_domain_type >::type
lower_max(const IntervalT& left, const IntervalT& right)
{
- return lower_less(left, right) ? right.lower() : left.lower();
+ return lower_less(left, right) ? bounded_lower(right) : bounded_lower(left);
}
//------------------------------------------------------------------------------
template<class IntervalT>
typename boost::enable_if<has_dynamic_bounds<IntervalT>,
- typename IntervalT::domain_type >::type
+ typename IntervalT::bounded_domain_type >::type
upper_max(const IntervalT& left, const IntervalT& right)
{
- return upper_less(left, right) ? right.upper() : left.upper();
+ return upper_less(left, right) ? bounded_upper(right) : bounded_upper(left);
}
//------------------------------------------------------------------------------
template<class IntervalT>
typename boost::enable_if<has_dynamic_bounds<IntervalT>,
- typename IntervalT::domain_type >::type
+ typename IntervalT::bounded_domain_type >::type
upper_min(const IntervalT& left, const IntervalT& right)
{
- return upper_less(left, right) ? left.upper() : right.upper();
+ return upper_less(left, right) ? bounded_upper(left) : bounded_upper(right);
}
@@ -408,8 +526,8 @@
typedef typename IntervalT::size_type SizeT;
if(itl::is_empty(object))
return itl::neutron<SizeT>::value();
- else if( object.bounds() == interval_bounds::closed()
- && IntervalT::domain_equal(object.lower(), object.upper()))
+ else if( object.bounds() == interval_bounds::closed()
+ && IntervalT::domain_equal(object.lower(), object.upper()))
return itl::unon<SizeT>::value();
else
return infinity<SizeT>::value();
@@ -421,7 +539,7 @@
typename IntervalT::size_type>::type
size(IntervalT object) //JODO conficting with metafunction size<T>::type -> sizetype<T>::type
{
- return cardinality(object);
+ return cardinality(object);
}
//==============================================================================
@@ -463,11 +581,11 @@
else if(itl::is_empty(left))
return right;
- return construct<IntervalT>
+ //JODO return construct<IntervalT,std::less>
+ return construct_interval<IntervalT>::bounded
(
lower_min(left, right),
- upper_max(left, right),
- outer_bounds(left, right).bits()
+ upper_max(left, right)
);
}
@@ -505,11 +623,10 @@
typename boost::enable_if<has_dynamic_bounds<IntervalT>, IntervalT>::type
left_subtract(IntervalT right, const IntervalT& left_minuend)
{
- //JODO
if(exclusive_less(left_minuend, right))
return right;
- return construct<IntervalT>(left_minuend.upper(), right.upper(),
- left_subtract_bounds(right, left_minuend).bits());
+ return construct_interval<IntervalT>::bounded
+ ( reverse_bounded_upper(left_minuend), bounded_upper(right) );
}
@@ -547,8 +664,9 @@
//JODO s.o.
if(exclusive_less(left, right_minuend))
return left;
- return construct<IntervalT>(left.lower(), right_minuend.lower(),
- right_subtract_bounds(left,right_minuend).bits());
+ //JODO return construct<IntervalT,std::less>(left.lower(), right_minuend.lower(),
+ return construct_interval<IntervalT>::bounded
+ ( bounded_lower(left), reverse_bounded_lower(right_minuend) );
}
//==============================================================================
@@ -562,7 +680,7 @@
{
if(itl::is_empty(left) || itl::is_empty(right))
return IntervalT(); //JODO return neutron<IntervalT>::value; neutron for new interval_types.
- else
+ else
return
IntervalT((std::max)(left.lower(), right.lower(), IntervalT::domain_compare()),
(std::min)(left.upper(), right.upper(), IntervalT::domain_compare()));
@@ -582,11 +700,11 @@
if(itl::is_empty(left) || itl::is_empty(right))
return IntervalT(); //JODO return neutron<IntervalT>::value; neutron for new interval_types.
else
- return construct
+ //JODO return construct<IntervalT,std::less>
+ return construct_interval<IntervalT>::bounded
(
lower_max(left, right),
- upper_min(left, right),
- outer_bounds(left, right)
+ upper_min(left, right)
);
}
Modified: sandbox/itl/boost/itl/predicates.hpp
==============================================================================
--- sandbox/itl/boost/itl/predicates.hpp (original)
+++ sandbox/itl/boost/itl/predicates.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -35,14 +35,6 @@
bool(Type::* m_pred)()const;
} ;
- //JODO this clashes with function template itl::empty(IntervalT)
- //template <class Type>
- //class empty: public property<Type>
- //{
- //public:
- // bool operator() (const Type& x)const { return x.empty(); }
- //} ;
-
template <class Type>
struct is_neutron: public property<Type>
{
Modified: sandbox/itl/boost/itl/rightopen_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/rightopen_interval.hpp (original)
+++ sandbox/itl/boost/itl/rightopen_interval.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -61,7 +61,7 @@
domain_type first()const{ return _lwb; }
DomainT last()const
- {
+ { //JODO first and last as global functions?
BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
return pred(_upb);
}
@@ -108,15 +108,6 @@
BOOST_STATIC_CONSTANT(bool, value = true);
};
-/*CL?
-template <class DomainT, ITL_COMPARE Compare>
-struct has_domain<rightopen_interval<DomainT,Compare> >
-{
- typedef has_domain<rightopen_interval<DomainT,Compare> > type;
- BOOST_STATIC_CONSTANT(bool, value = true);
-};
-*/
-
template <class DomainT, ITL_COMPARE Compare>
struct type_to_string<itl::rightopen_interval<DomainT,Compare> >
{
Added: sandbox/itl/boost/itl/type_traits/interval_type_of.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/interval_type_of.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -0,0 +1,32 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_TYPE_TRAITS_INTERVAL_TYPE_OF_HPP_JOFA_100403
+#define BOOST_ITL_TYPE_TRAITS_INTERVAL_TYPE_OF_HPP_JOFA_100403
+
+#include <boost/mpl/if.hpp>
+#include <boost/itl/detail/design_config.hpp>
+#include <boost/itl/continuous_interval.hpp>
+#include <boost/itl/discrete_interval.hpp>
+#include <boost/itl/type_traits/is_continuous.hpp>
+
+namespace boost{ namespace itl
+{
+ template <class DomainT, ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(DomainT,Compare)>
+ struct interval_type_of
+ {
+ typedef
+ typename mpl::if_< is_continuous<DomainT> //JODO add Traits to choose between static and dynamic intervals
+ , continuous_interval<DomainT,Compare>
+ , discrete_interval<DomainT,Compare> >::type type;
+ };
+
+}} // namespace boost itl
+
+#endif
+
+
Modified: sandbox/itl/boost/itl_xt/interval_bitset.hpp
==============================================================================
--- sandbox/itl/boost/itl_xt/interval_bitset.hpp (original)
+++ sandbox/itl/boost/itl_xt/interval_bitset.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -36,14 +36,14 @@
There is a datailed description on how an interval_bitset is
implemented using itl::interval_map in the project section
of the boost book documentation here:
- http://www.herold-faulhaber.de/boost_itl/doc/libs/itl/doc/html/boost_itl/projects.html
+ http://www.joachim-faulhaber.de/boost_itl/doc/libs/itl/doc/html/boost_itl/projects.html
*/
template
<
typename DomainT = unsigned long,
typename BitSetT = itl::bits<unsigned long>,
ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT),
- template<class, ITL_COMPARE>class Interval = boost::itl::interval,
+ ITL_INTERVAL(ITL_COMPARE) Interval = ITL_INTERVAL_INSTANCE(ITL_INTERVAL_DEFAULT, DomainT, Compare), //JODO change to rightopen_interval
ITL_ALLOC Alloc = std::allocator
>
class interval_bitset
@@ -62,11 +62,11 @@
, boost::andable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, DomainT
, boost::xorable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, DomainT
- , boost::addable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, Interval<DomainT,Compare>
- , boost::orable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, Interval<DomainT,Compare>
- , boost::subtractable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, Interval<DomainT,Compare>
- , boost::andable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, Interval<DomainT,Compare>
- , boost::xorable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, Interval<DomainT,Compare>
+ , boost::addable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, ITL_INTERVAL_TYPE(Interval,DomainT,Compare)
+ , boost::orable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, ITL_INTERVAL_TYPE(Interval,DomainT,Compare)
+ , boost::subtractable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, ITL_INTERVAL_TYPE(Interval,DomainT,Compare)
+ , boost::andable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, ITL_INTERVAL_TYPE(Interval,DomainT,Compare)
+ , boost::xorable2 < interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>, ITL_INTERVAL_TYPE(Interval,DomainT,Compare)
> > > > > > > > > > > > > > > > >
//^ & - | + ^ & - | + ^ & - | + < ==
//segment element container
@@ -294,7 +294,7 @@
};
-template<class DomainT, class BitSetT, ITL_COMPARE Compare, template<class, ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+template<class DomainT, class BitSetT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
typename interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>::PartsT
interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>::partition
(
@@ -348,7 +348,7 @@
-template<class DomainT, class BitSetT, ITL_COMPARE Compare, template<class, ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+template<class DomainT, class BitSetT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
bool interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>::contains(const segment_type& segment)const
{
if(segment.empty())
@@ -374,7 +374,7 @@
}
-template<class DomainT, class BitSetT, ITL_COMPARE Compare, template<class, ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+template<class DomainT, class BitSetT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
typename interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>::size_type
interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>::cardinality()const
{
@@ -385,7 +385,7 @@
}
-template<class DomainT, class BitSetT, ITL_COMPARE Compare, template<class, ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+template<class DomainT, class BitSetT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
void interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>::show_segments()const
{
for(typename interval_bitmap_type::const_iterator it_ = _map.begin();
@@ -397,7 +397,7 @@
}
}
-template<class DomainT, class BitSetT, ITL_COMPARE Compare, template<class, ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+template<class DomainT, class BitSetT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
void interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>::show_matrix(const char off_on[2])const
{
typename interval_bitmap_type::const_iterator iter = _map.begin();
@@ -410,7 +410,7 @@
}
}
-template<class DomainT, class BitSetT, ITL_COMPARE Compare, template<class, ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+template<class DomainT, class BitSetT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
bool is_element_equal(const interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>& left,
const interval_bitset<DomainT,BitSetT,Compare,Interval,Alloc>& right)
{ return left == right; }
Modified: sandbox/itl/boost/itl_xt/itvgentor.hpp
==============================================================================
--- sandbox/itl/boost/itl_xt/itvgentor.hpp (original)
+++ sandbox/itl/boost/itl_xt/itvgentor.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -76,19 +76,16 @@
if(decideEmpty==0)
{
ItvDomTV x2 = m_ItvDomTVGentor(m_valueRange);
- //CL x.set(x1, x1-x2, bndTypes); //JODO this should be done smarter
- x = construct<ItvTV>(x1, x1-x2, bndTypes);
+ x = construct<ItvTV>(x1, x1-x2, interval_bounds(bndTypes));
}
else if(upOrDown==0) {
ItvDomTV up
= m_ItvDomTVGentor(x1, static_cast<ItvDomTV>(std::min(m_valueRange.upper(), x1+m_maxIntervalLength)));
- //CL x.set(x1, up, bndTypes);
- x = construct<ItvTV>(x1, up, bndTypes);
+ x = construct<ItvTV>(x1, up, interval_bounds(bndTypes));
} else {
ItvDomTV low
= m_ItvDomTVGentor(static_cast<ItvDomTV>(std::max(m_valueRange.lower(), x1-m_maxIntervalLength)), x1);
- //CL x.set(low, x1, bndTypes);
- x = construct<ItvTV>(low, x1, bndTypes);
+ x = construct<ItvTV>(low, x1, interval_bounds(bndTypes));
}
};
Modified: sandbox/itl/boost/validate/driver/itl_set_driver.hpp
==============================================================================
--- sandbox/itl/boost/validate/driver/itl_set_driver.hpp (original)
+++ sandbox/itl/boost/validate/driver/itl_set_driver.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -30,10 +30,10 @@
setValid(true);
_rootChoice.setSize(RootType::Types_size);
_rootChoice.setMaxWeights(100);
- _rootChoice[RootType::itl_set] = 0; //JODO REV = 25
- _rootChoice[RootType::interval_set] = 33;
- _rootChoice[RootType::separate_interval_set] = 33;
- _rootChoice[RootType::split_interval_set] = 34;
+ _rootChoice[RootType::itl_set] = 25;
+ _rootChoice[RootType::interval_set] = 25;
+ _rootChoice[RootType::separate_interval_set] = 25;
+ _rootChoice[RootType::split_interval_set] = 25;
_rootChoice[RootType::itl_map] = 0;
_rootChoice[RootType::interval_map] = 0;
_rootChoice[RootType::split_interval_map] = 0;
@@ -93,7 +93,7 @@
algebra_validater* chooseValidater()
{
- typedef double intT; //JODO REV
+ typedef int intT;
typedef double doubleT;
int rootChoice = _rootChoice.some();
@@ -103,15 +103,14 @@
switch(rootChoice)
{
- //JODO REV
- //case RootType::itl_set: {
- // switch(domainChoice) {
- // case DomainType::Int: return new itl_set_validater<itl::set<int> >;
- // case DomainType::Double: return new itl_set_validater<itl::set<double> >;
- // default: return choiceError(ITL_LOCATION("\nRootType::itl_set: domainChoice:\n"),
- // domainChoice, _domainChoice);
- // }
- // }
+ case RootType::itl_set: {
+ switch(domainChoice) {
+ case DomainType::Int: return new itl_set_validater<itl::set<int> >;
+ case DomainType::Double: return new itl_set_validater<itl::set<double> >;
+ default: return choiceError(ITL_LOCATION("\nRootType::itl_set: domainChoice:\n"),
+ domainChoice, _domainChoice);
+ }
+ }
case RootType::interval_set: {
switch(domainChoice) {
case DomainType::Int: return new itl_set_validater<interval_set<intT> >;
Modified: sandbox/itl/boost/validate/driver/map_copy_conformity_driver.hpp
==============================================================================
--- sandbox/itl/boost/validate/driver/map_copy_conformity_driver.hpp (original)
+++ sandbox/itl/boost/validate/driver/map_copy_conformity_driver.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -112,20 +112,20 @@
//-----------------------------------------------------------------
case RootType::interval_map: {
switch(neutronizerChoice) {
- case NeutronHandlerType::partial_absorber: return new function_equality_validater<itl::list<std::pair<ITL_INTERVAL_DEFAULT<double>,int> >, interval_map<double,int,partial_absorber> >;
- case NeutronHandlerType::partial_enricher: return new function_equality_validater<itl::list<std::pair<ITL_INTERVAL_DEFAULT<double>,int> >, interval_map<double,int,partial_enricher> >;
- case NeutronHandlerType::total_absorber: return new function_equality_validater<itl::list<std::pair<ITL_INTERVAL_DEFAULT<int>, int> >, interval_map<int, int,total_absorber > >;
- case NeutronHandlerType::total_enricher: return new function_equality_validater<itl::list<std::pair<ITL_INTERVAL_DEFAULT<int>, int> >, interval_map<int, int,total_enricher > >;
+ case NeutronHandlerType::partial_absorber: return new function_equality_validater<itl::list<std::pair<ITL_contin_INTERVAL_DEF<double,std::less>,int> >, interval_map<double,int,partial_absorber> >;
+ case NeutronHandlerType::partial_enricher: return new function_equality_validater<itl::list<std::pair<ITL_contin_INTERVAL_DEF<double,std::less>,int> >, interval_map<double,int,partial_enricher> >;
+ case NeutronHandlerType::total_absorber: return new function_equality_validater<itl::list<std::pair<ITL_discrt_INTERVAL_DEF<int,std::less>, int> >, interval_map<int, int,total_absorber > >;
+ case NeutronHandlerType::total_enricher: return new function_equality_validater<itl::list<std::pair<ITL_discrt_INTERVAL_DEF<int,std::less>, int> >, interval_map<int, int,total_enricher > >;
default: return choiceError(ITL_LOCATION("\nRootType::interval_map: neutronizerChoice:\n"), neutronizerChoice, _neutronizerChoice);
}//switch neutronizerChoice
}//case interval_map
//-----------------------------------------------------------------
case RootType::split_interval_map: {
switch(neutronizerChoice) {
- case NeutronHandlerType::partial_absorber: return new function_equality_validater<itl::list<std::pair<ITL_INTERVAL_DEFAULT<double>,int> >, split_interval_map<double,int,partial_absorber> >;
- case NeutronHandlerType::partial_enricher: return new function_equality_validater<itl::list<std::pair<ITL_INTERVAL_DEFAULT<int>, int> >, split_interval_map<int, int,partial_enricher> >;
- case NeutronHandlerType::total_absorber: return new function_equality_validater<itl::list<std::pair<ITL_INTERVAL_DEFAULT<double>,int> >, split_interval_map<double,int,total_absorber > >;
- case NeutronHandlerType::total_enricher: return new function_equality_validater<itl::list<std::pair<ITL_INTERVAL_DEFAULT<int>, int> >, split_interval_map<int, int,total_enricher > >;
+ case NeutronHandlerType::partial_absorber: return new function_equality_validater<itl::list<std::pair<ITL_contin_INTERVAL_DEF<double,std::less>,int> >, split_interval_map<double,int,partial_absorber> >;
+ case NeutronHandlerType::partial_enricher: return new function_equality_validater<itl::list<std::pair<ITL_discrt_INTERVAL_DEF<int,std::less>, int> >, split_interval_map<int, int,partial_enricher> >;
+ case NeutronHandlerType::total_absorber: return new function_equality_validater<itl::list<std::pair<ITL_contin_INTERVAL_DEF<double,std::less>,int> >, split_interval_map<double,int,total_absorber > >;
+ case NeutronHandlerType::total_enricher: return new function_equality_validater<itl::list<std::pair<ITL_discrt_INTERVAL_DEF<int,std::less>, int> >, split_interval_map<int, int,total_enricher > >;
default: return choiceError(ITL_LOCATION("\nRootType::split_interval_map: neutronizerChoice:\n"), neutronizerChoice, _neutronizerChoice);
}//switch neutronizerChoice
}//case split_interval_map
Modified: sandbox/itl/boost/validate/gentor/randomgentor.hpp
==============================================================================
--- sandbox/itl/boost/validate/gentor/randomgentor.hpp (original)
+++ sandbox/itl/boost/validate/gentor/randomgentor.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -54,9 +54,13 @@
public bits_gentor<itl::bits<NaturalT> > {};
// -------------------------------------------------------------------------
- template <class DomainT>
- class RandomGentor<ITL_INTERVAL_DEFAULT<DomainT> > :
- public ItvGentorT<DomainT> {};
+ template <class DomainT, ITL_COMPARE Compare>
+ class RandomGentor<continuous_interval<DomainT,Compare> > :
+ public ItvGentorT<DomainT, continuous_interval<DomainT,Compare> > {};
+
+ template <class DomainT, ITL_COMPARE Compare>
+ class RandomGentor<discrete_interval<DomainT,Compare> > :
+ public ItvGentorT<DomainT, discrete_interval<DomainT,Compare> > {};
// -------------------------------------------------------------------------
template <class DomainT, class CodomainT>
@@ -80,27 +84,35 @@
#endif //LAW_BASED_TEST_BOOST_POLYGON
// ----- lists -------------------------------------------------------------
- template <class DomainT, class CodomainT>
- class RandomGentor<std::pair<ITL_INTERVAL_DEFAULT<DomainT>, CodomainT> > :
- public map_segment_gentor<DomainT,CodomainT> {};
-
- template <class DomainT, class CodomainT>
- class RandomGentor<itl::list<std::pair<ITL_INTERVAL_DEFAULT<DomainT>, CodomainT> > > :
- public SeqGentorT<itl::list<std::pair<ITL_INTERVAL_DEFAULT<DomainT>, CodomainT> > > {};
+ template <class DomainT, class CodomainT, ITL_COMPARE Compare>
+ class RandomGentor<std::pair<discrete_interval<DomainT,Compare>, CodomainT> > :
+ public map_segment_gentor<DomainT,CodomainT,discrete_interval<DomainT,Compare> > {};
+
+ template <class DomainT, class CodomainT, ITL_COMPARE Compare>
+ class RandomGentor<std::pair<continuous_interval<DomainT,Compare>, CodomainT> > :
+ public map_segment_gentor<DomainT,CodomainT,continuous_interval<DomainT,Compare> > {};
+
+ template <class DomainT, class CodomainT, ITL_COMPARE Compare>
+ class RandomGentor<itl::list<std::pair<discrete_interval<DomainT,Compare>, CodomainT> > > :
+ public SeqGentorT<itl::list<std::pair<discrete_interval<DomainT,Compare>, CodomainT> > > {};
+
+ template <class DomainT, class CodomainT, ITL_COMPARE Compare>
+ class RandomGentor<itl::list<std::pair<continuous_interval<DomainT,Compare>, CodomainT> > > :
+ public SeqGentorT<itl::list<std::pair<continuous_interval<DomainT,Compare>, CodomainT> > > {};
template <class DomainT, class CodomainT>
class RandomGentor<itl::list<std::pair<DomainT,CodomainT> > > :
public SeqGentorT<itl::list<std::pair<DomainT,CodomainT> > > {};
- template <class DomainT>
- class RandomGentor<itl::list<ITL_INTERVAL_DEFAULT<DomainT> > > :
- public SeqGentorT<itl::list<ITL_INTERVAL_DEFAULT<DomainT> > > {};
+ template <class DomainT, ITL_COMPARE Compare>
+ class RandomGentor<itl::list<discrete_interval<DomainT,Compare> > > :
+ public SeqGentorT<itl::list<discrete_interval<DomainT,Compare> > > {};
+
+ template <class DomainT, ITL_COMPARE Compare>
+ class RandomGentor<itl::list<continuous_interval<DomainT,Compare> > > :
+ public SeqGentorT<itl::list<continuous_interval<DomainT,Compare> > > {};
// ----- sets --------------------------------------------------------------
- //template <class DomainT, template<class>class Set>
- //class RandomGentor<Set<DomainT> > :
- // public SetGentorT<Set<DomainT> > {};
-
template <class DomainT>
class RandomGentor<itl::set<DomainT> > :
public SetGentorT<itl::set<DomainT> > {};
@@ -253,10 +265,10 @@
};
- template <>
- struct Calibrater<ITL_INTERVAL_DEFAULT<int>, RandomGentor>
+ template <ITL_COMPARE Compare>
+ struct Calibrater<discrete_interval<int,Compare>, RandomGentor>
{
- static void apply(RandomGentor<ITL_INTERVAL_DEFAULT<int> >& gentor)
+ static void apply(RandomGentor<discrete_interval<int,Compare> >& gentor)
{
// Set the range within which the sizes of the generated object varies.
gentor.setRange(GentorProfileSgl::it()->range_int());
@@ -333,26 +345,26 @@
}
};
- template <>
- struct Calibrater<std::pair<ITL_INTERVAL_DEFAULT<int>, int>, RandomGentor>
+ template <ITL_COMPARE Compare>
+ struct Calibrater<std::pair<discrete_interval<int,Compare>, int>, RandomGentor>
{
- static void apply(RandomGentor< std::pair<ITL_INTERVAL_DEFAULT<int>, int> >&){}
+ static void apply(RandomGentor< std::pair<discrete_interval<int,Compare>, int> >&){}
};
- template <>
- struct Calibrater<std::pair<ITL_INTERVAL_DEFAULT<double>, int>, RandomGentor>
+ template <ITL_COMPARE Compare>
+ struct Calibrater<std::pair<continuous_interval<double,Compare>, int>, RandomGentor>
{
- static void apply(RandomGentor< std::pair<ITL_INTERVAL_DEFAULT<double>, int> >&){}
+ static void apply(RandomGentor< std::pair<continuous_interval<double,Compare>, int> >&){}
};
- template <>
- struct Calibrater<itl::list<std::pair<ITL_INTERVAL_DEFAULT<double>, int> >, RandomGentor>
+ template <ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct Calibrater<itl::list<std::pair<Interval, int> >, RandomGentor>
{
- static void apply(RandomGentor< itl::list<std::pair<ITL_INTERVAL_DEFAULT<double>, int> > >& gentor)
+ static void apply(RandomGentor< itl::list<std::pair<Interval, int> > >& gentor)
{
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
- map_segment_gentor<double,int,ITL_INTERVAL_DEFAULT<double> >* segment_gentor
- = new map_segment_gentor<double,int,ITL_INTERVAL_DEFAULT<double> >;
+ map_segment_gentor<double,int,Interval >* segment_gentor
+ = new map_segment_gentor<double,int,Interval >;
NumberGentorT<int>* int_gentor = new NumberGentorT<int>;
int_gentor->setRange(GentorProfileSgl::it()->range_int());
segment_gentor->setCodomainGentor(int_gentor);
@@ -363,14 +375,28 @@
}
};
- template <class NumericT>
- struct Calibrater<itl::list< ITL_INTERVAL_DEFAULT<NumericT> >, RandomGentor>
+ template <class NumericT, ITL_COMPARE Compare>
+ struct Calibrater<itl::list< continuous_interval<NumericT,Compare> >, RandomGentor>
+ {
+ static void apply(RandomGentor< itl::list< continuous_interval<NumericT,Compare> > >& gentor)
+ {
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+ ItvGentorT<NumericT, continuous_interval<NumericT,Compare> >* itvGentor
+ = new ItvGentorT<NumericT, continuous_interval<NumericT,Compare> >;
+ itvGentor->setRange(GentorProfileSgl_numeric_range<NumericT>::get());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
+ gentor.setDomainGentor(itvGentor);
+ }
+ };
+
+ template <class NumericT, ITL_COMPARE Compare>
+ struct Calibrater<itl::list< discrete_interval<NumericT,Compare> >, RandomGentor>
{
- static void apply(RandomGentor< itl::list< ITL_INTERVAL_DEFAULT<NumericT> > >& gentor)
+ static void apply(RandomGentor< itl::list< discrete_interval<NumericT,Compare> > >& gentor)
{
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
- ItvGentorT<NumericT, ITL_INTERVAL_DEFAULT<NumericT> >* itvGentor
- = new ItvGentorT<NumericT, ITL_INTERVAL_DEFAULT<NumericT> >;
+ ItvGentorT<NumericT, discrete_interval<NumericT,Compare> >* itvGentor
+ = new ItvGentorT<NumericT, discrete_interval<NumericT,Compare> >;
itvGentor->setRange(GentorProfileSgl_numeric_range<NumericT>::get());
itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
gentor.setDomainGentor(itvGentor);
@@ -406,14 +432,14 @@
}
};
- template <>
- struct Calibrater<itl::list<std::pair<ITL_INTERVAL_DEFAULT<int>, int> >, RandomGentor>
+ template <ITL_COMPARE Compare>
+ struct Calibrater<itl::list<std::pair<discrete_interval<int,Compare>, int> >, RandomGentor>
{
- static void apply(RandomGentor< itl::list<std::pair<ITL_INTERVAL_DEFAULT<int>, int> > >& gentor)
+ static void apply(RandomGentor< itl::list<std::pair<discrete_interval<int,Compare>, int> > >& gentor)
{
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
- map_segment_gentor<int,int,ITL_INTERVAL_DEFAULT<int> >* segment_gentor
- = new map_segment_gentor<int,int,ITL_INTERVAL_DEFAULT<int> >;
+ map_segment_gentor<int,int,discrete_interval<int,Compare> >* segment_gentor
+ = new map_segment_gentor<int,int,discrete_interval<int,Compare> >;
NumberGentorT<int>* int_gentor = new NumberGentorT<int>;
int_gentor->setRange(GentorProfileSgl::it()->range_int());
segment_gentor->setCodomainGentor(int_gentor);
@@ -451,131 +477,51 @@
}
};
- //--------------------------------------------------------------------------
- template <>
- struct Calibrater<interval_set<int>, RandomGentor>
- {
- static void apply(RandomGentor<interval_set<int> >& gentor)
- {
- gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
- ItvGentorT<int, ITL_INTERVAL_DEFAULT<int> >* itvGentor
- = new ItvGentorT<int, ITL_INTERVAL_DEFAULT<int> >;
- interval<int> valRange = GentorProfileSgl::it()->range_interval_int();
- itvGentor->setValueRange(valRange.lower(), valRange.upper());
- itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
- gentor.setDomainGentor(itvGentor);
- }
- };
-
- template <>
- struct Calibrater<interval_set<double>, RandomGentor>
- {
- static void apply(RandomGentor<interval_set<double> >& gentor)
- {
- gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
- ItvGentorT<double, ITL_INTERVAL_DEFAULT<double> >* itvGentor
- = new ItvGentorT<double, ITL_INTERVAL_DEFAULT<double> >;
- interval<double> valRange = GentorProfileSgl::it()->range_interval_double();
- itvGentor->setValueRange(valRange.lower(), valRange.upper());
- itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
- gentor.setDomainGentor(itvGentor);
- }
- };
-
- template <>
- struct Calibrater<separate_interval_set<int>, RandomGentor>
- {
- static void apply(RandomGentor<separate_interval_set<int> >& gentor)
- {
- gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
- ItvGentorT<int, ITL_INTERVAL_DEFAULT<int> >* itvGentor
- = new ItvGentorT<int, ITL_INTERVAL_DEFAULT<int> >;
- interval<int> valRange = GentorProfileSgl::it()->range_interval_int();
- itvGentor->setValueRange(valRange.lower(), valRange.upper());
- itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
- gentor.setDomainGentor(itvGentor);
- }
- };
-
- template <>
- struct Calibrater<separate_interval_set<double>, RandomGentor>
+ //----------------------------------------------------------------------------
+ // itl::{,separate,split}_interval_set<NumericDomainT>
+ //----------------------------------------------------------------------------
+ template <class NumericDomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct Calibrater<interval_set<NumericDomainT,Compare,Interval>, RandomGentor>
{
- static void apply(RandomGentor<separate_interval_set<double> >& gentor)
+ static void apply(RandomGentor<interval_set<NumericDomainT,Compare,Interval> >& gentor)
{
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
-
- // If it is a container: (Create and) Pass the generator(s) for their contents
- // NumberGentorT<int> intGentor;
- ItvGentorT<double, ITL_INTERVAL_DEFAULT<double> >* itvGentor
- = new ItvGentorT<double, ITL_INTERVAL_DEFAULT<double> >;
- interval<double> valRange = GentorProfileSgl::it()->range_interval_double();
- itvGentor->setValueRange(valRange.lower(), valRange.upper());
- itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
- gentor.setDomainGentor(itvGentor);
+ ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >* domainGentor
+ = new ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >;
+ domainGentor->setRange(GentorProfileSgl_numeric_range<NumericDomainT>::get());
+ domainGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
+ gentor.setDomainGentor(domainGentor);
}
};
- template <>
- struct Calibrater<split_interval_set<int>, RandomGentor>
+ template <class NumericDomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct Calibrater<separate_interval_set<NumericDomainT,Compare,Interval>, RandomGentor>
{
- static void apply(RandomGentor<split_interval_set<int> >& gentor)
+ static void apply(RandomGentor<separate_interval_set<NumericDomainT,Compare,Interval> >& gentor)
{
- // Set the range within which the sizes of the generated object varies.
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
-
- // If it is a container: (Create and) Pass the generator(s) for their contents
- // NumberGentorT<int> intGentor;
- ItvGentorT<int, ITL_INTERVAL_DEFAULT<int> >* itvGentor
- = new ItvGentorT<int, ITL_INTERVAL_DEFAULT<int> >;
- interval<int> valRange = GentorProfileSgl::it()->range_interval_int();
- itvGentor->setValueRange(valRange.lower(), valRange.upper());
- itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
- gentor.setDomainGentor(itvGentor);
+ ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >* domainGentor
+ = new ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >;
+ domainGentor->setRange(GentorProfileSgl_numeric_range<NumericDomainT>::get());
+ domainGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
+ gentor.setDomainGentor(domainGentor);
}
};
- template <>
- struct Calibrater<split_interval_set<double>, RandomGentor>
+ template <class NumericDomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct Calibrater<split_interval_set<NumericDomainT,Compare,Interval>, RandomGentor>
{
- static void apply(RandomGentor<split_interval_set<double> >& gentor)
+ static void apply(RandomGentor<split_interval_set<NumericDomainT,Compare,Interval> >& gentor)
{
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
-
- // If it is a container: (Create and) Pass the generator(s) for their contents
- // NumberGentorT<int> intGentor;
- ItvGentorT<double, ITL_INTERVAL_DEFAULT<double> >* itvGentor
- = new ItvGentorT<double, ITL_INTERVAL_DEFAULT<double> >;
- interval<double> valRange = GentorProfileSgl::it()->range_interval_double();
- itvGentor->setValueRange(valRange.lower(), valRange.upper());
- itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
- gentor.setDomainGentor(itvGentor);
+ ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >* domainGentor
+ = new ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >;
+ domainGentor->setRange(GentorProfileSgl_numeric_range<NumericDomainT>::get());
+ domainGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
+ gentor.setDomainGentor(domainGentor);
}
};
-
- // template <class IntegralT, class BitSetT>
- // struct Calibrater<interval_bitset<IntegralT, BitSetT>, RandomGentor>
- // {
- // //static void apply(RandomGentor<interval_bitset<IntegralT, BitSetT> >& gentor)
- // //{
- // // gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
- // // ItvGentorT<IntegralT>* itvGentor = new ItvGentorT<IntegralT>;
- // // interval<IntegralT> valRange = GentorProfileSgl_numeric_range<IntegralT>::get();
- // // itvGentor->setValueRange(valRange.lower(), valRange.upper());
- // // itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
- // // gentor.setDomainGentor(itvGentor);
- // //}
- ////JODO
- // static void apply(RandomGentor<interval_bitset<IntegralT,BitSetT> >& gentor)
- // {
- // gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
- // NumberGentorT<IntegralT>* domainGentor = new NumberGentorT<IntegralT>;
- // domainGentor->setRange(GentorProfileSgl::it()->range_int());
- // gentor.setDomainGentor(domainGentor);
- // }
- // };
-
-
//--------------------------------------------------------------------------
// itl::tree
//--------------------------------------------------------------------------
@@ -586,8 +532,8 @@
static void apply(RandomGentor<itl::tree<int> >& gentor)
{
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
- ItvGentorT<int, ITL_INTERVAL_DEFAULT<int> >* itvGentor
- = new ItvGentorT<int, ITL_INTERVAL_DEFAULT<int> >;
+ ItvGentorT<int, discrete_interval<int,Compare> >* itvGentor
+ = new ItvGentorT<int, discrete_interval<int,Compare> >;
interval<int> valRange = GentorProfileSgl::it()->range_interval_int();
itvGentor->setValueRange(valRange.lower(), valRange.upper());
itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
@@ -666,19 +612,22 @@
//----------------------------------------------------------------------------
// itl::interval_map<DomainT,CodomainT,Neutronizer>
//----------------------------------------------------------------------------
- template <class NumericDomainT, class Neutronizer>
- struct Calibrater<interval_map<NumericDomainT,itl::set<int>,Neutronizer>, RandomGentor>
+ template <class NumericDomainT, class Neutronizer,
+ ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section,
+ ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct Calibrater<interval_map<NumericDomainT,itl::set<int>,
+ Neutronizer,Compare,Combine,Section,
+ Interval >, RandomGentor>
{
- static void apply(RandomGentor<interval_map<NumericDomainT,itl::set<int>,Neutronizer> >& gentor)
+ static void apply(RandomGentor<interval_map<NumericDomainT,itl::set<int>,
+ Neutronizer,Compare,Combine,Section,
+ Interval > >& gentor)
{
// Set the range within which the sizes of the generated object varies.
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
- // If it is a container: (Create and) Pass the generator(s) for their contents
- // NumberGentorT<int> intGentor;
- //CL ItvGentorT<NumericDomainT>* itvGentor = new ItvGentorT<NumericDomainT>;
- ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >* itvGentor
- = new ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >;
+ ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >* itvGentor
+ = new ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >;
interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
itvGentor->setValueRange(valRange.lower(), valRange.upper());
itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
@@ -695,18 +644,24 @@
}
};
- template <typename NumericDomainT, typename NumericCodomainT, class Neutronizer>
- struct Calibrater<interval_map<NumericDomainT,NumericCodomainT,Neutronizer>, RandomGentor>
+ template <typename NumericDomainT, typename NumericCodomainT, class Neutronizer,
+ ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section,
+ ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct Calibrater<interval_map<NumericDomainT,NumericCodomainT,
+ Neutronizer,Compare,Combine,Section,
+ Interval >, RandomGentor>
{
- static void apply(RandomGentor<interval_map<NumericDomainT,NumericCodomainT,Neutronizer> >& gentor)
+ static void apply(RandomGentor<interval_map<NumericDomainT,NumericCodomainT,
+ Neutronizer,Compare,Combine,Section,
+ Interval > >& gentor)
{
// Set the range within which the sizes of the generated object varies.
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
// If it is a container: (Create and) Pass the generator(s) for their contents
// NumberGentorT<int> intGentor;
- ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >* itvGentor
- = new ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >;
+ ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >* itvGentor
+ = new ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >;
interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
itvGentor->setValueRange(valRange.lower(), valRange.upper());
itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
@@ -722,17 +677,23 @@
//----------------------------------------------------------------------------
// itl::split_interval_map<DomainT,CodomainT,Neutronizer>
//----------------------------------------------------------------------------
- template <class NumericDomainT, class Neutronizer>
- struct Calibrater<split_interval_map<NumericDomainT,itl::set<int>,Neutronizer>, RandomGentor>
+ template <class NumericDomainT, class Neutronizer,
+ ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section,
+ ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct Calibrater<split_interval_map<NumericDomainT,itl::set<int>,
+ Neutronizer,Compare,Combine,Section,
+ Interval >, RandomGentor>
{
- static void apply(RandomGentor<split_interval_map<NumericDomainT,itl::set<int>,Neutronizer> >& gentor)
+ static void apply(RandomGentor<split_interval_map<NumericDomainT,itl::set<int>,
+ Neutronizer,Compare,Combine,Section,
+ Interval > >& gentor)
{
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
// If it is a container: (Create and) Pass the generator(s) for their contents
// NumberGentorT<int> intGentor;
- ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >* itvGentor
- = new ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >;
+ ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >* itvGentor
+ = new ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >;
interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
itvGentor->setValueRange(valRange.lower(), valRange.upper());
itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
@@ -750,18 +711,23 @@
};
template <typename NumericDomainT, typename NumericCodomainT, class Neutronizer,
- ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section>
- struct Calibrater<split_interval_map<NumericDomainT,NumericCodomainT,Neutronizer,Compare,Combine,Section>, RandomGentor>
+ ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section,
+ ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct Calibrater<split_interval_map<NumericDomainT,NumericCodomainT,
+ Neutronizer,Compare,Combine,Section,
+ Interval >, RandomGentor>
{
- static void apply(RandomGentor<split_interval_map<NumericDomainT,NumericCodomainT,Neutronizer,Compare,Combine,Section> >& gentor)
+ static void apply(RandomGentor<split_interval_map<NumericDomainT,NumericCodomainT,
+ Neutronizer,Compare,Combine,Section,
+ Interval > >& gentor)
{
// Set the range within which the sizes of the generated object varies.
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
// If it is a container: (Create and) Pass the generator(s) for their contents
// NumberGentorT<int> intGentor;
- ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >* itvGentor
- = new ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >;
+ ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >* itvGentor
+ = new ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >;
interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
itvGentor->setValueRange(valRange.lower(), valRange.upper());
itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
@@ -776,19 +742,22 @@
template <typename NumericDomainT, typename BitsT, class Neutronizer,
- ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section>
+ ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section,
+ ITL_INTERVAL(ITL_COMPARE) Interval>
struct Calibrater<interval_map<NumericDomainT,itl::bits<BitsT>,
- Neutronizer,Compare,Combine,Section>, RandomGentor>
+ Neutronizer,Compare,Combine,Section,
+ Interval >, RandomGentor>
{
static void apply(RandomGentor<interval_map<NumericDomainT,itl::bits<BitsT>,
- Neutronizer,Compare,Combine,Section> >& gentor)
+ Neutronizer,Compare,Combine,Section,
+ Interval > >& gentor)
{
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
// If it is a container: (Create and) Pass the generator(s) for their contents
// NumberGentorT<int> intGentor;
- ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >* itvGentor
- = new ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >;
+ ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >* itvGentor
+ = new ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >;
interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
itvGentor->setValueRange(valRange.lower(), valRange.upper());
itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
@@ -801,20 +770,24 @@
}
};
+
template <typename NumericDomainT, typename BitsT, class Neutronizer,
- ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section>
+ ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section,
+ ITL_INTERVAL(ITL_COMPARE) Interval>
struct Calibrater<split_interval_map<NumericDomainT,itl::bits<BitsT>,
- Neutronizer,Compare,Combine,Section>, RandomGentor>
+ Neutronizer,Compare,Combine,Section,
+ Interval >, RandomGentor>
{
static void apply(RandomGentor<split_interval_map<NumericDomainT,itl::bits<BitsT>,
- Neutronizer,Compare,Combine,Section> >& gentor)
+ Neutronizer,Compare,Combine,Section,
+ Interval > >& gentor)
{
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
// If it is a container: (Create and) Pass the generator(s) for their contents
// NumberGentorT<int> intGentor;
- ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >* itvGentor
- = new ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >;
+ ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >* itvGentor
+ = new ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >;
interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
itvGentor->setValueRange(valRange.lower(), valRange.upper());
itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
@@ -828,17 +801,20 @@
};
// ---------------------------------------------------------------------------
- template <typename NumericDomainT, typename BitsT>
- struct Calibrater<interval_bitset<NumericDomainT,itl::bits<BitsT> >, RandomGentor>
+ template <typename NumericDomainT, typename BitsT,
+ ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval>
+ struct Calibrater<interval_bitset<NumericDomainT,itl::bits<BitsT>,
+ Compare, Interval >, RandomGentor>
{
- static void apply(RandomGentor<interval_bitset<NumericDomainT,itl::bits<BitsT> > >& gentor)
+ static void apply(RandomGentor<interval_bitset<NumericDomainT,itl::bits<BitsT>,
+ Compare, Interval> >& gentor)
{
gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
// If it is a container: (Create and) Pass the generator(s) for their contents
// NumberGentorT<int> intGentor;
- ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >* itvGentor
- = new ItvGentorT<NumericDomainT, ITL_INTERVAL_DEFAULT<NumericDomainT> >;
+ ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >* itvGentor
+ = new ItvGentorT<NumericDomainT, ITL_INTERVAL_TYPE(Interval,NumericDomainT,Compare) >;
interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
itvGentor->setValueRange(valRange.lower(), valRange.upper());
itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
Modified: sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp (original)
+++ sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -92,9 +92,105 @@
BOOST_CHECK_EQUAL(is_continuous_interval<continuous_interval<double> >::value, true);
}
+/*JODO move to proper tests??
+BOOST_AUTO_TEST_CASE(casual)
+{
+ cout << left_bracket(interval_bounds(closed_bounded)) << endl;
+ cout << left_bracket(interval_bounds(right_open)) << endl;
+ cout << left_bracket(interval_bounds(left_open)) << endl;
+ cout << left_bracket(interval_bounds(open_bounded)) << endl;
+
+ cout << right_bracket(interval_bounds(closed_bounded)) << endl;
+ cout << right_bracket(interval_bounds(right_open)) << endl;
+ cout << right_bracket(interval_bounds(left_open)) << endl;
+ cout << right_bracket(interval_bounds(open_bounded)) << endl;
+
+ //continuous_interval<double> a_1 = continuous_interval<double>(0.0, 3.0, interval_bounds::left_open());
+ continuous_interval<double> a_1 = continuous_interval<double>(-5.0, -2.3, interval_bounds::closed());
+ continuous_interval<double> b_1 = continuous_interval<double>(-2.6, 4.0, interval_bounds::closed());
+
+ split_interval_set<double> a, b, a_o_b, b_o_a;
+ a_o_b += a_1;
+ a_o_b += b_1;
+
+ b_o_a += b_1;
+ b_o_a += a_1;
+
+ cout << "a+b =" << a_o_b << endl;
+ cout << "b+a =" << b_o_a << endl;
+
+ cout << "-------------------------------------------------\n";
+ continuous_interval<double> c_1 = continuous_interval<double>(1.0, 3.0, interval_bounds::closed());
+ continuous_interval<double> b_2 = right_subtract(b_1, c_1);
+
+ cout << b_2 << endl;
+
+ cout << "-------------------------------------------------\n";
+ continuous_interval<double> L0T = continuous_interval<double>(0.0, 0.0, interval_bounds::closed());
+ continuous_interval<double> C0T = continuous_interval<double>(0.0, 0.0, interval_bounds::left_open());
+ continuous_interval<double> L0D = continuous_interval<double>(0.0, 0.0, interval_bounds::right_open());
+ continuous_interval<double> C0D = continuous_interval<double>(0.0, 0.0, interval_bounds::open());
+
+ BOOST_CHECK_EQUAL(itl::is_empty(L0T), false);
+ BOOST_CHECK_EQUAL(itl::is_empty(C0T), true);
+ BOOST_CHECK_EQUAL(itl::is_empty(L0D), true);
+ BOOST_CHECK_EQUAL(itl::is_empty(C0D), true);
+
+
+ continuous_interval<double> L0_1T = continuous_interval<double>(0.0, 1.0, interval_bounds::closed());
+ continuous_interval<double> L1_2T = continuous_interval<double>(1.0, 2.0, interval_bounds::closed());
+ BOOST_CHECK_EQUAL(itl::exclusive_less(L0_1T, L1_2T), false);
+ BOOST_CHECK_EQUAL(itl::inner_bounds(L0_1T, L1_2T) == interval_bounds::open(), true);
+
+ continuous_interval<double> L0_1D = continuous_interval<double>(0.0, 1.0, interval_bounds::right_open());
+ BOOST_CHECK_EQUAL(itl::exclusive_less(L0_1D, L1_2T), true);
+ BOOST_CHECK_EQUAL(itl::inner_bounds(L0_1D, L1_2T) == interval_bounds::right_open(), true);
+
+ continuous_interval<double> C1_2T = continuous_interval<double>(1.0, 2.0, interval_bounds::left_open());
+ BOOST_CHECK_EQUAL(itl::exclusive_less(L0_1T, C1_2T), true);
+ BOOST_CHECK_EQUAL(itl::inner_bounds(L0_1T, C1_2T) == interval_bounds::left_open(), true);
+
+ BOOST_CHECK_EQUAL(itl::exclusive_less(L0_1D, C1_2T), true);
+ BOOST_CHECK_EQUAL(itl::inner_bounds(L0_1D, C1_2T) == interval_bounds::closed(), true);
+
+ //BOOST_CHECK_EQUAL(itl::is_empty(conterval), true);
+}
+
+BOOST_AUTO_TEST_CASE(test_interval_bounds)
+{
+ continuous_interval<double> L0_1T = continuous_interval<double>(0.0, 1.0, interval_bounds::closed());
+ continuous_interval<double> L0_1D = continuous_interval<double>(0.0, 1.0, interval_bounds::right_open());
+
+ cout << "itl::right(L0_1T) = " << static_cast<int>(itl::right(L0_1T.bounds()).bits()) << endl;
+ cout << "itl::right(L0_1D) = " << static_cast<int>(itl::right(L0_1D.bounds()).bits()) << endl;
+
+ BOOST_CHECK_EQUAL(itl::right_bounds(L0_1D, L0_1T), interval_bounds::left_open());
+}
+
+BOOST_AUTO_TEST_CASE(casual)
+{
+ separate_interval_set<double> a, b;
+
+ continuous_interval<double> L0_1T = continuous_interval<double>(0.0, 1.0, interval_bounds::closed());
+ continuous_interval<double> L0_1D = continuous_interval<double>(0.0, 1.0, interval_bounds::right_open());
+
+ a += L0_1T;
+ a += L0_1D;
+ cout << a << endl;
+
+ b += L0_1D;
+ b += L0_1T;
+ cout << b << endl;
+
+ cout << "double has "
+ << (numeric_limits<double>::has_infinity ? "inf: " : "NO inf: ")
+ << numeric_limits<double>::infinity()
+ << endl;
+}
+*/
+
+
BOOST_AUTO_TEST_CASE(casual)
{
- continuous_interval<double> conterval;
- BOOST_CHECK_EQUAL(itl::is_empty(conterval), true);
}
Modified: sandbox/itl/libs/itl/test/test_continuous_interval_/test_continuous_interval.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_continuous_interval_/test_continuous_interval.cpp (original)
+++ sandbox/itl/libs/itl/test/test_continuous_interval_/test_continuous_interval.cpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -24,7 +24,6 @@
#include "../test_itl_interval_shared.hpp"
-//CL #include "../test_itl_interval.hpp"
#define ORDERED_TYPES continuous_types
#define BICREMENTAL_TYPES bicremental_continuous_types
Modified: sandbox/itl/libs/itl/test/test_itl_interval.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_itl_interval.hpp (original)
+++ sandbox/itl/libs/itl/test/test_itl_interval.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -412,7 +412,7 @@
template <class T>
void interval_inner_complement_4_bicremental_types()
{
- test_inner_complement(interval<T>(), interval<T>());
+ test_inner_complement(interval<T>(), interval<T>());
test_inner_complement(interval<T>(), I_D(6,9));
test_inner_complement(C_D(2,4), interval<T>());
test_inner_complement(I_I(2,5), C_I(3,9));
Modified: sandbox/itl/libs/itl/test/test_itl_interval_shared.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_itl_interval_shared.hpp (original)
+++ sandbox/itl/libs/itl/test/test_itl_interval_shared.hpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -8,7 +8,6 @@
#ifndef __test_itl_interval_shared_hpp_JOFA_100306__
#define __test_itl_interval_shared_hpp_JOFA_100306__
-//CL #include <boost/itl/interval.hpp>
#include <boost/itl/interval_set.hpp>
@@ -16,16 +15,16 @@
ITL_INTERVAL(ITL_COMPARE) Interval>
void interval_ctor_4_ordered_types()
{
- typedef Interval<T,Compare> IntervalT;
+ typedef Interval<T,Compare> IntervalT;
// An empty interval is defined as the closed interval [1,0]
- BOOST_CHECK_EQUAL(itl::is_empty(IntervalT()), true);
+ BOOST_CHECK_EQUAL(itl::is_empty(IntervalT()), true);
BOOST_CHECK_EQUAL(cardinality(IntervalT()), itl::neutron<typename itl::size_type_of<T>::type>::value());
- BOOST_CHECK_EQUAL(itl::size(IntervalT()), itl::neutron<typename itl::size_type_of<T>::type>::value());
+ BOOST_CHECK_EQUAL(itl::size(IntervalT()), itl::neutron<typename itl::size_type_of<T>::type>::value());
BOOST_CHECK_EQUAL(IntervalT().lower(), itl::neutron<T>::value());
BOOST_CHECK_EQUAL(IntervalT().upper(), itl::neutron<T>::value());
BOOST_CHECK_EQUAL(IntervalT(), IntervalT());
BOOST_CHECK_EQUAL(IntervalT(), IntervalT(itl::neutron<T>::value(), itl::neutron<T>::value()));
- BOOST_CHECK_EQUAL(IntervalT(), IntervalT(itl::neutron<T>::value(), itl::neutron<T>::value(), interval_bounds::right_open()));
+ BOOST_CHECK_EQUAL(IntervalT(), IntervalT(itl::neutron<T>::value(), itl::neutron<T>::value(), interval_bounds::right_open()));
}
@@ -33,7 +32,7 @@
ITL_INTERVAL(ITL_COMPARE) Interval>
void interval_ctor_4_bicremental_types()
{
- typedef Interval<T,Compare> IntervalT;
+ typedef Interval<T,Compare> IntervalT;
BOOST_CHECK_EQUAL( T(), pred(succ(T())));
BOOST_CHECK_EQUAL( itl::neutron<T>::value(), pred(succ(itl::neutron<T>::value())) );
@@ -42,17 +41,17 @@
T v4 = make<T>(4);
IntervalT I4_4I(v4);
- BOOST_CHECK_EQUAL( I4_4I.bounds() == interval_bounds::closed(), true );
+ BOOST_CHECK_EQUAL( I4_4I.bounds() == interval_bounds::closed(), true );
BOOST_CHECK_EQUAL( I4_4I.bounds() == interval_bounds::left_open(), false );
BOOST_CHECK_EQUAL( I4_4I.bounds() == interval_bounds::left_open(), false );
BOOST_CHECK_EQUAL( I4_4I.bounds() == interval_bounds::right_open(), false );
BOOST_CHECK_EQUAL( I4_4I.bounds() == interval_bounds::open(), false );
- /*JODO
+ /*JODO
BOOST_CHECK_EQUAL( I4_4I.is_left(closed_bounded), true );
BOOST_CHECK_EQUAL( I4_4I.is_right(closed_bounded), true );
BOOST_CHECK_EQUAL( I4_4I.is_left(open_bounded), false );
BOOST_CHECK_EQUAL( I4_4I.is_right(open_bounded), false );
- */
+ */
BOOST_CHECK_EQUAL( I4_4I.lower(), v4 );
BOOST_CHECK_EQUAL( I4_4I.upper(), v4 );
@@ -62,7 +61,7 @@
BOOST_CHECK_EQUAL( within(I4_4I, I4_4I), true );
BOOST_CHECK_EQUAL( I4_4I, I4_4I );
BOOST_CHECK_EQUAL( cardinality(I4_4I), unon<typename interval<T>::size_type>::value() );
- BOOST_CHECK_EQUAL( itl::size(I4_4I), unon<typename interval<T>::size_type>::value() );
+ BOOST_CHECK_EQUAL( itl::size(I4_4I), unon<typename interval<T>::size_type>::value() );
IntervalT j_4_4(I4_4I);
BOOST_CHECK_EQUAL( I4_4I, j_4_4 );
@@ -70,7 +69,7 @@
k_4_4 = j_4_4;
BOOST_CHECK_EQUAL( I4_4I, k_4_4 );
- /*
+ /*
T v2 = make<T>(2);
BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4), interval<T>(v2, v4) );
BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4), interval<T>(v2, v4, closed_bounded) );
@@ -105,7 +104,7 @@
BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).bounds() == interval_bounds::open_bounded(), true );
BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).is_left(open_bounded), true );
BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).is_right(open_bounded), true );
- */
+ */
}
/*JODO
Modified: sandbox/itl/libs/validate/example/labat_single_/labat_single.cpp
==============================================================================
--- sandbox/itl/libs/validate/example/labat_single_/labat_single.cpp (original)
+++ sandbox/itl/libs/validate/example/labat_single_/labat_single.cpp 2010-04-09 11:26:09 EDT (Fri, 09 Apr 2010)
@@ -70,12 +70,13 @@
// <interval_map<int,int,partial_enricher>, itl::inplace_plus, itl::inplace_minus> TestLawT;
//LawValidater<TestLawT, RandomGentor> test_law;
- typedef InplaceSymmetricDifference
- <interval_set<int> > TestLawT;
+ typedef InplaceCommutativity
+ <separate_interval_set<double> > TestLawT;
LawValidater<TestLawT, RandomGentor> test_law;
+
//-----------------------------------------------------------------------------
- int test_count = 10000;
+ int test_count = 100000;
ptime start, stop;
GentorProfileSgl::it()->set_std_profile(8,1);
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk