|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56408 - sandbox/statistics/matrix_view/libs/matrix_view/example
From: erwann.rogard_at_[hidden]
Date: 2009-09-26 20:12:47
Author: e_r
Date: 2009-09-26 20:12:46 EDT (Sat, 26 Sep 2009)
New Revision: 56408
URL: http://svn.boost.org/trac/boost/changeset/56408
Log:
am
Added:
sandbox/statistics/matrix_view/libs/matrix_view/example/rows_iterator.cpp (contents, props changed)
Removed:
sandbox/statistics/matrix_view/libs/matrix_view/example/transform_column.cpp
sandbox/statistics/matrix_view/libs/matrix_view/example/transform_column.h
Added: sandbox/statistics/matrix_view/libs/matrix_view/example/rows_iterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/matrix_view/libs/matrix_view/example/rows_iterator.cpp 2009-09-26 20:12:46 EDT (Sat, 26 Sep 2009)
@@ -0,0 +1,81 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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/matrix_view/iterator/rows_iterator.hpp>
+#include <libs/matrix_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);
+ os << "std::distance(row_b,row_e) = " << std::distance(row_b,row_e) << std::endl;
+ 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
Deleted: sandbox/statistics/matrix_view/libs/matrix_view/example/transform_column.cpp
==============================================================================
--- sandbox/statistics/matrix_view/libs/matrix_view/example/transform_column.cpp 2009-09-26 20:12:46 EDT (Sat, 26 Sep 2009)
+++ (empty file)
@@ -1,61 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// view::example::transform_column.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/iterator/transform_iterator.hpp>
-#include <boost/matrix_view/algorithm/transform_column.hpp>
-#include <libs/matrix_view/example/transform_column.h>
-
-void example_transform_column(std::ostream& out)
-{
- out << "-> example_transform_column" << std::endl;
-
- using namespace boost;
- typedef int val_;
- typedef std::vector<val_> vec_;
- typedef range_size<vec_>::type size_;
-
- const unsigned n_col = 2;
- const unsigned n_row = 5;
- {
- typedef range_iterator<vec_>::type it_;
-
- vec_ vec;
- vec_ column;
- {
- using namespace boost::assign;
- size_ n = n_col * n_row;
- for(unsigned i = 0; i< n; i++){
- vec.push_back(i);
- }
- }
- for(unsigned j = 0; j<n_col; j++){
- column.clear();
- view::copy_column<n_col>(
- boost::begin(vec),
- boost::end(vec),
- j,
- std::back_inserter(column)
- );
- for(unsigned i = 0; i<n_row; i++){
- BOOST_ASSERT(
- vec[ i * n_col + j ] == column[i]
- );
- }
- }
-
- }
-
- out << "<-" << std::endl;
-}
\ No newline at end of file
Deleted: sandbox/statistics/matrix_view/libs/matrix_view/example/transform_column.h
==============================================================================
--- sandbox/statistics/matrix_view/libs/matrix_view/example/transform_column.h 2009-09-26 20:12:46 EDT (Sat, 26 Sep 2009)
+++ (empty file)
@@ -1,14 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// view::example::transform_column.h //
-// //
-// Copyright 2009 Erwann Rogard. Distributed under the Boost //
-// Software License, Version 1.0. (See accompanying file //
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
-//////////////////////////////////////////////////////////////////////////////
-#ifndef LIBS_VIEW_EXAMPLE_TRANSFORM_COLUMN_H_ER_2009
-#define LIBS_VIEW_EXAMPLE_TRANSFORM_COLUMN_H_ER_2009
-#include <ostream>
-
-void example_transform_column(std::ostream&);
-
-#endif
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