bug on compressed_matrix ?

Hoang Giang Bui <[email protected]>
Newsgroups gmane.comp.lib.boost.ublas
Message-ID <CAJW_hKe34gZ0m9OABLNfkRqZ-oqHO-T3E4O-asc=zYBT4_Dw_A@mail.gmail.com>
Hello

Please take a look on the example indicating a false behaviour of
compressed_matrix of ublas. In this example, I tried to fill a
compressed_matrix by given row pointers and column indices. The matrix has
dimension of 186x20 and contains 141 entries.

After fill I tried to print out the values of index1_data and index2_data
and observe different results with the inputs. The last component of
index1_data is zero which is not correct since compressed format require it
to be nnz. Furthermore, the index2_data vector is also longer than the
initial column pointers.

I don't think my algorithm to fill the matrix is wrong. In this case, which
should be the reason for such behaviour?

BR
Giang Bui

_______________________________________________
ublas mailing list
[email protected]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [email protected]
test_compressed_matrix.cpp (text/x-c++src, 1.8 KB)
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>


int main()
{
    using namespace boost::numeric::ublas;

    int pp[] = {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};

    int pi[] = {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};

    compressed_matrix<double> P(186, 20);
    
    for(int i = 0; i < 186; i++)
    {
        for(int j = pp[i]; j < pp[i+1]; j++)
        {
            P(i, pi[j]) = 1.00;
        }
    }
    
    std::cout << "index1_data:" << std::endl;
    std::copy(P.index1_data().begin(), P.index1_data().end(), std::ostream_iterator<int>(std::cout, " "));
    std::cout << std::endl;
    
    std::cout << "index2_data:" << std::endl;
    std::copy(P.index2_data().begin(), P.index2_data().end(), std::ostream_iterator<int>(std::cout, " "));
    std::cout << std::endl;
    std::cout << P.index2_data().size() << std::endl;
    
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.