Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60149 - in sandbox/itl: boost/itl boost/validate/laws libs/itl/doc libs/itl/test/test_casual_ libs/validate/example/de_morgan_ libs/validate/example/labat_single_
From: afojgo_at_[hidden]
Date: 2010-03-04 11:48:45


Author: jofaber
Date: 2010-03-04 11:48:44 EST (Thu, 04 Mar 2010)
New Revision: 60149
URL: http://svn.boost.org/trac/boost/changeset/60149

Log:
Fix of inplace_et and inplace_caret. Adding partial instantiations for double and float.
Added some laws for more specific inversions on interval_maps.
Text files modified:
   sandbox/itl/boost/itl/functors.hpp | 36 +++++++
   sandbox/itl/boost/validate/laws/inversion_laws.hpp | 186 ++++++++++++++++++++++++++++++++++++++++
   sandbox/itl/libs/itl/doc/concepts.qbk | 2
   sandbox/itl/libs/itl/doc/functions_addition.qbk | 2
   sandbox/itl/libs/itl/doc/functions_subtraction.qbk | 2
   sandbox/itl/libs/itl/doc/semantics.qbk | 4
   sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp | 4
   sandbox/itl/libs/validate/example/de_morgan_/de_morgan.cpp | 2
   sandbox/itl/libs/validate/example/labat_single_/labat_single.cpp | 5
   9 files changed, 235 insertions(+), 8 deletions(-)

Modified: sandbox/itl/boost/itl/functors.hpp
==============================================================================
--- sandbox/itl/boost/itl/functors.hpp (original)
+++ sandbox/itl/boost/itl/functors.hpp 2010-03-04 11:48:44 EST (Thu, 04 Mar 2010)
@@ -145,6 +145,24 @@
         { object &= operand; }
     };
 
+ template <> struct inplace_et<double>
+ : public neutron_based_inplace_combine<double>
+ {
+ typedef double type;
+
+ void operator()(type& object, type operand)const
+ { object += operand; }
+ };
+
+ template <> struct inplace_et<float>
+ : public neutron_based_inplace_combine<float>
+ {
+ typedef float type;
+
+ void operator()(type& object, type operand)const
+ { object += operand; }
+ };
+
     template<>
     inline std::string unary_template_to_string<inplace_et>::apply() { return "&="; }
 
@@ -159,6 +177,24 @@
         static Type neutron() { return boost::itl::neutron<Type>::value(); }
     };
 
+ template <> struct inplace_caret<double>
+ : public neutron_based_inplace_combine<double>
+ {
+ typedef double type;
+
+ void operator()(type& object, type operand)const
+ { object -= operand; }
+ };
+
+ template <> struct inplace_caret<float>
+ : public neutron_based_inplace_combine<float>
+ {
+ typedef float type;
+
+ void operator()(type& object, type operand)const
+ { object -= operand; }
+ };
+
     template<>
     inline std::string unary_template_to_string<inplace_caret>::apply() { return "^="; }
 

Modified: sandbox/itl/boost/validate/laws/inversion_laws.hpp
==============================================================================
--- sandbox/itl/boost/validate/laws/inversion_laws.hpp (original)
+++ sandbox/itl/boost/validate/laws/inversion_laws.hpp 2010-03-04 11:48:44 EST (Thu, 04 Mar 2010)
@@ -120,6 +120,192 @@
         size_t size()const { return value_size<Type>::apply(this->template getInputValue<operand_a>()); }
     };
 
+
+ template <typename Type,
+ template<class>class Combiner = inplace_plus,
+ template<class>class Inverter = inplace_minus,
+ template<class>class Equality = itl::std_equal>
+ class InplaceNaiveInversion
+ : public Law<InplaceNaiveInversion<Type,Combiner,Inverter,Equality>,
+ LOKI_TYPELIST_2(Type,Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ //(a + b) - b == a - b
+ //computed using inplace operators +=
+ //Input = (a := inVal1, b := inVal2)
+ //Output = (lhs_result, rhs_result)
+
+ public:
+ std::string name()const { return "InplaceNaiveInversion"; }
+ std::string formula()const { return "(a + b) - b == a - b"; }
+
+ std::string typeString()const
+ {
+ return "NaiveInversion<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Combiner>::apply()+","
+ +unary_template_to_string<Inverter>::apply()+","
+ +unary_template_to_string<Equality>::apply()
+ +">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ Type lhs = this->template getInputValue<operand_a>();
+ Combiner<Type>()(lhs, this->template getInputValue<operand_b>());
+ Inverter<Type>()(lhs, this->template getInputValue<operand_b>());
+
+ Type rhs = this->template getInputValue<operand_a>();
+ Inverter<Type>()(rhs, this->template getInputValue<operand_b>());
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return Equality<Type>()(lhs, rhs);
+ }
+
+ bool debug_holds()
+ {
+ return holds();
+ }
+
+ size_t size()const { return value_size<Type>::apply(this->template getInputValue<operand_a>()); }
+ };
+
+
+ template <typename Type,
+ template<class>class Combiner = inplace_plus,
+ template<class>class Inverter = inplace_minus,
+ template<class>class Equality = itl::std_equal>
+ class DisjointNaiveInversion
+ : public Law<DisjointNaiveInversion<Type,Combiner,Inverter,Equality>,
+ LOKI_TYPELIST_2(Type,Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ // dom(a).is_disjoint(dom(b)) => (a + b) - b == a - b
+ //computed using inplace operators +=
+ //Input = (a := inVal1, b := inVal2)
+ //Output = (lhs_result, rhs_result)
+
+ public:
+ std::string name()const { return "DisjointNaiveInversion"; }
+ std::string formula()const { return "a.is_disjoint(b) => (a + b) - b == a - b"; }
+
+ std::string typeString()const
+ {
+ return "DisjointNaiveInversion<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Combiner>::apply()+","
+ +unary_template_to_string<Inverter>::apply()+","
+ +unary_template_to_string<Equality>::apply()
+ +">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ // dom(a).is_disjoint(dom(b)) => (a + b) - b == a - b
+ Type value_a = this->template getInputValue<operand_a>();
+ Type value_b = this->template getInputValue<operand_b>();
+ typename Type::set_type dom_a; value_a.domain(dom_a);
+ typename Type::set_type dom_b; value_b.domain(dom_b);
+
+ if(is_disjoint(dom_a, dom_b))
+ {
+ Type lhs = value_a;
+ Combiner<Type>()(lhs, this->template getInputValue<operand_b>());
+ Inverter<Type>()(lhs, this->template getInputValue<operand_b>());
+
+ Type rhs = this->template getInputValue<operand_a>();
+ Inverter<Type>()(rhs, this->template getInputValue<operand_b>());
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return Equality<Type>()(lhs, rhs);
+ }
+ else // a intersects b
+ {
+ this->template setOutputValue<lhs_result>(value_a);
+ this->template setOutputValue<rhs_result>(value_b);
+ return true;
+ }
+ }
+
+ bool debug_holds()
+ {
+ return holds();
+ }
+
+ size_t size()const { return value_size<Type>::apply(this->template getInputValue<operand_a>()); }
+ };
+
+
+ template <typename Type,
+ template<class>class Combiner = inplace_plus,
+ template<class>class Inverter = inplace_minus,
+ template<class>class Equality = itl::std_equal>
+ class JointInverseExistence
+ : public Law<JointInverseExistence<Type,Combiner,Inverter,Equality>,
+ LOKI_TYPELIST_2(Type,Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ // a.contains(dom(b)) => (a + b) - b == (a - b) + a
+ //computed using inplace operators +=
+ //Input = (a := inVal1, b := inVal2)
+ //Output = (lhs_result, rhs_result)
+
+ public:
+ std::string name()const { return "JointInverseExistence"; }
+ std::string formula()const { return "a.contains(dom(b)) => (a + b) - b == (a - b) + b"; }
+
+ std::string typeString()const
+ {
+ return "JointInverseExistence<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Combiner>::apply()+","
+ +unary_template_to_string<Inverter>::apply()+","
+ +unary_template_to_string<Equality>::apply()
+ +">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ // a.contains(dom(b)) => (a + b) - b == (a - b) + a
+ Type value_a = this->template getInputValue<operand_a>();
+ Type value_b = this->template getInputValue<operand_b>();
+ typename Type::set_type dom_b; value_b.domain(dom_b);
+
+ if(value_a.contains(dom_b))
+ {
+ Type lhs = value_a;
+ Combiner<Type>()(lhs, value_b);
+ Inverter<Type>()(lhs, value_b);
+
+ Type rhs = value_a;
+ Inverter<Type>()(rhs, value_b);
+ Combiner<Type>()(rhs, value_b);
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return Equality<Type>()(lhs, rhs);
+ }
+ else // a intersects b
+ {
+ this->template setOutputValue<lhs_result>(value_a);
+ this->template setOutputValue<rhs_result>(value_b);
+ return true;
+ }
+ }
+
+ bool debug_holds()
+ {
+ return holds();
+ }
+
+ size_t size()const { return value_size<Type>::apply(this->template getInputValue<operand_a>()); }
+ };
+
 }} // namespace itl boost
 
 #endif // BOOST_ITL_INVERSION_LAWS_HPP_JOFA_071124

Modified: sandbox/itl/libs/itl/doc/concepts.qbk
==============================================================================
--- sandbox/itl/libs/itl/doc/concepts.qbk (original)
+++ sandbox/itl/libs/itl/doc/concepts.qbk 2010-03-04 11:48:44 EST (Thu, 04 Mar 2010)
@@ -165,7 +165,7 @@
 in the sections on the
 [link boost_itl.semantics.sets semantics of itl Sets] and
 [link boost_itl.semantics.maps Maps].
-These semantical differences are mainly based on the implementation
+These semantic differences are mainly based on the implementation
 of the pivotal member functions `add` and `subtract` for elements
 and intervals that again serve for implementing
 `operator +=` and `operator -=`.

Modified: sandbox/itl/libs/itl/doc/functions_addition.qbk
==============================================================================
--- sandbox/itl/libs/itl/doc/functions_addition.qbk (original)
+++ sandbox/itl/libs/itl/doc/functions_addition.qbk 2010-03-04 11:48:44 EST (Thu, 04 Mar 2010)
@@ -41,7 +41,7 @@
           Find more on
           [link boost_itl.concepts.addability__subtractability_and_aggregate_on_overlap ['addability of maps]]
           and related
- [link boost_itl.semantics.maps ['semantical issues]]
+ [link boost_itl.semantics.maps ['semantic issues]]
           following the links.
         
           Examples, demonstrating Addition on interval containers are

Modified: sandbox/itl/libs/itl/doc/functions_subtraction.qbk
==============================================================================
--- sandbox/itl/libs/itl/doc/functions_subtraction.qbk (original)
+++ sandbox/itl/libs/itl/doc/functions_subtraction.qbk 2010-03-04 11:48:44 EST (Thu, 04 Mar 2010)
@@ -34,7 +34,7 @@
           Find more on
           [link boost_itl.concepts.addability__subtractability_and_aggregate_on_overlap ['subtractability of maps]]
           and related
- [link boost_itl.semantics.maps ['semantical issues]]
+ [link boost_itl.semantics.maps ['semantic issues]]
           following the links.
         
          ]]

Modified: sandbox/itl/libs/itl/doc/semantics.qbk
==============================================================================
--- sandbox/itl/libs/itl/doc/semantics.qbk (original)
+++ sandbox/itl/libs/itl/doc/semantics.qbk 2010-03-04 11:48:44 EST (Thu, 04 Mar 2010)
@@ -295,7 +295,7 @@
 of it's aggregating facilities, where the aggregating combiner
 operations are passed to combine the map's associated values.
 It turns out, that the aggregation on overlap principle
-induces semantical properties to itl maps in such a way,
+induces semantic properties to itl maps in such a way,
 that the set of equations that are valid will depend on
 the semantics of the type `CodomainT` of the map's associated
 values.
@@ -497,7 +497,7 @@
 Reviewing the validity tables above shows, that the sets of valid laws for
 `itl Sets` and `itl Maps of Sets` that are /neutron absorbing/ are exactly the same.
 As expected, only for Maps of Sets that represent empty sets as associated values,
-called /neutron enrichers/, there are marginal semantical differences.
+called /neutron enrichers/, there are marginal semantic differences.
 
 [endsect][/ Collectors]
 

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-03-04 11:48:44 EST (Thu, 04 Mar 2010)
@@ -62,6 +62,8 @@
 
 BOOST_AUTO_TEST_CASE(casual)
 {
- itl::set<int> ion_set;
+ interval_map<int, float> map_1;
+ interval_map<int, float> map_2;
+ map_1 & map_2;
 }
 

Modified: sandbox/itl/libs/validate/example/de_morgan_/de_morgan.cpp
==============================================================================
--- sandbox/itl/libs/validate/example/de_morgan_/de_morgan.cpp (original)
+++ sandbox/itl/libs/validate/example/de_morgan_/de_morgan.cpp 2010-03-04 11:48:44 EST (Thu, 04 Mar 2010)
@@ -14,7 +14,7 @@
 Example de_morgan.cpp demonstrates some tests of
 <a href="http://en.wikipedia.org/wiki/De_Morgan%27s_laws">
 De Morgan's law</a> on interval_set.
-This law is selected, because we can show some interesting semantical
+This law is selected, because we can show some interesting semantic
 distinctions that reveal themselves in different instantiations of the law.
 
 We do not use De Morgan's laws in it's original form

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-03-04 11:48:44 EST (Thu, 04 Mar 2010)
@@ -64,7 +64,10 @@
     //>
     //TestLawT;
 
- typedef Antisymmetry<itl::map<int,int>, std::less_equal, std_equal> TestLawT;
+ //typedef Antisymmetry<itl::map<int,int>, std::less_equal, std_equal> TestLawT;
+
+ typedef JointInverseExistence
+ <interval_map<int,int,partial_enricher>, itl::inplace_plus, itl::inplace_minus> TestLawT;
 
     LawValidater<TestLawT, RandomGentor> test_law;
 


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