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

How to copy the upper triangular part of a sparse matrix

Tags: None
(comma "," separated)
flyfan
Registered Member
Posts
15
Karma
0
Is there a way to copy the upper triangular part of a sparse martix to the lower part just by calling function without any extra expenses?

Sparse double matrix A and B are symmetrical, and sparse complex matrix C= A*j-B*(1.0+j), where j is imaginary unite. I want to only store upper part of A and B to save memory since the nonezero number of A and B is about 600 thousand. Matrix C is complex which isn't self-adjoint, I cannot only use the upper part of C to calculate.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
I'm not sure to clearly understand what you want to achieve, but this should help, assuming sym is sparse lower triangular (the upper triangular part is empty), then you can do stuff like:

SparseMatrix<double> full = sym.selfadjointView<Lower>();
SparseMatrix<double> upper = sym.transpose();
SparseMatrix<double> upper2 = full.triangularView<Lower>().transpose();
flyfan
Registered Member
Posts
15
Karma
0
ggael wrote:I'm not sure to clearly understand what you want to achieve, but this should help, assuming sym is sparse lower triangular (the upper triangular part is empty), then you can do stuff like:

SparseMatrix<double> full = sym.selfadjointView<Lower>();
SparseMatrix<double> upper = sym.transpose();
SparseMatrix<double> upper2 = full.triangularView<Lower>().transpose();


Thaks for your attention!

I want to copy data from the upper part of a sparse complex matrix and not to get a self adjoint conjugate matrix. so for a sprase double matrix full = sym.selfadjointView<Lower>() will meet expectations. But for a sparse complex matrix, the function can not meet my requirements .

I am looking forward your reply again. Thanks.


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]