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

Basic BandMatrix question (Eigen3)

Tags: None
(comma "," separated)
lmdevries
Registered Member
Posts
2
Karma
0
OS

Basic BandMatrix question (Eigen3)

Fri Jul 02, 2010 10:18 am
Hi,

How can I access the elements of a BandMatrix? The following does not work:

Code: Select all
BandMatrix<double> myMatrix(5,5,1,1);
myMatrix(1,1) = 2.2;


And how can I initialize the banded matrix?

Thanks for your help.

Luis Manuel
User avatar
bjacob
Registered Member
Posts
658
Karma
3
When you have a bandMatrix, the only way to address it is by addressing its (sub/super-)diagonals, with the diagonal(index) method, which returns a normal expression that you can initialize in the usual ways.

Code: Select all
myMatrix.diagonal(1).setZero(); // fill first super-diagonal with zeros
myMatrix.diagonal(-1).setConstant(2); // fill first super-diagonal with twos
myMatrix.diagonal(0) = somevector
myMatrix.diagonal(1)(2) = 5; // write 5 as position 2 into the 1st superdiagonal


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
lmdevries
Registered Member
Posts
2
Karma
0
OS
Ok, not what I was hoping for, but it does provide a way to access the elements.

Thanks for the quick reply,

Saludos,

Luis Manuel


Bookmarks



Who is online

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