Boost logo

Glas :

Re: [glas] arithmetic operations

From: Andreas Pokorny (andreas.pokorny_at_[hidden])
Date: 2005-10-28 05:03:17

On Thu, Oct 27, 2005 at 11:01:54PM +0200, Toon Knapen <toon.knapen_at_[hidden]> wrote:
> What if as a user you can configure himself what operator* means?

I do something like that in my diploma thesis, but with a different goal in mind.
I do allow the user to declare the evaluation strategy on assignment or expression

  vec = A*x + b;
with a matrix A and x, b being column vectors, the meaning of this
expression and assignment will always be the same. But the user can
choose between different evaluation strategies:
  vec[doubled_acc] = A*x + b;
Will use compensated floating point algorithms to avoid cancelation. In
the next days I will add support for multi precision number libraries,
and after that I will look into supporting simd instructions.

The system works in two steps, first the expression tree is gathered,
until C++ reaches the assignment operator, then the expression tree
is transformed using node structures defined by the default strategy or
a special one. These strategies are structures without runtime data, but
group these node types.