0

I want to create a column vector of size 6 using the Eigen Library. I have done this before for Vectors of size 3 using Eigen::Vector3d but now that I'm using VectorXd it does not work anymore, altough I tried to just copy the example given on the Eigen website.

EDIT 1:

The minimal example does indeed work for me too @Daniel Langr so the reason might be the structure of the program. It is part of an object.

Does work:

#include <iostream>
#include ../../eigen/Eigen/Dense

using Eigen::Vector3d;
using Eigen::VectorXd;
using namespace std;

int main()
{
    Vector3d vec1;
    vec1 << 1, 2, 3;
    cout << vec1 << endl;

    VectorXd vec2(6);
    vec2 << 1, 2, 3, 4, 5, 6;
    cout << vec2 << endl;
}

Does not work:

#include <iostream>
#include "../../eigen/Eigen/Dense"

using Eigen::Vector3d;
using Eigen::VectorXd;
using namespace std;

class Controller
{
  public:
    Vector3d vec1;
    VectorXd vec2(6);

    Controller()
    {
      vec1 << 1, 2, 3;
      cout << "vec1 = " << vec1 << endl;
      vec2 << 1, 2, 3, 4, 5, 6;
      cout << "vec2 = " << vec2 << endl;
    }
}

int main(int argc, char * argv[])
{
  Controller* c = new Controller();
  return 0;
}
le_lemon
  • 107
  • 1
  • 11

0 Answers0