GSoC 2012 Proposal: Continued Work on a D Linear Algebra library (SciD - std.linalg)

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Apr 8 12:00:45 PDT 2012


On Sun, Apr 08, 2012 at 12:59:08PM -0500, Caligo wrote:
> On Tue, Apr 3, 2012 at 6:20 AM, Cristi Cobzarenco
> <cristi.cobzarenco at gmail.com> wrote:
[...]
> > Also I'm not sure how a case like this will be compiled, it may or
> > may not allocate a temporary:
> >
> > a[] = b[] * c[] + d[] * 2.0;
> >
> > The expression templates in SciD mean there will be no temporary
> > allocation in this call.
> >
> 
> Why are expression templates used?  Are you pretty much rewriting
> Eigen in D ?  I don't see why expression templates would be needed
> with D.

Expression templates are necessary to eliminate temporaries and optimize
loops. The reason libraries like BLAS are so efficient is because they
directly implement common operations like A = k*B + C. Without
expression templates, a D implementation would create a temporary for
k*B and then k*B + C and then assign the result, whereas expression
templates allow you to directly compute the elements of A in a single
loop over the matrix elements.


T

-- 
Change is inevitable, except from a vending machine.


More information about the Digitalmars-d mailing list