Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2006-05-16 04:48:07


Thomas Lemaire schrieb:
> Dear list,
>
> Here is a sample code:
>
> void test() {
> ublas::matrix<double> M(4,4);
> ublas::matrix_vector_range<ublas::matrix<double> > t(M,
> ublas::range(0,3), ublas::range(3,4));
> std::cout << t;
> };
>
> which I compile _whithout_ -DNDEBUG, execution gives:
>
> Assertion failed in file /usr/include/boost/numeric/ublas/matrix_proxy.hpp at
> line 970:
> size1 == size2
> ** std::exception: **
> bad argument
>
> looking at the test which triggers this exception:
>
> size_type size () const {
> return BOOST_UBLAS_SAME (r1_.size (), r2_.size ());
> }
>
> r1_ and r2_ are the two ranges, for me (0,3) and (3,4) which are not of the
> same size. Why must these ranges be the same size ? Maybe I have
> misunderstood the doc and the matrix_vector_range concept... I want a
> sub-vector of the 3 first elements of the last column of M.
matrix_vector_range is a very strange part of the matrix:

It is vector of k elements along a diagonal of the matrix, thus the
ranges have to have equal size. It is not a sub matrix.

You should try
project( column(M, i), range(0,3) )
or
vector_range<matrix_column<matrix> > r( column(M, i), range(0,3) ); //
not tested

mfg
Gunter