|
Boost : |
From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-03-05 15:17:27
Is there any interest in a proposed mpl sequence, fold_seq,
derived from mpl::fold and contained in
boost-sandbox.sourceforge.net/vault/ in
cppljevans/mpl/fold_seq_test.zip? This zip contains:
* a test driver, fold_seq_test.cpp
* a header file, fold_seq.hpp
* bjam output of driver for intel
* bjam output of driver for gcc.
A better name for fold_seq might be cummulative_app since
each element is a "partial_application" of the ForwardOp
"operation" to part of the Seqence, where ForwardOp and
Seqence are the arguments to fold, as described here:
http://www.boost.org/libs/mpl/doc/refmanual/fold.html
The reason for term "partial_application" is that it
corresponds to "partial sum" described here:
http://mathworld.wolfram.com/PartialSum.html
Alternative names include "prefix reduction" or "scan":
http://nf.apac.edu.au/training/MPIRefs/MPI_1.1/node84.html#Node84
Anyway, it seems that it's a useful extension to fold,
since, as seen by the above references, the corresponding
math concept occurs often.
In addition, the test driver in the vault contains
test_partial_product, where the value's at each element of
the fold_seq correspond to elements in a cummulative
product:
http://mathworld.wolfram.com/CumulativeProduct.html
Such a cummulative product could be used to calculate, at
compile time, the strides for an instance of mult_array.
Also, fold_seq could be used as a replacement for the
get_side_type template class mentioned here:
http://article.gmane.org/gmane.comp.lib.boost.devel/118867
and used to access the elements in a tuple, as demonstrated
by the test_tuple_access function in the test driver.
I'd be glad to discuss improvements or reasons why it's
unneeded.
TIA.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk