| Benoît Jacob ( @ 2007-08-26 09:19:00 |
| Entry tags: | kde eigen eigen2 tvmet c++ matrix librar |
The long road to Eigen 2
It's funny how none of the existing libraries for vector and matrix math seems to do all what one might want. Each of these libs (Blitz++, MTL, LAPACK, GSL, TVMET, GMM++...) is specialized for certain needs. Usually, an app will choose the most suitable one for its needs, and be happy. But KDE is a huge meta-project with lots of sub-projects, so it has a very broad range of mathematical needs, which is not covered by any of the specialized libraries.
Writing from scratch such a general math library would take many man-years. However, what one can do is to merge existing libraries into a single one.
A killer feature that we absolutely want is expression templates. It's a strange C++ technique that allows to do things like a = b + c without paying the cost of having a temporary object allocated on the stack and then copied into a. Basically, it allows to use natural mathematical notation without any overhead. It even allows things like
matrix.row(i) += matrix.row(j)which would be impossible otherwise.
The best expression templates for a matrix library are currently found in TVMET. Unfortunately, TVMET has been stagnant for 2 years and has been very little used by other projects, which is probably due to being too abstract, aiming too much for theoretical perfection.
For Eigen2, I decided to use TVMET as my starting point, instead of Eigen1. Of course, the contents of Eigen1 will be incorporated into Eigen2 as soon as possible. However, for now my work has been focused in shaping TVMET for my needs. I've converted it from autotools to CMake, and I've removed tons of stuff that I don't need, shrinking it down from 12000 to 7000 lines of code, and I've still room to shrink it further, and I've already added some good stuff from Eigen1, such as sane fuzzy comparisons. I'm currently porting the unit-tests from CPPUnit to QTestLib, and by the way I'm improving them a lot now that there are sane fuzzy comparisons.
What's next? Once I'll have fully reshaped TVMET and incorporated Eigen1 into it, I'll have a working Eigen2 for tiny (i.e. fixed-size) vectors and matrices. For dynamic-size objects, both dense and sparse, I'll wrap GMM++. In order to make this possible, the expression templates from TVMET will have to be adapted, as for instance loop unrolling will no longer be possible.
It's a very exciting project that is bound to fill a very bad gap in the current existing software. It requires only knowledge of pure C++, and vague notions of matrix mathematics. Your help is more than welcome, as there's a lot to do. So don't hesitate, join me: eigen at lists tuxfamily org.