[Numpy-discussion] Efficient operator overloading
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...
More information about the Numpy-discussion