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

using Vector3d as parameter, VS2013 Update 2 compile error

Tags: None
(comma "," separated)
rhauck
Registered Member
Posts
4
Karma
0
Hi all

I have a problem when using Vector3d as parameters. I recently upgraded to Update 2 of VS2013, an now the following code doens't compile anymore. What's wrong with it?

I have something like this:

Code: Select all
int getPosition(Eigen::Ref<Eigen::Vector3d> position, int device = 0)


and call it like that:

Code: Select all
Eigen::Vector3d pos(0.0,0.0,0.0);
_hapticDevice[i]->getPosition(pos);


Until now it worked, but Update 2 gives me the following error:
error C2664: 'int HapticDevices::GenericHapticDevice::getPosition(Eigen::Ref<Eigen::VectorXd,0,Eigen::InnerStride<1>>,int)' : cannot convert argument 1 from 'Eigen::Vector3d' to 'Eigen::Ref<Eigen::VectorXd,0,Eigen::InnerStride<1>>'

It looks like I have to change pos somehow, but I don't now how. Can someone please help me? It is surely a small thing, but I don't get it...

Thanks,
Bob
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
hm, it seems that they introduced some regression. Works for me with clang, gcc, and icc:
Code: Select all
#include <Eigen/Core>
using namespace Eigen;

int getPosition(Eigen::Ref<Eigen::Vector3d> position, int device = 0)
{
  return 1;
}

int main()
{
  Eigen::Vector3d pos(0.0,0.0,0.0);
  return getPosition(pos);
}


In doubt, make sure you have the latest version of Eigen.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
hm, the compilation error is talking about a "Ref<VectorXd...>" while your code is showing a "Ref<Vector3d...>".
rhauck
Registered Member
Posts
4
Karma
0
Hi, thanks for the answer, the VectorXd is from another try, but didn't help. It should be Vector3d.

I just copy pasted your code, gives me the exact same error (just to be sure), and I'm using the latest Eigen, 3.2.1.

What about using just something like

Code: Select all
int getPosition(Eigen::Vector3d &position, int device = 0)


What's the disadvantage of this?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
For small vectors like this, there is no disadvantage. Ref<> is useful to pass sub-vectors or sub-matrices to functions without copies while avoiding the need for templates.
rhauck
Registered Member
Posts
4
Karma
0
Ok, because when not using Refs, it compiles. So could this be a problem with Eigen or the VC compiler? Should I open a bug report?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
There is an implicit constructor of Ref<> from a DenseBase object, and Vector3f inherits DenseBase, so I think this is a VC issue.


Bookmarks



Who is online

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