|Tiny Vector Matrix library using Expression Templates||Sourceforge Project Page|
"Tiny" is a subjective term, but typically means vectors and matrices of size ten (10) or less.
The technique used internally by tvmet is described by Todd Veldhuizen:
and is used by his blitz++, too. Therefore, the speed achieved by tvmet is similar to the speed of blitz++. Unfortunately, blitz++ isn't developed any more (year 2001, 2002) because of other interests being pursued by Todd Veldhuizen (like his Ph.D.). Furthermore, blitz++'s TinyVector is mainly developed for use by the blitz++ Array class -- and not for minimalistic/tiny fast math support for which tvmet is designed. Because of this, the operators and functions are incomplete or not supported well. blitz::TinyMatrix supports a few lesser operators and functions (as with blitz::TinyVector). blitz++ doesn't conform to STL (e.g. Container<>::value_type isn't defined), it defines a T_numtype or, for blitz::TinyVector, it does have an iterator begin() - but the end() is missing (blitz::TinyMatrix doesn't have anything).
These were reasons why I developed tvmet. Still, tvmet is designed to be more than a mere rehashing of blitz++. The primary design goals are:
The dimensions for vectors and matrices are statically bound at compile time using template arguments. The bounded dimensions feature a compile time dimension check to force adherence to proper dimensional sizes between operands (even in the night if you are sleepy). For example, you can't assign a Vector or Matrix with dimension = 3 to a Vector or Matrix of dimension = 4; nor can you create an expression using a binary operation between arguments with incompatible dimensions. This is a major difference between tvmet (which features this) and blitz++ (which does not prevent from this). Nevertheless, tvmet isn't a matlab, maple or octave for C++.
tvmet is a general purpose library and is not (yet) a linear algebra library. It does not have an interface to other numerical libraries as BLAS or LAPACK. Tiny Vector Matrix template library offers these features:
a ? b : c(see eval for use).
Although there are many advantages and features, tvmet has some limitations. Due to the expression template and meta template programming, the compilation time increases for higher dimensional constructs. This can cause resource limitations, especially for memory (during compilation). On the other hand, the runtime performance will also decrease on higher order. Therefore only use tvmet only tiny (typically less than 10) sizes. (The maximum useful size/dimension depends on the operation, of course.) The Benchmark gives a good entry point about these problem. Other general purpose libraries and linear algebra libraries will do a better job for larger matrix/vector problems.