Reputation: 17468
I want to define a VectorXd
array in Eigen
, the following are my code
void function(VectorXd * b, ...)
{
[snippet]
vector<VectorXd(b->rows())> xs(max_iter+1);
[snippet]
}
So, I want to define an array whose length is max_iter+1
and every element in the array is a 3X1
VectorXd.
But when it was compiled, it returned the following error:
/path/to/solutions.h:187: error: invalid type in declaration before '(' token
vector<VectorXd(b->rows())> xs(max_iter+1);
^
/path/to/solutions.h:187: error: 'b' cannot appear in a constant-expression
vector<VectorXd(b->rows())> xs(max_iter+1);
^
What shoud I do to fix these bugs? Thank you!
Upvotes: 2
Views: 1201
Reputation: 9781
When you work on std::vector
of int
, you use
std::vector<int> xs(size, init_value);
Similarly, it should be something like this when you work on std::vector
of VectorXd
.
std::vector<VectorXd> xs(max_iter+1, VectorXd(b->rows()));
It has to be a type name between < >
, but you use an object VectorXd(b->rows())
.
Upvotes: 2