$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r56395 - in sandbox/statistics/view: . boost boost/view libs libs/view libs/view/doc libs/view/example libs/view/src
From: erwann.rogard_at_[hidden]
Date: 2009-09-26 19:21:07
Author: e_r
Date: 2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
New Revision: 56395
URL: http://svn.boost.org/trac/boost/changeset/56395
Log:
a
Added:
   sandbox/statistics/view/
   sandbox/statistics/view/boost/
   sandbox/statistics/view/boost/view/
   sandbox/statistics/view/boost/view/columns_iterator.hpp   (contents, props changed)
   sandbox/statistics/view/boost/view/rows_iterator.hpp   (contents, props changed)
   sandbox/statistics/view/boost/view/step_count_down_iterator.hpp   (contents, props changed)
   sandbox/statistics/view/libs/
   sandbox/statistics/view/libs/view/
   sandbox/statistics/view/libs/view/doc/
   sandbox/statistics/view/libs/view/doc/readme.txt   (contents, props changed)
   sandbox/statistics/view/libs/view/example/
   sandbox/statistics/view/libs/view/example/columns_iterator.cpp   (contents, props changed)
   sandbox/statistics/view/libs/view/example/columns_iterator.h   (contents, props changed)
   sandbox/statistics/view/libs/view/example/rows_iterator.cpp   (contents, props changed)
   sandbox/statistics/view/libs/view/example/rows_iterator.h   (contents, props changed)
   sandbox/statistics/view/libs/view/example/step_iterator.cpp   (contents, props changed)
   sandbox/statistics/view/libs/view/example/step_iterator.h   (contents, props changed)
   sandbox/statistics/view/libs/view/src/
   sandbox/statistics/view/libs/view/src/main.cpp   (contents, props changed)
Added: sandbox/statistics/view/boost/view/columns_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/boost/view/columns_iterator.hpp	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,161 @@
+///////////////////////////////////////////////////////////////////////////////
+// view::iterator::columns_iterator.hpp                                      //
+//                                                                           //
+//  (C) Copyright 2009 Erwann Rogard                                         //
+//  Use, modification and distribution are subject to the                    //
+//  Boost Software License, Version 1.0. (See accompanying file              //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)         //
+///////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_VIEW_DETAIL_COLUMNS_ITERATOR_HPP_ER_2009
+#define BOOST_VIEW_DETAIL_COLUMNS_ITERATOR_HPP_ER_2009
+#include <iterator>
+#include <algorithm>
+#include <cmath>
+#include <iostream>
+#include <boost/view//step_count_down_iterator.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/range.hpp>
+
+namespace boost{
+namespace view{
+namespace detail{
+
+// *rows_iterator returns an iterator range whose elements are a row of a 
+// row-major matrix view of a sequence traversed by an iterator of type I. 
+// The step is the number of elements per row.
+template< class I
+        , class V = use_default
+        , class C = use_default
+        , class R = use_default
+        , class D = use_default 
+>
+class columns_iterator
+  : public iterator_adaptor< 
+        columns_iterator<I, V, C, R, D>, 
+        I, 
+        iterator_range<
+            step_count_down_iterator<I,V,C,R,D>           //V1
+        >,                                     
+        C, 
+        iterator_range<
+            step_count_down_iterator<I,V,C,R,D>           // R1
+        >, 
+        D 
+    >
+{
+    typedef iterator_adaptor< 
+        columns_iterator<I, V, C, R, D>, 
+            I, 
+            iterator_range<
+            step_count_down_iterator<I,V,C,R,D>           
+        >,                                     
+        C, 
+        iterator_range<
+            step_count_down_iterator<I,V,C,R,D>           
+        >, 
+        D 
+  > super_;
+
+    typedef step_count_down_iterator<I,V,C,R,D> iter_;
+    typedef iterator_range<iter_> range_;
+
+ public:
+    typedef typename super_::difference_type difference_type; 
+    typedef typename super_::reference reference; 
+
+    columns_iterator() : super_(){}
+
+    explicit columns_iterator(  
+       I b,
+       I e,
+       difference_type step
+    )
+    :super_(b),base_e_(e),step_(step){
+        BOOST_ASSERT(
+            this->step()>=0
+        );
+    }
+    
+    columns_iterator(const columns_iterator& that)
+    :super_(that),base_e_(that.base_e_),step_(that.step_){}
+    
+    difference_type step()const{ return this->step_; }
+    
+ private:
+
+    friend class iterator_core_access;
+
+    // default should work for:
+    // void increment();
+    // void decrement()
+    // void advance(difference_type n)
+    // difference_type distance_to(columns_iterator const& other) const{
+    // bool equal(columns_iterator const& other) const
+
+    reference dereference() const {
+        // TODO may check against end
+        iter_ b = make_step_count_down_iterator(
+            this->base(),
+            this->base_e_,
+            this->step()
+        );
+        iter_ e = make_end_step_count_down_iterator(
+            this->base(),
+            this->base_e_,
+            this->step()
+        );
+        return range_(
+            b,
+            e
+        );
+    }
+
+    void advance(difference_type n)
+    {
+        std::advance(this->base_reference(), n);
+    }
+    I base_e_;
+    difference_type step_;
+};
+
+
+template<typename It,typename N>
+columns_iterator<It>
+make_columns_iterator(
+    It b,
+    It e,
+    N stride
+){
+    typedef columns_iterator<It> it_;
+    return it_(
+        b,
+        e,
+        stride
+    );
+}
+
+
+// [b,e) define the sequence from which the matrix view is created
+template<typename It,typename N>
+columns_iterator<It>
+make_end_columns_iterator(
+    It b,
+    It e,
+    N step
+){
+    typedef columns_iterator<It> it_;
+    return it_(
+        boost::next(b,step),
+        e,
+        step
+    );
+}
+
+}// detail
+}// view
+}// boost
+
+#endif
+
+
+
Added: sandbox/statistics/view/boost/view/rows_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/boost/view/rows_iterator.hpp	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,150 @@
+///////////////////////////////////////////////////////////////////////////////
+// view::iterator::rows_iterator.hpp                                         //
+//                                                                           //
+//  (C) Copyright 2009 Erwann Rogard                                         //
+//  Use, modification and distribution are subject to the                    //
+//  Boost Software License, Version 1.0. (See accompanying file              //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)         //
+///////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_VIEW_ITERATOR_ROWS_ITERATOR_HPP_ER_2009
+#define BOOST_VIEW_ITERATOR_ROWS_ITERATOR_HPP_ER_2009
+#include <iterator>
+#include <algorithm>
+#include <stdexcept>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/range.hpp>
+#include <boost/view//step_count_down_iterator.hpp>
+
+namespace boost{
+namespace view{
+namespace detail{
+
+// *rows_iterator returns an iterator range whose elements are a column of a 
+// row-major matrix view of a sequence traversed by an iterator of type I. 
+// The step is the number of elements per row.
+template< class I
+        , class V = use_default
+        , class C = use_default
+        , class R = use_default
+        , class D = use_default 
+>
+class rows_iterator
+  : public iterator_adaptor< 
+             rows_iterator<I, V, C, R, D>, 
+             step_count_down_iterator<I,V,C,R,D>, 
+             iterator_range<I>,                                 //V1
+             C, 
+             iterator_range<I>,                                 // R1
+             D 
+    >
+{
+  typedef iterator_adaptor< 
+        rows_iterator<I, V, C, R, D>, 
+        step_count_down_iterator<I,V,C,R,D>, 
+        iterator_range<I>, // V1                                     
+        C, 
+        iterator_range<I>, // R1 
+        D 
+    > super_;
+
+    typedef step_count_down_iterator<I,V,C,R,D> iter_;
+    typedef iterator_range<I> range_;
+
+ public:
+    typedef typename super_::difference_type difference_type; 
+    typedef typename super_::reference reference; 
+
+    rows_iterator() : super_(){}
+
+    explicit rows_iterator(  
+       I b,
+       I e,
+       difference_type step
+    )
+    :super_(
+        iter_(b,e,step)
+    ),
+    base_e_(e),
+    step_(step){}
+    
+    rows_iterator(const rows_iterator& that)
+    :super_(that),base_e_(that.base_e_),step_(that.step_){}
+        
+    difference_type step()const{ return this->step_; }    
+    
+ private:
+
+    friend class iterator_core_access;
+
+    // default should work for:
+    // void increment();
+    // void decrement()
+    // void advance(difference_type n)
+    // difference_type distance_to(columns_iterator const& other) const{
+    // bool equal(columns_iterator const& other) const
+
+    reference dereference() const {
+        // TODO may check against end
+        if(this->base().count_down()==0){
+            throw std::out_of_range(
+                "rows_iterator::dereference at one past the end"
+            );
+        }
+        
+        I b = (this->base()).base();
+        I e = boost::next(b,this->step());
+        // This would be wrong because how step_count_down_iterator uses 
+        // modulo 1 base iterator as one-past the end.
+        // I e = boost::next(this->base(),1).base(); 
+
+        return range_(
+            b,
+            e
+        );
+    }
+
+    I base_e_;
+    difference_type step_;
+};
+
+
+template<typename It,typename N>
+rows_iterator<It>
+make_rows_iterator(
+    It b,
+    It e,
+    N step
+){
+    typedef rows_iterator<It> it_;
+    return it_(
+        b,
+        e,
+        step
+    );
+}
+
+
+// [b,e) define the sequence from which the matrix view is created
+template<typename It,typename N>
+rows_iterator<It>
+make_end_rows_iterator(
+    It b,
+    It e,
+    N step
+){
+    typedef rows_iterator<It> it_;
+    return it_(
+        make_end_step_count_down_iterator(b,e,step).base(),
+        make_end_step_count_down_iterator(b,e,step).base(),
+        step
+    );
+}
+
+}// detail
+}// view
+}// boost
+
+#endif
+
+
+
Added: sandbox/statistics/view/boost/view/step_count_down_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/boost/view/step_count_down_iterator.hpp	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,223 @@
+// Copyright (C) 2003 Roland Richter <roland_at_[hidden]>
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+//
+// in Sept 2009, Erwann Rogard's modified version:
+//  - this->foo() rather than foo() because compile errors with gcc 4.0/Mac OS
+//  - deleted reachable functionality
+//  - Uses a modulo 1 base iterator (e) to mark an end iterator
+//    sequence =  {0,1,2,3,e}, step = 2;
+//    offset:       base iterators:
+//    0 :           {0,2,3}
+//    1 :           {1,3,e}
+//
+// Warning : don't try step < 0 yet
+
+#ifndef BOOST_VIEW_DETAIL_STEP_COUNT_DOWN_ITERATOR_HPP_ER_2009
+#define BOOST_VIEW_DETAIL_STEP_COUNT_DOWN_ITERATOR_HPP_ER_2009
+
+#include <iostream> // TODO remove
+#include <string>
+#include <stdexcept>
+#include <boost/format.hpp>
+
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/next_prior.hpp>
+
+
+namespace boost {
+namespace view{
+namespace detail{   // to avoid any conflict with existing files in view
+
+template< class I
+        , class V   = use_default
+        , class C   = use_default
+        , class R   = use_default
+        , class D   = use_default 
+>
+class step_count_down_iterator
+  : public iterator_adaptor< 
+        step_count_down_iterator<I, V, C, R, D>, 
+        I, 
+        V, 
+        C, 
+        R, 
+        D 
+    >
+{
+    typedef std::string str_;
+    typedef std::size_t size_;
+public:
+
+  typedef iterator_adaptor< 
+        step_count_down_iterator<I, V, C, R, D>, 
+        I, 
+        V, 
+        C, 
+        R, 
+        D 
+  > super_type;
+
+    typedef typename super_type::difference_type difference_type;
+    typedef typename super_type::reference reference;
+
+    step_count_down_iterator(): step_( 1 ),count_down_(0)
+    {}
+    
+    // Constructs an iterator that traverses the subsequence
+    // {(i+k), ..., (i+(n-1)k),(i+(n-1)k+1)}
+    // where n is the largest number such that (i+(n-1)k+1)<=e
+    explicit step_count_down_iterator( I i, I e, difference_type theStep = 1 )
+    : super_type(i), step_( theStep ),count_down_(0)   
+    {
+        difference_type d = std::distance(i,e);
+        if(d>0){
+            this->count_down_ = (d-1)/this->step()+1;
+        }
+    
+        BOOST_ASSERT( std::distance(i,e)>=0);
+        BOOST_ASSERT( this->step() != 0 ); 
+    }
+
+    step_count_down_iterator( const step_count_down_iterator& rhs )
+        : super_type( rhs ), step_( rhs.step_ ), count_down_(rhs.count_down_)
+    {}
+
+    //operator I() const
+    //  { return this->base(); } 
+
+    difference_type 
+    step()const{ return this->step_ ;}
+
+    difference_type count_down()const{ return this->count_down_; }
+
+private:
+    friend class iterator_core_access;
+
+    /// If the step if negative behaves like a reverse_iterator
+    reference dereference() const
+    {
+        //if( this->step() < 0 ) 
+        //    return *boost::prior( this->base() );
+        //else
+        return *this->base();
+    }
+
+    void increment()
+    {   
+        if(this->count_down()==0){
+            throw std::out_of_range(
+                "view::detail::step_count_down_iterator"
+            );
+        }else{
+            this->base_reference() = boost::next(
+                this->base(),
+                (this->count_down()>1)? this->step() : 1
+            );
+        }
+        --this->count_down_;
+    }
+
+    void decrement()
+    { 
+        this->base_reference() = boost::prior(
+            this->base(),
+            (this->count_down() > 0) ? this->step() : 1
+        );
+        ++this->count_down_;
+    } 
+
+    void advance( difference_type n )
+    {
+        if(n==0){
+            return;
+        }
+        difference_type n2 = this->count_down() - n;
+        if(n2<0){
+            throw std::out_of_range(
+                "view::detail::step_count_down_iterator"
+            );
+        }
+        if(n>0){
+            this->base_reference() = boost::next(
+                this->base(),
+                (n2>0)
+                    ?(n * this->step()):((n-1) * this->step()+1)
+            ); 
+        }else{
+            this->base_reference() = boost::next(
+                this->base(),
+                (this->count_down()>0)
+                    ?(n * this->step()):-1+(n+1) * this->step()
+            ); 
+        }
+        this->count_down_ -= n; 
+    }
+
+    difference_type distance_to( const step_count_down_iterator& rhs ) const
+    {
+        BOOST_ASSERT(
+            boost::next(
+                *this,
+                this->count_down()
+            ) == boost::next(
+                rhs,
+                rhs.count_down()
+            )
+        );
+        return this->count_down()-rhs.count_down();
+    }
+
+    bool equal( const step_count_down_iterator& rhs ) const
+    {
+        return( 
+            this->base() == rhs.base() 
+                && this->step() == rhs.step() ); 
+    }
+
+private: 
+  difference_type step_;
+  difference_type count_down_;
+};
+
+// Returns an iterator that traverses the subsequence
+// {(i+k), ..., (i+(n-1)k),(i+(n-1)k+1)}
+// where n is the largest number such that (i+(n-1)k+1)<=e
+template< class I, class D >
+inline step_count_down_iterator<I>
+make_step_count_down_iterator( I i, I e, D k)
+{
+  typedef step_count_down_iterator<I> result_;
+  return result_( i, e, k );
+}
+
+// Returns the step_iterator whose base is the maximum multiple number of steps 
+// away from b, less or equal to e
+template<typename I,typename D>
+step_count_down_iterator<I>
+make_end_step_count_down_iterator(I b,I e,D step){
+    typedef typename iterator_difference<I>::type diff_;
+    typedef step_count_down_iterator<I> res_;
+    //TODO be able lift these restrictions
+    BOOST_ASSERT(step>=0); 
+    diff_ d = std::distance(b,e);
+    BOOST_ASSERT(d>=0);
+    if(d>0){
+        d = (d-1)/step;
+        b = boost::next(b,d * step+1);
+        return res_(b,b,step);
+    }else{
+        return res_(e,e,step);
+    }
+}
+
+
+}// detail
+}// view
+}// boost
+
+#endif
+
Added: sandbox/statistics/view/libs/view/doc/readme.txt
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/libs/view/doc/readme.txt	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,40 @@
+//////////////////////////////////////////////////////////////////////////////
+// view::doc::readme                                                        //
+//                                                                          //
+//  (C) Copyright 2009 Erwann Rogard                                        //
+//  Use, modification and distribution are subject to the                   //
+//  Boost Software License, Version 1.0. (See accompanying file             //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)        //
+//////////////////////////////////////////////////////////////////////////////
+
+[ Contact ]
+
+erwann.rogard_at_[hidden]
+
+[ Overview ]
+
+This C++ package extends sandbox/boost/view notably by providing a row-major representation of a matrix via a columns or rows iterator.
+
+[ Compiler ]
+
+gcc version i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1
+
+[ Dependencies ]
+
+/boost_1_39_0/ 
+
+[ iterator ]
+
+	step_count_down_iterator
+	rows_iterator
+	columns_iterator
+
+
+[ History ]
+
+Sep 2009   :	Deleted all files. Replaced them with an interface/implementation closer to boost/view 
+
+July 2009  :    Revamped row_iterator (previously vector2matrix) and added
+                transform_column
+March 2009 :    vector2matrix
+
Added: sandbox/statistics/view/libs/view/example/columns_iterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/libs/view/example/columns_iterator.cpp	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,76 @@
+///////////////////////////////////////////////////////////////////////////////
+// view::example::columns_iterator.cpp                                       //  
+//                                                                           //
+//  (C) Copyright 2009 Erwann Rogard                                         //
+//  Use, modification and distribution are subject to the                    //
+//  Boost Software License, Version 1.0. (See accompanying file              //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)         //
+///////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <list>
+#include <algorithm>
+#include <iterator>
+#include <boost/range.hpp>
+#include <boost/foreach.hpp>
+#include <boost/assign/std/vector.hpp>
+#include <boost/view//columns_iterator.hpp>
+#include <libs/view/example/step_iterator.h>
+
+void example_columns_iterator(std::ostream& os)
+{
+    os << "->example_columns_iterator" << std::endl;
+    using namespace boost;
+    using namespace view;
+    typedef int val_;
+    typedef std::vector<val_> vals_;
+    typedef range_iterator<vals_>::type vals_it_;
+    typedef range_difference<vals_>::type diff_;
+    typedef view::detail::columns_iterator<vals_it_> cols_it_;   
+    typedef iterator_value<cols_it_>::type col_; 
+    typedef range_iterator<col_>::type col_it_;
+
+    const unsigned n = 3;
+    const diff_ m = 2;
+    vals_ vals;
+    vals.reserve( n * m );
+    
+    for(unsigned i = 0; i<n*m; i++){
+        vals.push_back(i);
+    }
+    vals_it_ b = boost::begin( vals );
+    vals_it_ e = boost::end( vals );
+
+    cols_it_ cols_b(
+        b,
+        e,
+        m
+    );
+    cols_it_ cols_e = view::detail::make_end_columns_iterator(
+        b,
+        e,
+        m
+    );
+    cols_it_ cols_i = cols_b;
+    BOOST_ASSERT(std::distance(cols_i,cols_e)==m);
+    // Outer loop = columns
+    unsigned j = 0;
+    while(cols_i<cols_e){
+        col_ col = *cols_i;
+        col_it_ col_b = boost::begin(col);
+        col_it_ col_e = boost::end(col);
+        BOOST_ASSERT(std::distance(col_b,col_e)==n);
+        unsigned i = 0;
+        while(col_b!=col_e)
+        {
+            BOOST_ASSERT(i<n);
+            val_ k = i*m + j;
+            BOOST_ASSERT(*col_b == k);
+            ++col_b;
+            ++i;
+        }
+        BOOST_ASSERT(j<m);
+        ++cols_i;
+        ++j;
+    }
+    os << " end." << std::endl;
+}
Added: sandbox/statistics/view/libs/view/example/columns_iterator.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/libs/view/example/columns_iterator.h	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,15 @@
+///////////////////////////////////////////////////////////////////////////////
+// view::example::columns_iterator.cpp                                       //  
+//                                                                           //
+//  (C) Copyright 2009 Erwann Rogard                                         //
+//  Use, modification and distribution are subject to the                    //
+//  Boost Software License, Version 1.0. (See accompanying file              //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)         //
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LIBS_VIEW_EXAMPLE_COLUMNS_ITERATOR_H_ER_2009
+#define LIBS_VIEW_EXAMPLE_COLUMNS_ITERATOR_H_ER_2009
+#include <iostream>
+
+void example_columns_iterator(std::ostream& os);
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/view/libs/view/example/rows_iterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/libs/view/example/rows_iterator.cpp	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,80 @@
+///////////////////////////////////////////////////////////////////////////////
+// view::example::rows_iterator.cpp                                          //  
+//                                                                           //
+//  (C) Copyright 2009 Erwann Rogard                                         //
+//  Use, modification and distribution are subject to the                    //
+//  Boost Software License, Version 1.0. (See accompanying file              //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)         //
+///////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <list>
+#include <algorithm>
+#include <iterator>
+#include <boost/range.hpp>
+#include <boost/foreach.hpp>
+#include <boost/assign/std/vector.hpp>
+#include <boost/view//rows_iterator.hpp>
+#include <libs/view/example/step_iterator.h>
+
+void example_rows_iterator(std::ostream& os)
+{
+    os << "->example_rows_iterator" << std::endl;
+    using namespace boost;
+    using namespace view;
+    typedef int val_;
+    typedef std::vector<val_> vals_;
+    typedef range_iterator<vals_>::type vals_it_;
+    typedef range_difference<vals_>::type diff_;
+    typedef view::detail::rows_iterator<vals_it_> rows_it_;   
+    typedef iterator_value<rows_it_>::type row_; 
+    typedef range_iterator<row_>::type row_it_;
+
+    const unsigned n = 3;
+    const diff_ m = 2;
+    vals_ vals;
+    vals.reserve( n * m );
+    
+    for(unsigned i = 0; i<n*m; i++){
+        vals.push_back(i);
+    }
+    vals_it_ b = boost::begin( vals );
+    vals_it_ e = boost::end( vals );
+
+    rows_it_ rows_b(
+        b,
+        e,
+        m
+    );
+    rows_it_ rows_e = view::detail::make_end_rows_iterator(
+        b,
+        e,
+        m
+    );
+    rows_it_ rows_i = rows_b;
+
+    BOOST_ASSERT(
+        std::distance(rows_i,rows_e)==n
+    );
+    // Outer loop = rows
+    unsigned i = 0;
+    while(rows_i<rows_e){
+        row_ row = *rows_i;
+        row_it_ row_b = boost::begin(row);
+        row_it_ row_e = boost::end(row);
+        BOOST_ASSERT(std::distance(row_b,row_e)==m);
+        unsigned j = 0;
+        while(row_b!=row_e)
+        {
+            BOOST_ASSERT(j<m);
+            val_ k = i*m + j;
+            BOOST_ASSERT(*row_b == k);
+            ++row_b;
+            ++j;
+        }
+        BOOST_ASSERT(i<n);
+        ++rows_i;
+        ++i;
+    }
+
+    os << " end." << std::endl;
+}
\ No newline at end of file
Added: sandbox/statistics/view/libs/view/example/rows_iterator.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/libs/view/example/rows_iterator.h	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,14 @@
+///////////////////////////////////////////////////////////////////////////////
+// view::example::rows_iterator.h                                            //
+//  (C) Copyright 2009 Erwann Rogard                                         //
+//  Use, modification and distribution are subject to the                    //
+//  Boost Software License, Version 1.0. (See accompanying file              //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)         //
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LIBS_VIEW_EXAMPLE_ROWS_ITERATOR_H_ER_2009
+#define LIBS_VIEW_EXAMPLE_ROWS_ITERATOR_H_ER_2009
+#include <iostream>
+
+void example_rows_iterator(std::ostream& os);
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/view/libs/view/example/step_iterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/libs/view/example/step_iterator.cpp	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,80 @@
+///////////////////////////////////////////////////////////////////////////////
+// view::example::step_iterator.cpp                                          //  
+//                                                                           //
+//  (C) Copyright 2009 Erwann Rogard                                         //
+//  Use, modification and distribution are subject to the                    //
+//  Boost Software License, Version 1.0. (See accompanying file              //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)         //
+///////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <list>
+#include <algorithm>
+#include <iterator>
+#include <boost/range.hpp>
+#include <boost/foreach.hpp>
+#include <boost/assign/std/vector.hpp>
+#include <boost/view//step_count_down_iterator.hpp>
+#include <libs/view/example/step_iterator.h>
+
+void example_step_iterator(std::ostream& os)
+{
+    os << "->example_step_iterator" << std::endl;
+    using namespace boost;
+    using namespace view;
+    typedef int val_;
+    typedef std::vector<val_> vals_;
+    typedef range_iterator<vals_>::type vals_it_;
+    typedef range_difference<vals_>::type diff_;
+    typedef view::detail::step_count_down_iterator<vals_it_> step_it_; 
+
+    const unsigned n = 3;
+    const diff_ m = 2;
+    vals_ vals;
+    vals.reserve( n * m );
+    
+    for(unsigned i = 0; i<n*m; i++){
+        vals.push_back(i);
+    }
+    vals_it_ b = boost::begin( vals );
+    vals_it_ e = boost::end( vals );
+
+    for(unsigned j = 0; j<m; j++){
+        vals_it_ it = boost::next(b,j);
+        step_it_ sb     
+            = view::detail::make_step_count_down_iterator(it,e,m);
+        step_it_ se     
+            = view::detail::make_end_step_count_down_iterator(it,e,m);
+        BOOST_ASSERT(se.count_down() == 0);
+        BOOST_ASSERT(std::distance(sb,se)==n);
+        {
+            step_it_ si = sb;
+            unsigned i = 0;
+            //jth column
+            while(si<se){
+                val_ k = i*m + j;
+                BOOST_ASSERT(k == *si);
+                ++i;
+                ++si;
+            }
+            si = boost::prior(si,n);
+            BOOST_ASSERT(si==sb);
+        }
+        {
+            step_it_ si = se;
+            unsigned i = n;
+            do{
+                --si;
+                --i;
+                val_ k = i*m + j;
+                BOOST_ASSERT(*si==k);
+            }while(
+                si!=sb
+            );
+            si = boost::next(si,n);
+            BOOST_ASSERT(si==se);
+        }
+    }
+    os << " end." << std::endl;
+}
+
+
Added: sandbox/statistics/view/libs/view/example/step_iterator.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/libs/view/example/step_iterator.h	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,15 @@
+///////////////////////////////////////////////////////////////////////////////
+// view::example::step_iterator.cpp                                          //  
+//                                                                           //
+//  (C) Copyright 2009 Erwann Rogard                                         //
+//  Use, modification and distribution are subject to the                    //
+//  Boost Software License, Version 1.0. (See accompanying file              //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)         //
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LIBS_VIEW_EXAMPLE_STEP_ITERATOR_H_ER_2009
+#define LIBS_VIEW_EXAMPLE_STEP_ITERATOR_H_ER_2009
+#include <iostream>
+
+void example_step_iterator(std::ostream& os);
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/view/libs/view/src/main.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/view/libs/view/src/main.cpp	2009-09-26 19:21:06 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,21 @@
+///////////////////////////////////////////////////////////////////////////////
+// view::src::main.cpp                                                //  
+//                                                                           //
+//  (C) Copyright 2009 Erwann Rogard                                         //
+//  Use, modification and distribution are subject to the                    //
+//  Boost Software License, Version 1.0. (See accompanying file              //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)         //
+///////////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include <libs/view/example/step_iterator.h>
+#include <libs/view/example/columns_iterator.h>
+#include <libs/view/example/rows_iterator.h>
+
+int main(){
+
+    example_step_iterator(std::cout);
+    example_columns_iterator(std::cout);
+    example_rows_iterator(std::cout);
+
+    return 0;
+}
\ No newline at end of file