This forum has been archived. All content is frozen. Please use KDE Discuss instead.

QR on a binary sparse matrix

Tags: None
(comma "," separated)
timocafe
Registered Member
Posts
1
Karma
0

QR on a binary sparse matrix

Wed Jun 13, 2018 11:34 am
Hello,

I have to determine the rank on a sparse binary matrix. My strategy was to perform a QR decomposition and get the rank of R.
I review a few library and Eigen look like a good alternative. I write the tiny example. Eigen look likes accept binary matrix.

Code: Select all
    int m = 5;  // number of row cols
    // Assembly:
    std::vector<T> coefficients;            // list of non-zeros coefficients
    coefficients.push_back(T(0,1,true));
    coefficients.push_back(T(2,1,true));
    coefficients.push_back(T(1,1,true));
    coefficients.push_back(T(2,2,true));
    SpMat A(m,m); // create my matrix
    A.setFromTriplets(coefficients.begin(), coefficients.end()); // fill up
    A.makeCompressed(); // move to CSR format
    Eigen::SparseQR<Eigen::SparseMatrix<bool>, Eigen::COLAMDOrdering<int> > QR(A); // create the solver and compute, perform PxA=QxRxP
    auto i = QR.info(); // does it work
    auto Q = QR.matrixQ(); // get Q
    auto R = QR.matrixR()*QR.colsPermutation().inverse(); // get R, due to the solver


At this point I am glue, how can I get the rank of R ? QR.rank() return 5 but R has only two columns with number
differents from 0, so rank should be 2.

Any suggestions ?

Best,

Tim

ps: from the doc is unclear if Eigen can perform linear algebra on sparse binary matrix. If somebody
know an alternative, please share, thank you !


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]