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

triangularView of sparse matrix

Tags: None
(comma "," separated)
bgreene
Registered Member
Posts
11
Karma
0

triangularView of sparse matrix

Mon Nov 03, 2014 4:04 pm
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
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: triangularView of sparse matrix

Tue Nov 11, 2014 9:15 pm
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?
bgreene
Registered Member
Posts
11
Karma
0

Re: triangularView of sparse matrix

Fri Nov 14, 2014 1:24 am
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
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
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.
bgreene
Registered Member
Posts
11
Karma
0

Re: triangularView of sparse matrix

Fri Nov 14, 2014 1:40 pm
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


Bookmarks



Who is online

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