[Numpy-discussion] Efficient operator overloading

Matthieu Brucher matthieu.brucher@gmail....
Wed Apr 18 13:24:42 CDT 2007

> This does not mean that all use of operator overloading is inherently
> bad. Notably, there is a C++ numerical library called Blitz++ which can
> avoid  these tempraries for small fixed-size arrays. As it depends on
> template metaprogramming, the size must be known at compile time. But if
> this is the case, it can be just as efficient as Fortran if the
> optimizer is smart enough to remove the redundant operations. Most
> modern C++ compilers is smart enough to do this. Note that it only works
> for fixed size arrays. Fortran compilers can do this on a more general
> basis. It is therefore advisable to have array syntax built into the
> language syntax it self, as in Fortran 90/95 and Ada 95.

Boost.ublas uses template expressions, I implemented them in my own matrix
lib, it's very simple to do. Even for big matrix, it can be interesting. If
the size is static, bothering with fixed-size arrays is useless, the
compilers do optimize the temporaries ; but using template expression with
iterators for general arrays allows to approach fixed-size arrays speed.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070418/4f97a5a3/attachment-0001.html 

More information about the Numpy-discussion mailing list