I am trying to understand how to manipulate Eigen Vector/Matrix. I would like to implement a least-square gauss-newton algorithm (hence why I am learning to use the Eigen library). I have a 1x6 vectors of parameters that I need to update each iteration. Right now, I just want to figure out how a function can take a vector as argument and change its values...
Eigen::VectorXf betas = Eigen::VectorXf::Zero(6);
void SomeFunc(const Eigen::VectorXf& v){ // as per the Eigen guide, one must pass as const
v(0) = 5; // error: expression must be a modifiable lvalue
return;
}
int main()
{
betas(5) = 5.f; // works
SomeFunc(&betas);
std::cout << "Hello World" << std::endl;
std::cout << betas(0) << "\t" << betas(5) << std::endl;
}
My question is: How would you make a function take a vector and modify its values?
Edit: Eigen guide