Proposal: Operator overloading without temporaries

James Dunne james.jdunne at gmail.com
Tue Mar 28 07:16:46 PST 2006


Norbert Nemec wrote:
> 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.

If possible, can someone lay out a clear definition of both "array 
expressions" and "expression templates"?  I'd really like to fully 
understand what's possible in this area for my own research.

Thanks,

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O 
M--@ V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e 
h>--->++ r+++ y+++
------END GEEK CODE BLOCK------

James Dunne



More information about the Digitalmars-d mailing list