Boost logo

Ublas :

Subject: Re: [ublas] [BLAS bindings] help appreciated on using trmv and gbmv
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2012-10-10 08:14:37

On 2012-10-10 09:38, Florent Teichteil wrote:
> Indeed, if I clear B before filling it, I get correct results with row
> major storage, but not with column major. Am I doing something wrong?
> Moreover, I thought that banded matrices only store data within the
> bands, so I don't understand why I have to clear B before filling only
> the bands.

Your code doesn't fill anything in the first row of your matrices. I
guess you should look into what the following does in C++:

std::size_t i = 0;
std::cout << (i-1) << std::endl;

This wasn't your only bug: please debug your code before coming to us.

> This is the more confusing part. The bindings for triangular matrices
> work only with triangular adaptors of dense matrices (not with
> triangular matrices), but the bindings for banded matrices work only
> with banded matrices (not with banded adaptors of dense matrices).
> Moreover, depending on the context, incompatible bindings silently
> compile or don't compile. At the end, as an end-user of the API, it is
> quite difficult to distinguish safe operations from insane ones. Perhaps
> some doxygen comments in the code would help programmers know what is
> allowed or not?

Of course, the bindings can assert for these cases, we can add the
following support:

  * add static asserts on data_structure w.r.t. the routine called
(i.e., BOOST_STATIC_ASSERT( (has_band_array<MatrixA>::..) )).
has_band_array is already available.
  * add support for banded matrices in the bindings::trans() function
  * check if/when a stride_major_op() and related functions are required
  * test the above.

Unfortunately, I already spent valuable time on debugging your code. If
your code would have been correct to begin with, maybe I could have used
that time for adding the items above.