Registered Member
|
Hi,
I would like to solve a sparse KKT system of the form Ax=b, where A is a sparse block matrix in the form A=[B C^T;C 0]. I already have the B and C matrices stored in the form of independent std::vector<Eigen::Triplet<double>>. What is the most efficient way to assemble A? Of course I could create a new std::vector with all the triplets, but I would like to avoid the copy of the existing vectors of triplets into a new vector (for efficiency). I've looked in the documentation, and it seems that I cannot call the SparseMatrix::setFromTriplets method more than once, because the content of the sparse matrix is cleared after each call. Any suggestion? Thank you! |
Moderator
|
You can copy B to A, call A.conservativeResize(...), and then call A.reserve(...) [1] with a vector containing the number of nonzeros for each column of C followed by the number of nonzeros for each row of C, and then call A.bottomLeftCorner(...) = C, and A.topRightCorner(...)=C^T.
[1] http://eigen.tuxfamily.org/dox/classEig ... f2487fb596 |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell