I am getting crazy with this seemingly simple question. I am translating code from Matlab to C++ with Eigen. In Matlab I have something like this:
v1 = zeros(100,1);
a=2;
b=5;
c=4;
v2 = [100 0.2 30 41 55];
v1(a:b:a+b*c) = v2;
In this way I set only the elements of v1 starting from a to a+b*c and equally spaced with b. The other elements are left unchanged. In Eigen, I currently solved with a for loop:
VectorXf v1 = VectorXf::Zero(100);
int a = 2;
int b = 5;
int c = 4;
VectorXf v2(5);
v2 << 100, 0.2, 30, 41, 55;
for (int i = 0; i < v2.size(); i++)
{
v1(a-1+b*i) = v2(i);
}
I am looking for a way to do this without a loop. Is it possible? I have searched a lot without finding anything. Thank you very much.