Boost logo

Ublas :

Subject: Re: [ublas] Troubles with triangular matrix - vector product
From: Oswin Krause (Oswin.Krause_at_[hidden])
Date: 2012-10-06 03:27:58


Hi,

i wonder why this works at all. it shouldn't - even if it does compile,
results should be garbage or crash.

typically calls to trmv assume a dense triangular matrix format(e.g.
the lower part of a blas::matrix, ignoring the upper part completely),
while banded matrices are storing their results in a space efficient
packed format.

Also your construction of the banded matrix looks strange. according to
the documentation it says:

"banded_matrix (size_type size1, size_type size2, size_type lower = 0,
size_type upper = 0)

Allocates an uninitialized banded_matrix that holds (lower + 1 + upper)
diagonals around the main diagonal of a matrix with size1 rows of size2
elements."

so you say there is a 1000x1000 matrix with 1000 upper diagonals and 1
main diagonal. which would imply a 1001 dimensional matrix. Off by one
:)

Greetings,
Oswin

On 2012-10-06 00:57, Florent Teichteil wrote:
> Hi,
>
> I'm trying to multiply a triangular matrix adapted from a banded
> matrix, by a vector.
> I'm using the latest blas bindings from boost sandbox.
>
> First problem: it seems that the boost::numeric::bindings::trans
> function does not work properly with triangular matrices.
> For instance, the following piece of code correctly compiles, but
> makes the backend BLAS library generate a runtime error (with ATLAS
> backend, I get "On entry to DTRMV parameter number 6 had an illegal
> value"):
>
> #include <boost/numeric/bindings/ublas.hpp>
> #include <boost/numeric/bindings/blas.hpp>
> #include <boost/numeric/bindings/trans.hpp>
> using namespace boost::numeric::ublas;
>
> int main () {
> banded_matrix<double, column_major> m(1000, 1000, 1, 1000);
> triangular_adaptor<banded_matrix<double, column_major>, upper>
> mT(m);
> vector<double> v(1000);
>
> boost::numeric::bindings::blas::trmv(boost::numeric::bindings::trans(mT),
> v);
> return 0;
> }
>
> If we do not transpose mT in the previous code, it executes
> correctly.
> (By the way, I am not sure that boost::numeric::bindings::trans does
> not change the transpose tag of mT for the next operations, since it
> looks like it modified some internal tags of mT)
>
>
> Second (independent) problem: it seems that we can not use trmv in
> conjunction with column-major matrix proxies. The following code does
> not compile:
>
> #include <boost/numeric/bindings/ublas.hpp>
> #include <boost/numeric/bindings/blas.hpp>
> #include <boost/numeric/bindings/trans.hpp>
> using namespace boost::numeric::ublas;
>
> int main () {
> banded_matrix<double, column_major> m(1000, 1000, 1, 1000);
> matrix_range<banded_matrix<double, column_major> > mR = project(m,
> range(100, 1000), range(100, 1000));
> triangular_adaptor<matrix_range<banded_matrix<double, column_major>
>>, upper> mT(mR);
> vector<double> v(900);
> boost::numeric::bindings::blas::trmv(mT, v);
> return 0;
> }
>
> Yet, if we replace all occurrences of column_major by row_major in
> the
> previous program, then it compiles correctly. It's really related to
> using matrix proxies AND trmv, because the code compiles either if we
> remove the the use of mR (see 1st program of the e-mail) or if we
> remove the call to trmv.
>
> Does it sound like bugs in the numeric bindings, or am I missing
> something?
>
> Cheers,
> Florent
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: Oswin.Krause_at_[hidden]