Designing a matrix library for D

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 23 22:11:59 PDT 2014


On Tue, Jun 24, 2014 at 03:46:09AM +0000, Tofu Ninja via Digitalmars-d wrote:
> On Tuesday, 24 June 2014 at 03:29:52 UTC, H. S. Teoh via Digitalmars-d
> wrote:
> 
> >a compile-time DSL instead of hack tricks like expression
> 
> That sounds like a it will be very odd to use and most likely have
> very little benefit. I think most people would agree that matrix math
> is a good use case for operator overloading.

The DSL can look exactly like a regular matrix expression.

The case against operator overloading, is that unless you resort to
hacks like expression templates, the result will likely have poor
performance, because the overloaded operator can only see one or two
arguments at a time, whereas a compile-time DSL interpreter can analyze
the entire expression and use algebraic rules to rewrite it in a form
that can be efficiently implemented, eg., in terms of lapack/blas
primitives for computing expressions like A*x + y. Doing this sort of
rewriting with expression templates would be a maintenance nightmare.


T

-- 
Lawyer: (n.) An innocence-vending machine, the effectiveness of which depends on how much money is inserted.


More information about the Digitalmars-d mailing list