Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-08-27 09:12:42


This is a good idea, but it is common to need to select the stride at
runtime.

A couple of my colleagues made such a policy and associated generators;
perhaps you'd like to take a look? If so, I'll see if I can convince them to
post it.

An intersting fact about striding over matrices: to avoid undefined behavior
you usually need to allocate an extra row (or column) so that there's a
valid end iterator position.

-Dave
----- Original Message -----
From: "Jeremy Siek" <jsiek_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, August 27, 2001 10:06 AM
Subject: Re: [boost] stride_iterator_policy

>
> Sounds good! :) I assume you'll add all the other iterator operations such
> as decrement, advance, etc.
>
> Cheers,
> Jeremy
>
> On Mon, 27 Aug 2001, Toon Knapen wrote:
>
> toon> If others would also be interested I would like to see
iterator_adaptors
> toon> extended with a strided_iterator_policy.
> toon>
> toon> Using the strided_iterator_policy, every increment of the iterator
will
> toon> advance the iterator according a user defined 'stride'
> toon>
> toon> { // begin example :
> toon>
> toon> template < int N >
> toon> class stride_iterator_policy : public
boost::default_iterator_policies
> toon> {
> toon> public:
> toon> template <class BaseType>
> toon> static void increment(BaseType& x) { std::advance( x, N ); }
> toon> };
> toon>
> toon> boost::iterator_adaptor< RealValues::const_iterator,
> toon> stride_iterator_policy<3> > dof_it( dof_values.begin() );
> toon> prod = std::inner_product( shapes.begin(), shapes.end(), dof_it,
0.0 );
> toon>
> toon> } // end example
> toon>
> toon> The iterator is here used to traverse the first row of every column
in a
> toon> column-major matrix.
> toon>
> toon>
> toon>
> toon> This type of iterator is frequently used within for instance matrix
> toon> operations.
> toon>
> toon> toon
> toon>
> toon>
> toon> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
> toon>
> toon> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> toon>
> toon>
> toon>
>
> ----------------------------------------------------------------------
> Jeremy Siek http://php.indiana.edu/~jsiek/
> Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
> C++ Booster (http://www.boost.org) office phone: (812) 855-9761
> ----------------------------------------------------------------------
>
>
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk