Boost logo

Ublas :

Subject: Re: [ublas] bug on compressed_matrix ?
From: Hoang Giang Bui (hgbk2008_at_[hidden])
Date: 2013-01-16 12:37:45


On 01/16/13 18:27, Thomas Klimpel wrote:
> 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
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: hgbk2008_at_[hidden]

Yes, the result is improved but it missed the last element. The matrix
has the last row is zero, therefore there should be another entry 141 in
the inde1_data vector. In fact, I expected P. index1_data().size() =187
and it was correct, just the last entry of P.index1_data() is wrong.

index1_data:
0 0 1 2 2 3 4 5 6 7 8 9 10 10 10 11 11 11 12 13 14 15 16 17 18 19 19 20
21 22 22 23 24 25 26 27 28 29 29 30 31 31 32 33 34 35 36 36 36 37 38 39
40 41 42 43 44 45 46 46 47 48 49 50 51 52 53 54 54 55 56 56 57 58 59 60
60 61 62 63 64 65 66 67 68 69 70 71 72 73 73 74 75 75 75 76 77 77 78 79
80 81 82 83 83 84 85 86 87 88 88 89 90 90 90 91 91 91 92 93 94 95 96 97
98 99 100 101 102 103 103 104 105 105 106 107 107 108 109 110 111 112
113 113 114 114 115 116 117 118 119 120 121 122 123 124 125 126 127 127
128 128 128 129 130 131 132 133 133 134 134 135 136 136 136 136 137 137
137 137 138 139 140 140 140 141

index2_data:
0 0 1 0 0 1 0 0 0 0 1 1 9 1 12 3 5 0 1 8 1 2 3 4 5 1 5 5 11 6 4 1 6 12 7
7 5 1 1 12 12 6 7 1 7 8 13 7 7 6 14 9 12 5 10 16 15 11 12 7 5 5 6 7 1 14
12 5 5 5 12 14 14 10 13 6 8 17 16 6 14 19 12 12 12 5 15 11 5 16 16 17 12
12 6 7 19 12 6 12 14 14 14 18 13 18 14 19 19 17 16 19 12 16 16 17 17 17
16 17 12 17 16 12 14 16 18 19 19 19 19 19 19 14 17 17 19 19 19 19 19

original index1:

{0,0,1,2,2,3,4,5,6,7,8,9,10,10,10,11,11,11,12,13,14,15,16,17,18,19,19,20,21,22,
22,23,24,25,26,27,28,29,29,30,31,31,32,33,34,35,36,36,36,37,38,39,40,41,42,43,
44,45,46,46,47,48,49,50,51,52,53,54,54,55,56,56,57,58,59,60,60,61,62,63,64,65,
66,67,68,69,70,71,72,73,73,74,75,75,75,76,77,77,78,79,80,81,82,83,83,84,85,86,
87,88,88,89,90,90,90,91,91,91,92,93,94,95,96,97,98,99,100,101,102,103,103,104,
105,105,106,107,107,108,109,110,111,112,113,113,114,114,115,116,117,118,119,120,
121,122,123,124,125,126,127,127,128,128,128,129,130,131,132,133,133,134,134,135,
         136,136,136,136,137,137,137,137,138,139,140,140,140,141, "141" };