Boost logo

Proto :

Subject: Re: [proto] Defining the result domain of a proto operator
From: Brandon Kohn (blkohn_at_[hidden])
Date: 2011-08-26 11:27:08


On 8/26/2011 11:18 AM, Eric Niebler wrote:
> On 8/26/2011 10:56 AM, Joel Falcou wrote:
>> On 26/08/2011 16:45, Eric Niebler wrote:
>>> Before I answer, can you tell me why you've decided to put vector and
>>> matrix operations into separate domains? This seems like an artificial
>>> and unnecessary separation to me.
>>
>> We have a system of specialisation where being able to make this
>> distinction allowed us to replace sub proto tree by a pregenerated call
>> to some BLAS functions or to apply some other Linear Algebra math based
>> simplification.
>>
>> We also have a covector domain which allow us to know that : covector *
>> vector is a dot product while vector * covector generate a matrix. In
>> the same way, covector * matrix and matrix * vector can be recognized
>> and handled in a proper way.
>
> Why can't you use a grammar to recognize patterns like these and take
> appropriate action?
>

I solved this kind of problem by tagging the various types in traits
structs and then embedding these traits in the transforms for the
various operations.

Here are examples of my expression, grammar, and binary function
definitions:

https://github.com/brandon-kohn/Geometrix/blob/master/geometrix/algebra/expression.hpp

https://github.com/brandon-kohn/Geometrix/blob/master/geometrix/algebra/grammar.hpp

https://github.com/brandon-kohn/Geometrix/blob/master/geometrix/algebra/binary_functions.hpp

I'm not sure if this is the best way to do these, but it does work.

Cheers,

Brandon


Proto list run by eric at boostpro.com