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

Passing Blocks to Functions that take Matrices

Tags: None
(comma "," separated)
pogon
Registered Member
Posts
1
Karma
0
Hi,

I'm new to Eigen and template programming, hope you can help me out with this one:

the function is:
Code: Select all
step(VectorXf &input);


and I do:
Code: Select all
step(trainsample.row(i));


The compiler complains:
no matching function for call to ‘step(Eigen::Block<Eigen::Matrix<float, -0x00000000000000001, 1, 0, -0x00000000000000001, 1>, 1, 1, true>)’

Trainsample is a VectorXf, so in my understanding the i'th row of it should be a VectorXf of length 1.

I'm using the 3.0beta1 of Eigen.

Cheers,
Victor

Edit: I think I found the reason why this does not work: viewtopic.php?f=74&t=88577&p=161739&hilit=segment#p161739

The solution is to declare input as const
User avatar
bjacob
Registered Member
Posts
658
Karma
3
If you're OK with your block being passed as const and you're OK with the block expression being evaluated into a temporary, then yes you can do just a const matrix reference.

Otherwise, the issue is that a block isn't a Matrix, it's a MatrixBase<T>. This question has been answered several times already, see also
http://eigen.tuxfamily.org/dox-devel/To ... Types.html
(but this page is for Eigen 3. For eigen 2, you want MatrixBase, not DenseBase.).


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!


Bookmarks



Who is online

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