This question was asked in haste. The error in my original program, was not the typo in the code that is displayed here. The error was that in my program v was not getting populated due to some conditions.
The more useful takeaway from this thread is the demonstration of copying a std::vector to all rows or columns of an Eigen Matrix, in the accepted answer.
I want to copy vectors into the columns of a matrix, like the following:
#include <Eigen/Dense>
#include <vector>
#include <iostream>
int main() {
int m = 10;
std::vector<Eigen::VectorXd> v(m);
Eigen::MatrixXd S(m,m);
for (int i = 0; i != m; ++i) {
v[i].resize(m);
for (int j = 0; j != m; ++j) {
v[i](j) = rand() % m;
}
//S.cols(i) = v[i]; //needed something like this
}
return 0;
}
S is of type Eigen::MatrixXd and dimension mxm. v is a std::vector of Eigen::VectorXd, where each Eigen::VectorXd is of size m and there are m of them in v.