1

Here is what I currently have. mat is a vector of vectors, and temp is a vector. The sizes of these two vectors are determined during runtime. I tried to declare a dynamic Eigen vector/matrix, but I don't know how to pass my current vectors in.

MatrixXf A(size, size);
VectorXf b(size);

for(int j = 0; j < size; j++)
{
    b << temp[j];
    for(int k = 0; k < size; k++)
        A << mat[j][k];
    cout << temp[j];
}
  • What is the line b << temp[j] supposed to do? And similarly for the line with A << mat[j][k]. Are you trying to assign values to A and b? And what does your code have to do with eigenvectors? – Jim Vargo Dec 14 '15 at 23:17
  • @JimVargo Right. I'm trying to assign what I already have in the vectors to eigen vectors/matrices. After this assignment the code will solve the matrix, but I don't think that is relevant to this specific assignment problem. –  Dec 14 '15 at 23:19
  • @JimVargo `eigen` is a library for linear algebra. That's how they assign their vector/matrix variables. http://eigen.tuxfamily.org/index.php?title=Main_Page#Documentation – beaker Dec 14 '15 at 23:26
  • @user502144 well that question is about vector, but mine involves matrix as well –  Dec 14 '15 at 23:43
  • Are you sure that you need to use vector of vectors for `mat`? Using vector of length `size*size` for `mat` will make things much simpler. – fdermishin Dec 14 '15 at 23:54
  • It's not clear in your question whether the code you have shown actually works. Does it work? Are you looking for a more tidy solution? – paddy Dec 14 '15 at 23:56
  • In any case, the question has been asked already: http://stackoverflow.com/questions/18839240/initialize-an-eigenmatrixxd-from-a-2d-stdvector – fdermishin Dec 14 '15 at 23:57
  • @user502144 Thx. I solved this problem with python. –  Dec 15 '15 at 00:32

0 Answers0