Boost logo

Ublas :

From: Michael Stevens (mail_at_[hidden])
Date: 2005-09-22 13:33:18

On Mittwoch 21 September 2005 20:04, Frank Astier wrote:
> I'm still trying to multiply a sparse matrix by a vector efficiently,
> comparing ublas to just looping over the whole matrix.
> For a square matrix of size 256x256 of floats with % non-zeros
> between 10 and 90%, ublas does not seem to be efficient compared to
> hand-crafted code that just carries out the naive matrix
> multiplication. axpy_prod performs worse than prod. sparse_matrix in
> 1_32 performs 3 times worse than compressed_matrix. I was hoping
> ublas would be efficient even with matrices of that size, and not
> that far off from "naive" code speed.
> I tried boost 1_32 and 1_33. Performance seems to be worse in 1_33 by
> a factor 4 ?!?

This caught my eye. The result is rather umplesant. I was amazed that there
could be a change that effected compressed_matrix.

Turn out the problem is much more general. I finally traced the problem to
some work done to avoid unused variable warnings in release builds. This
effected the BOOST_UBLAS_CHECK macro (similar to assert) do that the checked
expression was always evaluated, even if NDEBUG is defined. This effects all
of uBLAS in Boost_1.33.0 :-(

The fix is rather simple. In "exception.hpp" near the end the following is
#define BOOST_UBLAS_CHECK(expression, e) \
    if (! (expression) );
#define BOOST_UBLAS_CHECK_EX(expression, file, line, e) \
    if (! (expression) );

These should change to
#define BOOST_UBLAS_CHECK(expression, e)
#define BOOST_UBLAS_CHECK_EX(expression, file, line, e)

I will commit changes do future releases and Boost_1.33.1 will be fixed.

Michael Stevens Systems Engineering
34128 Kassel, Germany
Phone/Fax: +49 561 5218038
Navigation Systems, Estimation  and
                 Bayesian Filtering