
Boost : 
From: Larry Evans (cppljevans_at_[hidden])
Date: 20050316 17:17:35
On 03/06/2005 02:17 PM, Pavel Chikulaev wrote:
> "Larry Evans" <cppljevans_at_[hidden]> wrote in message
[snip]
(from Larry Evans' post here:
http://article.gmane.org/gmane.comp.lib.boost.devel/119148
)
>> and then the operator* and + could be used to maybe make a lazy
>> transtive closure, First^*, of this relation. Similarly, it could
[snip]
>>In addition to the above, I'd also like to see if the value
>>of a matrix multiplication and addition can be computed at compile
>>time. If so, then I'm guessing that, given enough resources,
>>a spirit grammar (normalized as described above) can be analyzed at
>>compile time and used to generate a parser with compiletime generated
>>lookahead sets.
> Actually the purpose of the library is to choose best algorithm at
> compiletime, and then apply
> it at runtime.
Yeah, that's probably where I've misunderstood your library. The
values I wanted would all be calculated at runtime; however, I'm afraid
the compiler will be overwhelmed and abort (due to max template
instantiation depth). Hence, I'm also anticipating I'll may need
something like your library. Maybe the expression for transitive
closure can be created and then feed with some values to compute the
closure.
Anyway, what I think will work for compiletime calculation is
a combination of fold_seq (see vault under cppljevans/mpl)
where the ForwardOp is simply matrix multiplication. Then, if the 1st
argument to fold_seq is the a sequence of identical values of
some binary relation, M, then the result would be a sequence:
{ M, M*M, M*M*M, ..., M^n }
where n is the size of the 1st arg to fold_seq and the * in the above is
simply matrix multiplication, and M^n is M raised to the nth power.
The transitive closure is gotten by maxtrix sum of this.
Unfortunately, this is only for types and not values. Maybe you could
figure out how to actually use it to calculate the values? If not,
I'll try to get to it later.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk