Boost logo

Ublas :

From: Vardan Akopian (vakopian_at_[hidden])
Date: 2007-03-22 15:10:33


> I've been testing the performance of ublas's matrix multiplication. I
> encountered a behavior that I don't quite understand. Consider the following
> code snippet:
>
>
>
> Ublas::matrix<double> m1(100, 100), C(100, 100);
>
> Ublas::Prod(m1, m1)
>
> c = ublas::prod(m1, m1)
>
>
>
> The second line and the third line are identical, except that in the third
> line I assign the result of the product operation to a pre-sized matrix. The
> second line appears to take almost no time to execute (0 millisecs, that
> is). The third line takes a non-zero amount of time to execute, however.
>

The second and third line are not identical. The second line just
creates an expression template which is never really evaluated.
The third line forces the evaluation because of the assignment. Thus
the difference in execution times.

-Vardan