Eliminating use of for loop with Eigen

I am trying to build a row vector and column vector using Eigen library to multiply them together to get a matrix without a use of for loop.

Original code:
1
2
3
4
5
6
7
8
9
10
11
12
static const int ny = 10; 
std::vector<double> ygl(ny+1);

Eigen::Matrix< double, ny+1, ny+1> dv; 
dv.setZero();

 for (int i = 0; i < ny+1; i++){
		for (int j = 0; j < ny+1; j++){
			ygl[j] = -1. * cos(((j) * EIGEN_PI )/ny);
			dv(j + ny*i) =   sin(acos(ygl[j]) * (i)); 
		}
	}

where ygl and sin(acos(ygl[j]) are column vectors.
what I tried doing is rewrite the row vector using Eigen as the following:
1
2
3
Eigen::Matrix< double, 1, ny+1> v1  ; 
v1.setZero();
std::iota(v1.begin(), v1.end(), 0);

but I don't know how to write this expression using Eigen:
sin(acos(ygl[j])
Hope this is clear, I am trying to figure things out with Eigen.
Topic archived. No new replies allowed.