我有一个std::vector,我想将其转换为arma::rowvec。
我已经完成了以下操作:
vector<int> x = foo();
rowvec a;
vector<int>::const_iterator iter2;
int j = 0;
for(iter2 = x.begin(); iter2 != x.end(); ++iter2) {
a(j++,0) = *iter2;
}
a.print("a");
但是我得到了:
error: Mat::operator(): out of bounds
terminate called after throwing an instance of 'std::logic_error'
what():
如果我在最后的rowvec中使用 a << *iter2;
而不是 a(j++,0) = *iter2;
,我只得到了最后一个元素。