Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2008-03-12 07:29:23


On 03/12/08 06:10, Larry Evans wrote:
> On 03/11/08 22:42, Max Motovilov wrote:
> [snip]
>> I apologize in advance if something along these lines is already
>> available; however current public documentation doesn't mention such a
>> facility and a brief glance into SVN did not reveal one either...
>>
>> product_view
>>
>> Description: provides a view of a Cartesian product of multiple
>> sequences. Modeled after zip_view in that it expects a sequence [of
>> length n] of sequences S1...Sn as its argument and lazily generates a
>> sequence [of length Prod{1...n}( size< Si > )] of sequences
>> S1[1]...Sn[1] through S1[n]...Sn[n]. Whew... I know I can write better
>> documentation than that if I put my mind to it :(
>>
> From Prod[1..n}(size<Si>} it appears this just flattens a list 1 level.
> IOW:
> from:
> list
> < list< A0_0, A0_1>
> , list< A1_0, A1_1>
> ...
> , list< An_0, An_1.
> >
> it produces:
> list
> < A0_0, A0_1
> , A1_0, A1_1
> ...
> , An_0, An_1
> >
>
> Is that right?
>
OOPS, that would be Sum{1..n}(size<Si>} so I guess this would be
more like an outer-product where for:

Input:
   list
   < list<A0_0, A0_1> //S1
   , list<A1_0, A1_1> //S2
>
Output:
   list
   < list<A0_0, A1_0> //s1[1]...S1[2]? Nope, this is S1[1]...S2[1]
   , list<A0_0, A2_0>
   , list<A0_1, A1_0>
   , list<A0_1, A1_1>
>

Here, since sizes of inputs are 2 and 2, size of output is 2*2=4.
But that's inconsistent with:

   sequences S1[1]...Sn[1] through S1[n]...Sn[n]

Could you please clarify? I'm lost ;(


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