Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2006-09-17 11:54:43


On 09/17/2006 09:16 AM, Andy Little wrote:
> "Larry Evans" <cppljevans_at_[hidden]> wrote in message
> news:eejch5$a8t$1_at_sea.gmane.org...
>
>>On 09/05/2006 08:36 AM, David Abrahams wrote:
[snip]
>>>1. use a fusion vector of fusion vectors.
[snip]
>>It suddenly dawned on me that 1 above seems a pretty simple solution.
>>Is there some reason for not using 1?
>
> Well, Lets assume that you could use one infinitely long sequence. That is
> slightly simpler (IMO) because it would work exactly the same for any size
> matrix, iow each could have the same representation, which might be something
> like:
>
> matrix<rows, columns, sequence>
>
> which actually is what I am currently going for.
>
> I havent tried the alternative., but I suspect that the metaprogramming of it
> would be more complicated.
>
> Ultimately I suppose the interface should be separated from the implementation
> and it should work for both, however I'm certainly not planning something
Let's see if I understand. First, shorthand:

   rank2_method means the fusion vector of fusion vector method.
   rank1_method means the existing method as illustrated in OP.

One thing that would be more complicated with rank2_method
vs. rank1_method is the initialization interface. IOW with the
rank1_method there's this initialization interface:

   typedef tuples::tuple<T0_0,T0_1,T1_0,T1_1> rank1_type;

   rcmatrix<2,2,rank1_type>
   mat
   ( rank1_type
     ( val0_0
     , val0_1
     , val1_0
     , val1_1
     )
   );

where rank1_type was matrix_elements in the OP.

With rank2_method, the iterface would be:

   typedef fusion::vector<T0_0,T0_1> rank1_0_type;
   typedef fusion::vector<T1_0,T1_1> rank1_1_type;
   typedef fusion::vector<rank1_0_type,rank1_1_type> rank2_type;

   rcmatrix<2,2,rank2_type>
   mat
   ( rank2_type
     ( rank1_0_type
       ( val0_0
       , val0_1
       )
     , rank1_1_type
       ( val1_0
       , val1_1
       )
     )
   );

So, the extra complexity the rank2_method is more typing;
however, that buys you, IMO, clearer code.

(WARNING: above code has not been compiled)

Is there something I'm missing?


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