Boost logo

Ublas :

Subject: Re: [ublas] bug on compressed_matrix ?
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2013-01-16 12:27:18


Hoang Giang Bui wrote:
> After fill I tried to print out the values of index1_data and
> index2_data and observe different results with the inputs.
> [...]
> In this case, which should be the reason for such behaviour?

You probably have a wrong expectation with respect to the member functions "index1_data()" and "index2_data()". The member functions "filled1()" and "filled2()" could help clear the confusion.

Your expectation is probably
P. index1_data().size() == P.filled1()
P. index2_data().size() == P.filled2()
but this is false.

I suggest you replace
    std::copy(P.index1_data().begin(), P.index1_data().end(), std::ostream_iterator<int>(std::cout, " "));
by
    std::copy(P.index1_data().begin(),P.index1_data().begin()+P.filled1(), std::ostream_iterator<int>(std::cout, " "));
and similarly for index2_data. Perhaps this will improve the match between your expectations and the actual results.

Regards,
Thomas