BLADE 0.2Alpha: Vector operations with mixins, expression templates, and asm

Mikola Lysenko mclysenk at mtu.edu
Thu Apr 5 21:38:13 PDT 2007


Bill Baxter wrote:
> Mikola Lysenko wrote:
>> Excellent work!  I have to say that I've had my misgivings about mixin 
>> statements, but I'm glad to see that BLADE and Don's hard work have 
>> proven me wrong.  Compile time vector expressions are desperately 
>> needed, and this library goes a long way to sorting things out.  As 
>> far as meta-type tricks go, this is by far the coolest I've ever seen 
>> in any  programming language.
>>
>> One very interesting application I would like to see with this 
>> technique would be a compile time geometric algebra library.  If no 
>> one writes one by this summer, I will probably do it myself.  
>> (Actually, when I heard the name BLADE, my heart skipped a beat 
>> thinking it was a GA library, but alas it is not...)  Maybe it is my 
>> unrestrained exuberance, I would guess that a strong D implementation 
>> should easily crush the leading C++ GA lib, GAIGEN in both performance 
>> and ease of use.
>>
>> For reference, here is the GAIGEN homepage:
>> http://www.science.uva.nl/ga/gaigen/content_gaigen.html
>>
>> -Mikola Lysenko
> 
> Wow, that looks really sweet.  Last I heard on GA was that it was good 
> for working out the math, but too slow for real use.  Now it's fast too 
> apparently!  Now I've really got to learn GA.  And a D compile-time fu 
> version would be neat.
> 
> One question: from the GAIGEN page it sounds almost like GAIGEN 
> generates off-line a set of primitive operations that are efficient for 
> the chosen specific GA domain (3D euclidean or whatever).  If so, then 
> that sounds pretty good to me.  What's wrong with using an off-line 
> approach?  Are there some expressions things that are just too difficult 
> to optimize ahead of time without seeing the whole expression as it will 
> actually used?  Or is it more like GAIGEN creates the primitives 
> operations for a particular GA like dot product, cross product, and 
> matrix multiplies?  If so then it still maybe leaves a lot of 
> optimization opportunities on the floor.  Like evaluating A*B*C*vec as 
> ((A*B)*C)*vec vs. (A*(B*(C*vec))) can make a big difference if ABC are 
> big matrices and vec is a small vector.
> 
> --bb

As I understand it, GAIGEN uses an external program to generate the 
implementation, and the implementation uses template expressions to 
actually perform the optimizations.  The process seems a bit contrived 
to me, but I'm sure they have their reasons.  Also if you look at the 
performance statistics on that site, you will see that the geometric 
algebra implementation is actually SLOWER than the standard linear 
algebra (but not by much.)  The main advantage of GA when programming is 
that the code is shorter and simpler.

Recently, GA has been getting some more widespread acceptance and 
commercial success.  Take Geomerics for example; they're a small company 
that specializes in graphics and physics software based on GA inspired 
algorithms.  Here is there website:

http://www.geomerics.com

They've got a very impressive realtime radiosity engine that seems to 
have gotten some press in the last few weeks.  There's also some 
interesting stuff in the technology section on their website.

Writing a GA library for D is definitely on my todo list (right after I 
get done with this semester of classes.)  I will probably work on it 
this summer unless someone beats me to it.

-Mik



More information about the Digitalmars-d mailing list