Main class hierarchies:
|
|
Main helper classes:
|
Matrix and vector types:
In order to have ease of use and a straightforward user interface, some trade-offs between verbosity, speed and memory efficiency are present:
Debugging:
External libraries:
Delayed evaluation via expression templates:
As an example, when the compiler evaluates the line mat Z = A + B + C, the line is converted, at compile time, to be mat Z = X, where X is of type Glue< Glue<mat, mat, glue_plus>, mat, glue_plus>. The constructor for the 'Mat' class then uses the last template argument to call glue_plus::apply(*this, X), which sets the size of Z and evaluates A + B + C in one loop (i.e. no temporary matrices are created).
The recursive template type Glue< glue_data<mat, mat, glue_plus>, mat, glue_plus> is constructed via repeated invocations of operator+(). First, operator+(mat,mat) is called, which returns an object of type Glue<mat, mat, glue_plus>. This object is then fed to operator+(Glue<T1,T2,glue_type>, mat) which returns an object of type Glue< Glue<mat, mat, glue_plus>, mat, glue_plus>.
Note that the compiler can optimise away the temporary object X as well as the intermediate object resulting from calling operator+() the first time. Furthermore, the single loop which evaluates A + B + C can be inlined.