Boost logo

Proto :

Subject: Re: [proto] Precomputing common matrix products in an expression
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2012-07-15 03:47:35

On Friday, July 13, 2012 21:51:40 Bart Janssens wrote:
> Hi guys,
> I've been thinking about a feature for our DSEL, where lots of matrix
> products can occur in an expression. Part of an expression might be:
> nu_eff * transpose(nabla(u)) * nabla(u) + transpose(N(u) +
> coeffs.tau_su*u_adv*nabla(u)) * u_adv*nabla(u)
> Here, u_adv*nabla(u) is a vector-matrix product that occurs twice, so
> it would be beneficial to calculate it only once. I was wondering if
> it would be doable to construct a fusion map, with as keys the type of
> each product occurring in an expression, and evaluate each member of
> the map before evaluating the actual expression. When the expression
> is evaluated, matrix products would then be looked up in the map.
> Does this sound like something that's doable? I'm assuming the fold
> transform can help me in the construction of the fusion map. Note also
> that each matrix has a compile-time size, so any stored temporary
> would need to have its type computed.

In a way, this reminds me of how local variables in phoenix work.
You have the key (the variables name) which is a distinct type, and you look
up the value of that key in a fusion map. The only real difference is that
local variables aren't computed lazily, but that should be a nobrainer to add.
Might get interesting in a multi-threaded environment though.

> Cheers,

Proto list run by eric at