![]() Registered Member ![]()
|
Hi,
I'm using Eigen 3.2.2 and would like to access the lower triangle of a sparse matrix without making a copy. If I do, const Eigen::SparseMatrix<double> &aLower = a.triangularView<Eigen::Lower>(); everything works fine but I believe a new sparse matrix is being created. Since I am using C++11, I simply replaced the line above with auto aLower = a.triangularView<Eigen::Lower>(); However, when the line: size_t n = aLower.nonZeros(); is executed, the code goes into an infinite loop and eventually crashes when it exceeds the maximum number of stack frames. Can someone please tell me how to correctly access the lower triangle without making a copy? Thanks. Bill |
![]() Moderator ![]()
|
This line is correct:
auto aLower = a.triangularView<Eigen::Lower>(); The problem is that nonZeros() is not implemented for sparse TriangularView: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=875 The sparse TriangularView was designed to leverage triangular solve only, as accessing the triangular part of a sparse matrix for other purposes does not seems to be very useful. Could you comment a bit on your use case? |
![]() Registered Member ![]()
|
I am basically trying to convert an Eigen sparse matrix into a form acceptable to MUMPS.
I know that the matrix is symmetric and that MUMPS requires a triplet form so I just want to iterate over 1/2 the entries and generate new triplets. Thanks. Bill |
![]() Moderator ![]()
|
I see, then tri_NNZ can be inferred from the global NNZ: tri_NNZ = (NNZ+N)/2 where N is the number of rows/columns.
|
![]() Registered Member ![]()
|
OK, thanks. Yes, I can easily compute NNZ myself.
But one of the reasons I posted was that the crash I encountered seems unfortunate. But a fix wasn't obvious to me from looking at the triangularView<> implementation. Bill |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]