Proposal: Operator overloading without temporaries

Norbert Nemec Norbert at Nemec-online.de
Tue Mar 28 06:40:25 PST 2006


Don Clugston wrote:
> Obviously not with real matrices (C*D is not a pointwise operation), but
>  point taken. (BTW, the temporaries are still there, they're just in
> registers this time (A[i]*B[i], C[i]*D[i]). The proposal does get rid of
> all unnecessary temporaries, the problem is that there's no vectorisation).

Point accepted. For matrices, the issues are much more complicated, but
still there is quite a bit of optimization possible when vectorization
is taken into accound. p.e. the expression A*B+C can be done very
efficiently when done in one shot. (There even are BLAS routines for
this kind of combined operations, which are very common in many fields
of application.)

> I completely agree. I see this as fixing the general case, but it does
> nothing for vectorisation. I suspect that array expressions are somewhat
> special as regards expressions, because of the vectorisation
> possibility. If we had array expressions, this might eliminate the
> necessity for expression templates. Do you think that's right?

Those have their right of existance and should be supported by the
language: array expressions are more comfortable to use and to optimize
than a corresponding ET-library, but expression templates can be used
for a much larger field of applications than just vectorized
expressions. Just consider the linear algebra example above, where an
expression template library might automatically optimize A*B+C into a
single BLAS function call.



More information about the Digitalmars-d mailing list