I'm C++ Newbie.
I made a function that generates Matrix using Eigen library, but I can't return it.
The code is long, but it won't be difficult for you to understand.
How to write functions returning Eigen types?
Also, I would appreciate it if you could tell me how to return the vector by calling it as a function.
Thanks all
int Design(int x ,int y) { MatrixXd A = MatrixXd(x, y); for (int row = 0; row < x; row++) { for (int col = 0; col < y; col++) { A(row, col) = 7; if (row % 2 == 0) { A(row, 0) = 1; if (col % 2 == 0) { A(row, 1) = 0; A(row, 3) = 0; } A(row, 5) = 0; if (col == 2) **{ A(row, 2) = -(row + 1) * 0.2; } if (col == 4) { A(row, 4) = (row + 1) * 0.3; } } if (row % 2 == 1) { A(row, 1) = 1; if (col % 2 == 1) { A(row, 0) = 0; A(row, 2) = 0; A(row, 4) = 0; } if (col == 5) { A(row, 5) = row * 0.2; } if (col == 3) { A(row, 3) = row * 0.3; } } } } return A; //error } https://stackoverflow.com/questions/66539386/how-to-write-functions-returning-eigen-types March 09, 2021 at 09:08AM
没有评论:
发表评论