Registered Member
|
Hi everyone
I am doing a project using OpenCV and Eigen and in a specific part I have to do a concatenation of sparse matrices. I saw in the forum that this question has already been asked and some solutions have been proposed: - The first one uses middleCols and middleRows to insert the new block but I cannot use this since I have to do vertical and horizontal concatenation in the same matrix. - The other one get the concatenation using SparseMatrix<float>::InnerIterator, but it is slow and I need faster ways to do it. P.D. If it helps, I should obtain at the end something like [SparseMatrix A, (zeros) ; (zeros), SparseMatrix B] given A and B. Any suggestion? Thanks! |
Moderator
|
Currently the best is to do it by hand through a call to reserve(A.nonZeros()+B.nonZeros()) and a iterations over the non-zeros of A (and then B) and calls to insert(it.index()+offset_i,j+offset_j) = it.value() for the insertion. This will translate to fast "push-back".
|
Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient