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

Return values from tridiagonalization

Tags: None
(comma "," separated)
ET3D
Registered Member
Posts
3
Karma
0
I'm new to Eigen and my first attempt is to tridiagonalise a matrix. I defined:

Tridiagonalization<MatrixType> tri(m);

where MatrixType is Matrix<complex<float>, 5, 5>.

I then want to assign the result of tri.diagonal() or tri.matrixT() to a reference variable:

DiagonalReturnType & diag = tri.diagonal();
MatrixTReturnType & matT = tri.matrixT();

Looks simple enough except I have no idea what I need to write as the return types. Nothing I tried works.

I'll be grateful for some help. Thanks.
ET3D
Registered Member
Posts
3
Karma
0
Found out that for diagonal() the return value is Diagonal<const MatrixType>::RealReturnType and for subDiagonal() it's Diagonal<Block<const MatrixType ,4,4>>. A little messy. For matrixT() it's too complex and I haven't tried to use it.
jitseniesen
Registered Member
Posts
204
Karma
2
You can also write

Tridiagonalization<MatrixType>::DiagonalReturnType diag = tri.diagonal();
Tridiagonalization<MatrixType>::MatrixTReturnType matT = tri.matrixT();

Another possibility is

Vector<float,5> diag = tri.diagonal();
Matrix<float,5,5> matT = tri.matrixT();

This uses that MatrixType is Matrix<complex<float>, 5, 5>.

There is a difference between these two possibilities. In the first possibility, diag and matT are light-weight objects that act as a reference to the information stored in tri. They become invalid if the tri-diagonalization gets recomputed or deleted. The second block of code constructs a new vector / matrix and copies the coefficients in the newly constructed vector / matrix, so there is some overhead (both time and memory) involved.
ET3D
Registered Member
Posts
3
Karma
0
Thanks a lot. That's exactly what I needed.


Bookmarks



Who is online

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