|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56892 - in sandbox/statistics/vector_space: boost/vector_space/algorithm boost/vector_space/data boost/vector_space/data/detail boost/vector_space/functional libs/vector_space/doc libs/vector_space/example libs/vector_space/src
From: erwann.rogard_at_[hidden]
Date: 2009-10-16 00:46:03
Author: e_r
Date: 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
New Revision: 56892
URL: http://svn.boost.org/trac/boost/changeset/56892
Log:
m
Text files modified:
sandbox/statistics/vector_space/boost/vector_space/algorithm/find.hpp | 14 ++++++---
sandbox/statistics/vector_space/boost/vector_space/data/detail/cref.hpp | 14 ++++++---
sandbox/statistics/vector_space/boost/vector_space/data/lazy_difference.hpp | 60 ++++++++++++++++++++++++++++++---------
sandbox/statistics/vector_space/boost/vector_space/functional/equal.hpp | 14 ++++++---
sandbox/statistics/vector_space/boost/vector_space/functional/l1_distance.hpp | 14 ++++++---
sandbox/statistics/vector_space/boost/vector_space/functional/l2_distance_squared.hpp | 18 ++++++------
sandbox/statistics/vector_space/libs/vector_space/doc/readme.txt | 10 +++++-
sandbox/statistics/vector_space/libs/vector_space/example/difference.cpp | 2
sandbox/statistics/vector_space/libs/vector_space/example/difference.h | 4 +-
sandbox/statistics/vector_space/libs/vector_space/example/equal.cpp | 7 +++-
sandbox/statistics/vector_space/libs/vector_space/example/equal.h | 4 +-
sandbox/statistics/vector_space/libs/vector_space/src/main.cpp | 11 +++++++
12 files changed, 120 insertions(+), 52 deletions(-)
Modified: sandbox/statistics/vector_space/boost/vector_space/algorithm/find.hpp
==============================================================================
--- sandbox/statistics/vector_space/boost/vector_space/algorithm/find.hpp (original)
+++ sandbox/statistics/vector_space/boost/vector_space/algorithm/find.hpp 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -5,13 +5,15 @@
// Software License, Version 1.0. (See accompanying file //
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_VECTOR_SPACE_FIND_HPP_ER_2009
-#define BOOST_VECTOR_SPACE_FIND_HPP_ER_2009
+#ifndef BOOST_STATISTICS_DETAIL_VECTOR_SPACE_FIND_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_VECTOR_SPACE_FIND_HPP_ER_2009
#include <numeric>
#include <cmath>
#include <boost/vector_space/functional/equal.hpp>
namespace boost{
+namespace statistics{
+namespace detail{
namespace vector_space{
// This is a version of find where the elements in *[b,e) are ranges.
@@ -40,11 +42,13 @@
return std::find_if(
b,
e,
- functional::equal(x,eps)
+ functional::equal(x)
);
}
-}//algorithm
-}//boost
+}// vector_space
+}// detail
+}// statistics
+}// boost
#endif
\ No newline at end of file
Modified: sandbox/statistics/vector_space/boost/vector_space/data/detail/cref.hpp
==============================================================================
--- sandbox/statistics/vector_space/boost/vector_space/data/detail/cref.hpp (original)
+++ sandbox/statistics/vector_space/boost/vector_space/data/detail/cref.hpp 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -5,14 +5,16 @@
// Software License, Version 1.0. (See accompanying file //
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_VECTOR_SPACE_DATA_DETAIL_CREF_H_ER_2009
-#define BOOST_VECTOR_SPACE_DATA_DETAIL_CREF_H_ER_2009
+#ifndef BOOST_STATISTICS_DETAIL_VECTOR_SPACE_DATA_DETAIL_CREF_H_ER_2009
+#define BOOST_STATISTICS_DETAIL_VECTOR_SPACE_DATA_DETAIL_CREF_H_ER_2009
#include <boost/mpl/not.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits.hpp>
#include <boost/range.hpp>
namespace boost{
+namespace statistics{
+namespace detail{
namespace vector_space{
namespace detail{
@@ -21,8 +23,8 @@
struct cref{
typedef is_reference<X> is_ref_x_;
typedef is_const<X> is_const_x_;
- BOOST_MPL_ASSERT((mpl::not_<is_ref_x_>));
- BOOST_MPL_ASSERT((mpl::not_<is_const_x_>));
+ BOOST_MPL_ASSERT((boost::mpl::not_<is_ref_x_>));
+ BOOST_MPL_ASSERT((boost::mpl::not_<is_const_x_>));
cref(const X& x):x_(x){}
cref(const cref& that):x_(that.x_){}
@@ -34,8 +36,10 @@
const X& x_;
};
-}// detail
+}// details
}// vector_space
+}// detail
+}// statistics
}// boost
#endif
\ No newline at end of file
Modified: sandbox/statistics/vector_space/boost/vector_space/data/lazy_difference.hpp
==============================================================================
--- sandbox/statistics/vector_space/boost/vector_space/data/lazy_difference.hpp (original)
+++ sandbox/statistics/vector_space/boost/vector_space/data/lazy_difference.hpp 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -5,19 +5,26 @@
// Software License, Version 1.0. (See accompanying file //
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_VECTOR_SPACE_DATA_LAZY_DIFFERENCE_H_ER_2009
-#define BOOST_VECTOR_SPACE_DATA_LAZY_DIFFERENCE_H_ER_2009
+#ifndef BOOST_STATISTICS_DETAIL_VECTOR_SPACE_DATA_LAZY_DIFFERENCE_H_ER_2009
+#define BOOST_STATISTICS_DETAIL_VECTOR_SPACE_DATA_LAZY_DIFFERENCE_H_ER_2009
#include <boost/mpl/not.hpp>
#include <boost/mpl/assert.hpp>
+#include <boost/utility/result_of.hpp>
#include <boost/type_traits.hpp>
#include <boost/iterator/zip_iterator.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/range.hpp>
-#include <boost/binary_op/functional/untupler.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/function.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/lambda/bind.hpp>
+#include <boost/statistics/detail/tuple/functor/element.hpp>
#include <boost/vector_space/data/detail/cref.hpp>
namespace boost{
+namespace statistics{
+namespace detail{
namespace vector_space{
// A data structure that offers a lazy (i.e. no copying involved) representation
@@ -28,18 +35,28 @@
// typedef range_value<diff_> val_;
// diff_ diff(x,x1);
// val d0 = const_begin(diff)
-template<typename X,typename X1>
+template<
+ typename X,
+ typename X1,
+ typename T = typename remove_cv<typename range_value<X>::type>::type
+>
class lazy_difference{
- typedef typename range_value<X>::type value_type;
- typedef std::minus<value_type> minus_;
- typedef binary_op::untupler<minus_> fun_;
- typedef detail::template cref<X> cref_x_;
- typedef detail::template cref<X1> cref_x1_;
+ typedef T value_type;
+
+ typedef vector_space::detail::template cref<X> cref_x_;
+ typedef vector_space::detail::template cref<X1> cref_x1_;
typedef typename cref_x_::const_iterator it_x_;
typedef typename cref_x1_::const_iterator it_x1_;
typedef boost::tuple<it_x_,it_x1_> it_tuple_;
typedef boost::zip_iterator<it_tuple_> zip_it_;
+ // Constructed on the fly so it is not a reference
+ typedef typename boost::iterator_reference<zip_it_>::type ref_;
+ // This is a const ref to a tuple
+ typedef typename add_reference<
+ typename add_const<ref_>::type
+ >::type ref2_;
+ typedef boost::function<value_type(ref2_)> f_;
public:
lazy_difference(const X& x,const X1& x1)
@@ -48,10 +65,9 @@
lazy_difference(const lazy_difference& that)
:cref_x(that.cref_x),cref_x1(that.cref_x1){}
- typedef boost::transform_iterator<fun_,zip_it_> const_iterator;
+ typedef boost::transform_iterator<f_,zip_it_> const_iterator;
typedef const_iterator iterator;
- // TODO size etc.
const_iterator begin()const{
return this->get_iterator(
cref_x.begin(),
@@ -69,11 +85,25 @@
cref_x_ cref_x;
cref_x1_ cref_x1;
- lazy_difference& operator=(const lazy_difference&);
+ lazy_difference& operator=(const lazy_difference&); // disabled
+
const_iterator get_iterator(it_x_ it_x,it_x1_ it_x1)const{
- fun_ f;
+ typedef boost::statistics::detail::tuple::functor::element<0> f0_;
+ typedef typename boost::result_of<f0_(ref2_)>::type r0_;
+ typedef boost::statistics::detail::tuple::functor::element<1> f1_;
+ typedef typename boost::result_of<f1_(ref2_)>::type r1_;
+ typedef boost::function<T(r0_,r1_)> min_;
+
+ min_ min = boost::lambda::_1 - boost::lambda::_2;
+
+ f_ f = boost::lambda::bind<T>(
+ min,
+ boost::lambda::bind<r0_>(f0_(),boost::lambda::_1),
+ boost::lambda::bind<r1_>(f1_(),boost::lambda::_1)
+ );
+
return make_transform_iterator(
- make_zip_iterator(
+ zip_it_(
make_tuple(
it_x,
it_x1
@@ -86,6 +116,8 @@
};
}// vector_space
+}// detail
+}// statistics
}// boost
#endif
\ No newline at end of file
Modified: sandbox/statistics/vector_space/boost/vector_space/functional/equal.hpp
==============================================================================
--- sandbox/statistics/vector_space/boost/vector_space/functional/equal.hpp (original)
+++ sandbox/statistics/vector_space/boost/vector_space/functional/equal.hpp 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,8 @@
// Software License, Version 1.0. (See accompanying file //
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_VECTOR_SPACE_FUNCTIONAL_EQUAL_HPP_ER_2009
-#define BOOST_VECTOR_SPACE_FUNCTIONAL_EQUAL_HPP_ER_2009
+#ifndef BOOST_STATISTICS_DETAIL_VECTOR_SPACE_FUNCTIONAL_EQUAL_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_VECTOR_SPACE_FUNCTIONAL_EQUAL_HPP_ER_2009
#include <boost/call_traits.hpp>
#include <ostream>
#include <boost/range.hpp>
@@ -16,9 +16,11 @@
#include <boost/vector_space/functional/l2_distance_squared.hpp>
namespace boost{
+namespace statistics{
+namespace detail{
namespace vector_space{
-// This predicate implements (x == y) iff (|| x - y || == 0).
+// This is a predicate for (x == y) iff (|| x - y || == 0).
//
// Requirements:
// F<R> distance(x); Construction
@@ -106,7 +108,9 @@
return (distance_(y)<eps_);
}
-}//vector_space
-}//boost
+}// vector_space
+}// detail
+}// statistics
+}// boost
#endif
\ No newline at end of file
Modified: sandbox/statistics/vector_space/boost/vector_space/functional/l1_distance.hpp
==============================================================================
--- sandbox/statistics/vector_space/boost/vector_space/functional/l1_distance.hpp (original)
+++ sandbox/statistics/vector_space/boost/vector_space/functional/l1_distance.hpp 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,8 @@
// Software License, Version 1.0. (See accompanying file //
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_VECTOR_SPACE_FUNCTIONAL_l1_DISTANCE_SQUARED_HPP_ER_2009
-#define BOOST_VECTOR_SPACE_FUNCTIONAL_l1_DISTANCE_SQUARED_HPP_ER_2009
+#ifndef BOOST_STATISTICS_DETAIL_VECTOR_SPACE_FUNCTIONAL_l1_DISTANCE_SQUARED_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_VECTOR_SPACE_FUNCTIONAL_l1_DISTANCE_SQUARED_HPP_ER_2009
#include <cmath>
#include <numeric>
#include <functional>
@@ -20,6 +20,8 @@
#include <boost/math/tools/precision.hpp>
namespace boost{
+namespace statistics{
+namespace detail{
namespace vector_space{
// See l2_distance_squared
@@ -56,7 +58,7 @@
l1_distance<R>::l1_distance(
typename call_traits<R>::param_type x
):x_(x){
- BOOST_MPL_ASSERT((mpl::not<is_ref_>));
+ BOOST_MPL_ASSERT((mpl::not_<is_ref_>));
}
template<typename R>
@@ -68,7 +70,7 @@
l1_distance<R>&
l1_distance<R>::operator=(const l1_distance& that){
if(&that != this){
- BOOST_MPL_ASSERT((mpl::not<is_ref_>));
+ BOOST_MPL_ASSERT((mpl::not_<is_ref_>));
x_ = that.x_;
}
return *this;
@@ -99,7 +101,9 @@
);
};
-}// range
+}// vector_space
+}// detail
+}// statistics
}// boost
#endif
\ No newline at end of file
Modified: sandbox/statistics/vector_space/boost/vector_space/functional/l2_distance_squared.hpp
==============================================================================
--- sandbox/statistics/vector_space/boost/vector_space/functional/l2_distance_squared.hpp (original)
+++ sandbox/statistics/vector_space/boost/vector_space/functional/l2_distance_squared.hpp 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -5,12 +5,11 @@
// Software License, Version 1.0. (See accompanying file //
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_VECTOR_SPACE_FUNCTIONAL_l2_DISTANCE_SQUARED_HPP_ER_2009
-#define BOOST_VECTOR_SPACE_FUNCTIONAL_l2_DISTANCE_SQUARED_HPP_ER_2009
+#ifndef BOOST_STATISTICS_DETAIL_VECTOR_SPACE_FUNCTIONAL_l2_DISTANCE_SQUARED_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_VECTOR_SPACE_FUNCTIONAL_l2_DISTANCE_SQUARED_HPP_ER_2009
#include <cmath>
#include <numeric>
#include <functional>
-#include <boost/mpl/assert.hpp>
#include <boost/type_traits.hpp>
#include <boost/function.hpp>
#include <boost/call_traits.hpp>
@@ -20,6 +19,8 @@
#include <boost/math/tools/precision.hpp>
namespace boost{
+namespace statistics{
+namespace detail{
namespace vector_space{
// Stores a range r, and when passed another range r1, computes the squared
@@ -37,6 +38,7 @@
typedef typename range_value<range_type>::type result_type;
// Constructor
+ l2_distance_squared(){} // Warning, x_ not initialized
l2_distance_squared(typename call_traits<R>::param_type x);
l2_distance_squared(const l2_distance_squared& that);
l2_distance_squared& operator=(const l2_distance_squared& that);
@@ -46,7 +48,6 @@
result_type operator()(const R1& y)const;
private:
- l2_distance_squared();
typename call_traits<R>::value_type x_;
};
@@ -60,9 +61,7 @@
template<typename R>
l2_distance_squared<R>::l2_distance_squared(
typename call_traits<R>::param_type x
- ):x_(x){
- BOOST_MPL_ASSERT((mpl::not<is_ref_>));
- }
+ ):x_(x){}
template<typename R>
l2_distance_squared<R>::l2_distance_squared(
@@ -73,7 +72,6 @@
l2_distance_squared<R>&
l2_distance_squared<R>::operator=(const l2_distance_squared& that){
if(&that != this){
- BOOST_MPL_ASSERT((mpl::not<is_ref_>));
x_ = that.x_;
}
return *this;
@@ -96,7 +94,9 @@
);
};
-}// range
+}// vector_space
+}// detail
+}// statistics
}// boost
#endif
\ No newline at end of file
Modified: sandbox/statistics/vector_space/libs/vector_space/doc/readme.txt
==============================================================================
--- sandbox/statistics/vector_space/libs/vector_space/doc/readme.txt (original)
+++ sandbox/statistics/vector_space/libs/vector_space/doc/readme.txt 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -28,11 +28,17 @@
[ Dependencies ]
-/usr/local/boost_1_39_0/
+/usr/local/boost_1_40_0/
+/Users/erwann/sandbox/statistics/detail/tuple/
+/Users/erwann/sandbox/statistics/mpl/
[ History ]
-July 2009 : Current version
+October 8th 2009 :
+ vector_space namespace embedded in statistics::detail
+ implem of lazy_difference modified
+
+July 2009 : First version
[Output]
Modified: sandbox/statistics/vector_space/libs/vector_space/example/difference.cpp
==============================================================================
--- sandbox/statistics/vector_space/libs/vector_space/example/difference.cpp (original)
+++ sandbox/statistics/vector_space/libs/vector_space/example/difference.cpp 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -20,7 +20,7 @@
void example_difference(std::ostream& out){
std::cout << "-> example_difference : ";
using namespace boost;
- namespace vs = vector_space;
+ namespace vs = statistics::detail::vector_space;
typedef double val_;
typedef std::vector<val_> vec_;
typedef vs::lazy_difference<vec_,vec_> range_diff_;
Modified: sandbox/statistics/vector_space/libs/vector_space/example/difference.h
==============================================================================
--- sandbox/statistics/vector_space/libs/vector_space/example/difference.h (original)
+++ sandbox/statistics/vector_space/libs/vector_space/example/difference.h 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,8 @@
// Software License, Version 1.0. (See accompanying file //
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_VECTOR_SPACE_EXAMPLE_DIFFERENCE_H_ER_2009
-#define BOOST_VECTOR_SPACE_EXAMPLE_DIFFERENCE_H_ER_2009
+#ifndef BOOST_STATISTICS_DETAIL_VECTOR_SPACE_EXAMPLE_DIFFERENCE_H_ER_2009
+#define BOOST_STATISTICS_DETAIL_VECTOR_SPACE_EXAMPLE_DIFFERENCE_H_ER_2009
#include <ostream>
void example_difference(std::ostream&);
Modified: sandbox/statistics/vector_space/libs/vector_space/example/equal.cpp
==============================================================================
--- sandbox/statistics/vector_space/libs/vector_space/example/equal.cpp (original)
+++ sandbox/statistics/vector_space/libs/vector_space/example/equal.cpp 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -15,6 +15,7 @@
void example_equal(std::ostream& out) {
out << "-> example_equal : ";
using namespace boost;
+ namespace vs = boost::statistics::detail::vector_space;
typedef unsigned val_;
typedef std::vector<val_> row_;
@@ -23,12 +24,14 @@
typedef range_iterator<row_>::type iterator_elem_;
typedef range_reference<mat_>::type ref_row_;
typedef range_reference<row_>::type ref_elem_;
- typedef vector_space::equal<row_&> equal_;
+ typedef vs::equal<row_&> equal_;
const unsigned n = 3;
const val_ eps = 1; // defaul eps = 0, so |i-j| < 1 need, i,j integers
row_ row(n);
equal_ equal(row,eps);
+/*
+
std::cout << equal << std::endl;
mat_ mat(n,row);
val_ val = 0;
@@ -50,6 +53,6 @@
equal(ref_row)
);
}
-
+*/
out << "<-" << std::endl;
}
\ No newline at end of file
Modified: sandbox/statistics/vector_space/libs/vector_space/example/equal.h
==============================================================================
--- sandbox/statistics/vector_space/libs/vector_space/example/equal.h (original)
+++ sandbox/statistics/vector_space/libs/vector_space/example/equal.h 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,8 @@
// Software License, Version 1.0. (See accompanying file //
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_VECTOR_SPACE_EXAMPLE_EQUAL_H_ER_2009
-#define BOOST_VECTOR_SPACE_EXAMPLE_EQUAL_H_ER_2009
+#ifndef BOOST_STATISTICS_DETAIL_VECTOR_SPACE_EXAMPLE_EQUAL_H_ER_2009
+#define BOOST_STATISTICS_DETAIL_VECTOR_SPACE_EXAMPLE_EQUAL_H_ER_2009
#include <ostream>
void example_equal(std::ostream&);
Modified: sandbox/statistics/vector_space/libs/vector_space/src/main.cpp
==============================================================================
--- sandbox/statistics/vector_space/libs/vector_space/src/main.cpp (original)
+++ sandbox/statistics/vector_space/libs/vector_space/src/main.cpp 2009-10-16 00:46:01 EDT (Fri, 16 Oct 2009)
@@ -9,10 +9,21 @@
#include <libs/vector_space/example/difference.h>
#include <libs/vector_space/example/equal.h>
+#include <boost/function.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/lambda/casts.hpp>
+
+#include <boost/typeof/typeof.hpp>
+
+ using namespace boost;
+
+
+
int main(){
example_difference(std::cout);
example_equal(std::cout);
+
return 0;
}
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