|
Boost : |
From: Larry Evans (cppljevans_at_[hidden])
Date: 2008-03-14 14:19:50
On 03/12/08 20:21, Max Motovilov wrote:
> Some final comments.
>
> First, in the code I posted above "push_back< S, A>" should be replaced
> with "push_front< S, A >", otherwise top-level sequence cannot be a list.
>
> Second, while recursive implementation is very similar to the iterative,
> it still generates the combinations in reverse order :) Not important
> for applications I can think of, but still.
>
> Finally, the performance comparison. I did it with GCC 4.2 on an Intel
> dual core with 4G RAM running 64-bit Ubuntu Gutsy.
I just uploaded to boost vault, in 'Template Metaprogramming' directory,
an n-ary cross product which uses the binary one (or really a slight
modification) which I posted on the wiki earlier. It uses
mpl::fold and the binary and joint_view to implement the
n-ary cross product. I doubt it's as efficient as your
iterative one, but it might provide some more ideas for
other implementations. If you post your benchmark, I could
actually make a comparison.
Anyway, the partial output is:
===>Enter:{{test3
size_type=12
cross_nproduct_view<Domains>
{ row_column_view
size=4
{ 30002
, 2001
, 101
, 0
}
, row_column_view
size=4
{ 30002
, 2001
, 100
, 0
}
, row_column_view
size=4
{ 30002
, 2000
, 101
, 0
}
, row_column_view
...
which has nicely indented output produced by some private
code. Since you don't have that, you can switch it off
by #undef'ing INDENT_PRINT.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk