|
Proto : |
Subject: Re: [proto] Defining the result domain of a proto operator
From: Eric Niebler (eric_at_[hidden])
Date: 2011-08-26 11:56:56
On 8/26/2011 11:44 AM, Eric Niebler wrote:
> Proto will
> compute the domain of m*v to be matrix. It will use matrix_domain's
> generator to post-process the new expression. That generator can do
> anything -- including placing the new expression in the vector domain.
> In short, there is no requirement that a domain's generator must produce
> expressions in that domain. Just hack matrix_domain's generator.
Expanding on this a bit ... there doesn't seem to a sub-/super-domain
relationship between matrix and vector. Why not make them both (together
with covector) sub-domains of some abstract nt2_domain, which has all
the logic for deciding which sub-domain a particular expression should
be in based on its structure? Its generator could actually be a Proto
algorithm, like:
nt2_generator
: proto::or_<
proto::when<
vector_grammar
, proto::generator<vector_expr>(_)>
proto::when<
covector_grammar
, proto::generator<covector_expr>(_)>
proto::otherwise<
proto::generator<matrix_expr>(_)>
>
{};
struct nt2_domain
: proto::domain<nt2_generator>
{};
Etc...
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Proto list run by eric at boostpro.com